@capgo/capacitor-passkey 8.2.0

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 (37) hide show
  1. package/CapgoCapacitorPasskey.podspec +17 -0
  2. package/LICENSE +373 -0
  3. package/Package.swift +28 -0
  4. package/README.md +692 -0
  5. package/android/build.gradle +61 -0
  6. package/android/src/main/AndroidManifest.xml +2 -0
  7. package/android/src/main/java/app/capgo/passkey/CapacitorPasskey.java +21 -0
  8. package/android/src/main/java/app/capgo/passkey/CapacitorPasskeyPlugin.java +299 -0
  9. package/android/src/main/res/.gitkeep +0 -0
  10. package/dist/docs.json +1034 -0
  11. package/dist/esm/definitions.d.ts +531 -0
  12. package/dist/esm/definitions.js +2 -0
  13. package/dist/esm/definitions.js.map +1 -0
  14. package/dist/esm/index.d.ts +4 -0
  15. package/dist/esm/index.js +87 -0
  16. package/dist/esm/index.js.map +1 -0
  17. package/dist/esm/internal.d.ts +14 -0
  18. package/dist/esm/internal.js +2 -0
  19. package/dist/esm/internal.js.map +1 -0
  20. package/dist/esm/shim.d.ts +8 -0
  21. package/dist/esm/shim.js +108 -0
  22. package/dist/esm/shim.js.map +1 -0
  23. package/dist/esm/web.d.ts +12 -0
  24. package/dist/esm/web.js +69 -0
  25. package/dist/esm/web.js.map +1 -0
  26. package/dist/esm/webauthn.d.ts +23 -0
  27. package/dist/esm/webauthn.js +440 -0
  28. package/dist/esm/webauthn.js.map +1 -0
  29. package/dist/plugin.cjs.js +707 -0
  30. package/dist/plugin.cjs.js.map +1 -0
  31. package/dist/plugin.js +710 -0
  32. package/dist/plugin.js.map +1 -0
  33. package/ios/Sources/CapacitorPasskeyPlugin/CapacitorPasskey.swift +39 -0
  34. package/ios/Sources/CapacitorPasskeyPlugin/CapacitorPasskeyPlugin.swift +388 -0
  35. package/ios/Tests/CapacitorPasskeyPluginTests/CapacitorPasskeyPluginTests.swift +17 -0
  36. package/package.json +105 -0
  37. package/scripts/configure-native.js +263 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sources":["esm/webauthn.js","esm/shim.js","esm/index.js","esm/web.js"],"sourcesContent":["const PASSKEY_TYPE = 'public-key';\nexport function createNativeRequest(options) {\n if ('mediation' in options) {\n const getOptions = options;\n return {\n origin: resolveOrigin(getOptions.origin, getOptions.publicKey.rpId),\n requestJson: JSON.stringify(normalizeRequestOptionsJSON(getOptions.publicKey, getOptions.origin)),\n };\n }\n const createOptions = options;\n return {\n origin: resolveOrigin(createOptions.origin, createOptions.publicKey.rp.id),\n requestJson: JSON.stringify(normalizeCreationOptionsJSON(createOptions.publicKey, createOptions.origin)),\n };\n}\nexport function webAuthnCreationOptionsToJSON(options, origin) {\n var _a;\n return normalizeCreationOptionsJSON({\n attestation: options.attestation,\n authenticatorSelection: options.authenticatorSelection\n ? {\n authenticatorAttachment: options.authenticatorSelection.authenticatorAttachment,\n requireResidentKey: options.authenticatorSelection.requireResidentKey,\n residentKey: options.authenticatorSelection.residentKey,\n userVerification: options.authenticatorSelection.userVerification,\n }\n : undefined,\n challenge: encodeBase64Url(options.challenge),\n excludeCredentials: (_a = options.excludeCredentials) === null || _a === void 0 ? void 0 : _a.map(descriptorToJSON),\n extensions: cloneExtensions(options.extensions),\n pubKeyCredParams: options.pubKeyCredParams.map((entry) => ({\n alg: entry.alg,\n type: entry.type,\n })),\n rp: {\n id: options.rp.id,\n name: options.rp.name,\n },\n timeout: options.timeout,\n user: {\n displayName: options.user.displayName,\n id: encodeBase64Url(options.user.id),\n name: options.user.name,\n },\n }, origin);\n}\nexport function webAuthnRequestOptionsToJSON(options, origin) {\n var _a;\n return normalizeRequestOptionsJSON({\n allowCredentials: (_a = options.allowCredentials) === null || _a === void 0 ? void 0 : _a.map(descriptorToJSON),\n challenge: encodeBase64Url(options.challenge),\n extensions: cloneExtensions(options.extensions),\n rpId: options.rpId,\n timeout: options.timeout,\n userVerification: options.userVerification,\n }, origin);\n}\nexport function normalizeCreationOptionsJSON(options, origin) {\n var _a, _b;\n const rpId = (_a = options.rp.id) !== null && _a !== void 0 ? _a : deriveRpId(resolveOrigin(origin, options.rp.id));\n if (!rpId) {\n throw createPasskeyDomException('DataError', 'A relying party id or HTTPS origin is required.');\n }\n return Object.assign(Object.assign({}, options), { excludeCredentials: (_b = options.excludeCredentials) === null || _b === void 0 ? void 0 : _b.map(descriptorToJSON), pubKeyCredParams: options.pubKeyCredParams.map((entry) => {\n var _a;\n return ({\n alg: entry.alg,\n type: (_a = entry.type) !== null && _a !== void 0 ? _a : PASSKEY_TYPE,\n });\n }), rp: Object.assign(Object.assign({}, options.rp), { id: rpId }) });\n}\nexport function normalizeRequestOptionsJSON(options, origin) {\n var _a, _b;\n const rpId = (_a = options.rpId) !== null && _a !== void 0 ? _a : deriveRpId(resolveOrigin(origin, options.rpId));\n return Object.assign(Object.assign({}, options), { allowCredentials: (_b = options.allowCredentials) === null || _b === void 0 ? void 0 : _b.map(descriptorToJSON), rpId });\n}\nexport function browserCreationOptionsFromJSON(options) {\n var _a, _b;\n return {\n attestation: options.attestation,\n authenticatorSelection: options.authenticatorSelection\n ? {\n authenticatorAttachment: options.authenticatorSelection.authenticatorAttachment,\n requireResidentKey: options.authenticatorSelection.requireResidentKey,\n residentKey: options.authenticatorSelection.residentKey,\n userVerification: options.authenticatorSelection.userVerification,\n }\n : undefined,\n challenge: decodeBase64Url(options.challenge),\n excludeCredentials: (_a = options.excludeCredentials) === null || _a === void 0 ? void 0 : _a.map(jsonDescriptorToBrowser),\n extensions: cloneExtensions(options.extensions),\n pubKeyCredParams: options.pubKeyCredParams.map((entry) => {\n var _a;\n return ({\n alg: entry.alg,\n type: (_a = entry.type) !== null && _a !== void 0 ? _a : PASSKEY_TYPE,\n });\n }),\n rp: {\n id: options.rp.id,\n name: options.rp.name,\n },\n timeout: options.timeout,\n user: {\n displayName: (_b = options.user.displayName) !== null && _b !== void 0 ? _b : options.user.name,\n id: decodeBase64Url(options.user.id),\n name: options.user.name,\n },\n };\n}\nexport function browserRequestOptionsFromJSON(options) {\n var _a;\n return {\n allowCredentials: (_a = options.allowCredentials) === null || _a === void 0 ? void 0 : _a.map(jsonDescriptorToBrowser),\n challenge: decodeBase64Url(options.challenge),\n extensions: cloneExtensions(options.extensions),\n rpId: options.rpId,\n timeout: options.timeout,\n userVerification: options.userVerification,\n };\n}\nexport async function browserRegistrationToJSON(credential) {\n var _a;\n const publicKeyCredential = expectPublicKeyCredential(credential, 'registration');\n const response = publicKeyCredential.response;\n const nativeJson = credentialWithToJSON(publicKeyCredential);\n if (nativeJson && 'attestationObject' in nativeJson.response) {\n return normalizeRegistrationCredential(nativeJson);\n }\n return {\n authenticatorAttachment: normalizeAttachment(publicKeyCredential.authenticatorAttachment),\n clientExtensionResults: clientExtensionResultsToRecord((_a = publicKeyCredential.getClientExtensionResults) === null || _a === void 0 ? void 0 : _a.call(publicKeyCredential)),\n id: publicKeyCredential.id,\n rawId: encodeBase64Url(publicKeyCredential.rawId),\n response: {\n attestationObject: encodeBase64Url(response.attestationObject),\n clientDataJSON: encodeBase64Url(response.clientDataJSON),\n publicKey: response.getPublicKey ? nullableBufferToOptionalBase64Url(response.getPublicKey()) : undefined,\n publicKeyAlgorithm: response.getPublicKeyAlgorithm ? response.getPublicKeyAlgorithm() : undefined,\n transports: response.getTransports ? response.getTransports() : undefined,\n },\n type: PASSKEY_TYPE,\n };\n}\nexport async function browserAuthenticationToJSON(credential) {\n var _a;\n const publicKeyCredential = expectPublicKeyCredential(credential, 'authentication');\n const response = publicKeyCredential.response;\n const nativeJson = credentialWithToJSON(publicKeyCredential);\n if (nativeJson && 'authenticatorData' in nativeJson.response) {\n return normalizeAuthenticationCredential(nativeJson);\n }\n return {\n authenticatorAttachment: normalizeAttachment(publicKeyCredential.authenticatorAttachment),\n clientExtensionResults: clientExtensionResultsToRecord((_a = publicKeyCredential.getClientExtensionResults) === null || _a === void 0 ? void 0 : _a.call(publicKeyCredential)),\n id: publicKeyCredential.id,\n rawId: encodeBase64Url(publicKeyCredential.rawId),\n response: {\n authenticatorData: encodeBase64Url(response.authenticatorData),\n clientDataJSON: encodeBase64Url(response.clientDataJSON),\n signature: encodeBase64Url(response.signature),\n userHandle: nullableBufferToBase64Url(response.userHandle),\n },\n type: PASSKEY_TYPE,\n };\n}\nexport function credentialFromJSON(credential) {\n const shimCredential = new PasskeyPublicKeyCredential(credential);\n if (typeof globalThis.PublicKeyCredential === 'function') {\n Object.setPrototypeOf(shimCredential, globalThis.PublicKeyCredential.prototype);\n }\n return shimCredential;\n}\nexport function parseCreationOptionsFromJSON(options) {\n return browserCreationOptionsFromJSON(normalizeCreationOptionsJSON(options));\n}\nexport function parseRequestOptionsFromJSON(options) {\n return browserRequestOptionsFromJSON(normalizeRequestOptionsJSON(options));\n}\nexport function decodeBase64Url(value) {\n const bytes = base64UrlToBytes(value);\n return bytes.slice().buffer;\n}\nexport function encodeBase64Url(value) {\n if (typeof value === 'undefined' || value === null) {\n return '';\n }\n const bytes = toUint8Array(value);\n let binary = '';\n bytes.forEach((byte) => {\n binary += String.fromCharCode(byte);\n });\n return btoa(binary).replace(/\\+/g, '-').replace(/\\//g, '_').replace(/=+$/u, '');\n}\nexport function resolveOrigin(explicitOrigin, rpId) {\n if (explicitOrigin) {\n return explicitOrigin;\n }\n if (typeof globalThis.location !== 'undefined' && /^https?:$/u.test(globalThis.location.protocol)) {\n return globalThis.location.origin;\n }\n if (rpId) {\n return `https://${rpId}`;\n }\n return undefined;\n}\nexport function createPasskeyDomException(name, message) {\n if (typeof DOMException !== 'undefined') {\n return new DOMException(message, name);\n }\n const error = new Error(message);\n error.name = name;\n return error;\n}\nexport function abortIfNeeded(signal) {\n if (signal === null || signal === void 0 ? void 0 : signal.aborted) {\n throw createPasskeyDomException('AbortError', 'The passkey request was aborted.');\n }\n}\nexport function normalizePluginError(error) {\n if (error instanceof Error) {\n return error;\n }\n const message = typeof error === 'object' && error && 'message' in error ? String(error.message) : String(error);\n const name = resolveErrorName(error);\n return createPasskeyDomException(name, message);\n}\nfunction credentialWithToJSON(credential) {\n const toJSON = credential.toJSON;\n if (typeof toJSON !== 'function') {\n return null;\n }\n const json = toJSON();\n if (!json || typeof json !== 'object') {\n return null;\n }\n const response = json.response;\n if (!response) {\n return null;\n }\n if ('attestationObject' in response) {\n return normalizeRegistrationCredential(json);\n }\n if ('authenticatorData' in response) {\n return normalizeAuthenticationCredential(json);\n }\n return null;\n}\nfunction normalizeRegistrationCredential(credential) {\n var _a, _b, _c, _d, _e;\n return {\n authenticatorAttachment: normalizeAttachment(credential.authenticatorAttachment),\n clientExtensionResults: (_a = credential.clientExtensionResults) !== null && _a !== void 0 ? _a : {},\n id: String((_b = credential.id) !== null && _b !== void 0 ? _b : ''),\n rawId: String((_d = (_c = credential.rawId) !== null && _c !== void 0 ? _c : credential.id) !== null && _d !== void 0 ? _d : ''),\n response: normalizeAttestationResponse((_e = credential.response) !== null && _e !== void 0 ? _e : {}),\n type: PASSKEY_TYPE,\n };\n}\nfunction normalizeAuthenticationCredential(credential) {\n var _a, _b, _c, _d, _e;\n return {\n authenticatorAttachment: normalizeAttachment(credential.authenticatorAttachment),\n clientExtensionResults: (_a = credential.clientExtensionResults) !== null && _a !== void 0 ? _a : {},\n id: String((_b = credential.id) !== null && _b !== void 0 ? _b : ''),\n rawId: String((_d = (_c = credential.rawId) !== null && _c !== void 0 ? _c : credential.id) !== null && _d !== void 0 ? _d : ''),\n response: normalizeAssertionResponse((_e = credential.response) !== null && _e !== void 0 ? _e : {}),\n type: PASSKEY_TYPE,\n };\n}\nfunction normalizeAttestationResponse(response) {\n var _a, _b;\n return {\n attestationObject: String((_a = response.attestationObject) !== null && _a !== void 0 ? _a : ''),\n clientDataJSON: String((_b = response.clientDataJSON) !== null && _b !== void 0 ? _b : ''),\n publicKey: response.publicKey,\n publicKeyAlgorithm: response.publicKeyAlgorithm,\n transports: response.transports,\n };\n}\nfunction normalizeAssertionResponse(response) {\n var _a, _b, _c;\n return {\n authenticatorData: String((_a = response.authenticatorData) !== null && _a !== void 0 ? _a : ''),\n clientDataJSON: String((_b = response.clientDataJSON) !== null && _b !== void 0 ? _b : ''),\n signature: String((_c = response.signature) !== null && _c !== void 0 ? _c : ''),\n userHandle: typeof response.userHandle === 'undefined' ? null : response.userHandle,\n };\n}\nfunction expectPublicKeyCredential(credential, flow) {\n if (!credential || !(credential instanceof PublicKeyCredential)) {\n throw createPasskeyDomException('InvalidStateError', `The browser did not return a ${flow} credential.`);\n }\n return credential;\n}\nfunction descriptorToJSON(descriptor) {\n var _a;\n return {\n id: typeof descriptor.id === 'string' ? descriptor.id : encodeBase64Url(descriptor.id),\n transports: descriptor.transports ? [...descriptor.transports] : undefined,\n type: (_a = descriptor.type) !== null && _a !== void 0 ? _a : PASSKEY_TYPE,\n };\n}\nfunction jsonDescriptorToBrowser(descriptor) {\n var _a;\n return {\n id: decodeBase64Url(descriptor.id),\n transports: descriptor.transports,\n type: (_a = descriptor.type) !== null && _a !== void 0 ? _a : PASSKEY_TYPE,\n };\n}\nfunction cloneExtensions(extensions) {\n if (!extensions) {\n return undefined;\n }\n return JSON.parse(JSON.stringify(extensions));\n}\nfunction nullableBufferToBase64Url(value) {\n if (typeof value === 'undefined') {\n return undefined;\n }\n if (value === null) {\n return null;\n }\n return encodeBase64Url(value);\n}\nfunction nullableBufferToOptionalBase64Url(value) {\n const encoded = nullableBufferToBase64Url(value);\n return encoded !== null && encoded !== void 0 ? encoded : undefined;\n}\nfunction deriveRpId(origin) {\n if (!origin) {\n return undefined;\n }\n try {\n return new URL(origin).hostname;\n }\n catch (_a) {\n return undefined;\n }\n}\nfunction base64UrlToBytes(value) {\n const normalized = value.replace(/-/g, '+').replace(/_/g, '/');\n const padding = normalized.length % 4 === 0 ? '' : '='.repeat(4 - (normalized.length % 4));\n const binary = atob(`${normalized}${padding}`);\n const bytes = new Uint8Array(binary.length);\n for (let index = 0; index < binary.length; index += 1) {\n bytes[index] = binary.charCodeAt(index);\n }\n return bytes;\n}\nfunction toUint8Array(value) {\n if (Array.isArray(value)) {\n return Uint8Array.from(value);\n }\n if (ArrayBuffer.isView(value)) {\n return new Uint8Array(value.buffer, value.byteOffset, value.byteLength);\n }\n return new Uint8Array(value);\n}\nfunction normalizeAttachment(value) {\n if (value === 'platform' || value === 'cross-platform') {\n return value;\n }\n return undefined;\n}\nfunction clientExtensionResultsToRecord(value) {\n if (!value) {\n return {};\n }\n return JSON.parse(JSON.stringify(value));\n}\nclass PasskeyAuthenticatorAttestationResponse {\n constructor(json) {\n this.json = json;\n this.clientDataJSON = decodeBase64Url(json.clientDataJSON);\n this.attestationObject = decodeBase64Url(json.attestationObject);\n }\n getPublicKey() {\n return this.json.publicKey ? decodeBase64Url(this.json.publicKey) : null;\n }\n getPublicKeyAlgorithm() {\n var _a;\n return (_a = this.json.publicKeyAlgorithm) !== null && _a !== void 0 ? _a : -7;\n }\n getTransports() {\n return this.json.transports ? [...this.json.transports] : [];\n }\n toJSON() {\n return Object.assign({}, this.json);\n }\n}\nclass PasskeyAuthenticatorAssertionResponse {\n constructor(json) {\n this.json = json;\n this.clientDataJSON = decodeBase64Url(json.clientDataJSON);\n this.authenticatorData = decodeBase64Url(json.authenticatorData);\n this.signature = decodeBase64Url(json.signature);\n this.userHandle = json.userHandle ? decodeBase64Url(json.userHandle) : null;\n }\n toJSON() {\n return Object.assign({}, this.json);\n }\n}\nclass PasskeyPublicKeyCredential {\n constructor(json) {\n var _a;\n this.json = json;\n this.type = PASSKEY_TYPE;\n this.id = json.id;\n this.rawId = decodeBase64Url(json.rawId);\n this.authenticatorAttachment = (_a = json.authenticatorAttachment) !== null && _a !== void 0 ? _a : null;\n this.response =\n 'attestationObject' in json.response\n ? new PasskeyAuthenticatorAttestationResponse(json.response)\n : new PasskeyAuthenticatorAssertionResponse(json.response);\n }\n getClientExtensionResults() {\n var _a;\n return ((_a = this.json.clientExtensionResults) !== null && _a !== void 0 ? _a : {});\n }\n toJSON() {\n return JSON.parse(JSON.stringify(this.json));\n }\n}\nfunction resolveErrorName(error) {\n if (typeof error === 'object' && error) {\n if ('code' in error && typeof error.code === 'string') {\n return error.code;\n }\n if ('data' in error && error.data && typeof error.data === 'object' && 'name' in error.data) {\n const candidate = error.data.name;\n if (typeof candidate === 'string') {\n return candidate;\n }\n }\n }\n return 'UnknownError';\n}\n//# sourceMappingURL=webauthn.js.map","import { abortIfNeeded, createPasskeyDomException, credentialFromJSON, normalizePluginError, parseCreationOptionsFromJSON, parseRequestOptionsFromJSON, webAuthnCreationOptionsToJSON, webAuthnRequestOptionsToJSON, } from './webauthn';\nexport function installWebAuthnShim({ root = globalThis, plugin, options }) {\n var _a;\n const shimRoot = root;\n const config = Object.assign(Object.assign({}, ((_a = shimRoot.__capgoPasskeyShimConfig) !== null && _a !== void 0 ? _a : {})), (options !== null && options !== void 0 ? options : {}));\n shimRoot.__capgoPasskeyShimConfig = config;\n if (shimRoot.__capgoPasskeyShimInstalled && !config.force) {\n return;\n }\n const originalCredentials = shimRoot.navigator.credentials;\n const patchedCredentials = {\n create: async (request) => {\n var _a;\n const currentConfig = (_a = shimRoot.__capgoPasskeyShimConfig) !== null && _a !== void 0 ? _a : {};\n if (!(request === null || request === void 0 ? void 0 : request.publicKey)) {\n if (originalCredentials === null || originalCredentials === void 0 ? void 0 : originalCredentials.create) {\n return originalCredentials.create.call(originalCredentials, request);\n }\n throw createPasskeyDomException('NotSupportedError', 'Only public-key credential creation is supported.');\n }\n abortIfNeeded(request.signal);\n const response = (await plugin.createCredential({\n origin: currentConfig.origin,\n publicKey: webAuthnCreationOptionsToJSON(request.publicKey, currentConfig.origin),\n }));\n return credentialFromJSON(response);\n },\n get: async (request) => {\n var _a;\n const currentConfig = (_a = shimRoot.__capgoPasskeyShimConfig) !== null && _a !== void 0 ? _a : {};\n if (!(request === null || request === void 0 ? void 0 : request.publicKey)) {\n if (originalCredentials === null || originalCredentials === void 0 ? void 0 : originalCredentials.get) {\n return originalCredentials.get.call(originalCredentials, request);\n }\n throw createPasskeyDomException('NotSupportedError', 'Only public-key credential requests are supported.');\n }\n abortIfNeeded(request.signal);\n if (request.mediation === 'conditional') {\n throw createPasskeyDomException('NotSupportedError', 'Conditional mediation is not available through the Capacitor passkey shim.');\n }\n const response = (await plugin.getCredential({\n mediation: request.mediation,\n origin: currentConfig.origin,\n publicKey: webAuthnRequestOptionsToJSON(request.publicKey, currentConfig.origin),\n }));\n return credentialFromJSON(response);\n },\n preventSilentAccess: async () => {\n if (originalCredentials === null || originalCredentials === void 0 ? void 0 : originalCredentials.preventSilentAccess) {\n await originalCredentials.preventSilentAccess.call(originalCredentials);\n }\n },\n store: async (credential) => {\n if ((originalCredentials === null || originalCredentials === void 0 ? void 0 : originalCredentials.store) && credential) {\n await originalCredentials.store.call(originalCredentials, credential);\n }\n },\n };\n try {\n Object.defineProperty(shimRoot.navigator, 'credentials', {\n configurable: true,\n value: patchedCredentials,\n writable: false,\n });\n }\n catch (_b) {\n shimRoot.navigator.credentials = patchedCredentials;\n }\n installPublicKeyCredentialStatics(shimRoot, plugin);\n shimRoot.__capgoPasskeyShimInstalled = true;\n}\nfunction installPublicKeyCredentialStatics(root, plugin) {\n var _a;\n const nativePublicKeyCredential = (_a = root.PublicKeyCredential) !== null && _a !== void 0 ? _a : class {\n };\n const supportRequest = async () => {\n try {\n return await plugin.isSupported();\n }\n catch (error) {\n throw normalizePluginError(error);\n }\n };\n defineStatic(nativePublicKeyCredential, 'isUserVerifyingPlatformAuthenticatorAvailable', async () => {\n const support = await supportRequest();\n return support.available;\n });\n defineStatic(nativePublicKeyCredential, 'isConditionalMediationAvailable', async () => {\n const support = await supportRequest();\n return support.conditionalMediation;\n });\n defineStatic(nativePublicKeyCredential, 'parseCreationOptionsFromJSON', parseCreationOptionsFromJSON);\n defineStatic(nativePublicKeyCredential, 'parseRequestOptionsFromJSON', parseRequestOptionsFromJSON);\n root.PublicKeyCredential = nativePublicKeyCredential;\n}\nfunction defineStatic(target, key, value) {\n try {\n Object.defineProperty(target, key, {\n configurable: true,\n value,\n writable: true,\n });\n }\n catch (_a) {\n Reflect.set(target, key, value);\n }\n}\n//# sourceMappingURL=shim.js.map","import { registerPlugin } from '@capacitor/core';\nimport { installWebAuthnShim } from './shim';\nimport { createNativeRequest } from './webauthn';\nconst NativeCapacitorPasskey = registerPlugin('CapacitorPasskey', {\n web: () => import('./web').then((module) => new module.CapacitorPasskeyWeb()),\n});\nlet configurationPromise;\nlet cachedConfiguration;\nfunction mergeShimOptions(configuration, options) {\n var _a;\n const origin = (_a = options === null || options === void 0 ? void 0 : options.origin) !== null && _a !== void 0 ? _a : configuration === null || configuration === void 0 ? void 0 : configuration.origin;\n const force = options === null || options === void 0 ? void 0 : options.force;\n if (!origin && force === undefined) {\n return undefined;\n }\n return {\n force,\n origin,\n };\n}\nfunction mergeRuntimeConfiguration(configuration, options) {\n var _a;\n const origin = (_a = options === null || options === void 0 ? void 0 : options.origin) !== null && _a !== void 0 ? _a : configuration.origin;\n const domains = new Set(configuration.domains);\n if (origin) {\n try {\n domains.add(new URL(origin).hostname);\n }\n catch (_b) {\n // Ignore invalid override values here and let native APIs validate later.\n }\n }\n return Object.assign(Object.assign({}, configuration), { domains: [...domains], origin });\n}\nasync function loadConfiguration() {\n try {\n const configuration = await NativeCapacitorPasskey.getConfiguration();\n cachedConfiguration = configuration;\n return configuration;\n }\n catch (error) {\n configurationPromise = undefined;\n throw error;\n }\n}\nconst CapacitorPasskey = {\n async autoShimWebAuthn(options) {\n const configuration = await CapacitorPasskey.getConfiguration();\n if (!configuration.autoShim && !(options === null || options === void 0 ? void 0 : options.force)) {\n return configuration;\n }\n const effectiveConfiguration = mergeRuntimeConfiguration(configuration, options);\n cachedConfiguration = effectiveConfiguration;\n installWebAuthnShim({\n options: mergeShimOptions(effectiveConfiguration, options),\n plugin: CapacitorPasskey,\n });\n return effectiveConfiguration;\n },\n async createCredential(options) {\n return NativeCapacitorPasskey.createCredential(createNativeRequest(options));\n },\n async getConfiguration() {\n if (!configurationPromise) {\n configurationPromise = loadConfiguration();\n }\n return configurationPromise;\n },\n async getCredential(options) {\n return NativeCapacitorPasskey.getCredential(createNativeRequest(options));\n },\n async getPluginVersion() {\n return NativeCapacitorPasskey.getPluginVersion();\n },\n async isSupported() {\n return NativeCapacitorPasskey.isSupported();\n },\n shimWebAuthn(options) {\n installWebAuthnShim({\n options: mergeShimOptions(cachedConfiguration, options),\n plugin: CapacitorPasskey,\n });\n },\n};\nexport * from './definitions';\nexport { CapacitorPasskey };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nimport { browserAuthenticationToJSON, browserCreationOptionsFromJSON, browserRegistrationToJSON, browserRequestOptionsFromJSON, createPasskeyDomException, } from './webauthn';\nexport class CapacitorPasskeyWeb extends WebPlugin {\n async createCredential(options) {\n const credentials = this.ensureCredentials();\n const parsed = JSON.parse(options.requestJson);\n const credential = await credentials.create({\n publicKey: browserCreationOptionsFromJSON(parsed),\n });\n return browserRegistrationToJSON(credential);\n }\n async getCredential(options) {\n const credentials = this.ensureCredentials();\n const parsed = JSON.parse(options.requestJson);\n const credential = await credentials.get({\n publicKey: browserRequestOptionsFromJSON(parsed),\n });\n return browserAuthenticationToJSON(credential);\n }\n async getConfiguration() {\n const origin = this.currentOrigin();\n const domains = origin ? [new URL(origin).hostname] : [];\n return {\n autoShim: true,\n domains,\n origin,\n platform: 'web',\n };\n }\n async isSupported() {\n var _a, _b, _c, _d;\n const available = typeof globalThis.PublicKeyCredential !== 'undefined' &&\n typeof ((_b = (_a = globalThis.navigator) === null || _a === void 0 ? void 0 : _a.credentials) === null || _b === void 0 ? void 0 : _b.create) === 'function' &&\n typeof ((_d = (_c = globalThis.navigator) === null || _c === void 0 ? void 0 : _c.credentials) === null || _d === void 0 ? void 0 : _d.get) === 'function';\n let conditionalMediation = false;\n if (available && typeof globalThis.PublicKeyCredential.isConditionalMediationAvailable === 'function') {\n conditionalMediation = await globalThis.PublicKeyCredential.isConditionalMediationAvailable();\n }\n return {\n available,\n conditionalMediation,\n platform: 'web',\n };\n }\n async getPluginVersion() {\n return {\n version: 'web',\n };\n }\n ensureCredentials() {\n var _a, _b, _c, _d;\n if (typeof globalThis.PublicKeyCredential === 'undefined' ||\n typeof ((_b = (_a = globalThis.navigator) === null || _a === void 0 ? void 0 : _a.credentials) === null || _b === void 0 ? void 0 : _b.create) !== 'function' ||\n typeof ((_d = (_c = globalThis.navigator) === null || _c === void 0 ? void 0 : _c.credentials) === null || _d === void 0 ? void 0 : _d.get) !== 'function') {\n throw createPasskeyDomException('NotSupportedError', 'WebAuthn is not available in this browser.');\n }\n return globalThis.navigator.credentials;\n }\n currentOrigin() {\n if (typeof globalThis.location === 'undefined') {\n return undefined;\n }\n if (globalThis.location.protocol !== 'http:' && globalThis.location.protocol !== 'https:') {\n return undefined;\n }\n return globalThis.location.origin;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;IAAA,MAAM,YAAY,GAAG,YAAY;IAC1B,SAAS,mBAAmB,CAAC,OAAO,EAAE;IAC7C,IAAI,IAAI,WAAW,IAAI,OAAO,EAAE;IAChC,QAAQ,MAAM,UAAU,GAAG,OAAO;IAClC,QAAQ,OAAO;IACf,YAAY,MAAM,EAAE,aAAa,CAAC,UAAU,CAAC,MAAM,EAAE,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC;IAC/E,YAAY,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,2BAA2B,CAAC,UAAU,CAAC,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;IAC7G,SAAS;IACT,IAAI;IACJ,IAAI,MAAM,aAAa,GAAG,OAAO;IACjC,IAAI,OAAO;IACX,QAAQ,MAAM,EAAE,aAAa,CAAC,aAAa,CAAC,MAAM,EAAE,aAAa,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE,CAAC;IAClF,QAAQ,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,4BAA4B,CAAC,aAAa,CAAC,SAAS,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAChH,KAA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,UAAU,CAAC,SAAS,CAAC,WAAW;IAC/C,IAAI;IACJ,IAAI,aAAa,GAAG;IACpB,QAAQ,IAAI,OAAO,UAAU,CAAC,QAAQ,KAAK,WAAW,EAAE;IACxD,YAAY,OAAO,SAAS;IAC5B,QAAQ;IACR,QAAQ,IAAI,UAAU,CAAC,QAAQ,CAAC,QAAQ,KAAK,OAAO,IAAI,UAAU,CAAC,QAAQ,CAAC,QAAQ,KAAK,QAAQ,EAAE;IACnG,YAAY,OAAO,SAAS;IAC5B,QAAQ;IACR,QAAQ,OAAO,UAAU,CAAC,QAAQ,CAAC,MAAM;IACzC,IAAI;IACJ;;;;;;;;;;;;;;;"}
@@ -0,0 +1,39 @@
1
+ import Foundation
2
+
3
+ @objc public class CapacitorPasskey: NSObject {
4
+ @objc public func getPluginVersion() -> String {
5
+ Self.pluginVersion
6
+ }
7
+
8
+ static let pluginVersion = "8.0.0"
9
+
10
+ static func encodeBase64URL(_ data: Data) -> String {
11
+ data
12
+ .base64EncodedString()
13
+ .replacingOccurrences(of: "+", with: "-")
14
+ .replacingOccurrences(of: "/", with: "_")
15
+ .replacingOccurrences(of: "=", with: "")
16
+ }
17
+
18
+ static func decodeBase64URL(_ value: String) throws -> Data {
19
+ var normalized = value
20
+ .replacingOccurrences(of: "-", with: "+")
21
+ .replacingOccurrences(of: "_", with: "/")
22
+
23
+ let remainder = normalized.count % 4
24
+ if remainder > 0 {
25
+ normalized += String(repeating: "=", count: 4 - remainder)
26
+ }
27
+
28
+ guard let data = Data(base64Encoded: normalized) else {
29
+ throw PasskeyPluginError(name: "DataError", message: "Invalid base64url value.")
30
+ }
31
+
32
+ return data
33
+ }
34
+ }
35
+
36
+ struct PasskeyPluginError: Error {
37
+ let name: String
38
+ let message: String
39
+ }
@@ -0,0 +1,388 @@
1
+ import AuthenticationServices
2
+ import Capacitor
3
+ import Foundation
4
+
5
+ private struct PasskeyRelyingParty: Decodable {
6
+ let id: String?
7
+ let name: String
8
+ }
9
+
10
+ private struct PasskeyUserEntity: Decodable {
11
+ let id: String
12
+ let name: String
13
+ let displayName: String?
14
+ }
15
+
16
+ private struct PasskeyCredentialDescriptor: Decodable {
17
+ let id: String
18
+ }
19
+
20
+ private struct PasskeyAuthenticatorSelection: Decodable {
21
+ let userVerification: String?
22
+ }
23
+
24
+ private struct PasskeyRegistrationRequestJSON: Decodable {
25
+ let challenge: String
26
+ let relyingParty: PasskeyRelyingParty
27
+ let user: PasskeyUserEntity
28
+ let excludeCredentials: [PasskeyCredentialDescriptor]?
29
+ let authenticatorSelection: PasskeyAuthenticatorSelection?
30
+ let attestation: String?
31
+
32
+ private enum CodingKeys: String, CodingKey {
33
+ case attestation
34
+ case authenticatorSelection
35
+ case challenge
36
+ case excludeCredentials
37
+ case relyingParty = "rp"
38
+ case user
39
+ }
40
+ }
41
+
42
+ private struct PasskeyAssertionRequestJSON: Decodable {
43
+ let challenge: String
44
+ let rpId: String?
45
+ let allowCredentials: [PasskeyCredentialDescriptor]?
46
+ let userVerification: String?
47
+ }
48
+
49
+ private enum PasskeyOperation {
50
+ case registration
51
+ case assertion
52
+ }
53
+
54
+ private func userVerificationPreference(_ value: String?) -> ASAuthorizationPublicKeyCredentialUserVerificationPreference {
55
+ switch value {
56
+ case "required":
57
+ return .required
58
+ case "discouraged":
59
+ return .discouraged
60
+ default:
61
+ return .preferred
62
+ }
63
+ }
64
+
65
+ private func attestationPreference(_ value: String?) -> ASAuthorizationPublicKeyCredentialAttestationKind {
66
+ switch value {
67
+ case "direct":
68
+ return .direct
69
+ case "enterprise":
70
+ return .enterprise
71
+ case "indirect":
72
+ return .indirect
73
+ default:
74
+ return .none
75
+ }
76
+ }
77
+
78
+ private func normalizedOrigin(_ explicitOrigin: String?, rpId: String?) -> String? {
79
+ if let explicitOrigin, !explicitOrigin.isEmpty {
80
+ return explicitOrigin
81
+ }
82
+
83
+ if let rpId, !rpId.isEmpty {
84
+ return "https://\(rpId)"
85
+ }
86
+
87
+ return nil
88
+ }
89
+
90
+ private func derivedRPID(from origin: String?) -> String? {
91
+ guard let origin, let host = URL(string: origin)?.host, !host.isEmpty else {
92
+ return nil
93
+ }
94
+
95
+ return host
96
+ }
97
+
98
+ private func normalizeConfiguredDomains(_ values: [String], origin: String?) -> [String] {
99
+ var domains = values.compactMap { normalizeDomain($0) }
100
+
101
+ if let originDomain = normalizeDomain(origin), !domains.contains(originDomain) {
102
+ domains.append(originDomain)
103
+ }
104
+
105
+ return domains
106
+ }
107
+
108
+ private func normalizeDomain(_ value: String?) -> String? {
109
+ guard let value, !value.isEmpty else {
110
+ return nil
111
+ }
112
+
113
+ if let host = URL(string: value)?.host, !host.isEmpty {
114
+ return host
115
+ }
116
+
117
+ return value
118
+ }
119
+
120
+ @objc(CapacitorPasskeyPlugin)
121
+ public class CapacitorPasskeyPlugin: CAPPlugin,
122
+ CAPBridgedPlugin,
123
+ ASAuthorizationControllerDelegate,
124
+ ASAuthorizationControllerPresentationContextProviding {
125
+ public let identifier = "CapacitorPasskeyPlugin"
126
+ public let jsName = "CapacitorPasskey"
127
+ public let pluginMethods: [CAPPluginMethod] = [
128
+ CAPPluginMethod(name: "createCredential", returnType: CAPPluginReturnPromise),
129
+ CAPPluginMethod(name: "getCredential", returnType: CAPPluginReturnPromise),
130
+ CAPPluginMethod(name: "getConfiguration", returnType: CAPPluginReturnPromise),
131
+ CAPPluginMethod(name: "isSupported", returnType: CAPPluginReturnPromise),
132
+ CAPPluginMethod(name: "getPluginVersion", returnType: CAPPluginReturnPromise)
133
+ ]
134
+
135
+ private let implementation = CapacitorPasskey()
136
+ private var pendingCall: CAPPluginCall?
137
+ private var pendingOperation: PasskeyOperation?
138
+
139
+ @objc func createCredential(_ call: CAPPluginCall) {
140
+ guard pendingCall == nil else {
141
+ reject(call, name: "InvalidStateError", message: "Another passkey request is already in progress.")
142
+ return
143
+ }
144
+
145
+ do {
146
+ let requestJson = try requestJSON(from: call)
147
+ let registrationRequest = try JSONDecoder().decode(PasskeyRegistrationRequestJSON.self, from: requestJson)
148
+ let origin = normalizedOrigin(call.getString("origin"), rpId: registrationRequest.relyingParty.id)
149
+ let authorizationRequest = try buildRegistrationRequest(from: registrationRequest, origin: origin)
150
+ performAuthorization(call: call, request: authorizationRequest, operation: .registration)
151
+ } catch let error as PasskeyPluginError {
152
+ reject(call, error: error)
153
+ } catch {
154
+ reject(call, name: "UnknownError", message: error.localizedDescription, error: error)
155
+ }
156
+ }
157
+
158
+ @objc func getCredential(_ call: CAPPluginCall) {
159
+ guard pendingCall == nil else {
160
+ reject(call, name: "InvalidStateError", message: "Another passkey request is already in progress.")
161
+ return
162
+ }
163
+
164
+ do {
165
+ let requestJson = try requestJSON(from: call)
166
+ let assertionRequest = try JSONDecoder().decode(PasskeyAssertionRequestJSON.self, from: requestJson)
167
+ let origin = normalizedOrigin(call.getString("origin"), rpId: assertionRequest.rpId)
168
+ let authorizationRequest = try buildAssertionRequest(from: assertionRequest, origin: origin)
169
+ performAuthorization(call: call, request: authorizationRequest, operation: .assertion)
170
+ } catch let error as PasskeyPluginError {
171
+ reject(call, error: error)
172
+ } catch {
173
+ reject(call, name: "UnknownError", message: error.localizedDescription, error: error)
174
+ }
175
+ }
176
+
177
+ @objc func isSupported(_ call: CAPPluginCall) {
178
+ call.resolve([
179
+ "available": true,
180
+ "conditionalMediation": false,
181
+ "platform": "ios"
182
+ ])
183
+ }
184
+
185
+ @objc func getConfiguration(_ call: CAPPluginCall) {
186
+ let config = getConfig()
187
+ let origin = normalizedOrigin(config.getString("origin"), rpId: nil)
188
+ let configuredDomains = (config.getArray("domains") as? [String]) ?? []
189
+
190
+ call.resolve([
191
+ "autoShim": config.getBoolean("autoShim", true),
192
+ "domains": normalizeConfiguredDomains(configuredDomains, origin: origin),
193
+ "origin": origin ?? NSNull(),
194
+ "platform": "ios"
195
+ ])
196
+ }
197
+
198
+ @objc func getPluginVersion(_ call: CAPPluginCall) {
199
+ call.resolve([
200
+ "version": implementation.getPluginVersion()
201
+ ])
202
+ }
203
+
204
+ public func authorizationController(controller: ASAuthorizationController, didCompleteWithAuthorization authorization: ASAuthorization) {
205
+ guard let call = pendingCall, let operation = pendingOperation else {
206
+ clearPendingRequest()
207
+ return
208
+ }
209
+
210
+ switch operation {
211
+ case .registration:
212
+ guard let credential = authorization.credential as? ASAuthorizationPlatformPublicKeyCredentialRegistration else {
213
+ clearPendingRequest()
214
+ reject(call, name: "UnknownError", message: "Unexpected registration credential type.")
215
+ return
216
+ }
217
+
218
+ clearPendingRequest()
219
+ call.resolve(serializeRegistration(credential))
220
+ case .assertion:
221
+ guard let credential = authorization.credential as? ASAuthorizationPlatformPublicKeyCredentialAssertion else {
222
+ clearPendingRequest()
223
+ reject(call, name: "UnknownError", message: "Unexpected assertion credential type.")
224
+ return
225
+ }
226
+
227
+ clearPendingRequest()
228
+ call.resolve(serializeAssertion(credential))
229
+ }
230
+ }
231
+
232
+ public func authorizationController(controller: ASAuthorizationController, didCompleteWithError error: Error) {
233
+ guard let call = pendingCall else {
234
+ clearPendingRequest()
235
+ return
236
+ }
237
+
238
+ clearPendingRequest()
239
+ if let authorizationError = error as? ASAuthorizationError {
240
+ switch authorizationError.code {
241
+ case .canceled, .failed, .notHandled:
242
+ reject(call, name: "NotAllowedError", message: authorizationError.localizedDescription, error: error)
243
+ case .matchedExcludedCredential:
244
+ reject(call, name: "InvalidStateError", message: authorizationError.localizedDescription, error: error)
245
+ default:
246
+ reject(call, name: "UnknownError", message: authorizationError.localizedDescription, error: error)
247
+ }
248
+ return
249
+ }
250
+
251
+ reject(call, name: "UnknownError", message: error.localizedDescription, error: error)
252
+ }
253
+
254
+ public func presentationAnchor(for controller: ASAuthorizationController) -> ASPresentationAnchor {
255
+ bridge?.viewController?.view.window ?? ASPresentationAnchor()
256
+ }
257
+
258
+ private func performAuthorization(call: CAPPluginCall, request: ASAuthorizationRequest, operation: PasskeyOperation) {
259
+ pendingCall = call
260
+ pendingOperation = operation
261
+
262
+ DispatchQueue.main.async {
263
+ let controller = ASAuthorizationController(authorizationRequests: [request])
264
+ controller.delegate = self
265
+ controller.presentationContextProvider = self
266
+ controller.performRequests()
267
+ }
268
+ }
269
+
270
+ private func buildRegistrationRequest(
271
+ from request: PasskeyRegistrationRequestJSON,
272
+ origin: String?
273
+ ) throws -> ASAuthorizationPlatformPublicKeyCredentialRegistrationRequest {
274
+ guard let rpId = request.relyingParty.id ?? derivedRPID(from: origin) else {
275
+ throw PasskeyPluginError(name: "DataError", message: "A relying party id or HTTPS origin is required.")
276
+ }
277
+
278
+ let challenge = try CapacitorPasskey.decodeBase64URL(request.challenge)
279
+ let userID = try CapacitorPasskey.decodeBase64URL(request.user.id)
280
+ let provider = ASAuthorizationPlatformPublicKeyCredentialProvider(relyingPartyIdentifier: rpId)
281
+
282
+ let credentialRequest: ASAuthorizationPlatformPublicKeyCredentialRegistrationRequest
283
+ if #available(iOS 17.4, *), let origin {
284
+ let clientData = ASPublicKeyCredentialClientData(challenge: challenge, origin: origin)
285
+ credentialRequest = provider.createCredentialRegistrationRequest(clientData: clientData, name: request.user.name, userID: userID)
286
+ if let excludedCredentials = request.excludeCredentials, !excludedCredentials.isEmpty {
287
+ credentialRequest.excludedCredentials = try excludedCredentials.map {
288
+ ASAuthorizationPlatformPublicKeyCredentialDescriptor(credentialID: try CapacitorPasskey.decodeBase64URL($0.id))
289
+ }
290
+ }
291
+ } else {
292
+ credentialRequest = provider.createCredentialRegistrationRequest(challenge: challenge, name: request.user.name, userID: userID)
293
+ }
294
+
295
+ credentialRequest.displayName = request.user.displayName
296
+ credentialRequest.userVerificationPreference = userVerificationPreference(request.authenticatorSelection?.userVerification)
297
+ credentialRequest.attestationPreference = attestationPreference(request.attestation)
298
+
299
+ return credentialRequest
300
+ }
301
+
302
+ private func buildAssertionRequest(
303
+ from request: PasskeyAssertionRequestJSON,
304
+ origin: String?
305
+ ) throws -> ASAuthorizationPlatformPublicKeyCredentialAssertionRequest {
306
+ guard let rpId = request.rpId ?? derivedRPID(from: origin) else {
307
+ throw PasskeyPluginError(name: "DataError", message: "A relying party id or HTTPS origin is required.")
308
+ }
309
+
310
+ let challenge = try CapacitorPasskey.decodeBase64URL(request.challenge)
311
+ let provider = ASAuthorizationPlatformPublicKeyCredentialProvider(relyingPartyIdentifier: rpId)
312
+
313
+ let credentialRequest: ASAuthorizationPlatformPublicKeyCredentialAssertionRequest
314
+ if #available(iOS 17.4, *), let origin {
315
+ let clientData = ASPublicKeyCredentialClientData(challenge: challenge, origin: origin)
316
+ credentialRequest = provider.createCredentialAssertionRequest(clientData: clientData)
317
+ } else {
318
+ credentialRequest = provider.createCredentialAssertionRequest(challenge: challenge)
319
+ }
320
+
321
+ credentialRequest.userVerificationPreference = userVerificationPreference(request.userVerification)
322
+ if let allowedCredentials = request.allowCredentials, !allowedCredentials.isEmpty {
323
+ credentialRequest.allowedCredentials = try allowedCredentials.map {
324
+ ASAuthorizationPlatformPublicKeyCredentialDescriptor(credentialID: try CapacitorPasskey.decodeBase64URL($0.id))
325
+ }
326
+ }
327
+
328
+ return credentialRequest
329
+ }
330
+
331
+ private func requestJSON(from call: CAPPluginCall) throws -> Data {
332
+ guard let requestJson = call.getString("requestJson"), !requestJson.isEmpty else {
333
+ throw PasskeyPluginError(name: "DataError", message: "requestJson is required.")
334
+ }
335
+
336
+ guard let data = requestJson.data(using: .utf8) else {
337
+ throw PasskeyPluginError(name: "DataError", message: "requestJson must be valid UTF-8.")
338
+ }
339
+
340
+ return data
341
+ }
342
+
343
+ private func serializeRegistration(_ credential: ASAuthorizationPlatformPublicKeyCredentialRegistration) -> JSObject {
344
+ [
345
+ "id": CapacitorPasskey.encodeBase64URL(credential.credentialID),
346
+ "rawId": CapacitorPasskey.encodeBase64URL(credential.credentialID),
347
+ "type": "public-key",
348
+ "authenticatorAttachment": "platform",
349
+ "clientExtensionResults": JSObject(),
350
+ "response": [
351
+ "clientDataJSON": CapacitorPasskey.encodeBase64URL(credential.rawClientDataJSON),
352
+ "attestationObject": CapacitorPasskey.encodeBase64URL(credential.rawAttestationObject ?? Data())
353
+ ]
354
+ ]
355
+ }
356
+
357
+ private func serializeAssertion(_ credential: ASAuthorizationPlatformPublicKeyCredentialAssertion) -> JSObject {
358
+ let response: JSObject = [
359
+ "clientDataJSON": CapacitorPasskey.encodeBase64URL(credential.rawClientDataJSON),
360
+ "authenticatorData": CapacitorPasskey.encodeBase64URL(credential.rawAuthenticatorData),
361
+ "signature": CapacitorPasskey.encodeBase64URL(credential.signature),
362
+ "userHandle": credential.userID.isEmpty ? NSNull() : CapacitorPasskey.encodeBase64URL(credential.userID)
363
+ ]
364
+
365
+ return [
366
+ "id": CapacitorPasskey.encodeBase64URL(credential.credentialID),
367
+ "rawId": CapacitorPasskey.encodeBase64URL(credential.credentialID),
368
+ "type": "public-key",
369
+ "authenticatorAttachment": "platform",
370
+ "clientExtensionResults": JSObject(),
371
+ "response": response
372
+ ]
373
+ }
374
+
375
+ private func clearPendingRequest() {
376
+ pendingCall = nil
377
+ pendingOperation = nil
378
+ }
379
+
380
+ private func reject(_ call: CAPPluginCall, error: PasskeyPluginError) {
381
+ reject(call, name: error.name, message: error.message)
382
+ }
383
+
384
+ private func reject(_ call: CAPPluginCall, name: String, message: String, error: Error? = nil) {
385
+ let data: JSObject = ["name": name]
386
+ call.reject(message, name, error, data)
387
+ }
388
+ }
@@ -0,0 +1,17 @@
1
+ import XCTest
2
+ @testable import CapacitorPasskeyPlugin
3
+
4
+ class CapacitorPasskeyPluginTests: XCTestCase {
5
+ func testGetPluginVersion() {
6
+ let implementation = CapacitorPasskey()
7
+ XCTAssertEqual("8.0.0", implementation.getPluginVersion())
8
+ }
9
+
10
+ func testBase64URLRoundTrip() throws {
11
+ let input = Data("capgo-passkey".utf8)
12
+ let encoded = CapacitorPasskey.encodeBase64URL(input)
13
+ let decoded = try CapacitorPasskey.decodeBase64URL(encoded)
14
+
15
+ XCTAssertEqual(input, decoded)
16
+ }
17
+ }