-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5ecd1ef
commit c982159
Showing
19 changed files
with
241 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# expo-webauthn | ||
|
||
webauthn polyfill for expo | ||
|
||
## usage | ||
|
||
```ts | ||
import "expo-webauthn"; | ||
|
||
// use navigator.credentials (https://www.w3.org/TR/webauthn-3/) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
apply plugin: "com.android.library" | ||
apply plugin: "kotlin-android" | ||
apply plugin: "maven-publish" | ||
|
||
group = "expo.modules.webauthn" | ||
version = "0.1.0" | ||
|
||
buildscript { | ||
def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle") | ||
if (expoModulesCorePlugin.exists()) { | ||
apply from: expoModulesCorePlugin | ||
applyKotlinExpoModulesCorePlugin() | ||
} | ||
|
||
ext.safeExtGet = { prop, fallback -> | ||
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback | ||
} | ||
|
||
ext.getKotlinVersion = { | ||
if (ext.has("kotlinVersion")) { | ||
ext.kotlinVersion() | ||
} else { | ||
ext.safeExtGet("kotlinVersion", "1.8.10") | ||
} | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${getKotlinVersion()}") | ||
} | ||
} | ||
|
||
afterEvaluate { | ||
publishing { | ||
publications { | ||
release(MavenPublication) { | ||
from components.release | ||
} | ||
} | ||
repositories { | ||
maven { | ||
url = mavenLocal().url | ||
} | ||
} | ||
} | ||
} | ||
|
||
android { | ||
compileSdkVersion safeExtGet("compileSdkVersion", 34) | ||
|
||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_11 | ||
targetCompatibility JavaVersion.VERSION_11 | ||
} | ||
|
||
kotlinOptions { | ||
jvmTarget = JavaVersion.VERSION_11.majorVersion | ||
} | ||
|
||
namespace "expo.modules.webauthn" | ||
defaultConfig { | ||
minSdkVersion safeExtGet("minSdkVersion", 21) | ||
targetSdkVersion safeExtGet("targetSdkVersion", 34) | ||
versionCode 1 | ||
versionName "0.1.0" | ||
} | ||
lintOptions { | ||
abortOnError false | ||
} | ||
publishing { | ||
singleVariant("release") { | ||
withSourcesJar() | ||
} | ||
} | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
implementation project(":expo-modules-core") | ||
implementation "androidx.credentials:credentials:1.2.0" | ||
implementation "androidx.credentials:credentials-play-services-auth:1.2.0" | ||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${getKotlinVersion()}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<manifest package="expo.modules.webauthn" xmlns:android="http://schemas.android.com/apk/res/android"> | ||
</manifest> |
10 changes: 10 additions & 0 deletions
10
webauthn/android/src/main/java/expo/modules/webauthn/ExpoWebauthn.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package expo.modules.webauthn | ||
|
||
import expo.modules.kotlin.modules.Module | ||
import expo.modules.kotlin.modules.ModuleDefinition | ||
|
||
class ExpoWebauthn : Module() { | ||
override fun definition() = ModuleDefinition { | ||
Name("ExpoWebauthn") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"platforms": ["android", "ios", "web"], | ||
"android": { | ||
"modules": ["expo.modules.webauthn.ExpoWebauthn"] | ||
}, | ||
"ios": { | ||
"modules": ["ExpoWebauthn"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
require 'json' | ||
|
||
package = JSON.parse(File.read(File.join(__dir__, '..', 'package.json'))) | ||
|
||
Pod::Spec.new do |s| | ||
s.name = 'ExpoWebauthn' | ||
s.version = package['version'] | ||
s.summary = package['description'] | ||
s.description = package['description'] | ||
s.license = package['license'] | ||
s.author = package['author'] | ||
s.homepage = package['repository']['url'] | ||
s.source = { git: package['repository']['url'] } | ||
s.platform = :ios, '13.0' | ||
s.swift_version = '5.4' | ||
s.static_framework = true | ||
|
||
s.dependency 'ExpoModulesCore' | ||
|
||
s.pod_target_xcconfig = { | ||
'DEFINES_MODULE' => 'YES', | ||
'SWIFT_COMPILATION_MODE' => 'wholemodule' | ||
} | ||
|
||
s.source_files = "**/*.{h,m,swift}" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import ExpoModulesCore | ||
|
||
public class ExpoWebauthn: Module { | ||
public func definition() -> ModuleDefinition { | ||
Name("ExpoWebauthn") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"name": "expo-webauthn", | ||
"version": "0.1.0", | ||
"license": "MIT", | ||
"description": "webauthn polyfill for expo", | ||
"author": "danilo neves cruz <[email protected]>", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/exactly/mobile.git", | ||
"directory": "webauthn" | ||
}, | ||
"scripts": { | ||
"build": "expo-module build", | ||
"clean": "expo-module clean", | ||
"lint": "expo-module lint", | ||
"test": "expo-module test", | ||
"prepare": "expo-module prepare", | ||
"prepublishOnly": "expo-module prepublishOnly" | ||
}, | ||
"workspaces": [ | ||
"example" | ||
], | ||
"dependencies": { | ||
"base64-arraybuffer": "^1.0.2", | ||
"expo-modules-core": "^1.5.11" | ||
}, | ||
"devDependencies": { | ||
"expo-module-scripts": "^3.1.0", | ||
"prettier": "^3.1.0", | ||
"typescript": "^5.2.2" | ||
}, | ||
"peerDependencies": { | ||
"expo": "*", | ||
"react": "*", | ||
"react-native": "*" | ||
}, | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { requireNativeModule } from "expo-modules-core"; | ||
|
||
export default requireNativeModule<{ | ||
create: (requestJSON: string) => Promise<string>; | ||
get(requestJSON: string): Promise<string>; | ||
}>("ExpoWebauthn"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { encode } from "base64-arraybuffer"; | ||
|
||
import ExpoWebauthn from "./ExpoWebauthn"; | ||
|
||
// @ts-expect-error -- polyfill | ||
global.navigator.credentials ??= { | ||
get(options) { | ||
if (!options?.publicKey) throw new Error("publicKey required"); | ||
return ExpoWebauthn.get(stringify(options.publicKey)); | ||
}, | ||
async create(options) { | ||
if (!options?.publicKey) throw new Error("publicKey required"); | ||
return ExpoWebauthn.create(stringify(options.publicKey)); | ||
}, | ||
} as CredentialsContainer; | ||
|
||
function stringify(value: unknown) { | ||
return JSON.stringify(value, (_, v) => { | ||
if (v instanceof ArrayBuffer) { | ||
return encode(v).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, ""); | ||
} | ||
return v as unknown; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"extends": "expo-module-scripts/tsconfig.base", | ||
"compilerOptions": { | ||
"types": ["node"], | ||
"outDir": "dist" | ||
}, | ||
"include": ["src"] | ||
} |