@clerk/expo-passkeys 1.0.0-canary.vda6fa771c2184cec7820e3bd218b8fcd4171265e → 1.0.0-snapshot.v20251203152900

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.
Files changed (44) hide show
  1. package/CHANGELOG.md +1027 -0
  2. package/README.md +3 -3
  3. package/{build → dist}/ClerkExpoPasskeys.types.d.ts +1 -1
  4. package/dist/ClerkExpoPasskeys.types.d.ts.map +1 -0
  5. package/dist/ClerkExpoPasskeys.types.js +17 -0
  6. package/dist/ClerkExpoPasskeys.types.js.map +1 -0
  7. package/dist/ClerkExpoPasskeysModule.js +26 -0
  8. package/dist/ClerkExpoPasskeysModule.js.map +1 -0
  9. package/dist/ClerkExpoPasskeysModule.web.js +25 -0
  10. package/dist/ClerkExpoPasskeysModule.web.js.map +1 -0
  11. package/{build → dist}/index.d.ts.map +1 -1
  12. package/dist/index.js +181 -0
  13. package/dist/index.js.map +1 -0
  14. package/dist/tsconfig.declarations.tsbuildinfo +1 -0
  15. package/{build → dist}/utils.d.ts +5 -5
  16. package/dist/utils.d.ts.map +1 -0
  17. package/dist/utils.js +122 -0
  18. package/dist/utils.js.map +1 -0
  19. package/package.json +21 -22
  20. package/src/ClerkExpoPasskeys.types.ts +1 -1
  21. package/src/ClerkExpoPasskeysModule.ts +1 -1
  22. package/src/index.ts +3 -2
  23. package/src/utils.ts +3 -3
  24. package/tsconfig.declarations.json +12 -0
  25. package/tsconfig.json +22 -5
  26. package/tsup.config.ts +30 -0
  27. package/.eslintrc.js +0 -7
  28. package/build/ClerkExpoPasskeys.types.d.ts.map +0 -1
  29. package/build/ClerkExpoPasskeys.types.js +0 -2
  30. package/build/ClerkExpoPasskeys.types.js.map +0 -1
  31. package/build/ClerkExpoPasskeysModule.js +0 -5
  32. package/build/ClerkExpoPasskeysModule.js.map +0 -1
  33. package/build/ClerkExpoPasskeysModule.web.js +0 -2
  34. package/build/ClerkExpoPasskeysModule.web.js.map +0 -1
  35. package/build/index.js +0 -143
  36. package/build/index.js.map +0 -1
  37. package/build/utils.d.ts.map +0 -1
  38. package/build/utils.js +0 -81
  39. package/build/utils.js.map +0 -1
  40. /package/{build → dist}/ClerkExpoPasskeysModule.d.ts +0 -0
  41. /package/{build → dist}/ClerkExpoPasskeysModule.d.ts.map +0 -0
  42. /package/{build → dist}/ClerkExpoPasskeysModule.web.d.ts +0 -0
  43. /package/{build → dist}/ClerkExpoPasskeysModule.web.d.ts.map +0 -0
  44. /package/{build → dist}/index.d.ts +0 -0
package/README.md CHANGED
@@ -38,10 +38,10 @@
38
38
  ## Usage
39
39
 
40
40
  ```tsx
41
- import { ClerkProvider } from '@clerk/clerk-expo';
42
- import { passkeys } from '@clerk/clerk-expo/passkeys';
41
+ import { ClerkProvider } from '@clerk/expo';
42
+ import { passkeys } from '@clerk/expo/passkeys';
43
43
 
44
- <ClerkProvider passkeys={passkeys}>{/* Your app here */}</ClerkProvider>;
44
+ <ClerkProvider __experimental_passkeys={passkeys}>{/* Your app here */}</ClerkProvider>;
45
45
  ```
46
46
 
47
47
  ### 🔑 Creating a Passkey
@@ -1,4 +1,4 @@
1
- import type { CredentialReturn, PublicKeyCredentialCreationOptionsWithoutExtensions, PublicKeyCredentialRequestOptionsWithoutExtensions, PublicKeyCredentialWithAuthenticatorAssertionResponse as ClerkPublicKeyCredentialWithAuthenticatorAssertionResponse, PublicKeyCredentialWithAuthenticatorAttestationResponse as ClerkPublicKeyCredentialWithAuthenticatorAttestationResponse } from '@clerk/types';
1
+ import type { CredentialReturn, PublicKeyCredentialCreationOptionsWithoutExtensions, PublicKeyCredentialRequestOptionsWithoutExtensions, PublicKeyCredentialWithAuthenticatorAssertionResponse as ClerkPublicKeyCredentialWithAuthenticatorAssertionResponse, PublicKeyCredentialWithAuthenticatorAttestationResponse as ClerkPublicKeyCredentialWithAuthenticatorAttestationResponse } from '@clerk/shared/types';
2
2
  export type { PublicKeyCredentialRequestOptionsWithoutExtensions, PublicKeyCredentialCreationOptionsWithoutExtensions, CredentialReturn, };
3
3
  type AuthenticatorTransportFuture = 'ble' | 'cable' | 'hybrid' | 'internal' | 'nfc' | 'smart-card' | 'usb';
4
4
  interface PublicKeyCredentialDescriptorJSON {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ClerkExpoPasskeys.types.d.ts","sourceRoot":"","sources":["../src/ClerkExpoPasskeys.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,mDAAmD,EACnD,kDAAkD,EAClD,qDAAqD,IAAI,0DAA0D,EACnH,uDAAuD,IAAI,4DAA4D,EACxH,MAAM,qBAAqB,CAAC;AAE7B,YAAY,EACV,kDAAkD,EAClD,mDAAmD,EACnD,gBAAgB,GACjB,CAAC;AAEF,KAAK,4BAA4B,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,UAAU,GAAG,KAAK,GAAG,YAAY,GAAG,KAAK,CAAC;AAE3G,UAAU,iCAAiC;IACzC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,uBAAuB,CAAC;IAC9B,UAAU,CAAC,EAAE,4BAA4B,EAAE,CAAC;CAC7C;AAGD,MAAM,MAAM,4CAA4C,GAAG,IAAI,CAC7D,mDAAmD,EACnD,wBAAwB,GAAG,kBAAkB,CAC9C,GAAG;IACF,EAAE,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACjC,IAAI,EAAE;QACJ,EAAE,EAAE,MAAM,CAAC;QACX,WAAW,EAAE,MAAM,CAAC;QACpB,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IACF,SAAS,EAAE,MAAM,CAAC;IAClB,kBAAkB,CAAC,EAAE,iCAAiC,EAAE,CAAC;CAC1D,CAAC;AAGF,MAAM,MAAM,2CAA2C,GAAG,IAAI,CAC5D,kDAAkD,EAClD,WAAW,CACZ,GAAG;IACF,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAGF,MAAM,WAAW,0BAA0B;IACzC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,kCAAkC,CAAC;IAC7C,uBAAuB,CAAC,EAAE,uBAAuB,CAAC;IAClD,sBAAsB,EAAE,qCAAqC,CAAC;IAC9D,IAAI,EAAE,uBAAuB,CAAC;CAC/B;AAGD,MAAM,MAAM,uDAAuD,GACjE,4DAA4D,GAAG;IAC7D,MAAM,EAAE,MAAM,GAAG,CAAC;CACnB,CAAC;AAEJ,UAAU,kCAAkC;IAC1C,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAGD,MAAM,MAAM,qDAAqD,GAC/D,0DAA0D,GAAG;IAC3D,MAAM,EAAE,MAAM,GAAG,CAAC;CACnB,CAAC;AAEJ,UAAU,oCAAoC;IAC5C,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,UAAU,CAAC,EAAE,4BAA4B,EAAE,CAAC;IAC5C,kBAAkB,CAAC,EAAE,uBAAuB,CAAC;IAC7C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAGD,MAAM,WAAW,wBAAwB;IACvC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,oCAAoC,CAAC;IAC/C,uBAAuB,CAAC,EAAE,uBAAuB,CAAC;IAClD,sBAAsB,EAAE,qCAAqC,CAAC;IAC9D,IAAI,EAAE,uBAAuB,CAAC;CAC/B"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var ClerkExpoPasskeys_types_exports = {};
16
+ module.exports = __toCommonJS(ClerkExpoPasskeys_types_exports);
17
+ //# sourceMappingURL=ClerkExpoPasskeys.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/ClerkExpoPasskeys.types.ts"],"sourcesContent":["import type {\n CredentialReturn,\n PublicKeyCredentialCreationOptionsWithoutExtensions,\n PublicKeyCredentialRequestOptionsWithoutExtensions,\n PublicKeyCredentialWithAuthenticatorAssertionResponse as ClerkPublicKeyCredentialWithAuthenticatorAssertionResponse,\n PublicKeyCredentialWithAuthenticatorAttestationResponse as ClerkPublicKeyCredentialWithAuthenticatorAttestationResponse,\n} from '@clerk/shared/types';\n\nexport type {\n PublicKeyCredentialRequestOptionsWithoutExtensions,\n PublicKeyCredentialCreationOptionsWithoutExtensions,\n CredentialReturn,\n};\n\ntype AuthenticatorTransportFuture = 'ble' | 'cable' | 'hybrid' | 'internal' | 'nfc' | 'smart-card' | 'usb';\n\ninterface PublicKeyCredentialDescriptorJSON {\n id: string;\n type: PublicKeyCredentialType;\n transports?: AuthenticatorTransportFuture[];\n}\n\n// The serialized JSON to send to \"create\" native module\nexport type SerializedPublicKeyCredentialCreationOptions = Pick<\n PublicKeyCredentialCreationOptionsWithoutExtensions,\n 'authenticatorSelection' | 'pubKeyCredParams'\n> & {\n rp: { id: string; name: string };\n user: {\n id: string;\n displayName: string;\n name: string;\n };\n challenge: string;\n excludeCredentials?: PublicKeyCredentialDescriptorJSON[];\n};\n\n// The serialized JSON to send to \"get\" native module\nexport type SerializedPublicKeyCredentialRequestOptions = Omit<\n PublicKeyCredentialRequestOptionsWithoutExtensions,\n 'challenge'\n> & {\n challenge: string;\n};\n\n// The return type from the \"get\" native module.\nexport interface AuthenticationResponseJSON {\n id: string;\n rawId: string;\n response: AuthenticatorAssertionResponseJSON;\n authenticatorAttachment?: AuthenticatorAttachment;\n clientExtensionResults: AuthenticationExtensionsClientOutputs;\n type: PublicKeyCredentialType;\n}\n\n// The serialized response of the native module \"create\" response to be send back to clerk\nexport type PublicKeyCredentialWithAuthenticatorAttestationResponse =\n ClerkPublicKeyCredentialWithAuthenticatorAttestationResponse & {\n toJSON: () => any;\n };\n\ninterface AuthenticatorAssertionResponseJSON {\n clientDataJSON: string;\n authenticatorData: string;\n signature: string;\n userHandle?: string;\n}\n\n// The serialized response of the native module \"get\" response to be send back to clerk\nexport type PublicKeyCredentialWithAuthenticatorAssertionResponse =\n ClerkPublicKeyCredentialWithAuthenticatorAssertionResponse & {\n toJSON: () => any;\n };\n\ninterface AuthenticatorAttestationResponseJSON {\n clientDataJSON: string;\n attestationObject: string;\n authenticatorData?: string;\n transports?: AuthenticatorTransportFuture[];\n publicKeyAlgorithm?: COSEAlgorithmIdentifier;\n publicKey?: string;\n}\n\n// The type is returned from from native module \"create\" response\nexport interface RegistrationResponseJSON {\n id: string;\n rawId: string;\n response: AuthenticatorAttestationResponseJSON;\n authenticatorAttachment?: AuthenticatorAttachment;\n clientExtensionResults: AuthenticationExtensionsClientOutputs;\n type: PublicKeyCredentialType;\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var ClerkExpoPasskeysModule_exports = {};
20
+ __export(ClerkExpoPasskeysModule_exports, {
21
+ default: () => ClerkExpoPasskeysModule_default
22
+ });
23
+ module.exports = __toCommonJS(ClerkExpoPasskeysModule_exports);
24
+ var import_expo = require("expo");
25
+ var ClerkExpoPasskeysModule_default = (0, import_expo.requireNativeModule)("ClerkExpoPasskeys");
26
+ //# sourceMappingURL=ClerkExpoPasskeysModule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/ClerkExpoPasskeysModule.ts"],"sourcesContent":["import { requireNativeModule } from 'expo';\n\n// It loads the native module object from the JSI or falls back to\n// the bridge module (from NativeModulesProxy) if the remote debugger is on.\nexport default requireNativeModule('ClerkExpoPasskeys');\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAoC;AAIpC,IAAO,sCAAQ,iCAAoB,mBAAmB;","names":[]}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var ClerkExpoPasskeysModule_web_exports = {};
20
+ __export(ClerkExpoPasskeysModule_web_exports, {
21
+ default: () => ClerkExpoPasskeysModule_web_default
22
+ });
23
+ module.exports = __toCommonJS(ClerkExpoPasskeysModule_web_exports);
24
+ var ClerkExpoPasskeysModule_web_default = {};
25
+ //# sourceMappingURL=ClerkExpoPasskeysModule.web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/ClerkExpoPasskeysModule.web.ts"],"sourcesContent":["export default {};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAO,sCAAQ,CAAC;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,gBAAgB,EAChB,mDAAmD,EACnD,kDAAkD,EAClD,qDAAqD,EACrD,uDAAuD,EAIxD,MAAM,2BAA2B,CAAC;AA0BnC,wBAAsB,MAAM,CAC1B,SAAS,EAAE,mDAAmD,GAC7D,OAAO,CAAC,gBAAgB,CAAC,uDAAuD,CAAC,CAAC,CAsDpF;AAsBD,wBAAsB,GAAG,CAAC,EACxB,gBAAgB,GACjB,EAAE;IACD,gBAAgB,EAAE,kDAAkD,CAAC;CACtE,GAAG,OAAO,CAAC,gBAAgB,CAAC,qDAAqD,CAAC,CAAC,CAmCnF;AAKD,wBAAgB,WAAW,YAU1B;AAgBD,eAAO,MAAM,QAAQ;;;;;CAOpB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,gBAAgB,EAChB,mDAAmD,EACnD,kDAAkD,EAClD,qDAAqD,EACrD,uDAAuD,EAIxD,MAAM,2BAA2B,CAAC;AA0BnC,wBAAsB,MAAM,CAC1B,SAAS,EAAE,mDAAmD,GAC7D,OAAO,CAAC,gBAAgB,CAAC,uDAAuD,CAAC,CAAC,CAsDpF;AAsBD,wBAAsB,GAAG,CAAC,EACxB,gBAAgB,GACjB,EAAE;IACD,gBAAgB,EAAE,kDAAkD,CAAC;CACtE,GAAG,OAAO,CAAC,gBAAgB,CAAC,qDAAqD,CAAC,CAAC,CAoCnF;AAKD,wBAAgB,WAAW,YAU1B;AAgBD,eAAO,MAAM,QAAQ;;;;;CAOpB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,181 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var index_exports = {};
30
+ __export(index_exports, {
31
+ create: () => create,
32
+ get: () => get,
33
+ isSupported: () => isSupported,
34
+ passkeys: () => passkeys
35
+ });
36
+ module.exports = __toCommonJS(index_exports);
37
+ var import_react_native = require("react-native");
38
+ var import_ClerkExpoPasskeysModule = __toESM(require("./ClerkExpoPasskeysModule"));
39
+ var import_utils = require("./utils");
40
+ const makeSerializedCreateResponse = (publicCredential) => ({
41
+ id: publicCredential.id,
42
+ rawId: (0, import_utils.base64urlToArrayBuffer)(publicCredential.rawId),
43
+ response: {
44
+ getTransports: () => {
45
+ var _a;
46
+ return (_a = publicCredential == null ? void 0 : publicCredential.response) == null ? void 0 : _a.transports;
47
+ },
48
+ attestationObject: (0, import_utils.base64urlToArrayBuffer)(publicCredential.response.attestationObject),
49
+ clientDataJSON: (0, import_utils.base64urlToArrayBuffer)(publicCredential.response.clientDataJSON)
50
+ },
51
+ type: publicCredential.type,
52
+ authenticatorAttachment: publicCredential.authenticatorAttachment || null,
53
+ toJSON: () => publicCredential
54
+ });
55
+ async function create(publicKey) {
56
+ if (!publicKey || !publicKey.rp.id) {
57
+ throw new Error("Invalid public key or RpID");
58
+ }
59
+ const createOptions = {
60
+ rp: { id: publicKey.rp.id, name: publicKey.rp.name },
61
+ user: {
62
+ id: (0, import_utils.encodeBase64Url)((0, import_utils.toArrayBuffer)(publicKey.user.id)),
63
+ displayName: publicKey.user.displayName,
64
+ name: publicKey.user.name
65
+ },
66
+ pubKeyCredParams: publicKey.pubKeyCredParams,
67
+ challenge: (0, import_utils.encodeBase64Url)((0, import_utils.toArrayBuffer)(publicKey.challenge)),
68
+ authenticatorSelection: {
69
+ authenticatorAttachment: "platform",
70
+ requireResidentKey: true,
71
+ residentKey: "required",
72
+ userVerification: "required"
73
+ },
74
+ excludeCredentials: publicKey.excludeCredentials.map((c) => ({
75
+ type: "public-key",
76
+ id: (0, import_utils.encodeBase64Url)((0, import_utils.toArrayBuffer)(c.id))
77
+ }))
78
+ };
79
+ const createPasskeyModule = import_react_native.Platform.select({
80
+ android: async () => import_ClerkExpoPasskeysModule.default.create(JSON.stringify(createOptions)),
81
+ ios: async () => import_ClerkExpoPasskeysModule.default.create(
82
+ createOptions.challenge,
83
+ createOptions.rp.id,
84
+ createOptions.user.id,
85
+ createOptions.user.displayName
86
+ ),
87
+ default: null
88
+ });
89
+ if (!createPasskeyModule) {
90
+ throw new Error("Platform not supported");
91
+ }
92
+ try {
93
+ const response = await createPasskeyModule();
94
+ return {
95
+ publicKeyCredential: makeSerializedCreateResponse(typeof response === "string" ? JSON.parse(response) : response),
96
+ error: null
97
+ };
98
+ } catch (error) {
99
+ return {
100
+ publicKeyCredential: null,
101
+ error: (0, import_utils.mapNativeErrorToClerkWebAuthnErrorCode)(error.code, error.message, "create")
102
+ };
103
+ }
104
+ }
105
+ const makeSerializedGetResponse = (publicKeyCredential) => {
106
+ return {
107
+ type: publicKeyCredential.type,
108
+ id: publicKeyCredential.id,
109
+ rawId: (0, import_utils.base64urlToArrayBuffer)(publicKeyCredential.rawId),
110
+ authenticatorAttachment: (publicKeyCredential == null ? void 0 : publicKeyCredential.authenticatorAttachment) || null,
111
+ response: {
112
+ clientDataJSON: (0, import_utils.base64urlToArrayBuffer)(publicKeyCredential.response.clientDataJSON),
113
+ authenticatorData: (0, import_utils.base64urlToArrayBuffer)(publicKeyCredential.response.authenticatorData),
114
+ signature: (0, import_utils.base64urlToArrayBuffer)(publicKeyCredential.response.signature),
115
+ userHandle: (publicKeyCredential == null ? void 0 : publicKeyCredential.response.userHandle) ? (0, import_utils.base64urlToArrayBuffer)(publicKeyCredential == null ? void 0 : publicKeyCredential.response.userHandle) : null
116
+ },
117
+ toJSON: () => publicKeyCredential
118
+ };
119
+ };
120
+ async function get({
121
+ publicKeyOptions
122
+ }) {
123
+ if (!publicKeyOptions) {
124
+ throw new Error("publicKeyCredential has not been provided");
125
+ }
126
+ const serializedPublicCredential = {
127
+ ...publicKeyOptions,
128
+ // @ts-expect-error FIXME
129
+ challenge: (0, import_utils.arrayBufferToBase64Url)(publicKeyOptions.challenge)
130
+ };
131
+ const getPasskeyModule = import_react_native.Platform.select({
132
+ android: async () => import_ClerkExpoPasskeysModule.default.get(JSON.stringify(serializedPublicCredential)),
133
+ ios: async () => import_ClerkExpoPasskeysModule.default.get(serializedPublicCredential.challenge, serializedPublicCredential.rpId),
134
+ default: null
135
+ });
136
+ if (!getPasskeyModule) {
137
+ return {
138
+ publicKeyCredential: null,
139
+ error: new import_utils.ClerkWebAuthnError("Platform is not supported", { code: "passkey_not_supported" })
140
+ };
141
+ }
142
+ try {
143
+ const response = await getPasskeyModule();
144
+ return {
145
+ publicKeyCredential: makeSerializedGetResponse(typeof response === "string" ? JSON.parse(response) : response),
146
+ error: null
147
+ };
148
+ } catch (error) {
149
+ return {
150
+ publicKeyCredential: null,
151
+ error: (0, import_utils.mapNativeErrorToClerkWebAuthnErrorCode)(error.code, error.message, "get")
152
+ };
153
+ }
154
+ }
155
+ const ANDROID_9 = 28;
156
+ const IOS_15 = 15;
157
+ function isSupported() {
158
+ if (import_react_native.Platform.OS === "android") {
159
+ return import_react_native.Platform.Version >= ANDROID_9;
160
+ }
161
+ if (import_react_native.Platform.OS === "ios") {
162
+ return parseInt(import_react_native.Platform.Version, 10) > IOS_15;
163
+ }
164
+ return false;
165
+ }
166
+ const passkeys = {
167
+ create,
168
+ get,
169
+ isSupported,
170
+ isAutoFillSupported: () => {
171
+ throw new Error("Not supported");
172
+ }
173
+ };
174
+ // Annotate the CommonJS export names for ESM import in node:
175
+ 0 && (module.exports = {
176
+ create,
177
+ get,
178
+ isSupported,
179
+ passkeys
180
+ });
181
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { Platform } from 'react-native';\n\nimport type {\n AuthenticationResponseJSON,\n CredentialReturn,\n PublicKeyCredentialCreationOptionsWithoutExtensions,\n PublicKeyCredentialRequestOptionsWithoutExtensions,\n PublicKeyCredentialWithAuthenticatorAssertionResponse,\n PublicKeyCredentialWithAuthenticatorAttestationResponse,\n RegistrationResponseJSON,\n SerializedPublicKeyCredentialCreationOptions,\n SerializedPublicKeyCredentialRequestOptions,\n} from './ClerkExpoPasskeys.types';\nimport ClerkExpoPasskeys from './ClerkExpoPasskeysModule';\nimport {\n arrayBufferToBase64Url,\n base64urlToArrayBuffer,\n ClerkWebAuthnError,\n encodeBase64Url,\n mapNativeErrorToClerkWebAuthnErrorCode,\n toArrayBuffer,\n} from './utils';\n\nconst makeSerializedCreateResponse = (\n publicCredential: RegistrationResponseJSON,\n): PublicKeyCredentialWithAuthenticatorAttestationResponse => ({\n id: publicCredential.id,\n rawId: base64urlToArrayBuffer(publicCredential.rawId),\n response: {\n getTransports: () => publicCredential?.response?.transports as string[],\n attestationObject: base64urlToArrayBuffer(publicCredential.response.attestationObject),\n clientDataJSON: base64urlToArrayBuffer(publicCredential.response.clientDataJSON),\n },\n type: publicCredential.type,\n authenticatorAttachment: publicCredential.authenticatorAttachment || null,\n toJSON: () => publicCredential,\n});\n\nexport async function create(\n publicKey: PublicKeyCredentialCreationOptionsWithoutExtensions,\n): Promise<CredentialReturn<PublicKeyCredentialWithAuthenticatorAttestationResponse>> {\n if (!publicKey || !publicKey.rp.id) {\n throw new Error('Invalid public key or RpID');\n }\n\n const createOptions: SerializedPublicKeyCredentialCreationOptions = {\n rp: { id: publicKey.rp.id, name: publicKey.rp.name },\n user: {\n id: encodeBase64Url(toArrayBuffer(publicKey.user.id)),\n displayName: publicKey.user.displayName,\n name: publicKey.user.name,\n },\n pubKeyCredParams: publicKey.pubKeyCredParams,\n challenge: encodeBase64Url(toArrayBuffer(publicKey.challenge)),\n authenticatorSelection: {\n authenticatorAttachment: 'platform',\n requireResidentKey: true,\n residentKey: 'required',\n userVerification: 'required',\n },\n excludeCredentials: publicKey.excludeCredentials.map(c => ({\n type: 'public-key',\n id: encodeBase64Url(toArrayBuffer(c.id)),\n })),\n };\n\n const createPasskeyModule = Platform.select({\n android: async () => ClerkExpoPasskeys.create(JSON.stringify(createOptions)),\n ios: async () =>\n ClerkExpoPasskeys.create(\n createOptions.challenge,\n createOptions.rp.id,\n createOptions.user.id,\n createOptions.user.displayName,\n ),\n default: null,\n });\n\n if (!createPasskeyModule) {\n throw new Error('Platform not supported');\n }\n\n try {\n const response = await createPasskeyModule();\n return {\n publicKeyCredential: makeSerializedCreateResponse(typeof response === 'string' ? JSON.parse(response) : response),\n error: null,\n };\n } catch (error: any) {\n return {\n publicKeyCredential: null,\n error: mapNativeErrorToClerkWebAuthnErrorCode(error.code, error.message, 'create'),\n };\n }\n}\n\nconst makeSerializedGetResponse = (\n publicKeyCredential: AuthenticationResponseJSON,\n): PublicKeyCredentialWithAuthenticatorAssertionResponse => {\n return {\n type: publicKeyCredential.type,\n id: publicKeyCredential.id,\n rawId: base64urlToArrayBuffer(publicKeyCredential.rawId),\n authenticatorAttachment: publicKeyCredential?.authenticatorAttachment || null,\n response: {\n clientDataJSON: base64urlToArrayBuffer(publicKeyCredential.response.clientDataJSON),\n authenticatorData: base64urlToArrayBuffer(publicKeyCredential.response.authenticatorData),\n signature: base64urlToArrayBuffer(publicKeyCredential.response.signature),\n userHandle: publicKeyCredential?.response.userHandle\n ? base64urlToArrayBuffer(publicKeyCredential?.response.userHandle)\n : null,\n },\n toJSON: () => publicKeyCredential,\n };\n};\n\nexport async function get({\n publicKeyOptions,\n}: {\n publicKeyOptions: PublicKeyCredentialRequestOptionsWithoutExtensions;\n}): Promise<CredentialReturn<PublicKeyCredentialWithAuthenticatorAssertionResponse>> {\n if (!publicKeyOptions) {\n throw new Error('publicKeyCredential has not been provided');\n }\n\n const serializedPublicCredential: SerializedPublicKeyCredentialRequestOptions = {\n ...publicKeyOptions,\n // @ts-expect-error FIXME\n challenge: arrayBufferToBase64Url(publicKeyOptions.challenge),\n };\n\n const getPasskeyModule = Platform.select({\n android: async () => ClerkExpoPasskeys.get(JSON.stringify(serializedPublicCredential)),\n ios: async () => ClerkExpoPasskeys.get(serializedPublicCredential.challenge, serializedPublicCredential.rpId),\n default: null,\n });\n\n if (!getPasskeyModule) {\n return {\n publicKeyCredential: null,\n error: new ClerkWebAuthnError('Platform is not supported', { code: 'passkey_not_supported' }),\n };\n }\n\n try {\n const response = await getPasskeyModule();\n return {\n publicKeyCredential: makeSerializedGetResponse(typeof response === 'string' ? JSON.parse(response) : response),\n error: null,\n };\n } catch (error: any) {\n return {\n publicKeyCredential: null,\n error: mapNativeErrorToClerkWebAuthnErrorCode(error.code, error.message, 'get'),\n };\n }\n}\n\nconst ANDROID_9 = 28;\nconst IOS_15 = 15;\n\nexport function isSupported() {\n if (Platform.OS === 'android') {\n return Platform.Version >= ANDROID_9;\n }\n\n if (Platform.OS === 'ios') {\n return parseInt(Platform.Version, 10) > IOS_15;\n }\n\n return false;\n}\n\n// FIX:The autofill function has been implemented for iOS only, but the pop-up is not showing up.\n// This seems to be an issue with Expo that we haven't been able to resolve yet.\n// Further investigation and possibly reaching out to Expo support may be necessary.\n\n// async function autofill(): Promise<AuthenticationResponseJSON | null> {\n// if (Platform.OS === 'android') {\n// throw new Error('Not supported');\n// } else if (Platform.OS === 'ios') {\n// throw new Error('Not supported');\n// } else {\n// throw new Error('Not supported');\n// }\n// }\n\nexport const passkeys = {\n create,\n get,\n isSupported,\n isAutoFillSupported: () => {\n throw new Error('Not supported');\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAyB;AAazB,qCAA8B;AAC9B,mBAOO;AAEP,MAAM,+BAA+B,CACnC,sBAC6D;AAAA,EAC7D,IAAI,iBAAiB;AAAA,EACrB,WAAO,qCAAuB,iBAAiB,KAAK;AAAA,EACpD,UAAU;AAAA,IACR,eAAe,MAAG;AA7BtB;AA6ByB,wEAAkB,aAAlB,mBAA4B;AAAA;AAAA,IACjD,uBAAmB,qCAAuB,iB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