@turnkey/react-native-passkey-stamper 0.2.16 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/dist/index.d.ts +15 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +38 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +39 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @turnkey/react-native-passkey-stamper
|
|
2
2
|
|
|
3
|
+
## 1.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [78bc39c]
|
|
8
|
+
- @turnkey/http@2.17.0
|
|
9
|
+
|
|
10
|
+
## 1.0.0
|
|
11
|
+
|
|
12
|
+
### Major Changes
|
|
13
|
+
|
|
14
|
+
Upgrade react-native-passkey to 3.0.0 (see [release notes](https://github.com/f-23/react-native-passkey/releases/tag/v3.0.0)). Among other things you can now specify `withSecurityKey` and `withPlatformKey` (new optional arguments to `createPasskey`) to target platform passkeys or security keys on iOS. The same options can be passed as configuration to `PasskeyStamper` to target these features at authentication time.
|
|
15
|
+
|
|
16
|
+
This is a major change because the `transports` property, previously a string array (`Array<string>`) is now an array of enums (`Array<AuthenticatorTransport>`).
|
|
17
|
+
|
|
3
18
|
## 0.2.16
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -4,10 +4,18 @@ import type { TurnkeyApiTypes } from "@turnkey/http";
|
|
|
4
4
|
* Copied from https://github.com/f-23/react-native-passkey/blob/17184a1b1f6f3ac61e07aa784c9b64efb28b570e/src/Passkey.tsx#L80C1-L85C2
|
|
5
5
|
* TODO: can we import this type instead?
|
|
6
6
|
*/
|
|
7
|
-
interface PublicKeyCredentialDescriptor {
|
|
7
|
+
export interface PublicKeyCredentialDescriptor {
|
|
8
8
|
type: string;
|
|
9
9
|
id: string;
|
|
10
|
-
transports?: Array<
|
|
10
|
+
transports?: Array<AuthenticatorTransport>;
|
|
11
|
+
}
|
|
12
|
+
export declare enum AuthenticatorTransport {
|
|
13
|
+
usb = "usb",
|
|
14
|
+
nfc = "nfc",
|
|
15
|
+
ble = "ble",
|
|
16
|
+
smartCard = "smart-card",
|
|
17
|
+
hybrid = "hybrid",
|
|
18
|
+
internal = "internal"
|
|
11
19
|
}
|
|
12
20
|
/**
|
|
13
21
|
* Authenticator params expected by the Turnkey API (for authenticator, user, or sub-organization creation)
|
|
@@ -42,6 +50,8 @@ export type TPasskeyStamperConfig = {
|
|
|
42
50
|
timeout?: number;
|
|
43
51
|
userVerification?: UserVerificationRequirement;
|
|
44
52
|
allowCredentials?: PublicKeyCredentialDescriptor[];
|
|
53
|
+
withSecurityKey?: boolean;
|
|
54
|
+
withPlatformKey?: boolean;
|
|
45
55
|
extensions?: Record<string, unknown>;
|
|
46
56
|
};
|
|
47
57
|
/**
|
|
@@ -53,6 +63,7 @@ export declare function isSupported(): boolean;
|
|
|
53
63
|
*/
|
|
54
64
|
export declare function createPasskey(config: TPasskeyRegistrationConfig, options?: {
|
|
55
65
|
withSecurityKey: boolean;
|
|
66
|
+
withPlatformKey: boolean;
|
|
56
67
|
}): Promise<TurnkeyAuthenticatorParams>;
|
|
57
68
|
/**
|
|
58
69
|
* Stamper to use with `@turnkey/http`'s `TurnkeyClient`
|
|
@@ -63,11 +74,12 @@ export declare class PasskeyStamper {
|
|
|
63
74
|
userVerification: UserVerificationRequirement;
|
|
64
75
|
allowCredentials: PublicKeyCredentialDescriptor[];
|
|
65
76
|
extensions: Record<string, unknown>;
|
|
77
|
+
forcePlatformKey: boolean;
|
|
78
|
+
forceSecurityKey: boolean;
|
|
66
79
|
constructor(config: TPasskeyStamperConfig);
|
|
67
80
|
stamp(payload: string): Promise<{
|
|
68
81
|
stampHeaderName: string;
|
|
69
82
|
stampHeaderValue: string;
|
|
70
83
|
}>;
|
|
71
84
|
}
|
|
72
|
-
export {};
|
|
73
85
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAIrD;;;;GAIG;AACH,MAAM,WAAW,6BAA6B;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,CAAC,EAAE,KAAK,CAAC,sBAAsB,CAAC,CAAC;CAC5C;AAED,oBAAY,sBAAsB;IAChC,GAAG,QAAQ;IACX,GAAG,QAAQ;IACX,GAAG,QAAQ;IACX,SAAS,eAAe;IACxB,MAAM,WAAW;IACjB,QAAQ,aAAa;CACtB;AAED;;GAEG;AACH,MAAM,MAAM,0BAA0B,GACpC,eAAe,CAAC,yBAAyB,CAAC,CAAC;AAO7C,MAAM,MAAM,0BAA0B,GAAG;IAGvC,EAAE,EAAE;QACF,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IAGF,IAAI,EAAE;QACJ,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;IAIF,iBAAiB,EAAE,MAAM,CAAC;IAG1B,SAAS,CAAC,EAAE,MAAM,CAAC;IAGnB,OAAO,CAAC,EAAE,MAAM,CAAC;IAGjB,gBAAgB,CAAC,EAAE,2BAA2B,CAAC;IAG/C,kBAAkB,CAAC,EAAE,6BAA6B,EAAE,CAAC;IASrD,sBAAsB,CAAC,EAAE;QACvB,uBAAuB,CAAC,EAAE,MAAM,CAAC;QACjC,kBAAkB,CAAC,EAAE,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-passkey');
|
|
|
4
4
|
var encoding = require('@turnkey/encoding');
|
|
5
5
|
var util = require('./util.js');
|
|
6
6
|
|
|
7
|
+
exports.AuthenticatorTransport = void 0;
|
|
8
|
+
(function (AuthenticatorTransport) {
|
|
9
|
+
AuthenticatorTransport["usb"] = "usb";
|
|
10
|
+
AuthenticatorTransport["nfc"] = "nfc";
|
|
11
|
+
AuthenticatorTransport["ble"] = "ble";
|
|
12
|
+
AuthenticatorTransport["smartCard"] = "smart-card";
|
|
13
|
+
AuthenticatorTransport["hybrid"] = "hybrid";
|
|
14
|
+
AuthenticatorTransport["internal"] = "internal";
|
|
15
|
+
})(exports.AuthenticatorTransport || (exports.AuthenticatorTransport = {}));
|
|
7
16
|
/**
|
|
8
17
|
* Header name for a webauthn stamp
|
|
9
18
|
*/
|
|
@@ -21,7 +30,12 @@ function isSupported() {
|
|
|
21
30
|
*/
|
|
22
31
|
async function createPasskey(config, options) {
|
|
23
32
|
const challenge = config.challenge || util.getRandomChallenge();
|
|
24
|
-
|
|
33
|
+
let createFn = options?.withPlatformKey
|
|
34
|
+
? reactNativePasskey.Passkey.createPlatformKey
|
|
35
|
+
: options?.withSecurityKey
|
|
36
|
+
? reactNativePasskey.Passkey.createSecurityKey
|
|
37
|
+
: reactNativePasskey.Passkey.create;
|
|
38
|
+
let registrationResult = await createFn({
|
|
25
39
|
challenge: challenge,
|
|
26
40
|
rp: config.rp,
|
|
27
41
|
user: config.user,
|
|
@@ -45,7 +59,14 @@ async function createPasskey(config, options) {
|
|
|
45
59
|
alg: -257,
|
|
46
60
|
},
|
|
47
61
|
],
|
|
48
|
-
}
|
|
62
|
+
});
|
|
63
|
+
// See https://github.com/f-23/react-native-passkey/issues/54
|
|
64
|
+
// On Android the typedef lies. Registration result is actually a string!
|
|
65
|
+
// TODO: remove me once the above is resolved.
|
|
66
|
+
const brokenRegistrationResult = registrationResult;
|
|
67
|
+
if (typeof brokenRegistrationResult === "string") {
|
|
68
|
+
registrationResult = JSON.parse(brokenRegistrationResult);
|
|
69
|
+
}
|
|
49
70
|
return {
|
|
50
71
|
authenticatorName: config.authenticatorName,
|
|
51
72
|
challenge: challenge,
|
|
@@ -69,6 +90,8 @@ class PasskeyStamper {
|
|
|
69
90
|
this.userVerification = config.userVerification || defaultUserVerification;
|
|
70
91
|
this.allowCredentials = config.allowCredentials || [];
|
|
71
92
|
this.extensions = config.extensions || {};
|
|
93
|
+
this.forcePlatformKey = !!config.withPlatformKey;
|
|
94
|
+
this.forceSecurityKey = !!config.withSecurityKey;
|
|
72
95
|
}
|
|
73
96
|
async stamp(payload) {
|
|
74
97
|
const challenge = util.getChallengeFromPayload(payload);
|
|
@@ -80,7 +103,19 @@ class PasskeyStamper {
|
|
|
80
103
|
userVerification: this.userVerification,
|
|
81
104
|
extensions: this.extensions,
|
|
82
105
|
};
|
|
83
|
-
|
|
106
|
+
let passkeyGetfn = this.forcePlatformKey
|
|
107
|
+
? reactNativePasskey.Passkey.getPlatformKey
|
|
108
|
+
: this.forceSecurityKey
|
|
109
|
+
? reactNativePasskey.Passkey.getSecurityKey
|
|
110
|
+
: reactNativePasskey.Passkey.get;
|
|
111
|
+
let authenticationResult = await passkeyGetfn(signingOptions);
|
|
112
|
+
// See https://github.com/f-23/react-native-passkey/issues/54
|
|
113
|
+
// On Android the typedef lies. Authentication result is actually a string!
|
|
114
|
+
// TODO: remove me once the above is resolved.
|
|
115
|
+
const brokenAuthenticationResult = authenticationResult;
|
|
116
|
+
if (typeof brokenAuthenticationResult === "string") {
|
|
117
|
+
authenticationResult = JSON.parse(brokenAuthenticationResult);
|
|
118
|
+
}
|
|
84
119
|
const stamp = {
|
|
85
120
|
authenticatorData: encoding.base64StringToBase64UrlEncodedString(authenticationResult.response.authenticatorData),
|
|
86
121
|
clientDataJson: encoding.base64StringToBase64UrlEncodedString(authenticationResult.response.clientDataJSON),
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":[null],"names":["Passkey","getRandomChallenge","base64Tobase64url","getChallengeFromPayload"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":[null],"names":["AuthenticatorTransport","Passkey","getRandomChallenge","base64Tobase64url","getChallengeFromPayload"],"mappings":";;;;;;AAoBYA,wCAOX;AAPD,CAAA,UAAY,sBAAsB,EAAA;AAChC,IAAA,sBAAA,CAAA,KAAA,CAAA,GAAA,KAAW,CAAA;AACX,IAAA,sBAAA,CAAA,KAAA,CAAA,GAAA,KAAW,CAAA;AACX,IAAA,sBAAA,CAAA,KAAA,CAAA,GAAA,KAAW,CAAA;AACX,IAAA,sBAAA,CAAA,WAAA,CAAA,GAAA,YAAwB,CAAA;AACxB,IAAA,sBAAA,CAAA,QAAA,CAAA,GAAA,QAAiB,CAAA;AACjB,IAAA,sBAAA,CAAA,UAAA,CAAA,GAAA,UAAqB,CAAA;AACvB,CAAC,EAPWA,8BAAsB,KAAtBA,8BAAsB,GAOjC,EAAA,CAAA,CAAA,CAAA;AAQD;;AAEG;AACH,MAAM,eAAe,GAAG,kBAAkB,CAAC;AA8E3C,MAAM,cAAc,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AACrC,MAAM,uBAAuB,GAAG,WAAW,CAAC;AAE5C;;AAEG;SACa,WAAW,GAAA;AACzB,IAAA,OAAOC,0BAAO,CAAC,WAAW,EAAE,CAAC;AAC/B,CAAC;AAMD;;AAEG;AACI,eAAe,aAAa,CACjC,MAAkC,EAClC,OAGC,EAAA;IAED,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,IAAIC,uBAAkB,EAAE,CAAC;AAE3D,IAAA,IAAI,QAAQ,GAAG,OAAO,EAAE,eAAe;UACnCD,0BAAO,CAAC,iBAAiB;UACzB,OAAO,EAAE,eAAe;cACxBA,0BAAO,CAAC,iBAAiB;AAC3B,cAAEA,0BAAO,CAAC,MAAM,CAAC;AAEnB,IAAA,IAAI,kBA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CAAC;AACjD,QAAA,IAAI,OAAO,0BAA0B,KAAK,QAAQ,EAAE;AAClD,YAAA,oBAAoB,GAAG,IAAI,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC;AAC/D,SAAA;AAED,QAAA,MAAM,KAAK,GAAG;YACZ,iBAAiB,EAAEE,6CAAiB,CAClC,oBAAoB,CAAC,QAAQ,CAAC,iBAAiB,CAChD;YACD,cAAc,EAAEA,6CAAiB,CAC/B,oBAAoB,CAAC,QAAQ,CAAC,cAAc,CAC7C;AACD,YAAA,YAAY,EAAEA,6CAAiB,CAAC,oBAAoB,CAAC,EAAE,CAAC;YACxD,SAAS,EAAEA,6CAAiB,CAAC,oBAAoB,CAAC,QAAQ,CAAC,SAAS,CAAC;SACtE,CAAC;QAEF,OAAO;AACL,YAAA,eAAe,EAAE,eAAe;AAChC,YAAA,gBAAgB,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;SACxC,CAAC;KACH;AACF;;;;;;"}
|
package/dist/index.mjs
CHANGED
|
@@ -2,6 +2,15 @@ import { Passkey } from 'react-native-passkey';
|
|
|
2
2
|
import { base64StringToBase64UrlEncodedString } from '@turnkey/encoding';
|
|
3
3
|
import { getRandomChallenge, getChallengeFromPayload } from './util.mjs';
|
|
4
4
|
|
|
5
|
+
var AuthenticatorTransport;
|
|
6
|
+
(function (AuthenticatorTransport) {
|
|
7
|
+
AuthenticatorTransport["usb"] = "usb";
|
|
8
|
+
AuthenticatorTransport["nfc"] = "nfc";
|
|
9
|
+
AuthenticatorTransport["ble"] = "ble";
|
|
10
|
+
AuthenticatorTransport["smartCard"] = "smart-card";
|
|
11
|
+
AuthenticatorTransport["hybrid"] = "hybrid";
|
|
12
|
+
AuthenticatorTransport["internal"] = "internal";
|
|
13
|
+
})(AuthenticatorTransport || (AuthenticatorTransport = {}));
|
|
5
14
|
/**
|
|
6
15
|
* Header name for a webauthn stamp
|
|
7
16
|
*/
|
|
@@ -19,7 +28,12 @@ function isSupported() {
|
|
|
19
28
|
*/
|
|
20
29
|
async function createPasskey(config, options) {
|
|
21
30
|
const challenge = config.challenge || getRandomChallenge();
|
|
22
|
-
|
|
31
|
+
let createFn = options?.withPlatformKey
|
|
32
|
+
? Passkey.createPlatformKey
|
|
33
|
+
: options?.withSecurityKey
|
|
34
|
+
? Passkey.createSecurityKey
|
|
35
|
+
: Passkey.create;
|
|
36
|
+
let registrationResult = await createFn({
|
|
23
37
|
challenge: challenge,
|
|
24
38
|
rp: config.rp,
|
|
25
39
|
user: config.user,
|
|
@@ -43,7 +57,14 @@ async function createPasskey(config, options) {
|
|
|
43
57
|
alg: -257,
|
|
44
58
|
},
|
|
45
59
|
],
|
|
46
|
-
}
|
|
60
|
+
});
|
|
61
|
+
// See https://github.com/f-23/react-native-passkey/issues/54
|
|
62
|
+
// On Android the typedef lies. Registration result is actually a string!
|
|
63
|
+
// TODO: remove me once the above is resolved.
|
|
64
|
+
const brokenRegistrationResult = registrationResult;
|
|
65
|
+
if (typeof brokenRegistrationResult === "string") {
|
|
66
|
+
registrationResult = JSON.parse(brokenRegistrationResult);
|
|
67
|
+
}
|
|
47
68
|
return {
|
|
48
69
|
authenticatorName: config.authenticatorName,
|
|
49
70
|
challenge: challenge,
|
|
@@ -67,6 +88,8 @@ class PasskeyStamper {
|
|
|
67
88
|
this.userVerification = config.userVerification || defaultUserVerification;
|
|
68
89
|
this.allowCredentials = config.allowCredentials || [];
|
|
69
90
|
this.extensions = config.extensions || {};
|
|
91
|
+
this.forcePlatformKey = !!config.withPlatformKey;
|
|
92
|
+
this.forceSecurityKey = !!config.withSecurityKey;
|
|
70
93
|
}
|
|
71
94
|
async stamp(payload) {
|
|
72
95
|
const challenge = getChallengeFromPayload(payload);
|
|
@@ -78,7 +101,19 @@ class PasskeyStamper {
|
|
|
78
101
|
userVerification: this.userVerification,
|
|
79
102
|
extensions: this.extensions,
|
|
80
103
|
};
|
|
81
|
-
|
|
104
|
+
let passkeyGetfn = this.forcePlatformKey
|
|
105
|
+
? Passkey.getPlatformKey
|
|
106
|
+
: this.forceSecurityKey
|
|
107
|
+
? Passkey.getSecurityKey
|
|
108
|
+
: Passkey.get;
|
|
109
|
+
let authenticationResult = await passkeyGetfn(signingOptions);
|
|
110
|
+
// See https://github.com/f-23/react-native-passkey/issues/54
|
|
111
|
+
// On Android the typedef lies. Authentication result is actually a string!
|
|
112
|
+
// TODO: remove me once the above is resolved.
|
|
113
|
+
const brokenAuthenticationResult = authenticationResult;
|
|
114
|
+
if (typeof brokenAuthenticationResult === "string") {
|
|
115
|
+
authenticationResult = JSON.parse(brokenAuthenticationResult);
|
|
116
|
+
}
|
|
82
117
|
const stamp = {
|
|
83
118
|
authenticatorData: base64StringToBase64UrlEncodedString(authenticationResult.response.authenticatorData),
|
|
84
119
|
clientDataJson: base64StringToBase64UrlEncodedString(authenticationResult.response.clientDataJSON),
|
|
@@ -92,5 +127,5 @@ class PasskeyStamper {
|
|
|
92
127
|
}
|
|
93
128
|
}
|
|
94
129
|
|
|
95
|
-
export { PasskeyStamper, createPasskey, isSupported };
|
|
130
|
+
export { AuthenticatorTransport, PasskeyStamper, createPasskey, isSupported };
|
|
96
131
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../src/index.ts"],"sourcesContent":[null],"names":["base64Tobase64url"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../src/index.ts"],"sourcesContent":[null],"names":["base64Tobase64url"],"mappings":";;;;IAoBY,uBAOX;AAPD,CAAA,UAAY,sBAAsB,EAAA;AAChC,IAAA,sBAAA,CAAA,KAAA,CAAA,GAAA,KAAW,CAAA;AACX,IAAA,sBAAA,CAAA,KAAA,CAAA,GAAA,KAAW,CAAA;AACX,IAAA,sBAAA,CAAA,KAAA,CAAA,GAAA,KAAW,CAAA;AACX,IAAA,sBAAA,CAAA,WAAA,CAAA,GAAA,YAAwB,CAAA;AACxB,IA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,EAAE,eAAe;AAChC,YAAA,gBAAgB,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;SACxC,CAAC;KACH;AACF;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turnkey/react-native-passkey-stamper",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index.mjs",
|
|
6
6
|
"exports": {
|
|
@@ -47,10 +47,10 @@
|
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"buffer": "^6.0.3",
|
|
50
|
-
"react-native-passkey": "^
|
|
50
|
+
"react-native-passkey": "^3.0.0",
|
|
51
51
|
"sha256-uint8array": "^0.10.7",
|
|
52
52
|
"@turnkey/encoding": "0.4.0",
|
|
53
|
-
"@turnkey/http": "2.
|
|
53
|
+
"@turnkey/http": "2.17.0"
|
|
54
54
|
},
|
|
55
55
|
"scripts": {
|
|
56
56
|
"build": "rollup -c",
|