@interop/wallet-core 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/dist/enrollment/enrollment.d.ts +144 -0
  2. package/dist/enrollment/enrollment.d.ts.map +1 -0
  3. package/dist/enrollment/enrollment.js +296 -0
  4. package/dist/enrollment/enrollment.js.map +1 -0
  5. package/dist/enrollment/index.d.ts +20 -0
  6. package/dist/enrollment/index.d.ts.map +1 -0
  7. package/dist/enrollment/index.js +19 -0
  8. package/dist/enrollment/index.js.map +1 -0
  9. package/dist/identity/index.d.ts +0 -5
  10. package/dist/identity/index.d.ts.map +1 -1
  11. package/dist/identity/index.js +0 -4
  12. package/dist/identity/index.js.map +1 -1
  13. package/dist/index.d.ts +13 -3
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +13 -3
  16. package/dist/index.js.map +1 -1
  17. package/dist/keyring/fetch.d.ts +22 -0
  18. package/dist/keyring/fetch.d.ts.map +1 -0
  19. package/dist/keyring/fetch.js +35 -0
  20. package/dist/keyring/fetch.js.map +1 -0
  21. package/dist/keyring/index.d.ts +30 -0
  22. package/dist/keyring/index.d.ts.map +1 -0
  23. package/dist/keyring/index.js +28 -0
  24. package/dist/keyring/index.js.map +1 -0
  25. package/dist/keyring/kdf.d.ts +102 -0
  26. package/dist/keyring/kdf.d.ts.map +1 -0
  27. package/dist/keyring/kdf.js +148 -0
  28. package/dist/keyring/kdf.js.map +1 -0
  29. package/dist/keyring/record.d.ts +98 -0
  30. package/dist/keyring/record.d.ts.map +1 -0
  31. package/dist/keyring/record.js +119 -0
  32. package/dist/keyring/record.js.map +1 -0
  33. package/dist/keyring/unlockSpace.d.ts +101 -0
  34. package/dist/keyring/unlockSpace.d.ts.map +1 -0
  35. package/dist/keyring/unlockSpace.js +226 -0
  36. package/dist/keyring/unlockSpace.js.map +1 -0
  37. package/dist/keys/index.d.ts +24 -0
  38. package/dist/keys/index.d.ts.map +1 -0
  39. package/dist/keys/index.js +22 -0
  40. package/dist/keys/index.js.map +1 -0
  41. package/dist/keys/puk.d.ts +42 -0
  42. package/dist/keys/puk.d.ts.map +1 -0
  43. package/dist/keys/puk.js +56 -0
  44. package/dist/keys/puk.js.map +1 -0
  45. package/dist/keys/pukRoster.d.ts +210 -0
  46. package/dist/keys/pukRoster.d.ts.map +1 -0
  47. package/dist/keys/pukRoster.js +263 -0
  48. package/dist/keys/pukRoster.js.map +1 -0
  49. package/dist/keys/rosterStore.d.ts +18 -0
  50. package/dist/keys/rosterStore.d.ts.map +1 -0
  51. package/dist/keys/rosterStore.js +38 -0
  52. package/dist/keys/rosterStore.js.map +1 -0
  53. package/dist/space/collections.d.ts +57 -0
  54. package/dist/space/collections.d.ts.map +1 -1
  55. package/dist/space/collections.js +48 -0
  56. package/dist/space/collections.js.map +1 -1
  57. package/dist/space/index.d.ts +4 -0
  58. package/dist/space/index.d.ts.map +1 -1
  59. package/dist/space/index.js +4 -0
  60. package/dist/space/index.js.map +1 -1
  61. package/dist/webvh/didWeb.d.ts +41 -0
  62. package/dist/webvh/didWeb.d.ts.map +1 -0
  63. package/dist/webvh/didWeb.js +24 -0
  64. package/dist/webvh/didWeb.js.map +1 -0
  65. package/dist/webvh/didWebvh.d.ts +251 -0
  66. package/dist/webvh/didWebvh.d.ts.map +1 -0
  67. package/dist/webvh/didWebvh.js +775 -0
  68. package/dist/webvh/didWebvh.js.map +1 -0
  69. package/dist/webvh/index.d.ts +27 -0
  70. package/dist/webvh/index.d.ts.map +1 -0
  71. package/dist/webvh/index.js +24 -0
  72. package/dist/webvh/index.js.map +1 -0
  73. package/dist/webvh/zcap.d.ts +104 -0
  74. package/dist/webvh/zcap.d.ts.map +1 -0
  75. package/dist/webvh/zcap.js +117 -0
  76. package/dist/webvh/zcap.js.map +1 -0
  77. package/package.json +30 -4
  78. package/dist/identity/collectionKeys.d.ts +0 -36
  79. package/dist/identity/collectionKeys.d.ts.map +0 -1
  80. package/dist/identity/collectionKeys.js +0 -92
  81. package/dist/identity/collectionKeys.js.map +0 -1
@@ -62,4 +62,52 @@ export const WALLET_SPACE_COLLECTION_SPECS = [
62
62
  PUBLIC_CREDENTIALS_COLLECTION_SPEC,
63
63
  WALLET_ACTIVITY_COLLECTION_SPEC
64
64
  ];
65
+ /**
66
+ * The system collections and resource names that carry an account's identity
67
+ * and key material. They sit deliberately OUTSIDE the synced collection specs
68
+ * above: none of them gets a local replica or background replication, and each
69
+ * is read and written directly.
70
+ *
71
+ * - `id` -- world-readable (a collection-level public-read policy): the
72
+ * published DID document (`did.json`) and the did:webvh history log
73
+ * (`did.jsonl`). The path segments name the collection that holds the
74
+ * document, so the did:web id is `did:web:<host>:space:<spaceId>:id` and
75
+ * resolves to `https://<host>/space/<spaceId>/id/did.json`.
76
+ * - `key-map` -- private and capability-gated: the key-id map (`keys.json`)
77
+ * and the PUK wrap-set roster (`puk.json`). Kept separate from `id` exactly
78
+ * so `id` can be made world-readable without ever exposing key material.
79
+ * - `keyring` -- the unlock Space's single collection, holding the one
80
+ * keyring record (`keyring.json`). It lives in the minimal unlock Space
81
+ * controlled by an unlock identity, never in the wallet data Space.
82
+ */
83
+ export const ID_COLLECTION = { id: 'id', name: 'Identity' };
84
+ export const KEY_MAP_COLLECTION = { id: 'key-map', name: 'Key Map' };
85
+ export const KEYRING_COLLECTION = { id: 'keyring', name: 'Keyring' };
86
+ /** The world-readable DID document, served as `application/did+json`. */
87
+ export const DID_DOCUMENT_RESOURCE = 'did.json';
88
+ /**
89
+ * The world-readable did:webvh history log, a raw JSON-Lines string served as
90
+ * `text/jsonl`: one log entry per line, each a full DID-document snapshot in a
91
+ * hash chain. Sibling of `did.json` in the same `id` collection;
92
+ * `did:webvh:<scid>:<host>:space:<spaceId>:id` resolves to
93
+ * `https://<host>/space/<spaceId>/id/did.jsonl`.
94
+ */
95
+ export const DID_LOG_RESOURCE = 'did.jsonl';
96
+ /**
97
+ * The (non-public) key-id map: verification method to KMS key id. Lives in the
98
+ * `key-map` collection. The recovery anchor -- written before `did.json` so a
99
+ * torn provisioning resumes from it.
100
+ */
101
+ export const DID_KEYS_RESOURCE = 'keys.json';
102
+ /**
103
+ * The per-user-key (PUK) wrap-set roster, sibling of `keys.json` in the same
104
+ * private `key-map` collection: a `CollectionEncryption` marker stored
105
+ * verbatim as the resource body, whose current epoch IS the current PUK (the
106
+ * epoch id is the PUK's did:key; the wrapped secret is the PUK's raw key,
107
+ * wrapped to each enrolled client's key-agreement key). Read directly with a
108
+ * compare-and-swap etag -- never replicated.
109
+ */
110
+ export const PUK_ROSTER_RESOURCE = 'puk.json';
111
+ /** The keyring record: the encrypted account pointer, in the unlock Space. */
112
+ export const KEYRING_RESOURCE = 'keyring.json';
65
113
  //# sourceMappingURL=collections.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"collections.js","sourceRoot":"","sources":["../../src/space/collections.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;GAaG;AAEH,0EAA0E;AAC1E,MAAM,CAAC,MAAM,8BAA8B,GAAG,qBAAqB,CAAA;AACnE,2EAA2E;AAC3E,MAAM,CAAC,MAAM,6BAA6B,GAAG,oBAAoB,CAAA;AACjE,0DAA0D;AAC1D,MAAM,CAAC,MAAM,0BAA0B,GAAG,iBAAiB,CAAA;AAyB3D;;;GAGG;AACH,MAAM,CAAC,MAAM,mCAAmC,GAAwB;IACtE,YAAY,EAAE,8BAA8B;IAC5C,YAAY,EAAE,SAAS;IACvB,OAAO,EAAE,KAAK;IACd,UAAU,EAAE,KAAK;IACjB,QAAQ,EAAE,KAAK;CAChB,CAAA;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,kCAAkC,GAAwB;IACrE,YAAY,EAAE,6BAA6B;IAC3C,YAAY,EAAE,SAAS;IACvB,OAAO,EAAE,KAAK;IACd,UAAU,EAAE,WAAW;IACvB,QAAQ,EAAE,IAAI;CACf,CAAA;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAwB;IAClE,YAAY,EAAE,0BAA0B;IACxC,YAAY,EAAE,SAAS;IACvB,OAAO,EAAE,KAAK;IACd,UAAU,EAAE,KAAK;IACjB,QAAQ,EAAE,KAAK;CAChB,CAAA;AAED,kFAAkF;AAClF,MAAM,CAAC,MAAM,6BAA6B,GAA0B;IAClE,mCAAmC;IACnC,kCAAkC;IAClC,+BAA+B;CAChC,CAAA"}
1
+ {"version":3,"file":"collections.js","sourceRoot":"","sources":["../../src/space/collections.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;GAaG;AAEH,0EAA0E;AAC1E,MAAM,CAAC,MAAM,8BAA8B,GAAG,qBAAqB,CAAA;AACnE,2EAA2E;AAC3E,MAAM,CAAC,MAAM,6BAA6B,GAAG,oBAAoB,CAAA;AACjE,0DAA0D;AAC1D,MAAM,CAAC,MAAM,0BAA0B,GAAG,iBAAiB,CAAA;AAyB3D;;;GAGG;AACH,MAAM,CAAC,MAAM,mCAAmC,GAAwB;IACtE,YAAY,EAAE,8BAA8B;IAC5C,YAAY,EAAE,SAAS;IACvB,OAAO,EAAE,KAAK;IACd,UAAU,EAAE,KAAK;IACjB,QAAQ,EAAE,KAAK;CAChB,CAAA;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,kCAAkC,GAAwB;IACrE,YAAY,EAAE,6BAA6B;IAC3C,YAAY,EAAE,SAAS;IACvB,OAAO,EAAE,KAAK;IACd,UAAU,EAAE,WAAW;IACvB,QAAQ,EAAE,IAAI;CACf,CAAA;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAwB;IAClE,YAAY,EAAE,0BAA0B;IACxC,YAAY,EAAE,SAAS;IACvB,OAAO,EAAE,KAAK;IACd,UAAU,EAAE,KAAK;IACjB,QAAQ,EAAE,KAAK;CAChB,CAAA;AAED,kFAAkF;AAClF,MAAM,CAAC,MAAM,6BAA6B,GAA0B;IAClE,mCAAmC;IACnC,kCAAkC;IAClC,+BAA+B;CAChC,CAAA;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,CAAA;AAC3D,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,CAAA;AACpE,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,CAAA;AAEpE,yEAAyE;AACzE,MAAM,CAAC,MAAM,qBAAqB,GAAG,UAAU,CAAA;AAC/C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,WAAW,CAAA;AAC3C;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,WAAW,CAAA;AAC5C;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,UAAU,CAAA;AAC7C,8EAA8E;AAC9E,MAAM,CAAC,MAAM,gBAAgB,GAAG,cAAc,CAAA"}
@@ -8,6 +8,9 @@
8
8
  * - The shared collection ids and descriptive specs (`private-credentials`,
9
9
  * `public-credentials`, `wallet-activity`). The contacts collections stay in
10
10
  * `@interop/social-core`.
11
+ * - The system collections and resource names that carry identity and key
12
+ * material (`id`, `key-map`, `keyring`; `did.json`, `did.jsonl`, `keys.json`,
13
+ * `puk.json`, `keyring.json`) -- outside the synced set, never replicated.
11
14
  * - The `wallet-activity` wire shape (`WalletActivity`) and the pure
12
15
  * `addHistory*` payload builders.
13
16
  * - `publicCredentialUrl`, the world-readable shared-credential URL both
@@ -16,6 +19,7 @@
16
19
  * `parseWasLinkPayload` / `encodeWasLinkSecret`).
17
20
  */
18
21
  export { PRIVATE_CREDENTIALS_COLLECTION, PUBLIC_CREDENTIALS_COLLECTION, WALLET_ACTIVITY_COLLECTION, PRIVATE_CREDENTIALS_COLLECTION_SPEC, PUBLIC_CREDENTIALS_COLLECTION_SPEC, WALLET_ACTIVITY_COLLECTION_SPEC, WALLET_SPACE_COLLECTION_SPECS } from './collections.js';
22
+ export { ID_COLLECTION, KEY_MAP_COLLECTION, KEYRING_COLLECTION, DID_DOCUMENT_RESOURCE, DID_LOG_RESOURCE, DID_KEYS_RESOURCE, PUK_ROSTER_RESOURCE, KEYRING_RESOURCE } from './collections.js';
19
23
  export type { SpaceCollectionSpec } from './collections.js';
20
24
  export { ACTIVITY_TYPE, addHistoryNewAccount, addHistorySpaceCreated, addHistoryCredentialCreated, addHistoryCredentialDeleted, addHistoryCredentialShared, addHistoryCredentialUnshared, addHistoryLogin, addHistoryAppRevoke } from './activity.js';
21
25
  export type { WalletActivity, ActivityGrant } from './activity.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/space/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;GAaG;AACH,OAAO,EACL,8BAA8B,EAC9B,6BAA6B,EAC7B,0BAA0B,EAC1B,mCAAmC,EACnC,kCAAkC,EAClC,+BAA+B,EAC/B,6BAA6B,EAC9B,MAAM,kBAAkB,CAAA;AACzB,YAAY,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AAE3D,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,sBAAsB,EACtB,2BAA2B,EAC3B,2BAA2B,EAC3B,0BAA0B,EAC1B,4BAA4B,EAC5B,eAAe,EACf,mBAAmB,EACpB,MAAM,eAAe,CAAA;AACtB,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAElE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAErD,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,cAAc,CAAA;AACrB,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAElD,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/space/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EACL,8BAA8B,EAC9B,6BAA6B,EAC7B,0BAA0B,EAC1B,mCAAmC,EACnC,kCAAkC,EAClC,+BAA+B,EAC/B,6BAA6B,EAC9B,MAAM,kBAAkB,CAAA;AACzB,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,kBAAkB,EAClB,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,kBAAkB,CAAA;AACzB,YAAY,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AAE3D,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,sBAAsB,EACtB,2BAA2B,EAC3B,2BAA2B,EAC3B,0BAA0B,EAC1B,4BAA4B,EAC5B,eAAe,EACf,mBAAmB,EACpB,MAAM,eAAe,CAAA;AACtB,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAElE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAErD,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,cAAc,CAAA;AACrB,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAElD,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA"}
@@ -8,6 +8,9 @@
8
8
  * - The shared collection ids and descriptive specs (`private-credentials`,
9
9
  * `public-credentials`, `wallet-activity`). The contacts collections stay in
10
10
  * `@interop/social-core`.
11
+ * - The system collections and resource names that carry identity and key
12
+ * material (`id`, `key-map`, `keyring`; `did.json`, `did.jsonl`, `keys.json`,
13
+ * `puk.json`, `keyring.json`) -- outside the synced set, never replicated.
11
14
  * - The `wallet-activity` wire shape (`WalletActivity`) and the pure
12
15
  * `addHistory*` payload builders.
13
16
  * - `publicCredentialUrl`, the world-readable shared-credential URL both
@@ -16,6 +19,7 @@
16
19
  * `parseWasLinkPayload` / `encodeWasLinkSecret`).
17
20
  */
18
21
  export { PRIVATE_CREDENTIALS_COLLECTION, PUBLIC_CREDENTIALS_COLLECTION, WALLET_ACTIVITY_COLLECTION, PRIVATE_CREDENTIALS_COLLECTION_SPEC, PUBLIC_CREDENTIALS_COLLECTION_SPEC, WALLET_ACTIVITY_COLLECTION_SPEC, WALLET_SPACE_COLLECTION_SPECS } from './collections.js';
22
+ export { ID_COLLECTION, KEY_MAP_COLLECTION, KEYRING_COLLECTION, DID_DOCUMENT_RESOURCE, DID_LOG_RESOURCE, DID_KEYS_RESOURCE, PUK_ROSTER_RESOURCE, KEYRING_RESOURCE } from './collections.js';
19
23
  export { ACTIVITY_TYPE, addHistoryNewAccount, addHistorySpaceCreated, addHistoryCredentialCreated, addHistoryCredentialDeleted, addHistoryCredentialShared, addHistoryCredentialUnshared, addHistoryLogin, addHistoryAppRevoke } from './activity.js';
20
24
  export { publicCredentialUrl } from './publicLink.js';
21
25
  export { encodeWasLinkSecret, buildWasLinkPayload, parseWasLinkPayload } from './wasLink.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/space/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;GAaG;AACH,OAAO,EACL,8BAA8B,EAC9B,6BAA6B,EAC7B,0BAA0B,EAC1B,mCAAmC,EACnC,kCAAkC,EAClC,+BAA+B,EAC/B,6BAA6B,EAC9B,MAAM,kBAAkB,CAAA;AAGzB,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,sBAAsB,EACtB,2BAA2B,EAC3B,2BAA2B,EAC3B,0BAA0B,EAC1B,4BAA4B,EAC5B,eAAe,EACf,mBAAmB,EACpB,MAAM,eAAe,CAAA;AAGtB,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAErD,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,cAAc,CAAA;AAGrB,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/space/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EACL,8BAA8B,EAC9B,6BAA6B,EAC7B,0BAA0B,EAC1B,mCAAmC,EACnC,kCAAkC,EAClC,+BAA+B,EAC/B,6BAA6B,EAC9B,MAAM,kBAAkB,CAAA;AACzB,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,kBAAkB,EAClB,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,kBAAkB,CAAA;AAGzB,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,sBAAsB,EACtB,2BAA2B,EAC3B,2BAA2B,EAC3B,0BAA0B,EAC1B,4BAA4B,EAC5B,eAAe,EACf,mBAAmB,EACpB,MAAM,eAAe,CAAA;AAGtB,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAErD,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,cAAc,CAAA;AAGrB,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA"}
@@ -0,0 +1,41 @@
1
+ /*!
2
+ * Copyright (c) 2026 Interop Alliance. All rights reserved.
3
+ */
4
+ /**
5
+ * The did:web relationship map the did:webvh module round-trips: the durable
6
+ * `keys.json` binding from DID relationship to KMS key, plus the fragment
7
+ * helper both documents' verification-method ids are read through. A KMS key's
8
+ * public alias expands `{publicKeyMultibase}` at generate time, so a
9
+ * verification-method id already carries the key's `publicKeyMultibase` and no
10
+ * separate key-description fetch is ever needed.
11
+ */
12
+ /**
13
+ * One verification method's durable binding: the verification-method id (the
14
+ * did:web `#fragment` URL, which is also the KMS key's publicAlias) and the
15
+ * KMS key id used to invoke signing.
16
+ */
17
+ export interface DidWebKey {
18
+ vmId: string;
19
+ kmsKeyId: string;
20
+ }
21
+ /**
22
+ * The key-id map persisted as `keys.json` in the private `key-map` collection:
23
+ * the durable mapping from DID relationship to KMS key, since the KMS protocol
24
+ * has no list-keys endpoint and key ids are server-generated.
25
+ */
26
+ export interface DidWebKeyMap {
27
+ authentication: DidWebKey;
28
+ assertionMethod: DidWebKey;
29
+ keyAgreement: DidWebKey;
30
+ }
31
+ /**
32
+ * The bare `publicKeyMultibase` a KMS key alias or verification-method id
33
+ * carries in its fragment. The KMS expanded `#{publicKeyMultibase}` at generate
34
+ * time, so the fragment IS the multibase key (no separate key-description fetch
35
+ * needed).
36
+ *
37
+ * @param id {string}
38
+ * @returns {string}
39
+ */
40
+ export declare function multibaseOf(id: string): string;
41
+ //# sourceMappingURL=didWeb.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"didWeb.d.ts","sourceRoot":"","sources":["../../src/webvh/didWeb.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;GAOG;AAEH;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,cAAc,EAAE,SAAS,CAAA;IACzB,eAAe,EAAE,SAAS,CAAA;IAC1B,YAAY,EAAE,SAAS,CAAA;CACxB;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAE9C"}
@@ -0,0 +1,24 @@
1
+ /*!
2
+ * Copyright (c) 2026 Interop Alliance. All rights reserved.
3
+ */
4
+ /**
5
+ * The did:web relationship map the did:webvh module round-trips: the durable
6
+ * `keys.json` binding from DID relationship to KMS key, plus the fragment
7
+ * helper both documents' verification-method ids are read through. A KMS key's
8
+ * public alias expands `{publicKeyMultibase}` at generate time, so a
9
+ * verification-method id already carries the key's `publicKeyMultibase` and no
10
+ * separate key-description fetch is ever needed.
11
+ */
12
+ /**
13
+ * The bare `publicKeyMultibase` a KMS key alias or verification-method id
14
+ * carries in its fragment. The KMS expanded `#{publicKeyMultibase}` at generate
15
+ * time, so the fragment IS the multibase key (no separate key-description fetch
16
+ * needed).
17
+ *
18
+ * @param id {string}
19
+ * @returns {string}
20
+ */
21
+ export function multibaseOf(id) {
22
+ return id.slice(id.lastIndexOf('#') + 1);
23
+ }
24
+ //# sourceMappingURL=didWeb.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"didWeb.js","sourceRoot":"","sources":["../../src/webvh/didWeb.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;GAOG;AAuBH;;;;;;;;GAQG;AACH,MAAM,UAAU,WAAW,CAAC,EAAU;IACpC,OAAO,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAA;AAC1C,CAAC"}
@@ -0,0 +1,251 @@
1
+ import type { KeystoreAgent } from '@interop/webkms-client';
2
+ import type { DidWebKeyMap } from './didWeb.js';
3
+ /**
4
+ * The Space-side seam this module reads and writes through: the world-readable
5
+ * `id` collection (the DID log and document) and the private `key-map`
6
+ * collection's `keys.json`. A wallet app's own remote-store class satisfies
7
+ * the shape structurally -- no adapter needed.
8
+ */
9
+ export interface WebvhIdStore {
10
+ /**
11
+ * The raw text body of an `id` collection resource (the JSON-Lines log), or
12
+ * `undefined` when it is not published.
13
+ */
14
+ getIdResourceRaw(options: {
15
+ resourceId: string;
16
+ }): Promise<string | undefined>;
17
+ /**
18
+ * The parsed JSON body of an `id` collection resource (the DID document), or
19
+ * `undefined` when it is not published.
20
+ */
21
+ getIdResource(options: {
22
+ resourceId: string;
23
+ }): Promise<unknown>;
24
+ /**
25
+ * Writes (upserts) an `id` collection resource.
26
+ */
27
+ putIdResource(options: {
28
+ resourceId: string;
29
+ content: object | string;
30
+ contentType?: string;
31
+ }): Promise<void>;
32
+ /**
33
+ * Writes (upserts) `keys.json` in the private `key-map` collection.
34
+ */
35
+ putKeyMap(options: {
36
+ content: object;
37
+ }): Promise<void>;
38
+ }
39
+ /**
40
+ * The client-held did:webvh update-key material: 32-byte Ed25519 seeds.
41
+ * `pendingStagedSeed` is present only mid-rotation (minted and persisted
42
+ * before the log entry publishes, promoted to `stagedSeed` after).
43
+ */
44
+ export interface ClientWebvhUpdateKeys {
45
+ updateSeed: Uint8Array;
46
+ stagedSeed: Uint8Array;
47
+ pendingStagedSeed?: Uint8Array;
48
+ }
49
+ /**
50
+ * The public halves of one enrolled client's key set, as they appear in the
51
+ * document: the Ed25519 signing key (`z6Mk...`) and its X25519 key-agreement
52
+ * twin (`z6LS...`).
53
+ */
54
+ export interface WebvhClientKeys {
55
+ signingKeyMultibase: string;
56
+ keyAgreementKeyMultibase: string;
57
+ }
58
+ /**
59
+ * The `webvh` block added to `keys.json` v2, a sibling of the did:web
60
+ * relationship map. Absent block = a record written before did:webvh hosting;
61
+ * everything degrades to did:web behavior, no format-version bump (additive
62
+ * convention). It carries only the published DID: the update keys are
63
+ * client-held seeds, never recorded in a Space-hosted resource.
64
+ */
65
+ export interface DidWebvhBlock {
66
+ did?: string;
67
+ }
68
+ /**
69
+ * `keys.json` v2: the did:web key map plus the optional `webvh` block. The
70
+ * did:web parse/guard tolerates and preserves the block, so a round-trip
71
+ * through the did:web provisioning never strips it.
72
+ */
73
+ export type DidWebKeyMapV2 = DidWebKeyMap & {
74
+ webvh?: DidWebvhBlock;
75
+ };
76
+ /**
77
+ * The `did:webvh:{SCID}:<host>:space:<spaceId>:id` controller template, with
78
+ * the literal `{SCID}` placeholder the library replaces at creation. The host
79
+ * segment percent-encodes a port (`localhost:8080` becomes `localhost%3A8080`),
80
+ * matching the library's `toDidDomainComponent`.
81
+ *
82
+ * @param options {object}
83
+ * @param options.wasServerUrl {string}
84
+ * @param options.spaceId {string}
85
+ * @returns {string}
86
+ */
87
+ export declare function didWebvhControllerTemplate({ wasServerUrl, spaceId }: {
88
+ wasServerUrl: string;
89
+ spaceId: string;
90
+ }): string;
91
+ /**
92
+ * Mints a fresh pair of client-held update-key seeds (active + staged) for a
93
+ * brand-new did:webvh log. The caller owns persistence: these seeds are the
94
+ * only update authority the log will ever accept, so they must be durable
95
+ * before {@link ensureDidWebvh} publishes anything.
96
+ *
97
+ * @returns {Promise<ClientWebvhUpdateKeys>}
98
+ */
99
+ export declare function mintClientWebvhUpdateKeys(): Promise<ClientWebvhUpdateKeys>;
100
+ /**
101
+ * The `publicKeyMultibase` of the Ed25519 update key a seed derives, as it
102
+ * appears in the log's `parameters.updateKeys`.
103
+ *
104
+ * @param options {object}
105
+ * @param options.seed {Uint8Array} a 32-byte Ed25519 seed
106
+ * @returns {Promise<string>}
107
+ */
108
+ export declare function updateKeyMultibase({ seed }: {
109
+ seed: Uint8Array;
110
+ }): Promise<string>;
111
+ /**
112
+ * Idempotently provisions and publishes the user's did:webvh DID log, run
113
+ * directly after the did:web provisioning (non-fatal). The durable anchor is
114
+ * the caller-persisted update-key seeds, so the flow is a simple probe:
115
+ *
116
+ * - `did.jsonl` published: sanity-check that the log's authorized `updateKeys`
117
+ * still name one of this client's seeds (active, staged, or pending -- a
118
+ * rotation in flight finalizes separately), adopt the resolved DID, and
119
+ * write the `keys.json` webvh block if it is missing or stale.
120
+ * - `did.jsonl` absent: create the log with the active update key, prerotation
121
+ * committed to the staged key, publish log + `did.json`, then record the DID
122
+ * in `keys.json`.
123
+ *
124
+ * A published log whose `updateKeys` match none of the seeds is fatal: with
125
+ * client-held update keys a lost seed is lost update authority, and no KMS
126
+ * repair path exists by design.
127
+ *
128
+ * @param options {object}
129
+ * @param options.idStore {WebvhIdStore}
130
+ * @param options.wasServerUrl {string}
131
+ * @param options.spaceId {string}
132
+ * @param options.didWebKeys {DidWebKeyMapV2} the parsed keys.json (with any
133
+ * webvh block) returned by the did:web provisioning.
134
+ * @param options.clientKeys {WebvhClientKeys} this client's published keys
135
+ * @param options.updateKeys {ClientWebvhUpdateKeys} already durably persisted
136
+ * @returns {Promise<{ did: string }>}
137
+ */
138
+ export declare function ensureDidWebvh({ idStore, wasServerUrl, spaceId, didWebKeys, clientKeys, updateKeys }: {
139
+ idStore: WebvhIdStore;
140
+ wasServerUrl: string;
141
+ spaceId: string;
142
+ didWebKeys: DidWebKeyMapV2;
143
+ clientKeys: WebvhClientKeys;
144
+ updateKeys: ClientWebvhUpdateKeys;
145
+ }): Promise<{
146
+ did: string;
147
+ }>;
148
+ /**
149
+ * Rotates this client's did:webvh update key (the user-triggered ceremony on
150
+ * the wallet's settings screen). The staged key is revealed to sign its own
151
+ * activation and become the sole active update key, a freshly minted staged
152
+ * key is committed as the new `nextKeyHashes`, and the caller's persisted
153
+ * seeds roll forward. No KMS and no `keys.json` involvement: the update keys
154
+ * are client-held, and the published DID does not change.
155
+ *
156
+ * The persist-before-publish invariant is load-bearing: the new staged seed is
157
+ * handed to `persistUpdateKeys` (as `pendingStagedSeed`) and awaited BEFORE the
158
+ * log entry committing it is published, so no published log can ever depend on
159
+ * a seed that is not durable. A crash between publish and finalize is
160
+ * recovered on the next run: the log already sits at the staged (or pending)
161
+ * key, and the seeds are simply rolled forward locally without touching it.
162
+ *
163
+ * @param options {object}
164
+ * @param options.idStore {WebvhIdStore}
165
+ * @param options.updateKeys {ClientWebvhUpdateKeys} the current seeds
166
+ * @param options.persistUpdateKeys {Function} awaited before every publish
167
+ * that changes the log's authorized update keys
168
+ * @returns {Promise<{ did: string }>}
169
+ */
170
+ export declare function rotateWebvhUpdateKey({ idStore, updateKeys, persistUpdateKeys }: {
171
+ idStore: WebvhIdStore;
172
+ updateKeys: ClientWebvhUpdateKeys;
173
+ persistUpdateKeys: (next: ClientWebvhUpdateKeys) => Promise<void>;
174
+ }): Promise<{
175
+ did: string;
176
+ }>;
177
+ /**
178
+ * The public halves of a client being enrolled: its published key set (the
179
+ * Ed25519 signing key and X25519 key-agreement twin that become document
180
+ * verification methods) plus its update-key pair -- the active key that joins
181
+ * `updateKeys` and the staged key whose hash is committed so the new client
182
+ * can later self-rotate. All four are `publicKeyMultibase` strings; the seeds
183
+ * behind them never leave the client being enrolled.
184
+ */
185
+ export interface WebvhEnrollmentKeys extends WebvhClientKeys {
186
+ updateKeyMultibase: string;
187
+ stagedUpdateKeyMultibase: string;
188
+ }
189
+ /**
190
+ * Enrolls a second wallet client into the published did:webvh document -- the
191
+ * log half of the enrollment ceremony (the PUK roster wrap happens first,
192
+ * outside this module). Two entries, forced by prerotation (a new update key
193
+ * must hash into the PREVIOUS entry's `nextKeyHashes`):
194
+ *
195
+ * 1. **Commit**: a sparse entry extending `nextKeyHashes` with the new
196
+ * client's update-key and staged-key hashes (document and `updateKeys`
197
+ * untouched).
198
+ * 2. **Add**: an entry adding the new client's verification methods (its
199
+ * Ed25519 key under the four signing relationships, its X25519 twin under
200
+ * `keyAgreement`) and its update key to `updateKeys`.
201
+ *
202
+ * Both entries are signed by THIS client's active update key (quorum-of-one:
203
+ * any single enrolled client can enroll). The ceremony is resumable from
204
+ * durable state alone: a tear after the commit is detected by its hashes
205
+ * already standing in `nextKeyHashes` (skip to the add entry), and a
206
+ * completed enrollment is detected by the update key already being authorized
207
+ * (no-op). Re-running with the same key set converges without forking the
208
+ * log.
209
+ *
210
+ * @param options {object}
211
+ * @param options.idStore {WebvhIdStore}
212
+ * @param options.updateKeys {ClientWebvhUpdateKeys} THIS client's seeds
213
+ * @param options.newClient {WebvhEnrollmentKeys} the enrollee's public halves
214
+ * @returns {Promise<{ did: string }>}
215
+ */
216
+ export declare function enrollWebvhClient({ idStore, updateKeys, newClient }: {
217
+ idStore: WebvhIdStore;
218
+ updateKeys: ClientWebvhUpdateKeys;
219
+ newClient: WebvhEnrollmentKeys;
220
+ }): Promise<{
221
+ did: string;
222
+ }>;
223
+ /**
224
+ * Rebuilds `keys.json` from the published artifacts plus a WebKMS key listing
225
+ * -- the recovery path for a lost or rolled-back `keys.json`. List Keys is
226
+ * authorized as `read` against the keystore controller, which only the
227
+ * root-controlled keystore agent can invoke.
228
+ *
229
+ * KMS key local ids are server-generated random and appear in no published
230
+ * artifact, so the bindings are rediscovered by public key material instead.
231
+ * List the keystore once -- each listed description carries `keyUrl`, the
232
+ * key's canonical invocation URL (the signable handle its alias-overridden
233
+ * `id` erases) -- then match `did.json`'s three relationship verification
234
+ * methods by `publicKeyMultibase` and rewrite `keys.json` from what matched.
235
+ * When `did.jsonl` is published, its resolved DID is recorded in the `webvh`
236
+ * block; there is nothing else to repair there, since the log's update keys are
237
+ * client-held seeds that no keystore listing could recover.
238
+ *
239
+ * An unmatchable binding is unrepairable and throws: a published artifact
240
+ * depends on a key the keystore no longer lists.
241
+ *
242
+ * @param options {object}
243
+ * @param options.keystoreAgent {KeystoreAgent}
244
+ * @param options.idStore {WebvhIdStore}
245
+ * @returns {Promise<DidWebKeyMapV2>} the rebuilt, persisted keys.json
246
+ */
247
+ export declare function repairKeyBindings({ keystoreAgent, idStore }: {
248
+ keystoreAgent: KeystoreAgent;
249
+ idStore: WebvhIdStore;
250
+ }): Promise<DidWebKeyMapV2>;
251
+ //# sourceMappingURL=didWebvh.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"didWebvh.d.ts","sourceRoot":"","sources":["../../src/webvh/didWebvh.ts"],"names":[],"mappings":"AAiEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAO3D,OAAO,KAAK,EAAa,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1D;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,gBAAgB,CAAC,OAAO,EAAE;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;IAC9E;;;OAGG;IACH,aAAa,CAAC,OAAO,EAAE;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IAChE;;OAEG;IACH,aAAa,CA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