@le-space/orbitdb-identity-provider-webauthn-did 0.12.2 → 0.14.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/CHANGELOG.md +153 -2
- package/README.md +145 -11
- package/docs/API.md +119 -12
- package/package.json +12 -3
- package/src/elements/index.js +41 -0
- package/src/elements/passkey-step-dialog.js +366 -0
- package/src/errors.js +5 -2
- package/src/index.js +15 -0
- package/src/keystore/derived-signing-key.js +2 -0
- package/src/keystore/encryption.js +7 -0
- package/src/keystore/prf-keys.js +2 -0
- package/src/keystore/provider.js +45 -12
- package/src/keystore/vault-keeper.js +171 -21
- package/src/keystore/vault.js +94 -19
- package/src/passkey-steps.js +183 -0
- package/src/standalone/index.js +11 -0
- package/src/standalone/webauthn/credential.js +2 -0
- package/src/standalone/webauthn/p256-wallet.js +10 -0
- package/src/varsig/assertion.js +2 -0
- package/src/varsig/credential.js +2 -0
- package/src/vault/index.js +1 -0
- package/src/webauthn/config.js +23 -0
- package/src/webauthn/large-blob-metadata.js +3 -0
- package/src/webauthn/proof-verification.js +172 -9
- package/src/webauthn/provider.js +32 -16
- package/src/webauthn/restore.js +3 -0
- package/types/elements.d.ts +54 -0
- package/types/index.d.ts +51 -5
- package/types/keystore.d.ts +5 -2
- package/types/passkey-steps.d.ts +51 -0
- package/types/standalone.d.ts +42 -6
- package/types/vault.d.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,149 @@
|
|
|
1
1
|
# Changes
|
|
2
2
|
|
|
3
|
+
## 0.14.0
|
|
4
|
+
|
|
5
|
+
An identity proof is a proof and nothing else: its challenge is labelled, and no longer something a
|
|
6
|
+
signature made for another protocol can stand in for.
|
|
7
|
+
|
|
8
|
+
A vault that replaces another says so, and a keeper never steps back to the one from before.
|
|
9
|
+
|
|
10
|
+
### Breaking
|
|
11
|
+
|
|
12
|
+
- **New identity proofs are in a new format, which 0.12.x and earlier cannot verify.** Update every
|
|
13
|
+
peer that verifies identities — relays included — before any device creates a new identity proof
|
|
14
|
+
on 0.14.0. A device that already has a proof stored keeps using it, so nothing changes for it until
|
|
15
|
+
the application refuses the first format (below).
|
|
16
|
+
|
|
17
|
+
### Security
|
|
18
|
+
|
|
19
|
+
- **One 32-byte signature by the passkey could be turned into an identity for its DID.** The proof in
|
|
20
|
+
`signatures.publicKey` is a WebAuthn assertion, and its challenge was `SHA-256(credentialId ‖ data)`
|
|
21
|
+
— 32 bytes, a bare hash. The same passkey may sign for other protocols: since 0.8.0 it is meant to
|
|
22
|
+
be a wallet key, and `signP256Challenge` signs any 32 bytes it is given. So a signature over a value
|
|
23
|
+
somebody chose was, byte for byte, an identity proof for whatever that value hashed. An application
|
|
24
|
+
that let the passkey sign one attacker-supplied "hash" handed out a permanent binding of the
|
|
25
|
+
attacker's key to the victim's DID — proofs do not expire. Nothing this package ships signs chosen
|
|
26
|
+
values (`@le-space/passkey-wallet` signs keccak hashes only), which is why this is a hazard for
|
|
27
|
+
applications rather than a hole in them all. Found in an audit of 0.12.2.
|
|
28
|
+
|
|
29
|
+
A label inside the hash would not have helped, since whoever picks the 32 bytes can hash the label
|
|
30
|
+
in. The challenge itself is now
|
|
31
|
+
`"orbitdb-webauthn-did:v2:<context>:" ‖ SHA-256(len(credentialId) ‖ credentialId ‖ data)`: longer
|
|
32
|
+
than any hash and starting with text, so nothing that signs a 32-byte challenge can produce it, and
|
|
33
|
+
a proof cannot pass for a wallet signature either. The context keeps an identity binding
|
|
34
|
+
(`identity`) apart from what `WebAuthnDIDProvider.sign(data)` makes for an application (`data`): a
|
|
35
|
+
proof over text an application was handed is not an identity. The credential id, which the proof
|
|
36
|
+
names and the verifier cannot check, is length-prefixed. A proof in this format must also show the
|
|
37
|
+
user was verified, not merely present — `sign()` always asked for it, and nothing checked.
|
|
38
|
+
|
|
39
|
+
- **The first format still verifies unless the application refuses it**, because every identity made
|
|
40
|
+
before, and everything those identities wrote, is in it. While it does, the hole is open on the
|
|
41
|
+
verifying side — an attacker forges a first-format proof whatever format the victim uses.
|
|
42
|
+
`configureWebAuthn({ acceptLegacyProofs: false })` refuses it; a device with such a proof stored
|
|
43
|
+
then makes a new one (one passkey prompt, a new identity document, the same DID), and entries
|
|
44
|
+
written under the old document no longer verify on a peer that syncs them afresh. Unset, a
|
|
45
|
+
first-format proof is accepted with one console notice; `true` accepts without it. An application
|
|
46
|
+
with no history to keep should refuse from the start. See the README, "Identity proofs, and the
|
|
47
|
+
first format".
|
|
48
|
+
|
|
49
|
+
- **A vault from before a renewal was taken as readily as the renewal.** `renew` is the answer to a
|
|
50
|
+
stolen authenticator: a new vault key, a new vault, no slot for the key that went. The old record
|
|
51
|
+
still exists wherever it was copied to, still opens for the authenticators that stayed, and still
|
|
52
|
+
carries the stolen one's slot. A keeper took whatever `find` gave it and — once it kept a vault —
|
|
53
|
+
never asked again, so a device shown the old record sealed everything that followed under a vault
|
|
54
|
+
key the stolen authenticator knows, and a device that had adopted it stayed there for good. Found
|
|
55
|
+
in an audit of 0.12.2.
|
|
56
|
+
|
|
57
|
+
A renewed vault now carries a **generation**, one more than the vault it replaces, sealed into
|
|
58
|
+
every slot (vault format version 2). A slot is sealed under a key only its authenticator derives,
|
|
59
|
+
so each one that stays vouches for the number, and a removed authenticator — which knows the old
|
|
60
|
+
vault key and nothing more — cannot pass an old vault off as newer. The keeper asks `find` on every
|
|
61
|
+
unlock, takes one record or several, and of everything this authenticator's slot opens keeps the
|
|
62
|
+
latest: a renewal made elsewhere is picked up as soon as it is shown, and nothing older than the
|
|
63
|
+
vault kept here is ever taken. A record with this authenticator's slot that cannot be read — cut
|
|
64
|
+
short, altered, or of a later format — is refused (`VAULT_MALFORMED`) on a device with nothing
|
|
65
|
+
kept, as before, rather than passed over: a new vault made in its place would part the device from
|
|
66
|
+
the real one for good.
|
|
67
|
+
|
|
68
|
+
**What this cannot do:** a device with nothing kept, shown _only_ the old record, still opens it —
|
|
69
|
+
no record says it was replaced. Put the renewed record wherever `find` reads from at once, and
|
|
70
|
+
where the generation is known from something trusted, pass `open({ minGeneration })`: anything
|
|
71
|
+
earlier is refused (`VAULT_SUPERSEDED`), neither kept nor replaced by a new vault.
|
|
72
|
+
|
|
73
|
+
A vault made fresh is unchanged — version 1, generation 0, byte for byte what 0.12.x wrote and
|
|
74
|
+
reads. A _renewed_ vault is version 2, which 0.12.x refuses as malformed: update every device
|
|
75
|
+
before renewing.
|
|
76
|
+
|
|
77
|
+
### Fixed
|
|
78
|
+
|
|
79
|
+
- **A cancel at the keystore step no longer makes the identity without it.** With
|
|
80
|
+
`encryptKeystore`, `createIdentity` caught every failure to create or unlock the encrypted
|
|
81
|
+
keystore, logged it and went on, and the two wrapped what they caught in an error of their own. So
|
|
82
|
+
a person who pressed Cancel on the step announced since 0.13.0 got an identity whose keystore key
|
|
83
|
+
is not sealed, or, with `useKeystoreDID`, the same prompt again and then a plain `Error`.
|
|
84
|
+
`PasskeyStepCancelled` now passes through all of them unchanged, as 0.13.0 promised.
|
|
85
|
+
|
|
86
|
+
### Added
|
|
87
|
+
|
|
88
|
+
- `generationOf(vault)` and `createVault(payload, slot, { generation })` in the main entry,
|
|
89
|
+
`./standalone` and `./vault`; `open({ find, minGeneration })` on the vault keeper, where `find` may
|
|
90
|
+
return several records, and `generation` and `findError` on what it returns; the `VaultError` code
|
|
91
|
+
`VAULT_SUPERSEDED`.
|
|
92
|
+
- `configureWebAuthn({ acceptLegacyProofs })`; `sign(data, { context })` and
|
|
93
|
+
`verify(proof, data, publicKey, { context, acceptLegacyProofs })` on `WebAuthnDIDProvider`;
|
|
94
|
+
`PROOF_CONTEXTS` and `proofFormat(proof)` (`1`, `2` or `null`, by the challenge) in the main entry.
|
|
95
|
+
|
|
96
|
+
Tested in `tests/identity-proof-context.test.js`: the attack itself — a wallet signature over a
|
|
97
|
+
chosen 32 bytes verifies as an identity for the victim's DID in the first format, and no longer once
|
|
98
|
+
it is refused; the wallet signer refuses a current-format challenge; a proof made for an application
|
|
99
|
+
is not an identity; a touch without verification is not enough; and a device keeps a stored
|
|
100
|
+
first-format proof while it is accepted and replaces it once it is refused.
|
|
101
|
+
|
|
102
|
+
And in `tests/vault-generation.test.js`: the generation is sealed into slot and payload, and a
|
|
103
|
+
removed authenticator relabelling the old vault as newer gets a record that does not open; shown the
|
|
104
|
+
old and the renewed record in either order a device opens the renewed one; a device on the old vault
|
|
105
|
+
moves forward when shown the renewal, and one on the renewal is not moved back; `minGeneration`
|
|
106
|
+
refuses the old vault before it is kept; a record that cannot be read makes no vault of its own —
|
|
107
|
+
and, stated as a test, the limit above. The cancel at the keystore step is in
|
|
108
|
+
`tests/passkey-steps.test.js`, through `createIdentity` with and without `useKeystoreDID`.
|
|
109
|
+
|
|
110
|
+
## 0.13.0
|
|
111
|
+
|
|
112
|
+
An application can now say, before each passkey prompt, what it is for — and `./elements` brings a
|
|
113
|
+
dialog that does it.
|
|
114
|
+
|
|
115
|
+
### Added
|
|
116
|
+
|
|
117
|
+
- **Before each passkey prompt, a word on what it is for.** Creating a passkey-backed identity asks
|
|
118
|
+
the authenticator three times in a row, and restoring one does too. Without a word in between
|
|
119
|
+
that looks like a loop, and people cancel it. Le-Space/belege put a dialog between its prompts
|
|
120
|
+
(#429), but only this package knows when it is about to ask and why. Every WebAuthn call here now
|
|
121
|
+
first awaits `beforePasskeyCeremony(purpose)`. An application registers a handler with
|
|
122
|
+
`setPasskeyStepHandler` and numbers an action's prompts with `withPasskeySteps(of, run)`. Every
|
|
123
|
+
prompt after the first is then announced, with its purpose, and starts from the click that
|
|
124
|
+
answers it. A cancel (`PasskeyStepCancelled`) stops before the authenticator is asked and reaches
|
|
125
|
+
the caller unchanged, also through `sign()` and the signing key's PRF read, which turn other
|
|
126
|
+
failures into errors or fallbacks of their own. Without a handler, or outside a plan, nothing
|
|
127
|
+
changes. Exported from the root and from `./standalone`.
|
|
128
|
+
- **`./elements` with `<passkey-step-dialog>`:** that handler without a framework, after belege's
|
|
129
|
+
`PasskeyStepDialog.svelte`. It shows "Passkey prompt n of m", a title and a reason per purpose,
|
|
130
|
+
and **Continue** / **Cancel**. Its wording is in English and German and can be replaced per
|
|
131
|
+
language; its colours come from custom properties. `connectPasskeyStepDialog(element)` makes it
|
|
132
|
+
the handler. Le-Space/simple-todo's escrow01 is the first application to use it.
|
|
133
|
+
|
|
134
|
+
Tested in `tests/passkey-steps.test.js` (Node, through `createCredential`, the signing key's PRF
|
|
135
|
+
read, `sign()` and the restore against the mock authenticator) and
|
|
136
|
+
`tests/passkey-step-dialog.test.js` (Chromium, with its own `playwright.elements.config.js`, run in
|
|
137
|
+
CI once the browsers are installed).
|
|
138
|
+
|
|
139
|
+
### Repository
|
|
140
|
+
|
|
141
|
+
- **No `@libp2p/crypto` below 5.1.22 in this repository's own install** (#102). Up to 5.1.21 it is
|
|
142
|
+
affected by GHSA-rvfr-cqwq-rc4j: its ASN.1 DER decoder can be driven into a long synchronous
|
|
143
|
+
loop by a remote peer before authentication. The override applies to this repository's lockfile
|
|
144
|
+
only. The package's own range, `^5.1.20`, already admits 5.1.22, so an application resolving it
|
|
145
|
+
fresh gets the fixed version; one with an older lockfile should update it.
|
|
146
|
+
|
|
3
147
|
## 0.12.2
|
|
4
148
|
|
|
5
149
|
A request that names a passkey asks that passkey. Until now this entry stood under 0.12.1, but
|
|
@@ -16,8 +160,15 @@ A request that names a passkey asks that passkey. Until now this entry stood und
|
|
|
16
160
|
(`WebAuthnAuthenticationError`), and the provider's own read for the signing key derives nothing
|
|
17
161
|
from it. Found in simple-todo's invoice01: a second passkey's vault slot was sealed under the
|
|
18
162
|
first one's PRF output, and the second passkey could not open it. Le-Space/belege has asked with
|
|
19
|
-
`discoverableCredentials: false` since its #429 for this reason
|
|
20
|
-
|
|
163
|
+
`discoverableCredentials: false` since its #429 for this reason. simple-todo's archived01 asked
|
|
164
|
+
through `readPrfOutput` without it, and is fixed by updating to 0.12.2.
|
|
165
|
+
- **`extractPrfSeedFromCredential` named the credential all along, by accident.** From 0.2.8 on it
|
|
166
|
+
passes `discoverableCredentials` on from its own options, and a key that is there but `undefined`
|
|
167
|
+
counted as off; only a caller passing `true` was affected. It still does not check which
|
|
168
|
+
credential answered: `readPrfOutput` does. Le-Space/invoice reads through it, so its requests
|
|
169
|
+
named the passkey; it took any answer, and now reads through `readPrfOutput`
|
|
170
|
+
(Le-Space/invoice#64). This entry first counted Le-Space/invoice among the applications that
|
|
171
|
+
asked without a credential.
|
|
21
172
|
|
|
22
173
|
Tested in `tests/prf-keys.test.js` with discoverable credentials on: a request names the credential
|
|
23
174
|
it asks, and another credential's answer is refused.
|
package/README.md
CHANGED
|
@@ -127,6 +127,37 @@ says no, a webauthn identity is checked again the way an uncached one would be
|
|
|
127
127
|
signature over the public key, and this provider's binding of the key to the DID. Other providers'
|
|
128
128
|
identities, and anything that fails those checks, stay refused.
|
|
129
129
|
|
|
130
|
+
### Identity proofs, and the first format
|
|
131
|
+
|
|
132
|
+
A passkey identity carries a proof that the passkey vouches for its signing key: a WebAuthn
|
|
133
|
+
assertion in `signatures.publicKey`. Until 0.14.0 that assertion's challenge was
|
|
134
|
+
`SHA-256(credentialId ‖ data)` — 32 bytes, a bare hash. The same passkey may sign for other
|
|
135
|
+
protocols, and a wallet signs any 32 bytes it is handed, so **one wallet signature over a value
|
|
136
|
+
somebody chose was a valid identity for the passkey's DID**, for good.
|
|
137
|
+
|
|
138
|
+
From 0.14.0 the challenge is labelled and longer than any hash —
|
|
139
|
+
`"orbitdb-webauthn-did:v2:identity:" ‖ SHA-256(…)` — which nothing that signs a 32-byte challenge
|
|
140
|
+
can produce. New identities get such a proof. Verification takes both formats by default, because
|
|
141
|
+
every identity made before, and everything those identities wrote, is in the first:
|
|
142
|
+
|
|
143
|
+
```javascript
|
|
144
|
+
import { configureWebAuthn } from '@le-space/orbitdb-identity-provider-webauthn-did';
|
|
145
|
+
|
|
146
|
+
configureWebAuthn({ acceptLegacyProofs: false }); // refuse the first format
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
- **Unset** (default): the first format verifies, with one console notice. The hole stays open on
|
|
150
|
+
this peer: an attacker forges a first-format proof whatever format the victim uses.
|
|
151
|
+
- **`false`**: the first format is refused, and a device that has such a proof stored makes a new
|
|
152
|
+
one — one passkey prompt, a new identity document, the same DID. Entries written under the old
|
|
153
|
+
document no longer verify on a peer that syncs them afresh. For an application without history
|
|
154
|
+
to keep, set this from the start.
|
|
155
|
+
- **`true`**: accepted knowingly, without the notice.
|
|
156
|
+
|
|
157
|
+
**Rolling out.** A peer on 0.12.x or earlier cannot verify the new format. Update every peer that
|
|
158
|
+
verifies identities — relays too — before any device creates a new identity proof on 0.14.0; devices
|
|
159
|
+
that already have one stored keep using it and are not affected.
|
|
160
|
+
|
|
130
161
|
### Discoverable Recovery Notes
|
|
131
162
|
|
|
132
163
|
For the DID-based flow:
|
|
@@ -140,6 +171,38 @@ Two ways past that, and the first keeps nothing:
|
|
|
140
171
|
1. `restoreIdentityFromAuthenticator()` — two discoverable assertions, from which `recoverPublicKey()` returns the credential's public key and with it the DID (0.6.0)
|
|
141
172
|
2. metadata written at registration — `largeBlob` where it comes back, otherwise browser storage — which the demos still do, because a stored copy spares both touches
|
|
142
173
|
|
|
174
|
+
### Saying what each passkey prompt is for
|
|
175
|
+
|
|
176
|
+
Creating a passkey-backed identity asks the authenticator three times in a row, and restoring one does too. Without a word in between, that looks like a loop. Every WebAuthn call in this package first awaits a step hook, so an application can show what the next prompt is for and start it from a click:
|
|
177
|
+
|
|
178
|
+
```js
|
|
179
|
+
import {
|
|
180
|
+
WebAuthnDIDProvider,
|
|
181
|
+
OrbitDBWebAuthnIdentityProviderFunction,
|
|
182
|
+
withPasskeySteps,
|
|
183
|
+
} from '@le-space/orbitdb-identity-provider-webauthn-did';
|
|
184
|
+
import { connectPasskeyStepDialog } from '@le-space/orbitdb-identity-provider-webauthn-did/elements';
|
|
185
|
+
|
|
186
|
+
// <passkey-step-dialog></passkey-step-dialog> somewhere in the page
|
|
187
|
+
connectPasskeyStepDialog(document.querySelector('passkey-step-dialog'));
|
|
188
|
+
|
|
189
|
+
const identity = await withPasskeySteps(3, async () => {
|
|
190
|
+
// 1 of 3: the passkey, from the click that started this
|
|
191
|
+
const credential = await WebAuthnDIDProvider.createCredential({
|
|
192
|
+
userId,
|
|
193
|
+
displayName,
|
|
194
|
+
});
|
|
195
|
+
// 2 and 3 of 3, each announced: the signing key's PRF output, the identity signature
|
|
196
|
+
return identities.createIdentity({
|
|
197
|
+
provider: OrbitDBWebAuthnIdentityProviderFunction({
|
|
198
|
+
webauthnCredential: credential,
|
|
199
|
+
}),
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
Between two prompts, `<passkey-step-dialog>` shows "Passkey prompt 2 of 3", what the prompt is for and why, then **Continue**, which starts it, or **Cancel**, which rejects with `PasskeyStepCancelled` before the authenticator is asked. It has no framework, its wording is built in for English and German and can be replaced per language, and it takes its colours from custom properties. Without a handler, or outside `withPasskeySteps`, nothing changes. See [Passkey Steps](docs/API.md#passkey-steps).
|
|
205
|
+
|
|
143
206
|
### Hardware-Secured Varsig Quick Start
|
|
144
207
|
|
|
145
208
|
```javascript
|
|
@@ -231,6 +294,7 @@ const { authenticatorData, clientDataJSON, challengeIndex, typeIndex, r, s } =
|
|
|
231
294
|
- **Key.** `x` and `y` are 32-byte big-endian `Uint8Array`s, like `publicKey.x`/`y` on the default path; Calibur's `abi.encode(uint256 x, uint256 y)` is the two concatenated. They come from `publicKey` (`{ x, y }` or SEC1 bytes) or, failing that, from a P-256 `did:key`; where both are present they must agree. `rpId` is the one `createCredential` returns; a credential stored before it returned one falls back to `window.location.hostname`.
|
|
232
295
|
- **`null`** for RS256 and Ed25519 keys, for the placeholder `createCredential` writes when it cannot read the public key (also once largeBlob metadata has dropped its `synthetic` flag: the point is not on the curve), and for anything unreadable.
|
|
233
296
|
- **Signing.** Unlike other requests, this one pins `allowCredentials` to the descriptor, whatever `configureWebAuthn` says, and requires user verification. An assertion from another credential is refused. The challenge is used as the WebAuthn challenge itself, as Calibur passes its hash.
|
|
297
|
+
- **Only ever a protocol's own hash.** `signP256Challenge` signs whatever 32 bytes it is given, so give it a user operation hash or an ERC-7739 digest and never a value somebody else chose. Identity proofs made before 0.14.0 used a bare 32-byte hash as their challenge too, and one signature over a chosen value was an identity for the passkey's DID — see [Identity proofs](#identity-proofs-and-the-first-format).
|
|
234
298
|
- **Result**: the fields of webauthn-sol's `WebAuthnAuth`. `r` and `s` are 32 bytes big-endian, `s` normalised to low-s (webauthn-sol refuses `s > n/2`). `clientDataJSON` is a string; `typeIndex` and `challengeIndex` are the UTF-8 byte offsets of `"type":"webauthn.get"` and `"challenge":"<base64url(challenge), unpadded>"` in it. The signature is verified against `x`/`y` before it is returned; anything a verifier would refuse throws instead.
|
|
235
299
|
|
|
236
300
|
| Signing mode | Descriptor |
|
|
@@ -280,6 +344,64 @@ const opened = await keeper.open({
|
|
|
280
344
|
|
|
281
345
|
Since **0.10.0**, a secret kept in that vault can be an identity of its own: `createSecretSigner(secret, { info })` turns it into an Ed25519 signer for the provider's `signer` option, so every key that opens the vault writes as the same identity — the root of a database's access controller, which a single passkey's identity would hold for good. See [docs/API.md](docs/API.md#an-identity-that-is-nobodys-passkey-createsecretsignersecret--info-).
|
|
282
346
|
|
|
347
|
+
### Default path (passkey DID + derived signing key)
|
|
348
|
+
|
|
349
|
+
```mermaid
|
|
350
|
+
sequenceDiagram
|
|
351
|
+
autonumber
|
|
352
|
+
participant User
|
|
353
|
+
participant App
|
|
354
|
+
participant WebAuthn
|
|
355
|
+
participant Auth as Authenticator
|
|
356
|
+
participant Prov as WebAuthn provider
|
|
357
|
+
participant KS as OrbitDB keystore
|
|
358
|
+
participant DB as OrbitDB
|
|
359
|
+
|
|
360
|
+
User->>App: Create credential
|
|
361
|
+
App->>WebAuthn: create() with PRF and largeBlob requested
|
|
362
|
+
WebAuthn->>Auth: Create passkey
|
|
363
|
+
Auth-->>WebAuthn: Attestation
|
|
364
|
+
WebAuthn-->>App: Credential
|
|
365
|
+
|
|
366
|
+
App->>Prov: createIdentity({ webauthnCredential })
|
|
367
|
+
Prov->>Prov: DID = did:key of the passkey's P-256 key
|
|
368
|
+
alt the keystore already holds a key for the DID
|
|
369
|
+
Note right of Prov: Nothing asked. That key stays.
|
|
370
|
+
else prfOutput handed over (one touch)
|
|
371
|
+
Prov->>KS: addKey(DID, key derived from prfOutput)
|
|
372
|
+
else the provider asks
|
|
373
|
+
Prov->>WebAuthn: get() with PRF
|
|
374
|
+
WebAuthn->>Auth: User verification
|
|
375
|
+
alt PRF output
|
|
376
|
+
Auth-->>Prov: PRF output
|
|
377
|
+
Prov->>KS: addKey(DID, HKDF(PRF output, DID) gives secp256k1 or Ed25519)
|
|
378
|
+
else no PRF
|
|
379
|
+
Auth-->>Prov: no PRF result
|
|
380
|
+
Note right of Prov: OrbitDB generates a random key. Stable on this device only.
|
|
381
|
+
end
|
|
382
|
+
end
|
|
383
|
+
alt identity signature stored (localStorage)
|
|
384
|
+
Prov->>Prov: reuse it
|
|
385
|
+
else first time on this device
|
|
386
|
+
Prov->>WebAuthn: get() over publicKey + idSignature
|
|
387
|
+
WebAuthn->>Auth: User verification
|
|
388
|
+
Auth-->>Prov: Assertion, becomes signatures.publicKey
|
|
389
|
+
end
|
|
390
|
+
Prov-->>App: Identity
|
|
391
|
+
|
|
392
|
+
User->>App: Add entry
|
|
393
|
+
App->>DB: db.put()
|
|
394
|
+
DB->>KS: sign entry with the derived key
|
|
395
|
+
KS-->>DB: Entry signature
|
|
396
|
+
|
|
397
|
+
Note over App,KS: No prompt per write. The derived key sits in OrbitDB's keystore unencrypted.
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
An application that reads the PRF output for keys of its own hands it over as
|
|
401
|
+
`prfOutput` and saves the second touch. That path, a vault a second security
|
|
402
|
+
key opens, and an identity derived from a secret in the vault are drawn in
|
|
403
|
+
[docs/EXAMPLE-SEQUENCES.md](docs/EXAMPLE-SEQUENCES.md).
|
|
404
|
+
|
|
283
405
|
### Keystore-based DID (WebAuthn + OrbitDB keystore)
|
|
284
406
|
|
|
285
407
|
```mermaid
|
|
@@ -456,8 +578,8 @@ forgeries.
|
|
|
456
578
|
|
|
457
579
|
The identity for each option is built by one module under
|
|
458
580
|
`examples/shared/lib/options/`, which is also the shortest way to read the
|
|
459
|
-
API; `docs/EXAMPLE-SEQUENCES.md` walks through the three sequences
|
|
460
|
-
prompt counts.
|
|
581
|
+
API; `docs/EXAMPLE-SEQUENCES.md` walks through the three sequences, three
|
|
582
|
+
more an application builds around them, and their prompt counts.
|
|
461
583
|
|
|
462
584
|
### In other repositories
|
|
463
585
|
|
|
@@ -479,15 +601,27 @@ Three consumers that show the package doing a whole job rather than one call:
|
|
|
479
601
|
|
|
480
602
|
## Documentation
|
|
481
603
|
|
|
482
|
-
- `docs/API.md`
|
|
483
|
-
|
|
484
|
-
- `docs/
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
- `docs/
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
- `
|
|
604
|
+
- [`docs/API.md`](docs/API.md) — the reference: every export, its options
|
|
605
|
+
and defaults, and what it throws.
|
|
606
|
+
- [`docs/EXAMPLE-SEQUENCES.md`](docs/EXAMPLE-SEQUENCES.md) — one sequence
|
|
607
|
+
diagram per way of using the package, what a peer verifies for each, and
|
|
608
|
+
how many passkey prompts each costs.
|
|
609
|
+
- [`docs/WEBAUTHN-DID-AND-ORBITDB-IDENTITY.md`](docs/WEBAUTHN-DID-AND-ORBITDB-IDENTITY.md)
|
|
610
|
+
— which DID an identity has, which key signs its entries, how the DID
|
|
611
|
+
relates to the identity hash, and how peers check the binding.
|
|
612
|
+
- [`docs/ED25519-KEYSTORE-DID.md`](docs/ED25519-KEYSTORE-DID.md) — the
|
|
613
|
+
keystore DID (`useKeystoreDID`) in detail.
|
|
614
|
+
- [`docs/WEBAUTHN-ENCRYPTED-KEYSTORE-INTEGRATION.md`](docs/WEBAUTHN-ENCRYPTED-KEYSTORE-INTEGRATION.md)
|
|
615
|
+
— sealing the keystore DID's key with the passkey (`encryptKeystore`).
|
|
616
|
+
- [`docs/E2E-TEST-SUMMARY.md`](docs/E2E-TEST-SUMMARY.md) — the test
|
|
617
|
+
configurations, what CI runs, and what a new suite needs to run there.
|
|
618
|
+
- [`docs/STANDALONE-API-PLAN.md`](docs/STANDALONE-API-PLAN.md) — historical:
|
|
619
|
+
the plan the `./standalone` export started from (#13). Its export list is
|
|
620
|
+
out of date; the reference is
|
|
621
|
+
[docs/API.md](docs/API.md#standalone-export).
|
|
622
|
+
- [`SECURITY.md`](SECURITY.md) — supported versions and how to report a
|
|
623
|
+
vulnerability.
|
|
624
|
+
- [`CODE_OF_CONDUCT.md`](CODE_OF_CONDUCT.md)
|
|
491
625
|
|
|
492
626
|
## Cross-Project Verification
|
|
493
627
|
|
package/docs/API.md
CHANGED
|
@@ -172,16 +172,46 @@ const identity = await identities.createIdentity({
|
|
|
172
172
|
});
|
|
173
173
|
```
|
|
174
174
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
- `webauthnCredential`
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
- `
|
|
181
|
-
|
|
175
|
+
Options, as `src/keystore/provider.js` reads them:
|
|
176
|
+
|
|
177
|
+
- `webauthnCredential` — the credential from `createCredential`, a stored
|
|
178
|
+
copy, or `restoreIdentityFromAuthenticator().credential`. Required unless
|
|
179
|
+
`signer` is given; without either the provider throws a `TypeError`.
|
|
180
|
+
- `signingKeyType` — `'secp256k1'` (default) or `'Ed25519'`: the type of the
|
|
181
|
+
signing key derived from the PRF output. Any other value throws. A key
|
|
182
|
+
already in the keystore for the DID is kept, whatever its type.
|
|
183
|
+
- `deriveSigningKeyFromPrf` — `true` by default: derive the signing key from
|
|
184
|
+
the passkey's PRF output, at the cost of one assertion the first time an
|
|
185
|
+
identity is created on a device. `false` leaves it to the keystore, which
|
|
186
|
+
generates a random secp256k1 key that stays on that device.
|
|
182
187
|
- `prfOutput` — a PRF output already read with `readPrfOutput`, so the signing
|
|
183
188
|
key costs no second touch; see
|
|
184
|
-
[One touch for the data and the identity](#one-touch-for-the-data-and-the-identity)
|
|
189
|
+
[One touch for the data and the identity](#one-touch-for-the-data-and-the-identity).
|
|
190
|
+
A `Uint8Array` of at least 32 bytes, or the provider throws a `TypeError`.
|
|
191
|
+
Unused with `signer`, `useKeystoreDID` or `deriveSigningKeyFromPrf: false`,
|
|
192
|
+
and once the keystore holds a key for the DID.
|
|
193
|
+
- `useKeystoreDID` — `false` by default. `true` makes the DID the `did:key` of
|
|
194
|
+
a key in the keystore, which also signs the entries (the keystore DID). It
|
|
195
|
+
needs `keystore`: without one the provider returns the passkey DID.
|
|
196
|
+
- `keystore` — `null` by default. The OrbitDB keystore, the same one given to
|
|
197
|
+
`Identities()`. `useKeystoreDID` needs it; the default path uses the
|
|
198
|
+
keystore OrbitDB passes to `getId()` and falls back to this one.
|
|
199
|
+
- `keystoreKeyType` — `'secp256k1'` (default) or `'Ed25519'`: the type of the
|
|
200
|
+
keystore DID's key. Only with `useKeystoreDID`.
|
|
201
|
+
- `encryptKeystore` — `false` by default. Seals the keystore DID's key with the
|
|
202
|
+
passkey, so it takes effect only with `useKeystoreDID` and `keystore`.
|
|
203
|
+
`provider.encryptionState` says whether it was sealed.
|
|
204
|
+
- `keystoreEncryptionMethod` — `'prf'` (default), `'largeBlob'` or
|
|
205
|
+
`'hmac-secret'`.
|
|
206
|
+
- `signer` — `null` by default. A key that signs elsewhere,
|
|
207
|
+
`{ did, type: 'Ed25519', publicKey, sign(data) }`, from `createWorkerSigner`
|
|
208
|
+
or `createSecretSigner`. The identity is its DID, and nothing asks a
|
|
209
|
+
passkey. Give `Identities()` the keystore from
|
|
210
|
+
`createSessionKeystore({ signer })`: `getId()` throws when the keystore
|
|
211
|
+
has no key under the signer's DID.
|
|
212
|
+
|
|
213
|
+
`keyType` and `usePersistentKey`, listed here before, are not options: the
|
|
214
|
+
provider never read either.
|
|
185
215
|
|
|
186
216
|
### WebAuthn Configuration
|
|
187
217
|
|
|
@@ -263,6 +293,51 @@ used in [the recovery example](https://github.com/NiKrause/orbitdb-storage-bridg
|
|
|
263
293
|
the database half of the same problem is in
|
|
264
294
|
[orbitdb-storage-bridge](https://github.com/NiKrause/orbitdb-storage-bridge/blob/main/docs/RECOVERY-ON-A-SECOND-DEVICE.md).
|
|
265
295
|
|
|
296
|
+
### Passkey Steps
|
|
297
|
+
|
|
298
|
+
Before each passkey prompt, a word on what it is for, when an application asks for one. Every WebAuthn call in this package first awaits `beforePasskeyCeremony(purpose)`. Inside a plan, every prompt after the first goes to the registered handler. The first prompt comes from the click that started the action, so it is not announced. The handler resolves to let the prompt start (from its click, which Safari wants for each WebAuthn call) or throws to stop it.
|
|
299
|
+
|
|
300
|
+
```js
|
|
301
|
+
import {
|
|
302
|
+
setPasskeyStepHandler,
|
|
303
|
+
withPasskeySteps,
|
|
304
|
+
PasskeyStepCancelled,
|
|
305
|
+
} from '@le-space/orbitdb-identity-provider-webauthn-did';
|
|
306
|
+
|
|
307
|
+
const stop = setPasskeyStepHandler(async ({ purpose, n, of, kind }) => {
|
|
308
|
+
// show "prompt n of of", what `purpose` is for; resolve on Continue,
|
|
309
|
+
// throw new PasskeyStepCancelled() on Cancel
|
|
310
|
+
});
|
|
311
|
+
await withPasskeySteps(3, () => createPasskeyAndIdentity());
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
#### `setPasskeyStepHandler(handler | null)`
|
|
315
|
+
|
|
316
|
+
Registers what runs before each announced prompt and returns a function that unregisters it, if it is still the one. A handler sees `{ purpose, n, of, kind }`: `of` is `null` when the plan gave no count, and `kind` is `'create'` or `'get'`.
|
|
317
|
+
|
|
318
|
+
#### `withPasskeySteps(of | { of, askFirst }, run)`
|
|
319
|
+
|
|
320
|
+
Runs `run` with its prompts numbered. `of` is how many the action takes, as the application counts them: a number that is too small makes the dialog say "4 of 3" and does nothing worse. `askFirst` announces the first prompt too, for an action that does not start from a click of its own. Plans do not nest: an inner plan numbers its own prompts and the outer one resumes afterwards.
|
|
321
|
+
|
|
322
|
+
#### `beforePasskeyCeremony(purpose, kind = 'get')`
|
|
323
|
+
|
|
324
|
+
What the package calls before each WebAuthn call. An application calls it around its own calls, so they are counted in the same plan. Call it outside any `try` that turns a failed ceremony into a fallback: a cancel has to reach the action, not be read as "this authenticator cannot".
|
|
325
|
+
|
|
326
|
+
#### `PASSKEY_PURPOSES`, `PasskeyStepCancelled`
|
|
327
|
+
|
|
328
|
+
The purposes are `create`, `signing-key` (the PRF output the signing key comes from), `identity` (the identity signature), `restore` and `restore-confirm` (the two touches of `restoreIdentityFromAuthenticator`), `keystore` (sealing or opening the keystore's key), `prf` (`readPrfOutput`, `extractPrfSeedFromCredential`), `metadata` (largeBlob metadata), `wallet` (the P-256 wallet's signatures) and `sign-entry` (varsig). `PasskeyStepCancelled` is what a cancel throws. It reaches the caller as it is, also through `sign()`, which wraps WebAuthn errors in its own.
|
|
329
|
+
|
|
330
|
+
#### `./elements`: `<passkey-step-dialog>`
|
|
331
|
+
|
|
332
|
+
```js
|
|
333
|
+
import { connectPasskeyStepDialog } from '@le-space/orbitdb-identity-provider-webauthn-did/elements';
|
|
334
|
+
const dialog = document.querySelector('passkey-step-dialog');
|
|
335
|
+
connectPasskeyStepDialog(dialog); // returns a function that disconnects it
|
|
336
|
+
dialog.strings = { de: { purposes: { prf: { title: '…', why: '…' } } } }; // optional
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
A framework-free handler: "Passkey prompt n of m", a title and a reason per purpose, a line that this is not a loop, **Continue** (focused) and **Cancel**. Escape counts as Cancel. The language is the element's `lang`, then the document's. English and German are built in (`PASSKEY_STEP_STRINGS`), and `strings` replaces any of them per language or adds a language. Its colours come from `--passkey-step-background`, `-color`, `-muted`, `-border`, `-accent`, `-on-accent`, `-radius` and `-backdrop`; the defaults follow `prefers-color-scheme`. `element.ask(step)` is the handler itself, for an application that wants to call it directly.
|
|
340
|
+
|
|
266
341
|
### PRF Keys and Vaults
|
|
267
342
|
|
|
268
343
|
Since 0.9.0. Applications that keep data under keys from the passkey used to
|
|
@@ -385,6 +460,14 @@ What a vault does not do:
|
|
|
385
460
|
what the old one protected.
|
|
386
461
|
- **It cannot tell the current record from an earlier copy of itself.** Where a
|
|
387
462
|
rollback matters, the place the record is stored has to say which is current.
|
|
463
|
+
What it can tell, since 0.14.0, is which of two records is the later
|
|
464
|
+
_renewal_: a vault that replaces another is version 2 and carries a
|
|
465
|
+
`generation`, sealed into every slot, so each authenticator that stays vouches
|
|
466
|
+
for it and a removed one — which knows the old vault key and nothing more —
|
|
467
|
+
cannot raise it. `generationOf(vault)` reads it (0 for a vault made fresh,
|
|
468
|
+
which stays version 1 and opens with earlier versions of this package; a
|
|
469
|
+
renewed vault does not). No record can say that a later one exists somewhere
|
|
470
|
+
it was not shown.
|
|
388
471
|
- **It does not make two keys one person.** Each authenticator keeps its own DID
|
|
389
472
|
and signing key; who may write to a database is its access controller's
|
|
390
473
|
decision.
|
|
@@ -429,11 +512,28 @@ await keeper.addPasskey(opened, {
|
|
|
429
512
|
a record kept elsewhere — a backup, an index — and keeps it here once it has
|
|
430
513
|
opened; without that it makes a new vault holding `create()`, with this
|
|
431
514
|
authenticator's slot. It returns `{ record, payload, vaultKey, kid, created,
|
|
432
|
-
found }`; keep that in memory while the vault is open, it holds the
|
|
515
|
+
found, generation }`; keep that in memory while the vault is open, it holds the
|
|
516
|
+
vault key.
|
|
433
517
|
- Pass `find` on every unlock where the vault may be kept elsewhere, not only
|
|
434
518
|
on a restore path. A synced passkey on a new device otherwise makes a vault
|
|
435
519
|
of its own, and from then on `open` finds that one here and never asks
|
|
436
520
|
`find` again (Le-Space/belege#524).
|
|
521
|
+
- **After a renewal**, `find` is how the other devices learn of it. It is asked
|
|
522
|
+
on every unlock — also when a vault is kept here — and may return one record
|
|
523
|
+
or several. Of everything this authenticator's slot opens, the latest
|
|
524
|
+
generation wins: a vault renewed elsewhere replaces the one kept here as soon
|
|
525
|
+
as `find` shows it, and a copy from before a renewal is never taken in place
|
|
526
|
+
of a later one. With a vault kept here, a `find` that fails does not stop the
|
|
527
|
+
unlock; the error comes back as `findError`.
|
|
528
|
+
- **What that cannot do:** a device with nothing kept, shown only the vault from
|
|
529
|
+
before a renewal, opens that vault — and seals what follows under a key the
|
|
530
|
+
removed authenticator knows. So put the renewed record wherever `find` reads
|
|
531
|
+
from straight away, and keep that place from being written by whoever holds
|
|
532
|
+
the removed key. An application that knows the generation the vault has
|
|
533
|
+
reached, from something it trusts (a pointer the owner's identity signed, for
|
|
534
|
+
one), passes `minGeneration`: anything earlier is refused with
|
|
535
|
+
`VAULT_SUPERSEDED`, before it is kept here and without a new vault being made
|
|
536
|
+
instead.
|
|
437
537
|
- An authenticator removed here is refused (`VAULT_SLOT_REMOVED`), never given
|
|
438
538
|
a new vault: for an application whose books existed before the vault, that
|
|
439
539
|
would be a stale copy that looks like the real books.
|
|
@@ -446,7 +546,9 @@ found }`; keep that in memory while the vault is open, it holds the vault key.
|
|
|
446
546
|
vault id, with a slot for every authenticator that stays. Every one of them
|
|
447
547
|
answers with its PRF output, checked against its slot, so none is left out
|
|
448
548
|
by mistake; the ones in `removed` are taken out. A new `payload` replaces
|
|
449
|
-
keys a removed authenticator must not know.
|
|
549
|
+
keys a removed authenticator must not know. The new vault is one generation
|
|
550
|
+
on from the old. It protects what is sealed from then on **on devices that
|
|
551
|
+
have it**: see `find` above for the ones that do not yet.
|
|
450
552
|
- `replacePayload(opened, payload)`, `status(rawCredentialId)` (is there a
|
|
451
553
|
vault here for this key, without asking it?) and `records()`.
|
|
452
554
|
|
|
@@ -466,8 +568,9 @@ it with `deriveSubkey(root, info)`, so the vault never changes when the
|
|
|
466
568
|
application needs one more key. Belege's vaults hold exactly that.
|
|
467
569
|
|
|
468
570
|
More refusals from the keeper, as `VaultError` codes: `VAULT_STORE_UNREADABLE`,
|
|
469
|
-
`VAULT_SLOT_REMOVED`,
|
|
470
|
-
the vault cannot remove itself, or be left out of a renewal
|
|
571
|
+
`VAULT_SLOT_REMOVED`, `VAULT_SLOT_IN_USE` — the authenticator that opened
|
|
572
|
+
the vault cannot remove itself, or be left out of a renewal — and
|
|
573
|
+
`VAULT_SUPERSEDED`, when nothing at hand reaches `minGeneration`.
|
|
471
574
|
|
|
472
575
|
#### An identity that is nobody's passkey: `createSecretSigner(secret, { info })`
|
|
473
576
|
|
|
@@ -730,6 +833,10 @@ with webauthn-sol). See the README section "Passkeys for smart accounts".
|
|
|
730
833
|
### Worker Keystore Client
|
|
731
834
|
|
|
732
835
|
- `createWorkerKeystoreClient(options?)`
|
|
836
|
+
- `createWorkerSigner(client, { did, publicKey })` — the result of
|
|
837
|
+
`client.deriveSigner(prfSeed)` as a signer for
|
|
838
|
+
`createSessionKeystore({ signer })` and the provider's `signer` option;
|
|
839
|
+
`sign` runs in the worker
|
|
733
840
|
- `isWorkerKeystoreAvailable()`
|
|
734
841
|
- `createEd25519DidFromPublicKey(publicKeyBytes)`
|
|
735
842
|
- `getDefaultWorkerKeystoreClient(options?)`
|
package/package.json
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@le-space/orbitdb-identity-provider-webauthn-did",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "WebAuthn-based DID identity provider for OrbitDB for hardware-secured wallets and biometric Passkey authentication",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
7
7
|
"type": "module",
|
|
8
|
+
"sideEffects": [
|
|
9
|
+
"./src/elements/index.js",
|
|
10
|
+
"./src/standalone/worker/ed25519-keystore.worker.js"
|
|
11
|
+
],
|
|
8
12
|
"exports": {
|
|
9
13
|
".": {
|
|
10
14
|
"types": "./types/index.d.ts",
|
|
@@ -25,6 +29,10 @@
|
|
|
25
29
|
"./vault": {
|
|
26
30
|
"types": "./types/vault.d.ts",
|
|
27
31
|
"import": "./src/vault/index.js"
|
|
32
|
+
},
|
|
33
|
+
"./elements": {
|
|
34
|
+
"types": "./types/elements.d.ts",
|
|
35
|
+
"import": "./src/elements/index.js"
|
|
28
36
|
}
|
|
29
37
|
},
|
|
30
38
|
"scripts": {
|
|
@@ -57,7 +65,7 @@
|
|
|
57
65
|
"postversion": "git push && git push --tags",
|
|
58
66
|
"test:two-peer": "playwright test tests/webauthn-two-peer-replication.test.js --project=chromium --reporter=line",
|
|
59
67
|
"test:node": "playwright test --config=playwright.node.config.js",
|
|
60
|
-
"test:wallet-fork": "PASSKEY_WALLET_FORK_URL
|
|
68
|
+
"test:wallet-fork": "node -e \"process.env.PASSKEY_WALLET_FORK_URL || (console.error('test:wallet-fork needs PASSKEY_WALLET_FORK_URL, a Sepolia RPC URL, e.g. https://eth-sepolia.g.alchemy.com/v2/<key>'), process.exit(1))\" && playwright test --config=playwright.fork.config.js"
|
|
61
69
|
},
|
|
62
70
|
"keywords": [
|
|
63
71
|
"orbitdb",
|
|
@@ -151,7 +159,8 @@
|
|
|
151
159
|
"iso-web": "^3.1.2",
|
|
152
160
|
"iso-webauthn-varsig": "npm:@le-space/iso-webauthn-varsig@^0.3.0",
|
|
153
161
|
"conf>ajv": "^8.18.0",
|
|
154
|
-
"ajv>fast-uri": "^3.1.9"
|
|
162
|
+
"ajv>fast-uri": "^3.1.9",
|
|
163
|
+
"@libp2p/crypto@<5.1.22": "5.1.22"
|
|
155
164
|
},
|
|
156
165
|
"onlyBuiltDependencies": [
|
|
157
166
|
"@ipshipyard/node-datachannel",
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom elements, for an application whatever its framework.
|
|
3
|
+
*
|
|
4
|
+
* `<passkey-step-dialog>` says, between two passkey prompts, what the next one
|
|
5
|
+
* is for. {@link connectPasskeyStepDialog} makes an element on the page the
|
|
6
|
+
* handler for every prompt this package announces.
|
|
7
|
+
*/
|
|
8
|
+
import { setPasskeyStepHandler } from '../passkey-steps.js';
|
|
9
|
+
import {
|
|
10
|
+
CONTINUE_DELAY_MS,
|
|
11
|
+
PasskeyStepDialogElement,
|
|
12
|
+
PASSKEY_STEP_STRINGS,
|
|
13
|
+
} from './passkey-step-dialog.js';
|
|
14
|
+
|
|
15
|
+
if (
|
|
16
|
+
globalThis.customElements &&
|
|
17
|
+
!globalThis.customElements.get('passkey-step-dialog')
|
|
18
|
+
) {
|
|
19
|
+
globalThis.customElements.define(
|
|
20
|
+
'passkey-step-dialog',
|
|
21
|
+
PasskeyStepDialogElement
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Let this element answer every announced passkey prompt.
|
|
27
|
+
*
|
|
28
|
+
* @param {PasskeyStepDialogElement} element
|
|
29
|
+
* @returns {() => void} disconnects it again (if it is still the handler)
|
|
30
|
+
*/
|
|
31
|
+
export function connectPasskeyStepDialog(element) {
|
|
32
|
+
return setPasskeyStepHandler((step) => element.ask(step));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export { CONTINUE_DELAY_MS, PasskeyStepDialogElement, PASSKEY_STEP_STRINGS };
|
|
36
|
+
export {
|
|
37
|
+
setPasskeyStepHandler,
|
|
38
|
+
withPasskeySteps,
|
|
39
|
+
PasskeyStepCancelled,
|
|
40
|
+
PASSKEY_PURPOSES,
|
|
41
|
+
} from '../passkey-steps.js';
|