@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.
- package/CapgoCapacitorPasskey.podspec +17 -0
- package/LICENSE +373 -0
- package/Package.swift +28 -0
- package/README.md +692 -0
- package/android/build.gradle +61 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/app/capgo/passkey/CapacitorPasskey.java +21 -0
- package/android/src/main/java/app/capgo/passkey/CapacitorPasskeyPlugin.java +299 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/dist/docs.json +1034 -0
- package/dist/esm/definitions.d.ts +531 -0
- package/dist/esm/definitions.js +2 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +87 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/internal.d.ts +14 -0
- package/dist/esm/internal.js +2 -0
- package/dist/esm/internal.js.map +1 -0
- package/dist/esm/shim.d.ts +8 -0
- package/dist/esm/shim.js +108 -0
- package/dist/esm/shim.js.map +1 -0
- package/dist/esm/web.d.ts +12 -0
- package/dist/esm/web.js +69 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/esm/webauthn.d.ts +23 -0
- package/dist/esm/webauthn.js +440 -0
- package/dist/esm/webauthn.js.map +1 -0
- package/dist/plugin.cjs.js +707 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +710 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Sources/CapacitorPasskeyPlugin/CapacitorPasskey.swift +39 -0
- package/ios/Sources/CapacitorPasskeyPlugin/CapacitorPasskeyPlugin.swift +388 -0
- package/ios/Tests/CapacitorPasskeyPluginTests/CapacitorPasskeyPluginTests.swift +17 -0
- package/package.json +105 -0
- package/scripts/configure-native.js +263 -0
package/README.md
ADDED
|
@@ -0,0 +1,692 @@
|
|
|
1
|
+
# @capgo/capacitor-passkey
|
|
2
|
+
<a href="https://capgo.app/"><img src='https://raw.githubusercontent.com/Cap-go/capgo/main/assets/capgo_banner.png' alt='Capgo - Instant updates for capacitor'/></a>
|
|
3
|
+
|
|
4
|
+
<div align="center">
|
|
5
|
+
<h2><a href="https://capgo.app/?ref=plugin_passkey"> ➡️ Get Instant updates for your App with Capgo</a></h2>
|
|
6
|
+
<h2><a href="https://capgo.app/consulting/?ref=plugin_passkey"> Missing a feature? We’ll build the plugin for you 💪</a></h2>
|
|
7
|
+
</div>
|
|
8
|
+
|
|
9
|
+
Passkeys for Capacitor with a browser-style WebAuthn shim.
|
|
10
|
+
|
|
11
|
+
## Why this plugin
|
|
12
|
+
|
|
13
|
+
Most Capacitor apps already have browser-oriented passkey code based on:
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
await navigator.credentials.create({ publicKey: registrationOptions });
|
|
17
|
+
await navigator.credentials.get({ publicKey: requestOptions });
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
This plugin keeps that shape in a Capacitor app:
|
|
21
|
+
|
|
22
|
+
- It can auto-patch `navigator.credentials.create/get` for `publicKey` requests.
|
|
23
|
+
- It forwards the call to native passkey APIs on iOS and Android.
|
|
24
|
+
- It returns browser-like credential objects so existing code can keep working.
|
|
25
|
+
- It can auto-configure the generated iOS and Android host projects during `cap sync/update`.
|
|
26
|
+
- It also exposes direct JSON-safe methods when your backend already returns WebAuthn JSON.
|
|
27
|
+
|
|
28
|
+
What it does not do:
|
|
29
|
+
|
|
30
|
+
- It does not generate backend challenges for you.
|
|
31
|
+
- It does not remove the need for your website to host `apple-app-site-association` and `assetlinks.json`.
|
|
32
|
+
- It does not make Android native passkeys report your website's HTTPS origin to the server. On Android, normal apps use the app origin (`android:apk-key-hash:...`).
|
|
33
|
+
|
|
34
|
+
## Documentation
|
|
35
|
+
|
|
36
|
+
The most complete doc is available here: https://capgo.app/docs/plugins/passkey/
|
|
37
|
+
|
|
38
|
+
## Compatibility
|
|
39
|
+
|
|
40
|
+
| Plugin version | Capacitor compatibility | Maintained |
|
|
41
|
+
| -------------- | ----------------------- | ---------- |
|
|
42
|
+
| v8.\*.\* | v8.\*.\* | ✅ |
|
|
43
|
+
| v7.\*.\* | v7.\*.\* | On demand |
|
|
44
|
+
| v6.\*.\* | v6.\*.\* | ❌ |
|
|
45
|
+
| v5.\*.\* | v5.\*.\* | ❌ |
|
|
46
|
+
|
|
47
|
+
> **Note:** The major version of this plugin follows the major version of Capacitor. Use the version that matches your Capacitor installation.
|
|
48
|
+
|
|
49
|
+
## Install
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
bun add @capgo/capacitor-passkey
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Browser-Like Setup
|
|
56
|
+
|
|
57
|
+
1. Configure the plugin once in `capacitor.config.ts` or `capacitor.config.json`.
|
|
58
|
+
2. Import the `/auto` entrypoint once during app bootstrap.
|
|
59
|
+
3. Keep your existing browser `navigator.credentials.create/get` code unchanged.
|
|
60
|
+
|
|
61
|
+
### 1. Configure `capacitor.config.*`
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
import type { CapacitorConfig } from '@capacitor/cli';
|
|
65
|
+
|
|
66
|
+
const config: CapacitorConfig = {
|
|
67
|
+
appId: 'app.capgo.passkey.example',
|
|
68
|
+
appName: 'My App',
|
|
69
|
+
webDir: 'dist',
|
|
70
|
+
plugins: {
|
|
71
|
+
CapacitorPasskey: {
|
|
72
|
+
origin: 'https://signin.example.com',
|
|
73
|
+
autoShim: true,
|
|
74
|
+
domains: [
|
|
75
|
+
'signin.example.com',
|
|
76
|
+
],
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export default config;
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Config keys:
|
|
85
|
+
|
|
86
|
+
- `origin`: the primary HTTPS relying-party origin for the app.
|
|
87
|
+
- `domains`: optional extra relying-party hostnames to wire natively during `cap sync/update`.
|
|
88
|
+
- `autoShim`: defaults to `true`. The `/auto` entrypoint uses this flag.
|
|
89
|
+
|
|
90
|
+
Then sync native projects:
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
bunx cap sync
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
During `cap sync` / `cap update`, the plugin automatically patches the generated host app:
|
|
97
|
+
|
|
98
|
+
- iOS: updates the entitlements file and wires `CODE_SIGN_ENTITLEMENTS` if needed.
|
|
99
|
+
- Android: injects `asset_statements` metadata and writes a generated string resource.
|
|
100
|
+
|
|
101
|
+
You do not need to manually edit the host project files every time.
|
|
102
|
+
|
|
103
|
+
### 2. Import Once At Bootstrap
|
|
104
|
+
|
|
105
|
+
```ts
|
|
106
|
+
import '@capgo/capacitor-passkey/auto';
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
That import reads `plugins.CapacitorPasskey` from the native Capacitor config and installs the WebAuthn shim automatically.
|
|
110
|
+
|
|
111
|
+
### 3. Keep Existing WebAuthn Calls
|
|
112
|
+
|
|
113
|
+
After the bootstrap import, your browser-style code can stay the same:
|
|
114
|
+
|
|
115
|
+
```ts
|
|
116
|
+
const registration = await navigator.credentials.create({
|
|
117
|
+
publicKey: {
|
|
118
|
+
challenge: crypto.getRandomValues(new Uint8Array(32)),
|
|
119
|
+
rp: {
|
|
120
|
+
id: 'signin.example.com',
|
|
121
|
+
name: 'Example Inc',
|
|
122
|
+
},
|
|
123
|
+
user: {
|
|
124
|
+
id: crypto.getRandomValues(new Uint8Array(32)),
|
|
125
|
+
name: 'ada@example.com',
|
|
126
|
+
displayName: 'Ada Lovelace',
|
|
127
|
+
},
|
|
128
|
+
pubKeyCredParams: [
|
|
129
|
+
{ type: 'public-key', alg: -7 },
|
|
130
|
+
{ type: 'public-key', alg: -257 },
|
|
131
|
+
],
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
const authentication = await navigator.credentials.get({
|
|
136
|
+
publicKey: {
|
|
137
|
+
challenge: crypto.getRandomValues(new Uint8Array(32)),
|
|
138
|
+
rpId: 'signin.example.com',
|
|
139
|
+
},
|
|
140
|
+
});
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
If you do not want the side-effect import, call the config-driven installer manually once:
|
|
144
|
+
|
|
145
|
+
```ts
|
|
146
|
+
import { CapacitorPasskey } from '@capgo/capacitor-passkey';
|
|
147
|
+
|
|
148
|
+
await CapacitorPasskey.autoShimWebAuthn();
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## What The Hook Configures
|
|
152
|
+
|
|
153
|
+
The plugin hook only patches the native host app files that Capacitor generates.
|
|
154
|
+
|
|
155
|
+
- It does not touch your app source code.
|
|
156
|
+
- It does not require you to permanently hand-edit Xcode or Android project files.
|
|
157
|
+
- It does not publish or generate the website association files for you.
|
|
158
|
+
|
|
159
|
+
### Direct JSON-safe API
|
|
160
|
+
|
|
161
|
+
If your backend already returns `PublicKeyCredentialCreationOptionsJSON` or `PublicKeyCredentialRequestOptionsJSON`, you can call the plugin directly:
|
|
162
|
+
|
|
163
|
+
```ts
|
|
164
|
+
import { CapacitorPasskey } from '@capgo/capacitor-passkey';
|
|
165
|
+
|
|
166
|
+
const registration = await CapacitorPasskey.createCredential({
|
|
167
|
+
origin: 'https://signin.example.com',
|
|
168
|
+
publicKey: registrationOptionsFromBackend,
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
const authentication = await CapacitorPasskey.getCredential({
|
|
172
|
+
origin: 'https://signin.example.com',
|
|
173
|
+
publicKey: requestOptionsFromBackend,
|
|
174
|
+
});
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## Website Files You Still Need
|
|
178
|
+
|
|
179
|
+
Passkeys only work when your app is associated with the same relying-party domain as your website.
|
|
180
|
+
|
|
181
|
+
### iOS Website Association File
|
|
182
|
+
|
|
183
|
+
Host an `apple-app-site-association` file on your relying-party domain:
|
|
184
|
+
|
|
185
|
+
```text
|
|
186
|
+
https://signin.example.com/.well-known/apple-app-site-association
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
Example:
|
|
190
|
+
|
|
191
|
+
```json
|
|
192
|
+
{
|
|
193
|
+
"webcredentials": {
|
|
194
|
+
"apps": [
|
|
195
|
+
"ABCDE12345.app.capgo.passkey.example"
|
|
196
|
+
]
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
Notes:
|
|
202
|
+
|
|
203
|
+
- The file must be served with HTTP `200`.
|
|
204
|
+
- Do not add a `.json` extension.
|
|
205
|
+
- The `webcredentials` domain must match the relying-party id you use for passkeys.
|
|
206
|
+
- The plugin hook writes the associated domains entitlement for you during `cap sync/update`.
|
|
207
|
+
- On iOS 17.4 and newer, the plugin uses the browser-style client-data API so the configured HTTPS origin is reflected in `clientDataJSON`.
|
|
208
|
+
|
|
209
|
+
### Android Website Association File
|
|
210
|
+
|
|
211
|
+
Host a Digital Asset Links file at:
|
|
212
|
+
|
|
213
|
+
```text
|
|
214
|
+
https://signin.example.com/.well-known/assetlinks.json
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
Example:
|
|
218
|
+
|
|
219
|
+
```json
|
|
220
|
+
[
|
|
221
|
+
{
|
|
222
|
+
"relation": [
|
|
223
|
+
"delegate_permission/common.handle_all_urls",
|
|
224
|
+
"delegate_permission/common.get_login_creds"
|
|
225
|
+
],
|
|
226
|
+
"target": {
|
|
227
|
+
"namespace": "android_app",
|
|
228
|
+
"package_name": "app.capgo.passkey.example",
|
|
229
|
+
"sha256_cert_fingerprints": [
|
|
230
|
+
"AA:BB:CC:DD:EE:FF:00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF:00:11:22:33:44:55:66:77:88:99"
|
|
231
|
+
]
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
]
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
- Use the same domain as your relying-party id.
|
|
238
|
+
- Include every signing certificate fingerprint you need, including debug builds if you test them.
|
|
239
|
+
- The plugin hook writes the `asset_statements` metadata and generated string resource for you during `cap sync/update`.
|
|
240
|
+
- Your website still needs to serve the actual `assetlinks.json` file.
|
|
241
|
+
|
|
242
|
+
## Backend Notes
|
|
243
|
+
|
|
244
|
+
This plugin preserves the front-end WebAuthn API shape, but native platforms are not identical to a browser backend contract.
|
|
245
|
+
|
|
246
|
+
- iOS 17.4+ can encode the HTTPS origin you configure for the shim or direct API.
|
|
247
|
+
- Android Credential Manager does **not** act like a privileged browser app. The native response origin is tied to the Android app signature (`android:apk-key-hash:...`), not automatically to your website.
|
|
248
|
+
- With Digital Asset Links configured, Android can still use the same relying party and passkeys as your website. The part that differs is the literal `clientDataJSON.origin` string.
|
|
249
|
+
- If your server strictly validates `clientDataJSON.origin`, allow the Android app origin alongside your web origin.
|
|
250
|
+
- Your backend still needs the normal WebAuthn challenge lifecycle and signature verification.
|
|
251
|
+
|
|
252
|
+
## Web Behavior
|
|
253
|
+
|
|
254
|
+
- On the web, the plugin forwards to the real browser WebAuthn API.
|
|
255
|
+
- On native Capacitor, the shim returns browser-like credential objects backed by native APIs.
|
|
256
|
+
- The `/auto` entrypoint is designed for “import once, keep browser code” setups.
|
|
257
|
+
- Conditional mediation currently returns `false`.
|
|
258
|
+
|
|
259
|
+
## Example App
|
|
260
|
+
|
|
261
|
+
The `example-app/` folder demonstrates the auto-shim flow:
|
|
262
|
+
|
|
263
|
+
- `example-app/capacitor.config.json` configures the plugin.
|
|
264
|
+
- `example-app/src/main.js` imports `@capgo/capacitor-passkey/auto`.
|
|
265
|
+
- The actual registration and authentication still go through `navigator.credentials.create/get`.
|
|
266
|
+
|
|
267
|
+
## API
|
|
268
|
+
|
|
269
|
+
<docgen-index>
|
|
270
|
+
|
|
271
|
+
* [`shimWebAuthn(...)`](#shimwebauthn)
|
|
272
|
+
* [`getConfiguration()`](#getconfiguration)
|
|
273
|
+
* [`autoShimWebAuthn(...)`](#autoshimwebauthn)
|
|
274
|
+
* [`createCredential(...)`](#createcredential)
|
|
275
|
+
* [`getCredential(...)`](#getcredential)
|
|
276
|
+
* [`isSupported()`](#issupported)
|
|
277
|
+
* [`getPluginVersion()`](#getpluginversion)
|
|
278
|
+
* [Interfaces](#interfaces)
|
|
279
|
+
* [Type Aliases](#type-aliases)
|
|
280
|
+
|
|
281
|
+
</docgen-index>
|
|
282
|
+
|
|
283
|
+
<docgen-api>
|
|
284
|
+
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
|
|
285
|
+
|
|
286
|
+
Capacitor Passkey plugin.
|
|
287
|
+
|
|
288
|
+
Use `autoShimWebAuthn()` or import `@capgo/capacitor-passkey/auto`
|
|
289
|
+
to keep existing `navigator.credentials.create/get` code working
|
|
290
|
+
inside a Capacitor app.
|
|
291
|
+
|
|
292
|
+
### shimWebAuthn(...)
|
|
293
|
+
|
|
294
|
+
```typescript
|
|
295
|
+
shimWebAuthn(options?: ShimWebAuthnOptions | undefined) => void
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
Install a browser-style WebAuthn shim on top of the native plugin.
|
|
299
|
+
|
|
300
|
+
The shim patches `navigator.credentials.create/get` for `publicKey`
|
|
301
|
+
requests and returns browser-like credential objects.
|
|
302
|
+
|
|
303
|
+
Use this when you want to override the auto-loaded config manually.
|
|
304
|
+
|
|
305
|
+
| Param | Type |
|
|
306
|
+
| ------------- | ------------------------------------------------------------------- |
|
|
307
|
+
| **`options`** | <code><a href="#shimwebauthnoptions">ShimWebAuthnOptions</a></code> |
|
|
308
|
+
|
|
309
|
+
**Since:** 1.0.0
|
|
310
|
+
|
|
311
|
+
--------------------
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
### getConfiguration()
|
|
315
|
+
|
|
316
|
+
```typescript
|
|
317
|
+
getConfiguration() => Promise<PasskeyRuntimeConfiguration>
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
Load plugin configuration from the host Capacitor app.
|
|
321
|
+
|
|
322
|
+
This reads `plugins.CapacitorPasskey` from `capacitor.config.*`.
|
|
323
|
+
|
|
324
|
+
**Returns:** <code>Promise<<a href="#passkeyruntimeconfiguration">PasskeyRuntimeConfiguration</a>></code>
|
|
325
|
+
|
|
326
|
+
**Since:** 1.1.0
|
|
327
|
+
|
|
328
|
+
--------------------
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
### autoShimWebAuthn(...)
|
|
332
|
+
|
|
333
|
+
```typescript
|
|
334
|
+
autoShimWebAuthn(options?: ShimWebAuthnOptions | undefined) => Promise<PasskeyRuntimeConfiguration>
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
Install the browser-style shim using host app configuration.
|
|
338
|
+
|
|
339
|
+
This is the easiest way to keep existing browser WebAuthn code working:
|
|
340
|
+
configure the plugin in `capacitor.config.*`, then call this once during
|
|
341
|
+
app bootstrap or use the `/auto` entrypoint.
|
|
342
|
+
|
|
343
|
+
| Param | Type |
|
|
344
|
+
| ------------- | ------------------------------------------------------------------- |
|
|
345
|
+
| **`options`** | <code><a href="#shimwebauthnoptions">ShimWebAuthnOptions</a></code> |
|
|
346
|
+
|
|
347
|
+
**Returns:** <code>Promise<<a href="#passkeyruntimeconfiguration">PasskeyRuntimeConfiguration</a>></code>
|
|
348
|
+
|
|
349
|
+
**Since:** 1.1.0
|
|
350
|
+
|
|
351
|
+
--------------------
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
### createCredential(...)
|
|
355
|
+
|
|
356
|
+
```typescript
|
|
357
|
+
createCredential(options: CreateCredentialOptions) => Promise<PasskeyRegistrationCredential>
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
Register a passkey from a JSON-safe WebAuthn request.
|
|
361
|
+
|
|
362
|
+
This method is useful when your backend already returns the
|
|
363
|
+
`PublicKeyCredentialCreationOptionsJSON` form.
|
|
364
|
+
|
|
365
|
+
| Param | Type |
|
|
366
|
+
| ------------- | --------------------------------------------------------------------------- |
|
|
367
|
+
| **`options`** | <code><a href="#createcredentialoptions">CreateCredentialOptions</a></code> |
|
|
368
|
+
|
|
369
|
+
**Returns:** <code>Promise<<a href="#passkeyregistrationcredential">PasskeyRegistrationCredential</a>></code>
|
|
370
|
+
|
|
371
|
+
**Since:** 1.0.0
|
|
372
|
+
|
|
373
|
+
--------------------
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
### getCredential(...)
|
|
377
|
+
|
|
378
|
+
```typescript
|
|
379
|
+
getCredential(options: GetCredentialOptions) => Promise<PasskeyAuthenticationCredential>
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
Authenticate with an existing passkey from a JSON-safe WebAuthn request.
|
|
383
|
+
|
|
384
|
+
This method is useful when your backend already returns the
|
|
385
|
+
`PublicKeyCredentialRequestOptionsJSON` form.
|
|
386
|
+
|
|
387
|
+
| Param | Type |
|
|
388
|
+
| ------------- | --------------------------------------------------------------------- |
|
|
389
|
+
| **`options`** | <code><a href="#getcredentialoptions">GetCredentialOptions</a></code> |
|
|
390
|
+
|
|
391
|
+
**Returns:** <code>Promise<<a href="#passkeyauthenticationcredential">PasskeyAuthenticationCredential</a>></code>
|
|
392
|
+
|
|
393
|
+
**Since:** 1.0.0
|
|
394
|
+
|
|
395
|
+
--------------------
|
|
396
|
+
|
|
397
|
+
|
|
398
|
+
### isSupported()
|
|
399
|
+
|
|
400
|
+
```typescript
|
|
401
|
+
isSupported() => Promise<PasskeySupportResult>
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
Report whether passkeys are available in the current runtime.
|
|
405
|
+
|
|
406
|
+
**Returns:** <code>Promise<<a href="#passkeysupportresult">PasskeySupportResult</a>></code>
|
|
407
|
+
|
|
408
|
+
**Since:** 1.0.0
|
|
409
|
+
|
|
410
|
+
--------------------
|
|
411
|
+
|
|
412
|
+
|
|
413
|
+
### getPluginVersion()
|
|
414
|
+
|
|
415
|
+
```typescript
|
|
416
|
+
getPluginVersion() => Promise<PluginVersionResult>
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
Returns the current platform implementation version marker.
|
|
420
|
+
|
|
421
|
+
**Returns:** <code>Promise<<a href="#pluginversionresult">PluginVersionResult</a>></code>
|
|
422
|
+
|
|
423
|
+
**Since:** 1.0.0
|
|
424
|
+
|
|
425
|
+
--------------------
|
|
426
|
+
|
|
427
|
+
|
|
428
|
+
### Interfaces
|
|
429
|
+
|
|
430
|
+
|
|
431
|
+
#### ShimWebAuthnOptions
|
|
432
|
+
|
|
433
|
+
Options used when installing the browser-style shim.
|
|
434
|
+
|
|
435
|
+
| Prop | Type | Description |
|
|
436
|
+
| ------------ | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
437
|
+
| **`origin`** | <code>string</code> | Optional HTTPS origin to encode into iOS 17.4+ clientDataJSON. Use this when your Capacitor app runs from `capacitor://localhost` but your relying party expects `https://signin.example.com`. |
|
|
438
|
+
| **`force`** | <code>boolean</code> | Force the shim even if the runtime already exposes `navigator.credentials`. Defaults to `false`. |
|
|
439
|
+
|
|
440
|
+
|
|
441
|
+
#### PasskeyRuntimeConfiguration
|
|
442
|
+
|
|
443
|
+
Runtime configuration loaded from the host app's Capacitor config.
|
|
444
|
+
|
|
445
|
+
This is the shape returned by `getConfiguration()`.
|
|
446
|
+
|
|
447
|
+
| Prop | Type | Description |
|
|
448
|
+
| -------------- | ---------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
449
|
+
| **`autoShim`** | <code>boolean</code> | Whether the `/auto` entrypoint should install the shim automatically. Defaults to `true`. |
|
|
450
|
+
| **`origin`** | <code>string</code> | Optional HTTPS origin used by the auto-shim. On iOS 17.4+ this origin is encoded into `clientDataJSON`. |
|
|
451
|
+
| **`domains`** | <code>string[]</code> | Domains associated with the app for passkey usage. These come from `domains` in Capacitor config plus the hostname derived from `origin` when available. |
|
|
452
|
+
| **`platform`** | <code>'ios' \| 'android' \| 'web'</code> | Current runtime platform. |
|
|
453
|
+
|
|
454
|
+
|
|
455
|
+
#### PasskeyRegistrationCredential
|
|
456
|
+
|
|
457
|
+
JSON-safe registration credential returned by the plugin.
|
|
458
|
+
|
|
459
|
+
| Prop | Type | Description |
|
|
460
|
+
| ----------------------------- | ------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------- |
|
|
461
|
+
| **`id`** | <code>string</code> | Base64url-encoded credential identifier. |
|
|
462
|
+
| **`rawId`** | <code>string</code> | Base64url-encoded raw credential identifier. |
|
|
463
|
+
| **`type`** | <code><a href="#passkeycredentialtype">PasskeyCredentialType</a></code> | Credential type. Always `public-key`. |
|
|
464
|
+
| **`authenticatorAttachment`** | <code><a href="#passkeyauthenticatorattachment">PasskeyAuthenticatorAttachment</a></code> | Optional authenticator attachment reported by the platform. |
|
|
465
|
+
| **`clientExtensionResults`** | <code><a href="#record">Record</a><string, unknown></code> | Client extension results returned by the platform. |
|
|
466
|
+
| **`response`** | <code><a href="#passkeyauthenticatorattestationresponsejson">PasskeyAuthenticatorAttestationResponseJSON</a></code> | Registration response payload. |
|
|
467
|
+
|
|
468
|
+
|
|
469
|
+
#### PasskeyAuthenticatorAttestationResponseJSON
|
|
470
|
+
|
|
471
|
+
JSON-safe attestation response payload.
|
|
472
|
+
|
|
473
|
+
All binary fields are base64url encoded.
|
|
474
|
+
|
|
475
|
+
| Prop | Type | Description |
|
|
476
|
+
| ------------------------ | --------------------- | -------------------------------------------------------------------- |
|
|
477
|
+
| **`clientDataJSON`** | <code>string</code> | Base64url-encoded clientDataJSON. |
|
|
478
|
+
| **`attestationObject`** | <code>string</code> | Base64url-encoded attestation object. |
|
|
479
|
+
| **`publicKey`** | <code>string</code> | Optional base64url-encoded public key when provided by the platform. |
|
|
480
|
+
| **`publicKeyAlgorithm`** | <code>number</code> | Optional public key algorithm when provided by the platform. |
|
|
481
|
+
| **`transports`** | <code>string[]</code> | Optional transport list when provided by the platform. |
|
|
482
|
+
|
|
483
|
+
|
|
484
|
+
#### CreateCredentialOptions
|
|
485
|
+
|
|
486
|
+
Direct registration request for the plugin transport.
|
|
487
|
+
|
|
488
|
+
| Prop | Type | Description |
|
|
489
|
+
| --------------- | ----------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
|
|
490
|
+
| **`publicKey`** | <code><a href="#passkeypublickeycredentialcreationoptionsjson">PasskeyPublicKeyCredentialCreationOptionsJSON</a></code> | JSON-safe registration request. |
|
|
491
|
+
| **`origin`** | <code>string</code> | Optional HTTPS origin to use for iOS 17.4+ browser-style clientDataJSON. |
|
|
492
|
+
|
|
493
|
+
|
|
494
|
+
#### PasskeyPublicKeyCredentialCreationOptionsJSON
|
|
495
|
+
|
|
496
|
+
JSON-safe registration request options.
|
|
497
|
+
|
|
498
|
+
All binary fields must be base64url encoded.
|
|
499
|
+
|
|
500
|
+
| Prop | Type | Description |
|
|
501
|
+
| ---------------------------- | --------------------------------------------------------------------------------------- | -------------------------------------------------------------------------- |
|
|
502
|
+
| **`challenge`** | <code>string</code> | Base64url-encoded challenge. |
|
|
503
|
+
| **`rp`** | <code><a href="#passkeyrelyingparty">PasskeyRelyingParty</a></code> | Relying party information. |
|
|
504
|
+
| **`user`** | <code><a href="#passkeyuserentity">PasskeyUserEntity</a></code> | User information. |
|
|
505
|
+
| **`pubKeyCredParams`** | <code>PasskeyCredentialParameter[]</code> | Supported credential algorithms. |
|
|
506
|
+
| **`timeout`** | <code>number</code> | Optional timeout hint in milliseconds. |
|
|
507
|
+
| **`excludeCredentials`** | <code>PasskeyCredentialDescriptor[]</code> | Optional credentials that must be excluded during registration. |
|
|
508
|
+
| **`authenticatorSelection`** | <code><a href="#passkeyauthenticatorselection">PasskeyAuthenticatorSelection</a></code> | Optional authenticator preferences. |
|
|
509
|
+
| **`attestation`** | <code><a href="#passkeyattestation">PasskeyAttestation</a></code> | Optional attestation preference. |
|
|
510
|
+
| **`hints`** | <code>string[]</code> | Optional hints copied from the JSON form used by modern WebAuthn toolkits. |
|
|
511
|
+
| **`extensions`** | <code><a href="#record">Record</a><string, unknown></code> | Optional extensions copied as-is into the request JSON. |
|
|
512
|
+
|
|
513
|
+
|
|
514
|
+
#### PasskeyRelyingParty
|
|
515
|
+
|
|
516
|
+
JSON-safe relying party information.
|
|
517
|
+
|
|
518
|
+
| Prop | Type | Description |
|
|
519
|
+
| ---------- | ------------------- | --------------------------------------------------------------------------------------------------- |
|
|
520
|
+
| **`id`** | <code>string</code> | Relying party identifier. If omitted, the shim derives it from the configured origin when possible. |
|
|
521
|
+
| **`name`** | <code>string</code> | Human-readable relying party name. |
|
|
522
|
+
|
|
523
|
+
|
|
524
|
+
#### PasskeyUserEntity
|
|
525
|
+
|
|
526
|
+
JSON-safe WebAuthn user entity.
|
|
527
|
+
|
|
528
|
+
Binary identifiers must be base64url encoded.
|
|
529
|
+
|
|
530
|
+
| Prop | Type | Description |
|
|
531
|
+
| ----------------- | ------------------- | ------------------------------------------------- |
|
|
532
|
+
| **`id`** | <code>string</code> | Base64url-encoded user handle. |
|
|
533
|
+
| **`name`** | <code>string</code> | User name shown by the authenticator. |
|
|
534
|
+
| **`displayName`** | <code>string</code> | Optional display name shown by the authenticator. |
|
|
535
|
+
|
|
536
|
+
|
|
537
|
+
#### PasskeyCredentialParameter
|
|
538
|
+
|
|
539
|
+
JSON-safe credential parameter entry.
|
|
540
|
+
|
|
541
|
+
| Prop | Type | Description |
|
|
542
|
+
| ---------- | ----------------------------------------------------------------------- | ------------------------------------------------ |
|
|
543
|
+
| **`type`** | <code><a href="#passkeycredentialtype">PasskeyCredentialType</a></code> | Credential type. Only `public-key` is supported. |
|
|
544
|
+
| **`alg`** | <code>number</code> | COSE algorithm identifier. |
|
|
545
|
+
|
|
546
|
+
|
|
547
|
+
#### PasskeyCredentialDescriptor
|
|
548
|
+
|
|
549
|
+
JSON-safe representation of a public key credential descriptor.
|
|
550
|
+
|
|
551
|
+
Binary identifiers must be base64url encoded.
|
|
552
|
+
|
|
553
|
+
| Prop | Type | Description |
|
|
554
|
+
| ---------------- | ----------------------------------------------------------------------- | ------------------------------------------------ |
|
|
555
|
+
| **`id`** | <code>string</code> | Base64url-encoded credential identifier. |
|
|
556
|
+
| **`type`** | <code><a href="#passkeycredentialtype">PasskeyCredentialType</a></code> | Credential type. Only `public-key` is supported. |
|
|
557
|
+
| **`transports`** | <code>string[]</code> | Optional transport hints copied from WebAuthn. |
|
|
558
|
+
|
|
559
|
+
|
|
560
|
+
#### PasskeyAuthenticatorSelection
|
|
561
|
+
|
|
562
|
+
JSON-safe authenticator selection options.
|
|
563
|
+
|
|
564
|
+
| Prop | Type | Description |
|
|
565
|
+
| ----------------------------- | ----------------------------------------------------------------------------------------- | --------------------------------------- |
|
|
566
|
+
| **`authenticatorAttachment`** | <code><a href="#passkeyauthenticatorattachment">PasskeyAuthenticatorAttachment</a></code> | Optional authenticator attachment hint. |
|
|
567
|
+
| **`residentKey`** | <code><a href="#passkeyresidentkey">PasskeyResidentKey</a></code> | Optional resident key preference. |
|
|
568
|
+
| **`requireResidentKey`** | <code>boolean</code> | Legacy resident key requirement flag. |
|
|
569
|
+
| **`userVerification`** | <code><a href="#passkeyuserverification">PasskeyUserVerification</a></code> | Optional user verification preference. |
|
|
570
|
+
|
|
571
|
+
|
|
572
|
+
#### PasskeyAuthenticationCredential
|
|
573
|
+
|
|
574
|
+
JSON-safe authentication credential returned by the plugin.
|
|
575
|
+
|
|
576
|
+
| Prop | Type | Description |
|
|
577
|
+
| ----------------------------- | --------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------- |
|
|
578
|
+
| **`id`** | <code>string</code> | Base64url-encoded credential identifier. |
|
|
579
|
+
| **`rawId`** | <code>string</code> | Base64url-encoded raw credential identifier. |
|
|
580
|
+
| **`type`** | <code><a href="#passkeycredentialtype">PasskeyCredentialType</a></code> | Credential type. Always `public-key`. |
|
|
581
|
+
| **`authenticatorAttachment`** | <code><a href="#passkeyauthenticatorattachment">PasskeyAuthenticatorAttachment</a></code> | Optional authenticator attachment reported by the platform. |
|
|
582
|
+
| **`clientExtensionResults`** | <code><a href="#record">Record</a><string, unknown></code> | Client extension results returned by the platform. |
|
|
583
|
+
| **`response`** | <code><a href="#passkeyauthenticatorassertionresponsejson">PasskeyAuthenticatorAssertionResponseJSON</a></code> | Assertion response payload. |
|
|
584
|
+
|
|
585
|
+
|
|
586
|
+
#### PasskeyAuthenticatorAssertionResponseJSON
|
|
587
|
+
|
|
588
|
+
JSON-safe assertion response payload.
|
|
589
|
+
|
|
590
|
+
All binary fields are base64url encoded.
|
|
591
|
+
|
|
592
|
+
| Prop | Type | Description |
|
|
593
|
+
| ----------------------- | --------------------------- | --------------------------------------- |
|
|
594
|
+
| **`clientDataJSON`** | <code>string</code> | Base64url-encoded clientDataJSON. |
|
|
595
|
+
| **`authenticatorData`** | <code>string</code> | Base64url-encoded authenticator data. |
|
|
596
|
+
| **`signature`** | <code>string</code> | Base64url-encoded signature. |
|
|
597
|
+
| **`userHandle`** | <code>string \| null</code> | Optional base64url-encoded user handle. |
|
|
598
|
+
|
|
599
|
+
|
|
600
|
+
#### GetCredentialOptions
|
|
601
|
+
|
|
602
|
+
Direct authentication request for the plugin transport.
|
|
603
|
+
|
|
604
|
+
| Prop | Type | Description |
|
|
605
|
+
| --------------- | --------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
|
|
606
|
+
| **`publicKey`** | <code><a href="#passkeypublickeycredentialrequestoptionsjson">PasskeyPublicKeyCredentialRequestOptionsJSON</a></code> | JSON-safe authentication request. |
|
|
607
|
+
| **`mediation`** | <code>string</code> | Optional mediation hint. `conditional` currently falls back to an explicit prompt. |
|
|
608
|
+
| **`origin`** | <code>string</code> | Optional HTTPS origin to use for iOS 17.4+ browser-style clientDataJSON. |
|
|
609
|
+
|
|
610
|
+
|
|
611
|
+
#### PasskeyPublicKeyCredentialRequestOptionsJSON
|
|
612
|
+
|
|
613
|
+
JSON-safe authentication request options.
|
|
614
|
+
|
|
615
|
+
All binary fields must be base64url encoded.
|
|
616
|
+
|
|
617
|
+
| Prop | Type | Description |
|
|
618
|
+
| ---------------------- | --------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
|
|
619
|
+
| **`challenge`** | <code>string</code> | Base64url-encoded challenge. |
|
|
620
|
+
| **`timeout`** | <code>number</code> | Optional timeout hint in milliseconds. |
|
|
621
|
+
| **`rpId`** | <code>string</code> | Optional relying party identifier. If omitted, the shim derives it from the configured origin when possible. |
|
|
622
|
+
| **`allowCredentials`** | <code>PasskeyCredentialDescriptor[]</code> | Optional allow list copied from WebAuthn. |
|
|
623
|
+
| **`userVerification`** | <code><a href="#passkeyuserverification">PasskeyUserVerification</a></code> | Optional user verification preference. |
|
|
624
|
+
| **`hints`** | <code>string[]</code> | Optional hints copied from the JSON form used by modern WebAuthn toolkits. |
|
|
625
|
+
| **`extensions`** | <code><a href="#record">Record</a><string, unknown></code> | Optional extensions copied as-is into the request JSON. |
|
|
626
|
+
|
|
627
|
+
|
|
628
|
+
#### PasskeySupportResult
|
|
629
|
+
|
|
630
|
+
Passkey support status for the current runtime.
|
|
631
|
+
|
|
632
|
+
| Prop | Type | Description |
|
|
633
|
+
| -------------------------- | ---------------------------------------- | ------------------------------------------------------ |
|
|
634
|
+
| **`available`** | <code>boolean</code> | Whether passkeys are available on the current runtime. |
|
|
635
|
+
| **`conditionalMediation`** | <code>boolean</code> | Whether conditional mediation is available. |
|
|
636
|
+
| **`platform`** | <code>'ios' \| 'android' \| 'web'</code> | Current platform identifier. |
|
|
637
|
+
|
|
638
|
+
|
|
639
|
+
#### PluginVersionResult
|
|
640
|
+
|
|
641
|
+
Plugin version payload.
|
|
642
|
+
|
|
643
|
+
| Prop | Type | Description |
|
|
644
|
+
| ------------- | ------------------- | ------------------------------------------------------------------- |
|
|
645
|
+
| **`version`** | <code>string</code> | Version identifier reported by the current platform implementation. |
|
|
646
|
+
|
|
647
|
+
|
|
648
|
+
### Type Aliases
|
|
649
|
+
|
|
650
|
+
|
|
651
|
+
#### PasskeyCredentialType
|
|
652
|
+
|
|
653
|
+
Supported WebAuthn credential type.
|
|
654
|
+
|
|
655
|
+
<code>'public-key'</code>
|
|
656
|
+
|
|
657
|
+
|
|
658
|
+
#### PasskeyAuthenticatorAttachment
|
|
659
|
+
|
|
660
|
+
Supported authenticator attachment values.
|
|
661
|
+
|
|
662
|
+
<code>'platform' | 'cross-platform'</code>
|
|
663
|
+
|
|
664
|
+
|
|
665
|
+
#### Record
|
|
666
|
+
|
|
667
|
+
Construct a type with a set of properties K of type T
|
|
668
|
+
|
|
669
|
+
<code>{
|
|
670
|
[P in K]: T;
|
|
1
671
|
}</code>
|
|
672
|
+
|
|
673
|
+
|
|
674
|
+
#### PasskeyResidentKey
|
|
675
|
+
|
|
676
|
+
Supported resident key preferences.
|
|
677
|
+
|
|
678
|
+
<code>'discouraged' | 'preferred' | 'required'</code>
|
|
679
|
+
|
|
680
|
+
|
|
681
|
+
#### PasskeyUserVerification
|
|
682
|
+
|
|
683
|
+
Supported user verification preferences.
|
|
684
|
+
|
|
685
|
+
<code>'discouraged' | 'preferred' | 'required'</code>
|
|
686
|
+
|
|
687
|
+
|
|
688
|
+
#### PasskeyAttestation
|
|
689
|
+
|
|
690
|
+
Supported attestation preferences.
|
|
691
|
+
|
|
692
|
+
<code>'none' | 'indirect' | 'direct' | 'enterprise'</code>
|
|
693
|
+
|
|
694
|
+
</docgen-api>
|