@learncard/sss-key-manager 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/README.md +13 -0
  2. package/dist/escrow-attestation.d.ts +5 -1
  3. package/dist/escrow-attestation.d.ts.map +1 -1
  4. package/dist/escrow-nitro-attestation.d.ts +32 -0
  5. package/dist/escrow-nitro-attestation.d.ts.map +1 -0
  6. package/dist/index.d.ts +3 -1
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/sss-key-manager.cjs.development.js +2995 -320
  9. package/dist/sss-key-manager.cjs.development.js.map +4 -4
  10. package/dist/sss-key-manager.cjs.production.min.js +33 -33
  11. package/dist/sss-key-manager.cjs.production.min.js.map +4 -4
  12. package/dist/sss-key-manager.esm.js +774 -170
  13. package/dist/sss-key-manager.esm.js.map +4 -4
  14. package/dist/sss-strategy.d.ts.map +1 -1
  15. package/dist/types.d.ts +15 -4
  16. package/dist/types.d.ts.map +1 -1
  17. package/package.json +7 -3
  18. package/src/__fixtures__/escrow-vectors-rust.json +82 -0
  19. package/src/__fixtures__/escrow-vectors.json +103 -0
  20. package/src/__fixtures__/nitro-attestation/bad-signature.cbor.b64 +1 -0
  21. package/src/__fixtures__/nitro-attestation/debug-zero-pcrs.cbor.b64 +1 -0
  22. package/src/__fixtures__/nitro-attestation/legacy-user-data.cbor.b64 +1 -0
  23. package/src/__fixtures__/nitro-attestation/manifest.json +60 -0
  24. package/src/__fixtures__/nitro-attestation/nonce-mismatch.cbor.b64 +1 -0
  25. package/src/__fixtures__/nitro-attestation/root.pem +12 -0
  26. package/src/__fixtures__/nitro-attestation/stale-timestamp.cbor.b64 +1 -0
  27. package/src/__fixtures__/nitro-attestation/tampered-previous-key-ids.cbor.b64 +1 -0
  28. package/src/__fixtures__/nitro-attestation/truncated-chain.cbor.b64 +1 -0
  29. package/src/__fixtures__/nitro-attestation/valid.cbor.b64 +1 -0
  30. package/src/__fixtures__/nitro-attestation/wrong-pcr0.cbor.b64 +1 -0
  31. package/src/__fixtures__/nitro-attestation/wrong-root.cbor.b64 +1 -0
  32. package/src/escrow-attestation.test.ts +7 -2
  33. package/src/escrow-attestation.ts +71 -10
  34. package/src/escrow-nitro-attestation.test.ts +204 -0
  35. package/src/escrow-nitro-attestation.ts +286 -0
  36. package/src/escrow-vectors.test.ts +198 -0
  37. package/src/index.ts +8 -1
  38. package/src/sss-session-writes.test.ts +2 -2
  39. package/src/sss-strategy.test.ts +95 -2
  40. package/src/sss-strategy.ts +128 -88
  41. package/src/types.ts +12 -1
@@ -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
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
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"),
@@ -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(() => decode2, "decode"),
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(() => encode2, "encode"),
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"),
@@ -568,7 +610,7 @@ var require_types_cjs_development = __commonJS({
568
610
  gte: /* @__PURE__ */ __name(() => _gte, "gte"),
569
611
  guid: /* @__PURE__ */ __name(() => guid2, "guid"),
570
612
  hash: /* @__PURE__ */ __name(() => hash, "hash"),
571
- hex: /* @__PURE__ */ __name(() => hex2, "hex"),
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(() => map, "map"),
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"),
@@ -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(() => decode, "decode"),
965
+ decode: /* @__PURE__ */ __name(() => decode2, "decode"),
924
966
  decodeAsync: /* @__PURE__ */ __name(() => decodeAsync, "decodeAsync"),
925
967
  describe: /* @__PURE__ */ __name(() => describe, "describe"),
926
- encode: /* @__PURE__ */ __name(() => encode, "encode"),
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"),
@@ -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 bytes = new Uint8Array(binaryString.length);
1854
+ const bytes2 = new Uint8Array(binaryString.length);
1813
1855
  for (let i = 0; i < binaryString.length; i++) {
1814
- bytes[i] = binaryString.charCodeAt(i);
1856
+ bytes2[i] = binaryString.charCodeAt(i);
1815
1857
  }
1816
- return bytes;
1858
+ return bytes2;
1817
1859
  }
1818
1860
  __name(base64ToUint8Array, "base64ToUint8Array");
1819
1861
  __name2(base64ToUint8Array, "base64ToUint8Array");
1820
- function uint8ArrayToBase64(bytes) {
1862
+ function uint8ArrayToBase64(bytes2) {
1821
1863
  let binaryString = "";
1822
- for (let i = 0; i < bytes.length; i++) {
1823
- binaryString += String.fromCharCode(bytes[i]);
1864
+ for (let i = 0; i < bytes2.length; i++) {
1865
+ binaryString += String.fromCharCode(bytes2[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(bytes) {
1837
- return uint8ArrayToBase64(bytes).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
1878
+ function uint8ArrayToBase64url(bytes2) {
1879
+ return uint8ArrayToBase64(bytes2).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 bytes = new Uint8Array(cleanHex.length / 2);
1888
+ const bytes2 = new Uint8Array(cleanHex.length / 2);
1847
1889
  for (let i = 0; i < cleanHex.length; i += 2) {
1848
- bytes[i / 2] = Number.parseInt(cleanHex.slice(i, i + 2), 16);
1890
+ bytes2[i / 2] = Number.parseInt(cleanHex.slice(i, i + 2), 16);
1849
1891
  }
1850
- return bytes;
1892
+ return bytes2;
1851
1893
  }
1852
1894
  __name(hexToUint8Array, "hexToUint8Array");
1853
1895
  __name2(hexToUint8Array, "hexToUint8Array");
1854
- function uint8ArrayToHex(bytes) {
1855
- return Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join("");
1896
+ function uint8ArrayToHex(bytes2) {
1897
+ return Array.from(bytes2).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 encode = /* @__PURE__ */ _encode($ZodRealError);
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 decode = /* @__PURE__ */ _decode($ZodRealError);
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);
@@ -2119,7 +2161,7 @@ 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(() => hex, "hex"),
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"),
@@ -2242,7 +2284,7 @@ var require_types_cjs_development = __commonJS({
2242
2284
  var _undefined = /^undefined$/i;
2243
2285
  var lowercase = /^[^A-Z]*$/;
2244
2286
  var uppercase = /^[^a-z]*$/;
2245
- var hex = /^[0-9a-fA-F]*$/;
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
  }
@@ -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 map2 = /* @__PURE__ */ new Map();
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 (map2.has(v)) {
3997
+ if (map22.has(v)) {
3956
3998
  throw new Error(`Duplicate discriminator value "${String(v)}"`);
3957
3999
  }
3958
- map2.set(v, o);
4000
+ map22.set(v, o);
3959
4001
  }
3960
4002
  }
3961
- return map2;
4003
+ return map22;
3962
4004
  });
3963
4005
  inst._zod.parse = (payload, ctx) => {
3964
4006
  const input = payload.value;
@@ -13475,7 +13517,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
13475
13517
  function: /* @__PURE__ */ __name(() => _function, "function"),
13476
13518
  guid: /* @__PURE__ */ __name(() => guid2, "guid"),
13477
13519
  hash: /* @__PURE__ */ __name(() => hash, "hash"),
13478
- hex: /* @__PURE__ */ __name(() => hex2, "hex"),
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(() => map, "map"),
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"),
@@ -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 encode2 = /* @__PURE__ */ _encode(ZodRealError);
13667
- var decode2 = /* @__PURE__ */ _decode(ZodRealError);
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) => encode2(inst, data, params);
13731
- inst.decode = (data, params) => decode2(inst, 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);
@@ -14153,11 +14195,11 @@ 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 hex2(_params) {
14198
+ function hex22(_params) {
14157
14199
  return /* @__PURE__ */ _stringFormat(ZodCustomStringFormat, "hex", regexes_exports.hex, _params);
14158
14200
  }
14159
- __name(hex2, "hex2");
14160
- __name2(hex2, "hex");
14201
+ __name(hex22, "hex2");
14202
+ __name2(hex22, "hex");
14161
14203
  function hash(alg, params) {
14162
14204
  const enc = params?.enc ?? "hex";
14163
14205
  const format = `${alg}_${enc}`;
@@ -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 map(keyType, valueType, params) {
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(map, "map");
14661
- __name2(map, "map");
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);
@@ -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(map2) {
15203
+ function setErrorMap(map22) {
15162
15204
  config({
15163
- customError: map2
15205
+ customError: map22
15164
15206
  });
15165
15207
  }
15166
15208
  __name(setErrorMap, "setErrorMap");
@@ -16118,7 +16160,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16118
16160
  "replacedBy"
16119
16161
  ]).or(external_exports.string());
16120
16162
  var AssociationValidator = external_exports.object({
16121
- type: external_exports.string().array().nonempty(),
16163
+ // Accept compacted scalars while retaining the existing permissive array contract.
16164
+ type: external_exports.string().min(1).or(external_exports.string().array().nonempty()),
16122
16165
  associationType: AssociationTypeValidator,
16123
16166
  sourceId: external_exports.string().optional(),
16124
16167
  targetId: external_exports.string()
@@ -16941,11 +16984,48 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16941
16984
  updatedAt: external_exports.string(),
16942
16985
  expiresAt: external_exports.string().optional(),
16943
16986
  autoBoosts: external_exports.string().array().optional(),
16944
- writers: external_exports.array(LCNProfileValidator).optional()
16987
+ writers: external_exports.array(LCNProfileValidator).optional(),
16988
+ recipients: external_exports.array(LCNPublicProfileValidator.extend({ did: external_exports.string() })).optional(),
16989
+ audienceVersion: external_exports.number().int().nonnegative().optional()
16945
16990
  });
16946
- var ConsentFlowContractRequestStatusValidator = external_exports.enum(["pending", "accepted", "denied"]).nullable();
16991
+ var ConsentFlowContractRequestStatusValidator = external_exports.enum(["pending", "accepted", "denied", "cancelled"]).nullable();
16947
16992
  var ConsentFlowContractRequestReadStatusValidator = external_exports.enum(["unseen", "seen"]).nullable();
16948
- var ConsentFlowContractRequestForProfileValidator = external_exports.object({
16993
+ var ConsentFlowReferralValidator = external_exports.object({
16994
+ requestId: external_exports.string(),
16995
+ requestedBy: external_exports.string(),
16996
+ externalReferenceId: external_exports.string().max(256).optional()
16997
+ });
16998
+ var ContractRequestFieldsValidator = ConsentFlowReferralValidator.partial().extend({
16999
+ requestedAt: external_exports.string().optional(),
17000
+ message: external_exports.string().max(500).optional()
17001
+ });
17002
+ var SendContractRequestValidator = external_exports.object({
17003
+ contractUri: external_exports.string(),
17004
+ targetProfileId: external_exports.string(),
17005
+ externalReferenceId: external_exports.string().trim().min(1).max(256).optional(),
17006
+ message: external_exports.string().trim().max(500).optional()
17007
+ });
17008
+ var ConsentFlowWebhookMetadataValidator = external_exports.object({
17009
+ eventId: external_exports.string(),
17010
+ deliveryKey: external_exports.string(),
17011
+ event: external_exports.enum([
17012
+ "request_sent",
17013
+ "request_accepted",
17014
+ "request_denied",
17015
+ "request_cancelled",
17016
+ "consent_created",
17017
+ "consent_updated",
17018
+ "consent_withdrawn",
17019
+ "credentials_synced"
17020
+ ]),
17021
+ contractUri: external_exports.string(),
17022
+ termsUri: external_exports.string().optional(),
17023
+ requestId: external_exports.string().optional(),
17024
+ requestedBy: external_exports.string().optional(),
17025
+ externalReferenceId: external_exports.string().optional(),
17026
+ recipientRole: external_exports.enum(["owner", "recipient", "requester", "target"])
17027
+ });
17028
+ var ConsentFlowContractRequestForProfileValidator = ContractRequestFieldsValidator.extend({
16949
17029
  profile: LCNProfileValidator,
16950
17030
  status: ConsentFlowContractRequestStatusValidator,
16951
17031
  readStatus: ConsentFlowContractRequestReadStatusValidator.optional()
@@ -16991,6 +17071,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16991
17071
  expiresAt: external_exports.string().optional(),
16992
17072
  oneTime: external_exports.boolean().optional(),
16993
17073
  terms: ConsentFlowTermsValidator,
17074
+ referral: ConsentFlowReferralValidator.optional(),
16994
17075
  contract: ConsentFlowContractDetailsValidator,
16995
17076
  uri: external_exports.string(),
16996
17077
  consenter: LCNProfileValidator,
@@ -17086,6 +17167,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17086
17167
  oneTime: external_exports.boolean().optional(),
17087
17168
  terms: ConsentFlowTermsValidator.optional(),
17088
17169
  guardianApproval: ConsentFlowGuardianApprovalValidator.optional(),
17170
+ referral: ConsentFlowReferralValidator.optional(),
17089
17171
  id: external_exports.string(),
17090
17172
  action: ConsentFlowTransactionActionValidator,
17091
17173
  date: external_exports.string(),
@@ -17096,6 +17178,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17096
17178
  status: ConsentFlowTermsStatusValidator,
17097
17179
  contract: ConsentFlowContractDetailsValidator,
17098
17180
  terms: ConsentFlowTermsValidator,
17181
+ referral: ConsentFlowReferralValidator.optional(),
17099
17182
  transactions: ConsentFlowTransactionValidator.array()
17100
17183
  });
17101
17184
  var HolderExportMetadataValidator = external_exports.object({
@@ -17832,7 +17915,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17832
17915
  displayName: external_exports.string(),
17833
17916
  email: external_exports.string().optional()
17834
17917
  });
17835
- var AppStoreListingValidator = external_exports.object({
17918
+ var AppStoreListingFieldsValidator = external_exports.object({
17836
17919
  listing_id: external_exports.string(),
17837
17920
  slug: external_exports.string().optional(),
17838
17921
  display_name: external_exports.string(),
@@ -17858,15 +17941,33 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17858
17941
  submitter: AppStoreListingSubmitterValidator.optional(),
17859
17942
  contact_email: external_exports.string().email().optional()
17860
17943
  });
17944
+ var PendingListingUpdateStatusValidator = external_exports.enum(["DRAFT", "PENDING_REVIEW"]);
17945
+ var PendingListingUpdateValidator = external_exports.object({
17946
+ status: PendingListingUpdateStatusValidator,
17947
+ submitted_at: external_exports.string().optional(),
17948
+ changes: AppStoreListingFieldsValidator.omit({
17949
+ listing_id: true,
17950
+ app_listing_status: true,
17951
+ promotion_level: true,
17952
+ submitted_at: true,
17953
+ submitter: true
17954
+ }).partial(),
17955
+ manifest_version: external_exports.number().int().min(1).optional()
17956
+ });
17957
+ var AppStoreListingValidator = AppStoreListingFieldsValidator.extend({
17958
+ pending_update: PendingListingUpdateValidator.optional()
17959
+ });
17861
17960
  var AppStoreListingCreateValidator = AppStoreListingValidator.omit({
17862
17961
  listing_id: true,
17863
17962
  app_listing_status: true,
17864
- promotion_level: true
17963
+ promotion_level: true,
17964
+ pending_update: true
17865
17965
  });
17866
17966
  var AppStoreListingUpdateValidator = AppStoreListingValidator.partial().omit({
17867
17967
  listing_id: true,
17868
17968
  app_listing_status: true,
17869
- promotion_level: true
17969
+ promotion_level: true,
17970
+ pending_update: true
17870
17971
  });
17871
17972
  var InstalledAppValidator = AppStoreListingValidator.extend({
17872
17973
  installed_at: external_exports.string()
@@ -17881,12 +17982,87 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17881
17982
  templateAlias: external_exports.string().min(1).max(50).regex(/^[a-z0-9-]+$/),
17882
17983
  boostUri: external_exports.string()
17883
17984
  });
17884
- var SendCredentialEventValidator = external_exports.object({
17985
+ var InlineWalletCategoryValidator = external_exports.enum([
17986
+ "Achievement",
17987
+ "Skill",
17988
+ "ID",
17989
+ "Learning History",
17990
+ "Work History",
17991
+ "Social Badges",
17992
+ "Membership",
17993
+ "Accomplishment",
17994
+ "Experiences",
17995
+ "Accommodation",
17996
+ "Family"
17997
+ ]);
17998
+ var InlineAlignmentValidator = external_exports.object({
17999
+ name: external_exports.string(),
18000
+ url: external_exports.string(),
18001
+ framework: external_exports.string().optional(),
18002
+ code: external_exports.string().optional()
18003
+ }).passthrough();
18004
+ var InlineEvidenceValidator = external_exports.object({
18005
+ id: external_exports.string().optional(),
18006
+ name: external_exports.string().optional(),
18007
+ narrative: external_exports.string().optional()
18008
+ }).passthrough();
18009
+ var InlineWalletSkillTagValidator = external_exports.object({
18010
+ frameworkId: external_exports.string(),
18011
+ id: external_exports.string(),
18012
+ proficiencyLevel: external_exports.string().optional()
18013
+ }).passthrough();
18014
+ var SimpleInlineCredentialTemplateValidator = external_exports.object({
18015
+ rawCredential: external_exports.undefined().optional(),
18016
+ name: external_exports.string(),
18017
+ description: external_exports.string().optional(),
18018
+ image: external_exports.string().optional(),
18019
+ issuerName: external_exports.string().optional(),
18020
+ achievementType: external_exports.string().optional(),
18021
+ category: InlineWalletCategoryValidator.optional(),
18022
+ criteria: external_exports.object({
18023
+ narrative: external_exports.string().optional(),
18024
+ url: external_exports.string().optional()
18025
+ }).passthrough().optional(),
18026
+ alignments: external_exports.array(InlineAlignmentValidator).optional(),
18027
+ tags: external_exports.array(external_exports.string()).optional(),
18028
+ activity: external_exports.object({
18029
+ startDate: external_exports.string().optional(),
18030
+ endDate: external_exports.string().optional()
18031
+ }).passthrough().optional(),
18032
+ credits: external_exports.object({
18033
+ earned: external_exports.union([external_exports.number(), external_exports.string()]).optional(),
18034
+ available: external_exports.union([external_exports.number(), external_exports.string()]).optional()
18035
+ }).passthrough().optional(),
18036
+ validUntil: external_exports.string().optional(),
18037
+ evidence: external_exports.array(InlineEvidenceValidator).optional(),
18038
+ walletSkills: external_exports.array(InlineWalletSkillTagValidator).optional()
18039
+ }).passthrough();
18040
+ var RawInlineCredentialTemplateValidator = external_exports.object({
18041
+ rawCredential: external_exports.record(external_exports.string(), external_exports.unknown()),
18042
+ category: InlineWalletCategoryValidator.optional(),
18043
+ walletSkills: external_exports.array(InlineWalletSkillTagValidator).optional()
18044
+ }).passthrough();
18045
+ var InlineCredentialTemplateValidator = external_exports.union([
18046
+ RawInlineCredentialTemplateValidator,
18047
+ SimpleInlineCredentialTemplateValidator
18048
+ ]);
18049
+ var LegacySendCredentialEventValidator = external_exports.object({
17885
18050
  type: external_exports.literal("send-credential"),
17886
18051
  templateAlias: external_exports.string(),
17887
18052
  templateData: external_exports.record(external_exports.string(), external_exports.unknown()).optional(),
17888
18053
  preventDuplicateClaim: external_exports.boolean().optional()
17889
18054
  });
18055
+ var InlineSendCredentialEventValidator = external_exports.object({
18056
+ type: external_exports.literal("send-credential"),
18057
+ alias: external_exports.string(),
18058
+ template: InlineCredentialTemplateValidator,
18059
+ templateData: external_exports.record(external_exports.string(), external_exports.unknown()).optional(),
18060
+ preventDuplicateClaim: external_exports.boolean().optional()
18061
+ });
18062
+ var SendCredentialEventValidator = external_exports.union([
18063
+ LegacySendCredentialEventValidator,
18064
+ InlineSendCredentialEventValidator
18065
+ ]);
17890
18066
  var CheckCredentialEventValidator = external_exports.object({
17891
18067
  type: external_exports.literal("check-credential"),
17892
18068
  templateAlias: external_exports.string().optional(),
@@ -17981,7 +18157,119 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17981
18157
  type: external_exports.literal("get-counters"),
17982
18158
  keys: external_exports.array(counterKeyValidator).min(1).max(50).optional()
17983
18159
  });
17984
- var AppEventValidator = external_exports.discriminatedUnion("type", [
18160
+ var ConsentRequestWalletCategoryValidator = external_exports.enum([
18161
+ "Achievement",
18162
+ "Skill",
18163
+ "ID",
18164
+ "Learning History",
18165
+ "Work History",
18166
+ "Social Badges",
18167
+ "Membership",
18168
+ "Accomplishment",
18169
+ "Experiences",
18170
+ "Accommodation",
18171
+ "Family"
18172
+ ]);
18173
+ var ConsentRequestPersonalFieldValidator = external_exports.enum([
18174
+ "name",
18175
+ "email",
18176
+ "phone",
18177
+ "birthDate",
18178
+ "country",
18179
+ "avatar"
18180
+ ]);
18181
+ var ConsentRequestValidator = external_exports.object({
18182
+ read: external_exports.object({
18183
+ credentialCategories: external_exports.array(ConsentRequestWalletCategoryValidator).optional(),
18184
+ personalFields: external_exports.array(ConsentRequestPersonalFieldValidator).optional()
18185
+ }).optional(),
18186
+ write: external_exports.object({
18187
+ credentialCategories: external_exports.array(ConsentRequestWalletCategoryValidator).optional()
18188
+ }).optional(),
18189
+ reason: external_exports.string().optional()
18190
+ });
18191
+ var NormalizedConsentScopesValidator = external_exports.object({
18192
+ read: external_exports.object({
18193
+ credentialCategories: external_exports.array(ConsentRequestWalletCategoryValidator).default([]),
18194
+ personalFields: external_exports.array(ConsentRequestPersonalFieldValidator).default([])
18195
+ }),
18196
+ write: external_exports.object({
18197
+ credentialCategories: external_exports.array(ConsentRequestWalletCategoryValidator).default([])
18198
+ })
18199
+ });
18200
+ var CapturedTemplateRecordValidator = external_exports.object({
18201
+ alias: external_exports.string(),
18202
+ template: InlineCredentialTemplateValidator,
18203
+ version: external_exports.number().int().min(1),
18204
+ lastUsedAt: external_exports.string()
18205
+ }).passthrough();
18206
+ var CapturedConsentRecordValidator = external_exports.object({
18207
+ scopes: NormalizedConsentScopesValidator,
18208
+ reason: external_exports.string().optional(),
18209
+ lastUsedAt: external_exports.string()
18210
+ }).passthrough();
18211
+ var AppManifestValidator = external_exports.object({
18212
+ manifestVersion: external_exports.literal(1),
18213
+ appUrl: external_exports.string(),
18214
+ appKey: external_exports.string().max(200).optional(),
18215
+ suggestedName: external_exports.string().optional(),
18216
+ suggestedIconUrl: external_exports.string().optional(),
18217
+ permissions: external_exports.array(external_exports.string()).default([]),
18218
+ templates: external_exports.array(CapturedTemplateRecordValidator).default([]),
18219
+ consentRequests: external_exports.array(CapturedConsentRecordValidator).default([]),
18220
+ usedConsentContract: external_exports.boolean().optional(),
18221
+ featuresLaunched: external_exports.array(external_exports.string()).default([]),
18222
+ counterKeys: external_exports.array(external_exports.string()).default([]),
18223
+ usedLearnerContext: external_exports.boolean(),
18224
+ usedNotifications: external_exports.boolean(),
18225
+ firstCapturedAt: external_exports.string(),
18226
+ lastUpdatedAt: external_exports.string()
18227
+ }).passthrough();
18228
+ var AppManifestVersionStatusValidator = external_exports.enum(["draft", "active", "superseded"]);
18229
+ var AppManifestVersionValidator = external_exports.object({
18230
+ id: external_exports.string(),
18231
+ version: external_exports.number().int().min(1),
18232
+ manifestHash: external_exports.string(),
18233
+ manifest: AppManifestValidator,
18234
+ status: AppManifestVersionStatusValidator,
18235
+ createdAt: external_exports.string(),
18236
+ activatedAt: external_exports.string().optional()
18237
+ });
18238
+ var AppManifestStringDiffValidator = external_exports.object({
18239
+ added: external_exports.array(external_exports.string()),
18240
+ removed: external_exports.array(external_exports.string()),
18241
+ changed: external_exports.array(external_exports.string())
18242
+ });
18243
+ var AppManifestTemplateRefValidator = external_exports.object({
18244
+ alias: external_exports.string(),
18245
+ version: external_exports.number().int().min(1)
18246
+ });
18247
+ var AppManifestTemplateChangeValidator = external_exports.object({
18248
+ alias: external_exports.string(),
18249
+ fromVersion: external_exports.number().int().min(1),
18250
+ toVersion: external_exports.number().int().min(1)
18251
+ });
18252
+ var AppManifestDiffValidator = external_exports.object({
18253
+ permissions: AppManifestStringDiffValidator,
18254
+ templates: external_exports.object({
18255
+ added: external_exports.array(AppManifestTemplateRefValidator),
18256
+ removed: external_exports.array(AppManifestTemplateRefValidator),
18257
+ changed: external_exports.array(AppManifestTemplateChangeValidator)
18258
+ }),
18259
+ consentScopes: AppManifestStringDiffValidator,
18260
+ featurePaths: AppManifestStringDiffValidator,
18261
+ counterKeys: AppManifestStringDiffValidator,
18262
+ requiresReview: external_exports.boolean()
18263
+ });
18264
+ var UpsertConsentContractEventValidator = external_exports.object({
18265
+ type: external_exports.literal("upsert-consent-contract"),
18266
+ scopes: ConsentRequestValidator
18267
+ });
18268
+ var UpsertConsentContractResponseValidator = external_exports.object({
18269
+ contractUri: external_exports.string(),
18270
+ created: external_exports.boolean()
18271
+ });
18272
+ var AppEventValidator = external_exports.union([
17985
18273
  SendCredentialEventValidator,
17986
18274
  CheckCredentialEventValidator,
17987
18275
  CheckIssuanceStatusEventValidator,
@@ -17991,7 +18279,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17991
18279
  SendNotificationEventValidator,
17992
18280
  IncrementCounterEventValidator,
17993
18281
  GetCounterEventValidator,
17994
- GetCountersEventValidator
18282
+ GetCountersEventValidator,
18283
+ UpsertConsentContractEventValidator
17995
18284
  ]);
17996
18285
  var AppEventInputValidator = external_exports.object({
17997
18286
  listingId: external_exports.string(),
@@ -18070,6 +18359,20 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18070
18359
  __name2(this, "AuthSessionError");
18071
18360
  }
18072
18361
  };
18362
+ var UnsupportedSignInOperationError = class extends Error {
18363
+ static {
18364
+ __name(this, "UnsupportedSignInOperationError");
18365
+ }
18366
+ constructor(operation, providerType) {
18367
+ super(`${operation} is not supported by ${providerType}`);
18368
+ this.operation = operation;
18369
+ this.providerType = providerType;
18370
+ this.name = "UnsupportedSignInOperationError";
18371
+ }
18372
+ static {
18373
+ __name2(this, "UnsupportedSignInOperationError");
18374
+ }
18375
+ };
18073
18376
  var ESCROW_PIN_LOCKED_MESSAGE2 = "Too many incorrect PIN attempts. You can still recover by waiting.";
18074
18377
  var ESCROW_PIN_UNAVAILABLE_MESSAGE2 = "PIN recovery is not available for this account.";
18075
18378
  var ESCROW_PIN_MISMATCH_PATTERN2 = /^Incorrect PIN\. (\d+) attempts left\.$/;
@@ -18216,12 +18519,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18216
18519
  }
18217
18520
  return table;
18218
18521
  })();
18219
- var encodeBase64Url = /* @__PURE__ */ __name2((bytes) => {
18522
+ var encodeBase64Url = /* @__PURE__ */ __name2((bytes2) => {
18220
18523
  let output = "";
18221
- for (let index = 0; index < bytes.length; index += 3) {
18222
- const first = bytes[index];
18223
- const second = bytes[index + 1];
18224
- const third = bytes[index + 2];
18524
+ for (let index = 0; index < bytes2.length; index += 3) {
18525
+ const first = bytes2[index];
18526
+ const second = bytes2[index + 1];
18527
+ const third = bytes2[index + 2];
18225
18528
  output += BASE64URL_ALPHABET[first >> 2];
18226
18529
  output += BASE64URL_ALPHABET[(first & 3) << 4 | (second ?? 0) >> 4];
18227
18530
  if (second === void 0) break;
@@ -18262,8 +18565,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18262
18565
  }, "isCanonicalBase64Url");
18263
18566
  var decodedBase64UrlByteLength = /* @__PURE__ */ __name2((value) => decodeBase64Url(value)?.length ?? null, "decodedBase64UrlByteLength");
18264
18567
  var utf8ByteLength = /* @__PURE__ */ __name2((value) => new TextEncoder().encode(value).length, "utf8ByteLength");
18265
- var canonicalBase64Url = /* @__PURE__ */ __name2((bytes) => external_exports.string().refine((value) => isCanonicalBase64Url(value, bytes), {
18266
- message: `must be canonical base64url for exactly ${bytes} bytes`
18568
+ var canonicalBase64Url = /* @__PURE__ */ __name2((bytes2) => external_exports.string().refine((value) => isCanonicalBase64Url(value, bytes2), {
18569
+ message: `must be canonical base64url for exactly ${bytes2} bytes`
18267
18570
  }), "canonicalBase64Url");
18268
18571
  var ShareLinkIdValidator = canonicalBase64Url(SHARE_LINK_ID_BYTES);
18269
18572
  var ShareContentKeyValidator = canonicalBase64Url(SHARE_CONTENT_KEY_BYTES);
@@ -18499,6 +18802,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18499
18802
  version: safeVersion,
18500
18803
  contentVersion: safeVersion,
18501
18804
  status: ShareLinkStatusValidator,
18805
+ attachmentId: external_exports.string().uuid().nullable().optional(),
18806
+ attachmentChunkCount: external_exports.number().int().min(1).max(16).nullable().optional(),
18502
18807
  contentState: ShareContentStateValidator,
18503
18808
  createdAt: external_exports.iso.datetime(),
18504
18809
  updatedAt: external_exports.iso.datetime(),
@@ -18522,6 +18827,43 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18522
18827
  contentUrl: external_exports.string().optional()
18523
18828
  });
18524
18829
  var clientRequestId = external_exports.string().uuid();
18830
+ var ShareLinkAttachmentValidator = external_exports.object({
18831
+ id: external_exports.string().uuid(),
18832
+ chunkCount: external_exports.number().int().min(1).max(16)
18833
+ }).strict();
18834
+ var attachmentChunkKey = {
18835
+ id: ShareLinkIdValidator,
18836
+ contentVersion: safeVersion,
18837
+ attachmentId: external_exports.string().uuid(),
18838
+ chunkIndex: external_exports.number().int().min(0).max(15)
18839
+ };
18840
+ var ShareLinkAttachmentChunkEnvelopeValidator = ShareEnvelopeValidator.refine(
18841
+ (value) => (decodedBase64UrlByteLength(value.ct) ?? Infinity) <= 256 * 1024 + SHARE_TAG_BYTES
18842
+ );
18843
+ var PutShareLinkAttachmentChunkInputValidator = external_exports.object({
18844
+ ...attachmentChunkKey,
18845
+ chunkCount: external_exports.number().int().min(1).max(16),
18846
+ envelope: ShareLinkAttachmentChunkEnvelopeValidator,
18847
+ ownerEncryptedRecovery: ShareOwnerRecoveryValidator
18848
+ }).strict().refine((value) => value.chunkIndex < value.chunkCount);
18849
+ var GetShareLinkAttachmentChunkInputValidator = external_exports.object({
18850
+ ...attachmentChunkKey,
18851
+ passcode: external_exports.string().min(4).max(64).optional(),
18852
+ accessToken: external_exports.string().min(1).max(2048).optional()
18853
+ }).strict();
18854
+ var ShareLinkAttachmentChunkOutputValidator = external_exports.object({
18855
+ ...attachmentChunkKey,
18856
+ envelope: ShareLinkAttachmentChunkEnvelopeValidator,
18857
+ accessToken: external_exports.string().min(1).max(2048).optional()
18858
+ }).strict();
18859
+ var DeleteShareLinkAttachmentChunksInputValidator = external_exports.object({
18860
+ id: ShareLinkIdValidator,
18861
+ contentVersion: safeVersion,
18862
+ attachmentId: external_exports.string().uuid(),
18863
+ chunkCount: external_exports.number().int().min(1).max(16)
18864
+ }).strict();
18865
+ var PutShareLinkAttachmentChunkOutputValidator = external_exports.object({ ok: external_exports.literal(true) }).strict();
18866
+ var DeleteShareLinkAttachmentChunksOutputValidator = external_exports.object({ ok: external_exports.boolean() }).strict();
18525
18867
  var CreateShareLinkInputValidator = external_exports.object({
18526
18868
  id: ShareLinkIdValidator,
18527
18869
  clientRequestId,
@@ -18533,7 +18875,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18533
18875
  selectedCount: external_exports.number().int().min(1).max(MAX_SELECTED_CREDENTIALS),
18534
18876
  contentVersion: external_exports.literal(1),
18535
18877
  envelope: ShareEnvelopeValidator,
18536
- ownerEncryptedRecovery: ShareOwnerRecoveryValidator
18878
+ ownerEncryptedRecovery: ShareOwnerRecoveryValidator,
18879
+ attachment: ShareLinkAttachmentValidator.optional()
18537
18880
  }).strict();
18538
18881
  var UpdateShareLinkInputValidator = external_exports.object({
18539
18882
  id: ShareLinkIdValidator,
@@ -18548,7 +18891,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18548
18891
  contentVersion: safeVersion.optional(),
18549
18892
  selectedCount: external_exports.number().int().min(1).max(MAX_SELECTED_CREDENTIALS).optional(),
18550
18893
  envelope: ShareEnvelopeValidator.optional(),
18551
- ownerEncryptedRecovery: ShareOwnerRecoveryValidator.optional()
18894
+ ownerEncryptedRecovery: ShareOwnerRecoveryValidator.optional(),
18895
+ attachment: ShareLinkAttachmentValidator.optional()
18552
18896
  }).strict().superRefine((value, ctx) => {
18553
18897
  const provided = [
18554
18898
  value.contentVersion,
@@ -18562,6 +18906,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18562
18906
  message: "content replacement requires contentVersion, selectedCount, envelope and ownerEncryptedRecovery together"
18563
18907
  });
18564
18908
  }
18909
+ if (value.attachment !== void 0 && provided !== 4) {
18910
+ ctx.addIssue({ code: "custom", message: "attachment requires a content replacement" });
18911
+ }
18565
18912
  });
18566
18913
  var ShareLinkIdInputValidator = external_exports.object({ id: ShareLinkIdValidator }).strict();
18567
18914
  var ShareLinkOperationKeyInputValidator = external_exports.object({ id: ShareLinkIdValidator, operationId: external_exports.string().uuid() }).strict();
@@ -18818,33 +19165,33 @@ var DEFAULT_KDF_PARAMS = {
18818
19165
  parallelism: ARGON2_PARALLELISM
18819
19166
  };
18820
19167
  function bufferToBase64(buf) {
18821
- const bytes = new Uint8Array(buf);
19168
+ const bytes2 = new Uint8Array(buf);
18822
19169
  let binary = "";
18823
- for (let i = 0; i < bytes.byteLength; i++) {
18824
- binary += String.fromCharCode(bytes[i]);
19170
+ for (let i = 0; i < bytes2.byteLength; i++) {
19171
+ binary += String.fromCharCode(bytes2[i]);
18825
19172
  }
18826
19173
  return btoa(binary);
18827
19174
  }
18828
19175
  __name(bufferToBase64, "bufferToBase64");
18829
19176
  function base64ToBuffer(b64) {
18830
19177
  const binary = atob(b64);
18831
- const bytes = new Uint8Array(binary.length);
19178
+ const bytes2 = new Uint8Array(binary.length);
18832
19179
  for (let i = 0; i < binary.length; i++) {
18833
- bytes[i] = binary.charCodeAt(i);
19180
+ bytes2[i] = binary.charCodeAt(i);
18834
19181
  }
18835
- return bytes;
19182
+ return bytes2;
18836
19183
  }
18837
19184
  __name(base64ToBuffer, "base64ToBuffer");
18838
- function hexToBytes(hex) {
18839
- const bytes = new Uint8Array(hex.length / 2);
18840
- for (let i = 0; i < hex.length; i += 2) {
18841
- bytes[i / 2] = parseInt(hex.slice(i, i + 2), 16);
19185
+ function hexToBytes(hex2) {
19186
+ const bytes2 = new Uint8Array(hex2.length / 2);
19187
+ for (let i = 0; i < hex2.length; i += 2) {
19188
+ bytes2[i / 2] = parseInt(hex2.slice(i, i + 2), 16);
18842
19189
  }
18843
- return bytes;
19190
+ return bytes2;
18844
19191
  }
18845
19192
  __name(hexToBytes, "hexToBytes");
18846
- function bytesToHex(bytes) {
18847
- return Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join("");
19193
+ function bytesToHex(bytes2) {
19194
+ return Array.from(bytes2).map((b) => b.toString(16).padStart(2, "0")).join("");
18848
19195
  }
18849
19196
  __name(bytesToHex, "bytesToHex");
18850
19197
  async function deriveKeyFromPassword(password, salt, params = DEFAULT_KDF_PARAMS) {
@@ -19011,21 +19358,21 @@ async function getOrCreateMasterKey() {
19011
19358
  }
19012
19359
  __name(getOrCreateMasterKey, "getOrCreateMasterKey");
19013
19360
  function bufferToBase642(buf) {
19014
- const bytes = new Uint8Array(buf);
19361
+ const bytes2 = new Uint8Array(buf);
19015
19362
  let binary = "";
19016
- for (let i = 0; i < bytes.byteLength; i++) {
19017
- binary += String.fromCharCode(bytes[i]);
19363
+ for (let i = 0; i < bytes2.byteLength; i++) {
19364
+ binary += String.fromCharCode(bytes2[i]);
19018
19365
  }
19019
19366
  return btoa(binary);
19020
19367
  }
19021
19368
  __name(bufferToBase642, "bufferToBase64");
19022
19369
  function base64ToBuffer2(b64) {
19023
19370
  const binary = atob(b64);
19024
- const bytes = new Uint8Array(binary.length);
19371
+ const bytes2 = new Uint8Array(binary.length);
19025
19372
  for (let i = 0; i < binary.length; i++) {
19026
- bytes[i] = binary.charCodeAt(i);
19373
+ bytes2[i] = binary.charCodeAt(i);
19027
19374
  }
19028
- return bytes.buffer;
19375
+ return bytes2.buffer;
19029
19376
  }
19030
19377
  __name(base64ToBuffer2, "base64ToBuffer");
19031
19378
  async function encryptShare(share, id) {
@@ -19433,16 +19780,16 @@ async function getWordlist() {
19433
19780
  return wordlistPromise;
19434
19781
  }
19435
19782
  __name(getWordlist, "getWordlist");
19436
- function bytesToBits(bytes) {
19437
- return Array.from(bytes).map((b) => b.toString(2).padStart(8, "0")).join("");
19783
+ function bytesToBits(bytes2) {
19784
+ return Array.from(bytes2).map((b) => b.toString(2).padStart(8, "0")).join("");
19438
19785
  }
19439
19786
  __name(bytesToBits, "bytesToBits");
19440
19787
  function bitsToBytes(bits) {
19441
- const bytes = new Uint8Array(Math.ceil(bits.length / 8));
19442
- for (let i = 0; i < bytes.length; i++) {
19443
- bytes[i] = parseInt(bits.slice(i * 8, (i + 1) * 8).padEnd(8, "0"), 2);
19788
+ const bytes2 = new Uint8Array(Math.ceil(bits.length / 8));
19789
+ for (let i = 0; i < bytes2.length; i++) {
19790
+ bytes2[i] = parseInt(bits.slice(i * 8, (i + 1) * 8).padEnd(8, "0"), 2);
19444
19791
  }
19445
- return bytes;
19792
+ return bytes2;
19446
19793
  }
19447
19794
  __name(bitsToBytes, "bitsToBytes");
19448
19795
  async function computeChecksum(data) {
@@ -19480,12 +19827,12 @@ async function recoveryPhraseToShare(phrase) {
19480
19827
  bits += index.toString(2).padStart(11, "0");
19481
19828
  }
19482
19829
  let dataByteCount = 0;
19483
- for (let bytes = 1; bytes <= 64; bytes++) {
19484
- const checksumBits2 = Math.floor(bytes / 4);
19485
- const totalBits = bytes * 8 + checksumBits2;
19830
+ for (let bytes2 = 1; bytes2 <= 64; bytes2++) {
19831
+ const checksumBits2 = Math.floor(bytes2 / 4);
19832
+ const totalBits = bytes2 * 8 + checksumBits2;
19486
19833
  const wordsNeeded = Math.ceil(totalBits / 11);
19487
19834
  if (wordsNeeded === words.length) {
19488
- dataByteCount = bytes;
19835
+ dataByteCount = bytes2;
19489
19836
  } else if (wordsNeeded > words.length) {
19490
19837
  break;
19491
19838
  }
@@ -19779,9 +20126,9 @@ __name(createSSSKeyManager, "createSSSKeyManager");
19779
20126
  var EMAIL_RELAY_ENVELOPE_VERSION = 1;
19780
20127
  var EMAIL_RELAY_ALGORITHM = "P-256-HKDF-SHA256-AES-256-GCM";
19781
20128
  var encodeUtf8 = /* @__PURE__ */ __name((value) => {
19782
- const bytes = new TextEncoder().encode(value);
19783
- const copy = new Uint8Array(new ArrayBuffer(bytes.byteLength));
19784
- copy.set(bytes);
20129
+ const bytes2 = new TextEncoder().encode(value);
20130
+ const copy = new Uint8Array(new ArrayBuffer(bytes2.byteLength));
20131
+ copy.set(bytes2);
19785
20132
  return copy;
19786
20133
  }, "encodeUtf8");
19787
20134
  var EMAIL_RELAY_INFO = encodeUtf8("learncard-email-relay-v1");
@@ -19976,9 +20323,9 @@ var ESCROW_BLOB_INFO = "learncard-escrow-blob-v1";
19976
20323
  var ESCROW_RELEASE_INFO = "learncard-escrow-release-v1";
19977
20324
  var ESCROW_CLIENT_KEY_ID = "client";
19978
20325
  var encodeUtf82 = /* @__PURE__ */ __name((value) => {
19979
- const bytes = new TextEncoder().encode(value);
19980
- const copy = new Uint8Array(new ArrayBuffer(bytes.byteLength));
19981
- copy.set(bytes);
20326
+ const bytes2 = new TextEncoder().encode(value);
20327
+ const copy = new Uint8Array(new ArrayBuffer(bytes2.byteLength));
20328
+ copy.set(bytes2);
19982
20329
  return copy;
19983
20330
  }, "encodeUtf8");
19984
20331
  var isRecord2 = /* @__PURE__ */ __name((value) => typeof value === "object" && value !== null && !Array.isArray(value), "isRecord");
@@ -20167,6 +20514,195 @@ var openEscrowRelease = /* @__PURE__ */ __name(async (envelope, clientEphemeralP
20167
20514
  await decryptFromEnvelope(envelope, clientEphemeralPrivateKeyPkcs8B64, ESCROW_RELEASE_INFO)
20168
20515
  ), "openEscrowRelease");
20169
20516
 
20517
+ // src/escrow-nitro-attestation.ts
20518
+ import "reflect-metadata";
20519
+ import { decode, encode } from "cborg";
20520
+ import {
20521
+ BasicConstraintsExtension,
20522
+ KeyUsagesExtension,
20523
+ KeyUsageFlags,
20524
+ X509Certificate
20525
+ } from "@peculiar/x509";
20526
+ var NitroAttestationError = class extends Error {
20527
+ constructor(reason) {
20528
+ super(`Nitro attestation rejected: ${reason}`);
20529
+ this.reason = reason;
20530
+ this.name = "NitroAttestationError";
20531
+ }
20532
+ static {
20533
+ __name(this, "NitroAttestationError");
20534
+ }
20535
+ };
20536
+ var AWS_ROOT_SHA256 = "641a0321a3e244efe456463195d606317ed7cdcc3c1756e09893f3c68f79bb5b";
20537
+ var fail = /* @__PURE__ */ __name((reason) => {
20538
+ throw new NitroAttestationError(reason);
20539
+ }, "fail");
20540
+ var hex = /* @__PURE__ */ __name((bytes2) => Array.from(bytes2, (byte) => byte.toString(16).padStart(2, "0")).join(""), "hex");
20541
+ var bytes = /* @__PURE__ */ __name((value, reason) => value instanceof Uint8Array && value.length > 0 ? value : fail(reason), "bytes");
20542
+ var map = /* @__PURE__ */ __name((value, reason) => value instanceof Map ? value : fail(reason), "map");
20543
+ var decodeCbor = /* @__PURE__ */ __name((value) => {
20544
+ try {
20545
+ return decode(value, {
20546
+ useMaps: true,
20547
+ rejectDuplicateMapKeys: true,
20548
+ allowIndefinite: false,
20549
+ allowUndefined: false,
20550
+ allowNaN: false,
20551
+ allowInfinity: false,
20552
+ allowBigInt: false
20553
+ });
20554
+ } catch {
20555
+ return fail("cbor");
20556
+ }
20557
+ }, "decodeCbor");
20558
+ var decodeUserData = /* @__PURE__ */ __name((userData) => {
20559
+ let decoded;
20560
+ try {
20561
+ decoded = decode(userData, {
20562
+ useMaps: true,
20563
+ rejectDuplicateMapKeys: true,
20564
+ allowIndefinite: false,
20565
+ allowUndefined: false,
20566
+ allowNaN: false,
20567
+ allowInfinity: false,
20568
+ allowBigInt: false
20569
+ });
20570
+ } catch {
20571
+ return void 0;
20572
+ }
20573
+ if (!(decoded instanceof Map) || decoded.size !== 3) return void 0;
20574
+ const spki = decoded.get(0);
20575
+ const keyId = decoded.get(1);
20576
+ const previousKeyIds = decoded.get(2);
20577
+ const isKeyId = /* @__PURE__ */ __name((value) => typeof value === "string" && /^[A-Za-z0-9._-]{1,128}$/.test(value), "isKeyId");
20578
+ if (!(spki instanceof Uint8Array) || spki.length === 0 || !isKeyId(keyId) || !Array.isArray(previousKeyIds) || previousKeyIds.length > 3 || !previousKeyIds.every(isKeyId)) {
20579
+ return void 0;
20580
+ }
20581
+ return { spki, keyId, previousKeyIds };
20582
+ }, "decodeUserData");
20583
+ var verifyNitroAttestationDocument = /* @__PURE__ */ __name(async (documentB64, {
20584
+ expectedNonce,
20585
+ policy,
20586
+ now = Date.now()
20587
+ }) => {
20588
+ let document;
20589
+ try {
20590
+ if (!documentB64 || documentB64.length > 65536 || !/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(documentB64))
20591
+ fail("cbor");
20592
+ document = base64ToBuffer(documentB64);
20593
+ } catch {
20594
+ return fail("cbor");
20595
+ }
20596
+ const cose = decodeCbor(document[0] === 210 ? document.subarray(1) : document);
20597
+ if (!Array.isArray(cose) || cose.length !== 4) fail("cose");
20598
+ const [protectedValue, unprotectedValue, payloadValue, signatureValue] = cose;
20599
+ const protectedBytes = bytes(protectedValue, "cose");
20600
+ const protectedHeader = map(decodeCbor(protectedBytes), "alg");
20601
+ if (protectedHeader.size !== 1 || protectedHeader.get(1) !== -35) fail("alg");
20602
+ if (map(unprotectedValue, "cose").size !== 0) fail("cose");
20603
+ const payloadBytes = bytes(payloadValue, "cose");
20604
+ const signature = bytes(signatureValue, "signature");
20605
+ if (signature.length !== 96) fail("signature");
20606
+ const payload = map(decodeCbor(payloadBytes), "cbor");
20607
+ const moduleId = payload.get("module_id");
20608
+ const timestamp = payload.get("timestamp");
20609
+ if (typeof moduleId !== "string" || !moduleId || payload.get("digest") !== "SHA384")
20610
+ fail("cbor");
20611
+ if (typeof timestamp !== "number" || !Number.isSafeInteger(timestamp) || timestamp < 0)
20612
+ fail("freshness");
20613
+ const leafDer = bytes(payload.get("certificate"), "chain");
20614
+ const bundle = payload.get("cabundle");
20615
+ if (!Array.isArray(bundle) || !bundle.length || bundle.length > 16) fail("chain");
20616
+ const ders = bundle.map((value) => bytes(value, "chain"));
20617
+ const rootHash = hex(
20618
+ new Uint8Array(await crypto.subtle.digest("SHA-256", new Uint8Array(ders[0])))
20619
+ );
20620
+ if (rootHash !== (policy.rootCertificateSha256 ?? AWS_ROOT_SHA256).toLowerCase()) fail("root");
20621
+ let leaf;
20622
+ try {
20623
+ const chain = [...ders, leafDer].map((der) => new X509Certificate(new Uint8Array(der)));
20624
+ for (let i = 0; i < chain.length; i++) {
20625
+ const cert = chain[i];
20626
+ const issuer = chain[Math.max(0, i - 1)];
20627
+ 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))
20628
+ fail("chain");
20629
+ if (i < chain.length - 1) {
20630
+ const constraints = cert.getExtension(BasicConstraintsExtension);
20631
+ const usage = cert.getExtension(KeyUsagesExtension);
20632
+ if (!constraints?.ca || constraints.pathLength !== void 0 && chain.length - i - 2 > constraints.pathLength || usage && !(usage.usages & KeyUsageFlags.keyCertSign))
20633
+ fail("chain");
20634
+ }
20635
+ }
20636
+ leaf = chain[chain.length - 1];
20637
+ } catch {
20638
+ return fail("chain");
20639
+ }
20640
+ try {
20641
+ const key = await crypto.subtle.importKey(
20642
+ "spki",
20643
+ leaf.publicKey.rawData,
20644
+ { name: "ECDSA", namedCurve: "P-384" },
20645
+ false,
20646
+ ["verify"]
20647
+ );
20648
+ const structure = encode(["Signature1", protectedBytes, new Uint8Array(), payloadBytes]);
20649
+ if (!await crypto.subtle.verify(
20650
+ { name: "ECDSA", hash: "SHA-384" },
20651
+ key,
20652
+ new Uint8Array(signature),
20653
+ new Uint8Array(structure)
20654
+ ))
20655
+ fail("signature");
20656
+ } catch {
20657
+ return fail("signature");
20658
+ }
20659
+ const rawPcrs = map(payload.get("pcrs"), "pcr");
20660
+ const pcrs = {};
20661
+ for (const [index, value] of rawPcrs) {
20662
+ if (typeof index !== "number" || !Number.isInteger(index) || index < 0 || index > 31)
20663
+ fail("pcr");
20664
+ const pcr = bytes(value, "pcr");
20665
+ if (pcr.length !== 48) fail("pcr");
20666
+ pcrs[index] = hex(pcr);
20667
+ }
20668
+ if (pcrs[0] === "00".repeat(48)) fail("debug");
20669
+ if (!policy.pinnedMeasurements.some(
20670
+ (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]
20671
+ ))
20672
+ fail("pcr");
20673
+ const nonce = bytes(payload.get("nonce"), "nonce");
20674
+ if (!(expectedNonce instanceof Uint8Array) || expectedNonce.length !== 32 || nonce.length !== expectedNonce.length)
20675
+ fail("nonce");
20676
+ let difference = 0;
20677
+ for (let i = 0; i < nonce.length; i++) difference |= nonce[i] ^ expectedNonce[i];
20678
+ if (difference !== 0) fail("nonce");
20679
+ const maxAge = policy.maxAgeMs ?? 3e5;
20680
+ if (!Number.isFinite(maxAge) || maxAge < 0 || now - timestamp > maxAge || timestamp > now + 6e4)
20681
+ fail("freshness");
20682
+ const userData = bytes(payload.get("user_data"), "user-data");
20683
+ const newFormat = decodeUserData(new Uint8Array(userData));
20684
+ const spki = newFormat ? newFormat.spki : userData;
20685
+ try {
20686
+ await crypto.subtle.importKey(
20687
+ "spki",
20688
+ new Uint8Array(spki),
20689
+ { name: "ECDH", namedCurve: "P-256" },
20690
+ false,
20691
+ []
20692
+ );
20693
+ } catch {
20694
+ return fail("user-data");
20695
+ }
20696
+ return {
20697
+ escrowPublicKeySpkiB64: bufferToBase64(new Uint8Array(spki).buffer),
20698
+ keyId: newFormat?.keyId,
20699
+ previousKeyIds: newFormat?.previousKeyIds ?? [],
20700
+ pcrs,
20701
+ timestamp,
20702
+ moduleId
20703
+ };
20704
+ }, "verifyNitroAttestationDocument");
20705
+
20170
20706
  // src/escrow-attestation.ts
20171
20707
  var isRecord3 = /* @__PURE__ */ __name((value) => typeof value === "object" && value !== null && !Array.isArray(value), "isRecord");
20172
20708
  var normalizePublicKey = /* @__PURE__ */ __name((value) => {
@@ -20176,13 +20712,50 @@ var normalizePublicKey = /* @__PURE__ */ __name((value) => {
20176
20712
  }
20177
20713
  return bufferToBase64(base64ToBuffer(trimmed).buffer);
20178
20714
  }, "normalizePublicKey");
20179
- var verifyEnclaveAttestation = /* @__PURE__ */ __name(async (attestation, policy) => {
20180
- const fields = ["mode", "keyId", "publicKey", "measurements", "document", "issuedAt"];
20181
- if (!isRecord3(attestation) || Object.keys(attestation).some((key) => !fields.includes(key)) || attestation.mode !== "software" && attestation.mode !== "nitro" || typeof attestation.keyId !== "string" || !/^[A-Za-z0-9._-]{1,128}$/.test(attestation.keyId) || typeof attestation.publicKey !== "string" || !isRecord3(attestation.measurements) || Object.entries(attestation.measurements).some(
20715
+ var verifyEnclaveAttestation = /* @__PURE__ */ __name(async (attestation, policy, nonce) => {
20716
+ const isKeyId = /* @__PURE__ */ __name((value) => typeof value === "string" && /^[A-Za-z0-9._-]{1,128}$/.test(value), "isKeyId");
20717
+ const fields = [
20718
+ "mode",
20719
+ "keyId",
20720
+ "previousKeyIds",
20721
+ "publicKey",
20722
+ "measurements",
20723
+ "document",
20724
+ "issuedAt"
20725
+ ];
20726
+ 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
20727
  ([key, value]) => !["imageSha384", "pcr0", "pcr1", "pcr2"].includes(key) || typeof value !== "string" || !value || value.length > 1024
20183
20728
  ) || typeof attestation.document !== "string" || !attestation.document || attestation.document.length > 65536 || typeof attestation.issuedAt !== "string" || !Number.isFinite(Date.parse(attestation.issuedAt))) {
20184
20729
  throw new Error("Invalid escrow attestation");
20185
20730
  }
20731
+ const plaintextPreviousKeyIds = attestation.previousKeyIds ?? [];
20732
+ if (attestation.mode !== policy.mode) throw new Error("Escrow attestation mode mismatch");
20733
+ if (policy.mode === "nitro") {
20734
+ if (!nonce) throw new NitroAttestationError("nonce");
20735
+ const verified = await verifyNitroAttestationDocument(attestation.document, {
20736
+ expectedNonce: nonce,
20737
+ policy
20738
+ });
20739
+ try {
20740
+ if (normalizePublicKey(attestation.publicKey) !== verified.escrowPublicKeySpkiB64) {
20741
+ throw new NitroAttestationError("user-data");
20742
+ }
20743
+ } catch {
20744
+ throw new NitroAttestationError("user-data");
20745
+ }
20746
+ if (verified.keyId !== void 0 && verified.keyId !== attestation.keyId) {
20747
+ throw new NitroAttestationError("user-data");
20748
+ }
20749
+ if (plaintextPreviousKeyIds.length !== verified.previousKeyIds.length || !plaintextPreviousKeyIds.every((id, index) => id === verified.previousKeyIds[index])) {
20750
+ throw new NitroAttestationError("user-data");
20751
+ }
20752
+ return {
20753
+ publicKey: verified.escrowPublicKeySpkiB64,
20754
+ keyId: attestation.keyId,
20755
+ previousKeyIds: verified.previousKeyIds,
20756
+ mode: "nitro"
20757
+ };
20758
+ }
20186
20759
  const publicKey = normalizePublicKey(attestation.publicKey);
20187
20760
  await crypto.subtle.importKey(
20188
20761
  "spki",
@@ -20191,14 +20764,15 @@ var verifyEnclaveAttestation = /* @__PURE__ */ __name(async (attestation, policy
20191
20764
  false,
20192
20765
  []
20193
20766
  );
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
20767
  if (!policy.pinnedPublicKeys.some((pin) => normalizePublicKey(pin) === publicKey)) {
20199
20768
  throw new Error("Escrow attestation public key is not trusted");
20200
20769
  }
20201
- return { publicKey, keyId: attestation.keyId, mode: attestation.mode };
20770
+ return {
20771
+ publicKey,
20772
+ keyId: attestation.keyId,
20773
+ previousKeyIds: plaintextPreviousKeyIds,
20774
+ mode: attestation.mode
20775
+ };
20202
20776
  }, "verifyEnclaveAttestation");
20203
20777
 
20204
20778
  // src/types.ts
@@ -20971,6 +21545,7 @@ function createSSSStrategy(config) {
20971
21545
  let pendingIdentityRecovery;
20972
21546
  let lastServerSnapshot = null;
20973
21547
  let escrowEnrollmentInFlight;
21548
+ let staleEscrowReenrollAttempted = false;
20974
21549
  let unenrolledRotation;
20975
21550
  const escrowRequest = /* @__PURE__ */ __name(async (path, init, pinAttempt = false) => {
20976
21551
  const response = await fetch(`${serverUrl}/keys/escrow${path}`, {
@@ -21018,11 +21593,16 @@ function createSSSStrategy(config) {
21018
21593
  }, "escrowRequest");
21019
21594
  const fetchVerifiedEnclaveKey = /* @__PURE__ */ __name(async () => {
21020
21595
  if (!config.escrow?.enabled) throw new Error("Escrow enrollment is disabled");
21021
- const { attestation } = await escrowRequest("/attestation", {
21022
- method: "GET",
21023
- headers: buildHeaders("", void 0, tenantId)
21024
- });
21025
- return verifyEnclaveAttestation(attestation, config.escrow.attestation);
21596
+ const nonce = crypto.getRandomValues(new Uint8Array(32));
21597
+ const nonceHex = Array.from(nonce, (byte) => byte.toString(16).padStart(2, "0")).join("");
21598
+ const { attestation } = await escrowRequest(
21599
+ `/attestation?nonce=${nonceHex}`,
21600
+ {
21601
+ method: "GET",
21602
+ headers: buildHeaders("", void 0, tenantId)
21603
+ }
21604
+ );
21605
+ return verifyEnclaveAttestation(attestation, config.escrow.attestation, nonce);
21026
21606
  }, "fetchVerifiedEnclaveKey");
21027
21607
  const enrollEscrow = /* @__PURE__ */ __name(async (token, providerType, privateKey, primaryDid, shares, shareVersion, signDidAuthVp, verifiedKey, pinMaterial, clearPin = false) => {
21028
21608
  if (!config.escrow?.enabled) throw new Error("Escrow enrollment is disabled");
@@ -21084,75 +21664,89 @@ function createSSSStrategy(config) {
21084
21664
  }
21085
21665
  const status = await self.fetchServerKeyStatus(params.token, params.providerType);
21086
21666
  if (status.escrowOptedOut) return { enrolled: false, reason: "opted-out" };
21087
- if (!forceRotate && pin === void 0 && status.shareVersion !== null && status.recoveryMethods.some(
21667
+ const currentlyEnrolled = status.shareVersion !== null && status.recoveryMethods.some(
21088
21668
  (method) => method.type === "escrow" && method.shareVersion === status.shareVersion && (Boolean(method.confirmedAt) || "confirmationStatus" in method && method.confirmationStatus === "confirmed")
21089
- ))
21669
+ );
21670
+ const repairingStaleBlob = pin === void 0 && !forceRotate && currentlyEnrolled && !!status.escrowStale && !staleEscrowReenrollAttempted;
21671
+ if (!forceRotate && pin === void 0 && currentlyEnrolled && !repairingStaleBlob)
21090
21672
  return { enrolled: true, changed: false };
21673
+ if (repairingStaleBlob) staleEscrowReenrollAttempted = true;
21091
21674
  if (!status.primaryDid) throw new Error("Cannot enroll escrow without a primary DID");
21092
21675
  if (!params.signDidAuthVp) {
21093
21676
  throw new Error("DID proof signing is required for escrow enrollment");
21094
21677
  }
21095
- if (!forceRotate && pin === void 0 && unenrolledRotation && unenrolledRotation.shareVersion === status.shareVersion && unenrolledRotation.primaryDid === status.primaryDid) {
21096
- const retry = unenrolledRotation;
21678
+ try {
21679
+ if (!forceRotate && pin === void 0 && unenrolledRotation && unenrolledRotation.shareVersion === status.shareVersion && unenrolledRotation.primaryDid === status.primaryDid) {
21680
+ const retry = unenrolledRotation;
21681
+ await enrollEscrow(
21682
+ params.token,
21683
+ params.providerType,
21684
+ params.privateKey,
21685
+ retry.primaryDid,
21686
+ retry.shares,
21687
+ retry.shareVersion,
21688
+ params.signDidAuthVp,
21689
+ void 0,
21690
+ void 0,
21691
+ retry.clearPin
21692
+ );
21693
+ unenrolledRotation = void 0;
21694
+ return { enrolled: true, changed: true, shareVersion: retry.shareVersion };
21695
+ }
21696
+ const verifiedKey = await fetchVerifiedEnclaveKey();
21697
+ const pinSalt = pin !== void 0 ? generatePinSalt() : void 0;
21698
+ const pinMaterial = pin !== void 0 && pinSalt !== void 0 ? { pinSalt, pinVerifier: await derivePinProof(pin, pinSalt) } : void 0;
21699
+ const storageId = activeStorageId;
21700
+ const primaryDid = status.primaryDid;
21701
+ const { shares, shareVersion } = await withShareUpdateLock(
21702
+ storage2,
21703
+ storageId,
21704
+ () => persistSharesWithoutLock(
21705
+ params.privateKey,
21706
+ serverUrl,
21707
+ params.token,
21708
+ params.providerType,
21709
+ primaryDid,
21710
+ storage2,
21711
+ storageId,
21712
+ void 0,
21713
+ params.signDidAuthVp,
21714
+ tenantId
21715
+ )
21716
+ );
21717
+ lastEmailShare = shares.emailShare;
21718
+ lastShareVersion = shareVersion;
21719
+ lastServerSnapshot = {
21720
+ currentVersion: shareVersion,
21721
+ resolvedVersion: shareVersion,
21722
+ authShare: shares.authShare,
21723
+ primaryDid: status.primaryDid
21724
+ };
21725
+ unenrolledRotation = pinMaterial ? void 0 : { shares, shareVersion, primaryDid: status.primaryDid, clearPin: forceRotate };
21097
21726
  await enrollEscrow(
21098
21727
  params.token,
21099
21728
  params.providerType,
21100
21729
  params.privateKey,
21101
- retry.primaryDid,
21102
- retry.shares,
21103
- retry.shareVersion,
21730
+ status.primaryDid,
21731
+ shares,
21732
+ shareVersion,
21104
21733
  params.signDidAuthVp,
21105
- void 0,
21106
- void 0,
21107
- retry.clearPin
21734
+ verifiedKey,
21735
+ pinMaterial,
21736
+ forceRotate
21108
21737
  );
21109
21738
  unenrolledRotation = void 0;
21110
- return { enrolled: true, changed: true, shareVersion: retry.shareVersion };
21739
+ return { enrolled: true, changed: true, shareVersion };
21740
+ } catch (err) {
21741
+ if (!repairingStaleBlob) throw err;
21742
+ try {
21743
+ if (config.onEscrowError) config.onEscrowError(err);
21744
+ else console.warn("SSS: escrow enrollment failed");
21745
+ } catch {
21746
+ console.warn("SSS: escrow error reporting failed");
21747
+ }
21748
+ return { enrolled: true, changed: false };
21111
21749
  }
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
21750
  }, "ensureEscrowEnrollmentUnguarded");
21157
21751
  const recordPromotion = /* @__PURE__ */ __name((primaryDid) => (snapshot) => {
21158
21752
  lastEmailShare = void 0;
@@ -21469,6 +22063,7 @@ function createSSSStrategy(config) {
21469
22063
  maskedRecoveryEmail: data.maskedRecoveryEmail ?? null,
21470
22064
  escrowOptedOut: data.escrowOptedOut === true,
21471
22065
  escrowPin: data.escrowPin,
22066
+ escrowStale: data.escrowStale,
21472
22067
  sssActivationState: data.sssActivationState ?? "active"
21473
22068
  };
21474
22069
  },
@@ -21513,10 +22108,17 @@ function createSSSStrategy(config) {
21513
22108
  if (!config.escrow?.enabled) return { state: "disabled" };
21514
22109
  const status = await this.fetchServerKeyStatus(params.token, params.providerType);
21515
22110
  if (status.escrowOptedOut) return { state: "opted-out", escrowPin: status.escrowPin };
21516
- const state = status.shareVersion !== null && status.recoveryMethods.some(
21517
- (method) => method.type === "escrow" && method.shareVersion === status.shareVersion && (Boolean(method.confirmedAt) || "confirmationStatus" in method && method.confirmationStatus === "confirmed")
21518
- ) ? "enrolled" : "not-enrolled";
21519
- return { state, escrowPin: status.escrowPin };
22111
+ const confirmedEscrow = status.recoveryMethods.filter(
22112
+ (method) => method.type === "escrow" && (Boolean(method.confirmedAt) || "confirmationStatus" in method && method.confirmationStatus === "confirmed")
22113
+ );
22114
+ const enrolled = status.shareVersion !== null && confirmedEscrow.some((method) => method.shareVersion === status.shareVersion);
22115
+ if (confirmedEscrow.length > 0 && (!enrolled || status.escrowStale))
22116
+ return {
22117
+ state: "stale",
22118
+ escrowPin: status.escrowPin,
22119
+ staleReason: status.escrowStale
22120
+ };
22121
+ return { state: enrolled ? "enrolled" : "not-enrolled", escrowPin: status.escrowPin };
21520
22122
  },
21521
22123
  async disableEscrowRecovery(params) {
21522
22124
  const status = await this.fetchServerKeyStatus(params.token, params.providerType);
@@ -21569,7 +22171,7 @@ function createSSSStrategy(config) {
21569
22171
  const result = await withRotationLock(
21570
22172
  () => ensureEscrowEnrollmentUnguarded(this, { ...params, options: { pin } }, storage2)
21571
22173
  );
21572
- if (!result.enrolled) {
22174
+ if (!result.enrolled || !result.changed) {
21573
22175
  throw new Error("Automatic recovery is not available for this account.");
21574
22176
  }
21575
22177
  },
@@ -21578,7 +22180,7 @@ function createSSSStrategy(config) {
21578
22180
  const result = await withRotationLock(
21579
22181
  () => ensureEscrowEnrollmentUnguarded(this, params, storage2, true)
21580
22182
  );
21581
- if (!result.enrolled) {
22183
+ if (!result.enrolled || !result.changed) {
21582
22184
  throw new Error("Automatic recovery is not available for this account.");
21583
22185
  }
21584
22186
  },
@@ -22737,6 +23339,7 @@ export {
22737
23339
  EscrowPinUnavailableError,
22738
23340
  EscrowRequestError,
22739
23341
  IdentityRecoverySessionConsumedError,
23342
+ NitroAttestationError,
22740
23343
  PIN_MAX_LENGTH,
22741
23344
  PIN_MIN_LENGTH,
22742
23345
  SSSApiClient,
@@ -22812,5 +23415,6 @@ export {
22812
23415
  validatePin,
22813
23416
  validateRecoveryPhrase,
22814
23417
  verifyEnclaveAttestation,
23418
+ verifyNitroAttestationDocument,
22815
23419
  verifyStoredShares
22816
23420
  };