@interop/was-react 0.8.3 → 0.9.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/README.md +50 -44
- package/dist/auth/chapi.d.ts.map +1 -1
- package/dist/auth/chapi.js +5 -4
- package/dist/auth/chapi.js.map +1 -1
- package/dist/auth/loginFlow.d.ts.map +1 -1
- package/dist/auth/loginFlow.js +39 -43
- package/dist/auth/loginFlow.js.map +1 -1
- package/dist/auth/verifyResponse.d.ts.map +1 -1
- package/dist/auth/verifyResponse.js +4 -4
- package/dist/auth/verifyResponse.js.map +1 -1
- package/dist/auth/walletRequestTypes.d.ts +9 -90
- package/dist/auth/walletRequestTypes.d.ts.map +1 -1
- package/dist/config.d.ts +9 -9
- package/dist/config.js +0 -0
- package/dist/dev/provisionDevGrants.d.ts.map +1 -1
- package/dist/dev/provisionDevGrants.js +18 -19
- package/dist/dev/provisionDevGrants.js.map +1 -1
- package/dist/grants.d.ts +19 -9
- package/dist/grants.d.ts.map +1 -1
- package/dist/grants.js +17 -2
- package/dist/grants.js.map +1 -1
- package/dist/identity/agents.d.ts +1 -1
- package/dist/identity/agents.d.ts.map +1 -1
- package/dist/identity/agents.js +10 -25
- package/dist/identity/agents.js.map +1 -1
- package/dist/identity/appSession.d.ts +27 -0
- package/dist/identity/appSession.d.ts.map +1 -1
- package/dist/identity/appSession.js +51 -13
- package/dist/identity/appSession.js.map +1 -1
- package/dist/identity/seedCredential.d.ts +7 -0
- package/dist/identity/seedCredential.d.ts.map +1 -1
- package/dist/identity/seedCredential.js +11 -14
- package/dist/identity/seedCredential.js.map +1 -1
- package/dist/identity/seedStore.d.ts +19 -0
- package/dist/identity/seedStore.d.ts.map +1 -1
- package/dist/identity/seedStore.js +40 -13
- package/dist/identity/seedStore.js.map +1 -1
- package/dist/index.d.ts +4 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -4
- package/dist/index.js.map +1 -1
- package/dist/jsonLd.d.ts +19 -0
- package/dist/jsonLd.d.ts.map +1 -0
- package/dist/jsonLd.js +24 -0
- package/dist/jsonLd.js.map +1 -0
- package/dist/mui/AdoptDialog.d.ts.map +1 -1
- package/dist/mui/AdoptDialog.js +7 -3
- package/dist/mui/AdoptDialog.js.map +1 -1
- package/dist/mui/ClearDataDialog.d.ts.map +1 -1
- package/dist/mui/ClearDataDialog.js +12 -11
- package/dist/mui/ClearDataDialog.js.map +1 -1
- package/dist/mui/ConfirmDialog.d.ts +35 -0
- package/dist/mui/ConfirmDialog.d.ts.map +1 -0
- package/dist/mui/ConfirmDialog.js +18 -0
- package/dist/mui/ConfirmDialog.js.map +1 -0
- package/dist/mui/LogoutDialog.d.ts.map +1 -1
- package/dist/mui/LogoutDialog.js +7 -3
- package/dist/mui/LogoutDialog.js.map +1 -1
- package/dist/react/documentApp.d.ts +29 -0
- package/dist/react/documentApp.d.ts.map +1 -1
- package/dist/react/documentApp.js +9 -38
- package/dist/react/documentApp.js.map +1 -1
- package/dist/react/hooks.d.ts +13 -7
- package/dist/react/hooks.d.ts.map +1 -1
- package/dist/react/hooks.js +17 -11
- package/dist/react/hooks.js.map +1 -1
- package/dist/session/authStore.d.ts +9 -9
- package/dist/session/authStore.d.ts.map +1 -1
- package/dist/session/authStore.js +100 -96
- package/dist/session/authStore.js.map +1 -1
- package/dist/storage/adopt.d.ts +5 -1
- package/dist/storage/adopt.d.ts.map +1 -1
- package/dist/storage/adopt.js +8 -24
- package/dist/storage/adopt.js.map +1 -1
- package/dist/storage/entityStore.d.ts.map +1 -1
- package/dist/storage/entityStore.js +27 -20
- package/dist/storage/entityStore.js.map +1 -1
- package/dist/storage/localStore.d.ts +12 -6
- package/dist/storage/localStore.d.ts.map +1 -1
- package/dist/storage/localStore.js +118 -74
- package/dist/storage/localStore.js.map +1 -1
- package/dist/storage/sharedCollectionReader.d.ts +1 -1
- package/dist/storage/sharedCollectionReader.d.ts.map +1 -1
- package/dist/storage/sharedCollectionReader.js +79 -81
- package/dist/storage/sharedCollectionReader.js.map +1 -1
- package/dist/storage/storageManager.d.ts +3 -1
- package/dist/storage/storageManager.d.ts.map +1 -1
- package/dist/storage/storageManager.js +20 -6
- package/dist/storage/storageManager.js.map +1 -1
- package/dist/storage/syncController.d.ts +1 -16
- package/dist/storage/syncController.d.ts.map +1 -1
- package/dist/storage/syncController.js +38 -58
- package/dist/storage/syncController.js.map +1 -1
- package/dist/storage/syncStatusStore.d.ts +8 -6
- package/dist/storage/syncStatusStore.d.ts.map +1 -1
- package/dist/storage/syncStatusStore.js +6 -6
- package/dist/storage/syncStatusStore.js.map +1 -1
- package/dist/storage/wasRemoteStore.d.ts +34 -2
- package/dist/storage/wasRemoteStore.d.ts.map +1 -1
- package/dist/storage/wasRemoteStore.js +45 -7
- package/dist/storage/wasRemoteStore.js.map +1 -1
- package/dist/storage/wasSync.d.ts.map +1 -1
- package/dist/storage/wasSync.js +47 -38
- package/dist/storage/wasSync.js.map +1 -1
- package/dist/sync/changesQuery.d.ts.map +1 -1
- package/dist/sync/changesQuery.js +2 -12
- package/dist/sync/changesQuery.js.map +1 -1
- package/dist/sync/docCipher.d.ts +17 -9
- package/dist/sync/docCipher.d.ts.map +1 -1
- package/dist/sync/docCipher.js +17 -11
- package/dist/sync/docCipher.js.map +1 -1
- package/dist/sync/feedMasterPort.d.ts +6 -0
- package/dist/sync/feedMasterPort.d.ts.map +1 -1
- package/dist/sync/feedMasterPort.js +82 -40
- package/dist/sync/feedMasterPort.js.map +1 -1
- package/dist/sync/index.d.ts +6 -5
- package/dist/sync/index.d.ts.map +1 -1
- package/dist/sync/index.js +6 -3
- package/dist/sync/index.js.map +1 -1
- package/dist/sync/lww.d.ts +15 -14
- package/dist/sync/lww.d.ts.map +1 -1
- package/dist/sync/lww.js +3 -3
- package/dist/sync/lww.js.map +1 -1
- package/dist/sync/lwwConflictHandler.d.ts +3 -10
- package/dist/sync/lwwConflictHandler.d.ts.map +1 -1
- package/dist/sync/lwwConflictHandler.js +7 -17
- package/dist/sync/lwwConflictHandler.js.map +1 -1
- package/dist/sync/pushWrites.d.ts +6 -8
- package/dist/sync/pushWrites.d.ts.map +1 -1
- package/dist/sync/pushWrites.js +56 -83
- package/dist/sync/pushWrites.js.map +1 -1
- package/dist/sync/types.d.ts +80 -4
- package/dist/sync/types.d.ts.map +1 -1
- package/dist/sync/types.js +36 -18
- package/dist/sync/types.js.map +1 -1
- package/dist/sync/wasSyncPort.d.ts +0 -11
- package/dist/sync/wasSyncPort.d.ts.map +1 -1
- package/dist/sync/wasSyncPort.js +8 -33
- package/dist/sync/wasSyncPort.js.map +1 -1
- package/package.json +5 -5
- package/dist/identity/initAppSession.d.ts +0 -27
- package/dist/identity/initAppSession.d.ts.map +0 -1
- package/dist/identity/initAppSession.js +0 -30
- package/dist/identity/initAppSession.js.map +0 -1
package/README.md
CHANGED
|
@@ -101,9 +101,9 @@ WAS collection `id` (a deliberately unprefixed, generic name shared across
|
|
|
101
101
|
interoperable apps). `credential` names the self-issued seed credential the
|
|
102
102
|
first-run flow mints; its `vocabBase` namespaces the app's own type term only,
|
|
103
103
|
since every app key also carries the shared `AppKeyCredential` marker type and
|
|
104
|
-
its `seed` / `origin` claims under `
|
|
105
|
-
(`mediatorBase`, `dbName`, `storageKeyPrefix`, `sync`, `expiry`) are
|
|
106
|
-
with documented defaults.
|
|
104
|
+
its `seed` / `origin` claims under `https://w3id.org/byoe#` IRIs. All other
|
|
105
|
+
fields (`mediatorBase`, `dbName`, `storageKeyPrefix`, `sync`, `expiry`) are
|
|
106
|
+
optional with documented defaults.
|
|
107
107
|
|
|
108
108
|
A collection may also declare `visibility: 'public'`
|
|
109
109
|
(`{ key: 'posts', id: 'microblog-posts', visibility: 'public' }`); the default
|
|
@@ -124,11 +124,11 @@ carry the `updatedAt` / `clientId` LWW fields like any other collection --
|
|
|
124
124
|
without them a concurrent multi-device edit falls back to server-wins.
|
|
125
125
|
|
|
126
126
|
At login, a public collection is requested from the wallet with the distinct
|
|
127
|
-
`
|
|
128
|
-
`
|
|
129
|
-
policy, shows a world-readable consent warning, and delegates the
|
|
130
|
-
read/write capability (public covers only unauthenticated reads; writes
|
|
131
|
-
capability-only). A wallet that predates the descriptor reports the request
|
|
127
|
+
`https://w3id.org/byoe#public-collection` descriptor type (private collections
|
|
128
|
+
use `https://w3id.org/byoe#collection`): the wallet provisions it plaintext with
|
|
129
|
+
a public-read policy, shows a world-readable consent warning, and delegates the
|
|
130
|
+
usual read/write capability (public covers only unauthenticated reads; writes
|
|
131
|
+
stay capability-only). A wallet that predates the descriptor reports the request
|
|
132
132
|
unsatisfiable rather than silently provisioning a private collection, so the
|
|
133
133
|
feature fails closed with older wallets. Publicness is granted at consent time
|
|
134
134
|
by the wallet -- the app itself can never escalate an existing private
|
|
@@ -173,14 +173,14 @@ the same `key` or `id` in each is rejected at store open
|
|
|
173
173
|
(`validateSharedCollections`).
|
|
174
174
|
|
|
175
175
|
At login each shared collection is requested with the distinct
|
|
176
|
-
`
|
|
177
|
-
`SHARED_ACTIONS` (`GET`/`HEAD`) -- an app never asks to write a
|
|
178
|
-
collection. As with `
|
|
179
|
-
reports the request unsatisfiable and the feature fails
|
|
180
|
-
point: a share fuses two axes -- the read zcap AND an entry
|
|
181
|
-
key-epoch roster -- and a wallet that granted only the zcap
|
|
182
|
-
ciphertext it cannot decrypt, surfacing as corrupt data
|
|
183
|
-
that needs updating.
|
|
176
|
+
`https://w3id.org/byoe#shared-collection` descriptor type and the read-only
|
|
177
|
+
action set `SHARED_ACTIONS` (`GET`/`HEAD`) -- an app never asks to write a
|
|
178
|
+
wallet collection. As with `https://w3id.org/byoe#public-collection`, a wallet
|
|
179
|
+
that predates the type reports the request unsatisfiable and the feature fails
|
|
180
|
+
closed, which is the point: a share fuses two axes -- the read zcap AND an entry
|
|
181
|
+
in the collection's key-epoch roster -- and a wallet that granted only the zcap
|
|
182
|
+
would hand the app ciphertext it cannot decrypt, surfacing as corrupt data
|
|
183
|
+
rather than as a wallet that needs updating.
|
|
184
184
|
|
|
185
185
|
Decryption uses the app's **identity** key-agreement key: the X25519 twin of its
|
|
186
186
|
`did:key` controller (`IdentityAgents.keyAgreementKey`), which is exactly what
|
|
@@ -254,8 +254,7 @@ export function Root() {
|
|
|
254
254
|
import { useLogin } from '@interop/was-react'
|
|
255
255
|
|
|
256
256
|
export function LoginPage() {
|
|
257
|
-
const { login,
|
|
258
|
-
const busy = status === 'authenticating'
|
|
257
|
+
const { login, authenticating: busy, phase, error } = useLogin()
|
|
259
258
|
|
|
260
259
|
return (
|
|
261
260
|
<div>
|
|
@@ -273,12 +272,13 @@ export function LoginPage() {
|
|
|
273
272
|
|
|
274
273
|
```tsx
|
|
275
274
|
import { uuidv7 } from 'uuidv7'
|
|
276
|
-
import {
|
|
275
|
+
import { useSession } from '@interop/was-react'
|
|
277
276
|
import { useNotes } from './stores.js'
|
|
278
277
|
|
|
279
278
|
export function Notes() {
|
|
280
279
|
const notes = useNotes(state => [...state.byId.values()])
|
|
281
280
|
const insert = useNotes(state => state.insert)
|
|
281
|
+
const { clientId } = useSession()
|
|
282
282
|
|
|
283
283
|
async function addNote() {
|
|
284
284
|
const now = new Date().toISOString()
|
|
@@ -288,7 +288,7 @@ export function Notes() {
|
|
|
288
288
|
body: '',
|
|
289
289
|
createdAt: now,
|
|
290
290
|
updatedAt: now,
|
|
291
|
-
clientId
|
|
291
|
+
clientId
|
|
292
292
|
})
|
|
293
293
|
}
|
|
294
294
|
|
|
@@ -305,10 +305,12 @@ export function Notes() {
|
|
|
305
305
|
}
|
|
306
306
|
```
|
|
307
307
|
|
|
308
|
-
Entity payloads MUST carry `updatedAt` and `clientId
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
308
|
+
Entity payloads MUST carry `updatedAt` and `clientId`, stamped on EVERY insert
|
|
309
|
+
and update: they are the last-write-wins pair that settles concurrent
|
|
310
|
+
multi-device edits of the same entity. A payload without them loses every sync
|
|
311
|
+
conflict. Read the id from `useSession().clientId` (resolved once per session,
|
|
312
|
+
honoring `storageKeyPrefix`); outside React, call
|
|
313
|
+
`getClientId({ storageKeyPrefix })` with the same prefix your config declares.
|
|
312
314
|
|
|
313
315
|
A public collection can additionally answer server-side equality queries.
|
|
314
316
|
Declare the queryable content attributes in the collection config:
|
|
@@ -393,9 +395,9 @@ a progress line (`connecting` to `verifying`):
|
|
|
393
395
|
2. **One popup.** A VPR carrying a `DIDAuthentication` query plus one
|
|
394
396
|
`AppConnectQuery` -- the app's display name, `credentialType`, and
|
|
395
397
|
`vocabBase`, a `capabilityQuery` entry per configured collection, and a
|
|
396
|
-
`
|
|
397
|
-
`navigator.credentials.get` (`buildAppConnectVpr`). A `null`
|
|
398
|
-
user cancel (`LoginCancelledError`), not an error.
|
|
398
|
+
`https://w3id.org/byoe#shared-collection` entry per shared collection -- is
|
|
399
|
+
sent via `navigator.credentials.get` (`buildAppConnectVpr`). A `null`
|
|
400
|
+
response is a user cancel (`LoginCancelledError`), not an error.
|
|
399
401
|
3. **The wallet matches or mints.** On a first run the wallet generates the
|
|
400
402
|
32-byte seed itself, self-issues the origin-bound app-key credential, and
|
|
401
403
|
stores it in its own credential store under the same consent; on a returning
|
|
@@ -412,8 +414,7 @@ a progress line (`connecting` to `verifying`):
|
|
|
412
414
|
and seed-to-DID bound, then recovers the seed.
|
|
413
415
|
6. **Derive identity.** The stable `did:key` controller and its signer are
|
|
414
416
|
derived deterministically from the seed via `CapabilityAgent.fromSeed`
|
|
415
|
-
(`
|
|
416
|
-
on every device.
|
|
417
|
+
(`deriveIdentity`). The same seed yields the same identity on every device.
|
|
417
418
|
7. **Check grants.** The delegated zcaps ride in the same presentation's
|
|
418
419
|
top-level `zcap` array. `checkGrants` asserts every zcap is controlled by the
|
|
419
420
|
app DID, shares one space on a single WAS host, covers each configured
|
|
@@ -429,10 +430,11 @@ a progress line (`connecting` to `verifying`):
|
|
|
429
430
|
## Session lifecycle
|
|
430
431
|
|
|
431
432
|
The session is owned by a zustand auth store built once per app by the provider
|
|
432
|
-
(`createAuthStore`). Its `status` is `
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
433
|
+
(`createAuthStore`). Its `status` is `boot` to `local` / `connected` /
|
|
434
|
+
`reconnect`, and it is the router gate: a protected route waits for the restore
|
|
435
|
+
attempt to settle before choosing between the app and the login page. A login in
|
|
436
|
+
flight is NOT a status -- it is the `phase` field, which `useSession()` /
|
|
437
|
+
`useLogin()` also surface as the derived boolean `authenticating`.
|
|
436
438
|
|
|
437
439
|
- **Restore (zero popups).** On mount, `restore()` reads the persisted session
|
|
438
440
|
from IndexedDB and, if present and consistent, re-derives the identity, opens
|
|
@@ -441,7 +443,8 @@ and the login page.
|
|
|
441
443
|
- **Login.** `useLogin().login()` runs the full [login flow](#login-flow).
|
|
442
444
|
- **Reconnect.** Grants are expiry-only. The store watches the earliest grant
|
|
443
445
|
expiry and, once within the warning window (`expiry.warningMs`, default 1h) or
|
|
444
|
-
after a live 401/403,
|
|
446
|
+
after a live 401/403, moves the status to `reconnect` (which `useReconnect()`
|
|
447
|
+
surfaces as the derived `accessExpired`). `useReconnect().reconnect()`
|
|
445
448
|
re-requests grants with the existing seed (one wallet popup, same identity,
|
|
446
449
|
same data) and restarts sync.
|
|
447
450
|
- **Logout.** `useLogout()` stops sync, closes and forgets the local store,
|
|
@@ -452,15 +455,15 @@ and the login page.
|
|
|
452
455
|
|
|
453
456
|
Hooks:
|
|
454
457
|
|
|
455
|
-
| Hook | Returns
|
|
456
|
-
| ----------------- |
|
|
457
|
-
| `useSession()` | `status`, `phase`, `error`, `controllerDid`, `expires`, `accessExpired`, `reconnecting` |
|
|
458
|
-
| `useLogin()` | `{ login, status, phase, error }`
|
|
459
|
-
| `useLogout()` | `() => Promise<void>`
|
|
460
|
-
| `useReconnect()` | `{ accessExpired, reconnecting, reconnect }`
|
|
461
|
-
| `useSyncStatus()` | `{ state, label, title }` (see below)
|
|
462
|
-
| `useAppReady()` | `{ ready, error }` -- the hydration gate
|
|
463
|
-
| `useAuthStore()` | the bound vanilla store (for `getState().restore()`, etc.)
|
|
458
|
+
| Hook | Returns |
|
|
459
|
+
| ----------------- | --------------------------------------------------------------------------------------------------------- |
|
|
460
|
+
| `useSession()` | `status`, `phase`, `authenticating`, `error`, `controllerDid`, `expires`, `accessExpired`, `reconnecting` |
|
|
461
|
+
| `useLogin()` | `{ login, authenticating, status, phase, error }` |
|
|
462
|
+
| `useLogout()` | `() => Promise<void>` |
|
|
463
|
+
| `useReconnect()` | `{ accessExpired, reconnecting, reconnect }` |
|
|
464
|
+
| `useSyncStatus()` | `{ state, label, title }` (see below) |
|
|
465
|
+
| `useAppReady()` | `{ ready, error }` -- the hydration gate |
|
|
466
|
+
| `useAuthStore()` | the bound vanilla store (for `getState().restore()`, etc.) |
|
|
464
467
|
|
|
465
468
|
## Sync architecture
|
|
466
469
|
|
|
@@ -491,7 +494,10 @@ Hooks:
|
|
|
491
494
|
with `sequence`+1 (a mutable-head model); deletes are soft-delete tombstones.
|
|
492
495
|
- **Status.** `useSyncStatus()` rolls the per-collection replication states up
|
|
493
496
|
to an aggregate: `offline` (no replication running / local-only), or
|
|
494
|
-
`error > syncing > synced`. The `SyncStatusChip` MUI component renders it.
|
|
497
|
+
`error > syncing > synced`. The `SyncStatusChip` MUI component renders it. The
|
|
498
|
+
underlying `useSyncStatusStore().statuses` map is keyed by the registry's
|
|
499
|
+
logical collection `key`, like every other layer (two entries may share one
|
|
500
|
+
WAS collection `id`, so the id is not a unique status key).
|
|
495
501
|
|
|
496
502
|
## Entry points
|
|
497
503
|
|
package/dist/auth/chapi.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chapi.d.ts","sourceRoot":"","sources":["../../src/auth/chapi.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAA;AAC3E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAE1D;;GAEG;AACH,eAAO,MAAM,qBAAqB,sCAAsC,CAAA;
|
|
1
|
+
{"version":3,"file":"chapi.d.ts","sourceRoot":"","sources":["../../src/auth/chapi.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAA;AAC3E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAE1D;;GAEG;AACH,eAAO,MAAM,qBAAqB,sCAAsC,CAAA;AAgExE;;;;;;;GAOG;AACH,wBAAsB,SAAS,CAAC,EAC9B,YAAoC,EACrC,GAAE;IACD,YAAY,CAAC,EAAE,MAAM,CAAA;CACjB,GAAG,OAAO,CAAC,IAAI,CAAC,CAMrB;AAED;;;;;;;;GAQG;AACH,wBAAsB,QAAQ,CAAC,EAC7B,GAAG,EACH,YAAY,EACb,EAAE;IACD,GAAG,EAAE,WAAW,CAAA;IAChB,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,GAAG,OAAO,CAAC,uBAAuB,GAAG,IAAI,CAAC,CAgB1C"}
|
package/dist/auth/chapi.js
CHANGED
|
@@ -38,14 +38,15 @@ function e2eBridgeActive() {
|
|
|
38
38
|
}
|
|
39
39
|
let e2eRequestId = 0;
|
|
40
40
|
/**
|
|
41
|
-
* Queues a request for the e2e harness and polls for its response
|
|
41
|
+
* Queues a `get` request for the e2e harness and polls for its response (the
|
|
42
|
+
* one-popup flow rides `get` alone, so that is the only queued request type).
|
|
42
43
|
*/
|
|
43
|
-
async function e2eRoundTrip(
|
|
44
|
+
async function e2eRoundTrip(body) {
|
|
44
45
|
const win = window;
|
|
45
46
|
win.__WAS_REACT_E2E_CHAPI_REQUESTS__ ??= [];
|
|
46
47
|
win.__WAS_REACT_E2E_CHAPI_RESPONSES__ ??= {};
|
|
47
48
|
const id = ++e2eRequestId;
|
|
48
|
-
win.__WAS_REACT_E2E_CHAPI_REQUESTS__.push({ id, type, body });
|
|
49
|
+
win.__WAS_REACT_E2E_CHAPI_REQUESTS__.push({ id, type: 'get', body });
|
|
49
50
|
const deadline = Date.now() + 120_000;
|
|
50
51
|
while (Date.now() < deadline) {
|
|
51
52
|
if (id in win.__WAS_REACT_E2E_CHAPI_RESPONSES__) {
|
|
@@ -85,7 +86,7 @@ export async function loadChapi({ mediatorBase = DEFAULT_MEDIATOR_BASE } = {}) {
|
|
|
85
86
|
export async function chapiGet({ vpr, mediatorBase }) {
|
|
86
87
|
let wire;
|
|
87
88
|
if (e2eBridgeActive()) {
|
|
88
|
-
wire = await e2eRoundTrip(
|
|
89
|
+
wire = await e2eRoundTrip(vpr);
|
|
89
90
|
}
|
|
90
91
|
else {
|
|
91
92
|
await loadChapi(mediatorBase !== undefined ? { mediatorBase } : {});
|
package/dist/auth/chapi.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chapi.js","sourceRoot":"","sources":["../../src/auth/chapi.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qCAAqC;AACrC;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AAItD;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,mCAAmC,CAAA;AAoBxE;;;;;;GAMG;AACH,SAAS,SAAS;IAChB,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,YAAY,CAAA;AAC9C,CAAC;AAED,SAAS,eAAe;IACtB,OAAO,CACL,SAAS,EAAE,KAAK,YAAY;QAC3B,MAA0B,CAAC,uBAAuB,KAAK,IAAI,CAC7D,CAAA;AACH,CAAC;AAED,IAAI,YAAY,GAAG,CAAC,CAAA;AAEpB
|
|
1
|
+
{"version":3,"file":"chapi.js","sourceRoot":"","sources":["../../src/auth/chapi.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qCAAqC;AACrC;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AAItD;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,mCAAmC,C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zB;AAED;;;;;GAKG;AACH,qBAAa,sBAAuB,SAAQ,KAAK;;CAQhD;AA4HD;;;;;;;;;;;GAWG;AACH,wBAAsB,aAAa,CAAC,EAClC,QAAQ,EACR,MAAM,EACN,OAAO,EACR,EAAE;IACD,QAAQ,EAAE,cAAc,CAAA;IACxB,MAAM,EAAE,WAAW,CAAA;IACnB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAA;CACtC,GAAG,OAAO,CAAC,aAAa,CAAC,CAczB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,eAAe,CAAC,EACpC,MAAM,EACN,OAAO,EACR,EAAE;IACD,MAAM,EAAE,WAAW,CAAA;IACnB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAA;CACtC,GAAG,OAAO,CAAC,YAAY,CAAC,CAkDxB"}
|
package/dist/auth/loginFlow.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { findSeedCredential, parseSeedCredential } from '../identity/seedCredential.js';
|
|
2
|
-
import {
|
|
2
|
+
import { NO_EXPIRY_MS } from '../identity/appSession.js';
|
|
3
3
|
import { chapiGet } from './chapi.js';
|
|
4
4
|
import { buildAppConnectVpr, newChallenge } from './loginRequest.js';
|
|
5
5
|
import { checkGrants, grantsOf, verifyLoginPresentation } from './verifyResponse.js';
|
|
@@ -25,11 +25,6 @@ export class WalletUnsupportedError extends Error {
|
|
|
25
25
|
this.name = 'WalletUnsupportedError';
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
/**
|
|
29
|
-
* A nominal far-future expiry (ms) used when an app requests no collections (so
|
|
30
|
-
* there are no grants and thus no earliest-expiry to report).
|
|
31
|
-
*/
|
|
32
|
-
const NO_GRANTS_EXPIRY_MS = 100 * 365 * 24 * 60 * 60 * 1000;
|
|
33
28
|
/**
|
|
34
29
|
* Reads the wallet-provided `presentation.appConnect.firstRun` boolean. Anything
|
|
35
30
|
* other than boolean `true` (including an absent member -- a returning login) is
|
|
@@ -76,7 +71,7 @@ function checkGrantsForCollections({ presentation, controllerDid, collections, s
|
|
|
76
71
|
return {
|
|
77
72
|
grants: [],
|
|
78
73
|
parsed: { serverUrl: '', spaceId: '', byCollectionId: {} },
|
|
79
|
-
expires: new Date(Date.now() +
|
|
74
|
+
expires: new Date(Date.now() + NO_EXPIRY_MS).toISOString()
|
|
80
75
|
};
|
|
81
76
|
}
|
|
82
77
|
return checkGrants({
|
|
@@ -86,18 +81,19 @@ function checkGrantsForCollections({ presentation, controllerDid, collections, s
|
|
|
86
81
|
});
|
|
87
82
|
}
|
|
88
83
|
/**
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
84
|
+
* Runs one App Connect round trip: builds the VPR, opens the single CHAPI `get`
|
|
85
|
+
* popup, and verifies the response presentation (cryptographically, plus the
|
|
86
|
+
* challenge/domain binds). Shared by the full login and the reconnect re-grant
|
|
87
|
+
* -- the same request either way; they differ only in what they take from the
|
|
88
|
+
* verified presentation, and in the step a user cancel names.
|
|
93
89
|
*
|
|
94
90
|
* @param options {object}
|
|
95
|
-
* @param options.identity {IdentityAgents}
|
|
96
91
|
* @param options.config {LoginConfig}
|
|
92
|
+
* @param options.cancelStep {string} the step a cancel is reported against
|
|
97
93
|
* @param [options.onPhase] {Function}
|
|
98
|
-
* @returns {Promise<
|
|
94
|
+
* @returns {Promise<IVerifiablePresentation>}
|
|
99
95
|
*/
|
|
100
|
-
|
|
96
|
+
async function runAppConnect({ config, cancelStep, onPhase }) {
|
|
101
97
|
onPhase?.('connecting');
|
|
102
98
|
const challenge = newChallenge();
|
|
103
99
|
const vpr = buildAppConnectVpr({
|
|
@@ -117,7 +113,7 @@ export async function requestGrants({ identity, config, onPhase }) {
|
|
|
117
113
|
})
|
|
118
114
|
});
|
|
119
115
|
if (!presentation) {
|
|
120
|
-
throw new LoginCancelledError(
|
|
116
|
+
throw new LoginCancelledError(cancelStep);
|
|
121
117
|
}
|
|
122
118
|
onPhase?.('verifying');
|
|
123
119
|
await verifyLoginPresentation({
|
|
@@ -126,6 +122,26 @@ export async function requestGrants({ identity, config, onPhase }) {
|
|
|
126
122
|
domain: window.location.origin,
|
|
127
123
|
documentLoader: config.documentLoader
|
|
128
124
|
});
|
|
125
|
+
return presentation;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Re-requests storage grants for `identity` over a fresh App Connect popup and
|
|
129
|
+
* validates them. The expired-access reconnect path: the seed already exists, so
|
|
130
|
+
* only the grants need renewing. The wallet matches the same app key and
|
|
131
|
+
* re-delegates; the returned credential/`appConnect` marker are ignored here.
|
|
132
|
+
*
|
|
133
|
+
* @param options {object}
|
|
134
|
+
* @param options.identity {IdentityAgents}
|
|
135
|
+
* @param options.config {LoginConfig}
|
|
136
|
+
* @param [options.onPhase] {Function}
|
|
137
|
+
* @returns {Promise<CheckedGrants>}
|
|
138
|
+
*/
|
|
139
|
+
export async function requestGrants({ identity, config, onPhase }) {
|
|
140
|
+
const presentation = await runAppConnect({
|
|
141
|
+
config,
|
|
142
|
+
cancelStep: 'storage grants',
|
|
143
|
+
...(onPhase && { onPhase })
|
|
144
|
+
});
|
|
129
145
|
return checkGrantsForCollections({
|
|
130
146
|
presentation,
|
|
131
147
|
controllerDid: identity.controllerDid,
|
|
@@ -150,33 +166,10 @@ export async function requestGrants({ identity, config, onPhase }) {
|
|
|
150
166
|
* @returns {Promise<LoginOutcome>}
|
|
151
167
|
*/
|
|
152
168
|
export async function loginWithWallet({ config, onPhase }) {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
domain: window.location.origin,
|
|
158
|
-
appName: config.appName,
|
|
159
|
-
credential: config.credential,
|
|
160
|
-
collections: config.collections,
|
|
161
|
-
...(config.sharedCollections && {
|
|
162
|
-
sharedCollections: config.sharedCollections
|
|
163
|
-
})
|
|
164
|
-
});
|
|
165
|
-
const presentation = await chapiGet({
|
|
166
|
-
vpr,
|
|
167
|
-
...(config.mediatorBase !== undefined && {
|
|
168
|
-
mediatorBase: config.mediatorBase
|
|
169
|
-
})
|
|
170
|
-
});
|
|
171
|
-
if (!presentation) {
|
|
172
|
-
throw new LoginCancelledError('wallet login');
|
|
173
|
-
}
|
|
174
|
-
onPhase?.('verifying');
|
|
175
|
-
await verifyLoginPresentation({
|
|
176
|
-
presentation,
|
|
177
|
-
challenge,
|
|
178
|
-
domain: window.location.origin,
|
|
179
|
-
documentLoader: config.documentLoader
|
|
169
|
+
const presentation = await runAppConnect({
|
|
170
|
+
config,
|
|
171
|
+
cancelStep: 'wallet login',
|
|
172
|
+
...(onPhase && { onPhase })
|
|
180
173
|
});
|
|
181
174
|
// The wallet mints the app key on first run, so a response with no app-key
|
|
182
175
|
// credential is not first run -- it is a wallet that could not satisfy
|
|
@@ -198,7 +191,10 @@ export async function loginWithWallet({ config, onPhase }) {
|
|
|
198
191
|
});
|
|
199
192
|
const seed = parsedCredential.seed;
|
|
200
193
|
const firstRun = appConnectFirstRun(presentation);
|
|
201
|
-
|
|
194
|
+
// The master identity comes off the parse, which already derived it from this
|
|
195
|
+
// seed to check the seed-to-DID binding (the same `deriveIdentity` call, and
|
|
196
|
+
// the same 32-byte seed rule, every other session path applies).
|
|
197
|
+
const identity = parsedCredential.identity;
|
|
202
198
|
// Grants ride in the SAME response; validate them against the app-key subject
|
|
203
199
|
// DID the wallet delegated to.
|
|
204
200
|
const checked = checkGrantsForCollections({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loginFlow.js","sourceRoot":"","sources":["../../src/auth/loginFlow.ts"],"names":[],"mappings":"AA6BA,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EAEpB,MAAM,+BAA+B,CAAA;AACtC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"loginFlow.js","sourceRoot":"","sources":["../../src/auth/loginFlow.ts"],"names":[],"mappings":"AA6BA,OAAO,EACL,kBAAkB,EAClB,mBAAmB,E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E,CAAA;IACpC,CAAC;IACD,4EAA4E;IAC5E,2EAA2E;IAC3E,MAAM,gBAAgB,GAAG,MAAM,mBAAmB,CAAC;QACjD,UAAU;QACV,MAAM,EAAE,MAAM,CAAC,SAAS;QACxB,MAAM,EAAE,MAAM,CAAC,UAAU;KAC1B,CAAC,CAAA;IACF,MAAM,IAAI,GAAG,gBAAgB,CAAC,IAAI,CAAA;IAClC,MAAM,QAAQ,GAAG,kBAAkB,CAAC,YAAY,CAAC,CAAA;IAEjD,8EAA8E;IAC9E,6EAA6E;IAC7E,iEAAiE;IACjE,MAAM,QAAQ,GAAG,gBAAgB,CAAC,QAAQ,CAAA;IAC1C,8EAA8E;IAC9E,+BAA+B;IAC/B,MAAM,OAAO,GAAG,yBAAyB,CAAC;QACxC,YAAY;QACZ,aAAa,EAAE,gBAAgB,CAAC,aAAa;QAC7C,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,GAAG,CAAC,MAAM,CAAC,iBAAiB,IAAI;YAC9B,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;SAC5C,CAAC;KACH,CAAC,CAAA;IACF,OAAO;QACL,IAAI;QACJ,QAAQ;QACR,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,QAAQ;KACT,CAAA;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifyResponse.d.ts","sourceRoot":"","sources":["../../src/auth/verifyResponse.ts"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EACV,uBAAuB,EACvB,KAAK,EACN,MAAM,8BAA8B,CAAA;AACrC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AACnE,OAAO,EAAe,KAAK,YAAY,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"verifyResponse.d.ts","sourceRoot":"","sources":["../../src/auth/verifyResponse.ts"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EACV,uBAAuB,EACvB,KAAK,EACN,MAAM,8BAA8B,CAAA;AACrC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AACnE,OAAO,EAAe,KAAK,YAAY,EAAE,MAAM,cAAc,CAAA;AAK7D;;;;;;;;;;GAUG;AACH,wBAAsB,uBAAuB,CAAC,EAC5C,YAAY,EACZ,SAAS,EACT,MAAM,EACN,cAAc,EACf,EAAE;IACD,YAAY,EAAE,uBAAuB,CAAA;IACrC,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,MAAM,CAAA;IACd,cAAc,EAAE,cAAc,CAAA;CAC/B,GAAG,OAAO,CAAC,IAAI,CAAC,CA0EhB;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,YAAY,EAAE,uBAAuB,GAAG,KAAK,EAAE,CAMvE;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,YAAY,CAAA;IACpB,MAAM,EAAE,KAAK,EAAE,CAAA;IACf;;OAEG;IACH,OAAO,EAAE,MAAM,CAAA;CAChB;AASD;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,EAC1B,MAAM,EACN,aAAa,EACb,WAAW,EACX,eAA4B,EAC7B,EAAE;IACD,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,aAAa,EAAE,MAAM,CAAA;IACrB,WAAW,EAAE,MAAM,EAAE,CAAA;IACrB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAA;CAC3B,GAAG,aAAa,CAyChB"}
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
import { verifyPresentation } from '@interop/verifier-core';
|
|
29
29
|
import { parseGrants } from '../grants.js';
|
|
30
30
|
import { earliestExpiry, isExpired } from '../identity/appSession.js';
|
|
31
|
+
import { asArray } from '../jsonLd.js';
|
|
31
32
|
import { RW_ACTIONS } from './loginRequest.js';
|
|
32
33
|
/**
|
|
33
34
|
* Verifies a login response VP cryptographically and structurally (steps 1-2
|
|
@@ -69,8 +70,8 @@ export async function verifyLoginPresentation({ presentation, challenge, domain,
|
|
|
69
70
|
.join(', ');
|
|
70
71
|
throw new Error(`Wallet presentation failed verification (${summary || 'unknown check'}).`);
|
|
71
72
|
}
|
|
72
|
-
|
|
73
|
-
const proofs =
|
|
73
|
+
// The presentation-level proofs (a VP may carry one object or several).
|
|
74
|
+
const proofs = asArray(presentation.proof);
|
|
74
75
|
if (proofs.length === 0) {
|
|
75
76
|
throw new Error('Wallet presentation carries no authentication proof.');
|
|
76
77
|
}
|
|
@@ -113,8 +114,7 @@ export function grantsOf(presentation) {
|
|
|
113
114
|
* The actions a grant allows, normalized to an array.
|
|
114
115
|
*/
|
|
115
116
|
function actionsOf(zcap) {
|
|
116
|
-
|
|
117
|
-
return Array.isArray(allowed) ? allowed : allowed ? [allowed] : [];
|
|
117
|
+
return asArray(zcap.allowedAction);
|
|
118
118
|
}
|
|
119
119
|
/**
|
|
120
120
|
* Structural validation of the granted zcaps (step 3 above). Throws on any
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifyResponse.js","sourceRoot":"","sources":["../../src/auth/verifyResponse.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAM3D,OAAO,EAAE,WAAW,EAAqB,MAAM,cAAc,CAAA;AAC7D,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"verifyResponse.js","sourceRoot":"","sources":["../../src/auth/verifyResponse.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAM3D,OAAO,EA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M,CAAC,CAAA;IAElC,KAAK,MAAM,EAAE,IAAI,WAAW,EAAE,CAAC;QAC7B,MAAM,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC,EAAE,CAAC,CAAA;QACvC,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CAAC,wBAAwB,EAAE,eAAe,CAAC,CAAA;QAC5D,CAAC;QACD,MAAM,OAAO,GAAG,SAAS,CAAC,KAAK,CAAC,CAAA;QAChC,MAAM,OAAO,GAAG,eAAe,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAA;QAC3E,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CACb,QAAQ,EAAE,mCAAmC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CACnE,CAAA;QACH,CAAC;IACH,CAAC;IAED,MAAM,OAAO,GAAG,cAAc,CAAC,MAAM,CAAC,CAAA;IACtC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAA;IACzD,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,CAAA;AACpC,CAAC"}
|
|
@@ -2,45 +2,19 @@
|
|
|
2
2
|
* Copyright (c) 2026 Interop Alliance. All rights reserved.
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* The relying-party side of the VC API request vocabulary: the Verifiable
|
|
6
|
+
* Presentation Request this library composes for a wallet, and the queries it
|
|
7
|
+
* carries.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
* agnostic so the same
|
|
11
|
-
*
|
|
12
|
-
*
|
|
9
|
+
* The request travels today via a CHAPI popup, but the shapes are transport
|
|
10
|
+
* agnostic, so the same compose logic can later back other entry points (a QR
|
|
11
|
+
* scan, an exchange-URL POST) without dragging React or CHAPI along. Only the
|
|
12
|
+
* types this library actually emits or consumes live here; the wallet-side
|
|
13
|
+
* message/response/classification shapes belong to the wallet.
|
|
13
14
|
*
|
|
14
15
|
* @see https://w3c-ccg.github.io/vp-request-spec/
|
|
15
16
|
*/
|
|
16
17
|
import type { IVerifiableCredential, IVerifiablePresentation, IZcap } from '@interop/data-integrity-core';
|
|
17
|
-
/**
|
|
18
|
-
* The union of VC API message types the wallet can classify. Zcap and exchange
|
|
19
|
-
* invitation / issue request messages are deferred to later work.
|
|
20
|
-
*/
|
|
21
|
-
export type WalletAPIMessage = IVPRequest | IVPOffer;
|
|
22
|
-
/**
|
|
23
|
-
* "I'm offering the following credentials" -- a Verifiable Presentation offered
|
|
24
|
-
* to the wallet for storage.
|
|
25
|
-
*
|
|
26
|
-
* @see https://vcplayground.org/docs/n/chapi/wallets/native/#vc-api
|
|
27
|
-
*/
|
|
28
|
-
export type IVPOffer = {
|
|
29
|
-
credentialRequestOrigin?: string;
|
|
30
|
-
verifiablePresentation: IVerifiablePresentation;
|
|
31
|
-
redirectUrl?: string;
|
|
32
|
-
};
|
|
33
|
-
/**
|
|
34
|
-
* "The following things are requested" -- a Verifiable Presentation Request
|
|
35
|
-
* asking the wallet to share credentials and/or prove DID Authentication.
|
|
36
|
-
*
|
|
37
|
-
* @see https://w3c-ccg.github.io/vp-request-spec/
|
|
38
|
-
*/
|
|
39
|
-
export type IVPRequest = {
|
|
40
|
-
credentialRequestOrigin?: string;
|
|
41
|
-
verifiablePresentationRequest: IVPRDetails;
|
|
42
|
-
redirectUrl?: string;
|
|
43
|
-
};
|
|
44
18
|
/**
|
|
45
19
|
* The body of a Verifiable Presentation Request: one or more queries, plus the
|
|
46
20
|
* `challenge` / `domain` used when a DID Authentication proof is requested.
|
|
@@ -50,27 +24,7 @@ export type IVPRDetails = {
|
|
|
50
24
|
challenge?: string;
|
|
51
25
|
domain?: string;
|
|
52
26
|
};
|
|
53
|
-
export type IVPRQuery =
|
|
54
|
-
/**
|
|
55
|
-
* A request for one or more VCs matching an example credential shape.
|
|
56
|
-
*
|
|
57
|
-
* @see https://w3c-ccg.github.io/vp-request-spec/#query-by-example
|
|
58
|
-
*/
|
|
59
|
-
export type IQueryByExample = {
|
|
60
|
-
type: 'QueryByExample';
|
|
61
|
-
acceptedCryptosuites?: Array<{
|
|
62
|
-
cryptosuite: string;
|
|
63
|
-
}>;
|
|
64
|
-
credentialQuery: {
|
|
65
|
-
reason?: string;
|
|
66
|
-
example: {
|
|
67
|
-
'@context'?: string | object | Array<string | object>;
|
|
68
|
-
type?: string | string[];
|
|
69
|
-
issuer?: string | object | Array<string | object>;
|
|
70
|
-
[x: string]: unknown;
|
|
71
|
-
};
|
|
72
|
-
};
|
|
73
|
-
};
|
|
27
|
+
export type IVPRQuery = IDIDAuthenticationQuery | IAppConnectQuery;
|
|
74
28
|
/**
|
|
75
29
|
* A request for a proof of DID Authentication (a signed VerifiablePresentation
|
|
76
30
|
* over the request's `challenge` / `domain`).
|
|
@@ -86,20 +40,6 @@ export type IDIDAuthenticationQuery = {
|
|
|
86
40
|
cryptosuite: string;
|
|
87
41
|
}>;
|
|
88
42
|
};
|
|
89
|
-
/**
|
|
90
|
-
* A request for one or more delegated capabilities (zcaps) on the user's WAS
|
|
91
|
-
* storage. `AuthorizationCapabilityQuery` is the canonical type string (VCALM
|
|
92
|
-
* §3.4.4); `ZcapQuery` is a legacy alias sent by DCW / the
|
|
93
|
-
* `wallet-to-webapp-demo`. `capabilityQuery` may be a single detail object or
|
|
94
|
-
* an array of them.
|
|
95
|
-
*
|
|
96
|
-
* @see https://w3c.github.io/vcalm/ -- AuthorizationCapabilityQuery
|
|
97
|
-
*/
|
|
98
|
-
export type IZcapQuery = {
|
|
99
|
-
type: 'AuthorizationCapabilityQuery' | 'ZcapQuery';
|
|
100
|
-
capabilityQuery: ICapabilityQueryDetail | ICapabilityQueryDetail[];
|
|
101
|
-
challenge?: string;
|
|
102
|
-
};
|
|
103
43
|
/**
|
|
104
44
|
* A single requested capability: which actions (`allowedAction`) the RP
|
|
105
45
|
* (`controller`) wants on which storage target (`invocationTarget`), with an
|
|
@@ -145,26 +85,5 @@ export type IAppConnectQuery = {
|
|
|
145
85
|
};
|
|
146
86
|
capabilityQuery: IAppConnectCapabilityQuery | IAppConnectCapabilityQuery[];
|
|
147
87
|
};
|
|
148
|
-
/**
|
|
149
|
-
* The wallet's response to a request, delivered by whichever transport received
|
|
150
|
-
* it (CHAPI `respondWith`, a future exchange-URL POST, etc). Delegated zcaps
|
|
151
|
-
* ride *inside* the response VP (as a `zcap` array, embedded before signing),
|
|
152
|
-
* so this shape stays credential-presentation only.
|
|
153
|
-
*/
|
|
154
|
-
export type WalletResponse = {
|
|
155
|
-
verifiablePresentation?: IVerifiablePresentation;
|
|
156
|
-
};
|
|
157
|
-
/**
|
|
158
|
-
* A VP Request classified on two independent axes: whether DID Authentication
|
|
159
|
-
* is requested, and separately what content is asked for (credentials and/or
|
|
160
|
-
* capability delegations). Any combination is valid, including zcap-only. The
|
|
161
|
-
* consent screen renders one section per non-empty axis; the two axes replace
|
|
162
|
-
* the former `'vc' | 'didauth' | 'vc+didauth'` cross-product enum.
|
|
163
|
-
*/
|
|
164
|
-
export type WalletRequestProfile = {
|
|
165
|
-
didAuth: boolean;
|
|
166
|
-
vcQueries: IQueryByExample[];
|
|
167
|
-
zcapRequests: ICapabilityQueryDetail[];
|
|
168
|
-
};
|
|
169
88
|
export type { IVerifiableCredential, IVerifiablePresentation, IZcap };
|
|
170
89
|
//# sourceMappingURL=walletRequestTypes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"walletRequestTypes.d.ts","sourceRoot":"","sources":["../../src/auth/walletRequestTypes.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH
|
|
1
|
+
{"version":3,"file":"walletRequestTypes.d.ts","sourceRoot":"","sources":["../../src/auth/walletRequestTypes.ts"],"names":[],"mappings":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