@interop/wallet-core 0.50.0 → 0.52.1

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 (241) hide show
  1. package/README.md +7 -11
  2. package/dist/clientAnnex/credentialAnchoredGenesis.d.ts +17 -8
  3. package/dist/clientAnnex/credentialAnchoredGenesis.d.ts.map +1 -1
  4. package/dist/clientAnnex/credentialAnchoredGenesis.js +33 -12
  5. package/dist/clientAnnex/credentialAnchoredGenesis.js.map +1 -1
  6. package/dist/clientAnnex/forget.d.ts +18 -6
  7. package/dist/clientAnnex/forget.d.ts.map +1 -1
  8. package/dist/clientAnnex/forget.js +19 -6
  9. package/dist/clientAnnex/forget.js.map +1 -1
  10. package/dist/clientAnnex/forgetLast.d.ts +65 -28
  11. package/dist/clientAnnex/forgetLast.d.ts.map +1 -1
  12. package/dist/clientAnnex/forgetLast.js +78 -18
  13. package/dist/clientAnnex/forgetLast.js.map +1 -1
  14. package/dist/clientAnnex/gc.d.ts +3 -3
  15. package/dist/clientAnnex/gc.d.ts.map +1 -1
  16. package/dist/clientAnnex/gc.js +2 -2
  17. package/dist/clientAnnex/gc.js.map +1 -1
  18. package/dist/clientAnnex/index.d.ts +6 -6
  19. package/dist/clientAnnex/index.d.ts.map +1 -1
  20. package/dist/clientAnnex/index.js +5 -5
  21. package/dist/clientAnnex/index.js.map +1 -1
  22. package/dist/clientAnnex/ladder.d.ts +19 -11
  23. package/dist/clientAnnex/ladder.d.ts.map +1 -1
  24. package/dist/clientAnnex/ladder.js +77 -14
  25. package/dist/clientAnnex/ladder.js.map +1 -1
  26. package/dist/clientAnnex/ladderAnchored.d.ts +36 -7
  27. package/dist/clientAnnex/ladderAnchored.d.ts.map +1 -1
  28. package/dist/clientAnnex/ladderAnchored.js +80 -18
  29. package/dist/clientAnnex/ladderAnchored.js.map +1 -1
  30. package/dist/clientAnnex/log.d.ts +6 -6
  31. package/dist/clientAnnex/log.d.ts.map +1 -1
  32. package/dist/clientAnnex/log.js +8 -8
  33. package/dist/clientAnnex/log.js.map +1 -1
  34. package/dist/clientAnnex/recoveryLadderAnchored.d.ts +7 -7
  35. package/dist/clientAnnex/recoveryLadderAnchored.js +9 -9
  36. package/dist/clientAnnex/recoveryLadderAnchored.js.map +1 -1
  37. package/dist/clientAnnex/selfEnroll.d.ts +6 -4
  38. package/dist/clientAnnex/selfEnroll.d.ts.map +1 -1
  39. package/dist/clientAnnex/selfEnroll.js +19 -7
  40. package/dist/clientAnnex/selfEnroll.js.map +1 -1
  41. package/dist/clients/listing.d.ts +1 -1
  42. package/dist/clients/listing.d.ts.map +1 -1
  43. package/dist/clients/listing.js +1 -1
  44. package/dist/clients/listing.js.map +1 -1
  45. package/dist/clients/revocation.d.ts +1 -1
  46. package/dist/clients/rosterPolicy.d.ts +1 -1
  47. package/dist/clients/rosterPolicy.d.ts.map +1 -1
  48. package/dist/descriptors/acquire.js +1 -1
  49. package/dist/descriptors/logSource.d.ts +1 -2
  50. package/dist/descriptors/logSource.d.ts.map +1 -1
  51. package/dist/descriptors/logSource.js +2 -2
  52. package/dist/descriptors/logSource.js.map +1 -1
  53. package/dist/enrollment/enrollment.d.ts +1 -1
  54. package/dist/enrollment/enrollment.d.ts.map +1 -1
  55. package/dist/enrollment/enrollment.js +2 -1
  56. package/dist/enrollment/enrollment.js.map +1 -1
  57. package/dist/genesis/accountGenesis.d.ts +13 -1
  58. package/dist/genesis/accountGenesis.d.ts.map +1 -1
  59. package/dist/genesis/accountGenesis.js +1 -1
  60. package/dist/genesis/accountGenesis.js.map +1 -1
  61. package/dist/index.d.ts +1 -3
  62. package/dist/index.d.ts.map +1 -1
  63. package/dist/index.js +1 -3
  64. package/dist/index.js.map +1 -1
  65. package/dist/keyring/kdf.d.ts +6 -20
  66. package/dist/keyring/kdf.d.ts.map +1 -1
  67. package/dist/keyring/kdf.js +8 -5
  68. package/dist/keyring/kdf.js.map +1 -1
  69. package/dist/keyring/unlockSpace.js +1 -1
  70. package/dist/keys/rosterLogStore.d.ts +16 -14
  71. package/dist/keys/rosterLogStore.d.ts.map +1 -1
  72. package/dist/keys/rosterLogStore.js +149 -32
  73. package/dist/keys/rosterLogStore.js.map +1 -1
  74. package/dist/keys/rosterStore.d.ts +8 -7
  75. package/dist/keys/rosterStore.d.ts.map +1 -1
  76. package/dist/keys/rosterStore.js +6 -6
  77. package/dist/keys/rosterStore.js.map +1 -1
  78. package/dist/keys/spaceEpochs.d.ts +1 -1
  79. package/dist/keys/spaceEpochs.js +1 -1
  80. package/dist/keys/userKeyRoster.d.ts +3 -3
  81. package/dist/keys/userKeyRoster.d.ts.map +1 -1
  82. package/dist/keys/userKeyRoster.js +3 -3
  83. package/dist/keys/userKeyRoster.js.map +1 -1
  84. package/dist/recovery/index.d.ts +2 -2
  85. package/dist/recovery/index.js +2 -2
  86. package/dist/recovery/recoveryDelegation.js +1 -1
  87. package/dist/recovery/recoveryDelegation.js.map +1 -1
  88. package/dist/recovery/recoveryWebvh.d.ts +4 -4
  89. package/dist/recovery/recoveryWebvh.js +5 -5
  90. package/dist/request/appKey.d.ts +9 -3
  91. package/dist/request/appKey.d.ts.map +1 -1
  92. package/dist/request/appKey.js +13 -8
  93. package/dist/request/appKey.js.map +1 -1
  94. package/dist/request/classify.d.ts.map +1 -1
  95. package/dist/request/classify.js +13 -1
  96. package/dist/request/classify.js.map +1 -1
  97. package/dist/request/ephemeralExchange.d.ts +6 -1
  98. package/dist/request/ephemeralExchange.d.ts.map +1 -1
  99. package/dist/request/ephemeralExchange.js +6 -1
  100. package/dist/request/ephemeralExchange.js.map +1 -1
  101. package/dist/request/exchangeClient.d.ts +0 -23
  102. package/dist/request/exchangeClient.d.ts.map +1 -1
  103. package/dist/request/exchangeClient.js +30 -1
  104. package/dist/request/exchangeClient.js.map +1 -1
  105. package/dist/request/index.d.ts +4 -1
  106. package/dist/request/index.d.ts.map +1 -1
  107. package/dist/request/index.js +4 -1
  108. package/dist/request/index.js.map +1 -1
  109. package/dist/request/interactionRequest.d.ts +23 -0
  110. package/dist/request/interactionRequest.d.ts.map +1 -0
  111. package/dist/request/interactionRequest.js +46 -0
  112. package/dist/request/interactionRequest.js.map +1 -0
  113. package/dist/request/interactionUrl.d.ts +3 -14
  114. package/dist/request/interactionUrl.d.ts.map +1 -1
  115. package/dist/request/interactionUrl.js +20 -1
  116. package/dist/request/interactionUrl.js.map +1 -1
  117. package/dist/resourceLog/controller.d.ts +48 -49
  118. package/dist/resourceLog/controller.d.ts.map +1 -1
  119. package/dist/resourceLog/controller.js +40 -20
  120. package/dist/resourceLog/controller.js.map +1 -1
  121. package/dist/resourceLog/errors.d.ts +12 -78
  122. package/dist/resourceLog/errors.d.ts.map +1 -1
  123. package/dist/resourceLog/errors.js +12 -79
  124. package/dist/resourceLog/errors.js.map +1 -1
  125. package/dist/resourceLog/index.d.ts +17 -22
  126. package/dist/resourceLog/index.d.ts.map +1 -1
  127. package/dist/resourceLog/index.js +16 -21
  128. package/dist/resourceLog/index.js.map +1 -1
  129. package/dist/resourceLog/license.d.ts +27 -26
  130. package/dist/resourceLog/license.d.ts.map +1 -1
  131. package/dist/resourceLog/license.js +31 -30
  132. package/dist/resourceLog/license.js.map +1 -1
  133. package/dist/unlock/index.d.ts +6 -6
  134. package/dist/unlock/index.d.ts.map +1 -1
  135. package/dist/unlock/index.js +5 -5
  136. package/dist/unlock/retire.d.ts +29 -28
  137. package/dist/unlock/retire.d.ts.map +1 -1
  138. package/dist/unlock/retire.js +25 -16
  139. package/dist/unlock/retire.js.map +1 -1
  140. package/dist/unlock/standingClient.d.ts +1 -1
  141. package/dist/unlock/standingClient.js +3 -3
  142. package/dist/unlock/standingWebvh.d.ts +28 -10
  143. package/dist/unlock/standingWebvh.d.ts.map +1 -1
  144. package/dist/unlock/standingWebvh.js +75 -37
  145. package/dist/unlock/standingWebvh.js.map +1 -1
  146. package/dist/unlock/unlockRecord.js +1 -1
  147. package/dist/webvh/delegatedLogStore.d.ts +2 -2
  148. package/dist/webvh/delegatedLogStore.js +2 -2
  149. package/dist/webvh/didWeb.js +1 -1
  150. package/dist/webvh/didWeb.js.map +1 -1
  151. package/dist/webvh/didWebvh.d.ts +3 -3
  152. package/dist/webvh/didWebvh.d.ts.map +1 -1
  153. package/dist/webvh/didWebvh.js +5 -5
  154. package/dist/webvh/didWebvh.js.map +1 -1
  155. package/dist/webvh/listClients.js +1 -1
  156. package/dist/webvh/listClients.js.map +1 -1
  157. package/dist/webvh/verifyLog.d.ts +1 -1
  158. package/dist/webvh/verifyLog.d.ts.map +1 -1
  159. package/dist/webvh/verifyLog.js +1 -2
  160. package/dist/webvh/verifyLog.js.map +1 -1
  161. package/package.json +6 -10
  162. package/dist/display/alignment.d.ts +0 -55
  163. package/dist/display/alignment.d.ts.map +0 -1
  164. package/dist/display/alignment.js +0 -117
  165. package/dist/display/alignment.js.map +0 -1
  166. package/dist/display/credentialName.d.ts +0 -42
  167. package/dist/display/credentialName.d.ts.map +0 -1
  168. package/dist/display/credentialName.js +0 -106
  169. package/dist/display/credentialName.js.map +0 -1
  170. package/dist/display/displayFields.d.ts +0 -59
  171. package/dist/display/displayFields.d.ts.map +0 -1
  172. package/dist/display/displayFields.js +0 -136
  173. package/dist/display/displayFields.js.map +0 -1
  174. package/dist/display/evidence.d.ts +0 -50
  175. package/dist/display/evidence.d.ts.map +0 -1
  176. package/dist/display/evidence.js +0 -67
  177. package/dist/display/evidence.js.map +0 -1
  178. package/dist/display/image.d.ts +0 -18
  179. package/dist/display/image.d.ts.map +0 -1
  180. package/dist/display/image.js +0 -23
  181. package/dist/display/image.js.map +0 -1
  182. package/dist/display/index.d.ts +0 -38
  183. package/dist/display/index.d.ts.map +0 -1
  184. package/dist/display/index.js +0 -32
  185. package/dist/display/index.js.map +0 -1
  186. package/dist/display/issuer.d.ts +0 -105
  187. package/dist/display/issuer.d.ts.map +0 -1
  188. package/dist/display/issuer.js +0 -126
  189. package/dist/display/issuer.js.map +0 -1
  190. package/dist/display/obv3.d.ts +0 -82
  191. package/dist/display/obv3.d.ts.map +0 -1
  192. package/dist/display/obv3.js +0 -117
  193. package/dist/display/obv3.js.map +0 -1
  194. package/dist/display/parse.d.ts +0 -66
  195. package/dist/display/parse.d.ts.map +0 -1
  196. package/dist/display/parse.js +0 -104
  197. package/dist/display/parse.js.map +0 -1
  198. package/dist/display/subject.d.ts +0 -79
  199. package/dist/display/subject.d.ts.map +0 -1
  200. package/dist/display/subject.js +0 -124
  201. package/dist/display/subject.js.map +0 -1
  202. package/dist/display/text.d.ts +0 -53
  203. package/dist/display/text.d.ts.map +0 -1
  204. package/dist/display/text.js +0 -78
  205. package/dist/display/text.js.map +0 -1
  206. package/dist/display/types.d.ts +0 -55
  207. package/dist/display/types.d.ts.map +0 -1
  208. package/dist/display/types.js +0 -41
  209. package/dist/display/types.js.map +0 -1
  210. package/dist/display/validity.d.ts +0 -51
  211. package/dist/display/validity.d.ts.map +0 -1
  212. package/dist/display/validity.js +0 -51
  213. package/dist/display/validity.js.map +0 -1
  214. package/dist/display/verificationView.d.ts +0 -115
  215. package/dist/display/verificationView.d.ts.map +0 -1
  216. package/dist/display/verificationView.js +0 -199
  217. package/dist/display/verificationView.js.map +0 -1
  218. package/dist/resourceLog/append.d.ts +0 -112
  219. package/dist/resourceLog/append.d.ts.map +0 -1
  220. package/dist/resourceLog/append.js +0 -197
  221. package/dist/resourceLog/append.js.map +0 -1
  222. package/dist/resourceLog/entry.d.ts +0 -68
  223. package/dist/resourceLog/entry.d.ts.map +0 -1
  224. package/dist/resourceLog/entry.js +0 -167
  225. package/dist/resourceLog/entry.js.map +0 -1
  226. package/dist/resourceLog/pin.d.ts +0 -82
  227. package/dist/resourceLog/pin.d.ts.map +0 -1
  228. package/dist/resourceLog/pin.js +0 -57
  229. package/dist/resourceLog/pin.js.map +0 -1
  230. package/dist/resourceLog/seal.d.ts +0 -97
  231. package/dist/resourceLog/seal.d.ts.map +0 -1
  232. package/dist/resourceLog/seal.js +0 -113
  233. package/dist/resourceLog/seal.js.map +0 -1
  234. package/dist/resourceLog/verify.d.ts +0 -96
  235. package/dist/resourceLog/verify.d.ts.map +0 -1
  236. package/dist/resourceLog/verify.js +0 -474
  237. package/dist/resourceLog/verify.js.map +0 -1
  238. package/dist/resourceLog/vmFragment.d.ts +0 -33
  239. package/dist/resourceLog/vmFragment.d.ts.map +0 -1
  240. package/dist/resourceLog/vmFragment.js +0 -39
  241. package/dist/resourceLog/vmFragment.js.map +0 -1
@@ -1,199 +0,0 @@
1
- import { getExpirationInstant } from './validity.js';
2
- import { typeArray } from '@interop/data-integrity-core/guards';
3
- const STEP_ID = {
4
- validSignature: 'valid_signature',
5
- expiration: 'expiration',
6
- revocation: 'revocation_status',
7
- registeredIssuer: 'registered_issuer'
8
- };
9
- const SUPPORTED_CREDENTIAL_TYPES = [
10
- 'VerifiableCredential',
11
- 'OpenBadgeCredential'
12
- ];
13
- function getVerifyLogFromPayload(raw) {
14
- const results = raw.results;
15
- const logFromFirstResult = results?.[0]?.log;
16
- if (Array.isArray(logFromFirstResult)) {
17
- return logFromFirstResult;
18
- }
19
- const topLevelLog = raw.log;
20
- if (Array.isArray(topLevelLog)) {
21
- return topLevelLog;
22
- }
23
- return [];
24
- }
25
- function step(valid, message, severity, error) {
26
- return {
27
- valid,
28
- message,
29
- status: severity,
30
- ...(error ? { error } : {})
31
- };
32
- }
33
- function logValid(entry) {
34
- if (!entry) {
35
- return undefined;
36
- }
37
- return entry.valid === true && !entry.error;
38
- }
39
- function supportedFormatStep(credential, labels) {
40
- const hasKnownType = typeArray(credential.type).some(type => SUPPORTED_CREDENTIAL_TYPES.includes(type));
41
- return step(hasKnownType, hasKnownType ? labels.supportedFormatOk : labels.supportedFormatFail, hasKnownType ? 'positive' : 'negative');
42
- }
43
- function signatureStep(entry, labels) {
44
- const valid = logValid(entry) ?? false;
45
- return step(valid, valid ? labels.signatureOk : labels.signatureFail, valid ? 'positive' : 'negative', entry?.error?.message);
46
- }
47
- function issuerStep(entry, labels) {
48
- const valid = logValid(entry) ?? false;
49
- return step(valid, valid ? labels.issuerOk : labels.issuerFail, valid ? 'positive' : 'warning', entry?.error?.message);
50
- }
51
- function revocationStep(entry, credential, labels) {
52
- if (!credential.credentialStatus && !entry) {
53
- return step(true, labels.revocationOk, 'positive');
54
- }
55
- const valid = logValid(entry) ?? true;
56
- return step(valid, valid ? labels.revocationOk : labels.revocationFail, valid ? 'positive' : 'negative', entry?.error?.message);
57
- }
58
- function expirationStep(entry, credential, labels) {
59
- const exp = getExpirationInstant(credential);
60
- const hasExpirationDate = exp != null;
61
- if (!hasExpirationDate && !entry) {
62
- return step(true, labels.noExpiration, 'positive');
63
- }
64
- if (entry) {
65
- const valid = logValid(entry) ?? false;
66
- return step(valid, valid ? labels.expirationOk : labels.expirationFail, valid ? 'positive' : 'warning', entry.error?.message);
67
- }
68
- const expired = exp.getTime() < Date.now();
69
- return step(!expired, expired ? labels.expirationFail : labels.expirationOk, expired ? 'warning' : 'positive');
70
- }
71
- function withGlobalErr(stepValue, globalErr) {
72
- if (stepValue.valid || !globalErr) {
73
- return stepValue;
74
- }
75
- return { ...stepValue, error: stepValue.error ?? globalErr };
76
- }
77
- function attachLegacyAliases(checklist) {
78
- return {
79
- ...checklist,
80
- expiry: checklist.expiration,
81
- status: checklist.revocation
82
- };
83
- }
84
- /**
85
- * Builds the five-step verification checklist from a raw `verifyCredential`
86
- * payload, the credential, and an injected `labels` map.
87
- *
88
- * @param raw {Record<string, unknown>} the raw verify result
89
- * @param credential {IVerifiableCredential}
90
- * @param labels {Record<ChecklistMsgKey, string>} localized message strings
91
- * @returns {VerificationChecklist}
92
- */
93
- export function buildVerificationChecklist(raw, credential, labels) {
94
- const log = getVerifyLogFromPayload(raw);
95
- const byId = (id) => log.find(line => line.id === id);
96
- const resultsWithError = raw.results;
97
- const globalErr = typeof resultsWithError?.[0]?.error?.message === 'string'
98
- ? resultsWithError[0].error.message
99
- : undefined;
100
- const checklist = {
101
- supportedFormat: supportedFormatStep(credential, labels),
102
- signature: signatureStep(byId(STEP_ID.validSignature), labels),
103
- issuer: issuerStep(byId(STEP_ID.registeredIssuer), labels),
104
- revocation: revocationStep(byId(STEP_ID.revocation), credential, labels),
105
- expiration: expirationStep(byId(STEP_ID.expiration), credential, labels)
106
- };
107
- if (!globalErr) {
108
- return attachLegacyAliases(checklist);
109
- }
110
- return attachLegacyAliases({
111
- supportedFormat: withGlobalErr(checklist.supportedFormat, globalErr),
112
- signature: withGlobalErr(checklist.signature, globalErr),
113
- issuer: withGlobalErr(checklist.issuer, globalErr),
114
- revocation: withGlobalErr(checklist.revocation, globalErr),
115
- expiration: withGlobalErr(checklist.expiration, globalErr)
116
- });
117
- }
118
- /**
119
- * Rolls the checklist up to a single status. Hard failures (bad signature /
120
- * format / revocation) yield `'not_verified'`; a soft issue (unknown issuer or
121
- * expired) yields `'warning'`; otherwise `'verified'`.
122
- *
123
- * @param result {VerificationChecklist | null}
124
- * @returns {VerificationAggregateStatus | null}
125
- */
126
- export function getVerificationAggregateStatus(result) {
127
- if (!result) {
128
- return null;
129
- }
130
- const hasFailure = !result.signature.valid ||
131
- !result.supportedFormat.valid ||
132
- !result.revocation.valid;
133
- const hasWarning = !result.issuer.valid || !result.expiration.valid;
134
- if (hasFailure) {
135
- return 'not_verified';
136
- }
137
- if (hasWarning) {
138
- return 'warning';
139
- }
140
- return 'verified';
141
- }
142
- /**
143
- * Whether every check passed.
144
- *
145
- * @param result {VerificationChecklist | null}
146
- * @returns {boolean}
147
- */
148
- export function isFullyVerified(result) {
149
- return getVerificationAggregateStatus(result) === 'verified';
150
- }
151
- /**
152
- * Whether the only failing check is expiration (everything else passed).
153
- *
154
- * @param result {VerificationChecklist | null}
155
- * @returns {boolean}
156
- */
157
- export function isExpiredOnly(result) {
158
- if (!result) {
159
- return false;
160
- }
161
- return (result.signature.valid &&
162
- result.supportedFormat.valid &&
163
- result.issuer.valid &&
164
- result.revocation.valid &&
165
- !result.expiration.valid);
166
- }
167
- /**
168
- * Whether the aggregate status is a warning.
169
- *
170
- * @param result {VerificationChecklist | null}
171
- * @returns {boolean}
172
- */
173
- export function hasVerificationWarning(result) {
174
- return getVerificationAggregateStatus(result) === 'warning';
175
- }
176
- /**
177
- * Whether verification confirms a registered issuer: the `registered_issuer`
178
- * log entry is valid and (when present) its `matchingIssuers` is non-empty.
179
- * Backs DCW's `shouldDisableUrls` (a one-line app wrapper:
180
- * `!issuerRecognizedByVerification(log)`).
181
- *
182
- * @param log {Array<{ id: string; valid?: boolean; matchingIssuers?: unknown[] }> | undefined}
183
- * @returns {boolean}
184
- */
185
- export function issuerRecognizedByVerification(log) {
186
- if (!Array.isArray(log)) {
187
- return false;
188
- }
189
- return log.some(entry => {
190
- if (entry.id !== 'registered_issuer') {
191
- return false;
192
- }
193
- const { matchingIssuers } = entry;
194
- return entry.valid && Array.isArray(matchingIssuers)
195
- ? matchingIssuers.length > 0
196
- : Boolean(entry.valid);
197
- });
198
- }
199
- //# sourceMappingURL=verificationView.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"verificationView.js","sourceRoot":"","sources":["../../src/display/verificationView.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAA;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAA;AA0D/D,MAAM,OAAO,GAAG;IACd,cAAc,EAAE,iBAAiB;IACjC,UAAU,EAAE,YAAY;IACxB,UAAU,EAAE,mBAAmB;IAC/B,gBAAgB,EAAE,mBAAmB;CAC7B,CAAA;AAEV,MAAM,0BAA0B,GAAG;IACjC,sBAAsB;IACtB,qBAAqB;CACtB,CAAA;AAQD,SAAS,uBAAuB,CAAC,GAA4B;IAC3D,MAAM,OAAO,GAAG,GAAG,CAAC,OAAiD,CAAA;IACrE,MAAM,kBAAkB,GAAG,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,CAAA;IAC5C,IAAI,KAAK,CAAC,OAAO,CAAC,kBAAkB,CAAC,EAAE,CAAC;QACtC,OAAO,kBAAkB,CAA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,SAAS,CAAA;AAC7D,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,8BAA8B,CAC5C,GAAyE;IAEzE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QACxB,OAAO,KAAK,CAAA;IACd,CAAC;IAED,OAAO,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;QACtB,IAAI,KAAK,CAAC,EAAE,KAAK,mBAAmB,EAAE,CAAC;YACrC,OAAO,KAAK,CAAA;QACd,CAAC;QACD,MAAM,EAAE,eAAe,EAAE,GAAG,KAAK,CAAA;QACjC,OAAO,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,eAAe,CAAC;YAClD,CAAC,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC;YAC5B,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;IAC1B,CAAC,CAAC,CAAA;AACJ,CAAC"}
@@ -1,112 +0,0 @@
1
- import { type ResourceLogEntry, type ResourceLogStore } from '@interop/was-client/log';
2
- import type { ResourceLogController } from './controller.js';
3
- import { type ResourceLogSigner } from './entry.js';
4
- import type { ResourceLogPinStore } from './pin.js';
5
- import { type VerifiedResourceLog } from './verify.js';
6
- /**
7
- * Reads and fully verifies a log through the store seam, advancing the
8
- * chain-head pin. Resolves `null` when the log resource does not exist yet
9
- * (the pre-genesis state). The one read entry point every consumer -- a
10
- * login-time roster read, a pre-append verification, a first-contact
11
- * bootstrap -- goes through, so the pin rules cannot be bypassed by reading
12
- * around them.
13
- *
14
- * @param options {object}
15
- * @param options.store {ResourceLogStore} the log's transport seam
16
- * @param options.controller {ResourceLogController} the verified controller
17
- * view
18
- * @param options.expectedMethod {string} the format identifier expected
19
- * (also confirming any `history` dispatch hint the caller followed)
20
- * @param options.pinStore {ResourceLogPinStore} this client's pin for this
21
- * log
22
- * @param options.logId {string} the pin-slot key for this log, from
23
- * `resourceLogPinId`
24
- * @returns {Promise<{ verified: VerifiedResourceLog; etag?: string } | null>}
25
- */
26
- export declare function readResourceLog({ store, controller, expectedMethod, pinStore, logId }: {
27
- store: ResourceLogStore;
28
- controller: ResourceLogController;
29
- expectedMethod: string;
30
- pinStore: ResourceLogPinStore;
31
- logId: string;
32
- }): Promise<{
33
- verified: VerifiedResourceLog;
34
- etag?: string;
35
- } | null>;
36
- /**
37
- * Appends one state change: verify, build against the verified head, CAS,
38
- * rebase-and-retry on conflict, confirm by read-back. `buildState` is the
39
- * rebase hook -- it is called with the current verified log on every attempt
40
- * and returns the full next state built on THAT head's state (or `null` to
41
- * signal the change is already present, making a re-run converge instead of
42
- * duplicating an entry). Refuses a log whose verified head is a terminal
43
- * handover entry ({@link ResourceLogClosedError}).
44
- *
45
- * @param options {object}
46
- * @param options.store {ResourceLogStore}
47
- * @param options.controller {ResourceLogController}
48
- * @param options.expectedMethod {string}
49
- * @param options.pinStore {ResourceLogPinStore}
50
- * @param options.logId {string} the pin-slot key for this log, from
51
- * `resourceLogPinId`
52
- * @param options.signer {ResourceLogSigner}
53
- * @param options.buildState {function} `(verified) => state | null` -- the
54
- * full next state rebased on the verified head, or `null` when the head
55
- * already carries the change
56
- * @param [options.versionTime] {string} RFC3339 UTC; defaults to now
57
- * @param [options.maxAttempts] {number} CAS attempts before giving up
58
- * (default 3)
59
- * @returns {Promise<VerifiedResourceLog>} the read-back, re-verified log
60
- * (whether or not this call appended)
61
- */
62
- export declare function appendResourceLog({ store, controller, expectedMethod, pinStore, logId, signer, buildState, versionTime, maxAttempts }: {
63
- store: ResourceLogStore;
64
- controller: ResourceLogController;
65
- expectedMethod: string;
66
- pinStore: ResourceLogPinStore;
67
- logId: string;
68
- signer: ResourceLogSigner;
69
- buildState: (verified: VerifiedResourceLog) => Promise<ResourceLogEntry['state'] | null> | ResourceLogEntry['state'] | null;
70
- versionTime?: string;
71
- maxAttempts?: number;
72
- }): Promise<VerifiedResourceLog>;
73
- /**
74
- * Creates a log with its genesis entry, guarded create-if-absent, and
75
- * confirms by read-back. Losing the create race to a concurrent provisioner
76
- * adopts the winner's log (the create is CAS, never clobbering): the served
77
- * log is verified and pinned, and the caller reconciles its intended state
78
- * through an ordinary {@link appendResourceLog}. First contact is where the
79
- * pin is established, so the pin store is written either way.
80
- *
81
- * @param options {object}
82
- * @param options.store {ResourceLogStore}
83
- * @param options.controller {ResourceLogController}
84
- * @param options.method {string} the format identifier to declare
85
- * @param options.pinStore {ResourceLogPinStore}
86
- * @param options.logId {string} the pin-slot key for this log, from
87
- * `resourceLogPinId`
88
- * @param options.signer {ResourceLogSigner}
89
- * @param options.state {ResourceLogEntry['state']} the full initial state
90
- * @param [options.previousLog] {object} handover successors only
91
- * @param [options.versionTime] {string} RFC3339 UTC; defaults to now
92
- * @returns {Promise<{ verified: VerifiedResourceLog; created: boolean }>}
93
- * the verified log as it now stands, and whether this call created it
94
- */
95
- export declare function createResourceLog({ store, controller, method, pinStore, logId, signer, state, previousLog, versionTime }: {
96
- store: ResourceLogStore;
97
- controller: ResourceLogController;
98
- method: string;
99
- pinStore: ResourceLogPinStore;
100
- logId: string;
101
- signer: ResourceLogSigner;
102
- state: ResourceLogEntry['state'];
103
- previousLog?: {
104
- scid: string;
105
- head: string;
106
- };
107
- versionTime?: string;
108
- }): Promise<{
109
- verified: VerifiedResourceLog;
110
- created: boolean;
111
- }>;
112
- //# sourceMappingURL=append.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"append.d.ts","sourceRoot":"","sources":["../../src/resourceLog/append.ts"],"names":[],"mappings":"AAeA,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACtB,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAA;AAE5D,OAAO,EAGL,KAAK,iBAAiB,EACvB,MAAM,YAAY,CAAA;AACnB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AACnD,OAAO,EAAqB,KAAK,mBAAmB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,WAAW,EACX,WAAW,EACZ,EAAE;IACD,KAAK,EAAE,gBAAgB,CAAA;IACvB,UAAU,EAAE,qBAAqB,CAAA;IACjC,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,mBAAmB,CAAA;IAC7B,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,iBAAiB,CAAA;IACzB,KAAK,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAA;IAChC,WAAW,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;IAC5C,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,GAAG,OAAO,CAAC;IAAE,QAAQ,EAAE,mBAAmB,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CAmC/D"}
@@ -1,197 +0,0 @@
1
- /*!
2
- * Copyright (c) 2026 Interop Alliance. All rights reserved.
3
- */
4
- /**
5
- * The append path (App Connect spec `#log-append`): read the full log and
6
- * verify it (an entry is never built on an unverified head), build the new
7
- * entry against the verified head anchored at the writer's current verified
8
- * controller head, write compare-and-swapped on the read's validator, and on
9
- * conflict re-read, re-verify, rebase, retry. A write acknowledgement is a
10
- * promise, not a fact: every append is confirmed by reading the log back and
11
- * re-verifying the extended history before the append -- or any ceremony step
12
- * gated on it -- is treated as durable. The chain-head pin advances on every
13
- * successful verification along the way, and only ever forward.
14
- */
15
- import { PreconditionFailedError } from '@interop/was-client';
16
- import { confirmAppend } from '@interop/was-client/log';
17
- import { ResourceLogClosedError } from './errors.js';
18
- import { buildResourceLogEntry, buildResourceLogGenesis } from './entry.js';
19
- import { verifyResourceLog } from './verify.js';
20
- /**
21
- * Reads and fully verifies a log through the store seam, advancing the
22
- * chain-head pin. Resolves `null` when the log resource does not exist yet
23
- * (the pre-genesis state). The one read entry point every consumer -- a
24
- * login-time roster read, a pre-append verification, a first-contact
25
- * bootstrap -- goes through, so the pin rules cannot be bypassed by reading
26
- * around them.
27
- *
28
- * @param options {object}
29
- * @param options.store {ResourceLogStore} the log's transport seam
30
- * @param options.controller {ResourceLogController} the verified controller
31
- * view
32
- * @param options.expectedMethod {string} the format identifier expected
33
- * (also confirming any `history` dispatch hint the caller followed)
34
- * @param options.pinStore {ResourceLogPinStore} this client's pin for this
35
- * log
36
- * @param options.logId {string} the pin-slot key for this log, from
37
- * `resourceLogPinId`
38
- * @returns {Promise<{ verified: VerifiedResourceLog; etag?: string } | null>}
39
- */
40
- export async function readResourceLog({ store, controller, expectedMethod, pinStore, logId }) {
41
- const current = await store.read();
42
- if (current === null) {
43
- return null;
44
- }
45
- const pin = await pinStore.read({ logId });
46
- const verified = await verifyResourceLog({
47
- entries: current.entries,
48
- controller,
49
- expectedMethod,
50
- pin
51
- });
52
- await pinStore.write({ logId, pin: verified.pin });
53
- return { verified, etag: current.etag };
54
- }
55
- /**
56
- * Appends one state change: verify, build against the verified head, CAS,
57
- * rebase-and-retry on conflict, confirm by read-back. `buildState` is the
58
- * rebase hook -- it is called with the current verified log on every attempt
59
- * and returns the full next state built on THAT head's state (or `null` to
60
- * signal the change is already present, making a re-run converge instead of
61
- * duplicating an entry). Refuses a log whose verified head is a terminal
62
- * handover entry ({@link ResourceLogClosedError}).
63
- *
64
- * @param options {object}
65
- * @param options.store {ResourceLogStore}
66
- * @param options.controller {ResourceLogController}
67
- * @param options.expectedMethod {string}
68
- * @param options.pinStore {ResourceLogPinStore}
69
- * @param options.logId {string} the pin-slot key for this log, from
70
- * `resourceLogPinId`
71
- * @param options.signer {ResourceLogSigner}
72
- * @param options.buildState {function} `(verified) => state | null` -- the
73
- * full next state rebased on the verified head, or `null` when the head
74
- * already carries the change
75
- * @param [options.versionTime] {string} RFC3339 UTC; defaults to now
76
- * @param [options.maxAttempts] {number} CAS attempts before giving up
77
- * (default 3)
78
- * @returns {Promise<VerifiedResourceLog>} the read-back, re-verified log
79
- * (whether or not this call appended)
80
- */
81
- export async function appendResourceLog({ store, controller, expectedMethod, pinStore, logId, signer, buildState, versionTime, maxAttempts = 3 }) {
82
- let lastConflict;
83
- for (let attempt = 0; attempt < maxAttempts; attempt++) {
84
- const current = await readResourceLog({
85
- store,
86
- controller,
87
- expectedMethod,
88
- pinStore,
89
- logId
90
- });
91
- if (current === null) {
92
- throw new Error('Cannot append to the resource log: the log does not exist yet ' +
93
- '(create it with its genesis entry first).');
94
- }
95
- const { verified, etag } = current;
96
- if (verified.terminal) {
97
- throw new ResourceLogClosedError({ nextLog: verified.terminal });
98
- }
99
- if (etag === undefined) {
100
- throw new Error('Cannot append to the resource log: the backend returned no ' +
101
- 'validator, and the profile forbids an unconditional write.');
102
- }
103
- const state = await buildState(verified);
104
- if (state === null) {
105
- // The head already carries the change -- a torn earlier run landed it,
106
- // or a concurrent writer did. Converged.
107
- return verified;
108
- }
109
- const entry = await buildResourceLogEntry({
110
- head: verified.head,
111
- state,
112
- controller,
113
- signer,
114
- versionTime
115
- });
116
- try {
117
- await store.append(entry, { ifMatch: etag });
118
- }
119
- catch (err) {
120
- if (err instanceof PreconditionFailedError) {
121
- // A concurrent append won the CAS: re-read, re-verify, rebase, retry.
122
- lastConflict = err;
123
- continue;
124
- }
125
- throw err;
126
- }
127
- const readBack = await confirmAppend({ store, entry });
128
- const confirmed = await verifyResourceLog({
129
- entries: readBack.entries,
130
- controller,
131
- expectedMethod,
132
- pin: await pinStore.read({ logId })
133
- });
134
- await pinStore.write({ logId, pin: confirmed.pin });
135
- return confirmed;
136
- }
137
- throw new Error(`Appending to the resource log lost the compare-and-swap race ` +
138
- `${maxAttempts} times in a row.`, { cause: lastConflict });
139
- }
140
- /**
141
- * Creates a log with its genesis entry, guarded create-if-absent, and
142
- * confirms by read-back. Losing the create race to a concurrent provisioner
143
- * adopts the winner's log (the create is CAS, never clobbering): the served
144
- * log is verified and pinned, and the caller reconciles its intended state
145
- * through an ordinary {@link appendResourceLog}. First contact is where the
146
- * pin is established, so the pin store is written either way.
147
- *
148
- * @param options {object}
149
- * @param options.store {ResourceLogStore}
150
- * @param options.controller {ResourceLogController}
151
- * @param options.method {string} the format identifier to declare
152
- * @param options.pinStore {ResourceLogPinStore}
153
- * @param options.logId {string} the pin-slot key for this log, from
154
- * `resourceLogPinId`
155
- * @param options.signer {ResourceLogSigner}
156
- * @param options.state {ResourceLogEntry['state']} the full initial state
157
- * @param [options.previousLog] {object} handover successors only
158
- * @param [options.versionTime] {string} RFC3339 UTC; defaults to now
159
- * @returns {Promise<{ verified: VerifiedResourceLog; created: boolean }>}
160
- * the verified log as it now stands, and whether this call created it
161
- */
162
- export async function createResourceLog({ store, controller, method, pinStore, logId, signer, state, previousLog, versionTime }) {
163
- const genesis = await buildResourceLogGenesis({
164
- state,
165
- method,
166
- controller,
167
- signer,
168
- previousLog,
169
- versionTime
170
- });
171
- let created = true;
172
- try {
173
- await store.create(genesis);
174
- }
175
- catch (err) {
176
- if (!(err instanceof PreconditionFailedError)) {
177
- throw err;
178
- }
179
- created = false;
180
- }
181
- const current = created
182
- ? await confirmAppend({ store, entry: genesis })
183
- : await store.read();
184
- if (current === null) {
185
- throw new Error('The resource log create lost its guarded-create race, but no log ' +
186
- 'was served on re-read.');
187
- }
188
- const verified = await verifyResourceLog({
189
- entries: current.entries,
190
- controller,
191
- expectedMethod: method,
192
- pin: await pinStore.read({ logId })
193
- });
194
- await pinStore.write({ logId, pin: verified.pin });
195
- return { verified, created };
196
- }
197
- //# sourceMappingURL=append.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"append.js","sourceRoot":"","sources":["../../src/resourceLog/append.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;GAUG;AACH,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAA;AAC7D,OAAO,EACL,aAAa,EAGd,MAAM,yBAAyB,CAAA;AAEhC,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,EACL,qBAAqB,EACrB,uBAAuB,EAExB,MAAM,YAAY,CAAA;AAEnB,OAAO,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AE,OAAO,CAAC,OAAO;QACxB,UAAU;QACV,cAAc,EAAE,MAAM;QACtB,GAAG,EAAE,MAAM,QAAQ,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC;KACpC,CAAC,CAAA;IACF,MAAM,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAA;IAClD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAA;AAC9B,CAAC"}
@@ -1,68 +0,0 @@
1
- import type { ResourceLogEntry } from '@interop/was-client/log';
2
- import type { ResourceLogController } from './controller.js';
3
- /**
4
- * The writer's signing seam: its enrolled Ed25519 signing key's multibase
5
- * (the fragment of its verification method in the controller document) and a
6
- * raw detached-signature hook over it. The multibase names the key in the
7
- * proof's `verificationMethod`; membership under `assertionMethod` at the
8
- * anchored version is what authorizes the append.
9
- */
10
- export interface ResourceLogSigner {
11
- keyMultibase: string;
12
- sign(input: {
13
- data: Uint8Array;
14
- }): Promise<Uint8Array>;
15
- }
16
- /**
17
- * Builds and signs a genesis entry by the profile's two-pass SCID procedure:
18
- * the preliminary entry carries the `{SCID}` placeholder as `versionId` and
19
- * `parameters.scid`, its hash is the SCID, and the final entry substitutes it
20
- * back in before the ordinary entry hash is computed (`versionId` input
21
- * value: the SCID).
22
- *
23
- * @param options {object}
24
- * @param options.state {ResourceLogEntry['state']} the full initial state
25
- * (with its `type`)
26
- * @param options.method {string} the format identifier
27
- * (`RESOURCE_LOG_METHOD`)
28
- * @param options.controller {ResourceLogController} the verified controller
29
- * view -- the anchor source
30
- * @param options.signer {ResourceLogSigner}
31
- * @param [options.previousLog] {object} handover successors only: the prior
32
- * log's SCID and the `versionId` of its terminal entry's predecessor
33
- * @param [options.versionTime] {string} RFC3339 UTC; defaults to now
34
- * @returns {Promise<ResourceLogEntry>}
35
- */
36
- export declare function buildResourceLogGenesis({ state, method, controller, signer, previousLog, versionTime }: {
37
- state: ResourceLogEntry['state'];
38
- method: string;
39
- controller: ResourceLogController;
40
- signer: ResourceLogSigner;
41
- previousLog?: {
42
- scid: string;
43
- head: string;
44
- };
45
- versionTime?: string;
46
- }): Promise<ResourceLogEntry>;
47
- /**
48
- * Builds and signs the next ordinary entry against a verified head: full
49
- * state, empty `parameters`, hash chained off the head's `versionId`, proof
50
- * anchored at the controller's verified head. Callers hold a verified head
51
- * by construction (an entry is never built on an unverified one).
52
- *
53
- * @param options {object}
54
- * @param options.head {ResourceLogEntry} the verified head entry
55
- * @param options.state {ResourceLogEntry['state']} the full next state
56
- * @param options.controller {ResourceLogController}
57
- * @param options.signer {ResourceLogSigner}
58
- * @param [options.versionTime] {string} RFC3339 UTC; defaults to now
59
- * @returns {Promise<ResourceLogEntry>}
60
- */
61
- export declare function buildResourceLogEntry({ head, state, controller, signer, versionTime }: {
62
- head: ResourceLogEntry;
63
- state: ResourceLogEntry['state'];
64
- controller: ResourceLogController;
65
- signer: ResourceLogSigner;
66
- versionTime?: string;
67
- }): Promise<ResourceLogEntry>;
68
- //# sourceMappingURL=entry.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"entry.d.ts","sourceRoot":"","sources":["../../src/resourceLog/entry.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC/D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAA;AAE5D;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC,YAAY,EAAE,MAAM,CAAA;IACpB,IAAI,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,UAAU,CAAA;KAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;CACvD;AAqFD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,uBAAuB,CAAC,EAC5C,KAAK,EACL,MAAM,EACN,UAAU,EACV,MAAM,EACN,WAAW,EACX,WAAW,EACZ,EAAE;IACD,KAAK,EAAE,gBAAg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