@learncard/sss-key-manager 0.2.0 → 0.2.2
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 +13 -0
- package/dist/escrow-attestation.d.ts +2 -5
- package/dist/escrow-attestation.d.ts.map +1 -1
- package/dist/escrow-authority.d.ts +112 -0
- package/dist/escrow-authority.d.ts.map +1 -0
- package/dist/escrow-authority.types.d.ts +51 -0
- package/dist/escrow-authority.types.d.ts.map +1 -0
- package/dist/escrow-crypto.d.ts +9 -1
- package/dist/escrow-crypto.d.ts.map +1 -1
- package/dist/escrow-enrollment-intent.d.ts +13 -0
- package/dist/escrow-enrollment-intent.d.ts.map +1 -0
- package/dist/escrow-enrollment-intent.types.d.ts +28 -0
- package/dist/escrow-enrollment-intent.types.d.ts.map +1 -0
- package/dist/escrow-nitro-attestation.d.ts +34 -0
- package/dist/escrow-nitro-attestation.d.ts.map +1 -0
- package/dist/index.d.ts +11 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/sss-key-manager.cjs.development.js +4478 -424
- package/dist/sss-key-manager.cjs.development.js.map +4 -4
- package/dist/sss-key-manager.cjs.production.min.js +37 -32
- package/dist/sss-key-manager.cjs.production.min.js.map +4 -4
- package/dist/sss-key-manager.esm.js +1813 -265
- package/dist/sss-key-manager.esm.js.map +4 -4
- package/dist/sss-strategy.d.ts.map +1 -1
- package/dist/types.d.ts +31 -5
- package/dist/types.d.ts.map +1 -1
- package/package.json +7 -3
- package/src/__fixtures__/escrow-authority-v1.json +96 -0
- package/src/__fixtures__/escrow-carry-contact-contract-v1.json +33 -0
- package/src/__fixtures__/escrow-enrollment-intent-v1.json +26 -0
- package/src/__fixtures__/escrow-vectors-rust.json +82 -0
- package/src/__fixtures__/escrow-vectors.json +103 -0
- package/src/__fixtures__/nitro-attestation/bad-signature.cbor.b64 +1 -0
- package/src/__fixtures__/nitro-attestation/debug-zero-pcrs.cbor.b64 +1 -0
- package/src/__fixtures__/nitro-attestation/legacy-user-data.cbor.b64 +1 -0
- package/src/__fixtures__/nitro-attestation/manifest.json +60 -0
- package/src/__fixtures__/nitro-attestation/nonce-mismatch.cbor.b64 +1 -0
- package/src/__fixtures__/nitro-attestation/root.pem +12 -0
- package/src/__fixtures__/nitro-attestation/stale-timestamp.cbor.b64 +1 -0
- package/src/__fixtures__/nitro-attestation/tampered-previous-key-ids.cbor.b64 +1 -0
- package/src/__fixtures__/nitro-attestation/truncated-chain.cbor.b64 +1 -0
- package/src/__fixtures__/nitro-attestation/valid.cbor.b64 +1 -0
- package/src/__fixtures__/nitro-attestation/wrong-pcr0.cbor.b64 +1 -0
- package/src/__fixtures__/nitro-attestation/wrong-root.cbor.b64 +1 -0
- package/src/__fixtures__/nitro-attestation-real/staging-nsm-document.json +16 -0
- package/src/escrow-attestation.test.ts +7 -2
- package/src/escrow-attestation.ts +72 -10
- package/src/escrow-authority.test.ts +643 -0
- package/src/escrow-authority.ts +597 -0
- package/src/escrow-authority.types.ts +56 -0
- package/src/escrow-crypto.ts +39 -1
- package/src/escrow-enrollment-intent.test.ts +224 -0
- package/src/escrow-enrollment-intent.ts +236 -0
- package/src/escrow-enrollment-intent.types.ts +28 -0
- package/src/escrow-nitro-attestation.test.ts +276 -0
- package/src/escrow-nitro-attestation.ts +317 -0
- package/src/escrow-vectors.test.ts +198 -0
- package/src/index.ts +35 -1
- package/src/sss-authority.test.ts +889 -0
- package/src/sss-session-writes.test.ts +2 -2
- package/src/sss-strategy.test.ts +95 -2
- package/src/sss-strategy.ts +596 -115
- package/src/types.ts +34 -4
|
@@ -6,7 +6,11 @@ var __getProtoOf = Object.getPrototypeOf;
|
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
8
|
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
-
|
|
9
|
+
try {
|
|
10
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
11
|
+
} catch (e) {
|
|
12
|
+
throw mod = 0, e;
|
|
13
|
+
}
|
|
10
14
|
};
|
|
11
15
|
var __copyProps = (to, from, except, desc) => {
|
|
12
16
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
@@ -73,6 +77,12 @@ var require_types_cjs_development = __commonJS({
|
|
|
73
77
|
AppEventResponseValidator: /* @__PURE__ */ __name(() => AppEventResponseValidator, "AppEventResponseValidator"),
|
|
74
78
|
AppEventValidator: /* @__PURE__ */ __name(() => AppEventValidator, "AppEventValidator"),
|
|
75
79
|
AppListingStatusValidator: /* @__PURE__ */ __name(() => AppListingStatusValidator, "AppListingStatusValidator"),
|
|
80
|
+
AppManifestDiffValidator: /* @__PURE__ */ __name(() => AppManifestDiffValidator, "AppManifestDiffValidator"),
|
|
81
|
+
AppManifestTemplateChangeValidator: /* @__PURE__ */ __name(() => AppManifestTemplateChangeValidator, "AppManifestTemplateChangeValidator"),
|
|
82
|
+
AppManifestTemplateRefValidator: /* @__PURE__ */ __name(() => AppManifestTemplateRefValidator, "AppManifestTemplateRefValidator"),
|
|
83
|
+
AppManifestValidator: /* @__PURE__ */ __name(() => AppManifestValidator, "AppManifestValidator"),
|
|
84
|
+
AppManifestVersionStatusValidator: /* @__PURE__ */ __name(() => AppManifestVersionStatusValidator, "AppManifestVersionStatusValidator"),
|
|
85
|
+
AppManifestVersionValidator: /* @__PURE__ */ __name(() => AppManifestVersionValidator, "AppManifestVersionValidator"),
|
|
76
86
|
AppStoreListingCreateValidator: /* @__PURE__ */ __name(() => AppStoreListingCreateValidator, "AppStoreListingCreateValidator"),
|
|
77
87
|
AppStoreListingSubmitterValidator: /* @__PURE__ */ __name(() => AppStoreListingSubmitterValidator, "AppStoreListingSubmitterValidator"),
|
|
78
88
|
AppStoreListingUpdateValidator: /* @__PURE__ */ __name(() => AppStoreListingUpdateValidator, "AppStoreListingUpdateValidator"),
|
|
@@ -94,6 +104,8 @@ var require_types_cjs_development = __commonJS({
|
|
|
94
104
|
BoostRecipientValidator: /* @__PURE__ */ __name(() => BoostRecipientValidator, "BoostRecipientValidator"),
|
|
95
105
|
BoostRecipientWithChildrenValidator: /* @__PURE__ */ __name(() => BoostRecipientWithChildrenValidator, "BoostRecipientWithChildrenValidator"),
|
|
96
106
|
BoostValidator: /* @__PURE__ */ __name(() => BoostValidator, "BoostValidator"),
|
|
107
|
+
CapturedConsentRecordValidator: /* @__PURE__ */ __name(() => CapturedConsentRecordValidator, "CapturedConsentRecordValidator"),
|
|
108
|
+
CapturedTemplateRecordValidator: /* @__PURE__ */ __name(() => CapturedTemplateRecordValidator, "CapturedTemplateRecordValidator"),
|
|
97
109
|
CheckCredentialEventValidator: /* @__PURE__ */ __name(() => CheckCredentialEventValidator, "CheckCredentialEventValidator"),
|
|
98
110
|
CheckIssuanceStatusEventValidator: /* @__PURE__ */ __name(() => CheckIssuanceStatusEventValidator, "CheckIssuanceStatusEventValidator"),
|
|
99
111
|
ClaimHookQueryValidator: /* @__PURE__ */ __name(() => ClaimHookQueryValidator, "ClaimHookQueryValidator"),
|
|
@@ -115,6 +127,7 @@ var require_types_cjs_development = __commonJS({
|
|
|
115
127
|
ConsentFlowDataForDidQueryValidator: /* @__PURE__ */ __name(() => ConsentFlowDataForDidQueryValidator, "ConsentFlowDataForDidQueryValidator"),
|
|
116
128
|
ConsentFlowDataQueryValidator: /* @__PURE__ */ __name(() => ConsentFlowDataQueryValidator, "ConsentFlowDataQueryValidator"),
|
|
117
129
|
ConsentFlowGuardianApprovalValidator: /* @__PURE__ */ __name(() => ConsentFlowGuardianApprovalValidator, "ConsentFlowGuardianApprovalValidator"),
|
|
130
|
+
ConsentFlowReferralValidator: /* @__PURE__ */ __name(() => ConsentFlowReferralValidator, "ConsentFlowReferralValidator"),
|
|
118
131
|
ConsentFlowTermValidator: /* @__PURE__ */ __name(() => ConsentFlowTermValidator, "ConsentFlowTermValidator"),
|
|
119
132
|
ConsentFlowTermsQueryValidator: /* @__PURE__ */ __name(() => ConsentFlowTermsQueryValidator, "ConsentFlowTermsQueryValidator"),
|
|
120
133
|
ConsentFlowTermsStatusValidator: /* @__PURE__ */ __name(() => ConsentFlowTermsStatusValidator, "ConsentFlowTermsStatusValidator"),
|
|
@@ -122,6 +135,10 @@ var require_types_cjs_development = __commonJS({
|
|
|
122
135
|
ConsentFlowTransactionActionValidator: /* @__PURE__ */ __name(() => ConsentFlowTransactionActionValidator, "ConsentFlowTransactionActionValidator"),
|
|
123
136
|
ConsentFlowTransactionValidator: /* @__PURE__ */ __name(() => ConsentFlowTransactionValidator, "ConsentFlowTransactionValidator"),
|
|
124
137
|
ConsentFlowTransactionsQueryValidator: /* @__PURE__ */ __name(() => ConsentFlowTransactionsQueryValidator, "ConsentFlowTransactionsQueryValidator"),
|
|
138
|
+
ConsentFlowWebhookMetadataValidator: /* @__PURE__ */ __name(() => ConsentFlowWebhookMetadataValidator, "ConsentFlowWebhookMetadataValidator"),
|
|
139
|
+
ConsentRequestPersonalFieldValidator: /* @__PURE__ */ __name(() => ConsentRequestPersonalFieldValidator, "ConsentRequestPersonalFieldValidator"),
|
|
140
|
+
ConsentRequestValidator: /* @__PURE__ */ __name(() => ConsentRequestValidator, "ConsentRequestValidator"),
|
|
141
|
+
ConsentRequestWalletCategoryValidator: /* @__PURE__ */ __name(() => ConsentRequestWalletCategoryValidator, "ConsentRequestWalletCategoryValidator"),
|
|
125
142
|
ContactMethodCreateValidator: /* @__PURE__ */ __name(() => ContactMethodCreateValidator, "ContactMethodCreateValidator"),
|
|
126
143
|
ContactMethodQueryValidator: /* @__PURE__ */ __name(() => ContactMethodQueryValidator, "ContactMethodQueryValidator"),
|
|
127
144
|
ContactMethodValidator: /* @__PURE__ */ __name(() => ContactMethodValidator, "ContactMethodValidator"),
|
|
@@ -129,6 +146,7 @@ var require_types_cjs_development = __commonJS({
|
|
|
129
146
|
ContactMethodVerificationValidator: /* @__PURE__ */ __name(() => ContactMethodVerificationValidator, "ContactMethodVerificationValidator"),
|
|
130
147
|
ContextValidator: /* @__PURE__ */ __name(() => ContextValidator, "ContextValidator"),
|
|
131
148
|
ContractCredentialValidator: /* @__PURE__ */ __name(() => ContractCredentialValidator, "ContractCredentialValidator"),
|
|
149
|
+
ContractRequestFieldsValidator: /* @__PURE__ */ __name(() => ContractRequestFieldsValidator, "ContractRequestFieldsValidator"),
|
|
132
150
|
CountSkillsInputValidator: /* @__PURE__ */ __name(() => CountSkillsInputValidator, "CountSkillsInputValidator"),
|
|
133
151
|
CountSkillsResultValidator: /* @__PURE__ */ __name(() => CountSkillsResultValidator, "CountSkillsResultValidator"),
|
|
134
152
|
CreateContactMethodSessionResponseValidator: /* @__PURE__ */ __name(() => CreateContactMethodSessionResponseValidator, "CreateContactMethodSessionResponseValidator"),
|
|
@@ -164,6 +182,8 @@ var require_types_cjs_development = __commonJS({
|
|
|
164
182
|
CriteriaValidator: /* @__PURE__ */ __name(() => CriteriaValidator, "CriteriaValidator"),
|
|
165
183
|
DEFAULT_BITSTRING_STATUS_LIST_SIZE: /* @__PURE__ */ __name(() => DEFAULT_BITSTRING_STATUS_LIST_SIZE, "DEFAULT_BITSTRING_STATUS_LIST_SIZE"),
|
|
166
184
|
DeleteFrameworkInputValidator: /* @__PURE__ */ __name(() => DeleteFrameworkInputValidator, "DeleteFrameworkInputValidator"),
|
|
185
|
+
DeleteShareLinkAttachmentChunksInputValidator: /* @__PURE__ */ __name(() => DeleteShareLinkAttachmentChunksInputValidator, "DeleteShareLinkAttachmentChunksInputValidator"),
|
|
186
|
+
DeleteShareLinkAttachmentChunksOutputValidator: /* @__PURE__ */ __name(() => DeleteShareLinkAttachmentChunksOutputValidator, "DeleteShareLinkAttachmentChunksOutputValidator"),
|
|
167
187
|
DeleteSkillInputValidator: /* @__PURE__ */ __name(() => DeleteSkillInputValidator, "DeleteSkillInputValidator"),
|
|
168
188
|
DidDocumentValidator: /* @__PURE__ */ __name(() => DidDocumentValidator, "DidDocumentValidator"),
|
|
169
189
|
EMPTY_IN_APP_MESSAGES_FLAG: /* @__PURE__ */ __name(() => EMPTY_IN_APP_MESSAGES_FLAG, "EMPTY_IN_APP_MESSAGES_FLAG"),
|
|
@@ -186,6 +206,7 @@ var require_types_cjs_development = __commonJS({
|
|
|
186
206
|
GetCredentialRefreshHistoryResultValidator: /* @__PURE__ */ __name(() => GetCredentialRefreshHistoryResultValidator, "GetCredentialRefreshHistoryResultValidator"),
|
|
187
207
|
GetFullSkillTreeInputValidator: /* @__PURE__ */ __name(() => GetFullSkillTreeInputValidator, "GetFullSkillTreeInputValidator"),
|
|
188
208
|
GetFullSkillTreeResultValidator: /* @__PURE__ */ __name(() => GetFullSkillTreeResultValidator, "GetFullSkillTreeResultValidator"),
|
|
209
|
+
GetShareLinkAttachmentChunkInputValidator: /* @__PURE__ */ __name(() => GetShareLinkAttachmentChunkInputValidator, "GetShareLinkAttachmentChunkInputValidator"),
|
|
189
210
|
GetSkillPathInputValidator: /* @__PURE__ */ __name(() => GetSkillPathInputValidator, "GetSkillPathInputValidator"),
|
|
190
211
|
GetSkillPathResultValidator: /* @__PURE__ */ __name(() => GetSkillPathResultValidator, "GetSkillPathResultValidator"),
|
|
191
212
|
GetTemplateRecipientsEventValidator: /* @__PURE__ */ __name(() => GetTemplateRecipientsEventValidator, "GetTemplateRecipientsEventValidator"),
|
|
@@ -203,6 +224,12 @@ var require_types_cjs_development = __commonJS({
|
|
|
203
224
|
InboxCredentialRefreshReceiptValidator: /* @__PURE__ */ __name(() => InboxCredentialRefreshReceiptValidator, "InboxCredentialRefreshReceiptValidator"),
|
|
204
225
|
InboxCredentialValidator: /* @__PURE__ */ __name(() => InboxCredentialValidator, "InboxCredentialValidator"),
|
|
205
226
|
IncrementCounterEventValidator: /* @__PURE__ */ __name(() => IncrementCounterEventValidator, "IncrementCounterEventValidator"),
|
|
227
|
+
InlineAlignmentValidator: /* @__PURE__ */ __name(() => InlineAlignmentValidator, "InlineAlignmentValidator"),
|
|
228
|
+
InlineCredentialTemplateValidator: /* @__PURE__ */ __name(() => InlineCredentialTemplateValidator, "InlineCredentialTemplateValidator"),
|
|
229
|
+
InlineEvidenceValidator: /* @__PURE__ */ __name(() => InlineEvidenceValidator, "InlineEvidenceValidator"),
|
|
230
|
+
InlineSendCredentialEventValidator: /* @__PURE__ */ __name(() => InlineSendCredentialEventValidator, "InlineSendCredentialEventValidator"),
|
|
231
|
+
InlineWalletCategoryValidator: /* @__PURE__ */ __name(() => InlineWalletCategoryValidator, "InlineWalletCategoryValidator"),
|
|
232
|
+
InlineWalletSkillTagValidator: /* @__PURE__ */ __name(() => InlineWalletSkillTagValidator, "InlineWalletSkillTagValidator"),
|
|
206
233
|
InstalledAppValidator: /* @__PURE__ */ __name(() => InstalledAppValidator, "InstalledAppValidator"),
|
|
207
234
|
IssueInboxCredentialBatchItemResultValidator: /* @__PURE__ */ __name(() => IssueInboxCredentialBatchItemResultValidator, "IssueInboxCredentialBatchItemResultValidator"),
|
|
208
235
|
IssueInboxCredentialBatchItemValidator: /* @__PURE__ */ __name(() => IssueInboxCredentialBatchItemValidator, "IssueInboxCredentialBatchItemValidator"),
|
|
@@ -255,6 +282,7 @@ var require_types_cjs_development = __commonJS({
|
|
|
255
282
|
LCNVisibleProfileValidator: /* @__PURE__ */ __name(() => LCNVisibleProfileValidator, "LCNVisibleProfileValidator"),
|
|
256
283
|
LaunchTypeValidator: /* @__PURE__ */ __name(() => LaunchTypeValidator, "LaunchTypeValidator"),
|
|
257
284
|
LearnCardRefreshAuthorizationValidator: /* @__PURE__ */ __name(() => LearnCardRefreshAuthorizationValidator, "LearnCardRefreshAuthorizationValidator"),
|
|
285
|
+
LegacySendCredentialEventValidator: /* @__PURE__ */ __name(() => LegacySendCredentialEventValidator, "LegacySendCredentialEventValidator"),
|
|
258
286
|
LinkProviderFrameworkInputValidator: /* @__PURE__ */ __name(() => LinkProviderFrameworkInputValidator, "LinkProviderFrameworkInputValidator"),
|
|
259
287
|
ListShareLinksInputValidator: /* @__PURE__ */ __name(() => ListShareLinksInputValidator, "ListShareLinksInputValidator"),
|
|
260
288
|
MAX_ENDORSEMENTS: /* @__PURE__ */ __name(() => MAX_ENDORSEMENTS, "MAX_ENDORSEMENTS"),
|
|
@@ -266,6 +294,7 @@ var require_types_cjs_development = __commonJS({
|
|
|
266
294
|
MAX_VP_MEMBERS: /* @__PURE__ */ __name(() => MAX_VP_MEMBERS, "MAX_VP_MEMBERS"),
|
|
267
295
|
ManagedCredentialRefreshReceiptValidator: /* @__PURE__ */ __name(() => ManagedCredentialRefreshReceiptValidator, "ManagedCredentialRefreshReceiptValidator"),
|
|
268
296
|
ManagedCredentialRefreshServiceValidator: /* @__PURE__ */ __name(() => ManagedCredentialRefreshServiceValidator, "ManagedCredentialRefreshServiceValidator"),
|
|
297
|
+
NormalizedConsentScopesValidator: /* @__PURE__ */ __name(() => NormalizedConsentScopesValidator, "NormalizedConsentScopesValidator"),
|
|
269
298
|
PaginatedAppStoreListingsValidator: /* @__PURE__ */ __name(() => PaginatedAppStoreListingsValidator, "PaginatedAppStoreListingsValidator"),
|
|
270
299
|
PaginatedBoostRecipientsValidator: /* @__PURE__ */ __name(() => PaginatedBoostRecipientsValidator, "PaginatedBoostRecipientsValidator"),
|
|
271
300
|
PaginatedBoostRecipientsWithChildrenValidator: /* @__PURE__ */ __name(() => PaginatedBoostRecipientsWithChildrenValidator, "PaginatedBoostRecipientsWithChildrenValidator"),
|
|
@@ -292,6 +321,8 @@ var require_types_cjs_development = __commonJS({
|
|
|
292
321
|
PaginatedVisibleLCNProfilesValidator: /* @__PURE__ */ __name(() => PaginatedVisibleLCNProfilesValidator, "PaginatedVisibleLCNProfilesValidator"),
|
|
293
322
|
PaginationOptionsValidator: /* @__PURE__ */ __name(() => PaginationOptionsValidator, "PaginationOptionsValidator"),
|
|
294
323
|
PaginationResponseValidator: /* @__PURE__ */ __name(() => PaginationResponseValidator, "PaginationResponseValidator"),
|
|
324
|
+
PendingListingUpdateStatusValidator: /* @__PURE__ */ __name(() => PendingListingUpdateStatusValidator, "PendingListingUpdateStatusValidator"),
|
|
325
|
+
PendingListingUpdateValidator: /* @__PURE__ */ __name(() => PendingListingUpdateValidator, "PendingListingUpdateValidator"),
|
|
295
326
|
PrepareRefreshableSendInputValidator: /* @__PURE__ */ __name(() => PrepareRefreshableSendInputValidator, "PrepareRefreshableSendInputValidator"),
|
|
296
327
|
PrepareRefreshableSendResultValidator: /* @__PURE__ */ __name(() => PrepareRefreshableSendResultValidator, "PrepareRefreshableSendResultValidator"),
|
|
297
328
|
ProfileValidator: /* @__PURE__ */ __name(() => ProfileValidator, "ProfileValidator"),
|
|
@@ -304,6 +335,9 @@ var require_types_cjs_development = __commonJS({
|
|
|
304
335
|
PublishCredentialRefreshResultValidator: /* @__PURE__ */ __name(() => PublishCredentialRefreshResultValidator, "PublishCredentialRefreshResultValidator"),
|
|
305
336
|
PublishIssuerSignedRefreshValidator: /* @__PURE__ */ __name(() => PublishIssuerSignedRefreshValidator, "PublishIssuerSignedRefreshValidator"),
|
|
306
337
|
PublishSigningAuthorityRefreshValidator: /* @__PURE__ */ __name(() => PublishSigningAuthorityRefreshValidator, "PublishSigningAuthorityRefreshValidator"),
|
|
338
|
+
PutShareLinkAttachmentChunkInputValidator: /* @__PURE__ */ __name(() => PutShareLinkAttachmentChunkInputValidator, "PutShareLinkAttachmentChunkInputValidator"),
|
|
339
|
+
PutShareLinkAttachmentChunkOutputValidator: /* @__PURE__ */ __name(() => PutShareLinkAttachmentChunkOutputValidator, "PutShareLinkAttachmentChunkOutputValidator"),
|
|
340
|
+
RawInlineCredentialTemplateValidator: /* @__PURE__ */ __name(() => RawInlineCredentialTemplateValidator, "RawInlineCredentialTemplateValidator"),
|
|
307
341
|
RefreshServiceValidator: /* @__PURE__ */ __name(() => RefreshServiceValidator, "RefreshServiceValidator"),
|
|
308
342
|
RegExpValidator: /* @__PURE__ */ __name(() => RegExpValidator, "RegExpValidator"),
|
|
309
343
|
RelatedValidator: /* @__PURE__ */ __name(() => RelatedValidator, "RelatedValidator"),
|
|
@@ -330,6 +364,7 @@ var require_types_cjs_development = __commonJS({
|
|
|
330
364
|
SendBoostResponseValidator: /* @__PURE__ */ __name(() => SendBoostResponseValidator, "SendBoostResponseValidator"),
|
|
331
365
|
SendBoostTemplateValidator: /* @__PURE__ */ __name(() => SendBoostTemplateValidator, "SendBoostTemplateValidator"),
|
|
332
366
|
SendBrandingOptionsValidator: /* @__PURE__ */ __name(() => SendBrandingOptionsValidator, "SendBrandingOptionsValidator"),
|
|
367
|
+
SendContractRequestValidator: /* @__PURE__ */ __name(() => SendContractRequestValidator, "SendContractRequestValidator"),
|
|
333
368
|
SendCredentialEventValidator: /* @__PURE__ */ __name(() => SendCredentialEventValidator, "SendCredentialEventValidator"),
|
|
334
369
|
SendInboxResponseValidator: /* @__PURE__ */ __name(() => SendInboxResponseValidator, "SendInboxResponseValidator"),
|
|
335
370
|
SendInputValidator: /* @__PURE__ */ __name(() => SendInputValidator, "SendInputValidator"),
|
|
@@ -345,6 +380,9 @@ var require_types_cjs_development = __commonJS({
|
|
|
345
380
|
ShareEndorsementEntryValidator: /* @__PURE__ */ __name(() => ShareEndorsementEntryValidator, "ShareEndorsementEntryValidator"),
|
|
346
381
|
ShareEnvelopeValidator: /* @__PURE__ */ __name(() => ShareEnvelopeValidator, "ShareEnvelopeValidator"),
|
|
347
382
|
ShareIvValidator: /* @__PURE__ */ __name(() => ShareIvValidator, "ShareIvValidator"),
|
|
383
|
+
ShareLinkAttachmentChunkEnvelopeValidator: /* @__PURE__ */ __name(() => ShareLinkAttachmentChunkEnvelopeValidator, "ShareLinkAttachmentChunkEnvelopeValidator"),
|
|
384
|
+
ShareLinkAttachmentChunkOutputValidator: /* @__PURE__ */ __name(() => ShareLinkAttachmentChunkOutputValidator, "ShareLinkAttachmentChunkOutputValidator"),
|
|
385
|
+
ShareLinkAttachmentValidator: /* @__PURE__ */ __name(() => ShareLinkAttachmentValidator, "ShareLinkAttachmentValidator"),
|
|
348
386
|
ShareLinkIdInputValidator: /* @__PURE__ */ __name(() => ShareLinkIdInputValidator, "ShareLinkIdInputValidator"),
|
|
349
387
|
ShareLinkIdValidator: /* @__PURE__ */ __name(() => ShareLinkIdValidator, "ShareLinkIdValidator"),
|
|
350
388
|
ShareLinkOperationKeyInputValidator: /* @__PURE__ */ __name(() => ShareLinkOperationKeyInputValidator, "ShareLinkOperationKeyInputValidator"),
|
|
@@ -365,6 +403,7 @@ var require_types_cjs_development = __commonJS({
|
|
|
365
403
|
ShareRecoverySelectionValidator: /* @__PURE__ */ __name(() => ShareRecoverySelectionValidator, "ShareRecoverySelectionValidator"),
|
|
366
404
|
ShareSelectionEntryValidator: /* @__PURE__ */ __name(() => ShareSelectionEntryValidator, "ShareSelectionEntryValidator"),
|
|
367
405
|
ShareSharerValidator: /* @__PURE__ */ __name(() => ShareSharerValidator, "ShareSharerValidator"),
|
|
406
|
+
SimpleInlineCredentialTemplateValidator: /* @__PURE__ */ __name(() => SimpleInlineCredentialTemplateValidator, "SimpleInlineCredentialTemplateValidator"),
|
|
368
407
|
SkillDeletionStrategyValidator: /* @__PURE__ */ __name(() => SkillDeletionStrategyValidator, "SkillDeletionStrategyValidator"),
|
|
369
408
|
SkillFrameworkAdminInputValidator: /* @__PURE__ */ __name(() => SkillFrameworkAdminInputValidator, "SkillFrameworkAdminInputValidator"),
|
|
370
409
|
SkillFrameworkAdminsValidator: /* @__PURE__ */ __name(() => SkillFrameworkAdminsValidator, "SkillFrameworkAdminsValidator"),
|
|
@@ -395,9 +434,12 @@ var require_types_cjs_development = __commonJS({
|
|
|
395
434
|
UnsignedClrCredentialValidator: /* @__PURE__ */ __name(() => UnsignedClrCredentialValidator, "UnsignedClrCredentialValidator"),
|
|
396
435
|
UnsignedVCValidator: /* @__PURE__ */ __name(() => UnsignedVCValidator, "UnsignedVCValidator"),
|
|
397
436
|
UnsignedVPValidator: /* @__PURE__ */ __name(() => UnsignedVPValidator, "UnsignedVPValidator"),
|
|
437
|
+
UnsupportedSignInOperationError: /* @__PURE__ */ __name(() => UnsupportedSignInOperationError, "UnsupportedSignInOperationError"),
|
|
398
438
|
UpdateFrameworkInputValidator: /* @__PURE__ */ __name(() => UpdateFrameworkInputValidator, "UpdateFrameworkInputValidator"),
|
|
399
439
|
UpdateShareLinkInputValidator: /* @__PURE__ */ __name(() => UpdateShareLinkInputValidator, "UpdateShareLinkInputValidator"),
|
|
400
440
|
UpdateSkillInputValidator: /* @__PURE__ */ __name(() => UpdateSkillInputValidator, "UpdateSkillInputValidator"),
|
|
441
|
+
UpsertConsentContractEventValidator: /* @__PURE__ */ __name(() => UpsertConsentContractEventValidator, "UpsertConsentContractEventValidator"),
|
|
442
|
+
UpsertConsentContractResponseValidator: /* @__PURE__ */ __name(() => UpsertConsentContractResponseValidator, "UpsertConsentContractResponseValidator"),
|
|
401
443
|
VC2EvidenceValidator: /* @__PURE__ */ __name(() => VC2EvidenceValidator, "VC2EvidenceValidator"),
|
|
402
444
|
VCValidator: /* @__PURE__ */ __name(() => VCValidator, "VCValidator"),
|
|
403
445
|
VPValidator: /* @__PURE__ */ __name(() => VPValidator, "VPValidator"),
|
|
@@ -526,7 +568,7 @@ var require_types_cjs_development = __commonJS({
|
|
|
526
568
|
_function: /* @__PURE__ */ __name(() => _function, "_function"),
|
|
527
569
|
any: /* @__PURE__ */ __name(() => any, "any"),
|
|
528
570
|
array: /* @__PURE__ */ __name(() => array, "array"),
|
|
529
|
-
base64: /* @__PURE__ */ __name(() =>
|
|
571
|
+
base64: /* @__PURE__ */ __name(() => base6422, "base64"),
|
|
530
572
|
base64url: /* @__PURE__ */ __name(() => base64url2, "base64url"),
|
|
531
573
|
bigint: /* @__PURE__ */ __name(() => bigint2, "bigint"),
|
|
532
574
|
boolean: /* @__PURE__ */ __name(() => boolean2, "boolean"),
|
|
@@ -543,14 +585,14 @@ var require_types_cjs_development = __commonJS({
|
|
|
543
585
|
cuid2: /* @__PURE__ */ __name(() => cuid22, "cuid2"),
|
|
544
586
|
custom: /* @__PURE__ */ __name(() => custom, "custom"),
|
|
545
587
|
date: /* @__PURE__ */ __name(() => date3, "date"),
|
|
546
|
-
decode: /* @__PURE__ */ __name(() =>
|
|
588
|
+
decode: /* @__PURE__ */ __name(() => decode22, "decode"),
|
|
547
589
|
decodeAsync: /* @__PURE__ */ __name(() => decodeAsync2, "decodeAsync"),
|
|
548
590
|
describe: /* @__PURE__ */ __name(() => describe2, "describe"),
|
|
549
591
|
discriminatedUnion: /* @__PURE__ */ __name(() => discriminatedUnion, "discriminatedUnion"),
|
|
550
592
|
e164: /* @__PURE__ */ __name(() => e1642, "e164"),
|
|
551
593
|
email: /* @__PURE__ */ __name(() => email2, "email"),
|
|
552
594
|
emoji: /* @__PURE__ */ __name(() => emoji2, "emoji"),
|
|
553
|
-
encode: /* @__PURE__ */ __name(() =>
|
|
595
|
+
encode: /* @__PURE__ */ __name(() => encode22, "encode"),
|
|
554
596
|
encodeAsync: /* @__PURE__ */ __name(() => encodeAsync2, "encodeAsync"),
|
|
555
597
|
endsWith: /* @__PURE__ */ __name(() => _endsWith, "endsWith"),
|
|
556
598
|
enum: /* @__PURE__ */ __name(() => _enum2, "enum"),
|
|
@@ -567,8 +609,8 @@ var require_types_cjs_development = __commonJS({
|
|
|
567
609
|
gt: /* @__PURE__ */ __name(() => _gt, "gt"),
|
|
568
610
|
gte: /* @__PURE__ */ __name(() => _gte, "gte"),
|
|
569
611
|
guid: /* @__PURE__ */ __name(() => guid2, "guid"),
|
|
570
|
-
hash: /* @__PURE__ */ __name(() =>
|
|
571
|
-
hex: /* @__PURE__ */ __name(() =>
|
|
612
|
+
hash: /* @__PURE__ */ __name(() => hash2, "hash"),
|
|
613
|
+
hex: /* @__PURE__ */ __name(() => hex22, "hex"),
|
|
572
614
|
hostname: /* @__PURE__ */ __name(() => hostname2, "hostname"),
|
|
573
615
|
httpUrl: /* @__PURE__ */ __name(() => httpUrl, "httpUrl"),
|
|
574
616
|
includes: /* @__PURE__ */ __name(() => _includes, "includes"),
|
|
@@ -595,7 +637,7 @@ var require_types_cjs_development = __commonJS({
|
|
|
595
637
|
lt: /* @__PURE__ */ __name(() => _lt, "lt"),
|
|
596
638
|
lte: /* @__PURE__ */ __name(() => _lte, "lte"),
|
|
597
639
|
mac: /* @__PURE__ */ __name(() => mac2, "mac"),
|
|
598
|
-
map: /* @__PURE__ */ __name(() =>
|
|
640
|
+
map: /* @__PURE__ */ __name(() => map2, "map"),
|
|
599
641
|
maxLength: /* @__PURE__ */ __name(() => _maxLength, "maxLength"),
|
|
600
642
|
maxSize: /* @__PURE__ */ __name(() => _maxSize, "maxSize"),
|
|
601
643
|
meta: /* @__PURE__ */ __name(() => meta2, "meta"),
|
|
@@ -616,7 +658,7 @@ var require_types_cjs_development = __commonJS({
|
|
|
616
658
|
nullable: /* @__PURE__ */ __name(() => nullable, "nullable"),
|
|
617
659
|
nullish: /* @__PURE__ */ __name(() => nullish2, "nullish"),
|
|
618
660
|
number: /* @__PURE__ */ __name(() => number2, "number"),
|
|
619
|
-
object: /* @__PURE__ */ __name(() =>
|
|
661
|
+
object: /* @__PURE__ */ __name(() => object2, "object"),
|
|
620
662
|
optional: /* @__PURE__ */ __name(() => optional, "optional"),
|
|
621
663
|
overwrite: /* @__PURE__ */ __name(() => _overwrite, "overwrite"),
|
|
622
664
|
parse: /* @__PURE__ */ __name(() => parse2, "parse"),
|
|
@@ -920,10 +962,10 @@ var require_types_cjs_development = __commonJS({
|
|
|
920
962
|
config: /* @__PURE__ */ __name(() => config, "config"),
|
|
921
963
|
createStandardJSONSchemaMethod: /* @__PURE__ */ __name(() => createStandardJSONSchemaMethod, "createStandardJSONSchemaMethod"),
|
|
922
964
|
createToJSONSchemaMethod: /* @__PURE__ */ __name(() => createToJSONSchemaMethod, "createToJSONSchemaMethod"),
|
|
923
|
-
decode: /* @__PURE__ */ __name(() =>
|
|
965
|
+
decode: /* @__PURE__ */ __name(() => decode2, "decode"),
|
|
924
966
|
decodeAsync: /* @__PURE__ */ __name(() => decodeAsync, "decodeAsync"),
|
|
925
967
|
describe: /* @__PURE__ */ __name(() => describe, "describe"),
|
|
926
|
-
encode: /* @__PURE__ */ __name(() =>
|
|
968
|
+
encode: /* @__PURE__ */ __name(() => encode2, "encode"),
|
|
927
969
|
encodeAsync: /* @__PURE__ */ __name(() => encodeAsync, "encodeAsync"),
|
|
928
970
|
extractDefs: /* @__PURE__ */ __name(() => extractDefs, "extractDefs"),
|
|
929
971
|
finalize: /* @__PURE__ */ __name(() => finalize, "finalize"),
|
|
@@ -978,9 +1020,9 @@ var require_types_cjs_development = __commonJS({
|
|
|
978
1020
|
inst._zod.traits.add(name);
|
|
979
1021
|
initializer3(inst, def);
|
|
980
1022
|
const proto = _.prototype;
|
|
981
|
-
const
|
|
982
|
-
for (let i = 0; i <
|
|
983
|
-
const k =
|
|
1023
|
+
const keys2 = Object.keys(proto);
|
|
1024
|
+
for (let i = 0; i < keys2.length; i++) {
|
|
1025
|
+
const k = keys2[i];
|
|
984
1026
|
if (!(k in inst)) {
|
|
985
1027
|
inst[k] = proto[k].bind(inst);
|
|
986
1028
|
}
|
|
@@ -1202,9 +1244,9 @@ var require_types_cjs_development = __commonJS({
|
|
|
1202
1244
|
__name(floatSafeRemainder, "floatSafeRemainder");
|
|
1203
1245
|
__name2(floatSafeRemainder, "floatSafeRemainder");
|
|
1204
1246
|
var EVALUATING = /* @__PURE__ */ Symbol("evaluating");
|
|
1205
|
-
function defineLazy(
|
|
1247
|
+
function defineLazy(object22, key, getter) {
|
|
1206
1248
|
let value = void 0;
|
|
1207
|
-
Object.defineProperty(
|
|
1249
|
+
Object.defineProperty(object22, key, {
|
|
1208
1250
|
get() {
|
|
1209
1251
|
if (value === EVALUATING) {
|
|
1210
1252
|
return void 0;
|
|
@@ -1216,7 +1258,7 @@ var require_types_cjs_development = __commonJS({
|
|
|
1216
1258
|
return value;
|
|
1217
1259
|
},
|
|
1218
1260
|
set(v) {
|
|
1219
|
-
Object.defineProperty(
|
|
1261
|
+
Object.defineProperty(object22, key, {
|
|
1220
1262
|
value: v
|
|
1221
1263
|
// configurable: true,
|
|
1222
1264
|
});
|
|
@@ -1264,12 +1306,12 @@ var require_types_cjs_development = __commonJS({
|
|
|
1264
1306
|
__name(getElementAtPath, "getElementAtPath");
|
|
1265
1307
|
__name2(getElementAtPath, "getElementAtPath");
|
|
1266
1308
|
function promiseAllObject(promisesObj) {
|
|
1267
|
-
const
|
|
1268
|
-
const promises =
|
|
1309
|
+
const keys2 = Object.keys(promisesObj);
|
|
1310
|
+
const promises = keys2.map((key) => promisesObj[key]);
|
|
1269
1311
|
return Promise.all(promises).then((results) => {
|
|
1270
1312
|
const resolvedObj = {};
|
|
1271
|
-
for (let i = 0; i <
|
|
1272
|
-
resolvedObj[
|
|
1313
|
+
for (let i = 0; i < keys2.length; i++) {
|
|
1314
|
+
resolvedObj[keys2[i]] = results[i];
|
|
1273
1315
|
}
|
|
1274
1316
|
return resolvedObj;
|
|
1275
1317
|
});
|
|
@@ -1809,18 +1851,18 @@ var require_types_cjs_development = __commonJS({
|
|
|
1809
1851
|
__name2(cleanEnum, "cleanEnum");
|
|
1810
1852
|
function base64ToUint8Array(base643) {
|
|
1811
1853
|
const binaryString = atob(base643);
|
|
1812
|
-
const
|
|
1854
|
+
const bytes3 = new Uint8Array(binaryString.length);
|
|
1813
1855
|
for (let i = 0; i < binaryString.length; i++) {
|
|
1814
|
-
|
|
1856
|
+
bytes3[i] = binaryString.charCodeAt(i);
|
|
1815
1857
|
}
|
|
1816
|
-
return
|
|
1858
|
+
return bytes3;
|
|
1817
1859
|
}
|
|
1818
1860
|
__name(base64ToUint8Array, "base64ToUint8Array");
|
|
1819
1861
|
__name2(base64ToUint8Array, "base64ToUint8Array");
|
|
1820
|
-
function uint8ArrayToBase64(
|
|
1862
|
+
function uint8ArrayToBase64(bytes3) {
|
|
1821
1863
|
let binaryString = "";
|
|
1822
|
-
for (let i = 0; i <
|
|
1823
|
-
binaryString += String.fromCharCode(
|
|
1864
|
+
for (let i = 0; i < bytes3.length; i++) {
|
|
1865
|
+
binaryString += String.fromCharCode(bytes3[i]);
|
|
1824
1866
|
}
|
|
1825
1867
|
return btoa(binaryString);
|
|
1826
1868
|
}
|
|
@@ -1833,8 +1875,8 @@ var require_types_cjs_development = __commonJS({
|
|
|
1833
1875
|
}
|
|
1834
1876
|
__name(base64urlToUint8Array, "base64urlToUint8Array");
|
|
1835
1877
|
__name2(base64urlToUint8Array, "base64urlToUint8Array");
|
|
1836
|
-
function uint8ArrayToBase64url(
|
|
1837
|
-
return uint8ArrayToBase64(
|
|
1878
|
+
function uint8ArrayToBase64url(bytes3) {
|
|
1879
|
+
return uint8ArrayToBase64(bytes3).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
1838
1880
|
}
|
|
1839
1881
|
__name(uint8ArrayToBase64url, "uint8ArrayToBase64url");
|
|
1840
1882
|
__name2(uint8ArrayToBase64url, "uint8ArrayToBase64url");
|
|
@@ -1843,16 +1885,16 @@ var require_types_cjs_development = __commonJS({
|
|
|
1843
1885
|
if (cleanHex.length % 2 !== 0) {
|
|
1844
1886
|
throw new Error("Invalid hex string length");
|
|
1845
1887
|
}
|
|
1846
|
-
const
|
|
1888
|
+
const bytes3 = new Uint8Array(cleanHex.length / 2);
|
|
1847
1889
|
for (let i = 0; i < cleanHex.length; i += 2) {
|
|
1848
|
-
|
|
1890
|
+
bytes3[i / 2] = Number.parseInt(cleanHex.slice(i, i + 2), 16);
|
|
1849
1891
|
}
|
|
1850
|
-
return
|
|
1892
|
+
return bytes3;
|
|
1851
1893
|
}
|
|
1852
1894
|
__name(hexToUint8Array, "hexToUint8Array");
|
|
1853
1895
|
__name2(hexToUint8Array, "hexToUint8Array");
|
|
1854
|
-
function uint8ArrayToHex(
|
|
1855
|
-
return Array.from(
|
|
1896
|
+
function uint8ArrayToHex(bytes3) {
|
|
1897
|
+
return Array.from(bytes3).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
1856
1898
|
}
|
|
1857
1899
|
__name(uint8ArrayToHex, "uint8ArrayToHex");
|
|
1858
1900
|
__name2(uint8ArrayToHex, "uint8ArrayToHex");
|
|
@@ -2067,11 +2109,11 @@ var require_types_cjs_development = __commonJS({
|
|
|
2067
2109
|
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
2068
2110
|
return _parse(_Err)(schema, value, ctx);
|
|
2069
2111
|
}, "_encode");
|
|
2070
|
-
var
|
|
2112
|
+
var encode2 = /* @__PURE__ */ _encode($ZodRealError);
|
|
2071
2113
|
var _decode = /* @__PURE__ */ __name2((_Err) => (schema, value, _ctx) => {
|
|
2072
2114
|
return _parse(_Err)(schema, value, _ctx);
|
|
2073
2115
|
}, "_decode");
|
|
2074
|
-
var
|
|
2116
|
+
var decode2 = /* @__PURE__ */ _decode($ZodRealError);
|
|
2075
2117
|
var _encodeAsync = /* @__PURE__ */ __name2((_Err) => async (schema, value, _ctx) => {
|
|
2076
2118
|
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
2077
2119
|
return _parseAsync(_Err)(schema, value, ctx);
|
|
@@ -2101,7 +2143,7 @@ var require_types_cjs_development = __commonJS({
|
|
|
2101
2143
|
var safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync($ZodRealError);
|
|
2102
2144
|
var regexes_exports = {};
|
|
2103
2145
|
__export(regexes_exports, {
|
|
2104
|
-
base64: /* @__PURE__ */ __name(() =>
|
|
2146
|
+
base64: /* @__PURE__ */ __name(() => base642, "base64"),
|
|
2105
2147
|
base64url: /* @__PURE__ */ __name(() => base64url, "base64url"),
|
|
2106
2148
|
bigint: /* @__PURE__ */ __name(() => bigint, "bigint"),
|
|
2107
2149
|
boolean: /* @__PURE__ */ __name(() => boolean, "boolean"),
|
|
@@ -2119,12 +2161,12 @@ var require_types_cjs_development = __commonJS({
|
|
|
2119
2161
|
emoji: /* @__PURE__ */ __name(() => emoji, "emoji"),
|
|
2120
2162
|
extendedDuration: /* @__PURE__ */ __name(() => extendedDuration, "extendedDuration"),
|
|
2121
2163
|
guid: /* @__PURE__ */ __name(() => guid, "guid"),
|
|
2122
|
-
hex: /* @__PURE__ */ __name(() =>
|
|
2164
|
+
hex: /* @__PURE__ */ __name(() => hex2, "hex"),
|
|
2123
2165
|
hostname: /* @__PURE__ */ __name(() => hostname, "hostname"),
|
|
2124
2166
|
html5Email: /* @__PURE__ */ __name(() => html5Email, "html5Email"),
|
|
2125
2167
|
httpProtocol: /* @__PURE__ */ __name(() => httpProtocol, "httpProtocol"),
|
|
2126
2168
|
idnEmail: /* @__PURE__ */ __name(() => idnEmail, "idnEmail"),
|
|
2127
|
-
integer: /* @__PURE__ */ __name(() =>
|
|
2169
|
+
integer: /* @__PURE__ */ __name(() => integer3, "integer"),
|
|
2128
2170
|
ipv4: /* @__PURE__ */ __name(() => ipv4, "ipv4"),
|
|
2129
2171
|
ipv6: /* @__PURE__ */ __name(() => ipv6, "ipv6"),
|
|
2130
2172
|
ksuid: /* @__PURE__ */ __name(() => ksuid, "ksuid"),
|
|
@@ -2198,7 +2240,7 @@ var require_types_cjs_development = __commonJS({
|
|
|
2198
2240
|
}, "mac");
|
|
2199
2241
|
var cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/;
|
|
2200
2242
|
var cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
|
|
2201
|
-
var
|
|
2243
|
+
var base642 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
|
|
2202
2244
|
var base64url = /^[A-Za-z0-9_-]*$/;
|
|
2203
2245
|
var hostname = /^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/;
|
|
2204
2246
|
var domain = /^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/;
|
|
@@ -2235,14 +2277,14 @@ var require_types_cjs_development = __commonJS({
|
|
|
2235
2277
|
return new RegExp(`^${regex}$`);
|
|
2236
2278
|
}, "string");
|
|
2237
2279
|
var bigint = /^-?\d+n?$/;
|
|
2238
|
-
var
|
|
2280
|
+
var integer3 = /^-?\d+$/;
|
|
2239
2281
|
var number = /^-?\d+(?:\.\d+)?$/;
|
|
2240
2282
|
var boolean = /^(?:true|false)$/i;
|
|
2241
2283
|
var _null = /^null$/i;
|
|
2242
2284
|
var _undefined = /^undefined$/i;
|
|
2243
2285
|
var lowercase = /^[^A-Z]*$/;
|
|
2244
2286
|
var uppercase = /^[^a-z]*$/;
|
|
2245
|
-
var
|
|
2287
|
+
var hex2 = /^[0-9a-fA-F]*$/;
|
|
2246
2288
|
function fixedBase64(bodyLength, padding) {
|
|
2247
2289
|
return new RegExp(`^[A-Za-z0-9+/]{${bodyLength}}${padding}$`);
|
|
2248
2290
|
}
|
|
@@ -2369,7 +2411,7 @@ var require_types_cjs_development = __commonJS({
|
|
|
2369
2411
|
bag.minimum = minimum;
|
|
2370
2412
|
bag.maximum = maximum;
|
|
2371
2413
|
if (isInt)
|
|
2372
|
-
bag.pattern =
|
|
2414
|
+
bag.pattern = integer3;
|
|
2373
2415
|
});
|
|
2374
2416
|
inst._zod.check = (payload) => {
|
|
2375
2417
|
const input = payload.value;
|
|
@@ -3209,7 +3251,7 @@ var require_types_cjs_development = __commonJS({
|
|
|
3209
3251
|
__name(isValidBase64, "isValidBase64");
|
|
3210
3252
|
__name2(isValidBase64, "isValidBase64");
|
|
3211
3253
|
var $ZodBase64 = /* @__PURE__ */ $constructor("$ZodBase64", (inst, def) => {
|
|
3212
|
-
def.pattern ?? (def.pattern =
|
|
3254
|
+
def.pattern ?? (def.pattern = base642);
|
|
3213
3255
|
$ZodStringFormat.init(inst, def);
|
|
3214
3256
|
inst._zod.bag.contentEncoding = "base64";
|
|
3215
3257
|
inst._zod.check = (payload) => {
|
|
@@ -3555,8 +3597,8 @@ var require_types_cjs_development = __commonJS({
|
|
|
3555
3597
|
__name(handlePropertyResult, "handlePropertyResult");
|
|
3556
3598
|
__name2(handlePropertyResult, "handlePropertyResult");
|
|
3557
3599
|
function normalizeDef(def) {
|
|
3558
|
-
const
|
|
3559
|
-
for (const k of
|
|
3600
|
+
const keys2 = Object.keys(def.shape);
|
|
3601
|
+
for (const k of keys2) {
|
|
3560
3602
|
if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) {
|
|
3561
3603
|
throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
|
|
3562
3604
|
}
|
|
@@ -3564,9 +3606,9 @@ var require_types_cjs_development = __commonJS({
|
|
|
3564
3606
|
const okeys = optionalKeys(def.shape);
|
|
3565
3607
|
return {
|
|
3566
3608
|
...def,
|
|
3567
|
-
keys,
|
|
3568
|
-
keySet: new Set(
|
|
3569
|
-
numKeys:
|
|
3609
|
+
keys: keys2,
|
|
3610
|
+
keySet: new Set(keys2),
|
|
3611
|
+
numKeys: keys2.length,
|
|
3570
3612
|
optionalKeys: new Set(okeys)
|
|
3571
3613
|
};
|
|
3572
3614
|
}
|
|
@@ -3946,19 +3988,19 @@ var require_types_cjs_development = __commonJS({
|
|
|
3946
3988
|
});
|
|
3947
3989
|
const disc = cached(() => {
|
|
3948
3990
|
const opts = def.options;
|
|
3949
|
-
const
|
|
3991
|
+
const map22 = /* @__PURE__ */ new Map();
|
|
3950
3992
|
for (const o of opts) {
|
|
3951
3993
|
const values = o._zod.propValues?.[def.discriminator];
|
|
3952
3994
|
if (!values || values.size === 0)
|
|
3953
3995
|
throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
|
|
3954
3996
|
for (const v of values) {
|
|
3955
|
-
if (
|
|
3997
|
+
if (map22.has(v)) {
|
|
3956
3998
|
throw new Error(`Duplicate discriminator value "${String(v)}"`);
|
|
3957
3999
|
}
|
|
3958
|
-
|
|
4000
|
+
map22.set(v, o);
|
|
3959
4001
|
}
|
|
3960
4002
|
}
|
|
3961
|
-
return
|
|
4003
|
+
return map22;
|
|
3962
4004
|
});
|
|
3963
4005
|
inst._zod.parse = (payload, ctx) => {
|
|
3964
4006
|
const input = payload.value;
|
|
@@ -8328,8 +8370,8 @@ var require_types_cjs_development = __commonJS({
|
|
|
8328
8370
|
}
|
|
8329
8371
|
__name(ko_default, "ko_default");
|
|
8330
8372
|
__name2(ko_default, "default");
|
|
8331
|
-
var capitalizeFirstCharacter = /* @__PURE__ */ __name2((
|
|
8332
|
-
return
|
|
8373
|
+
var capitalizeFirstCharacter = /* @__PURE__ */ __name2((text2) => {
|
|
8374
|
+
return text2.charAt(0).toUpperCase() + text2.slice(1);
|
|
8333
8375
|
}, "capitalizeFirstCharacter");
|
|
8334
8376
|
function getUnitTypeFromNumber(number4) {
|
|
8335
8377
|
const abs = Math.abs(number4);
|
|
@@ -13449,7 +13491,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
13449
13491
|
_function: /* @__PURE__ */ __name(() => _function, "_function"),
|
|
13450
13492
|
any: /* @__PURE__ */ __name(() => any, "any"),
|
|
13451
13493
|
array: /* @__PURE__ */ __name(() => array, "array"),
|
|
13452
|
-
base64: /* @__PURE__ */ __name(() =>
|
|
13494
|
+
base64: /* @__PURE__ */ __name(() => base6422, "base64"),
|
|
13453
13495
|
base64url: /* @__PURE__ */ __name(() => base64url2, "base64url"),
|
|
13454
13496
|
bigint: /* @__PURE__ */ __name(() => bigint2, "bigint"),
|
|
13455
13497
|
boolean: /* @__PURE__ */ __name(() => boolean2, "boolean"),
|
|
@@ -13474,8 +13516,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
13474
13516
|
float64: /* @__PURE__ */ __name(() => float64, "float64"),
|
|
13475
13517
|
function: /* @__PURE__ */ __name(() => _function, "function"),
|
|
13476
13518
|
guid: /* @__PURE__ */ __name(() => guid2, "guid"),
|
|
13477
|
-
hash: /* @__PURE__ */ __name(() =>
|
|
13478
|
-
hex: /* @__PURE__ */ __name(() =>
|
|
13519
|
+
hash: /* @__PURE__ */ __name(() => hash2, "hash"),
|
|
13520
|
+
hex: /* @__PURE__ */ __name(() => hex22, "hex"),
|
|
13479
13521
|
hostname: /* @__PURE__ */ __name(() => hostname2, "hostname"),
|
|
13480
13522
|
httpUrl: /* @__PURE__ */ __name(() => httpUrl, "httpUrl"),
|
|
13481
13523
|
instanceof: /* @__PURE__ */ __name(() => _instanceof, "instanceof"),
|
|
@@ -13495,7 +13537,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
13495
13537
|
looseObject: /* @__PURE__ */ __name(() => looseObject, "looseObject"),
|
|
13496
13538
|
looseRecord: /* @__PURE__ */ __name(() => looseRecord, "looseRecord"),
|
|
13497
13539
|
mac: /* @__PURE__ */ __name(() => mac2, "mac"),
|
|
13498
|
-
map: /* @__PURE__ */ __name(() =>
|
|
13540
|
+
map: /* @__PURE__ */ __name(() => map2, "map"),
|
|
13499
13541
|
meta: /* @__PURE__ */ __name(() => meta2, "meta"),
|
|
13500
13542
|
nan: /* @__PURE__ */ __name(() => nan, "nan"),
|
|
13501
13543
|
nanoid: /* @__PURE__ */ __name(() => nanoid2, "nanoid"),
|
|
@@ -13506,7 +13548,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
13506
13548
|
nullable: /* @__PURE__ */ __name(() => nullable, "nullable"),
|
|
13507
13549
|
nullish: /* @__PURE__ */ __name(() => nullish2, "nullish"),
|
|
13508
13550
|
number: /* @__PURE__ */ __name(() => number2, "number"),
|
|
13509
|
-
object: /* @__PURE__ */ __name(() =>
|
|
13551
|
+
object: /* @__PURE__ */ __name(() => object2, "object"),
|
|
13510
13552
|
optional: /* @__PURE__ */ __name(() => optional, "optional"),
|
|
13511
13553
|
partialRecord: /* @__PURE__ */ __name(() => partialRecord, "partialRecord"),
|
|
13512
13554
|
pipe: /* @__PURE__ */ __name(() => pipe, "pipe"),
|
|
@@ -13663,8 +13705,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
13663
13705
|
var parseAsync2 = /* @__PURE__ */ _parseAsync(ZodRealError);
|
|
13664
13706
|
var safeParse2 = /* @__PURE__ */ _safeParse(ZodRealError);
|
|
13665
13707
|
var safeParseAsync2 = /* @__PURE__ */ _safeParseAsync(ZodRealError);
|
|
13666
|
-
var
|
|
13667
|
-
var
|
|
13708
|
+
var encode22 = /* @__PURE__ */ _encode(ZodRealError);
|
|
13709
|
+
var decode22 = /* @__PURE__ */ _decode(ZodRealError);
|
|
13668
13710
|
var encodeAsync2 = /* @__PURE__ */ _encodeAsync(ZodRealError);
|
|
13669
13711
|
var decodeAsync2 = /* @__PURE__ */ _decodeAsync(ZodRealError);
|
|
13670
13712
|
var safeEncode2 = /* @__PURE__ */ _safeEncode(ZodRealError);
|
|
@@ -13727,8 +13769,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
13727
13769
|
inst.parseAsync = async (data, params) => parseAsync2(inst, data, params, { callee: inst.parseAsync });
|
|
13728
13770
|
inst.safeParseAsync = async (data, params) => safeParseAsync2(inst, data, params);
|
|
13729
13771
|
inst.spa = inst.safeParseAsync;
|
|
13730
|
-
inst.encode = (data, params) =>
|
|
13731
|
-
inst.decode = (data, params) =>
|
|
13772
|
+
inst.encode = (data, params) => encode22(inst, data, params);
|
|
13773
|
+
inst.decode = (data, params) => decode22(inst, data, params);
|
|
13732
13774
|
inst.encodeAsync = async (data, params) => encodeAsync2(inst, data, params);
|
|
13733
13775
|
inst.decodeAsync = async (data, params) => decodeAsync2(inst, data, params);
|
|
13734
13776
|
inst.safeEncode = (data, params) => safeEncode2(inst, data, params);
|
|
@@ -14107,11 +14149,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
14107
14149
|
$ZodBase64.init(inst, def);
|
|
14108
14150
|
ZodStringFormat.init(inst, def);
|
|
14109
14151
|
});
|
|
14110
|
-
function
|
|
14152
|
+
function base6422(params) {
|
|
14111
14153
|
return /* @__PURE__ */ _base64(ZodBase64, params);
|
|
14112
14154
|
}
|
|
14113
|
-
__name(
|
|
14114
|
-
__name2(
|
|
14155
|
+
__name(base6422, "base642");
|
|
14156
|
+
__name2(base6422, "base64");
|
|
14115
14157
|
var ZodBase64URL = /* @__PURE__ */ $constructor("ZodBase64URL", (inst, def) => {
|
|
14116
14158
|
$ZodBase64URL.init(inst, def);
|
|
14117
14159
|
ZodStringFormat.init(inst, def);
|
|
@@ -14153,12 +14195,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
14153
14195
|
}
|
|
14154
14196
|
__name(hostname2, "hostname2");
|
|
14155
14197
|
__name2(hostname2, "hostname");
|
|
14156
|
-
function
|
|
14198
|
+
function hex22(_params) {
|
|
14157
14199
|
return /* @__PURE__ */ _stringFormat(ZodCustomStringFormat, "hex", regexes_exports.hex, _params);
|
|
14158
14200
|
}
|
|
14159
|
-
__name(
|
|
14160
|
-
__name2(
|
|
14161
|
-
function
|
|
14201
|
+
__name(hex22, "hex2");
|
|
14202
|
+
__name2(hex22, "hex");
|
|
14203
|
+
function hash2(alg, params) {
|
|
14162
14204
|
const enc = params?.enc ?? "hex";
|
|
14163
14205
|
const format = `${alg}_${enc}`;
|
|
14164
14206
|
const regex = regexes_exports[format];
|
|
@@ -14166,8 +14208,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
14166
14208
|
throw new Error(`Unrecognized hash format: ${format}`);
|
|
14167
14209
|
return /* @__PURE__ */ _stringFormat(ZodCustomStringFormat, format, regex, params);
|
|
14168
14210
|
}
|
|
14169
|
-
__name(
|
|
14170
|
-
__name2(
|
|
14211
|
+
__name(hash2, "hash");
|
|
14212
|
+
__name2(hash2, "hash");
|
|
14171
14213
|
var ZodNumber = /* @__PURE__ */ $constructor("ZodNumber", (inst, def) => {
|
|
14172
14214
|
$ZodNumber.init(inst, def);
|
|
14173
14215
|
ZodType.init(inst, def);
|
|
@@ -14479,7 +14521,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
14479
14521
|
}
|
|
14480
14522
|
});
|
|
14481
14523
|
});
|
|
14482
|
-
function
|
|
14524
|
+
function object2(shape, params) {
|
|
14483
14525
|
const def = {
|
|
14484
14526
|
type: "object",
|
|
14485
14527
|
shape: shape ?? {},
|
|
@@ -14487,8 +14529,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
14487
14529
|
};
|
|
14488
14530
|
return new ZodObject(def);
|
|
14489
14531
|
}
|
|
14490
|
-
__name(
|
|
14491
|
-
__name2(
|
|
14532
|
+
__name(object2, "object");
|
|
14533
|
+
__name2(object2, "object");
|
|
14492
14534
|
function strictObject(shape, params) {
|
|
14493
14535
|
return new ZodObject({
|
|
14494
14536
|
type: "object",
|
|
@@ -14649,7 +14691,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
14649
14691
|
inst.max = (...args) => inst.check(/* @__PURE__ */ _maxSize(...args));
|
|
14650
14692
|
inst.size = (...args) => inst.check(/* @__PURE__ */ _size(...args));
|
|
14651
14693
|
});
|
|
14652
|
-
function
|
|
14694
|
+
function map2(keyType, valueType, params) {
|
|
14653
14695
|
return new ZodMap({
|
|
14654
14696
|
type: "map",
|
|
14655
14697
|
keyType,
|
|
@@ -14657,8 +14699,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
14657
14699
|
...util_exports.normalizeParams(params)
|
|
14658
14700
|
});
|
|
14659
14701
|
}
|
|
14660
|
-
__name(
|
|
14661
|
-
__name2(
|
|
14702
|
+
__name(map2, "map");
|
|
14703
|
+
__name2(map2, "map");
|
|
14662
14704
|
var ZodSet = /* @__PURE__ */ $constructor("ZodSet", (inst, def) => {
|
|
14663
14705
|
$ZodSet.init(inst, def);
|
|
14664
14706
|
ZodType.init(inst, def);
|
|
@@ -14683,11 +14725,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
14683
14725
|
inst._zod.processJSONSchema = (ctx, json2, params) => enumProcessor(inst, ctx, json2, params);
|
|
14684
14726
|
inst.enum = def.entries;
|
|
14685
14727
|
inst.options = Object.values(def.entries);
|
|
14686
|
-
const
|
|
14728
|
+
const keys2 = new Set(Object.keys(def.entries));
|
|
14687
14729
|
inst.extract = (values, params) => {
|
|
14688
14730
|
const newEntries = {};
|
|
14689
14731
|
for (const value of values) {
|
|
14690
|
-
if (
|
|
14732
|
+
if (keys2.has(value)) {
|
|
14691
14733
|
newEntries[value] = def.entries[value];
|
|
14692
14734
|
} else
|
|
14693
14735
|
throw new Error(`Key ${value} not found in enum`);
|
|
@@ -14702,7 +14744,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
14702
14744
|
inst.exclude = (values, params) => {
|
|
14703
14745
|
const newEntries = { ...def.entries };
|
|
14704
14746
|
for (const value of values) {
|
|
14705
|
-
if (
|
|
14747
|
+
if (keys2.has(value)) {
|
|
14706
14748
|
delete newEntries[value];
|
|
14707
14749
|
} else
|
|
14708
14750
|
throw new Error(`Key ${value} not found in enum`);
|
|
@@ -15158,9 +15200,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
15158
15200
|
invalid_value: "invalid_value",
|
|
15159
15201
|
custom: "custom"
|
|
15160
15202
|
};
|
|
15161
|
-
function setErrorMap(
|
|
15203
|
+
function setErrorMap(map22) {
|
|
15162
15204
|
config({
|
|
15163
|
-
customError:
|
|
15205
|
+
customError: map22
|
|
15164
15206
|
});
|
|
15165
15207
|
}
|
|
15166
15208
|
__name(setErrorMap, "setErrorMap");
|
|
@@ -15838,7 +15880,18 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
15838
15880
|
verificationMethod: external_exports.string(),
|
|
15839
15881
|
jws: external_exports.string().optional()
|
|
15840
15882
|
}).catchall(external_exports.any()).superRefine((proof, ctx) => {
|
|
15841
|
-
if (proof.created === void 0 &&
|
|
15883
|
+
if (proof.created === void 0 && // These standardized Data Integrity suites make created optional.
|
|
15884
|
+
// Keep the prior requirement for legacy and unknown proof suites.
|
|
15885
|
+
// https://www.w3.org/TR/vc-di-eddsa/#proof-configuration-eddsa-jcs-2022
|
|
15886
|
+
// https://www.w3.org/TR/vc-di-bbs/#proof-configuration
|
|
15887
|
+
(proof.type !== "DataIntegrityProof" || ![
|
|
15888
|
+
"ecdsa-rdfc-2019",
|
|
15889
|
+
"ecdsa-jcs-2019",
|
|
15890
|
+
"ecdsa-sd-2023",
|
|
15891
|
+
"eddsa-rdfc-2022",
|
|
15892
|
+
"eddsa-jcs-2022",
|
|
15893
|
+
"bbs-2023"
|
|
15894
|
+
].includes(proof.cryptosuite))) {
|
|
15842
15895
|
ctx.addIssue({
|
|
15843
15896
|
code: "custom",
|
|
15844
15897
|
path: ["created"],
|
|
@@ -16118,7 +16171,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
16118
16171
|
"replacedBy"
|
|
16119
16172
|
]).or(external_exports.string());
|
|
16120
16173
|
var AssociationValidator = external_exports.object({
|
|
16121
|
-
|
|
16174
|
+
// Accept compacted scalars while retaining the existing permissive array contract.
|
|
16175
|
+
type: external_exports.string().min(1).or(external_exports.string().array().nonempty()),
|
|
16122
16176
|
associationType: AssociationTypeValidator,
|
|
16123
16177
|
sourceId: external_exports.string().optional(),
|
|
16124
16178
|
targetId: external_exports.string()
|
|
@@ -16941,11 +16995,48 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
16941
16995
|
updatedAt: external_exports.string(),
|
|
16942
16996
|
expiresAt: external_exports.string().optional(),
|
|
16943
16997
|
autoBoosts: external_exports.string().array().optional(),
|
|
16944
|
-
writers: external_exports.array(LCNProfileValidator).optional()
|
|
16998
|
+
writers: external_exports.array(LCNProfileValidator).optional(),
|
|
16999
|
+
recipients: external_exports.array(LCNPublicProfileValidator.extend({ did: external_exports.string() })).optional(),
|
|
17000
|
+
audienceVersion: external_exports.number().int().nonnegative().optional()
|
|
16945
17001
|
});
|
|
16946
|
-
var ConsentFlowContractRequestStatusValidator = external_exports.enum(["pending", "accepted", "denied"]).nullable();
|
|
17002
|
+
var ConsentFlowContractRequestStatusValidator = external_exports.enum(["pending", "accepted", "denied", "cancelled"]).nullable();
|
|
16947
17003
|
var ConsentFlowContractRequestReadStatusValidator = external_exports.enum(["unseen", "seen"]).nullable();
|
|
16948
|
-
var
|
|
17004
|
+
var ConsentFlowReferralValidator = external_exports.object({
|
|
17005
|
+
requestId: external_exports.string(),
|
|
17006
|
+
requestedBy: external_exports.string(),
|
|
17007
|
+
externalReferenceId: external_exports.string().max(256).optional()
|
|
17008
|
+
});
|
|
17009
|
+
var ContractRequestFieldsValidator = ConsentFlowReferralValidator.partial().extend({
|
|
17010
|
+
requestedAt: external_exports.string().optional(),
|
|
17011
|
+
message: external_exports.string().max(500).optional()
|
|
17012
|
+
});
|
|
17013
|
+
var SendContractRequestValidator = external_exports.object({
|
|
17014
|
+
contractUri: external_exports.string(),
|
|
17015
|
+
targetProfileId: external_exports.string(),
|
|
17016
|
+
externalReferenceId: external_exports.string().trim().min(1).max(256).optional(),
|
|
17017
|
+
message: external_exports.string().trim().max(500).optional()
|
|
17018
|
+
});
|
|
17019
|
+
var ConsentFlowWebhookMetadataValidator = external_exports.object({
|
|
17020
|
+
eventId: external_exports.string(),
|
|
17021
|
+
deliveryKey: external_exports.string(),
|
|
17022
|
+
event: external_exports.enum([
|
|
17023
|
+
"request_sent",
|
|
17024
|
+
"request_accepted",
|
|
17025
|
+
"request_denied",
|
|
17026
|
+
"request_cancelled",
|
|
17027
|
+
"consent_created",
|
|
17028
|
+
"consent_updated",
|
|
17029
|
+
"consent_withdrawn",
|
|
17030
|
+
"credentials_synced"
|
|
17031
|
+
]),
|
|
17032
|
+
contractUri: external_exports.string(),
|
|
17033
|
+
termsUri: external_exports.string().optional(),
|
|
17034
|
+
requestId: external_exports.string().optional(),
|
|
17035
|
+
requestedBy: external_exports.string().optional(),
|
|
17036
|
+
externalReferenceId: external_exports.string().optional(),
|
|
17037
|
+
recipientRole: external_exports.enum(["owner", "recipient", "requester", "target"])
|
|
17038
|
+
});
|
|
17039
|
+
var ConsentFlowContractRequestForProfileValidator = ContractRequestFieldsValidator.extend({
|
|
16949
17040
|
profile: LCNProfileValidator,
|
|
16950
17041
|
status: ConsentFlowContractRequestStatusValidator,
|
|
16951
17042
|
readStatus: ConsentFlowContractRequestReadStatusValidator.optional()
|
|
@@ -16991,6 +17082,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
16991
17082
|
expiresAt: external_exports.string().optional(),
|
|
16992
17083
|
oneTime: external_exports.boolean().optional(),
|
|
16993
17084
|
terms: ConsentFlowTermsValidator,
|
|
17085
|
+
referral: ConsentFlowReferralValidator.optional(),
|
|
16994
17086
|
contract: ConsentFlowContractDetailsValidator,
|
|
16995
17087
|
uri: external_exports.string(),
|
|
16996
17088
|
consenter: LCNProfileValidator,
|
|
@@ -17086,6 +17178,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
17086
17178
|
oneTime: external_exports.boolean().optional(),
|
|
17087
17179
|
terms: ConsentFlowTermsValidator.optional(),
|
|
17088
17180
|
guardianApproval: ConsentFlowGuardianApprovalValidator.optional(),
|
|
17181
|
+
referral: ConsentFlowReferralValidator.optional(),
|
|
17089
17182
|
id: external_exports.string(),
|
|
17090
17183
|
action: ConsentFlowTransactionActionValidator,
|
|
17091
17184
|
date: external_exports.string(),
|
|
@@ -17096,6 +17189,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
17096
17189
|
status: ConsentFlowTermsStatusValidator,
|
|
17097
17190
|
contract: ConsentFlowContractDetailsValidator,
|
|
17098
17191
|
terms: ConsentFlowTermsValidator,
|
|
17192
|
+
referral: ConsentFlowReferralValidator.optional(),
|
|
17099
17193
|
transactions: ConsentFlowTransactionValidator.array()
|
|
17100
17194
|
});
|
|
17101
17195
|
var HolderExportMetadataValidator = external_exports.object({
|
|
@@ -17832,7 +17926,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
17832
17926
|
displayName: external_exports.string(),
|
|
17833
17927
|
email: external_exports.string().optional()
|
|
17834
17928
|
});
|
|
17835
|
-
var
|
|
17929
|
+
var AppStoreListingFieldsValidator = external_exports.object({
|
|
17836
17930
|
listing_id: external_exports.string(),
|
|
17837
17931
|
slug: external_exports.string().optional(),
|
|
17838
17932
|
display_name: external_exports.string(),
|
|
@@ -17858,15 +17952,33 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
17858
17952
|
submitter: AppStoreListingSubmitterValidator.optional(),
|
|
17859
17953
|
contact_email: external_exports.string().email().optional()
|
|
17860
17954
|
});
|
|
17955
|
+
var PendingListingUpdateStatusValidator = external_exports.enum(["DRAFT", "PENDING_REVIEW"]);
|
|
17956
|
+
var PendingListingUpdateValidator = external_exports.object({
|
|
17957
|
+
status: PendingListingUpdateStatusValidator,
|
|
17958
|
+
submitted_at: external_exports.string().optional(),
|
|
17959
|
+
changes: AppStoreListingFieldsValidator.omit({
|
|
17960
|
+
listing_id: true,
|
|
17961
|
+
app_listing_status: true,
|
|
17962
|
+
promotion_level: true,
|
|
17963
|
+
submitted_at: true,
|
|
17964
|
+
submitter: true
|
|
17965
|
+
}).partial(),
|
|
17966
|
+
manifest_version: external_exports.number().int().min(1).optional()
|
|
17967
|
+
});
|
|
17968
|
+
var AppStoreListingValidator = AppStoreListingFieldsValidator.extend({
|
|
17969
|
+
pending_update: PendingListingUpdateValidator.optional()
|
|
17970
|
+
});
|
|
17861
17971
|
var AppStoreListingCreateValidator = AppStoreListingValidator.omit({
|
|
17862
17972
|
listing_id: true,
|
|
17863
17973
|
app_listing_status: true,
|
|
17864
|
-
promotion_level: true
|
|
17974
|
+
promotion_level: true,
|
|
17975
|
+
pending_update: true
|
|
17865
17976
|
});
|
|
17866
17977
|
var AppStoreListingUpdateValidator = AppStoreListingValidator.partial().omit({
|
|
17867
17978
|
listing_id: true,
|
|
17868
17979
|
app_listing_status: true,
|
|
17869
|
-
promotion_level: true
|
|
17980
|
+
promotion_level: true,
|
|
17981
|
+
pending_update: true
|
|
17870
17982
|
});
|
|
17871
17983
|
var InstalledAppValidator = AppStoreListingValidator.extend({
|
|
17872
17984
|
installed_at: external_exports.string()
|
|
@@ -17881,12 +17993,87 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
17881
17993
|
templateAlias: external_exports.string().min(1).max(50).regex(/^[a-z0-9-]+$/),
|
|
17882
17994
|
boostUri: external_exports.string()
|
|
17883
17995
|
});
|
|
17884
|
-
var
|
|
17996
|
+
var InlineWalletCategoryValidator = external_exports.enum([
|
|
17997
|
+
"Achievement",
|
|
17998
|
+
"Skill",
|
|
17999
|
+
"ID",
|
|
18000
|
+
"Learning History",
|
|
18001
|
+
"Work History",
|
|
18002
|
+
"Social Badges",
|
|
18003
|
+
"Membership",
|
|
18004
|
+
"Accomplishment",
|
|
18005
|
+
"Experiences",
|
|
18006
|
+
"Accommodation",
|
|
18007
|
+
"Family"
|
|
18008
|
+
]);
|
|
18009
|
+
var InlineAlignmentValidator = external_exports.object({
|
|
18010
|
+
name: external_exports.string(),
|
|
18011
|
+
url: external_exports.string(),
|
|
18012
|
+
framework: external_exports.string().optional(),
|
|
18013
|
+
code: external_exports.string().optional()
|
|
18014
|
+
}).passthrough();
|
|
18015
|
+
var InlineEvidenceValidator = external_exports.object({
|
|
18016
|
+
id: external_exports.string().optional(),
|
|
18017
|
+
name: external_exports.string().optional(),
|
|
18018
|
+
narrative: external_exports.string().optional()
|
|
18019
|
+
}).passthrough();
|
|
18020
|
+
var InlineWalletSkillTagValidator = external_exports.object({
|
|
18021
|
+
frameworkId: external_exports.string(),
|
|
18022
|
+
id: external_exports.string(),
|
|
18023
|
+
proficiencyLevel: external_exports.string().optional()
|
|
18024
|
+
}).passthrough();
|
|
18025
|
+
var SimpleInlineCredentialTemplateValidator = external_exports.object({
|
|
18026
|
+
rawCredential: external_exports.undefined().optional(),
|
|
18027
|
+
name: external_exports.string(),
|
|
18028
|
+
description: external_exports.string().optional(),
|
|
18029
|
+
image: external_exports.string().optional(),
|
|
18030
|
+
issuerName: external_exports.string().optional(),
|
|
18031
|
+
achievementType: external_exports.string().optional(),
|
|
18032
|
+
category: InlineWalletCategoryValidator.optional(),
|
|
18033
|
+
criteria: external_exports.object({
|
|
18034
|
+
narrative: external_exports.string().optional(),
|
|
18035
|
+
url: external_exports.string().optional()
|
|
18036
|
+
}).passthrough().optional(),
|
|
18037
|
+
alignments: external_exports.array(InlineAlignmentValidator).optional(),
|
|
18038
|
+
tags: external_exports.array(external_exports.string()).optional(),
|
|
18039
|
+
activity: external_exports.object({
|
|
18040
|
+
startDate: external_exports.string().optional(),
|
|
18041
|
+
endDate: external_exports.string().optional()
|
|
18042
|
+
}).passthrough().optional(),
|
|
18043
|
+
credits: external_exports.object({
|
|
18044
|
+
earned: external_exports.union([external_exports.number(), external_exports.string()]).optional(),
|
|
18045
|
+
available: external_exports.union([external_exports.number(), external_exports.string()]).optional()
|
|
18046
|
+
}).passthrough().optional(),
|
|
18047
|
+
validUntil: external_exports.string().optional(),
|
|
18048
|
+
evidence: external_exports.array(InlineEvidenceValidator).optional(),
|
|
18049
|
+
walletSkills: external_exports.array(InlineWalletSkillTagValidator).optional()
|
|
18050
|
+
}).passthrough();
|
|
18051
|
+
var RawInlineCredentialTemplateValidator = external_exports.object({
|
|
18052
|
+
rawCredential: external_exports.record(external_exports.string(), external_exports.unknown()),
|
|
18053
|
+
category: InlineWalletCategoryValidator.optional(),
|
|
18054
|
+
walletSkills: external_exports.array(InlineWalletSkillTagValidator).optional()
|
|
18055
|
+
}).passthrough();
|
|
18056
|
+
var InlineCredentialTemplateValidator = external_exports.union([
|
|
18057
|
+
RawInlineCredentialTemplateValidator,
|
|
18058
|
+
SimpleInlineCredentialTemplateValidator
|
|
18059
|
+
]);
|
|
18060
|
+
var LegacySendCredentialEventValidator = external_exports.object({
|
|
17885
18061
|
type: external_exports.literal("send-credential"),
|
|
17886
18062
|
templateAlias: external_exports.string(),
|
|
17887
18063
|
templateData: external_exports.record(external_exports.string(), external_exports.unknown()).optional(),
|
|
17888
18064
|
preventDuplicateClaim: external_exports.boolean().optional()
|
|
17889
18065
|
});
|
|
18066
|
+
var InlineSendCredentialEventValidator = external_exports.object({
|
|
18067
|
+
type: external_exports.literal("send-credential"),
|
|
18068
|
+
alias: external_exports.string(),
|
|
18069
|
+
template: InlineCredentialTemplateValidator,
|
|
18070
|
+
templateData: external_exports.record(external_exports.string(), external_exports.unknown()).optional(),
|
|
18071
|
+
preventDuplicateClaim: external_exports.boolean().optional()
|
|
18072
|
+
});
|
|
18073
|
+
var SendCredentialEventValidator = external_exports.union([
|
|
18074
|
+
LegacySendCredentialEventValidator,
|
|
18075
|
+
InlineSendCredentialEventValidator
|
|
18076
|
+
]);
|
|
17890
18077
|
var CheckCredentialEventValidator = external_exports.object({
|
|
17891
18078
|
type: external_exports.literal("check-credential"),
|
|
17892
18079
|
templateAlias: external_exports.string().optional(),
|
|
@@ -17981,7 +18168,119 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
17981
18168
|
type: external_exports.literal("get-counters"),
|
|
17982
18169
|
keys: external_exports.array(counterKeyValidator).min(1).max(50).optional()
|
|
17983
18170
|
});
|
|
17984
|
-
var
|
|
18171
|
+
var ConsentRequestWalletCategoryValidator = external_exports.enum([
|
|
18172
|
+
"Achievement",
|
|
18173
|
+
"Skill",
|
|
18174
|
+
"ID",
|
|
18175
|
+
"Learning History",
|
|
18176
|
+
"Work History",
|
|
18177
|
+
"Social Badges",
|
|
18178
|
+
"Membership",
|
|
18179
|
+
"Accomplishment",
|
|
18180
|
+
"Experiences",
|
|
18181
|
+
"Accommodation",
|
|
18182
|
+
"Family"
|
|
18183
|
+
]);
|
|
18184
|
+
var ConsentRequestPersonalFieldValidator = external_exports.enum([
|
|
18185
|
+
"name",
|
|
18186
|
+
"email",
|
|
18187
|
+
"phone",
|
|
18188
|
+
"birthDate",
|
|
18189
|
+
"country",
|
|
18190
|
+
"avatar"
|
|
18191
|
+
]);
|
|
18192
|
+
var ConsentRequestValidator = external_exports.object({
|
|
18193
|
+
read: external_exports.object({
|
|
18194
|
+
credentialCategories: external_exports.array(ConsentRequestWalletCategoryValidator).optional(),
|
|
18195
|
+
personalFields: external_exports.array(ConsentRequestPersonalFieldValidator).optional()
|
|
18196
|
+
}).optional(),
|
|
18197
|
+
write: external_exports.object({
|
|
18198
|
+
credentialCategories: external_exports.array(ConsentRequestWalletCategoryValidator).optional()
|
|
18199
|
+
}).optional(),
|
|
18200
|
+
reason: external_exports.string().optional()
|
|
18201
|
+
});
|
|
18202
|
+
var NormalizedConsentScopesValidator = external_exports.object({
|
|
18203
|
+
read: external_exports.object({
|
|
18204
|
+
credentialCategories: external_exports.array(ConsentRequestWalletCategoryValidator).default([]),
|
|
18205
|
+
personalFields: external_exports.array(ConsentRequestPersonalFieldValidator).default([])
|
|
18206
|
+
}),
|
|
18207
|
+
write: external_exports.object({
|
|
18208
|
+
credentialCategories: external_exports.array(ConsentRequestWalletCategoryValidator).default([])
|
|
18209
|
+
})
|
|
18210
|
+
});
|
|
18211
|
+
var CapturedTemplateRecordValidator = external_exports.object({
|
|
18212
|
+
alias: external_exports.string(),
|
|
18213
|
+
template: InlineCredentialTemplateValidator,
|
|
18214
|
+
version: external_exports.number().int().min(1),
|
|
18215
|
+
lastUsedAt: external_exports.string()
|
|
18216
|
+
}).passthrough();
|
|
18217
|
+
var CapturedConsentRecordValidator = external_exports.object({
|
|
18218
|
+
scopes: NormalizedConsentScopesValidator,
|
|
18219
|
+
reason: external_exports.string().optional(),
|
|
18220
|
+
lastUsedAt: external_exports.string()
|
|
18221
|
+
}).passthrough();
|
|
18222
|
+
var AppManifestValidator = external_exports.object({
|
|
18223
|
+
manifestVersion: external_exports.literal(1),
|
|
18224
|
+
appUrl: external_exports.string(),
|
|
18225
|
+
appKey: external_exports.string().max(200).optional(),
|
|
18226
|
+
suggestedName: external_exports.string().optional(),
|
|
18227
|
+
suggestedIconUrl: external_exports.string().optional(),
|
|
18228
|
+
permissions: external_exports.array(external_exports.string()).default([]),
|
|
18229
|
+
templates: external_exports.array(CapturedTemplateRecordValidator).default([]),
|
|
18230
|
+
consentRequests: external_exports.array(CapturedConsentRecordValidator).default([]),
|
|
18231
|
+
usedConsentContract: external_exports.boolean().optional(),
|
|
18232
|
+
featuresLaunched: external_exports.array(external_exports.string()).default([]),
|
|
18233
|
+
counterKeys: external_exports.array(external_exports.string()).default([]),
|
|
18234
|
+
usedLearnerContext: external_exports.boolean(),
|
|
18235
|
+
usedNotifications: external_exports.boolean(),
|
|
18236
|
+
firstCapturedAt: external_exports.string(),
|
|
18237
|
+
lastUpdatedAt: external_exports.string()
|
|
18238
|
+
}).passthrough();
|
|
18239
|
+
var AppManifestVersionStatusValidator = external_exports.enum(["draft", "active", "superseded"]);
|
|
18240
|
+
var AppManifestVersionValidator = external_exports.object({
|
|
18241
|
+
id: external_exports.string(),
|
|
18242
|
+
version: external_exports.number().int().min(1),
|
|
18243
|
+
manifestHash: external_exports.string(),
|
|
18244
|
+
manifest: AppManifestValidator,
|
|
18245
|
+
status: AppManifestVersionStatusValidator,
|
|
18246
|
+
createdAt: external_exports.string(),
|
|
18247
|
+
activatedAt: external_exports.string().optional()
|
|
18248
|
+
});
|
|
18249
|
+
var AppManifestStringDiffValidator = external_exports.object({
|
|
18250
|
+
added: external_exports.array(external_exports.string()),
|
|
18251
|
+
removed: external_exports.array(external_exports.string()),
|
|
18252
|
+
changed: external_exports.array(external_exports.string())
|
|
18253
|
+
});
|
|
18254
|
+
var AppManifestTemplateRefValidator = external_exports.object({
|
|
18255
|
+
alias: external_exports.string(),
|
|
18256
|
+
version: external_exports.number().int().min(1)
|
|
18257
|
+
});
|
|
18258
|
+
var AppManifestTemplateChangeValidator = external_exports.object({
|
|
18259
|
+
alias: external_exports.string(),
|
|
18260
|
+
fromVersion: external_exports.number().int().min(1),
|
|
18261
|
+
toVersion: external_exports.number().int().min(1)
|
|
18262
|
+
});
|
|
18263
|
+
var AppManifestDiffValidator = external_exports.object({
|
|
18264
|
+
permissions: AppManifestStringDiffValidator,
|
|
18265
|
+
templates: external_exports.object({
|
|
18266
|
+
added: external_exports.array(AppManifestTemplateRefValidator),
|
|
18267
|
+
removed: external_exports.array(AppManifestTemplateRefValidator),
|
|
18268
|
+
changed: external_exports.array(AppManifestTemplateChangeValidator)
|
|
18269
|
+
}),
|
|
18270
|
+
consentScopes: AppManifestStringDiffValidator,
|
|
18271
|
+
featurePaths: AppManifestStringDiffValidator,
|
|
18272
|
+
counterKeys: AppManifestStringDiffValidator,
|
|
18273
|
+
requiresReview: external_exports.boolean()
|
|
18274
|
+
});
|
|
18275
|
+
var UpsertConsentContractEventValidator = external_exports.object({
|
|
18276
|
+
type: external_exports.literal("upsert-consent-contract"),
|
|
18277
|
+
scopes: ConsentRequestValidator
|
|
18278
|
+
});
|
|
18279
|
+
var UpsertConsentContractResponseValidator = external_exports.object({
|
|
18280
|
+
contractUri: external_exports.string(),
|
|
18281
|
+
created: external_exports.boolean()
|
|
18282
|
+
});
|
|
18283
|
+
var AppEventValidator = external_exports.union([
|
|
17985
18284
|
SendCredentialEventValidator,
|
|
17986
18285
|
CheckCredentialEventValidator,
|
|
17987
18286
|
CheckIssuanceStatusEventValidator,
|
|
@@ -17991,7 +18290,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
17991
18290
|
SendNotificationEventValidator,
|
|
17992
18291
|
IncrementCounterEventValidator,
|
|
17993
18292
|
GetCounterEventValidator,
|
|
17994
|
-
GetCountersEventValidator
|
|
18293
|
+
GetCountersEventValidator,
|
|
18294
|
+
UpsertConsentContractEventValidator
|
|
17995
18295
|
]);
|
|
17996
18296
|
var AppEventInputValidator = external_exports.object({
|
|
17997
18297
|
listingId: external_exports.string(),
|
|
@@ -18070,6 +18370,20 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
18070
18370
|
__name2(this, "AuthSessionError");
|
|
18071
18371
|
}
|
|
18072
18372
|
};
|
|
18373
|
+
var UnsupportedSignInOperationError = class extends Error {
|
|
18374
|
+
static {
|
|
18375
|
+
__name(this, "UnsupportedSignInOperationError");
|
|
18376
|
+
}
|
|
18377
|
+
constructor(operation, providerType) {
|
|
18378
|
+
super(`${operation} is not supported by ${providerType}`);
|
|
18379
|
+
this.operation = operation;
|
|
18380
|
+
this.providerType = providerType;
|
|
18381
|
+
this.name = "UnsupportedSignInOperationError";
|
|
18382
|
+
}
|
|
18383
|
+
static {
|
|
18384
|
+
__name2(this, "UnsupportedSignInOperationError");
|
|
18385
|
+
}
|
|
18386
|
+
};
|
|
18073
18387
|
var ESCROW_PIN_LOCKED_MESSAGE2 = "Too many incorrect PIN attempts. You can still recover by waiting.";
|
|
18074
18388
|
var ESCROW_PIN_UNAVAILABLE_MESSAGE2 = "PIN recovery is not available for this account.";
|
|
18075
18389
|
var ESCROW_PIN_MISMATCH_PATTERN2 = /^Incorrect PIN\. (\d+) attempts left\.$/;
|
|
@@ -18216,12 +18530,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
18216
18530
|
}
|
|
18217
18531
|
return table;
|
|
18218
18532
|
})();
|
|
18219
|
-
var encodeBase64Url = /* @__PURE__ */ __name2((
|
|
18533
|
+
var encodeBase64Url = /* @__PURE__ */ __name2((bytes3) => {
|
|
18220
18534
|
let output = "";
|
|
18221
|
-
for (let index = 0; index <
|
|
18222
|
-
const first =
|
|
18223
|
-
const second =
|
|
18224
|
-
const third =
|
|
18535
|
+
for (let index = 0; index < bytes3.length; index += 3) {
|
|
18536
|
+
const first = bytes3[index];
|
|
18537
|
+
const second = bytes3[index + 1];
|
|
18538
|
+
const third = bytes3[index + 2];
|
|
18225
18539
|
output += BASE64URL_ALPHABET[first >> 2];
|
|
18226
18540
|
output += BASE64URL_ALPHABET[(first & 3) << 4 | (second ?? 0) >> 4];
|
|
18227
18541
|
if (second === void 0) break;
|
|
@@ -18262,8 +18576,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
18262
18576
|
}, "isCanonicalBase64Url");
|
|
18263
18577
|
var decodedBase64UrlByteLength = /* @__PURE__ */ __name2((value) => decodeBase64Url(value)?.length ?? null, "decodedBase64UrlByteLength");
|
|
18264
18578
|
var utf8ByteLength = /* @__PURE__ */ __name2((value) => new TextEncoder().encode(value).length, "utf8ByteLength");
|
|
18265
|
-
var canonicalBase64Url = /* @__PURE__ */ __name2((
|
|
18266
|
-
message: `must be canonical base64url for exactly ${
|
|
18579
|
+
var canonicalBase64Url = /* @__PURE__ */ __name2((bytes3) => external_exports.string().refine((value) => isCanonicalBase64Url(value, bytes3), {
|
|
18580
|
+
message: `must be canonical base64url for exactly ${bytes3} bytes`
|
|
18267
18581
|
}), "canonicalBase64Url");
|
|
18268
18582
|
var ShareLinkIdValidator = canonicalBase64Url(SHARE_LINK_ID_BYTES);
|
|
18269
18583
|
var ShareContentKeyValidator = canonicalBase64Url(SHARE_CONTENT_KEY_BYTES);
|
|
@@ -18499,6 +18813,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
18499
18813
|
version: safeVersion,
|
|
18500
18814
|
contentVersion: safeVersion,
|
|
18501
18815
|
status: ShareLinkStatusValidator,
|
|
18816
|
+
attachmentId: external_exports.string().uuid().nullable().optional(),
|
|
18817
|
+
attachmentChunkCount: external_exports.number().int().min(1).max(16).nullable().optional(),
|
|
18502
18818
|
contentState: ShareContentStateValidator,
|
|
18503
18819
|
createdAt: external_exports.iso.datetime(),
|
|
18504
18820
|
updatedAt: external_exports.iso.datetime(),
|
|
@@ -18522,6 +18838,43 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
18522
18838
|
contentUrl: external_exports.string().optional()
|
|
18523
18839
|
});
|
|
18524
18840
|
var clientRequestId = external_exports.string().uuid();
|
|
18841
|
+
var ShareLinkAttachmentValidator = external_exports.object({
|
|
18842
|
+
id: external_exports.string().uuid(),
|
|
18843
|
+
chunkCount: external_exports.number().int().min(1).max(16)
|
|
18844
|
+
}).strict();
|
|
18845
|
+
var attachmentChunkKey = {
|
|
18846
|
+
id: ShareLinkIdValidator,
|
|
18847
|
+
contentVersion: safeVersion,
|
|
18848
|
+
attachmentId: external_exports.string().uuid(),
|
|
18849
|
+
chunkIndex: external_exports.number().int().min(0).max(15)
|
|
18850
|
+
};
|
|
18851
|
+
var ShareLinkAttachmentChunkEnvelopeValidator = ShareEnvelopeValidator.refine(
|
|
18852
|
+
(value) => (decodedBase64UrlByteLength(value.ct) ?? Infinity) <= 256 * 1024 + SHARE_TAG_BYTES
|
|
18853
|
+
);
|
|
18854
|
+
var PutShareLinkAttachmentChunkInputValidator = external_exports.object({
|
|
18855
|
+
...attachmentChunkKey,
|
|
18856
|
+
chunkCount: external_exports.number().int().min(1).max(16),
|
|
18857
|
+
envelope: ShareLinkAttachmentChunkEnvelopeValidator,
|
|
18858
|
+
ownerEncryptedRecovery: ShareOwnerRecoveryValidator
|
|
18859
|
+
}).strict().refine((value) => value.chunkIndex < value.chunkCount);
|
|
18860
|
+
var GetShareLinkAttachmentChunkInputValidator = external_exports.object({
|
|
18861
|
+
...attachmentChunkKey,
|
|
18862
|
+
passcode: external_exports.string().min(4).max(64).optional(),
|
|
18863
|
+
accessToken: external_exports.string().min(1).max(2048).optional()
|
|
18864
|
+
}).strict();
|
|
18865
|
+
var ShareLinkAttachmentChunkOutputValidator = external_exports.object({
|
|
18866
|
+
...attachmentChunkKey,
|
|
18867
|
+
envelope: ShareLinkAttachmentChunkEnvelopeValidator,
|
|
18868
|
+
accessToken: external_exports.string().min(1).max(2048).optional()
|
|
18869
|
+
}).strict();
|
|
18870
|
+
var DeleteShareLinkAttachmentChunksInputValidator = external_exports.object({
|
|
18871
|
+
id: ShareLinkIdValidator,
|
|
18872
|
+
contentVersion: safeVersion,
|
|
18873
|
+
attachmentId: external_exports.string().uuid(),
|
|
18874
|
+
chunkCount: external_exports.number().int().min(1).max(16)
|
|
18875
|
+
}).strict();
|
|
18876
|
+
var PutShareLinkAttachmentChunkOutputValidator = external_exports.object({ ok: external_exports.literal(true) }).strict();
|
|
18877
|
+
var DeleteShareLinkAttachmentChunksOutputValidator = external_exports.object({ ok: external_exports.boolean() }).strict();
|
|
18525
18878
|
var CreateShareLinkInputValidator = external_exports.object({
|
|
18526
18879
|
id: ShareLinkIdValidator,
|
|
18527
18880
|
clientRequestId,
|
|
@@ -18533,7 +18886,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
18533
18886
|
selectedCount: external_exports.number().int().min(1).max(MAX_SELECTED_CREDENTIALS),
|
|
18534
18887
|
contentVersion: external_exports.literal(1),
|
|
18535
18888
|
envelope: ShareEnvelopeValidator,
|
|
18536
|
-
ownerEncryptedRecovery: ShareOwnerRecoveryValidator
|
|
18889
|
+
ownerEncryptedRecovery: ShareOwnerRecoveryValidator,
|
|
18890
|
+
attachment: ShareLinkAttachmentValidator.optional()
|
|
18537
18891
|
}).strict();
|
|
18538
18892
|
var UpdateShareLinkInputValidator = external_exports.object({
|
|
18539
18893
|
id: ShareLinkIdValidator,
|
|
@@ -18548,7 +18902,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
18548
18902
|
contentVersion: safeVersion.optional(),
|
|
18549
18903
|
selectedCount: external_exports.number().int().min(1).max(MAX_SELECTED_CREDENTIALS).optional(),
|
|
18550
18904
|
envelope: ShareEnvelopeValidator.optional(),
|
|
18551
|
-
ownerEncryptedRecovery: ShareOwnerRecoveryValidator.optional()
|
|
18905
|
+
ownerEncryptedRecovery: ShareOwnerRecoveryValidator.optional(),
|
|
18906
|
+
attachment: ShareLinkAttachmentValidator.optional()
|
|
18552
18907
|
}).strict().superRefine((value, ctx) => {
|
|
18553
18908
|
const provided = [
|
|
18554
18909
|
value.contentVersion,
|
|
@@ -18562,6 +18917,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
18562
18917
|
message: "content replacement requires contentVersion, selectedCount, envelope and ownerEncryptedRecovery together"
|
|
18563
18918
|
});
|
|
18564
18919
|
}
|
|
18920
|
+
if (value.attachment !== void 0 && provided !== 4) {
|
|
18921
|
+
ctx.addIssue({ code: "custom", message: "attachment requires a content replacement" });
|
|
18922
|
+
}
|
|
18565
18923
|
});
|
|
18566
18924
|
var ShareLinkIdInputValidator = external_exports.object({ id: ShareLinkIdValidator }).strict();
|
|
18567
18925
|
var ShareLinkOperationKeyInputValidator = external_exports.object({ id: ShareLinkIdValidator, operationId: external_exports.string().uuid() }).strict();
|
|
@@ -18818,37 +19176,37 @@ var DEFAULT_KDF_PARAMS = {
|
|
|
18818
19176
|
parallelism: ARGON2_PARALLELISM
|
|
18819
19177
|
};
|
|
18820
19178
|
function bufferToBase64(buf) {
|
|
18821
|
-
const
|
|
19179
|
+
const bytes3 = new Uint8Array(buf);
|
|
18822
19180
|
let binary = "";
|
|
18823
|
-
for (let i = 0; i <
|
|
18824
|
-
binary += String.fromCharCode(
|
|
19181
|
+
for (let i = 0; i < bytes3.byteLength; i++) {
|
|
19182
|
+
binary += String.fromCharCode(bytes3[i]);
|
|
18825
19183
|
}
|
|
18826
19184
|
return btoa(binary);
|
|
18827
19185
|
}
|
|
18828
19186
|
__name(bufferToBase64, "bufferToBase64");
|
|
18829
19187
|
function base64ToBuffer(b64) {
|
|
18830
19188
|
const binary = atob(b64);
|
|
18831
|
-
const
|
|
19189
|
+
const bytes3 = new Uint8Array(binary.length);
|
|
18832
19190
|
for (let i = 0; i < binary.length; i++) {
|
|
18833
|
-
|
|
19191
|
+
bytes3[i] = binary.charCodeAt(i);
|
|
18834
19192
|
}
|
|
18835
|
-
return
|
|
19193
|
+
return bytes3;
|
|
18836
19194
|
}
|
|
18837
19195
|
__name(base64ToBuffer, "base64ToBuffer");
|
|
18838
|
-
function hexToBytes(
|
|
18839
|
-
const
|
|
18840
|
-
for (let i = 0; i <
|
|
18841
|
-
|
|
19196
|
+
function hexToBytes(hex2) {
|
|
19197
|
+
const bytes3 = new Uint8Array(hex2.length / 2);
|
|
19198
|
+
for (let i = 0; i < hex2.length; i += 2) {
|
|
19199
|
+
bytes3[i / 2] = parseInt(hex2.slice(i, i + 2), 16);
|
|
18842
19200
|
}
|
|
18843
|
-
return
|
|
19201
|
+
return bytes3;
|
|
18844
19202
|
}
|
|
18845
19203
|
__name(hexToBytes, "hexToBytes");
|
|
18846
|
-
function bytesToHex(
|
|
18847
|
-
return Array.from(
|
|
19204
|
+
function bytesToHex(bytes3) {
|
|
19205
|
+
return Array.from(bytes3).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
18848
19206
|
}
|
|
18849
19207
|
__name(bytesToHex, "bytesToHex");
|
|
18850
19208
|
async function deriveKeyFromPassword(password, salt, params = DEFAULT_KDF_PARAMS) {
|
|
18851
|
-
const
|
|
19209
|
+
const hash2 = await argon2id({
|
|
18852
19210
|
password,
|
|
18853
19211
|
salt,
|
|
18854
19212
|
iterations: params.timeCost,
|
|
@@ -18857,7 +19215,7 @@ async function deriveKeyFromPassword(password, salt, params = DEFAULT_KDF_PARAMS
|
|
|
18857
19215
|
hashLength: ARGON2_HASH_LENGTH,
|
|
18858
19216
|
outputType: "binary"
|
|
18859
19217
|
});
|
|
18860
|
-
return Uint8Array.from(
|
|
19218
|
+
return Uint8Array.from(hash2);
|
|
18861
19219
|
}
|
|
18862
19220
|
__name(deriveKeyFromPassword, "deriveKeyFromPassword");
|
|
18863
19221
|
async function encryptWithPassword(plaintext, password) {
|
|
@@ -19011,21 +19369,21 @@ async function getOrCreateMasterKey() {
|
|
|
19011
19369
|
}
|
|
19012
19370
|
__name(getOrCreateMasterKey, "getOrCreateMasterKey");
|
|
19013
19371
|
function bufferToBase642(buf) {
|
|
19014
|
-
const
|
|
19372
|
+
const bytes3 = new Uint8Array(buf);
|
|
19015
19373
|
let binary = "";
|
|
19016
|
-
for (let i = 0; i <
|
|
19017
|
-
binary += String.fromCharCode(
|
|
19374
|
+
for (let i = 0; i < bytes3.byteLength; i++) {
|
|
19375
|
+
binary += String.fromCharCode(bytes3[i]);
|
|
19018
19376
|
}
|
|
19019
19377
|
return btoa(binary);
|
|
19020
19378
|
}
|
|
19021
19379
|
__name(bufferToBase642, "bufferToBase64");
|
|
19022
19380
|
function base64ToBuffer2(b64) {
|
|
19023
19381
|
const binary = atob(b64);
|
|
19024
|
-
const
|
|
19382
|
+
const bytes3 = new Uint8Array(binary.length);
|
|
19025
19383
|
for (let i = 0; i < binary.length; i++) {
|
|
19026
|
-
|
|
19384
|
+
bytes3[i] = binary.charCodeAt(i);
|
|
19027
19385
|
}
|
|
19028
|
-
return
|
|
19386
|
+
return bytes3.buffer;
|
|
19029
19387
|
}
|
|
19030
19388
|
__name(base64ToBuffer2, "base64ToBuffer");
|
|
19031
19389
|
async function encryptShare(share, id) {
|
|
@@ -19433,21 +19791,21 @@ async function getWordlist() {
|
|
|
19433
19791
|
return wordlistPromise;
|
|
19434
19792
|
}
|
|
19435
19793
|
__name(getWordlist, "getWordlist");
|
|
19436
|
-
function bytesToBits(
|
|
19437
|
-
return Array.from(
|
|
19794
|
+
function bytesToBits(bytes3) {
|
|
19795
|
+
return Array.from(bytes3).map((b) => b.toString(2).padStart(8, "0")).join("");
|
|
19438
19796
|
}
|
|
19439
19797
|
__name(bytesToBits, "bytesToBits");
|
|
19440
19798
|
function bitsToBytes(bits) {
|
|
19441
|
-
const
|
|
19442
|
-
for (let i = 0; i <
|
|
19443
|
-
|
|
19799
|
+
const bytes3 = new Uint8Array(Math.ceil(bits.length / 8));
|
|
19800
|
+
for (let i = 0; i < bytes3.length; i++) {
|
|
19801
|
+
bytes3[i] = parseInt(bits.slice(i * 8, (i + 1) * 8).padEnd(8, "0"), 2);
|
|
19444
19802
|
}
|
|
19445
|
-
return
|
|
19803
|
+
return bytes3;
|
|
19446
19804
|
}
|
|
19447
19805
|
__name(bitsToBytes, "bitsToBytes");
|
|
19448
19806
|
async function computeChecksum(data) {
|
|
19449
|
-
const
|
|
19450
|
-
const hashBits = bytesToBits(new Uint8Array(
|
|
19807
|
+
const hash2 = await crypto.subtle.digest("SHA-256", data);
|
|
19808
|
+
const hashBits = bytesToBits(new Uint8Array(hash2));
|
|
19451
19809
|
const checksumLength = Math.floor(data.length / 4);
|
|
19452
19810
|
return hashBits.slice(0, checksumLength);
|
|
19453
19811
|
}
|
|
@@ -19480,12 +19838,12 @@ async function recoveryPhraseToShare(phrase) {
|
|
|
19480
19838
|
bits += index.toString(2).padStart(11, "0");
|
|
19481
19839
|
}
|
|
19482
19840
|
let dataByteCount = 0;
|
|
19483
|
-
for (let
|
|
19484
|
-
const checksumBits2 = Math.floor(
|
|
19485
|
-
const totalBits =
|
|
19841
|
+
for (let bytes3 = 1; bytes3 <= 64; bytes3++) {
|
|
19842
|
+
const checksumBits2 = Math.floor(bytes3 / 4);
|
|
19843
|
+
const totalBits = bytes3 * 8 + checksumBits2;
|
|
19486
19844
|
const wordsNeeded = Math.ceil(totalBits / 11);
|
|
19487
19845
|
if (wordsNeeded === words.length) {
|
|
19488
|
-
dataByteCount =
|
|
19846
|
+
dataByteCount = bytes3;
|
|
19489
19847
|
} else if (wordsNeeded > words.length) {
|
|
19490
19848
|
break;
|
|
19491
19849
|
}
|
|
@@ -19779,9 +20137,9 @@ __name(createSSSKeyManager, "createSSSKeyManager");
|
|
|
19779
20137
|
var EMAIL_RELAY_ENVELOPE_VERSION = 1;
|
|
19780
20138
|
var EMAIL_RELAY_ALGORITHM = "P-256-HKDF-SHA256-AES-256-GCM";
|
|
19781
20139
|
var encodeUtf8 = /* @__PURE__ */ __name((value) => {
|
|
19782
|
-
const
|
|
19783
|
-
const copy = new Uint8Array(new ArrayBuffer(
|
|
19784
|
-
copy.set(
|
|
20140
|
+
const bytes3 = new TextEncoder().encode(value);
|
|
20141
|
+
const copy = new Uint8Array(new ArrayBuffer(bytes3.byteLength));
|
|
20142
|
+
copy.set(bytes3);
|
|
19785
20143
|
return copy;
|
|
19786
20144
|
}, "encodeUtf8");
|
|
19787
20145
|
var EMAIL_RELAY_INFO = encodeUtf8("learncard-email-relay-v1");
|
|
@@ -19800,7 +20158,7 @@ var parseBranding = /* @__PURE__ */ __name((value) => {
|
|
|
19800
20158
|
if (value === void 0) return void 0;
|
|
19801
20159
|
if (!isRecord(value)) throw new Error("Invalid email relay branding");
|
|
19802
20160
|
const branding = {};
|
|
19803
|
-
const
|
|
20161
|
+
const keys2 = [
|
|
19804
20162
|
"brandName",
|
|
19805
20163
|
"logoUrl",
|
|
19806
20164
|
"logoAlt",
|
|
@@ -19812,7 +20170,7 @@ var parseBranding = /* @__PURE__ */ __name((value) => {
|
|
|
19812
20170
|
"fromDomain",
|
|
19813
20171
|
"copyrightHolder"
|
|
19814
20172
|
];
|
|
19815
|
-
for (const key of
|
|
20173
|
+
for (const key of keys2) {
|
|
19816
20174
|
const field = value[key];
|
|
19817
20175
|
if (field === void 0) continue;
|
|
19818
20176
|
if (typeof field !== "string" || field.length > 2048) {
|
|
@@ -19865,7 +20223,7 @@ var parseEmailRelayPlaintext = /* @__PURE__ */ __name((value) => {
|
|
|
19865
20223
|
branding: parseBranding(value.branding)
|
|
19866
20224
|
};
|
|
19867
20225
|
}, "parseEmailRelayPlaintext");
|
|
19868
|
-
var getAad = /* @__PURE__ */ __name((
|
|
20226
|
+
var getAad = /* @__PURE__ */ __name((envelope2) => encodeUtf8(`${envelope2.version}|${envelope2.algorithm}|${envelope2.keyId}`), "getAad");
|
|
19869
20227
|
var deriveAesKey = /* @__PURE__ */ __name(async (sharedSecret, salt, usage) => {
|
|
19870
20228
|
const keyMaterial = await crypto.subtle.importKey("raw", sharedSecret, "HKDF", false, [
|
|
19871
20229
|
"deriveKey"
|
|
@@ -19937,7 +20295,7 @@ var encryptEmailRelayPayload = /* @__PURE__ */ __name(async (input, publicKeyBas
|
|
|
19937
20295
|
};
|
|
19938
20296
|
}, "encryptEmailRelayPayload");
|
|
19939
20297
|
var decryptEmailRelayPayload = /* @__PURE__ */ __name(async (value, privateKeyBase64) => {
|
|
19940
|
-
const
|
|
20298
|
+
const envelope2 = parseEmailRelayEnvelope(value);
|
|
19941
20299
|
const privateKey = await crypto.subtle.importKey(
|
|
19942
20300
|
"pkcs8",
|
|
19943
20301
|
base64ToBuffer(privateKeyBase64.trim()).buffer,
|
|
@@ -19947,7 +20305,7 @@ var decryptEmailRelayPayload = /* @__PURE__ */ __name(async (value, privateKeyBa
|
|
|
19947
20305
|
);
|
|
19948
20306
|
const ephemeralPublicKey = await crypto.subtle.importKey(
|
|
19949
20307
|
"raw",
|
|
19950
|
-
base64ToBuffer(
|
|
20308
|
+
base64ToBuffer(envelope2.ephemeralPublicKey).buffer,
|
|
19951
20309
|
{ name: "ECDH", namedCurve: "P-256" },
|
|
19952
20310
|
false,
|
|
19953
20311
|
[]
|
|
@@ -19957,13 +20315,13 @@ var decryptEmailRelayPayload = /* @__PURE__ */ __name(async (value, privateKeyBa
|
|
|
19957
20315
|
privateKey,
|
|
19958
20316
|
256
|
|
19959
20317
|
);
|
|
19960
|
-
const salt = base64ToBuffer(
|
|
19961
|
-
const iv = base64ToBuffer(
|
|
20318
|
+
const salt = base64ToBuffer(envelope2.salt);
|
|
20319
|
+
const iv = base64ToBuffer(envelope2.iv);
|
|
19962
20320
|
const aesKey = await deriveAesKey(sharedSecret, salt, "decrypt");
|
|
19963
20321
|
const decrypted = await crypto.subtle.decrypt(
|
|
19964
|
-
{ name: "AES-GCM", iv, additionalData: getAad(
|
|
20322
|
+
{ name: "AES-GCM", iv, additionalData: getAad(envelope2) },
|
|
19965
20323
|
aesKey,
|
|
19966
|
-
base64ToBuffer(
|
|
20324
|
+
base64ToBuffer(envelope2.ciphertext)
|
|
19967
20325
|
);
|
|
19968
20326
|
const parsed = JSON.parse(new TextDecoder().decode(decrypted));
|
|
19969
20327
|
return parseEmailRelayPlaintext(parsed);
|
|
@@ -19975,10 +20333,11 @@ var ESCROW_ALGORITHM = "P-256-HKDF-SHA256-AES-256-GCM";
|
|
|
19975
20333
|
var ESCROW_BLOB_INFO = "learncard-escrow-blob-v1";
|
|
19976
20334
|
var ESCROW_RELEASE_INFO = "learncard-escrow-release-v1";
|
|
19977
20335
|
var ESCROW_CLIENT_KEY_ID = "client";
|
|
20336
|
+
var RECOVERY_LANGUAGES = ["en", "es", "fr", "ar"];
|
|
19978
20337
|
var encodeUtf82 = /* @__PURE__ */ __name((value) => {
|
|
19979
|
-
const
|
|
19980
|
-
const copy = new Uint8Array(new ArrayBuffer(
|
|
19981
|
-
copy.set(
|
|
20338
|
+
const bytes3 = new TextEncoder().encode(value);
|
|
20339
|
+
const copy = new Uint8Array(new ArrayBuffer(bytes3.byteLength));
|
|
20340
|
+
copy.set(bytes3);
|
|
19982
20341
|
return copy;
|
|
19983
20342
|
}, "encodeUtf8");
|
|
19984
20343
|
var isRecord2 = /* @__PURE__ */ __name((value) => typeof value === "object" && value !== null && !Array.isArray(value), "isRecord");
|
|
@@ -20014,6 +20373,22 @@ var parseEscrowBlobPlaintext = /* @__PURE__ */ __name((value) => {
|
|
|
20014
20373
|
if (typeof value.shareVersion !== "number" || !Number.isInteger(value.shareVersion) || value.shareVersion <= 0) {
|
|
20015
20374
|
throw new Error("Invalid escrow shareVersion");
|
|
20016
20375
|
}
|
|
20376
|
+
if (value.recoveryEmail !== void 0 !== (value.recoveryLanguage !== void 0)) {
|
|
20377
|
+
throw new Error("Invalid escrow recoveryEmail");
|
|
20378
|
+
}
|
|
20379
|
+
let recoveryContact = {};
|
|
20380
|
+
if (value.recoveryEmail !== void 0) {
|
|
20381
|
+
const email = requireString2(value, "recoveryEmail", { min: 3, max: 254 }).trim().toLowerCase();
|
|
20382
|
+
const at = email.split("@");
|
|
20383
|
+
if (!/^[\x21-\x7e]+$/.test(email) || at.length !== 2 || at[0].length === 0 || at[1].length === 0 || !at[1].includes(".") || at[1].startsWith(".") || at[1].endsWith(".")) {
|
|
20384
|
+
throw new Error("Invalid escrow recoveryEmail");
|
|
20385
|
+
}
|
|
20386
|
+
const language = requireString2(value, "recoveryLanguage", { min: 2, max: 2 });
|
|
20387
|
+
if (!RECOVERY_LANGUAGES.includes(language)) {
|
|
20388
|
+
throw new Error("Invalid escrow recoveryLanguage");
|
|
20389
|
+
}
|
|
20390
|
+
recoveryContact = { recoveryEmail: email, recoveryLanguage: language };
|
|
20391
|
+
}
|
|
20017
20392
|
return {
|
|
20018
20393
|
version: ESCROW_ENVELOPE_VERSION,
|
|
20019
20394
|
recoveryShare: requireString2(value, "recoveryShare", {
|
|
@@ -20029,7 +20404,8 @@ var parseEscrowBlobPlaintext = /* @__PURE__ */ __name((value) => {
|
|
|
20029
20404
|
max: 64,
|
|
20030
20405
|
pattern: /^[0-9a-f]{64}$/i
|
|
20031
20406
|
}).toLowerCase()
|
|
20032
|
-
} : {}
|
|
20407
|
+
} : {},
|
|
20408
|
+
...recoveryContact
|
|
20033
20409
|
};
|
|
20034
20410
|
}, "parseEscrowBlobPlaintext");
|
|
20035
20411
|
var parseEscrowReleasePlaintext = /* @__PURE__ */ __name((value) => {
|
|
@@ -20040,7 +20416,7 @@ var parseEscrowReleasePlaintext = /* @__PURE__ */ __name((value) => {
|
|
|
20040
20416
|
holdId: requireString2(value, "holdId", { max: 128, pattern: /^[A-Za-z0-9._-]+$/ })
|
|
20041
20417
|
};
|
|
20042
20418
|
}, "parseEscrowReleasePlaintext");
|
|
20043
|
-
var getAad2 = /* @__PURE__ */ __name((
|
|
20419
|
+
var getAad2 = /* @__PURE__ */ __name((envelope2) => encodeUtf82(`${envelope2.version}|${envelope2.algorithm}|${envelope2.keyId}`), "getAad");
|
|
20044
20420
|
var deriveAesKey2 = /* @__PURE__ */ __name(async (sharedSecret, salt, usage, info) => {
|
|
20045
20421
|
const keyMaterial = await crypto.subtle.importKey("raw", sharedSecret, "HKDF", false, [
|
|
20046
20422
|
"deriveKey"
|
|
@@ -20111,7 +20487,7 @@ var encryptToRecipient = /* @__PURE__ */ __name(async (plaintextJson, spki, keyI
|
|
|
20111
20487
|
};
|
|
20112
20488
|
}, "encryptToRecipient");
|
|
20113
20489
|
var decryptFromEnvelope = /* @__PURE__ */ __name(async (value, pkcs8, info) => {
|
|
20114
|
-
const
|
|
20490
|
+
const envelope2 = parseEscrowEnvelope(value);
|
|
20115
20491
|
const privateKey = await crypto.subtle.importKey(
|
|
20116
20492
|
"pkcs8",
|
|
20117
20493
|
base64ToBuffer(pkcs8.trim()),
|
|
@@ -20121,7 +20497,7 @@ var decryptFromEnvelope = /* @__PURE__ */ __name(async (value, pkcs8, info) => {
|
|
|
20121
20497
|
);
|
|
20122
20498
|
const ephemeralPublicKey = await crypto.subtle.importKey(
|
|
20123
20499
|
"raw",
|
|
20124
|
-
base64ToBuffer(
|
|
20500
|
+
base64ToBuffer(envelope2.ephemeralPublicKey),
|
|
20125
20501
|
{ name: "ECDH", namedCurve: "P-256" },
|
|
20126
20502
|
false,
|
|
20127
20503
|
[]
|
|
@@ -20131,13 +20507,13 @@ var decryptFromEnvelope = /* @__PURE__ */ __name(async (value, pkcs8, info) => {
|
|
|
20131
20507
|
privateKey,
|
|
20132
20508
|
256
|
|
20133
20509
|
);
|
|
20134
|
-
const salt = base64ToBuffer(
|
|
20135
|
-
const iv = base64ToBuffer(
|
|
20510
|
+
const salt = base64ToBuffer(envelope2.salt);
|
|
20511
|
+
const iv = base64ToBuffer(envelope2.iv);
|
|
20136
20512
|
const aesKey = await deriveAesKey2(sharedSecret, salt, "decrypt", info);
|
|
20137
20513
|
const decrypted = await crypto.subtle.decrypt(
|
|
20138
|
-
{ name: "AES-GCM", iv, additionalData: getAad2(
|
|
20514
|
+
{ name: "AES-GCM", iv, additionalData: getAad2(envelope2) },
|
|
20139
20515
|
aesKey,
|
|
20140
|
-
base64ToBuffer(
|
|
20516
|
+
base64ToBuffer(envelope2.ciphertext)
|
|
20141
20517
|
);
|
|
20142
20518
|
const parsed = JSON.parse(new TextDecoder().decode(decrypted));
|
|
20143
20519
|
return parsed;
|
|
@@ -20151,8 +20527,8 @@ var encryptEscrowBlob = /* @__PURE__ */ __name(async (input, enclavePublicKeySpk
|
|
|
20151
20527
|
ESCROW_BLOB_INFO
|
|
20152
20528
|
);
|
|
20153
20529
|
}, "encryptEscrowBlob");
|
|
20154
|
-
var decryptEscrowBlob = /* @__PURE__ */ __name(async (
|
|
20155
|
-
await decryptFromEnvelope(
|
|
20530
|
+
var decryptEscrowBlob = /* @__PURE__ */ __name(async (envelope2, enclavePrivateKeyPkcs8B64) => parseEscrowBlobPlaintext(
|
|
20531
|
+
await decryptFromEnvelope(envelope2, enclavePrivateKeyPkcs8B64, ESCROW_BLOB_INFO)
|
|
20156
20532
|
), "decryptEscrowBlob");
|
|
20157
20533
|
var sealEscrowRelease = /* @__PURE__ */ __name(async (input, clientEphemeralPublicKeySpkiB64) => {
|
|
20158
20534
|
const plaintext = parseEscrowReleasePlaintext({ ...input, version: ESCROW_ENVELOPE_VERSION });
|
|
@@ -20163,10 +20539,408 @@ var sealEscrowRelease = /* @__PURE__ */ __name(async (input, clientEphemeralPubl
|
|
|
20163
20539
|
ESCROW_RELEASE_INFO
|
|
20164
20540
|
);
|
|
20165
20541
|
}, "sealEscrowRelease");
|
|
20166
|
-
var openEscrowRelease = /* @__PURE__ */ __name(async (
|
|
20167
|
-
await decryptFromEnvelope(
|
|
20542
|
+
var openEscrowRelease = /* @__PURE__ */ __name(async (envelope2, clientEphemeralPrivateKeyPkcs8B64) => parseEscrowReleasePlaintext(
|
|
20543
|
+
await decryptFromEnvelope(envelope2, clientEphemeralPrivateKeyPkcs8B64, ESCROW_RELEASE_INFO)
|
|
20168
20544
|
), "openEscrowRelease");
|
|
20169
20545
|
|
|
20546
|
+
// src/escrow-enrollment-intent.ts
|
|
20547
|
+
import { ExtendedPoint, getPublicKeyAsync, signAsync } from "@noble/ed25519";
|
|
20548
|
+
var ESCROW_ENROLLMENT_INTENT_DOMAIN = "learncard-escrow-enrollment-intent-v2\0";
|
|
20549
|
+
var BASE58 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
20550
|
+
var FIELDS = [
|
|
20551
|
+
"version",
|
|
20552
|
+
"tenant",
|
|
20553
|
+
"did",
|
|
20554
|
+
"authorityGeneration",
|
|
20555
|
+
"expectedEnrollmentVersion",
|
|
20556
|
+
"action",
|
|
20557
|
+
"sourceBlobIdentity",
|
|
20558
|
+
"targetBlobIdentity",
|
|
20559
|
+
"pinAction",
|
|
20560
|
+
"shareVersion",
|
|
20561
|
+
"enrollmentEpoch",
|
|
20562
|
+
"requestId",
|
|
20563
|
+
"allowRewrap",
|
|
20564
|
+
"recoveryEmail",
|
|
20565
|
+
"recoveryLanguage"
|
|
20566
|
+
];
|
|
20567
|
+
var ACTIONS = ["enroll", "replace", "disable", "carry"];
|
|
20568
|
+
var PIN_ACTIONS = ["set", "change", "clear", "keep"];
|
|
20569
|
+
var RECOVERY_LANGUAGES2 = ["en", "es", "fr", "ar"];
|
|
20570
|
+
var requireIntent = /* @__PURE__ */ __name((condition) => {
|
|
20571
|
+
if (!condition) throw new Error("Invalid escrow enrollment intent");
|
|
20572
|
+
}, "requireIntent");
|
|
20573
|
+
var matches = /* @__PURE__ */ __name((value, pattern) => typeof value === "string" && pattern.exec(value)?.[0] === value, "matches");
|
|
20574
|
+
var utf8 = /* @__PURE__ */ __name((value) => new TextEncoder().encode(value), "utf8");
|
|
20575
|
+
var integer = /* @__PURE__ */ __name((value, width) => {
|
|
20576
|
+
requireIntent(
|
|
20577
|
+
Number.isSafeInteger(value) && value >= 0 && (width === 8 || value <= 4294967295)
|
|
20578
|
+
);
|
|
20579
|
+
const bytes3 = new Uint8Array(width);
|
|
20580
|
+
const view = new DataView(bytes3.buffer);
|
|
20581
|
+
if (width === 4) view.setUint32(0, value, false);
|
|
20582
|
+
else view.setBigUint64(0, BigInt(value), false);
|
|
20583
|
+
return bytes3;
|
|
20584
|
+
}, "integer");
|
|
20585
|
+
var join = /* @__PURE__ */ __name((fields) => {
|
|
20586
|
+
const result = new Uint8Array(fields.reduce((length, field) => length + field.length, 0));
|
|
20587
|
+
let offset = 0;
|
|
20588
|
+
for (const field of fields) {
|
|
20589
|
+
result.set(field, offset);
|
|
20590
|
+
offset += field.length;
|
|
20591
|
+
}
|
|
20592
|
+
return result;
|
|
20593
|
+
}, "join");
|
|
20594
|
+
var hashBytes = /* @__PURE__ */ __name((value) => {
|
|
20595
|
+
if (value === null) return new Uint8Array();
|
|
20596
|
+
requireIntent(matches(value, /^[0-9a-f]{64}$/));
|
|
20597
|
+
return new Uint8Array(hexToBytes(value));
|
|
20598
|
+
}, "hashBytes");
|
|
20599
|
+
var didPublicKey = /* @__PURE__ */ __name((did) => {
|
|
20600
|
+
requireIntent(typeof did === "string" && did.startsWith("did:key:z") && did.length === 56);
|
|
20601
|
+
let value = 0n;
|
|
20602
|
+
for (const char of did.slice(9)) {
|
|
20603
|
+
const digit = BASE58.indexOf(char);
|
|
20604
|
+
requireIntent(digit >= 0);
|
|
20605
|
+
value = value * 58n + BigInt(digit);
|
|
20606
|
+
}
|
|
20607
|
+
const bytes3 = new Uint8Array(34);
|
|
20608
|
+
for (let i = 33; i >= 0; i--) {
|
|
20609
|
+
bytes3[i] = Number(value & 255n);
|
|
20610
|
+
value >>= 8n;
|
|
20611
|
+
}
|
|
20612
|
+
requireIntent(value === 0n && bytes3[0] === 237 && bytes3[1] === 1);
|
|
20613
|
+
const key = bytes3.slice(2);
|
|
20614
|
+
try {
|
|
20615
|
+
requireIntent(!ExtendedPoint.fromHex(key, false).isSmallOrder());
|
|
20616
|
+
} catch {
|
|
20617
|
+
throw new Error("Invalid escrow enrollment intent");
|
|
20618
|
+
}
|
|
20619
|
+
return key;
|
|
20620
|
+
}, "didPublicKey");
|
|
20621
|
+
var encodeEscrowEnrollmentIntent = /* @__PURE__ */ __name((intent) => {
|
|
20622
|
+
requireIntent(typeof intent === "object" && intent !== null && !Array.isArray(intent));
|
|
20623
|
+
requireIntent(
|
|
20624
|
+
Object.keys(intent).length === FIELDS.length && FIELDS.every((field) => Object.prototype.hasOwnProperty.call(intent, field))
|
|
20625
|
+
);
|
|
20626
|
+
requireIntent(intent.version === 2 && typeof intent.allowRewrap === "boolean");
|
|
20627
|
+
requireIntent(matches(intent.tenant, /^[A-Za-z0-9_-]{1,128}$/));
|
|
20628
|
+
requireIntent(matches(intent.authorityGeneration, /^[A-Za-z0-9_-]{1,128}$/));
|
|
20629
|
+
requireIntent(matches(intent.requestId, /^[A-Za-z0-9._-]{1,112}$/));
|
|
20630
|
+
didPublicKey(intent.did);
|
|
20631
|
+
const action = ACTIONS.indexOf(intent.action);
|
|
20632
|
+
const pin = PIN_ACTIONS.indexOf(intent.pinAction);
|
|
20633
|
+
requireIntent(action >= 0 && pin >= 0 && intent.shareVersion > 0 && intent.enrollmentEpoch > 0);
|
|
20634
|
+
const source = hashBytes(intent.sourceBlobIdentity);
|
|
20635
|
+
const target = hashBytes(intent.targetBlobIdentity);
|
|
20636
|
+
if (intent.action === "enroll") requireIntent(source.length === 0 && target.length === 32);
|
|
20637
|
+
else if (intent.action === "disable")
|
|
20638
|
+
requireIntent(
|
|
20639
|
+
source.length === 32 && target.length === 0 && intent.pinAction === "keep" && !intent.allowRewrap
|
|
20640
|
+
);
|
|
20641
|
+
else
|
|
20642
|
+
requireIntent(
|
|
20643
|
+
source.length === 32 && target.length === 32 && intent.sourceBlobIdentity !== intent.targetBlobIdentity
|
|
20644
|
+
);
|
|
20645
|
+
if (intent.action === "carry") requireIntent(intent.pinAction === "keep");
|
|
20646
|
+
if (intent.recoveryEmail === null) {
|
|
20647
|
+
requireIntent(
|
|
20648
|
+
intent.recoveryLanguage === null && (intent.action === "disable" || intent.action === "carry")
|
|
20649
|
+
);
|
|
20650
|
+
} else {
|
|
20651
|
+
requireIntent(intent.action === "enroll" || intent.action === "replace");
|
|
20652
|
+
requireIntent(
|
|
20653
|
+
matches(intent.recoveryEmail, /^[\x21-\x7e]{3,254}$/) && intent.recoveryEmail === intent.recoveryEmail.trim().toLowerCase()
|
|
20654
|
+
);
|
|
20655
|
+
const at = intent.recoveryEmail.split("@");
|
|
20656
|
+
requireIntent(
|
|
20657
|
+
at.length === 2 && at[0].length > 0 && at[1].length > 0 && at[1].includes(".") && !at[1].startsWith(".") && !at[1].endsWith(".")
|
|
20658
|
+
);
|
|
20659
|
+
requireIntent(
|
|
20660
|
+
intent.recoveryLanguage !== null && RECOVERY_LANGUAGES2.includes(intent.recoveryLanguage)
|
|
20661
|
+
);
|
|
20662
|
+
}
|
|
20663
|
+
const fields = [
|
|
20664
|
+
integer(intent.version, 4),
|
|
20665
|
+
utf8(intent.tenant),
|
|
20666
|
+
utf8(intent.did),
|
|
20667
|
+
utf8(intent.authorityGeneration),
|
|
20668
|
+
integer(intent.expectedEnrollmentVersion, 8),
|
|
20669
|
+
Uint8Array.of(action),
|
|
20670
|
+
source,
|
|
20671
|
+
target,
|
|
20672
|
+
Uint8Array.of(pin),
|
|
20673
|
+
integer(intent.shareVersion, 4),
|
|
20674
|
+
integer(intent.enrollmentEpoch, 8),
|
|
20675
|
+
utf8(intent.requestId),
|
|
20676
|
+
Uint8Array.of(Number(intent.allowRewrap)),
|
|
20677
|
+
intent.recoveryEmail === null ? new Uint8Array() : utf8(intent.recoveryEmail),
|
|
20678
|
+
intent.recoveryLanguage === null ? new Uint8Array() : utf8(intent.recoveryLanguage)
|
|
20679
|
+
];
|
|
20680
|
+
return join([
|
|
20681
|
+
utf8(ESCROW_ENROLLMENT_INTENT_DOMAIN),
|
|
20682
|
+
...fields.flatMap((field) => [integer(field.length, 4), field])
|
|
20683
|
+
]);
|
|
20684
|
+
}, "encodeEscrowEnrollmentIntent");
|
|
20685
|
+
var signEscrowEnrollmentIntent = /* @__PURE__ */ __name(async (intent, privateKey) => {
|
|
20686
|
+
encodeEscrowEnrollmentIntent(intent);
|
|
20687
|
+
const snapshot = { ...intent };
|
|
20688
|
+
const message = encodeEscrowEnrollmentIntent(snapshot);
|
|
20689
|
+
requireIntent(matches(privateKey, /^[0-9a-f]{64}$/i));
|
|
20690
|
+
const seed = hexToBytes(privateKey);
|
|
20691
|
+
try {
|
|
20692
|
+
const publicKey = await getPublicKeyAsync(seed);
|
|
20693
|
+
const expected = didPublicKey(snapshot.did);
|
|
20694
|
+
requireIntent(publicKey.every((byte, index) => byte === expected[index]));
|
|
20695
|
+
const signature = await signAsync(message, seed);
|
|
20696
|
+
return { intent: snapshot, signature: bufferToBase64(new Uint8Array(signature).buffer) };
|
|
20697
|
+
} finally {
|
|
20698
|
+
seed.fill(0);
|
|
20699
|
+
}
|
|
20700
|
+
}, "signEscrowEnrollmentIntent");
|
|
20701
|
+
var getEscrowBlobIdentity = /* @__PURE__ */ __name(async (input) => {
|
|
20702
|
+
const envelope2 = parseEscrowEnvelope(input);
|
|
20703
|
+
const decode2 = /* @__PURE__ */ __name((value) => {
|
|
20704
|
+
const bytes3 = new Uint8Array(base64ToBuffer(value));
|
|
20705
|
+
requireIntent(bufferToBase64(bytes3.buffer) === value);
|
|
20706
|
+
return bytes3;
|
|
20707
|
+
}, "decode");
|
|
20708
|
+
const point = decode2(envelope2.ephemeralPublicKey);
|
|
20709
|
+
const salt = decode2(envelope2.salt);
|
|
20710
|
+
const iv = decode2(envelope2.iv);
|
|
20711
|
+
const ciphertext = decode2(envelope2.ciphertext);
|
|
20712
|
+
requireIntent(
|
|
20713
|
+
point.length === 65 && point[0] === 4 && salt.length === 32 && iv.length === 12 && ciphertext.length >= 16
|
|
20714
|
+
);
|
|
20715
|
+
await crypto.subtle.importKey("raw", point, { name: "ECDH", namedCurve: "P-256" }, false, []);
|
|
20716
|
+
const fields = [
|
|
20717
|
+
Uint8Array.of(1),
|
|
20718
|
+
utf8(envelope2.algorithm),
|
|
20719
|
+
utf8(envelope2.keyId),
|
|
20720
|
+
point.slice(1, 33),
|
|
20721
|
+
salt,
|
|
20722
|
+
iv,
|
|
20723
|
+
ciphertext
|
|
20724
|
+
];
|
|
20725
|
+
const message = join([
|
|
20726
|
+
utf8("learncard-escrow-blob-id-v1\0"),
|
|
20727
|
+
...fields.flatMap((field) => [integer(field.length, 8), field])
|
|
20728
|
+
]);
|
|
20729
|
+
return bytesToHex(new Uint8Array(await crypto.subtle.digest("SHA-256", message)));
|
|
20730
|
+
}, "getEscrowBlobIdentity");
|
|
20731
|
+
|
|
20732
|
+
// src/escrow-nitro-attestation.ts
|
|
20733
|
+
import "reflect-metadata";
|
|
20734
|
+
import { decode, encode } from "cborg";
|
|
20735
|
+
import {
|
|
20736
|
+
BasicConstraintsExtension,
|
|
20737
|
+
KeyUsagesExtension,
|
|
20738
|
+
KeyUsageFlags,
|
|
20739
|
+
X509Certificate
|
|
20740
|
+
} from "@peculiar/x509";
|
|
20741
|
+
var NitroAttestationError = class extends Error {
|
|
20742
|
+
constructor(reason) {
|
|
20743
|
+
super(`Nitro attestation rejected: ${reason}`);
|
|
20744
|
+
this.reason = reason;
|
|
20745
|
+
this.name = "NitroAttestationError";
|
|
20746
|
+
}
|
|
20747
|
+
static {
|
|
20748
|
+
__name(this, "NitroAttestationError");
|
|
20749
|
+
}
|
|
20750
|
+
};
|
|
20751
|
+
var AWS_ROOT_SHA256 = "641a0321a3e244efe456463195d606317ed7cdcc3c1756e09893f3c68f79bb5b";
|
|
20752
|
+
var fail = /* @__PURE__ */ __name((reason) => {
|
|
20753
|
+
throw new NitroAttestationError(reason);
|
|
20754
|
+
}, "fail");
|
|
20755
|
+
var hex = /* @__PURE__ */ __name((bytes3) => Array.from(bytes3, (byte) => byte.toString(16).padStart(2, "0")).join(""), "hex");
|
|
20756
|
+
var bytes = /* @__PURE__ */ __name((value, reason) => value instanceof Uint8Array && value.length > 0 ? value : fail(reason), "bytes");
|
|
20757
|
+
var map = /* @__PURE__ */ __name((value, reason) => value instanceof Map ? value : fail(reason), "map");
|
|
20758
|
+
var decodeCbor = /* @__PURE__ */ __name((value, { allowIndefinite = false } = {}) => {
|
|
20759
|
+
try {
|
|
20760
|
+
return decode(value, {
|
|
20761
|
+
useMaps: true,
|
|
20762
|
+
rejectDuplicateMapKeys: true,
|
|
20763
|
+
allowIndefinite,
|
|
20764
|
+
allowUndefined: false,
|
|
20765
|
+
allowNaN: false,
|
|
20766
|
+
allowInfinity: false,
|
|
20767
|
+
allowBigInt: false
|
|
20768
|
+
});
|
|
20769
|
+
} catch {
|
|
20770
|
+
return fail("cbor");
|
|
20771
|
+
}
|
|
20772
|
+
}, "decodeCbor");
|
|
20773
|
+
var decodeUserData = /* @__PURE__ */ __name((userData) => {
|
|
20774
|
+
let decoded;
|
|
20775
|
+
try {
|
|
20776
|
+
decoded = decode(userData, {
|
|
20777
|
+
useMaps: true,
|
|
20778
|
+
rejectDuplicateMapKeys: true,
|
|
20779
|
+
allowIndefinite: false,
|
|
20780
|
+
allowUndefined: false,
|
|
20781
|
+
allowNaN: false,
|
|
20782
|
+
allowInfinity: false,
|
|
20783
|
+
allowBigInt: false
|
|
20784
|
+
});
|
|
20785
|
+
} catch {
|
|
20786
|
+
return void 0;
|
|
20787
|
+
}
|
|
20788
|
+
if (!(decoded instanceof Map) || decoded.size !== 3) return void 0;
|
|
20789
|
+
const spki = decoded.get(0);
|
|
20790
|
+
const keyId = decoded.get(1);
|
|
20791
|
+
const previousKeyIds = decoded.get(2);
|
|
20792
|
+
const isKeyId = /* @__PURE__ */ __name((value) => typeof value === "string" && /^[A-Za-z0-9._-]{1,128}$/.test(value), "isKeyId");
|
|
20793
|
+
if (!(spki instanceof Uint8Array) || spki.length === 0 || !isKeyId(keyId) || !Array.isArray(previousKeyIds) || previousKeyIds.length > 3 || !previousKeyIds.every(isKeyId)) {
|
|
20794
|
+
return void 0;
|
|
20795
|
+
}
|
|
20796
|
+
return { spki, keyId, previousKeyIds };
|
|
20797
|
+
}, "decodeUserData");
|
|
20798
|
+
var verifyNitroAttestationDocument = /* @__PURE__ */ __name(async (documentB64, {
|
|
20799
|
+
expectedNonce,
|
|
20800
|
+
policy,
|
|
20801
|
+
now = Date.now()
|
|
20802
|
+
}) => {
|
|
20803
|
+
let document;
|
|
20804
|
+
try {
|
|
20805
|
+
if (!documentB64 || documentB64.length > 65536 || !/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(documentB64))
|
|
20806
|
+
fail("cbor");
|
|
20807
|
+
document = base64ToBuffer(documentB64);
|
|
20808
|
+
} catch {
|
|
20809
|
+
return fail("cbor");
|
|
20810
|
+
}
|
|
20811
|
+
const cose = decodeCbor(document[0] === 210 ? document.subarray(1) : document);
|
|
20812
|
+
if (!Array.isArray(cose) || cose.length !== 4) fail("cose");
|
|
20813
|
+
const [protectedValue, unprotectedValue, payloadValue, signatureValue] = cose;
|
|
20814
|
+
const protectedBytes = bytes(protectedValue, "cose");
|
|
20815
|
+
const protectedHeader = map(decodeCbor(protectedBytes), "alg");
|
|
20816
|
+
if (protectedHeader.size !== 1 || protectedHeader.get(1) !== -35) fail("alg");
|
|
20817
|
+
if (map(unprotectedValue, "cose").size !== 0) fail("cose");
|
|
20818
|
+
const payloadBytes = bytes(payloadValue, "cose");
|
|
20819
|
+
const signature = bytes(signatureValue, "signature");
|
|
20820
|
+
if (signature.length !== 96) fail("signature");
|
|
20821
|
+
const payload = map(decodeCbor(payloadBytes, { allowIndefinite: true }), "cbor");
|
|
20822
|
+
const moduleId = payload.get("module_id");
|
|
20823
|
+
const timestamp = payload.get("timestamp");
|
|
20824
|
+
if (typeof moduleId !== "string" || !moduleId || payload.get("digest") !== "SHA384")
|
|
20825
|
+
fail("cbor");
|
|
20826
|
+
if (typeof timestamp !== "number" || !Number.isSafeInteger(timestamp) || timestamp < 0)
|
|
20827
|
+
fail("freshness");
|
|
20828
|
+
const leafDer = bytes(payload.get("certificate"), "chain");
|
|
20829
|
+
const bundle = payload.get("cabundle");
|
|
20830
|
+
if (!Array.isArray(bundle) || !bundle.length || bundle.length > 16) fail("chain");
|
|
20831
|
+
const ders = bundle.map((value) => bytes(value, "chain"));
|
|
20832
|
+
const rootHash = hex(
|
|
20833
|
+
new Uint8Array(await crypto.subtle.digest("SHA-256", new Uint8Array(ders[0])))
|
|
20834
|
+
);
|
|
20835
|
+
if (rootHash !== (policy.rootCertificateSha256 ?? AWS_ROOT_SHA256).toLowerCase()) fail("root");
|
|
20836
|
+
let leaf;
|
|
20837
|
+
try {
|
|
20838
|
+
const chain = [...ders, leafDer].map((der) => new X509Certificate(new Uint8Array(der)));
|
|
20839
|
+
for (let i = 0; i < chain.length; i++) {
|
|
20840
|
+
const cert = chain[i];
|
|
20841
|
+
const issuer = chain[Math.max(0, i - 1)];
|
|
20842
|
+
if (!Number.isFinite(now) || now < cert.notBefore.getTime() || now > cert.notAfter.getTime() || cert.issuer !== issuer.subject || !await cert.verify({ publicKey: issuer.publicKey, date: new Date(now) }, crypto))
|
|
20843
|
+
fail("chain");
|
|
20844
|
+
if (i < chain.length - 1) {
|
|
20845
|
+
const constraints = cert.getExtension(BasicConstraintsExtension);
|
|
20846
|
+
const usage = cert.getExtension(KeyUsagesExtension);
|
|
20847
|
+
if (!constraints?.ca || constraints.pathLength !== void 0 && chain.length - i - 2 > constraints.pathLength || usage && !(usage.usages & KeyUsageFlags.keyCertSign))
|
|
20848
|
+
fail("chain");
|
|
20849
|
+
}
|
|
20850
|
+
}
|
|
20851
|
+
leaf = chain[chain.length - 1];
|
|
20852
|
+
} catch {
|
|
20853
|
+
return fail("chain");
|
|
20854
|
+
}
|
|
20855
|
+
try {
|
|
20856
|
+
const key = await crypto.subtle.importKey(
|
|
20857
|
+
"spki",
|
|
20858
|
+
leaf.publicKey.rawData,
|
|
20859
|
+
{ name: "ECDSA", namedCurve: "P-384" },
|
|
20860
|
+
false,
|
|
20861
|
+
["verify"]
|
|
20862
|
+
);
|
|
20863
|
+
const structure = encode(["Signature1", protectedBytes, new Uint8Array(), payloadBytes]);
|
|
20864
|
+
if (!await crypto.subtle.verify(
|
|
20865
|
+
{ name: "ECDSA", hash: "SHA-384" },
|
|
20866
|
+
key,
|
|
20867
|
+
new Uint8Array(signature),
|
|
20868
|
+
new Uint8Array(structure)
|
|
20869
|
+
))
|
|
20870
|
+
fail("signature");
|
|
20871
|
+
} catch {
|
|
20872
|
+
return fail("signature");
|
|
20873
|
+
}
|
|
20874
|
+
const rawPcrs = map(payload.get("pcrs"), "pcr");
|
|
20875
|
+
const pcrs = {};
|
|
20876
|
+
for (const [index, value] of rawPcrs) {
|
|
20877
|
+
if (typeof index !== "number" || !Number.isInteger(index) || index < 0 || index > 31)
|
|
20878
|
+
fail("pcr");
|
|
20879
|
+
const pcr = bytes(value, "pcr");
|
|
20880
|
+
if (pcr.length !== 48) fail("pcr");
|
|
20881
|
+
pcrs[index] = hex(pcr);
|
|
20882
|
+
}
|
|
20883
|
+
if (pcrs[0] === "00".repeat(48)) fail("debug");
|
|
20884
|
+
if (!policy.pinnedMeasurements.some(
|
|
20885
|
+
(pin) => typeof pin.pcr0 === "string" && typeof pin.pcr1 === "string" && typeof pin.pcr2 === "string" && pin.pcr0.toLowerCase() === pcrs[0] && pin.pcr1.toLowerCase() === pcrs[1] && pin.pcr2.toLowerCase() === pcrs[2]
|
|
20886
|
+
))
|
|
20887
|
+
fail("pcr");
|
|
20888
|
+
const nonce = bytes(payload.get("nonce"), "nonce");
|
|
20889
|
+
if (!(expectedNonce instanceof Uint8Array) || expectedNonce.length !== 32 || nonce.length !== expectedNonce.length)
|
|
20890
|
+
fail("nonce");
|
|
20891
|
+
let difference = 0;
|
|
20892
|
+
for (let i = 0; i < nonce.length; i++) difference |= nonce[i] ^ expectedNonce[i];
|
|
20893
|
+
if (difference !== 0) fail("nonce");
|
|
20894
|
+
const maxAge = policy.maxAgeMs ?? 3e5;
|
|
20895
|
+
if (!Number.isFinite(maxAge) || maxAge < 0 || now - timestamp > maxAge || timestamp > now + 6e4)
|
|
20896
|
+
fail("freshness");
|
|
20897
|
+
const userData = bytes(payload.get("user_data"), "user-data");
|
|
20898
|
+
const newFormat = decodeUserData(new Uint8Array(userData));
|
|
20899
|
+
const spki = newFormat ? newFormat.spki : userData;
|
|
20900
|
+
try {
|
|
20901
|
+
await crypto.subtle.importKey(
|
|
20902
|
+
"spki",
|
|
20903
|
+
new Uint8Array(spki),
|
|
20904
|
+
{ name: "ECDH", namedCurve: "P-256" },
|
|
20905
|
+
false,
|
|
20906
|
+
[]
|
|
20907
|
+
);
|
|
20908
|
+
} catch {
|
|
20909
|
+
return fail("user-data");
|
|
20910
|
+
}
|
|
20911
|
+
const rawLedgerKey = payload.get("public_key");
|
|
20912
|
+
let ledgerPublicKey;
|
|
20913
|
+
let measurementHash;
|
|
20914
|
+
if (rawLedgerKey !== void 0 && rawLedgerKey !== null) {
|
|
20915
|
+
const ledger = new Uint8Array(bytes(rawLedgerKey, "user-data"));
|
|
20916
|
+
if (ledger.length !== 65 || ledger[0] !== 4) fail("user-data");
|
|
20917
|
+
try {
|
|
20918
|
+
await crypto.subtle.importKey(
|
|
20919
|
+
"raw",
|
|
20920
|
+
ledger,
|
|
20921
|
+
{ name: "ECDSA", namedCurve: "P-256" },
|
|
20922
|
+
false,
|
|
20923
|
+
["verify"]
|
|
20924
|
+
);
|
|
20925
|
+
} catch {
|
|
20926
|
+
return fail("user-data");
|
|
20927
|
+
}
|
|
20928
|
+
const tuple = new Uint8Array(144);
|
|
20929
|
+
for (let i = 0; i < 3; i++) tuple.set(bytes(rawPcrs.get(i), "pcr"), i * 48);
|
|
20930
|
+
measurementHash = hex(new Uint8Array(await crypto.subtle.digest("SHA-256", tuple)));
|
|
20931
|
+
ledgerPublicKey = bufferToBase64(ledger.buffer);
|
|
20932
|
+
}
|
|
20933
|
+
return {
|
|
20934
|
+
escrowPublicKeySpkiB64: bufferToBase64(new Uint8Array(spki).buffer),
|
|
20935
|
+
keyId: newFormat?.keyId,
|
|
20936
|
+
previousKeyIds: newFormat?.previousKeyIds ?? [],
|
|
20937
|
+
pcrs,
|
|
20938
|
+
timestamp,
|
|
20939
|
+
moduleId,
|
|
20940
|
+
...ledgerPublicKey ? { ledgerPublicKey, measurementHash } : {}
|
|
20941
|
+
};
|
|
20942
|
+
}, "verifyNitroAttestationDocument");
|
|
20943
|
+
|
|
20170
20944
|
// src/escrow-attestation.ts
|
|
20171
20945
|
var isRecord3 = /* @__PURE__ */ __name((value) => typeof value === "object" && value !== null && !Array.isArray(value), "isRecord");
|
|
20172
20946
|
var normalizePublicKey = /* @__PURE__ */ __name((value) => {
|
|
@@ -20176,13 +20950,56 @@ var normalizePublicKey = /* @__PURE__ */ __name((value) => {
|
|
|
20176
20950
|
}
|
|
20177
20951
|
return bufferToBase64(base64ToBuffer(trimmed).buffer);
|
|
20178
20952
|
}, "normalizePublicKey");
|
|
20179
|
-
var verifyEnclaveAttestation = /* @__PURE__ */ __name(async (attestation, policy) => {
|
|
20180
|
-
const
|
|
20181
|
-
|
|
20953
|
+
var verifyEnclaveAttestation = /* @__PURE__ */ __name(async (attestation, policy, nonce) => {
|
|
20954
|
+
const isKeyId = /* @__PURE__ */ __name((value) => typeof value === "string" && /^[A-Za-z0-9._-]{1,128}$/.test(value), "isKeyId");
|
|
20955
|
+
const fields = [
|
|
20956
|
+
"mode",
|
|
20957
|
+
"keyId",
|
|
20958
|
+
"previousKeyIds",
|
|
20959
|
+
"publicKey",
|
|
20960
|
+
"measurements",
|
|
20961
|
+
"document",
|
|
20962
|
+
"issuedAt"
|
|
20963
|
+
];
|
|
20964
|
+
if (!isRecord3(attestation) || Object.keys(attestation).some((key) => !fields.includes(key)) || attestation.mode !== "software" && attestation.mode !== "nitro" || !isKeyId(attestation.keyId) || attestation.previousKeyIds !== void 0 && (!Array.isArray(attestation.previousKeyIds) || attestation.previousKeyIds.length > 3 || !attestation.previousKeyIds.every(isKeyId)) || typeof attestation.publicKey !== "string" || !isRecord3(attestation.measurements) || Object.entries(attestation.measurements).some(
|
|
20182
20965
|
([key, value]) => !["imageSha384", "pcr0", "pcr1", "pcr2"].includes(key) || typeof value !== "string" || !value || value.length > 1024
|
|
20183
20966
|
) || typeof attestation.document !== "string" || !attestation.document || attestation.document.length > 65536 || typeof attestation.issuedAt !== "string" || !Number.isFinite(Date.parse(attestation.issuedAt))) {
|
|
20184
20967
|
throw new Error("Invalid escrow attestation");
|
|
20185
20968
|
}
|
|
20969
|
+
const plaintextPreviousKeyIds = attestation.previousKeyIds ?? [];
|
|
20970
|
+
if (attestation.mode !== policy.mode) throw new Error("Escrow attestation mode mismatch");
|
|
20971
|
+
if (policy.mode === "nitro") {
|
|
20972
|
+
if (!nonce) throw new NitroAttestationError("nonce");
|
|
20973
|
+
const verified = await verifyNitroAttestationDocument(attestation.document, {
|
|
20974
|
+
expectedNonce: nonce,
|
|
20975
|
+
policy
|
|
20976
|
+
});
|
|
20977
|
+
try {
|
|
20978
|
+
if (normalizePublicKey(attestation.publicKey) !== verified.escrowPublicKeySpkiB64) {
|
|
20979
|
+
throw new NitroAttestationError("user-data");
|
|
20980
|
+
}
|
|
20981
|
+
} catch {
|
|
20982
|
+
throw new NitroAttestationError("user-data");
|
|
20983
|
+
}
|
|
20984
|
+
if (verified.keyId !== void 0 && verified.keyId !== attestation.keyId) {
|
|
20985
|
+
throw new NitroAttestationError("user-data");
|
|
20986
|
+
}
|
|
20987
|
+
if (plaintextPreviousKeyIds.length !== verified.previousKeyIds.length || !plaintextPreviousKeyIds.every((id, index) => id === verified.previousKeyIds[index])) {
|
|
20988
|
+
throw new NitroAttestationError("user-data");
|
|
20989
|
+
}
|
|
20990
|
+
return {
|
|
20991
|
+
publicKey: verified.escrowPublicKeySpkiB64,
|
|
20992
|
+
keyId: attestation.keyId,
|
|
20993
|
+
previousKeyIds: verified.previousKeyIds,
|
|
20994
|
+
mode: "nitro",
|
|
20995
|
+
...verified.keyId && verified.ledgerPublicKey && verified.measurementHash ? {
|
|
20996
|
+
authority: {
|
|
20997
|
+
ledgerPublicKey: verified.ledgerPublicKey,
|
|
20998
|
+
measurement: verified.measurementHash
|
|
20999
|
+
}
|
|
21000
|
+
} : {}
|
|
21001
|
+
};
|
|
21002
|
+
}
|
|
20186
21003
|
const publicKey = normalizePublicKey(attestation.publicKey);
|
|
20187
21004
|
await crypto.subtle.importKey(
|
|
20188
21005
|
"spki",
|
|
@@ -20191,16 +21008,404 @@ var verifyEnclaveAttestation = /* @__PURE__ */ __name(async (attestation, policy
|
|
|
20191
21008
|
false,
|
|
20192
21009
|
[]
|
|
20193
21010
|
);
|
|
20194
|
-
if (policy.mode === "nitro") {
|
|
20195
|
-
throw new Error("Nitro attestation verification is not implemented yet");
|
|
20196
|
-
}
|
|
20197
|
-
if (attestation.mode !== policy.mode) throw new Error("Escrow attestation mode mismatch");
|
|
20198
21011
|
if (!policy.pinnedPublicKeys.some((pin) => normalizePublicKey(pin) === publicKey)) {
|
|
20199
21012
|
throw new Error("Escrow attestation public key is not trusted");
|
|
20200
21013
|
}
|
|
20201
|
-
return {
|
|
21014
|
+
return {
|
|
21015
|
+
publicKey,
|
|
21016
|
+
keyId: attestation.keyId,
|
|
21017
|
+
previousKeyIds: plaintextPreviousKeyIds,
|
|
21018
|
+
mode: attestation.mode
|
|
21019
|
+
};
|
|
20202
21020
|
}, "verifyEnclaveAttestation");
|
|
20203
21021
|
|
|
21022
|
+
// src/escrow-authority.types.ts
|
|
21023
|
+
var EscrowEvidenceError = class extends Error {
|
|
21024
|
+
static {
|
|
21025
|
+
__name(this, "EscrowEvidenceError");
|
|
21026
|
+
}
|
|
21027
|
+
constructor() {
|
|
21028
|
+
super("Automatic recovery evidence could not be verified.");
|
|
21029
|
+
this.name = "EscrowEvidenceError";
|
|
21030
|
+
}
|
|
21031
|
+
};
|
|
21032
|
+
|
|
21033
|
+
// src/escrow-authority.ts
|
|
21034
|
+
var fail2 = /* @__PURE__ */ __name(() => {
|
|
21035
|
+
throw new EscrowEvidenceError();
|
|
21036
|
+
}, "fail");
|
|
21037
|
+
var requireEvidence = /* @__PURE__ */ __name((condition) => {
|
|
21038
|
+
if (!condition) fail2();
|
|
21039
|
+
}, "requireEvidence");
|
|
21040
|
+
var object = /* @__PURE__ */ __name((value) => {
|
|
21041
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return fail2();
|
|
21042
|
+
return value;
|
|
21043
|
+
}, "object");
|
|
21044
|
+
var keys = /* @__PURE__ */ __name((value, names) => {
|
|
21045
|
+
requireEvidence(
|
|
21046
|
+
Object.keys(value).length === names.length && names.every((name) => Object.prototype.hasOwnProperty.call(value, name))
|
|
21047
|
+
);
|
|
21048
|
+
}, "keys");
|
|
21049
|
+
var integer2 = /* @__PURE__ */ __name((value, minimum = 0, maximum = Number.MAX_SAFE_INTEGER) => {
|
|
21050
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < minimum || value > maximum)
|
|
21051
|
+
return fail2();
|
|
21052
|
+
return value;
|
|
21053
|
+
}, "integer");
|
|
21054
|
+
var text = /* @__PURE__ */ __name((value, maximum) => {
|
|
21055
|
+
if (typeof value !== "string" || !value.length || value.length > maximum) return fail2();
|
|
21056
|
+
return value;
|
|
21057
|
+
}, "text");
|
|
21058
|
+
var bytes2 = /* @__PURE__ */ __name((value, length) => {
|
|
21059
|
+
if (!Array.isArray(value) || value.length !== length || !value.every(
|
|
21060
|
+
(byte) => typeof byte === "number" && Number.isInteger(byte) && byte >= 0 && byte <= 255
|
|
21061
|
+
))
|
|
21062
|
+
return fail2();
|
|
21063
|
+
return Uint8Array.from(value);
|
|
21064
|
+
}, "bytes");
|
|
21065
|
+
var base64 = /* @__PURE__ */ __name((value, maximum) => {
|
|
21066
|
+
const encoded = text(value, maximum);
|
|
21067
|
+
try {
|
|
21068
|
+
const decoded = new Uint8Array(base64ToBuffer(encoded));
|
|
21069
|
+
requireEvidence(bufferToBase64(decoded.buffer) === encoded);
|
|
21070
|
+
return decoded;
|
|
21071
|
+
} catch {
|
|
21072
|
+
return fail2();
|
|
21073
|
+
}
|
|
21074
|
+
}, "base64");
|
|
21075
|
+
var frame = /* @__PURE__ */ __name((value) => {
|
|
21076
|
+
const result = new Uint8Array(4 + value.length);
|
|
21077
|
+
new DataView(result.buffer).setUint32(0, value.length, false);
|
|
21078
|
+
result.set(value, 4);
|
|
21079
|
+
return result;
|
|
21080
|
+
}, "frame");
|
|
21081
|
+
var join2 = /* @__PURE__ */ __name((...values) => {
|
|
21082
|
+
const result = new Uint8Array(values.reduce((n, v) => n + v.length, 0));
|
|
21083
|
+
let offset = 0;
|
|
21084
|
+
for (const value of values) {
|
|
21085
|
+
result.set(value, offset);
|
|
21086
|
+
offset += value.length;
|
|
21087
|
+
}
|
|
21088
|
+
return result;
|
|
21089
|
+
}, "join");
|
|
21090
|
+
var hash = /* @__PURE__ */ __name(async (value) => bytesToHex(new Uint8Array(await crypto.subtle.digest("SHA-256", new Uint8Array(value)))), "hash");
|
|
21091
|
+
var utf82 = /* @__PURE__ */ __name((value) => new TextEncoder().encode(value), "utf8");
|
|
21092
|
+
var escrowAuthorityMeasurements = /* @__PURE__ */ __name(async (policy) => {
|
|
21093
|
+
if (policy.mode !== "nitro") return [];
|
|
21094
|
+
const hashes = [];
|
|
21095
|
+
for (const pin of policy.pinnedMeasurements) {
|
|
21096
|
+
const tuple = [pin.pcr0, pin.pcr1, pin.pcr2];
|
|
21097
|
+
if (!tuple.every((pcr) => typeof pcr === "string" && /^[0-9a-f]{96}$/i.test(pcr))) continue;
|
|
21098
|
+
if (pin.pcr0 === "00".repeat(48)) continue;
|
|
21099
|
+
const encoded = tuple.join("");
|
|
21100
|
+
const decoded = Uint8Array.from(
|
|
21101
|
+
{ length: 144 },
|
|
21102
|
+
(_, i) => parseInt(encoded.slice(i * 2, i * 2 + 2), 16)
|
|
21103
|
+
);
|
|
21104
|
+
hashes.push(await hash(decoded));
|
|
21105
|
+
}
|
|
21106
|
+
return hashes;
|
|
21107
|
+
}, "escrowAuthorityMeasurements");
|
|
21108
|
+
var P256_ORDER = BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551");
|
|
21109
|
+
var verifyRecord = /* @__PURE__ */ __name(async (input, kind, identity, historical) => {
|
|
21110
|
+
requireEvidence(identity.mode === "nitro" && !!identity.authority);
|
|
21111
|
+
const raw = object(input);
|
|
21112
|
+
keys(raw, ["version", "kind", "keyId", "measurement", "payload", "signature"]);
|
|
21113
|
+
requireEvidence(raw.version === 1 && raw.kind === kind);
|
|
21114
|
+
const keyId = text(raw.keyId, 128);
|
|
21115
|
+
requireEvidence(
|
|
21116
|
+
historical ? [identity.keyId, ...identity.previousKeyIds].includes(keyId) : keyId === identity.keyId
|
|
21117
|
+
);
|
|
21118
|
+
const measurement = bytes2(raw.measurement, 32);
|
|
21119
|
+
requireEvidence(
|
|
21120
|
+
historical ? historical.allowedMeasurements.includes(bytesToHex(measurement)) : bytesToHex(measurement) === identity.authority?.measurement
|
|
21121
|
+
);
|
|
21122
|
+
const payloadB64 = text(raw.payload, kind === "snapshot" ? 49152 : 8192);
|
|
21123
|
+
const signatureB64 = text(raw.signature, 88);
|
|
21124
|
+
const payload = base64(payloadB64, kind === "snapshot" ? 49152 : 8192);
|
|
21125
|
+
const signature = base64(signatureB64, 88);
|
|
21126
|
+
const ledgerKey = base64(identity.authority?.ledgerPublicKey, 88);
|
|
21127
|
+
requireEvidence(ledgerKey.length === 65 && ledgerKey[0] === 4);
|
|
21128
|
+
requireEvidence(signature.length === 64);
|
|
21129
|
+
const s = BigInt(`0x${bytesToHex(signature.slice(32))}`);
|
|
21130
|
+
requireEvidence(s > 0n && s <= P256_ORDER / 2n);
|
|
21131
|
+
const message = join2(
|
|
21132
|
+
utf82("learncard-authority-signed-record-v1\0"),
|
|
21133
|
+
Uint8Array.of(kind === "snapshot" ? 2 : 1),
|
|
21134
|
+
frame(utf82(keyId)),
|
|
21135
|
+
measurement,
|
|
21136
|
+
frame(payload)
|
|
21137
|
+
);
|
|
21138
|
+
try {
|
|
21139
|
+
const key = await crypto.subtle.importKey(
|
|
21140
|
+
"raw",
|
|
21141
|
+
ledgerKey,
|
|
21142
|
+
{ name: "ECDSA", namedCurve: "P-256" },
|
|
21143
|
+
false,
|
|
21144
|
+
["verify"]
|
|
21145
|
+
);
|
|
21146
|
+
requireEvidence(
|
|
21147
|
+
await crypto.subtle.verify({ name: "ECDSA", hash: "SHA-256" }, key, signature, message)
|
|
21148
|
+
);
|
|
21149
|
+
const decoded = JSON.parse(
|
|
21150
|
+
new TextDecoder("utf-8", { fatal: true }).decode(payload)
|
|
21151
|
+
);
|
|
21152
|
+
const record = {
|
|
21153
|
+
version: 1,
|
|
21154
|
+
kind,
|
|
21155
|
+
keyId,
|
|
21156
|
+
measurement: Array.from(measurement),
|
|
21157
|
+
payload: payloadB64,
|
|
21158
|
+
signature: signatureB64
|
|
21159
|
+
};
|
|
21160
|
+
return { record, payload: decoded };
|
|
21161
|
+
} catch {
|
|
21162
|
+
return fail2();
|
|
21163
|
+
}
|
|
21164
|
+
}, "verifyRecord");
|
|
21165
|
+
var envelope = /* @__PURE__ */ __name((value) => {
|
|
21166
|
+
try {
|
|
21167
|
+
const e = parseEscrowEnvelope(value);
|
|
21168
|
+
return {
|
|
21169
|
+
version: e.version,
|
|
21170
|
+
algorithm: e.algorithm,
|
|
21171
|
+
keyId: e.keyId,
|
|
21172
|
+
ephemeralPublicKey: e.ephemeralPublicKey,
|
|
21173
|
+
salt: e.salt,
|
|
21174
|
+
iv: e.iv,
|
|
21175
|
+
ciphertext: e.ciphertext
|
|
21176
|
+
};
|
|
21177
|
+
} catch {
|
|
21178
|
+
return fail2();
|
|
21179
|
+
}
|
|
21180
|
+
}, "envelope");
|
|
21181
|
+
var state = /* @__PURE__ */ __name((value) => {
|
|
21182
|
+
const raw = object(value);
|
|
21183
|
+
keys(raw, [
|
|
21184
|
+
"tenant",
|
|
21185
|
+
"authorityGeneration",
|
|
21186
|
+
"did",
|
|
21187
|
+
"enrollmentVersion",
|
|
21188
|
+
"enrollmentEpoch",
|
|
21189
|
+
"status",
|
|
21190
|
+
"envelope",
|
|
21191
|
+
"shareVersion",
|
|
21192
|
+
"hasPin",
|
|
21193
|
+
"pinGeneration",
|
|
21194
|
+
"attemptsUsed"
|
|
21195
|
+
]);
|
|
21196
|
+
if (raw.status !== "empty" && raw.status !== "active" && raw.status !== "disabled")
|
|
21197
|
+
return fail2();
|
|
21198
|
+
if (typeof raw.hasPin !== "boolean") return fail2();
|
|
21199
|
+
const result = {
|
|
21200
|
+
tenant: text(raw.tenant, 128),
|
|
21201
|
+
authorityGeneration: text(raw.authorityGeneration, 128),
|
|
21202
|
+
did: text(raw.did, 8192),
|
|
21203
|
+
enrollmentVersion: integer2(raw.enrollmentVersion),
|
|
21204
|
+
enrollmentEpoch: integer2(raw.enrollmentEpoch),
|
|
21205
|
+
status: raw.status,
|
|
21206
|
+
envelope: raw.envelope === null ? null : envelope(raw.envelope),
|
|
21207
|
+
shareVersion: raw.shareVersion === null ? null : integer2(raw.shareVersion, 1, 4294967295),
|
|
21208
|
+
hasPin: raw.hasPin,
|
|
21209
|
+
pinGeneration: integer2(raw.pinGeneration),
|
|
21210
|
+
attemptsUsed: integer2(raw.attemptsUsed, 0, 10)
|
|
21211
|
+
};
|
|
21212
|
+
requireEvidence(
|
|
21213
|
+
result.pinGeneration <= result.enrollmentVersion && result.enrollmentEpoch <= result.enrollmentVersion && (!result.hasPin || result.pinGeneration > 0) && (result.hasPin || result.attemptsUsed === 0)
|
|
21214
|
+
);
|
|
21215
|
+
if (result.status === "empty")
|
|
21216
|
+
requireEvidence(
|
|
21217
|
+
result.enrollmentVersion === 0 && result.enrollmentEpoch === 0 && !result.envelope && result.shareVersion === null && !result.hasPin
|
|
21218
|
+
);
|
|
21219
|
+
else requireEvidence(result.enrollmentVersion > 0 && result.enrollmentEpoch > 0);
|
|
21220
|
+
if (result.status === "active")
|
|
21221
|
+
requireEvidence(!!result.envelope && result.shareVersion !== null);
|
|
21222
|
+
else requireEvidence(result.envelope === null && result.shareVersion === null);
|
|
21223
|
+
return result;
|
|
21224
|
+
}, "state");
|
|
21225
|
+
var verifyEscrowAuthorityState = /* @__PURE__ */ __name(async (response, nonce, tenant, did, identity) => {
|
|
21226
|
+
requireEvidence(/^[0-9a-f]{64}$/.test(nonce) && nonce.length === 64);
|
|
21227
|
+
const raw = object(response);
|
|
21228
|
+
keys(raw, ["state", "proof"]);
|
|
21229
|
+
const { payload } = await verifyRecord(raw.proof, "snapshot", identity);
|
|
21230
|
+
if (!Array.isArray(payload) || payload.length !== 2 || payload[0] !== nonce) return fail2();
|
|
21231
|
+
const signed = state(payload[1]);
|
|
21232
|
+
requireEvidence(signed.tenant === tenant && signed.did === did);
|
|
21233
|
+
requireEvidence(JSON.stringify(signed) === JSON.stringify(state(raw.state)));
|
|
21234
|
+
if (signed.envelope) {
|
|
21235
|
+
requireEvidence(
|
|
21236
|
+
[identity.keyId, ...identity.previousKeyIds].includes(signed.envelope.keyId)
|
|
21237
|
+
);
|
|
21238
|
+
await getEscrowBlobIdentity(signed.envelope);
|
|
21239
|
+
}
|
|
21240
|
+
return signed;
|
|
21241
|
+
}, "verifyEscrowAuthorityState");
|
|
21242
|
+
var verifyEscrowEnrollmentCommit = /* @__PURE__ */ __name(async (response, intent, identity) => {
|
|
21243
|
+
const raw = object(response);
|
|
21244
|
+
const { record, payload } = await verifyRecord(raw.receipt, "commit", identity);
|
|
21245
|
+
const data = object(payload);
|
|
21246
|
+
keys(data, ["commit", "eventHash", "requestDigest", "resultBlobIdentity", "enrollmentEpoch"]);
|
|
21247
|
+
const commit = object(data.commit);
|
|
21248
|
+
keys(commit, ["schemaVersion", "binding", "executionId", "revisions", "transactionDigest"]);
|
|
21249
|
+
const binding = object(commit.binding);
|
|
21250
|
+
keys(binding, ["tenant", "generation", "didHash"]);
|
|
21251
|
+
const revisions = object(commit.revisions);
|
|
21252
|
+
keys(revisions, ["operation", "enrollment"]);
|
|
21253
|
+
requireEvidence(
|
|
21254
|
+
commit.schemaVersion === 1 && binding.tenant === intent.tenant && binding.generation === intent.authorityGeneration
|
|
21255
|
+
);
|
|
21256
|
+
requireEvidence(bytesToHex(bytes2(binding.didHash, 32)) === await hash(utf82(intent.did)));
|
|
21257
|
+
requireEvidence(
|
|
21258
|
+
integer2(revisions.enrollment, 1) === intent.expectedEnrollmentVersion + 1 && integer2(revisions.operation, 1) >= integer2(revisions.enrollment, 1)
|
|
21259
|
+
);
|
|
21260
|
+
bytes2(commit.executionId, 16);
|
|
21261
|
+
bytes2(commit.transactionDigest, 32);
|
|
21262
|
+
bytes2(data.eventHash, 32);
|
|
21263
|
+
requireEvidence(integer2(data.enrollmentEpoch, 1) === intent.enrollmentEpoch);
|
|
21264
|
+
requireEvidence(
|
|
21265
|
+
bytesToHex(bytes2(data.requestDigest, 32)) === await hash(encodeEscrowEnrollmentIntent(intent))
|
|
21266
|
+
);
|
|
21267
|
+
if (intent.action === "disable") {
|
|
21268
|
+
requireEvidence(
|
|
21269
|
+
(raw.envelope === null || raw.envelope === void 0) && data.resultBlobIdentity === null
|
|
21270
|
+
);
|
|
21271
|
+
return { envelope: null, receipt: record };
|
|
21272
|
+
}
|
|
21273
|
+
const output = envelope(raw.envelope);
|
|
21274
|
+
requireEvidence(
|
|
21275
|
+
output.keyId === identity.keyId && bytesToHex(bytes2(data.resultBlobIdentity, 32)) === await getEscrowBlobIdentity(output)
|
|
21276
|
+
);
|
|
21277
|
+
return { envelope: output, receipt: record };
|
|
21278
|
+
}, "verifyEscrowEnrollmentCommit");
|
|
21279
|
+
var holdDigest = /* @__PURE__ */ __name(async (tenant, record) => {
|
|
21280
|
+
const h = record.hold;
|
|
21281
|
+
const didHash = await hash(utf82(h.did));
|
|
21282
|
+
return hash(
|
|
21283
|
+
utf82(
|
|
21284
|
+
JSON.stringify([
|
|
21285
|
+
"learncard-hold-v1",
|
|
21286
|
+
tenant,
|
|
21287
|
+
h.holdId,
|
|
21288
|
+
didHash,
|
|
21289
|
+
h.shareVersion,
|
|
21290
|
+
h.blobHash,
|
|
21291
|
+
h.enrollmentEpoch,
|
|
21292
|
+
h.releasePolicy,
|
|
21293
|
+
h.clientEphemeralPublicKey,
|
|
21294
|
+
h.createdLo,
|
|
21295
|
+
h.createdHi,
|
|
21296
|
+
record.holdDurationMs,
|
|
21297
|
+
h.policyVersion,
|
|
21298
|
+
record.ledgerSeq
|
|
21299
|
+
])
|
|
21300
|
+
)
|
|
21301
|
+
);
|
|
21302
|
+
}, "holdDigest");
|
|
21303
|
+
var verifyEscrowHoldRecord = /* @__PURE__ */ __name(async (record, expected, identity, historical) => {
|
|
21304
|
+
requireEvidence(
|
|
21305
|
+
record.hold.holdId === expected.holdId && record.hold.did === expected.did && record.hold.clientEphemeralPublicKey === expected.clientEphemeralPublicKey && record.hold.blobHash === expected.blobHash
|
|
21306
|
+
);
|
|
21307
|
+
let signed;
|
|
21308
|
+
try {
|
|
21309
|
+
signed = JSON.parse(
|
|
21310
|
+
new TextDecoder("utf-8", { fatal: true }).decode(base64(record.hold.signature, 8192))
|
|
21311
|
+
);
|
|
21312
|
+
} catch {
|
|
21313
|
+
return fail2();
|
|
21314
|
+
}
|
|
21315
|
+
const { record: receipt, payload } = await verifyRecord(signed, "commit", identity, historical);
|
|
21316
|
+
const data = object(payload);
|
|
21317
|
+
keys(data, ["commit", "eventHash", "requestDigest", "resultBlobIdentity", "enrollmentEpoch"]);
|
|
21318
|
+
const commit = object(data.commit);
|
|
21319
|
+
keys(commit, ["schemaVersion", "binding", "executionId", "revisions", "transactionDigest"]);
|
|
21320
|
+
const binding = object(commit.binding);
|
|
21321
|
+
keys(binding, ["tenant", "generation", "didHash"]);
|
|
21322
|
+
requireEvidence(commit.schemaVersion === 1 && binding.tenant === expected.tenant);
|
|
21323
|
+
const authorityGeneration = text(binding.generation, 128);
|
|
21324
|
+
if (historical) requireEvidence(authorityGeneration === historical.authorityGeneration);
|
|
21325
|
+
requireEvidence(bytesToHex(bytes2(binding.didHash, 32)) === await hash(utf82(expected.did)));
|
|
21326
|
+
requireEvidence(integer2(data.enrollmentEpoch, 1) === record.hold.enrollmentEpoch);
|
|
21327
|
+
requireEvidence(bytesToHex(bytes2(data.resultBlobIdentity, 32)) === record.hold.blobHash);
|
|
21328
|
+
const digest = await holdDigest(expected.tenant, record);
|
|
21329
|
+
requireEvidence(bytesToHex(bytes2(data.requestDigest, 32)) === digest);
|
|
21330
|
+
return { receipt, authorityGeneration, holdDigest: digest };
|
|
21331
|
+
}, "verifyEscrowHoldRecord");
|
|
21332
|
+
var verifyEscrowHoldConfirmation = /* @__PURE__ */ __name(async (receipt, record, expected, identity) => {
|
|
21333
|
+
const raw = object(receipt);
|
|
21334
|
+
const kind = raw.kind;
|
|
21335
|
+
if (kind !== "commit" && kind !== "snapshot") return fail2();
|
|
21336
|
+
const { record: verified, payload } = await verifyRecord(raw, kind, identity);
|
|
21337
|
+
if (kind === "snapshot") {
|
|
21338
|
+
if (!Array.isArray(payload) || payload.length !== 7) return fail2();
|
|
21339
|
+
const [tag, holdId, digestBytes] = payload;
|
|
21340
|
+
requireEvidence(
|
|
21341
|
+
tag === "learncard-authority-hold-snapshot-v2" && holdId === record.hold.holdId && payload[6] === expected.authorityGeneration
|
|
21342
|
+
);
|
|
21343
|
+
requireEvidence(
|
|
21344
|
+
bytesToHex(bytes2(digestBytes, 32)) === await holdDigest(expected.tenant, record)
|
|
21345
|
+
);
|
|
21346
|
+
requireEvidence(payload[3] === "pending");
|
|
21347
|
+
integer2(payload[4], 1);
|
|
21348
|
+
return verified;
|
|
21349
|
+
}
|
|
21350
|
+
const data = object(payload);
|
|
21351
|
+
keys(data, ["commit", "eventHash", "requestDigest", "resultBlobIdentity", "enrollmentEpoch"]);
|
|
21352
|
+
const commit = object(data.commit);
|
|
21353
|
+
keys(commit, ["schemaVersion", "binding", "executionId", "revisions", "transactionDigest"]);
|
|
21354
|
+
const binding = object(commit.binding);
|
|
21355
|
+
keys(binding, ["tenant", "generation", "didHash"]);
|
|
21356
|
+
requireEvidence(
|
|
21357
|
+
commit.schemaVersion === 1 && binding.tenant === expected.tenant && binding.generation === expected.authorityGeneration
|
|
21358
|
+
);
|
|
21359
|
+
requireEvidence(bytesToHex(bytes2(binding.didHash, 32)) === await hash(utf82(expected.did)));
|
|
21360
|
+
requireEvidence(integer2(data.enrollmentEpoch, 1) === record.hold.enrollmentEpoch);
|
|
21361
|
+
requireEvidence(bytesToHex(bytes2(data.resultBlobIdentity, 32)) === record.hold.blobHash);
|
|
21362
|
+
bytes2(data.requestDigest, 32);
|
|
21363
|
+
return verified;
|
|
21364
|
+
}, "verifyEscrowHoldConfirmation");
|
|
21365
|
+
var resolveEscrowEnrollmentAction = /* @__PURE__ */ __name((current, input) => {
|
|
21366
|
+
const disabling = input === "disable";
|
|
21367
|
+
const pinAction = disabling ? "keep" : input === "set" ? current.hasPin ? "change" : "set" : input === "clear" ? current.hasPin ? "clear" : "keep" : "keep";
|
|
21368
|
+
const action = disabling ? "disable" : current.status !== "active" ? "enroll" : current.hasPin && pinAction === "keep" ? "carry" : "replace";
|
|
21369
|
+
return { action, pinAction, bindsRecoveryContact: action === "enroll" || action === "replace" };
|
|
21370
|
+
}, "resolveEscrowEnrollmentAction");
|
|
21371
|
+
var violatesCarryContactRule = /* @__PURE__ */ __name((action, target) => action === "carry" && !!target && (!!target.recoveryEmail || !!target.recoveryLanguage), "violatesCarryContactRule");
|
|
21372
|
+
var createEscrowEnrollmentIntent = /* @__PURE__ */ __name(async (input) => {
|
|
21373
|
+
const current = state(input.state);
|
|
21374
|
+
const target = input.target === null ? null : envelope(input.target);
|
|
21375
|
+
const disabling = input.pinAction === "disable";
|
|
21376
|
+
requireEvidence(
|
|
21377
|
+
current.enrollmentVersion < Number.MAX_SAFE_INTEGER && (disabling || current.enrollmentEpoch < Number.MAX_SAFE_INTEGER)
|
|
21378
|
+
);
|
|
21379
|
+
if (disabling && current.status !== "active") return fail2();
|
|
21380
|
+
if (current.status === "disabled" && current.hasPin && input.pinAction === "automatic")
|
|
21381
|
+
return fail2();
|
|
21382
|
+
const { action, pinAction, bindsRecoveryContact } = resolveEscrowEnrollmentAction(
|
|
21383
|
+
current,
|
|
21384
|
+
input.pinAction
|
|
21385
|
+
);
|
|
21386
|
+
requireEvidence(!disabling || input.target === null);
|
|
21387
|
+
requireEvidence(disabling || input.target !== null);
|
|
21388
|
+
if (action === "carry") requireEvidence(input.shareVersion > (current.shareVersion ?? 0));
|
|
21389
|
+
const intent = {
|
|
21390
|
+
version: 2,
|
|
21391
|
+
tenant: current.tenant,
|
|
21392
|
+
did: current.did,
|
|
21393
|
+
authorityGeneration: current.authorityGeneration,
|
|
21394
|
+
expectedEnrollmentVersion: current.enrollmentVersion,
|
|
21395
|
+
action,
|
|
21396
|
+
sourceBlobIdentity: current.envelope ? await getEscrowBlobIdentity(current.envelope) : null,
|
|
21397
|
+
targetBlobIdentity: target ? await getEscrowBlobIdentity(target) : null,
|
|
21398
|
+
pinAction,
|
|
21399
|
+
shareVersion: disabling ? current.shareVersion : input.shareVersion,
|
|
21400
|
+
enrollmentEpoch: current.enrollmentEpoch + (disabling ? 0 : 1),
|
|
21401
|
+
requestId: crypto.randomUUID(),
|
|
21402
|
+
allowRewrap: !disabling,
|
|
21403
|
+
recoveryEmail: bindsRecoveryContact ? input.recoveryEmail : null,
|
|
21404
|
+
recoveryLanguage: bindsRecoveryContact ? input.recoveryLanguage : null
|
|
21405
|
+
};
|
|
21406
|
+
return signEscrowEnrollmentIntent(intent, input.privateKey);
|
|
21407
|
+
}, "createEscrowEnrollmentIntent");
|
|
21408
|
+
|
|
20204
21409
|
// src/types.ts
|
|
20205
21410
|
var import_types = __toESM(require_dist());
|
|
20206
21411
|
var EscrowPinUnavailableError = class extends Error {
|
|
@@ -20945,6 +22150,10 @@ function createSSSStrategy(config) {
|
|
|
20945
22150
|
const localWrites = /* @__PURE__ */ new Set();
|
|
20946
22151
|
const guardedStorage = /* @__PURE__ */ __name(() => {
|
|
20947
22152
|
const generation = storageGeneration;
|
|
22153
|
+
const assertCurrent = /* @__PURE__ */ __name(() => {
|
|
22154
|
+
if (generation !== storageGeneration)
|
|
22155
|
+
throw new Error("This recovery request was cancelled.");
|
|
22156
|
+
}, "assertCurrent");
|
|
20948
22157
|
const write = /* @__PURE__ */ __name((operation) => {
|
|
20949
22158
|
if (generation !== storageGeneration) {
|
|
20950
22159
|
return Promise.reject(new Error("This recovery request was cancelled."));
|
|
@@ -20955,6 +22164,7 @@ function createSSSStrategy(config) {
|
|
|
20955
22164
|
}, "write");
|
|
20956
22165
|
const guarded = {
|
|
20957
22166
|
...storage,
|
|
22167
|
+
assertCurrent,
|
|
20958
22168
|
storeDeviceShare: /* @__PURE__ */ __name((share, id) => write(() => storage.storeDeviceShare(share, id)), "storeDeviceShare"),
|
|
20959
22169
|
storeShareVersion: /* @__PURE__ */ __name((version, id) => write(() => storage.storeShareVersion(version, id)), "storeShareVersion"),
|
|
20960
22170
|
clearAllShares: /* @__PURE__ */ __name((id) => write(() => storage.clearAllShares(id)), "clearAllShares"),
|
|
@@ -20971,6 +22181,8 @@ function createSSSStrategy(config) {
|
|
|
20971
22181
|
let pendingIdentityRecovery;
|
|
20972
22182
|
let lastServerSnapshot = null;
|
|
20973
22183
|
let escrowEnrollmentInFlight;
|
|
22184
|
+
let staleEscrowReenrollAttempted = false;
|
|
22185
|
+
let verifiedEscrowEnvelope;
|
|
20974
22186
|
let unenrolledRotation;
|
|
20975
22187
|
const escrowRequest = /* @__PURE__ */ __name(async (path, init, pinAttempt = false) => {
|
|
20976
22188
|
const response = await fetch(`${serverUrl}/keys/escrow${path}`, {
|
|
@@ -21018,22 +22230,100 @@ function createSSSStrategy(config) {
|
|
|
21018
22230
|
}, "escrowRequest");
|
|
21019
22231
|
const fetchVerifiedEnclaveKey = /* @__PURE__ */ __name(async () => {
|
|
21020
22232
|
if (!config.escrow?.enabled) throw new Error("Escrow enrollment is disabled");
|
|
21021
|
-
const
|
|
21022
|
-
|
|
21023
|
-
|
|
21024
|
-
|
|
21025
|
-
|
|
22233
|
+
const nonce = crypto.getRandomValues(new Uint8Array(32));
|
|
22234
|
+
const nonceHex = Array.from(nonce, (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
22235
|
+
const { attestation } = await escrowRequest(
|
|
22236
|
+
`/attestation?nonce=${nonceHex}`,
|
|
22237
|
+
{
|
|
22238
|
+
method: "GET",
|
|
22239
|
+
headers: buildHeaders("", void 0, tenantId)
|
|
22240
|
+
}
|
|
22241
|
+
);
|
|
22242
|
+
return verifyEnclaveAttestation(attestation, config.escrow.attestation, nonce);
|
|
21026
22243
|
}, "fetchVerifiedEnclaveKey");
|
|
21027
|
-
const
|
|
22244
|
+
const fetchEscrowHoldStatus = /* @__PURE__ */ __name(async (params) => {
|
|
22245
|
+
const query = new URLSearchParams(
|
|
22246
|
+
"holdId" in params ? { holdId: params.holdId } : { providerType: params.providerType }
|
|
22247
|
+
);
|
|
22248
|
+
const secret = "holdId" in params ? params.resumeToken : params.token;
|
|
22249
|
+
const result = await escrowRequest(`/status?${query}`, {
|
|
22250
|
+
method: "GET",
|
|
22251
|
+
headers: {
|
|
22252
|
+
...buildHeaders("", void 0, tenantId),
|
|
22253
|
+
"X-Auth-Token": secret
|
|
22254
|
+
}
|
|
22255
|
+
});
|
|
22256
|
+
return result.hold;
|
|
22257
|
+
}, "fetchEscrowHoldStatus");
|
|
22258
|
+
const recoveryExpectations = /* @__PURE__ */ __name((holdId, expected) => {
|
|
22259
|
+
if (!expected || expected.holdId !== holdId || expected.tenant !== (tenantId ?? "learncard") || !expected.did || !expected.clientEphemeralPublicKey || !expected.blobHash || !expected.authorityGeneration || !expected.holdDigest || !expected.ledgerPublicKey || !expected.keyId)
|
|
22260
|
+
throw new EscrowEvidenceError();
|
|
22261
|
+
return { ...expected };
|
|
22262
|
+
}, "recoveryExpectations");
|
|
22263
|
+
const verifyPendingHold = /* @__PURE__ */ __name(async (status, expected, identity) => {
|
|
22264
|
+
if (!config.escrow || identity.mode !== "nitro" || !identity.authority || identity.authority.ledgerPublicKey !== expected.ledgerPublicKey || ![identity.keyId, ...identity.previousKeyIds].includes(expected.keyId) || status.holdId !== expected.holdId || !status.holdRecord)
|
|
22265
|
+
throw new EscrowEvidenceError();
|
|
22266
|
+
const record = status.holdRecord;
|
|
22267
|
+
const verified = await verifyEscrowHoldRecord(record, expected, identity, {
|
|
22268
|
+
historical: true,
|
|
22269
|
+
allowedMeasurements: await escrowAuthorityMeasurements(config.escrow.attestation),
|
|
22270
|
+
authorityGeneration: expected.authorityGeneration
|
|
22271
|
+
});
|
|
22272
|
+
if (verified.holdDigest !== expected.holdDigest || verified.receipt.keyId !== expected.keyId)
|
|
22273
|
+
throw new EscrowEvidenceError();
|
|
22274
|
+
return record;
|
|
22275
|
+
}, "verifyPendingHold");
|
|
22276
|
+
const fetchAuthorityState = /* @__PURE__ */ __name(async (token, providerType, privateKey, did, signer, identity, assertCurrent) => {
|
|
22277
|
+
assertCurrent();
|
|
22278
|
+
if (identity.mode !== "nitro" || !identity.authority)
|
|
22279
|
+
throw new Error("The enclave does not support verified enrollment.");
|
|
22280
|
+
const nonce = Array.from(
|
|
22281
|
+
crypto.getRandomValues(new Uint8Array(32)),
|
|
22282
|
+
(byte) => byte.toString(16).padStart(2, "0")
|
|
22283
|
+
).join("");
|
|
22284
|
+
const vp = await requestFreshDidAuthVp(serverUrl, privateKey, did, signer, tenantId);
|
|
22285
|
+
assertCurrent();
|
|
22286
|
+
const response = await escrowRequest("/authority-state", {
|
|
22287
|
+
method: "POST",
|
|
22288
|
+
headers: buildHeaders(token, vp, tenantId),
|
|
22289
|
+
body: JSON.stringify({ authToken: token, providerType, nonce })
|
|
22290
|
+
});
|
|
22291
|
+
const result = await verifyEscrowAuthorityState(
|
|
22292
|
+
response,
|
|
22293
|
+
nonce,
|
|
22294
|
+
tenantId ?? "learncard",
|
|
22295
|
+
did,
|
|
22296
|
+
identity
|
|
22297
|
+
);
|
|
22298
|
+
assertCurrent();
|
|
22299
|
+
return result;
|
|
22300
|
+
}, "fetchAuthorityState");
|
|
22301
|
+
const enrollEscrow = /* @__PURE__ */ __name(async (token, providerType, privateKey, primaryDid, shares, shareVersion, signDidAuthVp, verifiedKey, pinMaterial, clearPin = false, assertCurrent = guardedStorage().assertCurrent, recoveryEmail = "", recoveryLanguage = "") => {
|
|
21028
22302
|
if (!config.escrow?.enabled) throw new Error("Escrow enrollment is disabled");
|
|
21029
22303
|
if (!signDidAuthVp) throw new Error("DID proof signing is required for escrow enrollment");
|
|
21030
|
-
const
|
|
21031
|
-
|
|
22304
|
+
const identity = verifiedKey ?? await fetchVerifiedEnclaveKey();
|
|
22305
|
+
assertCurrent();
|
|
22306
|
+
const { publicKey, keyId } = identity;
|
|
22307
|
+
const authority = config.escrow.attestation.mode === "nitro" ? await fetchAuthorityState(
|
|
22308
|
+
token,
|
|
22309
|
+
providerType,
|
|
22310
|
+
privateKey,
|
|
22311
|
+
primaryDid,
|
|
22312
|
+
signDidAuthVp,
|
|
22313
|
+
identity,
|
|
22314
|
+
assertCurrent
|
|
22315
|
+
) : void 0;
|
|
22316
|
+
const bindsRecoveryContact = !authority || resolveEscrowEnrollmentAction(
|
|
22317
|
+
authority,
|
|
22318
|
+
pinMaterial ? "set" : clearPin ? "clear" : "automatic"
|
|
22319
|
+
).bindsRecoveryContact;
|
|
22320
|
+
const envelope2 = await encryptEscrowBlob(
|
|
21032
22321
|
{
|
|
21033
22322
|
recoveryShare: shares.recoveryShare,
|
|
21034
22323
|
did: primaryDid,
|
|
21035
22324
|
shareVersion,
|
|
21036
|
-
...pinMaterial ? { pinVerifier: pinMaterial.pinVerifier } : {}
|
|
22325
|
+
...pinMaterial ? { pinVerifier: pinMaterial.pinVerifier } : {},
|
|
22326
|
+
...authority && recoveryEmail && bindsRecoveryContact ? { recoveryEmail, recoveryLanguage } : {}
|
|
21037
22327
|
},
|
|
21038
22328
|
publicKey,
|
|
21039
22329
|
keyId
|
|
@@ -21045,19 +22335,40 @@ function createSSSStrategy(config) {
|
|
|
21045
22335
|
signDidAuthVp,
|
|
21046
22336
|
tenantId
|
|
21047
22337
|
);
|
|
21048
|
-
await
|
|
22338
|
+
const signedIntent = authority ? await createEscrowEnrollmentIntent({
|
|
22339
|
+
state: authority,
|
|
22340
|
+
target: envelope2,
|
|
22341
|
+
shareVersion,
|
|
22342
|
+
privateKey,
|
|
22343
|
+
pinAction: pinMaterial ? "set" : clearPin ? "clear" : "automatic",
|
|
22344
|
+
recoveryEmail,
|
|
22345
|
+
recoveryLanguage
|
|
22346
|
+
}) : void 0;
|
|
22347
|
+
assertCurrent();
|
|
22348
|
+
verifiedEscrowEnvelope = void 0;
|
|
22349
|
+
const response = await escrowRequest("", {
|
|
21049
22350
|
method: "POST",
|
|
21050
22351
|
headers: buildHeaders(token, vp, tenantId),
|
|
21051
22352
|
body: JSON.stringify({
|
|
21052
22353
|
authToken: token,
|
|
21053
22354
|
providerType,
|
|
21054
|
-
envelope,
|
|
22355
|
+
envelope: envelope2,
|
|
21055
22356
|
shareVersion,
|
|
21056
22357
|
enclaveKeyId: keyId,
|
|
21057
22358
|
...pinMaterial ? { pinSalt: pinMaterial.pinSalt } : {},
|
|
21058
|
-
...clearPin ? { clearPin: true } : {}
|
|
22359
|
+
...(signedIntent ? signedIntent.intent.pinAction === "clear" : clearPin) ? { clearPin: true } : {},
|
|
22360
|
+
...signedIntent ? { signedIntent, sourceEnvelope: authority?.envelope ?? null } : {}
|
|
21059
22361
|
})
|
|
21060
22362
|
});
|
|
22363
|
+
if (signedIntent) {
|
|
22364
|
+
const committed = await verifyEscrowEnrollmentCommit(
|
|
22365
|
+
response,
|
|
22366
|
+
signedIntent.intent,
|
|
22367
|
+
identity
|
|
22368
|
+
);
|
|
22369
|
+
assertCurrent();
|
|
22370
|
+
verifiedEscrowEnvelope = committed.envelope ?? void 0;
|
|
22371
|
+
}
|
|
21061
22372
|
}, "enrollEscrow");
|
|
21062
22373
|
const tryEnrollEscrow = /* @__PURE__ */ __name(async (...args) => {
|
|
21063
22374
|
if (!config.escrow?.enabled) return;
|
|
@@ -21072,9 +22383,12 @@ function createSSSStrategy(config) {
|
|
|
21072
22383
|
}
|
|
21073
22384
|
}
|
|
21074
22385
|
}, "tryEnrollEscrow");
|
|
21075
|
-
const ensureEscrowEnrollmentUnguarded = /* @__PURE__ */ __name(async (self, params, storage2, forceRotate = false) => {
|
|
22386
|
+
const ensureEscrowEnrollmentUnguarded = /* @__PURE__ */ __name(async (self, params, storage2, forceRotate = false, allowDisabledEnrollment = false) => {
|
|
22387
|
+
let clearPinForEnrollment = forceRotate;
|
|
21076
22388
|
if (!config.escrow?.enabled) return { enrolled: false, reason: "disabled" };
|
|
21077
22389
|
const pin = params.options?.pin;
|
|
22390
|
+
const recoveryEmail = params.options?.recoveryEmail ?? "";
|
|
22391
|
+
const recoveryLanguage = params.options?.recoveryLanguage ?? "";
|
|
21078
22392
|
if (pin !== void 0) {
|
|
21079
22393
|
const validation = validatePin(pin);
|
|
21080
22394
|
if (!validation.ok)
|
|
@@ -21083,76 +22397,125 @@ function createSSSStrategy(config) {
|
|
|
21083
22397
|
);
|
|
21084
22398
|
}
|
|
21085
22399
|
const status = await self.fetchServerKeyStatus(params.token, params.providerType);
|
|
22400
|
+
storage2.assertCurrent();
|
|
21086
22401
|
if (status.escrowOptedOut) return { enrolled: false, reason: "opted-out" };
|
|
21087
|
-
|
|
22402
|
+
let currentlyEnrolled = status.shareVersion !== null && status.recoveryMethods.some(
|
|
21088
22403
|
(method) => method.type === "escrow" && method.shareVersion === status.shareVersion && (Boolean(method.confirmedAt) || "confirmationStatus" in method && method.confirmationStatus === "confirmed")
|
|
21089
|
-
)
|
|
22404
|
+
);
|
|
22405
|
+
let verifiedKey;
|
|
22406
|
+
if (config.escrow.attestation.mode === "nitro") {
|
|
22407
|
+
if (!status.primaryDid || !params.signDidAuthVp)
|
|
22408
|
+
throw new Error("Owner proof signing is required for escrow enrollment.");
|
|
22409
|
+
verifiedKey = await fetchVerifiedEnclaveKey();
|
|
22410
|
+
const current = await fetchAuthorityState(
|
|
22411
|
+
params.token,
|
|
22412
|
+
params.providerType,
|
|
22413
|
+
params.privateKey,
|
|
22414
|
+
status.primaryDid,
|
|
22415
|
+
params.signDidAuthVp,
|
|
22416
|
+
verifiedKey,
|
|
22417
|
+
storage2.assertCurrent
|
|
22418
|
+
);
|
|
22419
|
+
if (current.status === "disabled") {
|
|
22420
|
+
verifiedEscrowEnvelope = void 0;
|
|
22421
|
+
if (!allowDisabledEnrollment) return { enrolled: false, reason: "opted-out" };
|
|
22422
|
+
clearPinForEnrollment ||= current.hasPin && pin === void 0;
|
|
22423
|
+
}
|
|
22424
|
+
currentlyEnrolled = currentlyEnrolled && current.status === "active" && current.shareVersion === status.shareVersion && current.envelope?.keyId === verifiedKey.keyId;
|
|
22425
|
+
if (currentlyEnrolled) verifiedEscrowEnvelope = current.envelope ?? void 0;
|
|
22426
|
+
}
|
|
22427
|
+
const repairingStaleBlob = pin === void 0 && !clearPinForEnrollment && currentlyEnrolled && !!status.escrowStale && !staleEscrowReenrollAttempted;
|
|
22428
|
+
if (!clearPinForEnrollment && pin === void 0 && currentlyEnrolled && !repairingStaleBlob)
|
|
21090
22429
|
return { enrolled: true, changed: false };
|
|
22430
|
+
if (repairingStaleBlob) staleEscrowReenrollAttempted = true;
|
|
21091
22431
|
if (!status.primaryDid) throw new Error("Cannot enroll escrow without a primary DID");
|
|
21092
22432
|
if (!params.signDidAuthVp) {
|
|
21093
22433
|
throw new Error("DID proof signing is required for escrow enrollment");
|
|
21094
22434
|
}
|
|
21095
|
-
|
|
21096
|
-
|
|
22435
|
+
try {
|
|
22436
|
+
if (!clearPinForEnrollment && pin === void 0 && unenrolledRotation && unenrolledRotation.shareVersion === status.shareVersion && unenrolledRotation.primaryDid === status.primaryDid) {
|
|
22437
|
+
const retry = unenrolledRotation;
|
|
22438
|
+
await enrollEscrow(
|
|
22439
|
+
params.token,
|
|
22440
|
+
params.providerType,
|
|
22441
|
+
params.privateKey,
|
|
22442
|
+
retry.primaryDid,
|
|
22443
|
+
retry.shares,
|
|
22444
|
+
retry.shareVersion,
|
|
22445
|
+
params.signDidAuthVp,
|
|
22446
|
+
void 0,
|
|
22447
|
+
void 0,
|
|
22448
|
+
retry.clearPin,
|
|
22449
|
+
storage2.assertCurrent,
|
|
22450
|
+
recoveryEmail,
|
|
22451
|
+
recoveryLanguage
|
|
22452
|
+
);
|
|
22453
|
+
unenrolledRotation = void 0;
|
|
22454
|
+
return { enrolled: true, changed: true, shareVersion: retry.shareVersion };
|
|
22455
|
+
}
|
|
22456
|
+
verifiedKey ??= await fetchVerifiedEnclaveKey();
|
|
22457
|
+
storage2.assertCurrent();
|
|
22458
|
+
const pinSalt = pin !== void 0 ? generatePinSalt() : void 0;
|
|
22459
|
+
const pinMaterial = pin !== void 0 && pinSalt !== void 0 ? { pinSalt, pinVerifier: await derivePinProof(pin, pinSalt) } : void 0;
|
|
22460
|
+
const storageId = activeStorageId;
|
|
22461
|
+
const primaryDid = status.primaryDid;
|
|
22462
|
+
const { shares, shareVersion } = await withShareUpdateLock(
|
|
22463
|
+
storage2,
|
|
22464
|
+
storageId,
|
|
22465
|
+
() => persistSharesWithoutLock(
|
|
22466
|
+
params.privateKey,
|
|
22467
|
+
serverUrl,
|
|
22468
|
+
params.token,
|
|
22469
|
+
params.providerType,
|
|
22470
|
+
primaryDid,
|
|
22471
|
+
storage2,
|
|
22472
|
+
storageId,
|
|
22473
|
+
void 0,
|
|
22474
|
+
params.signDidAuthVp,
|
|
22475
|
+
tenantId
|
|
22476
|
+
)
|
|
22477
|
+
);
|
|
22478
|
+
lastEmailShare = shares.emailShare;
|
|
22479
|
+
lastShareVersion = shareVersion;
|
|
22480
|
+
lastServerSnapshot = {
|
|
22481
|
+
currentVersion: shareVersion,
|
|
22482
|
+
resolvedVersion: shareVersion,
|
|
22483
|
+
authShare: shares.authShare,
|
|
22484
|
+
primaryDid: status.primaryDid
|
|
22485
|
+
};
|
|
22486
|
+
unenrolledRotation = pinMaterial ? void 0 : {
|
|
22487
|
+
shares,
|
|
22488
|
+
shareVersion,
|
|
22489
|
+
primaryDid: status.primaryDid,
|
|
22490
|
+
clearPin: clearPinForEnrollment
|
|
22491
|
+
};
|
|
21097
22492
|
await enrollEscrow(
|
|
21098
22493
|
params.token,
|
|
21099
22494
|
params.providerType,
|
|
21100
22495
|
params.privateKey,
|
|
21101
|
-
|
|
21102
|
-
|
|
21103
|
-
|
|
22496
|
+
status.primaryDid,
|
|
22497
|
+
shares,
|
|
22498
|
+
shareVersion,
|
|
21104
22499
|
params.signDidAuthVp,
|
|
21105
|
-
|
|
21106
|
-
|
|
21107
|
-
|
|
22500
|
+
verifiedKey,
|
|
22501
|
+
pinMaterial,
|
|
22502
|
+
clearPinForEnrollment,
|
|
22503
|
+
storage2.assertCurrent,
|
|
22504
|
+
recoveryEmail,
|
|
22505
|
+
recoveryLanguage
|
|
21108
22506
|
);
|
|
21109
22507
|
unenrolledRotation = void 0;
|
|
21110
|
-
return { enrolled: true, changed: true, shareVersion
|
|
22508
|
+
return { enrolled: true, changed: true, shareVersion };
|
|
22509
|
+
} catch (err) {
|
|
22510
|
+
if (!repairingStaleBlob || config.escrow.attestation.mode === "nitro") throw err;
|
|
22511
|
+
try {
|
|
22512
|
+
if (config.onEscrowError) config.onEscrowError(err);
|
|
22513
|
+
else console.warn("SSS: escrow enrollment failed");
|
|
22514
|
+
} catch {
|
|
22515
|
+
console.warn("SSS: escrow error reporting failed");
|
|
22516
|
+
}
|
|
22517
|
+
return { enrolled: true, changed: false };
|
|
21111
22518
|
}
|
|
21112
|
-
const verifiedKey = await fetchVerifiedEnclaveKey();
|
|
21113
|
-
const pinSalt = pin !== void 0 ? generatePinSalt() : void 0;
|
|
21114
|
-
const pinMaterial = pin !== void 0 && pinSalt !== void 0 ? { pinSalt, pinVerifier: await derivePinProof(pin, pinSalt) } : void 0;
|
|
21115
|
-
const storageId = activeStorageId;
|
|
21116
|
-
const primaryDid = status.primaryDid;
|
|
21117
|
-
const { shares, shareVersion } = await withShareUpdateLock(
|
|
21118
|
-
storage2,
|
|
21119
|
-
storageId,
|
|
21120
|
-
() => persistSharesWithoutLock(
|
|
21121
|
-
params.privateKey,
|
|
21122
|
-
serverUrl,
|
|
21123
|
-
params.token,
|
|
21124
|
-
params.providerType,
|
|
21125
|
-
primaryDid,
|
|
21126
|
-
storage2,
|
|
21127
|
-
storageId,
|
|
21128
|
-
void 0,
|
|
21129
|
-
params.signDidAuthVp,
|
|
21130
|
-
tenantId
|
|
21131
|
-
)
|
|
21132
|
-
);
|
|
21133
|
-
lastEmailShare = shares.emailShare;
|
|
21134
|
-
lastShareVersion = shareVersion;
|
|
21135
|
-
lastServerSnapshot = {
|
|
21136
|
-
currentVersion: shareVersion,
|
|
21137
|
-
resolvedVersion: shareVersion,
|
|
21138
|
-
authShare: shares.authShare,
|
|
21139
|
-
primaryDid: status.primaryDid
|
|
21140
|
-
};
|
|
21141
|
-
unenrolledRotation = pinMaterial ? void 0 : { shares, shareVersion, primaryDid: status.primaryDid, clearPin: forceRotate };
|
|
21142
|
-
await enrollEscrow(
|
|
21143
|
-
params.token,
|
|
21144
|
-
params.providerType,
|
|
21145
|
-
params.privateKey,
|
|
21146
|
-
status.primaryDid,
|
|
21147
|
-
shares,
|
|
21148
|
-
shareVersion,
|
|
21149
|
-
params.signDidAuthVp,
|
|
21150
|
-
verifiedKey,
|
|
21151
|
-
pinMaterial,
|
|
21152
|
-
forceRotate
|
|
21153
|
-
);
|
|
21154
|
-
unenrolledRotation = void 0;
|
|
21155
|
-
return { enrolled: true, changed: true, shareVersion };
|
|
21156
22519
|
}, "ensureEscrowEnrollmentUnguarded");
|
|
21157
22520
|
const recordPromotion = /* @__PURE__ */ __name((primaryDid) => (snapshot) => {
|
|
21158
22521
|
lastEmailShare = void 0;
|
|
@@ -21185,6 +22548,7 @@ function createSSSStrategy(config) {
|
|
|
21185
22548
|
},
|
|
21186
22549
|
// --- User scoping ---
|
|
21187
22550
|
setActiveUser(userId) {
|
|
22551
|
+
verifiedEscrowEnvelope = void 0;
|
|
21188
22552
|
if (activeStorageId !== `sss-device-share:${userId}`) storageGeneration++;
|
|
21189
22553
|
activeStorageId = `sss-device-share:${userId}`;
|
|
21190
22554
|
lastServerSnapshot = null;
|
|
@@ -21229,6 +22593,7 @@ function createSSSStrategy(config) {
|
|
|
21229
22593
|
);
|
|
21230
22594
|
}
|
|
21231
22595
|
storageGeneration++;
|
|
22596
|
+
verifiedEscrowEnvelope = void 0;
|
|
21232
22597
|
await Promise.allSettled(localWrites);
|
|
21233
22598
|
await clearPendingShareCandidates(storage, storageId);
|
|
21234
22599
|
return storage.clearAllShares(storageId);
|
|
@@ -21469,6 +22834,7 @@ function createSSSStrategy(config) {
|
|
|
21469
22834
|
maskedRecoveryEmail: data.maskedRecoveryEmail ?? null,
|
|
21470
22835
|
escrowOptedOut: data.escrowOptedOut === true,
|
|
21471
22836
|
escrowPin: data.escrowPin,
|
|
22837
|
+
escrowStale: data.escrowStale,
|
|
21472
22838
|
sssActivationState: data.sssActivationState ?? "active"
|
|
21473
22839
|
};
|
|
21474
22840
|
},
|
|
@@ -21513,14 +22879,71 @@ function createSSSStrategy(config) {
|
|
|
21513
22879
|
if (!config.escrow?.enabled) return { state: "disabled" };
|
|
21514
22880
|
const status = await this.fetchServerKeyStatus(params.token, params.providerType);
|
|
21515
22881
|
if (status.escrowOptedOut) return { state: "opted-out", escrowPin: status.escrowPin };
|
|
21516
|
-
const
|
|
21517
|
-
(method) => method.type === "escrow" &&
|
|
21518
|
-
)
|
|
21519
|
-
|
|
22882
|
+
const confirmedEscrow = status.recoveryMethods.filter(
|
|
22883
|
+
(method) => method.type === "escrow" && (Boolean(method.confirmedAt) || "confirmationStatus" in method && method.confirmationStatus === "confirmed")
|
|
22884
|
+
);
|
|
22885
|
+
const enrolled = status.shareVersion !== null && confirmedEscrow.some((method) => method.shareVersion === status.shareVersion);
|
|
22886
|
+
if (confirmedEscrow.length > 0 && (!enrolled || status.escrowStale))
|
|
22887
|
+
return {
|
|
22888
|
+
state: "stale",
|
|
22889
|
+
escrowPin: status.escrowPin,
|
|
22890
|
+
staleReason: status.escrowStale
|
|
22891
|
+
};
|
|
22892
|
+
return { state: enrolled ? "enrolled" : "not-enrolled", escrowPin: status.escrowPin };
|
|
21520
22893
|
},
|
|
21521
22894
|
async disableEscrowRecovery(params) {
|
|
22895
|
+
const assertCurrent = guardedStorage().assertCurrent;
|
|
21522
22896
|
const status = await this.fetchServerKeyStatus(params.token, params.providerType);
|
|
21523
22897
|
if (!status.primaryDid) throw new Error("Cannot disable escrow without a primary DID");
|
|
22898
|
+
if (config.escrow?.attestation.mode === "nitro") {
|
|
22899
|
+
const identity = await fetchVerifiedEnclaveKey();
|
|
22900
|
+
const current = await fetchAuthorityState(
|
|
22901
|
+
params.token,
|
|
22902
|
+
params.providerType,
|
|
22903
|
+
params.privateKey,
|
|
22904
|
+
status.primaryDid,
|
|
22905
|
+
params.signDidAuthVp,
|
|
22906
|
+
identity,
|
|
22907
|
+
assertCurrent
|
|
22908
|
+
);
|
|
22909
|
+
if (current.status === "disabled") {
|
|
22910
|
+
verifiedEscrowEnvelope = void 0;
|
|
22911
|
+
return;
|
|
22912
|
+
}
|
|
22913
|
+
const signedIntent = await createEscrowEnrollmentIntent({
|
|
22914
|
+
state: current,
|
|
22915
|
+
target: null,
|
|
22916
|
+
shareVersion: current.shareVersion ?? 0,
|
|
22917
|
+
privateKey: params.privateKey,
|
|
22918
|
+
pinAction: "disable",
|
|
22919
|
+
// Disable always nulls these server-side regardless of input.
|
|
22920
|
+
recoveryEmail: "",
|
|
22921
|
+
recoveryLanguage: ""
|
|
22922
|
+
});
|
|
22923
|
+
const vp2 = await requestFreshDidAuthVp(
|
|
22924
|
+
serverUrl,
|
|
22925
|
+
params.privateKey,
|
|
22926
|
+
status.primaryDid,
|
|
22927
|
+
params.signDidAuthVp,
|
|
22928
|
+
tenantId
|
|
22929
|
+
);
|
|
22930
|
+
assertCurrent();
|
|
22931
|
+
const response = await escrowRequest("/disable", {
|
|
22932
|
+
method: "POST",
|
|
22933
|
+
headers: buildHeaders(params.token, vp2, tenantId),
|
|
22934
|
+
body: JSON.stringify({
|
|
22935
|
+
authToken: params.token,
|
|
22936
|
+
providerType: params.providerType,
|
|
22937
|
+
optOut: true,
|
|
22938
|
+
signedIntent,
|
|
22939
|
+
sourceEnvelope: current.envelope
|
|
22940
|
+
})
|
|
22941
|
+
});
|
|
22942
|
+
await verifyEscrowEnrollmentCommit(response, signedIntent.intent, identity);
|
|
22943
|
+
assertCurrent();
|
|
22944
|
+
verifiedEscrowEnvelope = void 0;
|
|
22945
|
+
return;
|
|
22946
|
+
}
|
|
21524
22947
|
const vp = await requestFreshDidAuthVp(
|
|
21525
22948
|
serverUrl,
|
|
21526
22949
|
params.privateKey,
|
|
@@ -21561,15 +22984,31 @@ function createSSSStrategy(config) {
|
|
|
21561
22984
|
providerType: params.providerType
|
|
21562
22985
|
})
|
|
21563
22986
|
});
|
|
21564
|
-
return ensureEscrowEnrollmentUnguarded(this, params, storage2);
|
|
22987
|
+
return ensureEscrowEnrollmentUnguarded(this, params, storage2, false, true);
|
|
21565
22988
|
});
|
|
21566
22989
|
},
|
|
21567
22990
|
async setEscrowPin({ pin, ...params }) {
|
|
21568
22991
|
const storage2 = guardedStorage();
|
|
21569
22992
|
const result = await withRotationLock(
|
|
21570
|
-
() =>
|
|
22993
|
+
() => (
|
|
22994
|
+
// P9.1: preserve the caller's recoveryEmail/recoveryLanguage — do
|
|
22995
|
+
// not replace `params.options` wholesale, or nitro enroll/replace
|
|
22996
|
+
// loses its required recovery contact.
|
|
22997
|
+
ensureEscrowEnrollmentUnguarded(
|
|
22998
|
+
this,
|
|
22999
|
+
{
|
|
23000
|
+
...params,
|
|
23001
|
+
options: {
|
|
23002
|
+
pin,
|
|
23003
|
+
recoveryEmail: params.options?.recoveryEmail,
|
|
23004
|
+
recoveryLanguage: params.options?.recoveryLanguage
|
|
23005
|
+
}
|
|
23006
|
+
},
|
|
23007
|
+
storage2
|
|
23008
|
+
)
|
|
23009
|
+
)
|
|
21571
23010
|
);
|
|
21572
|
-
if (!result.enrolled) {
|
|
23011
|
+
if (!result.enrolled || !result.changed) {
|
|
21573
23012
|
throw new Error("Automatic recovery is not available for this account.");
|
|
21574
23013
|
}
|
|
21575
23014
|
},
|
|
@@ -21578,7 +23017,7 @@ function createSSSStrategy(config) {
|
|
|
21578
23017
|
const result = await withRotationLock(
|
|
21579
23018
|
() => ensureEscrowEnrollmentUnguarded(this, params, storage2, true)
|
|
21580
23019
|
);
|
|
21581
|
-
if (!result.enrolled) {
|
|
23020
|
+
if (!result.enrolled || !result.changed) {
|
|
21582
23021
|
throw new Error("Automatic recovery is not available for this account.");
|
|
21583
23022
|
}
|
|
21584
23023
|
},
|
|
@@ -21599,8 +23038,15 @@ function createSSSStrategy(config) {
|
|
|
21599
23038
|
escrowEnrollmentInFlight = void 0;
|
|
21600
23039
|
}
|
|
21601
23040
|
},
|
|
23041
|
+
getVerifiedEscrowEnvelope() {
|
|
23042
|
+
return verifiedEscrowEnvelope ? { ...verifiedEscrowEnvelope } : null;
|
|
23043
|
+
},
|
|
21602
23044
|
/** Start or explicitly restart a hold with fresh client-bound resume secrets. */
|
|
21603
23045
|
async startEscrowRecovery(params) {
|
|
23046
|
+
const expectedDid = params.expectedDid;
|
|
23047
|
+
const nitro = config.escrow?.attestation.mode === "nitro";
|
|
23048
|
+
if (nitro && (!expectedDid || (params.tenantId ?? tenantId) !== tenantId))
|
|
23049
|
+
throw new EscrowEvidenceError();
|
|
21604
23050
|
const sessionProof = params.recoverySessionToken !== void 0;
|
|
21605
23051
|
if (sessionProof ? params.token !== void 0 || params.providerType !== void 0 : !params.token || !params.providerType) {
|
|
21606
23052
|
throw new Error("Provide exactly one identity proof");
|
|
@@ -21620,25 +23066,101 @@ function createSSSStrategy(config) {
|
|
|
21620
23066
|
},
|
|
21621
23067
|
params.options?.releasePolicy === "pin"
|
|
21622
23068
|
);
|
|
21623
|
-
|
|
23069
|
+
let expectations;
|
|
23070
|
+
if (nitro && result.resumeToken !== null) {
|
|
23071
|
+
const identity = await fetchVerifiedEnclaveKey();
|
|
23072
|
+
if (identity.mode !== "nitro" || !identity.authority || !result.holdRecord || !expectedDid)
|
|
23073
|
+
throw new EscrowEvidenceError();
|
|
23074
|
+
const verified = await verifyEscrowHoldRecord(
|
|
23075
|
+
result.holdRecord,
|
|
23076
|
+
{
|
|
23077
|
+
tenant: tenantId ?? "learncard",
|
|
23078
|
+
did: expectedDid,
|
|
23079
|
+
holdId: result.holdId,
|
|
23080
|
+
clientEphemeralPublicKey: pair.publicKey,
|
|
23081
|
+
blobHash: result.holdRecord.hold.blobHash
|
|
23082
|
+
},
|
|
23083
|
+
identity
|
|
23084
|
+
);
|
|
23085
|
+
expectations = {
|
|
23086
|
+
tenant: tenantId ?? "learncard",
|
|
23087
|
+
did: expectedDid,
|
|
23088
|
+
holdId: result.holdId,
|
|
23089
|
+
clientEphemeralPublicKey: pair.publicKey,
|
|
23090
|
+
blobHash: result.holdRecord.hold.blobHash,
|
|
23091
|
+
authorityGeneration: verified.authorityGeneration,
|
|
23092
|
+
holdDigest: verified.holdDigest,
|
|
23093
|
+
ledgerPublicKey: identity.authority.ledgerPublicKey,
|
|
23094
|
+
keyId: verified.receipt.keyId
|
|
23095
|
+
};
|
|
23096
|
+
}
|
|
23097
|
+
return { ...result, clientEphemeralPrivateKey: pair.privateKey, expectations };
|
|
21624
23098
|
},
|
|
21625
23099
|
/** Read hold status; secrets (auth or resume token) never travel in a URL. */
|
|
21626
23100
|
async getEscrowRecoveryStatus(params) {
|
|
21627
|
-
const
|
|
21628
|
-
|
|
21629
|
-
)
|
|
21630
|
-
|
|
21631
|
-
|
|
21632
|
-
|
|
21633
|
-
|
|
21634
|
-
|
|
21635
|
-
|
|
21636
|
-
|
|
21637
|
-
|
|
21638
|
-
|
|
23101
|
+
const expected = config.escrow?.attestation.mode === "nitro" && "holdId" in params ? recoveryExpectations(params.holdId, params.expectations) : void 0;
|
|
23102
|
+
const status = await fetchEscrowHoldStatus(params);
|
|
23103
|
+
if (expected && status)
|
|
23104
|
+
await verifyPendingHold(status, expected, await fetchVerifiedEnclaveKey());
|
|
23105
|
+
return status;
|
|
23106
|
+
},
|
|
23107
|
+
/** Submit the confirmation code emailed by the enclave for an authority-mode hold. */
|
|
23108
|
+
async confirmEscrowRecovery(params) {
|
|
23109
|
+
let pending;
|
|
23110
|
+
if (config.escrow?.attestation.mode === "nitro") {
|
|
23111
|
+
const expected = recoveryExpectations(params.holdId, params.expectations);
|
|
23112
|
+
if ((params.tenantId ?? tenantId) !== tenantId) throw new EscrowEvidenceError();
|
|
23113
|
+
const identity = await fetchVerifiedEnclaveKey();
|
|
23114
|
+
const status = await fetchEscrowHoldStatus({
|
|
23115
|
+
holdId: params.holdId,
|
|
23116
|
+
resumeToken: params.resumeToken
|
|
23117
|
+
});
|
|
23118
|
+
if (!status?.holdRecord) {
|
|
23119
|
+
throw new EscrowEvidenceError();
|
|
21639
23120
|
}
|
|
21640
|
-
|
|
21641
|
-
|
|
23121
|
+
const holdRecord = await verifyPendingHold(status, expected, identity);
|
|
23122
|
+
pending = { identity, holdRecord, expected };
|
|
23123
|
+
}
|
|
23124
|
+
const confirm = /* @__PURE__ */ __name(() => escrowRequest("/confirm", {
|
|
23125
|
+
method: "POST",
|
|
23126
|
+
headers: buildHeaders("", void 0, params.tenantId ?? tenantId),
|
|
23127
|
+
body: JSON.stringify({
|
|
23128
|
+
holdId: params.holdId,
|
|
23129
|
+
resumeToken: params.resumeToken,
|
|
23130
|
+
code: params.code
|
|
23131
|
+
})
|
|
23132
|
+
}), "confirm");
|
|
23133
|
+
const result = await confirm();
|
|
23134
|
+
if (pending) {
|
|
23135
|
+
if (!result.receipt) {
|
|
23136
|
+
throw new EscrowEvidenceError();
|
|
23137
|
+
}
|
|
23138
|
+
const receipt = await verifyEscrowHoldConfirmation(
|
|
23139
|
+
result.receipt,
|
|
23140
|
+
pending.holdRecord,
|
|
23141
|
+
pending.expected,
|
|
23142
|
+
pending.identity
|
|
23143
|
+
);
|
|
23144
|
+
if (receipt.kind === "commit") {
|
|
23145
|
+
const readback = await confirm();
|
|
23146
|
+
const snapshot = await verifyEscrowHoldConfirmation(
|
|
23147
|
+
readback.receipt,
|
|
23148
|
+
pending.holdRecord,
|
|
23149
|
+
pending.expected,
|
|
23150
|
+
pending.identity
|
|
23151
|
+
);
|
|
23152
|
+
if (snapshot.kind !== "snapshot") throw new EscrowEvidenceError();
|
|
23153
|
+
}
|
|
23154
|
+
}
|
|
23155
|
+
return { success: true };
|
|
23156
|
+
},
|
|
23157
|
+
/** Request a fresh confirmation code for a hold awaiting confirmation. */
|
|
23158
|
+
async resendEscrowRecoveryCode(params) {
|
|
23159
|
+
return escrowRequest("/resend", {
|
|
23160
|
+
method: "POST",
|
|
23161
|
+
headers: buildHeaders("", void 0, params.tenantId ?? tenantId),
|
|
23162
|
+
body: JSON.stringify({ holdId: params.holdId, resumeToken: params.resumeToken })
|
|
23163
|
+
});
|
|
21642
23164
|
},
|
|
21643
23165
|
/** Cancel a pending hold with a fresh DID-owner proof. */
|
|
21644
23166
|
async cancelEscrowRecovery(params) {
|
|
@@ -21670,8 +23192,19 @@ function createSSSStrategy(config) {
|
|
|
21670
23192
|
const start = input.method === "escrow-pin" ? await this.startEscrowRecovery({
|
|
21671
23193
|
token,
|
|
21672
23194
|
providerType,
|
|
23195
|
+
expectedDid: input.expectedDid,
|
|
21673
23196
|
options: { releasePolicy: "pin" }
|
|
21674
23197
|
}) : input;
|
|
23198
|
+
const expected = config.escrow?.attestation.mode === "nitro" ? recoveryExpectations(start.holdId, start.expectations) : void 0;
|
|
23199
|
+
if (expected) {
|
|
23200
|
+
if (!start.resumeToken) throw new EscrowEvidenceError();
|
|
23201
|
+
const status = await fetchEscrowHoldStatus({
|
|
23202
|
+
holdId: start.holdId,
|
|
23203
|
+
resumeToken: start.resumeToken
|
|
23204
|
+
});
|
|
23205
|
+
if (!status) throw new EscrowEvidenceError();
|
|
23206
|
+
await verifyPendingHold(status, expected, await fetchVerifiedEnclaveKey());
|
|
23207
|
+
}
|
|
21675
23208
|
let pinProof;
|
|
21676
23209
|
if (input.method === "escrow-pin") {
|
|
21677
23210
|
if (!("pinSalt" in start) || !start.pinSalt || !start.resumeToken)
|
|
@@ -21695,6 +23228,8 @@ function createSSSStrategy(config) {
|
|
|
21695
23228
|
material.sealedShare,
|
|
21696
23229
|
start.clientEphemeralPrivateKey
|
|
21697
23230
|
);
|
|
23231
|
+
if (expected && (plaintext.did !== expected.did || plaintext.holdId !== expected.holdId))
|
|
23232
|
+
throw new EscrowEvidenceError();
|
|
21698
23233
|
if (plaintext.holdId !== start.holdId || plaintext.did !== material.primaryDid || plaintext.shareVersion !== material.shareVersion) {
|
|
21699
23234
|
throw new Error("Escrow recovery material does not match the request");
|
|
21700
23235
|
}
|
|
@@ -22108,10 +23643,10 @@ function createSSSStrategy(config) {
|
|
|
22108
23643
|
const pending = pendingPhraseConfirmation;
|
|
22109
23644
|
if (!pending) throw new Error("Generate a new recovery phrase to continue");
|
|
22110
23645
|
const phraseWords = pending.phrase.trim().toLowerCase().split(/\s+/);
|
|
22111
|
-
const
|
|
23646
|
+
const matches2 = input.challengeWords.length === pending.challengeWordIndices.length && pending.challengeWordIndices.every(
|
|
22112
23647
|
(wordIndex, answerIndex) => input.challengeWords[answerIndex]?.trim().toLowerCase() === phraseWords[wordIndex]
|
|
22113
23648
|
);
|
|
22114
|
-
if (!
|
|
23649
|
+
if (!matches2) {
|
|
22115
23650
|
throw new Error("Those words do not match. Check your phrase and try again.");
|
|
22116
23651
|
}
|
|
22117
23652
|
} else if (input.method === "backup") {
|
|
@@ -22497,6 +24032,7 @@ function createSSSStrategy(config) {
|
|
|
22497
24032
|
},
|
|
22498
24033
|
async cleanup() {
|
|
22499
24034
|
storageGeneration++;
|
|
24035
|
+
verifiedEscrowEnvelope = void 0;
|
|
22500
24036
|
await Promise.allSettled(localWrites);
|
|
22501
24037
|
}
|
|
22502
24038
|
};
|
|
@@ -22727,9 +24263,11 @@ export {
|
|
|
22727
24263
|
ESCROW_ALGORITHM,
|
|
22728
24264
|
ESCROW_BLOB_INFO,
|
|
22729
24265
|
ESCROW_CLIENT_KEY_ID,
|
|
24266
|
+
ESCROW_ENROLLMENT_INTENT_DOMAIN,
|
|
22730
24267
|
ESCROW_ENVELOPE_VERSION,
|
|
22731
24268
|
ESCROW_PIN_MAX_ATTEMPTS,
|
|
22732
24269
|
ESCROW_RELEASE_INFO,
|
|
24270
|
+
EscrowEvidenceError,
|
|
22733
24271
|
EscrowHoldRestartThrottledError,
|
|
22734
24272
|
EscrowPinLockedError,
|
|
22735
24273
|
EscrowPinMismatchError,
|
|
@@ -22737,6 +24275,7 @@ export {
|
|
|
22737
24275
|
EscrowPinUnavailableError,
|
|
22738
24276
|
EscrowRequestError,
|
|
22739
24277
|
IdentityRecoverySessionConsumedError,
|
|
24278
|
+
NitroAttestationError,
|
|
22740
24279
|
PIN_MAX_LENGTH,
|
|
22741
24280
|
PIN_MIN_LENGTH,
|
|
22742
24281
|
SSSApiClient,
|
|
@@ -22756,6 +24295,7 @@ export {
|
|
|
22756
24295
|
constantTimeEqualHex,
|
|
22757
24296
|
countWords,
|
|
22758
24297
|
createAdaptiveStorage,
|
|
24298
|
+
createEscrowEnrollmentIntent,
|
|
22759
24299
|
createPasskeyCredential,
|
|
22760
24300
|
createQrLoginSession,
|
|
22761
24301
|
createSSSKeyManager,
|
|
@@ -22769,6 +24309,7 @@ export {
|
|
|
22769
24309
|
deriveKeyFromPasskey,
|
|
22770
24310
|
deriveKeyFromPassword,
|
|
22771
24311
|
derivePinProof,
|
|
24312
|
+
encodeEscrowEnrollmentIntent,
|
|
22772
24313
|
encryptEmailRelayPayload,
|
|
22773
24314
|
encryptEscrowBlob,
|
|
22774
24315
|
encryptShareForTransfer,
|
|
@@ -22781,6 +24322,7 @@ export {
|
|
|
22781
24322
|
generatePinSalt,
|
|
22782
24323
|
generateRecoveryPhrase,
|
|
22783
24324
|
getDeviceShare,
|
|
24325
|
+
getEscrowBlobIdentity,
|
|
22784
24326
|
getQrLoginSessionInfo,
|
|
22785
24327
|
getShareVersion,
|
|
22786
24328
|
hasDeviceShare,
|
|
@@ -22802,9 +24344,11 @@ export {
|
|
|
22802
24344
|
reconstructFromShares,
|
|
22803
24345
|
reconstructPrivateKey,
|
|
22804
24346
|
recoveryPhraseToShare,
|
|
24347
|
+
resolveEscrowEnrollmentAction,
|
|
22805
24348
|
sealEscrowRelease,
|
|
22806
24349
|
setPublicComputerMode,
|
|
22807
24350
|
shareToRecoveryPhrase,
|
|
24351
|
+
signEscrowEnrollmentIntent,
|
|
22808
24352
|
splitAndVerify,
|
|
22809
24353
|
splitPrivateKey,
|
|
22810
24354
|
storeDeviceShare,
|
|
@@ -22812,5 +24356,9 @@ export {
|
|
|
22812
24356
|
validatePin,
|
|
22813
24357
|
validateRecoveryPhrase,
|
|
22814
24358
|
verifyEnclaveAttestation,
|
|
22815
|
-
|
|
24359
|
+
verifyEscrowAuthorityState,
|
|
24360
|
+
verifyEscrowEnrollmentCommit,
|
|
24361
|
+
verifyNitroAttestationDocument,
|
|
24362
|
+
verifyStoredShares,
|
|
24363
|
+
violatesCarryContactRule
|
|
22816
24364
|
};
|