@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.
- package/README.md +13 -0
- package/dist/escrow-attestation.d.ts +5 -1
- package/dist/escrow-attestation.d.ts.map +1 -1
- package/dist/escrow-nitro-attestation.d.ts +32 -0
- package/dist/escrow-nitro-attestation.d.ts.map +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/sss-key-manager.cjs.development.js +2995 -320
- package/dist/sss-key-manager.cjs.development.js.map +4 -4
- package/dist/sss-key-manager.cjs.production.min.js +33 -33
- package/dist/sss-key-manager.cjs.production.min.js.map +4 -4
- package/dist/sss-key-manager.esm.js +774 -170
- package/dist/sss-key-manager.esm.js.map +4 -4
- package/dist/sss-strategy.d.ts.map +1 -1
- package/dist/types.d.ts +15 -4
- package/dist/types.d.ts.map +1 -1
- package/package.json +7 -3
- package/src/__fixtures__/escrow-vectors-rust.json +82 -0
- package/src/__fixtures__/escrow-vectors.json +103 -0
- package/src/__fixtures__/nitro-attestation/bad-signature.cbor.b64 +1 -0
- package/src/__fixtures__/nitro-attestation/debug-zero-pcrs.cbor.b64 +1 -0
- package/src/__fixtures__/nitro-attestation/legacy-user-data.cbor.b64 +1 -0
- package/src/__fixtures__/nitro-attestation/manifest.json +60 -0
- package/src/__fixtures__/nitro-attestation/nonce-mismatch.cbor.b64 +1 -0
- package/src/__fixtures__/nitro-attestation/root.pem +12 -0
- package/src/__fixtures__/nitro-attestation/stale-timestamp.cbor.b64 +1 -0
- package/src/__fixtures__/nitro-attestation/tampered-previous-key-ids.cbor.b64 +1 -0
- package/src/__fixtures__/nitro-attestation/truncated-chain.cbor.b64 +1 -0
- package/src/__fixtures__/nitro-attestation/valid.cbor.b64 +1 -0
- package/src/__fixtures__/nitro-attestation/wrong-pcr0.cbor.b64 +1 -0
- package/src/__fixtures__/nitro-attestation/wrong-root.cbor.b64 +1 -0
- package/src/escrow-attestation.test.ts +7 -2
- package/src/escrow-attestation.ts +71 -10
- package/src/escrow-nitro-attestation.test.ts +204 -0
- package/src/escrow-nitro-attestation.ts +286 -0
- package/src/escrow-vectors.test.ts +198 -0
- package/src/index.ts +8 -1
- package/src/sss-session-writes.test.ts +2 -2
- package/src/sss-strategy.test.ts +95 -2
- package/src/sss-strategy.ts +128 -88
- package/src/types.ts +12 -1
|
@@ -7,7 +7,11 @@ var __getProtoOf = Object.getPrototypeOf;
|
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
8
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
9
|
var __commonJS = (cb, mod) => function __require() {
|
|
10
|
-
|
|
10
|
+
try {
|
|
11
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
12
|
+
} catch (e) {
|
|
13
|
+
throw mod = 0, e;
|
|
14
|
+
}
|
|
11
15
|
};
|
|
12
16
|
var __export = (target, all) => {
|
|
13
17
|
for (var name in all)
|
|
@@ -79,6 +83,12 @@ var require_types_cjs_development = __commonJS({
|
|
|
79
83
|
AppEventResponseValidator: /* @__PURE__ */ __name(() => AppEventResponseValidator, "AppEventResponseValidator"),
|
|
80
84
|
AppEventValidator: /* @__PURE__ */ __name(() => AppEventValidator, "AppEventValidator"),
|
|
81
85
|
AppListingStatusValidator: /* @__PURE__ */ __name(() => AppListingStatusValidator, "AppListingStatusValidator"),
|
|
86
|
+
AppManifestDiffValidator: /* @__PURE__ */ __name(() => AppManifestDiffValidator, "AppManifestDiffValidator"),
|
|
87
|
+
AppManifestTemplateChangeValidator: /* @__PURE__ */ __name(() => AppManifestTemplateChangeValidator, "AppManifestTemplateChangeValidator"),
|
|
88
|
+
AppManifestTemplateRefValidator: /* @__PURE__ */ __name(() => AppManifestTemplateRefValidator, "AppManifestTemplateRefValidator"),
|
|
89
|
+
AppManifestValidator: /* @__PURE__ */ __name(() => AppManifestValidator, "AppManifestValidator"),
|
|
90
|
+
AppManifestVersionStatusValidator: /* @__PURE__ */ __name(() => AppManifestVersionStatusValidator, "AppManifestVersionStatusValidator"),
|
|
91
|
+
AppManifestVersionValidator: /* @__PURE__ */ __name(() => AppManifestVersionValidator, "AppManifestVersionValidator"),
|
|
82
92
|
AppStoreListingCreateValidator: /* @__PURE__ */ __name(() => AppStoreListingCreateValidator, "AppStoreListingCreateValidator"),
|
|
83
93
|
AppStoreListingSubmitterValidator: /* @__PURE__ */ __name(() => AppStoreListingSubmitterValidator, "AppStoreListingSubmitterValidator"),
|
|
84
94
|
AppStoreListingUpdateValidator: /* @__PURE__ */ __name(() => AppStoreListingUpdateValidator, "AppStoreListingUpdateValidator"),
|
|
@@ -100,6 +110,8 @@ var require_types_cjs_development = __commonJS({
|
|
|
100
110
|
BoostRecipientValidator: /* @__PURE__ */ __name(() => BoostRecipientValidator, "BoostRecipientValidator"),
|
|
101
111
|
BoostRecipientWithChildrenValidator: /* @__PURE__ */ __name(() => BoostRecipientWithChildrenValidator, "BoostRecipientWithChildrenValidator"),
|
|
102
112
|
BoostValidator: /* @__PURE__ */ __name(() => BoostValidator, "BoostValidator"),
|
|
113
|
+
CapturedConsentRecordValidator: /* @__PURE__ */ __name(() => CapturedConsentRecordValidator, "CapturedConsentRecordValidator"),
|
|
114
|
+
CapturedTemplateRecordValidator: /* @__PURE__ */ __name(() => CapturedTemplateRecordValidator, "CapturedTemplateRecordValidator"),
|
|
103
115
|
CheckCredentialEventValidator: /* @__PURE__ */ __name(() => CheckCredentialEventValidator, "CheckCredentialEventValidator"),
|
|
104
116
|
CheckIssuanceStatusEventValidator: /* @__PURE__ */ __name(() => CheckIssuanceStatusEventValidator, "CheckIssuanceStatusEventValidator"),
|
|
105
117
|
ClaimHookQueryValidator: /* @__PURE__ */ __name(() => ClaimHookQueryValidator, "ClaimHookQueryValidator"),
|
|
@@ -121,6 +133,7 @@ var require_types_cjs_development = __commonJS({
|
|
|
121
133
|
ConsentFlowDataForDidQueryValidator: /* @__PURE__ */ __name(() => ConsentFlowDataForDidQueryValidator, "ConsentFlowDataForDidQueryValidator"),
|
|
122
134
|
ConsentFlowDataQueryValidator: /* @__PURE__ */ __name(() => ConsentFlowDataQueryValidator, "ConsentFlowDataQueryValidator"),
|
|
123
135
|
ConsentFlowGuardianApprovalValidator: /* @__PURE__ */ __name(() => ConsentFlowGuardianApprovalValidator, "ConsentFlowGuardianApprovalValidator"),
|
|
136
|
+
ConsentFlowReferralValidator: /* @__PURE__ */ __name(() => ConsentFlowReferralValidator, "ConsentFlowReferralValidator"),
|
|
124
137
|
ConsentFlowTermValidator: /* @__PURE__ */ __name(() => ConsentFlowTermValidator, "ConsentFlowTermValidator"),
|
|
125
138
|
ConsentFlowTermsQueryValidator: /* @__PURE__ */ __name(() => ConsentFlowTermsQueryValidator, "ConsentFlowTermsQueryValidator"),
|
|
126
139
|
ConsentFlowTermsStatusValidator: /* @__PURE__ */ __name(() => ConsentFlowTermsStatusValidator, "ConsentFlowTermsStatusValidator"),
|
|
@@ -128,6 +141,10 @@ var require_types_cjs_development = __commonJS({
|
|
|
128
141
|
ConsentFlowTransactionActionValidator: /* @__PURE__ */ __name(() => ConsentFlowTransactionActionValidator, "ConsentFlowTransactionActionValidator"),
|
|
129
142
|
ConsentFlowTransactionValidator: /* @__PURE__ */ __name(() => ConsentFlowTransactionValidator, "ConsentFlowTransactionValidator"),
|
|
130
143
|
ConsentFlowTransactionsQueryValidator: /* @__PURE__ */ __name(() => ConsentFlowTransactionsQueryValidator, "ConsentFlowTransactionsQueryValidator"),
|
|
144
|
+
ConsentFlowWebhookMetadataValidator: /* @__PURE__ */ __name(() => ConsentFlowWebhookMetadataValidator, "ConsentFlowWebhookMetadataValidator"),
|
|
145
|
+
ConsentRequestPersonalFieldValidator: /* @__PURE__ */ __name(() => ConsentRequestPersonalFieldValidator, "ConsentRequestPersonalFieldValidator"),
|
|
146
|
+
ConsentRequestValidator: /* @__PURE__ */ __name(() => ConsentRequestValidator, "ConsentRequestValidator"),
|
|
147
|
+
ConsentRequestWalletCategoryValidator: /* @__PURE__ */ __name(() => ConsentRequestWalletCategoryValidator, "ConsentRequestWalletCategoryValidator"),
|
|
131
148
|
ContactMethodCreateValidator: /* @__PURE__ */ __name(() => ContactMethodCreateValidator, "ContactMethodCreateValidator"),
|
|
132
149
|
ContactMethodQueryValidator: /* @__PURE__ */ __name(() => ContactMethodQueryValidator, "ContactMethodQueryValidator"),
|
|
133
150
|
ContactMethodValidator: /* @__PURE__ */ __name(() => ContactMethodValidator, "ContactMethodValidator"),
|
|
@@ -135,6 +152,7 @@ var require_types_cjs_development = __commonJS({
|
|
|
135
152
|
ContactMethodVerificationValidator: /* @__PURE__ */ __name(() => ContactMethodVerificationValidator, "ContactMethodVerificationValidator"),
|
|
136
153
|
ContextValidator: /* @__PURE__ */ __name(() => ContextValidator, "ContextValidator"),
|
|
137
154
|
ContractCredentialValidator: /* @__PURE__ */ __name(() => ContractCredentialValidator, "ContractCredentialValidator"),
|
|
155
|
+
ContractRequestFieldsValidator: /* @__PURE__ */ __name(() => ContractRequestFieldsValidator, "ContractRequestFieldsValidator"),
|
|
138
156
|
CountSkillsInputValidator: /* @__PURE__ */ __name(() => CountSkillsInputValidator, "CountSkillsInputValidator"),
|
|
139
157
|
CountSkillsResultValidator: /* @__PURE__ */ __name(() => CountSkillsResultValidator, "CountSkillsResultValidator"),
|
|
140
158
|
CreateContactMethodSessionResponseValidator: /* @__PURE__ */ __name(() => CreateContactMethodSessionResponseValidator, "CreateContactMethodSessionResponseValidator"),
|
|
@@ -170,6 +188,8 @@ var require_types_cjs_development = __commonJS({
|
|
|
170
188
|
CriteriaValidator: /* @__PURE__ */ __name(() => CriteriaValidator, "CriteriaValidator"),
|
|
171
189
|
DEFAULT_BITSTRING_STATUS_LIST_SIZE: /* @__PURE__ */ __name(() => DEFAULT_BITSTRING_STATUS_LIST_SIZE, "DEFAULT_BITSTRING_STATUS_LIST_SIZE"),
|
|
172
190
|
DeleteFrameworkInputValidator: /* @__PURE__ */ __name(() => DeleteFrameworkInputValidator, "DeleteFrameworkInputValidator"),
|
|
191
|
+
DeleteShareLinkAttachmentChunksInputValidator: /* @__PURE__ */ __name(() => DeleteShareLinkAttachmentChunksInputValidator, "DeleteShareLinkAttachmentChunksInputValidator"),
|
|
192
|
+
DeleteShareLinkAttachmentChunksOutputValidator: /* @__PURE__ */ __name(() => DeleteShareLinkAttachmentChunksOutputValidator, "DeleteShareLinkAttachmentChunksOutputValidator"),
|
|
173
193
|
DeleteSkillInputValidator: /* @__PURE__ */ __name(() => DeleteSkillInputValidator, "DeleteSkillInputValidator"),
|
|
174
194
|
DidDocumentValidator: /* @__PURE__ */ __name(() => DidDocumentValidator, "DidDocumentValidator"),
|
|
175
195
|
EMPTY_IN_APP_MESSAGES_FLAG: /* @__PURE__ */ __name(() => EMPTY_IN_APP_MESSAGES_FLAG, "EMPTY_IN_APP_MESSAGES_FLAG"),
|
|
@@ -192,6 +212,7 @@ var require_types_cjs_development = __commonJS({
|
|
|
192
212
|
GetCredentialRefreshHistoryResultValidator: /* @__PURE__ */ __name(() => GetCredentialRefreshHistoryResultValidator, "GetCredentialRefreshHistoryResultValidator"),
|
|
193
213
|
GetFullSkillTreeInputValidator: /* @__PURE__ */ __name(() => GetFullSkillTreeInputValidator, "GetFullSkillTreeInputValidator"),
|
|
194
214
|
GetFullSkillTreeResultValidator: /* @__PURE__ */ __name(() => GetFullSkillTreeResultValidator, "GetFullSkillTreeResultValidator"),
|
|
215
|
+
GetShareLinkAttachmentChunkInputValidator: /* @__PURE__ */ __name(() => GetShareLinkAttachmentChunkInputValidator, "GetShareLinkAttachmentChunkInputValidator"),
|
|
195
216
|
GetSkillPathInputValidator: /* @__PURE__ */ __name(() => GetSkillPathInputValidator, "GetSkillPathInputValidator"),
|
|
196
217
|
GetSkillPathResultValidator: /* @__PURE__ */ __name(() => GetSkillPathResultValidator, "GetSkillPathResultValidator"),
|
|
197
218
|
GetTemplateRecipientsEventValidator: /* @__PURE__ */ __name(() => GetTemplateRecipientsEventValidator, "GetTemplateRecipientsEventValidator"),
|
|
@@ -209,6 +230,12 @@ var require_types_cjs_development = __commonJS({
|
|
|
209
230
|
InboxCredentialRefreshReceiptValidator: /* @__PURE__ */ __name(() => InboxCredentialRefreshReceiptValidator, "InboxCredentialRefreshReceiptValidator"),
|
|
210
231
|
InboxCredentialValidator: /* @__PURE__ */ __name(() => InboxCredentialValidator, "InboxCredentialValidator"),
|
|
211
232
|
IncrementCounterEventValidator: /* @__PURE__ */ __name(() => IncrementCounterEventValidator, "IncrementCounterEventValidator"),
|
|
233
|
+
InlineAlignmentValidator: /* @__PURE__ */ __name(() => InlineAlignmentValidator, "InlineAlignmentValidator"),
|
|
234
|
+
InlineCredentialTemplateValidator: /* @__PURE__ */ __name(() => InlineCredentialTemplateValidator, "InlineCredentialTemplateValidator"),
|
|
235
|
+
InlineEvidenceValidator: /* @__PURE__ */ __name(() => InlineEvidenceValidator, "InlineEvidenceValidator"),
|
|
236
|
+
InlineSendCredentialEventValidator: /* @__PURE__ */ __name(() => InlineSendCredentialEventValidator, "InlineSendCredentialEventValidator"),
|
|
237
|
+
InlineWalletCategoryValidator: /* @__PURE__ */ __name(() => InlineWalletCategoryValidator, "InlineWalletCategoryValidator"),
|
|
238
|
+
InlineWalletSkillTagValidator: /* @__PURE__ */ __name(() => InlineWalletSkillTagValidator, "InlineWalletSkillTagValidator"),
|
|
212
239
|
InstalledAppValidator: /* @__PURE__ */ __name(() => InstalledAppValidator, "InstalledAppValidator"),
|
|
213
240
|
IssueInboxCredentialBatchItemResultValidator: /* @__PURE__ */ __name(() => IssueInboxCredentialBatchItemResultValidator, "IssueInboxCredentialBatchItemResultValidator"),
|
|
214
241
|
IssueInboxCredentialBatchItemValidator: /* @__PURE__ */ __name(() => IssueInboxCredentialBatchItemValidator, "IssueInboxCredentialBatchItemValidator"),
|
|
@@ -261,6 +288,7 @@ var require_types_cjs_development = __commonJS({
|
|
|
261
288
|
LCNVisibleProfileValidator: /* @__PURE__ */ __name(() => LCNVisibleProfileValidator, "LCNVisibleProfileValidator"),
|
|
262
289
|
LaunchTypeValidator: /* @__PURE__ */ __name(() => LaunchTypeValidator, "LaunchTypeValidator"),
|
|
263
290
|
LearnCardRefreshAuthorizationValidator: /* @__PURE__ */ __name(() => LearnCardRefreshAuthorizationValidator, "LearnCardRefreshAuthorizationValidator"),
|
|
291
|
+
LegacySendCredentialEventValidator: /* @__PURE__ */ __name(() => LegacySendCredentialEventValidator, "LegacySendCredentialEventValidator"),
|
|
264
292
|
LinkProviderFrameworkInputValidator: /* @__PURE__ */ __name(() => LinkProviderFrameworkInputValidator, "LinkProviderFrameworkInputValidator"),
|
|
265
293
|
ListShareLinksInputValidator: /* @__PURE__ */ __name(() => ListShareLinksInputValidator, "ListShareLinksInputValidator"),
|
|
266
294
|
MAX_ENDORSEMENTS: /* @__PURE__ */ __name(() => MAX_ENDORSEMENTS, "MAX_ENDORSEMENTS"),
|
|
@@ -272,6 +300,7 @@ var require_types_cjs_development = __commonJS({
|
|
|
272
300
|
MAX_VP_MEMBERS: /* @__PURE__ */ __name(() => MAX_VP_MEMBERS, "MAX_VP_MEMBERS"),
|
|
273
301
|
ManagedCredentialRefreshReceiptValidator: /* @__PURE__ */ __name(() => ManagedCredentialRefreshReceiptValidator, "ManagedCredentialRefreshReceiptValidator"),
|
|
274
302
|
ManagedCredentialRefreshServiceValidator: /* @__PURE__ */ __name(() => ManagedCredentialRefreshServiceValidator, "ManagedCredentialRefreshServiceValidator"),
|
|
303
|
+
NormalizedConsentScopesValidator: /* @__PURE__ */ __name(() => NormalizedConsentScopesValidator, "NormalizedConsentScopesValidator"),
|
|
275
304
|
PaginatedAppStoreListingsValidator: /* @__PURE__ */ __name(() => PaginatedAppStoreListingsValidator, "PaginatedAppStoreListingsValidator"),
|
|
276
305
|
PaginatedBoostRecipientsValidator: /* @__PURE__ */ __name(() => PaginatedBoostRecipientsValidator, "PaginatedBoostRecipientsValidator"),
|
|
277
306
|
PaginatedBoostRecipientsWithChildrenValidator: /* @__PURE__ */ __name(() => PaginatedBoostRecipientsWithChildrenValidator, "PaginatedBoostRecipientsWithChildrenValidator"),
|
|
@@ -298,6 +327,8 @@ var require_types_cjs_development = __commonJS({
|
|
|
298
327
|
PaginatedVisibleLCNProfilesValidator: /* @__PURE__ */ __name(() => PaginatedVisibleLCNProfilesValidator, "PaginatedVisibleLCNProfilesValidator"),
|
|
299
328
|
PaginationOptionsValidator: /* @__PURE__ */ __name(() => PaginationOptionsValidator, "PaginationOptionsValidator"),
|
|
300
329
|
PaginationResponseValidator: /* @__PURE__ */ __name(() => PaginationResponseValidator, "PaginationResponseValidator"),
|
|
330
|
+
PendingListingUpdateStatusValidator: /* @__PURE__ */ __name(() => PendingListingUpdateStatusValidator, "PendingListingUpdateStatusValidator"),
|
|
331
|
+
PendingListingUpdateValidator: /* @__PURE__ */ __name(() => PendingListingUpdateValidator, "PendingListingUpdateValidator"),
|
|
301
332
|
PrepareRefreshableSendInputValidator: /* @__PURE__ */ __name(() => PrepareRefreshableSendInputValidator, "PrepareRefreshableSendInputValidator"),
|
|
302
333
|
PrepareRefreshableSendResultValidator: /* @__PURE__ */ __name(() => PrepareRefreshableSendResultValidator, "PrepareRefreshableSendResultValidator"),
|
|
303
334
|
ProfileValidator: /* @__PURE__ */ __name(() => ProfileValidator, "ProfileValidator"),
|
|
@@ -310,6 +341,9 @@ var require_types_cjs_development = __commonJS({
|
|
|
310
341
|
PublishCredentialRefreshResultValidator: /* @__PURE__ */ __name(() => PublishCredentialRefreshResultValidator, "PublishCredentialRefreshResultValidator"),
|
|
311
342
|
PublishIssuerSignedRefreshValidator: /* @__PURE__ */ __name(() => PublishIssuerSignedRefreshValidator, "PublishIssuerSignedRefreshValidator"),
|
|
312
343
|
PublishSigningAuthorityRefreshValidator: /* @__PURE__ */ __name(() => PublishSigningAuthorityRefreshValidator, "PublishSigningAuthorityRefreshValidator"),
|
|
344
|
+
PutShareLinkAttachmentChunkInputValidator: /* @__PURE__ */ __name(() => PutShareLinkAttachmentChunkInputValidator, "PutShareLinkAttachmentChunkInputValidator"),
|
|
345
|
+
PutShareLinkAttachmentChunkOutputValidator: /* @__PURE__ */ __name(() => PutShareLinkAttachmentChunkOutputValidator, "PutShareLinkAttachmentChunkOutputValidator"),
|
|
346
|
+
RawInlineCredentialTemplateValidator: /* @__PURE__ */ __name(() => RawInlineCredentialTemplateValidator, "RawInlineCredentialTemplateValidator"),
|
|
313
347
|
RefreshServiceValidator: /* @__PURE__ */ __name(() => RefreshServiceValidator, "RefreshServiceValidator"),
|
|
314
348
|
RegExpValidator: /* @__PURE__ */ __name(() => RegExpValidator, "RegExpValidator"),
|
|
315
349
|
RelatedValidator: /* @__PURE__ */ __name(() => RelatedValidator, "RelatedValidator"),
|
|
@@ -336,6 +370,7 @@ var require_types_cjs_development = __commonJS({
|
|
|
336
370
|
SendBoostResponseValidator: /* @__PURE__ */ __name(() => SendBoostResponseValidator, "SendBoostResponseValidator"),
|
|
337
371
|
SendBoostTemplateValidator: /* @__PURE__ */ __name(() => SendBoostTemplateValidator, "SendBoostTemplateValidator"),
|
|
338
372
|
SendBrandingOptionsValidator: /* @__PURE__ */ __name(() => SendBrandingOptionsValidator, "SendBrandingOptionsValidator"),
|
|
373
|
+
SendContractRequestValidator: /* @__PURE__ */ __name(() => SendContractRequestValidator, "SendContractRequestValidator"),
|
|
339
374
|
SendCredentialEventValidator: /* @__PURE__ */ __name(() => SendCredentialEventValidator, "SendCredentialEventValidator"),
|
|
340
375
|
SendInboxResponseValidator: /* @__PURE__ */ __name(() => SendInboxResponseValidator, "SendInboxResponseValidator"),
|
|
341
376
|
SendInputValidator: /* @__PURE__ */ __name(() => SendInputValidator, "SendInputValidator"),
|
|
@@ -351,6 +386,9 @@ var require_types_cjs_development = __commonJS({
|
|
|
351
386
|
ShareEndorsementEntryValidator: /* @__PURE__ */ __name(() => ShareEndorsementEntryValidator, "ShareEndorsementEntryValidator"),
|
|
352
387
|
ShareEnvelopeValidator: /* @__PURE__ */ __name(() => ShareEnvelopeValidator, "ShareEnvelopeValidator"),
|
|
353
388
|
ShareIvValidator: /* @__PURE__ */ __name(() => ShareIvValidator, "ShareIvValidator"),
|
|
389
|
+
ShareLinkAttachmentChunkEnvelopeValidator: /* @__PURE__ */ __name(() => ShareLinkAttachmentChunkEnvelopeValidator, "ShareLinkAttachmentChunkEnvelopeValidator"),
|
|
390
|
+
ShareLinkAttachmentChunkOutputValidator: /* @__PURE__ */ __name(() => ShareLinkAttachmentChunkOutputValidator, "ShareLinkAttachmentChunkOutputValidator"),
|
|
391
|
+
ShareLinkAttachmentValidator: /* @__PURE__ */ __name(() => ShareLinkAttachmentValidator, "ShareLinkAttachmentValidator"),
|
|
354
392
|
ShareLinkIdInputValidator: /* @__PURE__ */ __name(() => ShareLinkIdInputValidator, "ShareLinkIdInputValidator"),
|
|
355
393
|
ShareLinkIdValidator: /* @__PURE__ */ __name(() => ShareLinkIdValidator, "ShareLinkIdValidator"),
|
|
356
394
|
ShareLinkOperationKeyInputValidator: /* @__PURE__ */ __name(() => ShareLinkOperationKeyInputValidator, "ShareLinkOperationKeyInputValidator"),
|
|
@@ -371,6 +409,7 @@ var require_types_cjs_development = __commonJS({
|
|
|
371
409
|
ShareRecoverySelectionValidator: /* @__PURE__ */ __name(() => ShareRecoverySelectionValidator, "ShareRecoverySelectionValidator"),
|
|
372
410
|
ShareSelectionEntryValidator: /* @__PURE__ */ __name(() => ShareSelectionEntryValidator, "ShareSelectionEntryValidator"),
|
|
373
411
|
ShareSharerValidator: /* @__PURE__ */ __name(() => ShareSharerValidator, "ShareSharerValidator"),
|
|
412
|
+
SimpleInlineCredentialTemplateValidator: /* @__PURE__ */ __name(() => SimpleInlineCredentialTemplateValidator, "SimpleInlineCredentialTemplateValidator"),
|
|
374
413
|
SkillDeletionStrategyValidator: /* @__PURE__ */ __name(() => SkillDeletionStrategyValidator, "SkillDeletionStrategyValidator"),
|
|
375
414
|
SkillFrameworkAdminInputValidator: /* @__PURE__ */ __name(() => SkillFrameworkAdminInputValidator, "SkillFrameworkAdminInputValidator"),
|
|
376
415
|
SkillFrameworkAdminsValidator: /* @__PURE__ */ __name(() => SkillFrameworkAdminsValidator, "SkillFrameworkAdminsValidator"),
|
|
@@ -401,9 +440,12 @@ var require_types_cjs_development = __commonJS({
|
|
|
401
440
|
UnsignedClrCredentialValidator: /* @__PURE__ */ __name(() => UnsignedClrCredentialValidator, "UnsignedClrCredentialValidator"),
|
|
402
441
|
UnsignedVCValidator: /* @__PURE__ */ __name(() => UnsignedVCValidator, "UnsignedVCValidator"),
|
|
403
442
|
UnsignedVPValidator: /* @__PURE__ */ __name(() => UnsignedVPValidator, "UnsignedVPValidator"),
|
|
443
|
+
UnsupportedSignInOperationError: /* @__PURE__ */ __name(() => UnsupportedSignInOperationError, "UnsupportedSignInOperationError"),
|
|
404
444
|
UpdateFrameworkInputValidator: /* @__PURE__ */ __name(() => UpdateFrameworkInputValidator, "UpdateFrameworkInputValidator"),
|
|
405
445
|
UpdateShareLinkInputValidator: /* @__PURE__ */ __name(() => UpdateShareLinkInputValidator, "UpdateShareLinkInputValidator"),
|
|
406
446
|
UpdateSkillInputValidator: /* @__PURE__ */ __name(() => UpdateSkillInputValidator, "UpdateSkillInputValidator"),
|
|
447
|
+
UpsertConsentContractEventValidator: /* @__PURE__ */ __name(() => UpsertConsentContractEventValidator, "UpsertConsentContractEventValidator"),
|
|
448
|
+
UpsertConsentContractResponseValidator: /* @__PURE__ */ __name(() => UpsertConsentContractResponseValidator, "UpsertConsentContractResponseValidator"),
|
|
407
449
|
VC2EvidenceValidator: /* @__PURE__ */ __name(() => VC2EvidenceValidator, "VC2EvidenceValidator"),
|
|
408
450
|
VCValidator: /* @__PURE__ */ __name(() => VCValidator, "VCValidator"),
|
|
409
451
|
VPValidator: /* @__PURE__ */ __name(() => VPValidator, "VPValidator"),
|
|
@@ -549,14 +591,14 @@ var require_types_cjs_development = __commonJS({
|
|
|
549
591
|
cuid2: /* @__PURE__ */ __name(() => cuid22, "cuid2"),
|
|
550
592
|
custom: /* @__PURE__ */ __name(() => custom, "custom"),
|
|
551
593
|
date: /* @__PURE__ */ __name(() => date3, "date"),
|
|
552
|
-
decode: /* @__PURE__ */ __name(() =>
|
|
594
|
+
decode: /* @__PURE__ */ __name(() => decode22, "decode"),
|
|
553
595
|
decodeAsync: /* @__PURE__ */ __name(() => decodeAsync2, "decodeAsync"),
|
|
554
596
|
describe: /* @__PURE__ */ __name(() => describe2, "describe"),
|
|
555
597
|
discriminatedUnion: /* @__PURE__ */ __name(() => discriminatedUnion, "discriminatedUnion"),
|
|
556
598
|
e164: /* @__PURE__ */ __name(() => e1642, "e164"),
|
|
557
599
|
email: /* @__PURE__ */ __name(() => email2, "email"),
|
|
558
600
|
emoji: /* @__PURE__ */ __name(() => emoji2, "emoji"),
|
|
559
|
-
encode: /* @__PURE__ */ __name(() =>
|
|
601
|
+
encode: /* @__PURE__ */ __name(() => encode22, "encode"),
|
|
560
602
|
encodeAsync: /* @__PURE__ */ __name(() => encodeAsync2, "encodeAsync"),
|
|
561
603
|
endsWith: /* @__PURE__ */ __name(() => _endsWith, "endsWith"),
|
|
562
604
|
enum: /* @__PURE__ */ __name(() => _enum2, "enum"),
|
|
@@ -574,7 +616,7 @@ var require_types_cjs_development = __commonJS({
|
|
|
574
616
|
gte: /* @__PURE__ */ __name(() => _gte, "gte"),
|
|
575
617
|
guid: /* @__PURE__ */ __name(() => guid2, "guid"),
|
|
576
618
|
hash: /* @__PURE__ */ __name(() => hash, "hash"),
|
|
577
|
-
hex: /* @__PURE__ */ __name(() =>
|
|
619
|
+
hex: /* @__PURE__ */ __name(() => hex22, "hex"),
|
|
578
620
|
hostname: /* @__PURE__ */ __name(() => hostname2, "hostname"),
|
|
579
621
|
httpUrl: /* @__PURE__ */ __name(() => httpUrl, "httpUrl"),
|
|
580
622
|
includes: /* @__PURE__ */ __name(() => _includes, "includes"),
|
|
@@ -601,7 +643,7 @@ var require_types_cjs_development = __commonJS({
|
|
|
601
643
|
lt: /* @__PURE__ */ __name(() => _lt, "lt"),
|
|
602
644
|
lte: /* @__PURE__ */ __name(() => _lte, "lte"),
|
|
603
645
|
mac: /* @__PURE__ */ __name(() => mac2, "mac"),
|
|
604
|
-
map: /* @__PURE__ */ __name(() =>
|
|
646
|
+
map: /* @__PURE__ */ __name(() => map2, "map"),
|
|
605
647
|
maxLength: /* @__PURE__ */ __name(() => _maxLength, "maxLength"),
|
|
606
648
|
maxSize: /* @__PURE__ */ __name(() => _maxSize, "maxSize"),
|
|
607
649
|
meta: /* @__PURE__ */ __name(() => meta2, "meta"),
|
|
@@ -926,10 +968,10 @@ var require_types_cjs_development = __commonJS({
|
|
|
926
968
|
config: /* @__PURE__ */ __name(() => config, "config"),
|
|
927
969
|
createStandardJSONSchemaMethod: /* @__PURE__ */ __name(() => createStandardJSONSchemaMethod, "createStandardJSONSchemaMethod"),
|
|
928
970
|
createToJSONSchemaMethod: /* @__PURE__ */ __name(() => createToJSONSchemaMethod, "createToJSONSchemaMethod"),
|
|
929
|
-
decode: /* @__PURE__ */ __name(() =>
|
|
971
|
+
decode: /* @__PURE__ */ __name(() => decode2, "decode"),
|
|
930
972
|
decodeAsync: /* @__PURE__ */ __name(() => decodeAsync, "decodeAsync"),
|
|
931
973
|
describe: /* @__PURE__ */ __name(() => describe, "describe"),
|
|
932
|
-
encode: /* @__PURE__ */ __name(() =>
|
|
974
|
+
encode: /* @__PURE__ */ __name(() => encode2, "encode"),
|
|
933
975
|
encodeAsync: /* @__PURE__ */ __name(() => encodeAsync, "encodeAsync"),
|
|
934
976
|
extractDefs: /* @__PURE__ */ __name(() => extractDefs, "extractDefs"),
|
|
935
977
|
finalize: /* @__PURE__ */ __name(() => finalize, "finalize"),
|
|
@@ -1815,18 +1857,18 @@ var require_types_cjs_development = __commonJS({
|
|
|
1815
1857
|
__name2(cleanEnum, "cleanEnum");
|
|
1816
1858
|
function base64ToUint8Array(base643) {
|
|
1817
1859
|
const binaryString = atob(base643);
|
|
1818
|
-
const
|
|
1860
|
+
const bytes2 = new Uint8Array(binaryString.length);
|
|
1819
1861
|
for (let i = 0; i < binaryString.length; i++) {
|
|
1820
|
-
|
|
1862
|
+
bytes2[i] = binaryString.charCodeAt(i);
|
|
1821
1863
|
}
|
|
1822
|
-
return
|
|
1864
|
+
return bytes2;
|
|
1823
1865
|
}
|
|
1824
1866
|
__name(base64ToUint8Array, "base64ToUint8Array");
|
|
1825
1867
|
__name2(base64ToUint8Array, "base64ToUint8Array");
|
|
1826
|
-
function uint8ArrayToBase64(
|
|
1868
|
+
function uint8ArrayToBase64(bytes2) {
|
|
1827
1869
|
let binaryString = "";
|
|
1828
|
-
for (let i = 0; i <
|
|
1829
|
-
binaryString += String.fromCharCode(
|
|
1870
|
+
for (let i = 0; i < bytes2.length; i++) {
|
|
1871
|
+
binaryString += String.fromCharCode(bytes2[i]);
|
|
1830
1872
|
}
|
|
1831
1873
|
return btoa(binaryString);
|
|
1832
1874
|
}
|
|
@@ -1839,8 +1881,8 @@ var require_types_cjs_development = __commonJS({
|
|
|
1839
1881
|
}
|
|
1840
1882
|
__name(base64urlToUint8Array, "base64urlToUint8Array");
|
|
1841
1883
|
__name2(base64urlToUint8Array, "base64urlToUint8Array");
|
|
1842
|
-
function uint8ArrayToBase64url(
|
|
1843
|
-
return uint8ArrayToBase64(
|
|
1884
|
+
function uint8ArrayToBase64url(bytes2) {
|
|
1885
|
+
return uint8ArrayToBase64(bytes2).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
1844
1886
|
}
|
|
1845
1887
|
__name(uint8ArrayToBase64url, "uint8ArrayToBase64url");
|
|
1846
1888
|
__name2(uint8ArrayToBase64url, "uint8ArrayToBase64url");
|
|
@@ -1849,16 +1891,16 @@ var require_types_cjs_development = __commonJS({
|
|
|
1849
1891
|
if (cleanHex.length % 2 !== 0) {
|
|
1850
1892
|
throw new Error("Invalid hex string length");
|
|
1851
1893
|
}
|
|
1852
|
-
const
|
|
1894
|
+
const bytes2 = new Uint8Array(cleanHex.length / 2);
|
|
1853
1895
|
for (let i = 0; i < cleanHex.length; i += 2) {
|
|
1854
|
-
|
|
1896
|
+
bytes2[i / 2] = Number.parseInt(cleanHex.slice(i, i + 2), 16);
|
|
1855
1897
|
}
|
|
1856
|
-
return
|
|
1898
|
+
return bytes2;
|
|
1857
1899
|
}
|
|
1858
1900
|
__name(hexToUint8Array, "hexToUint8Array");
|
|
1859
1901
|
__name2(hexToUint8Array, "hexToUint8Array");
|
|
1860
|
-
function uint8ArrayToHex(
|
|
1861
|
-
return Array.from(
|
|
1902
|
+
function uint8ArrayToHex(bytes2) {
|
|
1903
|
+
return Array.from(bytes2).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
1862
1904
|
}
|
|
1863
1905
|
__name(uint8ArrayToHex, "uint8ArrayToHex");
|
|
1864
1906
|
__name2(uint8ArrayToHex, "uint8ArrayToHex");
|
|
@@ -2073,11 +2115,11 @@ var require_types_cjs_development = __commonJS({
|
|
|
2073
2115
|
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
2074
2116
|
return _parse(_Err)(schema, value, ctx);
|
|
2075
2117
|
}, "_encode");
|
|
2076
|
-
var
|
|
2118
|
+
var encode2 = /* @__PURE__ */ _encode($ZodRealError);
|
|
2077
2119
|
var _decode = /* @__PURE__ */ __name2((_Err) => (schema, value, _ctx) => {
|
|
2078
2120
|
return _parse(_Err)(schema, value, _ctx);
|
|
2079
2121
|
}, "_decode");
|
|
2080
|
-
var
|
|
2122
|
+
var decode2 = /* @__PURE__ */ _decode($ZodRealError);
|
|
2081
2123
|
var _encodeAsync = /* @__PURE__ */ __name2((_Err) => async (schema, value, _ctx) => {
|
|
2082
2124
|
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
2083
2125
|
return _parseAsync(_Err)(schema, value, ctx);
|
|
@@ -2125,7 +2167,7 @@ var require_types_cjs_development = __commonJS({
|
|
|
2125
2167
|
emoji: /* @__PURE__ */ __name(() => emoji, "emoji"),
|
|
2126
2168
|
extendedDuration: /* @__PURE__ */ __name(() => extendedDuration, "extendedDuration"),
|
|
2127
2169
|
guid: /* @__PURE__ */ __name(() => guid, "guid"),
|
|
2128
|
-
hex: /* @__PURE__ */ __name(() =>
|
|
2170
|
+
hex: /* @__PURE__ */ __name(() => hex2, "hex"),
|
|
2129
2171
|
hostname: /* @__PURE__ */ __name(() => hostname, "hostname"),
|
|
2130
2172
|
html5Email: /* @__PURE__ */ __name(() => html5Email, "html5Email"),
|
|
2131
2173
|
httpProtocol: /* @__PURE__ */ __name(() => httpProtocol, "httpProtocol"),
|
|
@@ -2248,7 +2290,7 @@ var require_types_cjs_development = __commonJS({
|
|
|
2248
2290
|
var _undefined = /^undefined$/i;
|
|
2249
2291
|
var lowercase = /^[^A-Z]*$/;
|
|
2250
2292
|
var uppercase = /^[^a-z]*$/;
|
|
2251
|
-
var
|
|
2293
|
+
var hex2 = /^[0-9a-fA-F]*$/;
|
|
2252
2294
|
function fixedBase64(bodyLength, padding) {
|
|
2253
2295
|
return new RegExp(`^[A-Za-z0-9+/]{${bodyLength}}${padding}$`);
|
|
2254
2296
|
}
|
|
@@ -3952,19 +3994,19 @@ var require_types_cjs_development = __commonJS({
|
|
|
3952
3994
|
});
|
|
3953
3995
|
const disc = cached(() => {
|
|
3954
3996
|
const opts = def.options;
|
|
3955
|
-
const
|
|
3997
|
+
const map22 = /* @__PURE__ */ new Map();
|
|
3956
3998
|
for (const o of opts) {
|
|
3957
3999
|
const values = o._zod.propValues?.[def.discriminator];
|
|
3958
4000
|
if (!values || values.size === 0)
|
|
3959
4001
|
throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
|
|
3960
4002
|
for (const v of values) {
|
|
3961
|
-
if (
|
|
4003
|
+
if (map22.has(v)) {
|
|
3962
4004
|
throw new Error(`Duplicate discriminator value "${String(v)}"`);
|
|
3963
4005
|
}
|
|
3964
|
-
|
|
4006
|
+
map22.set(v, o);
|
|
3965
4007
|
}
|
|
3966
4008
|
}
|
|
3967
|
-
return
|
|
4009
|
+
return map22;
|
|
3968
4010
|
});
|
|
3969
4011
|
inst._zod.parse = (payload, ctx) => {
|
|
3970
4012
|
const input = payload.value;
|
|
@@ -13481,7 +13523,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
13481
13523
|
function: /* @__PURE__ */ __name(() => _function, "function"),
|
|
13482
13524
|
guid: /* @__PURE__ */ __name(() => guid2, "guid"),
|
|
13483
13525
|
hash: /* @__PURE__ */ __name(() => hash, "hash"),
|
|
13484
|
-
hex: /* @__PURE__ */ __name(() =>
|
|
13526
|
+
hex: /* @__PURE__ */ __name(() => hex22, "hex"),
|
|
13485
13527
|
hostname: /* @__PURE__ */ __name(() => hostname2, "hostname"),
|
|
13486
13528
|
httpUrl: /* @__PURE__ */ __name(() => httpUrl, "httpUrl"),
|
|
13487
13529
|
instanceof: /* @__PURE__ */ __name(() => _instanceof, "instanceof"),
|
|
@@ -13501,7 +13543,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
13501
13543
|
looseObject: /* @__PURE__ */ __name(() => looseObject, "looseObject"),
|
|
13502
13544
|
looseRecord: /* @__PURE__ */ __name(() => looseRecord, "looseRecord"),
|
|
13503
13545
|
mac: /* @__PURE__ */ __name(() => mac2, "mac"),
|
|
13504
|
-
map: /* @__PURE__ */ __name(() =>
|
|
13546
|
+
map: /* @__PURE__ */ __name(() => map2, "map"),
|
|
13505
13547
|
meta: /* @__PURE__ */ __name(() => meta2, "meta"),
|
|
13506
13548
|
nan: /* @__PURE__ */ __name(() => nan, "nan"),
|
|
13507
13549
|
nanoid: /* @__PURE__ */ __name(() => nanoid2, "nanoid"),
|
|
@@ -13669,8 +13711,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
13669
13711
|
var parseAsync2 = /* @__PURE__ */ _parseAsync(ZodRealError);
|
|
13670
13712
|
var safeParse2 = /* @__PURE__ */ _safeParse(ZodRealError);
|
|
13671
13713
|
var safeParseAsync2 = /* @__PURE__ */ _safeParseAsync(ZodRealError);
|
|
13672
|
-
var
|
|
13673
|
-
var
|
|
13714
|
+
var encode22 = /* @__PURE__ */ _encode(ZodRealError);
|
|
13715
|
+
var decode22 = /* @__PURE__ */ _decode(ZodRealError);
|
|
13674
13716
|
var encodeAsync2 = /* @__PURE__ */ _encodeAsync(ZodRealError);
|
|
13675
13717
|
var decodeAsync2 = /* @__PURE__ */ _decodeAsync(ZodRealError);
|
|
13676
13718
|
var safeEncode2 = /* @__PURE__ */ _safeEncode(ZodRealError);
|
|
@@ -13733,8 +13775,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
13733
13775
|
inst.parseAsync = async (data, params) => parseAsync2(inst, data, params, { callee: inst.parseAsync });
|
|
13734
13776
|
inst.safeParseAsync = async (data, params) => safeParseAsync2(inst, data, params);
|
|
13735
13777
|
inst.spa = inst.safeParseAsync;
|
|
13736
|
-
inst.encode = (data, params) =>
|
|
13737
|
-
inst.decode = (data, params) =>
|
|
13778
|
+
inst.encode = (data, params) => encode22(inst, data, params);
|
|
13779
|
+
inst.decode = (data, params) => decode22(inst, data, params);
|
|
13738
13780
|
inst.encodeAsync = async (data, params) => encodeAsync2(inst, data, params);
|
|
13739
13781
|
inst.decodeAsync = async (data, params) => decodeAsync2(inst, data, params);
|
|
13740
13782
|
inst.safeEncode = (data, params) => safeEncode2(inst, data, params);
|
|
@@ -14159,11 +14201,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
14159
14201
|
}
|
|
14160
14202
|
__name(hostname2, "hostname2");
|
|
14161
14203
|
__name2(hostname2, "hostname");
|
|
14162
|
-
function
|
|
14204
|
+
function hex22(_params) {
|
|
14163
14205
|
return /* @__PURE__ */ _stringFormat(ZodCustomStringFormat, "hex", regexes_exports.hex, _params);
|
|
14164
14206
|
}
|
|
14165
|
-
__name(
|
|
14166
|
-
__name2(
|
|
14207
|
+
__name(hex22, "hex2");
|
|
14208
|
+
__name2(hex22, "hex");
|
|
14167
14209
|
function hash(alg, params) {
|
|
14168
14210
|
const enc = params?.enc ?? "hex";
|
|
14169
14211
|
const format = `${alg}_${enc}`;
|
|
@@ -14655,7 +14697,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
14655
14697
|
inst.max = (...args) => inst.check(/* @__PURE__ */ _maxSize(...args));
|
|
14656
14698
|
inst.size = (...args) => inst.check(/* @__PURE__ */ _size(...args));
|
|
14657
14699
|
});
|
|
14658
|
-
function
|
|
14700
|
+
function map2(keyType, valueType, params) {
|
|
14659
14701
|
return new ZodMap({
|
|
14660
14702
|
type: "map",
|
|
14661
14703
|
keyType,
|
|
@@ -14663,8 +14705,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
14663
14705
|
...util_exports.normalizeParams(params)
|
|
14664
14706
|
});
|
|
14665
14707
|
}
|
|
14666
|
-
__name(
|
|
14667
|
-
__name2(
|
|
14708
|
+
__name(map2, "map");
|
|
14709
|
+
__name2(map2, "map");
|
|
14668
14710
|
var ZodSet = /* @__PURE__ */ $constructor("ZodSet", (inst, def) => {
|
|
14669
14711
|
$ZodSet.init(inst, def);
|
|
14670
14712
|
ZodType.init(inst, def);
|
|
@@ -15164,9 +15206,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
15164
15206
|
invalid_value: "invalid_value",
|
|
15165
15207
|
custom: "custom"
|
|
15166
15208
|
};
|
|
15167
|
-
function setErrorMap(
|
|
15209
|
+
function setErrorMap(map22) {
|
|
15168
15210
|
config({
|
|
15169
|
-
customError:
|
|
15211
|
+
customError: map22
|
|
15170
15212
|
});
|
|
15171
15213
|
}
|
|
15172
15214
|
__name(setErrorMap, "setErrorMap");
|
|
@@ -16124,7 +16166,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
16124
16166
|
"replacedBy"
|
|
16125
16167
|
]).or(external_exports.string());
|
|
16126
16168
|
var AssociationValidator = external_exports.object({
|
|
16127
|
-
|
|
16169
|
+
// Accept compacted scalars while retaining the existing permissive array contract.
|
|
16170
|
+
type: external_exports.string().min(1).or(external_exports.string().array().nonempty()),
|
|
16128
16171
|
associationType: AssociationTypeValidator,
|
|
16129
16172
|
sourceId: external_exports.string().optional(),
|
|
16130
16173
|
targetId: external_exports.string()
|
|
@@ -16947,11 +16990,48 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
16947
16990
|
updatedAt: external_exports.string(),
|
|
16948
16991
|
expiresAt: external_exports.string().optional(),
|
|
16949
16992
|
autoBoosts: external_exports.string().array().optional(),
|
|
16950
|
-
writers: external_exports.array(LCNProfileValidator).optional()
|
|
16993
|
+
writers: external_exports.array(LCNProfileValidator).optional(),
|
|
16994
|
+
recipients: external_exports.array(LCNPublicProfileValidator.extend({ did: external_exports.string() })).optional(),
|
|
16995
|
+
audienceVersion: external_exports.number().int().nonnegative().optional()
|
|
16951
16996
|
});
|
|
16952
|
-
var ConsentFlowContractRequestStatusValidator = external_exports.enum(["pending", "accepted", "denied"]).nullable();
|
|
16997
|
+
var ConsentFlowContractRequestStatusValidator = external_exports.enum(["pending", "accepted", "denied", "cancelled"]).nullable();
|
|
16953
16998
|
var ConsentFlowContractRequestReadStatusValidator = external_exports.enum(["unseen", "seen"]).nullable();
|
|
16954
|
-
var
|
|
16999
|
+
var ConsentFlowReferralValidator = external_exports.object({
|
|
17000
|
+
requestId: external_exports.string(),
|
|
17001
|
+
requestedBy: external_exports.string(),
|
|
17002
|
+
externalReferenceId: external_exports.string().max(256).optional()
|
|
17003
|
+
});
|
|
17004
|
+
var ContractRequestFieldsValidator = ConsentFlowReferralValidator.partial().extend({
|
|
17005
|
+
requestedAt: external_exports.string().optional(),
|
|
17006
|
+
message: external_exports.string().max(500).optional()
|
|
17007
|
+
});
|
|
17008
|
+
var SendContractRequestValidator = external_exports.object({
|
|
17009
|
+
contractUri: external_exports.string(),
|
|
17010
|
+
targetProfileId: external_exports.string(),
|
|
17011
|
+
externalReferenceId: external_exports.string().trim().min(1).max(256).optional(),
|
|
17012
|
+
message: external_exports.string().trim().max(500).optional()
|
|
17013
|
+
});
|
|
17014
|
+
var ConsentFlowWebhookMetadataValidator = external_exports.object({
|
|
17015
|
+
eventId: external_exports.string(),
|
|
17016
|
+
deliveryKey: external_exports.string(),
|
|
17017
|
+
event: external_exports.enum([
|
|
17018
|
+
"request_sent",
|
|
17019
|
+
"request_accepted",
|
|
17020
|
+
"request_denied",
|
|
17021
|
+
"request_cancelled",
|
|
17022
|
+
"consent_created",
|
|
17023
|
+
"consent_updated",
|
|
17024
|
+
"consent_withdrawn",
|
|
17025
|
+
"credentials_synced"
|
|
17026
|
+
]),
|
|
17027
|
+
contractUri: external_exports.string(),
|
|
17028
|
+
termsUri: external_exports.string().optional(),
|
|
17029
|
+
requestId: external_exports.string().optional(),
|
|
17030
|
+
requestedBy: external_exports.string().optional(),
|
|
17031
|
+
externalReferenceId: external_exports.string().optional(),
|
|
17032
|
+
recipientRole: external_exports.enum(["owner", "recipient", "requester", "target"])
|
|
17033
|
+
});
|
|
17034
|
+
var ConsentFlowContractRequestForProfileValidator = ContractRequestFieldsValidator.extend({
|
|
16955
17035
|
profile: LCNProfileValidator,
|
|
16956
17036
|
status: ConsentFlowContractRequestStatusValidator,
|
|
16957
17037
|
readStatus: ConsentFlowContractRequestReadStatusValidator.optional()
|
|
@@ -16997,6 +17077,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
16997
17077
|
expiresAt: external_exports.string().optional(),
|
|
16998
17078
|
oneTime: external_exports.boolean().optional(),
|
|
16999
17079
|
terms: ConsentFlowTermsValidator,
|
|
17080
|
+
referral: ConsentFlowReferralValidator.optional(),
|
|
17000
17081
|
contract: ConsentFlowContractDetailsValidator,
|
|
17001
17082
|
uri: external_exports.string(),
|
|
17002
17083
|
consenter: LCNProfileValidator,
|
|
@@ -17092,6 +17173,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
17092
17173
|
oneTime: external_exports.boolean().optional(),
|
|
17093
17174
|
terms: ConsentFlowTermsValidator.optional(),
|
|
17094
17175
|
guardianApproval: ConsentFlowGuardianApprovalValidator.optional(),
|
|
17176
|
+
referral: ConsentFlowReferralValidator.optional(),
|
|
17095
17177
|
id: external_exports.string(),
|
|
17096
17178
|
action: ConsentFlowTransactionActionValidator,
|
|
17097
17179
|
date: external_exports.string(),
|
|
@@ -17102,6 +17184,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
17102
17184
|
status: ConsentFlowTermsStatusValidator,
|
|
17103
17185
|
contract: ConsentFlowContractDetailsValidator,
|
|
17104
17186
|
terms: ConsentFlowTermsValidator,
|
|
17187
|
+
referral: ConsentFlowReferralValidator.optional(),
|
|
17105
17188
|
transactions: ConsentFlowTransactionValidator.array()
|
|
17106
17189
|
});
|
|
17107
17190
|
var HolderExportMetadataValidator = external_exports.object({
|
|
@@ -17838,7 +17921,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
17838
17921
|
displayName: external_exports.string(),
|
|
17839
17922
|
email: external_exports.string().optional()
|
|
17840
17923
|
});
|
|
17841
|
-
var
|
|
17924
|
+
var AppStoreListingFieldsValidator = external_exports.object({
|
|
17842
17925
|
listing_id: external_exports.string(),
|
|
17843
17926
|
slug: external_exports.string().optional(),
|
|
17844
17927
|
display_name: external_exports.string(),
|
|
@@ -17864,15 +17947,33 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
17864
17947
|
submitter: AppStoreListingSubmitterValidator.optional(),
|
|
17865
17948
|
contact_email: external_exports.string().email().optional()
|
|
17866
17949
|
});
|
|
17950
|
+
var PendingListingUpdateStatusValidator = external_exports.enum(["DRAFT", "PENDING_REVIEW"]);
|
|
17951
|
+
var PendingListingUpdateValidator = external_exports.object({
|
|
17952
|
+
status: PendingListingUpdateStatusValidator,
|
|
17953
|
+
submitted_at: external_exports.string().optional(),
|
|
17954
|
+
changes: AppStoreListingFieldsValidator.omit({
|
|
17955
|
+
listing_id: true,
|
|
17956
|
+
app_listing_status: true,
|
|
17957
|
+
promotion_level: true,
|
|
17958
|
+
submitted_at: true,
|
|
17959
|
+
submitter: true
|
|
17960
|
+
}).partial(),
|
|
17961
|
+
manifest_version: external_exports.number().int().min(1).optional()
|
|
17962
|
+
});
|
|
17963
|
+
var AppStoreListingValidator = AppStoreListingFieldsValidator.extend({
|
|
17964
|
+
pending_update: PendingListingUpdateValidator.optional()
|
|
17965
|
+
});
|
|
17867
17966
|
var AppStoreListingCreateValidator = AppStoreListingValidator.omit({
|
|
17868
17967
|
listing_id: true,
|
|
17869
17968
|
app_listing_status: true,
|
|
17870
|
-
promotion_level: true
|
|
17969
|
+
promotion_level: true,
|
|
17970
|
+
pending_update: true
|
|
17871
17971
|
});
|
|
17872
17972
|
var AppStoreListingUpdateValidator = AppStoreListingValidator.partial().omit({
|
|
17873
17973
|
listing_id: true,
|
|
17874
17974
|
app_listing_status: true,
|
|
17875
|
-
promotion_level: true
|
|
17975
|
+
promotion_level: true,
|
|
17976
|
+
pending_update: true
|
|
17876
17977
|
});
|
|
17877
17978
|
var InstalledAppValidator = AppStoreListingValidator.extend({
|
|
17878
17979
|
installed_at: external_exports.string()
|
|
@@ -17887,12 +17988,87 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
17887
17988
|
templateAlias: external_exports.string().min(1).max(50).regex(/^[a-z0-9-]+$/),
|
|
17888
17989
|
boostUri: external_exports.string()
|
|
17889
17990
|
});
|
|
17890
|
-
var
|
|
17991
|
+
var InlineWalletCategoryValidator = external_exports.enum([
|
|
17992
|
+
"Achievement",
|
|
17993
|
+
"Skill",
|
|
17994
|
+
"ID",
|
|
17995
|
+
"Learning History",
|
|
17996
|
+
"Work History",
|
|
17997
|
+
"Social Badges",
|
|
17998
|
+
"Membership",
|
|
17999
|
+
"Accomplishment",
|
|
18000
|
+
"Experiences",
|
|
18001
|
+
"Accommodation",
|
|
18002
|
+
"Family"
|
|
18003
|
+
]);
|
|
18004
|
+
var InlineAlignmentValidator = external_exports.object({
|
|
18005
|
+
name: external_exports.string(),
|
|
18006
|
+
url: external_exports.string(),
|
|
18007
|
+
framework: external_exports.string().optional(),
|
|
18008
|
+
code: external_exports.string().optional()
|
|
18009
|
+
}).passthrough();
|
|
18010
|
+
var InlineEvidenceValidator = external_exports.object({
|
|
18011
|
+
id: external_exports.string().optional(),
|
|
18012
|
+
name: external_exports.string().optional(),
|
|
18013
|
+
narrative: external_exports.string().optional()
|
|
18014
|
+
}).passthrough();
|
|
18015
|
+
var InlineWalletSkillTagValidator = external_exports.object({
|
|
18016
|
+
frameworkId: external_exports.string(),
|
|
18017
|
+
id: external_exports.string(),
|
|
18018
|
+
proficiencyLevel: external_exports.string().optional()
|
|
18019
|
+
}).passthrough();
|
|
18020
|
+
var SimpleInlineCredentialTemplateValidator = external_exports.object({
|
|
18021
|
+
rawCredential: external_exports.undefined().optional(),
|
|
18022
|
+
name: external_exports.string(),
|
|
18023
|
+
description: external_exports.string().optional(),
|
|
18024
|
+
image: external_exports.string().optional(),
|
|
18025
|
+
issuerName: external_exports.string().optional(),
|
|
18026
|
+
achievementType: external_exports.string().optional(),
|
|
18027
|
+
category: InlineWalletCategoryValidator.optional(),
|
|
18028
|
+
criteria: external_exports.object({
|
|
18029
|
+
narrative: external_exports.string().optional(),
|
|
18030
|
+
url: external_exports.string().optional()
|
|
18031
|
+
}).passthrough().optional(),
|
|
18032
|
+
alignments: external_exports.array(InlineAlignmentValidator).optional(),
|
|
18033
|
+
tags: external_exports.array(external_exports.string()).optional(),
|
|
18034
|
+
activity: external_exports.object({
|
|
18035
|
+
startDate: external_exports.string().optional(),
|
|
18036
|
+
endDate: external_exports.string().optional()
|
|
18037
|
+
}).passthrough().optional(),
|
|
18038
|
+
credits: external_exports.object({
|
|
18039
|
+
earned: external_exports.union([external_exports.number(), external_exports.string()]).optional(),
|
|
18040
|
+
available: external_exports.union([external_exports.number(), external_exports.string()]).optional()
|
|
18041
|
+
}).passthrough().optional(),
|
|
18042
|
+
validUntil: external_exports.string().optional(),
|
|
18043
|
+
evidence: external_exports.array(InlineEvidenceValidator).optional(),
|
|
18044
|
+
walletSkills: external_exports.array(InlineWalletSkillTagValidator).optional()
|
|
18045
|
+
}).passthrough();
|
|
18046
|
+
var RawInlineCredentialTemplateValidator = external_exports.object({
|
|
18047
|
+
rawCredential: external_exports.record(external_exports.string(), external_exports.unknown()),
|
|
18048
|
+
category: InlineWalletCategoryValidator.optional(),
|
|
18049
|
+
walletSkills: external_exports.array(InlineWalletSkillTagValidator).optional()
|
|
18050
|
+
}).passthrough();
|
|
18051
|
+
var InlineCredentialTemplateValidator = external_exports.union([
|
|
18052
|
+
RawInlineCredentialTemplateValidator,
|
|
18053
|
+
SimpleInlineCredentialTemplateValidator
|
|
18054
|
+
]);
|
|
18055
|
+
var LegacySendCredentialEventValidator = external_exports.object({
|
|
17891
18056
|
type: external_exports.literal("send-credential"),
|
|
17892
18057
|
templateAlias: external_exports.string(),
|
|
17893
18058
|
templateData: external_exports.record(external_exports.string(), external_exports.unknown()).optional(),
|
|
17894
18059
|
preventDuplicateClaim: external_exports.boolean().optional()
|
|
17895
18060
|
});
|
|
18061
|
+
var InlineSendCredentialEventValidator = external_exports.object({
|
|
18062
|
+
type: external_exports.literal("send-credential"),
|
|
18063
|
+
alias: external_exports.string(),
|
|
18064
|
+
template: InlineCredentialTemplateValidator,
|
|
18065
|
+
templateData: external_exports.record(external_exports.string(), external_exports.unknown()).optional(),
|
|
18066
|
+
preventDuplicateClaim: external_exports.boolean().optional()
|
|
18067
|
+
});
|
|
18068
|
+
var SendCredentialEventValidator = external_exports.union([
|
|
18069
|
+
LegacySendCredentialEventValidator,
|
|
18070
|
+
InlineSendCredentialEventValidator
|
|
18071
|
+
]);
|
|
17896
18072
|
var CheckCredentialEventValidator = external_exports.object({
|
|
17897
18073
|
type: external_exports.literal("check-credential"),
|
|
17898
18074
|
templateAlias: external_exports.string().optional(),
|
|
@@ -17987,7 +18163,119 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
17987
18163
|
type: external_exports.literal("get-counters"),
|
|
17988
18164
|
keys: external_exports.array(counterKeyValidator).min(1).max(50).optional()
|
|
17989
18165
|
});
|
|
17990
|
-
var
|
|
18166
|
+
var ConsentRequestWalletCategoryValidator = external_exports.enum([
|
|
18167
|
+
"Achievement",
|
|
18168
|
+
"Skill",
|
|
18169
|
+
"ID",
|
|
18170
|
+
"Learning History",
|
|
18171
|
+
"Work History",
|
|
18172
|
+
"Social Badges",
|
|
18173
|
+
"Membership",
|
|
18174
|
+
"Accomplishment",
|
|
18175
|
+
"Experiences",
|
|
18176
|
+
"Accommodation",
|
|
18177
|
+
"Family"
|
|
18178
|
+
]);
|
|
18179
|
+
var ConsentRequestPersonalFieldValidator = external_exports.enum([
|
|
18180
|
+
"name",
|
|
18181
|
+
"email",
|
|
18182
|
+
"phone",
|
|
18183
|
+
"birthDate",
|
|
18184
|
+
"country",
|
|
18185
|
+
"avatar"
|
|
18186
|
+
]);
|
|
18187
|
+
var ConsentRequestValidator = external_exports.object({
|
|
18188
|
+
read: external_exports.object({
|
|
18189
|
+
credentialCategories: external_exports.array(ConsentRequestWalletCategoryValidator).optional(),
|
|
18190
|
+
personalFields: external_exports.array(ConsentRequestPersonalFieldValidator).optional()
|
|
18191
|
+
}).optional(),
|
|
18192
|
+
write: external_exports.object({
|
|
18193
|
+
credentialCategories: external_exports.array(ConsentRequestWalletCategoryValidator).optional()
|
|
18194
|
+
}).optional(),
|
|
18195
|
+
reason: external_exports.string().optional()
|
|
18196
|
+
});
|
|
18197
|
+
var NormalizedConsentScopesValidator = external_exports.object({
|
|
18198
|
+
read: external_exports.object({
|
|
18199
|
+
credentialCategories: external_exports.array(ConsentRequestWalletCategoryValidator).default([]),
|
|
18200
|
+
personalFields: external_exports.array(ConsentRequestPersonalFieldValidator).default([])
|
|
18201
|
+
}),
|
|
18202
|
+
write: external_exports.object({
|
|
18203
|
+
credentialCategories: external_exports.array(ConsentRequestWalletCategoryValidator).default([])
|
|
18204
|
+
})
|
|
18205
|
+
});
|
|
18206
|
+
var CapturedTemplateRecordValidator = external_exports.object({
|
|
18207
|
+
alias: external_exports.string(),
|
|
18208
|
+
template: InlineCredentialTemplateValidator,
|
|
18209
|
+
version: external_exports.number().int().min(1),
|
|
18210
|
+
lastUsedAt: external_exports.string()
|
|
18211
|
+
}).passthrough();
|
|
18212
|
+
var CapturedConsentRecordValidator = external_exports.object({
|
|
18213
|
+
scopes: NormalizedConsentScopesValidator,
|
|
18214
|
+
reason: external_exports.string().optional(),
|
|
18215
|
+
lastUsedAt: external_exports.string()
|
|
18216
|
+
}).passthrough();
|
|
18217
|
+
var AppManifestValidator = external_exports.object({
|
|
18218
|
+
manifestVersion: external_exports.literal(1),
|
|
18219
|
+
appUrl: external_exports.string(),
|
|
18220
|
+
appKey: external_exports.string().max(200).optional(),
|
|
18221
|
+
suggestedName: external_exports.string().optional(),
|
|
18222
|
+
suggestedIconUrl: external_exports.string().optional(),
|
|
18223
|
+
permissions: external_exports.array(external_exports.string()).default([]),
|
|
18224
|
+
templates: external_exports.array(CapturedTemplateRecordValidator).default([]),
|
|
18225
|
+
consentRequests: external_exports.array(CapturedConsentRecordValidator).default([]),
|
|
18226
|
+
usedConsentContract: external_exports.boolean().optional(),
|
|
18227
|
+
featuresLaunched: external_exports.array(external_exports.string()).default([]),
|
|
18228
|
+
counterKeys: external_exports.array(external_exports.string()).default([]),
|
|
18229
|
+
usedLearnerContext: external_exports.boolean(),
|
|
18230
|
+
usedNotifications: external_exports.boolean(),
|
|
18231
|
+
firstCapturedAt: external_exports.string(),
|
|
18232
|
+
lastUpdatedAt: external_exports.string()
|
|
18233
|
+
}).passthrough();
|
|
18234
|
+
var AppManifestVersionStatusValidator = external_exports.enum(["draft", "active", "superseded"]);
|
|
18235
|
+
var AppManifestVersionValidator = external_exports.object({
|
|
18236
|
+
id: external_exports.string(),
|
|
18237
|
+
version: external_exports.number().int().min(1),
|
|
18238
|
+
manifestHash: external_exports.string(),
|
|
18239
|
+
manifest: AppManifestValidator,
|
|
18240
|
+
status: AppManifestVersionStatusValidator,
|
|
18241
|
+
createdAt: external_exports.string(),
|
|
18242
|
+
activatedAt: external_exports.string().optional()
|
|
18243
|
+
});
|
|
18244
|
+
var AppManifestStringDiffValidator = external_exports.object({
|
|
18245
|
+
added: external_exports.array(external_exports.string()),
|
|
18246
|
+
removed: external_exports.array(external_exports.string()),
|
|
18247
|
+
changed: external_exports.array(external_exports.string())
|
|
18248
|
+
});
|
|
18249
|
+
var AppManifestTemplateRefValidator = external_exports.object({
|
|
18250
|
+
alias: external_exports.string(),
|
|
18251
|
+
version: external_exports.number().int().min(1)
|
|
18252
|
+
});
|
|
18253
|
+
var AppManifestTemplateChangeValidator = external_exports.object({
|
|
18254
|
+
alias: external_exports.string(),
|
|
18255
|
+
fromVersion: external_exports.number().int().min(1),
|
|
18256
|
+
toVersion: external_exports.number().int().min(1)
|
|
18257
|
+
});
|
|
18258
|
+
var AppManifestDiffValidator = external_exports.object({
|
|
18259
|
+
permissions: AppManifestStringDiffValidator,
|
|
18260
|
+
templates: external_exports.object({
|
|
18261
|
+
added: external_exports.array(AppManifestTemplateRefValidator),
|
|
18262
|
+
removed: external_exports.array(AppManifestTemplateRefValidator),
|
|
18263
|
+
changed: external_exports.array(AppManifestTemplateChangeValidator)
|
|
18264
|
+
}),
|
|
18265
|
+
consentScopes: AppManifestStringDiffValidator,
|
|
18266
|
+
featurePaths: AppManifestStringDiffValidator,
|
|
18267
|
+
counterKeys: AppManifestStringDiffValidator,
|
|
18268
|
+
requiresReview: external_exports.boolean()
|
|
18269
|
+
});
|
|
18270
|
+
var UpsertConsentContractEventValidator = external_exports.object({
|
|
18271
|
+
type: external_exports.literal("upsert-consent-contract"),
|
|
18272
|
+
scopes: ConsentRequestValidator
|
|
18273
|
+
});
|
|
18274
|
+
var UpsertConsentContractResponseValidator = external_exports.object({
|
|
18275
|
+
contractUri: external_exports.string(),
|
|
18276
|
+
created: external_exports.boolean()
|
|
18277
|
+
});
|
|
18278
|
+
var AppEventValidator = external_exports.union([
|
|
17991
18279
|
SendCredentialEventValidator,
|
|
17992
18280
|
CheckCredentialEventValidator,
|
|
17993
18281
|
CheckIssuanceStatusEventValidator,
|
|
@@ -17997,7 +18285,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
17997
18285
|
SendNotificationEventValidator,
|
|
17998
18286
|
IncrementCounterEventValidator,
|
|
17999
18287
|
GetCounterEventValidator,
|
|
18000
|
-
GetCountersEventValidator
|
|
18288
|
+
GetCountersEventValidator,
|
|
18289
|
+
UpsertConsentContractEventValidator
|
|
18001
18290
|
]);
|
|
18002
18291
|
var AppEventInputValidator = external_exports.object({
|
|
18003
18292
|
listingId: external_exports.string(),
|
|
@@ -18076,6 +18365,20 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
18076
18365
|
__name2(this, "AuthSessionError");
|
|
18077
18366
|
}
|
|
18078
18367
|
};
|
|
18368
|
+
var UnsupportedSignInOperationError = class extends Error {
|
|
18369
|
+
static {
|
|
18370
|
+
__name(this, "UnsupportedSignInOperationError");
|
|
18371
|
+
}
|
|
18372
|
+
constructor(operation, providerType) {
|
|
18373
|
+
super(`${operation} is not supported by ${providerType}`);
|
|
18374
|
+
this.operation = operation;
|
|
18375
|
+
this.providerType = providerType;
|
|
18376
|
+
this.name = "UnsupportedSignInOperationError";
|
|
18377
|
+
}
|
|
18378
|
+
static {
|
|
18379
|
+
__name2(this, "UnsupportedSignInOperationError");
|
|
18380
|
+
}
|
|
18381
|
+
};
|
|
18079
18382
|
var ESCROW_PIN_LOCKED_MESSAGE2 = "Too many incorrect PIN attempts. You can still recover by waiting.";
|
|
18080
18383
|
var ESCROW_PIN_UNAVAILABLE_MESSAGE2 = "PIN recovery is not available for this account.";
|
|
18081
18384
|
var ESCROW_PIN_MISMATCH_PATTERN2 = /^Incorrect PIN\. (\d+) attempts left\.$/;
|
|
@@ -18222,12 +18525,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
18222
18525
|
}
|
|
18223
18526
|
return table;
|
|
18224
18527
|
})();
|
|
18225
|
-
var encodeBase64Url = /* @__PURE__ */ __name2((
|
|
18528
|
+
var encodeBase64Url = /* @__PURE__ */ __name2((bytes2) => {
|
|
18226
18529
|
let output = "";
|
|
18227
|
-
for (let index = 0; index <
|
|
18228
|
-
const first =
|
|
18229
|
-
const second =
|
|
18230
|
-
const third =
|
|
18530
|
+
for (let index = 0; index < bytes2.length; index += 3) {
|
|
18531
|
+
const first = bytes2[index];
|
|
18532
|
+
const second = bytes2[index + 1];
|
|
18533
|
+
const third = bytes2[index + 2];
|
|
18231
18534
|
output += BASE64URL_ALPHABET[first >> 2];
|
|
18232
18535
|
output += BASE64URL_ALPHABET[(first & 3) << 4 | (second ?? 0) >> 4];
|
|
18233
18536
|
if (second === void 0) break;
|
|
@@ -18268,8 +18571,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
18268
18571
|
}, "isCanonicalBase64Url");
|
|
18269
18572
|
var decodedBase64UrlByteLength = /* @__PURE__ */ __name2((value) => decodeBase64Url(value)?.length ?? null, "decodedBase64UrlByteLength");
|
|
18270
18573
|
var utf8ByteLength = /* @__PURE__ */ __name2((value) => new TextEncoder().encode(value).length, "utf8ByteLength");
|
|
18271
|
-
var canonicalBase64Url = /* @__PURE__ */ __name2((
|
|
18272
|
-
message: `must be canonical base64url for exactly ${
|
|
18574
|
+
var canonicalBase64Url = /* @__PURE__ */ __name2((bytes2) => external_exports.string().refine((value) => isCanonicalBase64Url(value, bytes2), {
|
|
18575
|
+
message: `must be canonical base64url for exactly ${bytes2} bytes`
|
|
18273
18576
|
}), "canonicalBase64Url");
|
|
18274
18577
|
var ShareLinkIdValidator = canonicalBase64Url(SHARE_LINK_ID_BYTES);
|
|
18275
18578
|
var ShareContentKeyValidator = canonicalBase64Url(SHARE_CONTENT_KEY_BYTES);
|
|
@@ -18505,6 +18808,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
18505
18808
|
version: safeVersion,
|
|
18506
18809
|
contentVersion: safeVersion,
|
|
18507
18810
|
status: ShareLinkStatusValidator,
|
|
18811
|
+
attachmentId: external_exports.string().uuid().nullable().optional(),
|
|
18812
|
+
attachmentChunkCount: external_exports.number().int().min(1).max(16).nullable().optional(),
|
|
18508
18813
|
contentState: ShareContentStateValidator,
|
|
18509
18814
|
createdAt: external_exports.iso.datetime(),
|
|
18510
18815
|
updatedAt: external_exports.iso.datetime(),
|
|
@@ -18528,6 +18833,43 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
18528
18833
|
contentUrl: external_exports.string().optional()
|
|
18529
18834
|
});
|
|
18530
18835
|
var clientRequestId = external_exports.string().uuid();
|
|
18836
|
+
var ShareLinkAttachmentValidator = external_exports.object({
|
|
18837
|
+
id: external_exports.string().uuid(),
|
|
18838
|
+
chunkCount: external_exports.number().int().min(1).max(16)
|
|
18839
|
+
}).strict();
|
|
18840
|
+
var attachmentChunkKey = {
|
|
18841
|
+
id: ShareLinkIdValidator,
|
|
18842
|
+
contentVersion: safeVersion,
|
|
18843
|
+
attachmentId: external_exports.string().uuid(),
|
|
18844
|
+
chunkIndex: external_exports.number().int().min(0).max(15)
|
|
18845
|
+
};
|
|
18846
|
+
var ShareLinkAttachmentChunkEnvelopeValidator = ShareEnvelopeValidator.refine(
|
|
18847
|
+
(value) => (decodedBase64UrlByteLength(value.ct) ?? Infinity) <= 256 * 1024 + SHARE_TAG_BYTES
|
|
18848
|
+
);
|
|
18849
|
+
var PutShareLinkAttachmentChunkInputValidator = external_exports.object({
|
|
18850
|
+
...attachmentChunkKey,
|
|
18851
|
+
chunkCount: external_exports.number().int().min(1).max(16),
|
|
18852
|
+
envelope: ShareLinkAttachmentChunkEnvelopeValidator,
|
|
18853
|
+
ownerEncryptedRecovery: ShareOwnerRecoveryValidator
|
|
18854
|
+
}).strict().refine((value) => value.chunkIndex < value.chunkCount);
|
|
18855
|
+
var GetShareLinkAttachmentChunkInputValidator = external_exports.object({
|
|
18856
|
+
...attachmentChunkKey,
|
|
18857
|
+
passcode: external_exports.string().min(4).max(64).optional(),
|
|
18858
|
+
accessToken: external_exports.string().min(1).max(2048).optional()
|
|
18859
|
+
}).strict();
|
|
18860
|
+
var ShareLinkAttachmentChunkOutputValidator = external_exports.object({
|
|
18861
|
+
...attachmentChunkKey,
|
|
18862
|
+
envelope: ShareLinkAttachmentChunkEnvelopeValidator,
|
|
18863
|
+
accessToken: external_exports.string().min(1).max(2048).optional()
|
|
18864
|
+
}).strict();
|
|
18865
|
+
var DeleteShareLinkAttachmentChunksInputValidator = external_exports.object({
|
|
18866
|
+
id: ShareLinkIdValidator,
|
|
18867
|
+
contentVersion: safeVersion,
|
|
18868
|
+
attachmentId: external_exports.string().uuid(),
|
|
18869
|
+
chunkCount: external_exports.number().int().min(1).max(16)
|
|
18870
|
+
}).strict();
|
|
18871
|
+
var PutShareLinkAttachmentChunkOutputValidator = external_exports.object({ ok: external_exports.literal(true) }).strict();
|
|
18872
|
+
var DeleteShareLinkAttachmentChunksOutputValidator = external_exports.object({ ok: external_exports.boolean() }).strict();
|
|
18531
18873
|
var CreateShareLinkInputValidator = external_exports.object({
|
|
18532
18874
|
id: ShareLinkIdValidator,
|
|
18533
18875
|
clientRequestId,
|
|
@@ -18539,7 +18881,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
18539
18881
|
selectedCount: external_exports.number().int().min(1).max(MAX_SELECTED_CREDENTIALS),
|
|
18540
18882
|
contentVersion: external_exports.literal(1),
|
|
18541
18883
|
envelope: ShareEnvelopeValidator,
|
|
18542
|
-
ownerEncryptedRecovery: ShareOwnerRecoveryValidator
|
|
18884
|
+
ownerEncryptedRecovery: ShareOwnerRecoveryValidator,
|
|
18885
|
+
attachment: ShareLinkAttachmentValidator.optional()
|
|
18543
18886
|
}).strict();
|
|
18544
18887
|
var UpdateShareLinkInputValidator = external_exports.object({
|
|
18545
18888
|
id: ShareLinkIdValidator,
|
|
@@ -18554,7 +18897,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
18554
18897
|
contentVersion: safeVersion.optional(),
|
|
18555
18898
|
selectedCount: external_exports.number().int().min(1).max(MAX_SELECTED_CREDENTIALS).optional(),
|
|
18556
18899
|
envelope: ShareEnvelopeValidator.optional(),
|
|
18557
|
-
ownerEncryptedRecovery: ShareOwnerRecoveryValidator.optional()
|
|
18900
|
+
ownerEncryptedRecovery: ShareOwnerRecoveryValidator.optional(),
|
|
18901
|
+
attachment: ShareLinkAttachmentValidator.optional()
|
|
18558
18902
|
}).strict().superRefine((value, ctx) => {
|
|
18559
18903
|
const provided = [
|
|
18560
18904
|
value.contentVersion,
|
|
@@ -18568,6 +18912,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
18568
18912
|
message: "content replacement requires contentVersion, selectedCount, envelope and ownerEncryptedRecovery together"
|
|
18569
18913
|
});
|
|
18570
18914
|
}
|
|
18915
|
+
if (value.attachment !== void 0 && provided !== 4) {
|
|
18916
|
+
ctx.addIssue({ code: "custom", message: "attachment requires a content replacement" });
|
|
18917
|
+
}
|
|
18571
18918
|
});
|
|
18572
18919
|
var ShareLinkIdInputValidator = external_exports.object({ id: ShareLinkIdValidator }).strict();
|
|
18573
18920
|
var ShareLinkOperationKeyInputValidator = external_exports.object({ id: ShareLinkIdValidator, operationId: external_exports.string().uuid() }).strict();
|
|
@@ -18688,6 +19035,7 @@ __export(index_exports, {
|
|
|
18688
19035
|
EscrowPinUnavailableError: () => EscrowPinUnavailableError,
|
|
18689
19036
|
EscrowRequestError: () => EscrowRequestError,
|
|
18690
19037
|
IdentityRecoverySessionConsumedError: () => IdentityRecoverySessionConsumedError,
|
|
19038
|
+
NitroAttestationError: () => NitroAttestationError,
|
|
18691
19039
|
PIN_MAX_LENGTH: () => PIN_MAX_LENGTH,
|
|
18692
19040
|
PIN_MIN_LENGTH: () => PIN_MIN_LENGTH,
|
|
18693
19041
|
SSSApiClient: () => SSSApiClient,
|
|
@@ -18763,6 +19111,7 @@ __export(index_exports, {
|
|
|
18763
19111
|
validatePin: () => validatePin,
|
|
18764
19112
|
validateRecoveryPhrase: () => validateRecoveryPhrase,
|
|
18765
19113
|
verifyEnclaveAttestation: () => verifyEnclaveAttestation,
|
|
19114
|
+
verifyNitroAttestationDocument: () => verifyNitroAttestationDocument,
|
|
18766
19115
|
verifyStoredShares: () => verifyStoredShares
|
|
18767
19116
|
});
|
|
18768
19117
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -18924,33 +19273,33 @@ var DEFAULT_KDF_PARAMS = {
|
|
|
18924
19273
|
parallelism: ARGON2_PARALLELISM
|
|
18925
19274
|
};
|
|
18926
19275
|
function bufferToBase64(buf) {
|
|
18927
|
-
const
|
|
19276
|
+
const bytes2 = new Uint8Array(buf);
|
|
18928
19277
|
let binary = "";
|
|
18929
|
-
for (let i = 0; i <
|
|
18930
|
-
binary += String.fromCharCode(
|
|
19278
|
+
for (let i = 0; i < bytes2.byteLength; i++) {
|
|
19279
|
+
binary += String.fromCharCode(bytes2[i]);
|
|
18931
19280
|
}
|
|
18932
19281
|
return btoa(binary);
|
|
18933
19282
|
}
|
|
18934
19283
|
__name(bufferToBase64, "bufferToBase64");
|
|
18935
19284
|
function base64ToBuffer(b64) {
|
|
18936
19285
|
const binary = atob(b64);
|
|
18937
|
-
const
|
|
19286
|
+
const bytes2 = new Uint8Array(binary.length);
|
|
18938
19287
|
for (let i = 0; i < binary.length; i++) {
|
|
18939
|
-
|
|
19288
|
+
bytes2[i] = binary.charCodeAt(i);
|
|
18940
19289
|
}
|
|
18941
|
-
return
|
|
19290
|
+
return bytes2;
|
|
18942
19291
|
}
|
|
18943
19292
|
__name(base64ToBuffer, "base64ToBuffer");
|
|
18944
|
-
function hexToBytes(
|
|
18945
|
-
const
|
|
18946
|
-
for (let i = 0; i <
|
|
18947
|
-
|
|
19293
|
+
function hexToBytes(hex2) {
|
|
19294
|
+
const bytes2 = new Uint8Array(hex2.length / 2);
|
|
19295
|
+
for (let i = 0; i < hex2.length; i += 2) {
|
|
19296
|
+
bytes2[i / 2] = parseInt(hex2.slice(i, i + 2), 16);
|
|
18948
19297
|
}
|
|
18949
|
-
return
|
|
19298
|
+
return bytes2;
|
|
18950
19299
|
}
|
|
18951
19300
|
__name(hexToBytes, "hexToBytes");
|
|
18952
|
-
function bytesToHex(
|
|
18953
|
-
return Array.from(
|
|
19301
|
+
function bytesToHex(bytes2) {
|
|
19302
|
+
return Array.from(bytes2).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
18954
19303
|
}
|
|
18955
19304
|
__name(bytesToHex, "bytesToHex");
|
|
18956
19305
|
async function deriveKeyFromPassword(password, salt, params = DEFAULT_KDF_PARAMS) {
|
|
@@ -19117,21 +19466,21 @@ async function getOrCreateMasterKey() {
|
|
|
19117
19466
|
}
|
|
19118
19467
|
__name(getOrCreateMasterKey, "getOrCreateMasterKey");
|
|
19119
19468
|
function bufferToBase642(buf) {
|
|
19120
|
-
const
|
|
19469
|
+
const bytes2 = new Uint8Array(buf);
|
|
19121
19470
|
let binary = "";
|
|
19122
|
-
for (let i = 0; i <
|
|
19123
|
-
binary += String.fromCharCode(
|
|
19471
|
+
for (let i = 0; i < bytes2.byteLength; i++) {
|
|
19472
|
+
binary += String.fromCharCode(bytes2[i]);
|
|
19124
19473
|
}
|
|
19125
19474
|
return btoa(binary);
|
|
19126
19475
|
}
|
|
19127
19476
|
__name(bufferToBase642, "bufferToBase64");
|
|
19128
19477
|
function base64ToBuffer2(b64) {
|
|
19129
19478
|
const binary = atob(b64);
|
|
19130
|
-
const
|
|
19479
|
+
const bytes2 = new Uint8Array(binary.length);
|
|
19131
19480
|
for (let i = 0; i < binary.length; i++) {
|
|
19132
|
-
|
|
19481
|
+
bytes2[i] = binary.charCodeAt(i);
|
|
19133
19482
|
}
|
|
19134
|
-
return
|
|
19483
|
+
return bytes2.buffer;
|
|
19135
19484
|
}
|
|
19136
19485
|
__name(base64ToBuffer2, "base64ToBuffer");
|
|
19137
19486
|
async function encryptShare(share, id) {
|
|
@@ -19539,16 +19888,16 @@ async function getWordlist() {
|
|
|
19539
19888
|
return wordlistPromise;
|
|
19540
19889
|
}
|
|
19541
19890
|
__name(getWordlist, "getWordlist");
|
|
19542
|
-
function bytesToBits(
|
|
19543
|
-
return Array.from(
|
|
19891
|
+
function bytesToBits(bytes2) {
|
|
19892
|
+
return Array.from(bytes2).map((b) => b.toString(2).padStart(8, "0")).join("");
|
|
19544
19893
|
}
|
|
19545
19894
|
__name(bytesToBits, "bytesToBits");
|
|
19546
19895
|
function bitsToBytes(bits) {
|
|
19547
|
-
const
|
|
19548
|
-
for (let i = 0; i <
|
|
19549
|
-
|
|
19896
|
+
const bytes2 = new Uint8Array(Math.ceil(bits.length / 8));
|
|
19897
|
+
for (let i = 0; i < bytes2.length; i++) {
|
|
19898
|
+
bytes2[i] = parseInt(bits.slice(i * 8, (i + 1) * 8).padEnd(8, "0"), 2);
|
|
19550
19899
|
}
|
|
19551
|
-
return
|
|
19900
|
+
return bytes2;
|
|
19552
19901
|
}
|
|
19553
19902
|
__name(bitsToBytes, "bitsToBytes");
|
|
19554
19903
|
async function computeChecksum(data) {
|
|
@@ -19586,12 +19935,12 @@ async function recoveryPhraseToShare(phrase) {
|
|
|
19586
19935
|
bits += index.toString(2).padStart(11, "0");
|
|
19587
19936
|
}
|
|
19588
19937
|
let dataByteCount = 0;
|
|
19589
|
-
for (let
|
|
19590
|
-
const checksumBits2 = Math.floor(
|
|
19591
|
-
const totalBits =
|
|
19938
|
+
for (let bytes2 = 1; bytes2 <= 64; bytes2++) {
|
|
19939
|
+
const checksumBits2 = Math.floor(bytes2 / 4);
|
|
19940
|
+
const totalBits = bytes2 * 8 + checksumBits2;
|
|
19592
19941
|
const wordsNeeded = Math.ceil(totalBits / 11);
|
|
19593
19942
|
if (wordsNeeded === words.length) {
|
|
19594
|
-
dataByteCount =
|
|
19943
|
+
dataByteCount = bytes2;
|
|
19595
19944
|
} else if (wordsNeeded > words.length) {
|
|
19596
19945
|
break;
|
|
19597
19946
|
}
|
|
@@ -19885,9 +20234,9 @@ __name(createSSSKeyManager, "createSSSKeyManager");
|
|
|
19885
20234
|
var EMAIL_RELAY_ENVELOPE_VERSION = 1;
|
|
19886
20235
|
var EMAIL_RELAY_ALGORITHM = "P-256-HKDF-SHA256-AES-256-GCM";
|
|
19887
20236
|
var encodeUtf8 = /* @__PURE__ */ __name((value) => {
|
|
19888
|
-
const
|
|
19889
|
-
const copy = new Uint8Array(new ArrayBuffer(
|
|
19890
|
-
copy.set(
|
|
20237
|
+
const bytes2 = new TextEncoder().encode(value);
|
|
20238
|
+
const copy = new Uint8Array(new ArrayBuffer(bytes2.byteLength));
|
|
20239
|
+
copy.set(bytes2);
|
|
19891
20240
|
return copy;
|
|
19892
20241
|
}, "encodeUtf8");
|
|
19893
20242
|
var EMAIL_RELAY_INFO = encodeUtf8("learncard-email-relay-v1");
|
|
@@ -20082,9 +20431,9 @@ var ESCROW_BLOB_INFO = "learncard-escrow-blob-v1";
|
|
|
20082
20431
|
var ESCROW_RELEASE_INFO = "learncard-escrow-release-v1";
|
|
20083
20432
|
var ESCROW_CLIENT_KEY_ID = "client";
|
|
20084
20433
|
var encodeUtf82 = /* @__PURE__ */ __name((value) => {
|
|
20085
|
-
const
|
|
20086
|
-
const copy = new Uint8Array(new ArrayBuffer(
|
|
20087
|
-
copy.set(
|
|
20434
|
+
const bytes2 = new TextEncoder().encode(value);
|
|
20435
|
+
const copy = new Uint8Array(new ArrayBuffer(bytes2.byteLength));
|
|
20436
|
+
copy.set(bytes2);
|
|
20088
20437
|
return copy;
|
|
20089
20438
|
}, "encodeUtf8");
|
|
20090
20439
|
var isRecord2 = /* @__PURE__ */ __name((value) => typeof value === "object" && value !== null && !Array.isArray(value), "isRecord");
|
|
@@ -20273,196 +20622,2494 @@ var openEscrowRelease = /* @__PURE__ */ __name(async (envelope, clientEphemeralP
|
|
|
20273
20622
|
await decryptFromEnvelope(envelope, clientEphemeralPrivateKeyPkcs8B64, ESCROW_RELEASE_INFO)
|
|
20274
20623
|
), "openEscrowRelease");
|
|
20275
20624
|
|
|
20276
|
-
// src/escrow-attestation.ts
|
|
20277
|
-
var
|
|
20278
|
-
|
|
20279
|
-
|
|
20280
|
-
|
|
20281
|
-
|
|
20625
|
+
// src/escrow-nitro-attestation.ts
|
|
20626
|
+
var import_reflect_metadata = require("reflect-metadata");
|
|
20627
|
+
|
|
20628
|
+
// ../../node_modules/cborg/lib/is.js
|
|
20629
|
+
var objectTypeNames = [
|
|
20630
|
+
"Object",
|
|
20631
|
+
// for Object.create(null) and other non-plain objects
|
|
20632
|
+
"RegExp",
|
|
20633
|
+
"Date",
|
|
20634
|
+
"Error",
|
|
20635
|
+
"Map",
|
|
20636
|
+
"Set",
|
|
20637
|
+
"WeakMap",
|
|
20638
|
+
"WeakSet",
|
|
20639
|
+
"ArrayBuffer",
|
|
20640
|
+
"SharedArrayBuffer",
|
|
20641
|
+
"DataView",
|
|
20642
|
+
"Promise",
|
|
20643
|
+
"URL",
|
|
20644
|
+
"HTMLElement",
|
|
20645
|
+
"Int8Array",
|
|
20646
|
+
"Uint8ClampedArray",
|
|
20647
|
+
"Int16Array",
|
|
20648
|
+
"Uint16Array",
|
|
20649
|
+
"Int32Array",
|
|
20650
|
+
"Uint32Array",
|
|
20651
|
+
"Float32Array",
|
|
20652
|
+
"Float64Array",
|
|
20653
|
+
"BigInt64Array",
|
|
20654
|
+
"BigUint64Array",
|
|
20655
|
+
"Tagged"
|
|
20656
|
+
];
|
|
20657
|
+
function is(value) {
|
|
20658
|
+
if (value === null) {
|
|
20659
|
+
return "null";
|
|
20282
20660
|
}
|
|
20283
|
-
|
|
20284
|
-
|
|
20285
|
-
var verifyEnclaveAttestation = /* @__PURE__ */ __name(async (attestation, policy) => {
|
|
20286
|
-
const fields = ["mode", "keyId", "publicKey", "measurements", "document", "issuedAt"];
|
|
20287
|
-
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(
|
|
20288
|
-
([key, value]) => !["imageSha384", "pcr0", "pcr1", "pcr2"].includes(key) || typeof value !== "string" || !value || value.length > 1024
|
|
20289
|
-
) || typeof attestation.document !== "string" || !attestation.document || attestation.document.length > 65536 || typeof attestation.issuedAt !== "string" || !Number.isFinite(Date.parse(attestation.issuedAt))) {
|
|
20290
|
-
throw new Error("Invalid escrow attestation");
|
|
20661
|
+
if (value === void 0) {
|
|
20662
|
+
return "undefined";
|
|
20291
20663
|
}
|
|
20292
|
-
|
|
20293
|
-
|
|
20294
|
-
"spki",
|
|
20295
|
-
base64ToBuffer(publicKey),
|
|
20296
|
-
{ name: "ECDH", namedCurve: "P-256" },
|
|
20297
|
-
false,
|
|
20298
|
-
[]
|
|
20299
|
-
);
|
|
20300
|
-
if (policy.mode === "nitro") {
|
|
20301
|
-
throw new Error("Nitro attestation verification is not implemented yet");
|
|
20664
|
+
if (value === true || value === false) {
|
|
20665
|
+
return "boolean";
|
|
20302
20666
|
}
|
|
20303
|
-
|
|
20304
|
-
if (
|
|
20305
|
-
|
|
20667
|
+
const typeOf = typeof value;
|
|
20668
|
+
if (typeOf === "string" || typeOf === "number" || typeOf === "bigint" || typeOf === "symbol") {
|
|
20669
|
+
return typeOf;
|
|
20306
20670
|
}
|
|
20307
|
-
|
|
20308
|
-
|
|
20309
|
-
|
|
20310
|
-
// src/types.ts
|
|
20311
|
-
var import_types = __toESM(require_dist());
|
|
20312
|
-
var EscrowPinUnavailableError = class extends Error {
|
|
20313
|
-
static {
|
|
20314
|
-
__name(this, "EscrowPinUnavailableError");
|
|
20671
|
+
if (typeOf === "function") {
|
|
20672
|
+
return "Function";
|
|
20315
20673
|
}
|
|
20316
|
-
|
|
20317
|
-
|
|
20318
|
-
this.name = "EscrowPinUnavailableError";
|
|
20674
|
+
if (Array.isArray(value)) {
|
|
20675
|
+
return "Array";
|
|
20319
20676
|
}
|
|
20320
|
-
|
|
20321
|
-
|
|
20322
|
-
constructor(attemptsRemaining) {
|
|
20323
|
-
super("Incorrect PIN.");
|
|
20324
|
-
this.attemptsRemaining = attemptsRemaining;
|
|
20325
|
-
this.name = "EscrowPinMismatchError";
|
|
20677
|
+
if (value instanceof Uint8Array) {
|
|
20678
|
+
return "Uint8Array";
|
|
20326
20679
|
}
|
|
20327
|
-
|
|
20328
|
-
|
|
20680
|
+
if (value.constructor === Object) {
|
|
20681
|
+
return "Object";
|
|
20329
20682
|
}
|
|
20330
|
-
|
|
20331
|
-
|
|
20683
|
+
const objectType = getObjectType(value);
|
|
20684
|
+
if (objectType) {
|
|
20685
|
+
return objectType;
|
|
20686
|
+
}
|
|
20687
|
+
return "Object";
|
|
20688
|
+
}
|
|
20689
|
+
__name(is, "is");
|
|
20690
|
+
function getObjectType(value) {
|
|
20691
|
+
const objectTypeName = Object.prototype.toString.call(value).slice(8, -1);
|
|
20692
|
+
if (objectTypeNames.includes(objectTypeName)) {
|
|
20693
|
+
return objectTypeName;
|
|
20694
|
+
}
|
|
20695
|
+
return void 0;
|
|
20696
|
+
}
|
|
20697
|
+
__name(getObjectType, "getObjectType");
|
|
20698
|
+
|
|
20699
|
+
// ../../node_modules/cborg/lib/token.js
|
|
20700
|
+
var Type = class {
|
|
20332
20701
|
static {
|
|
20333
|
-
__name(this, "
|
|
20702
|
+
__name(this, "Type");
|
|
20334
20703
|
}
|
|
20335
|
-
|
|
20336
|
-
|
|
20337
|
-
|
|
20704
|
+
/**
|
|
20705
|
+
* @param {number} major
|
|
20706
|
+
* @param {string} name
|
|
20707
|
+
* @param {boolean} terminal
|
|
20708
|
+
*/
|
|
20709
|
+
constructor(major, name, terminal) {
|
|
20710
|
+
this.major = major;
|
|
20711
|
+
this.majorEncoded = major << 5;
|
|
20712
|
+
this.name = name;
|
|
20713
|
+
this.terminal = terminal;
|
|
20338
20714
|
}
|
|
20339
|
-
|
|
20340
|
-
|
|
20341
|
-
constructor(retryAfter) {
|
|
20342
|
-
super("A recovery request was started recently. Please wait before restarting.");
|
|
20343
|
-
this.retryAfter = retryAfter;
|
|
20344
|
-
this.name = "EscrowHoldRestartThrottledError";
|
|
20715
|
+
toString() {
|
|
20716
|
+
return `Type[${this.major}].${this.name}`;
|
|
20345
20717
|
}
|
|
20346
|
-
|
|
20347
|
-
|
|
20718
|
+
/**
|
|
20719
|
+
* @param {Type} typ
|
|
20720
|
+
* @returns {number}
|
|
20721
|
+
*/
|
|
20722
|
+
compare(typ) {
|
|
20723
|
+
return this.major < typ.major ? -1 : this.major > typ.major ? 1 : 0;
|
|
20724
|
+
}
|
|
20725
|
+
/**
|
|
20726
|
+
* Check equality between two Type instances. Safe to use across different
|
|
20727
|
+
* copies of the Type class (e.g., when bundlers duplicate the module).
|
|
20728
|
+
* (major, name) uniquely identifies a Type; terminal is implied by these.
|
|
20729
|
+
* @param {Type} a
|
|
20730
|
+
* @param {Type} b
|
|
20731
|
+
* @returns {boolean}
|
|
20732
|
+
*/
|
|
20733
|
+
static equals(a, b) {
|
|
20734
|
+
return a === b || a.major === b.major && a.name === b.name;
|
|
20348
20735
|
}
|
|
20349
20736
|
};
|
|
20350
|
-
|
|
20737
|
+
Type.uint = new Type(0, "uint", true);
|
|
20738
|
+
Type.negint = new Type(1, "negint", true);
|
|
20739
|
+
Type.bytes = new Type(2, "bytes", true);
|
|
20740
|
+
Type.string = new Type(3, "string", true);
|
|
20741
|
+
Type.array = new Type(4, "array", false);
|
|
20742
|
+
Type.map = new Type(5, "map", false);
|
|
20743
|
+
Type.tag = new Type(6, "tag", false);
|
|
20744
|
+
Type.float = new Type(7, "float", true);
|
|
20745
|
+
Type.false = new Type(7, "false", true);
|
|
20746
|
+
Type.true = new Type(7, "true", true);
|
|
20747
|
+
Type.null = new Type(7, "null", true);
|
|
20748
|
+
Type.undefined = new Type(7, "undefined", true);
|
|
20749
|
+
Type.break = new Type(7, "break", true);
|
|
20750
|
+
var Token = class {
|
|
20351
20751
|
static {
|
|
20352
|
-
__name(this, "
|
|
20752
|
+
__name(this, "Token");
|
|
20353
20753
|
}
|
|
20354
|
-
|
|
20355
|
-
|
|
20356
|
-
|
|
20754
|
+
/**
|
|
20755
|
+
* @param {Type} type
|
|
20756
|
+
* @param {any} [value]
|
|
20757
|
+
* @param {number} [encodedLength]
|
|
20758
|
+
*/
|
|
20759
|
+
constructor(type, value, encodedLength) {
|
|
20760
|
+
this.type = type;
|
|
20761
|
+
this.value = value;
|
|
20762
|
+
this.encodedLength = encodedLength;
|
|
20763
|
+
this.encodedBytes = void 0;
|
|
20764
|
+
this.byteValue = void 0;
|
|
20765
|
+
}
|
|
20766
|
+
toString() {
|
|
20767
|
+
return `Token[${this.type}].${this.value}`;
|
|
20357
20768
|
}
|
|
20358
20769
|
};
|
|
20359
20770
|
|
|
20360
|
-
//
|
|
20361
|
-
var
|
|
20362
|
-
|
|
20363
|
-
|
|
20364
|
-
|
|
20365
|
-
|
|
20366
|
-
|
|
20367
|
-
|
|
20368
|
-
|
|
20369
|
-
|
|
20370
|
-
|
|
20371
|
-
|
|
20372
|
-
|
|
20373
|
-
"123321"
|
|
20374
|
-
]);
|
|
20375
|
-
var normalizePin = /* @__PURE__ */ __name((raw) => raw.trim().normalize("NFKD").replace(/\D/g, ""), "normalizePin");
|
|
20376
|
-
var validatePin = /* @__PURE__ */ __name((pin) => {
|
|
20377
|
-
const normalized = normalizePin(pin);
|
|
20378
|
-
if (normalized.length < PIN_MIN_LENGTH || normalized.length > PIN_MAX_LENGTH) {
|
|
20379
|
-
return { ok: false, reason: "length" };
|
|
20771
|
+
// ../../node_modules/cborg/lib/byte-utils.js
|
|
20772
|
+
var useBuffer = globalThis.process && // @ts-ignore
|
|
20773
|
+
!globalThis.process.browser && // @ts-ignore
|
|
20774
|
+
globalThis.Buffer && // @ts-ignore
|
|
20775
|
+
typeof globalThis.Buffer.isBuffer === "function";
|
|
20776
|
+
var textEncoder = new TextEncoder();
|
|
20777
|
+
function isBuffer(buf) {
|
|
20778
|
+
return useBuffer && globalThis.Buffer.isBuffer(buf);
|
|
20779
|
+
}
|
|
20780
|
+
__name(isBuffer, "isBuffer");
|
|
20781
|
+
function asU8A(buf) {
|
|
20782
|
+
if (!(buf instanceof Uint8Array)) {
|
|
20783
|
+
return Uint8Array.from(buf);
|
|
20380
20784
|
}
|
|
20381
|
-
|
|
20382
|
-
|
|
20785
|
+
return isBuffer(buf) ? new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength) : buf;
|
|
20786
|
+
}
|
|
20787
|
+
__name(asU8A, "asU8A");
|
|
20788
|
+
var FROM_STRING_THRESHOLD_BUFFER = 24;
|
|
20789
|
+
var FROM_STRING_THRESHOLD_TEXTENCODER = 200;
|
|
20790
|
+
var fromString = useBuffer ? (
|
|
20791
|
+
// eslint-disable-line operator-linebreak
|
|
20792
|
+
/**
|
|
20793
|
+
* @param {string} string
|
|
20794
|
+
*/
|
|
20795
|
+
(string) => {
|
|
20796
|
+
return string.length >= FROM_STRING_THRESHOLD_BUFFER ? (
|
|
20797
|
+
// eslint-disable-line operator-linebreak
|
|
20798
|
+
// @ts-ignore
|
|
20799
|
+
globalThis.Buffer.from(string)
|
|
20800
|
+
) : utf8ToBytes(string);
|
|
20383
20801
|
}
|
|
20384
|
-
|
|
20385
|
-
|
|
20386
|
-
|
|
20387
|
-
|
|
20388
|
-
|
|
20389
|
-
|
|
20390
|
-
|
|
20391
|
-
try {
|
|
20392
|
-
return bytesToHex(key);
|
|
20393
|
-
} finally {
|
|
20394
|
-
key.fill(0);
|
|
20802
|
+
) : (
|
|
20803
|
+
// eslint-disable-line operator-linebreak
|
|
20804
|
+
/**
|
|
20805
|
+
* @param {string} string
|
|
20806
|
+
*/
|
|
20807
|
+
(string) => {
|
|
20808
|
+
return string.length >= FROM_STRING_THRESHOLD_TEXTENCODER ? textEncoder.encode(string) : utf8ToBytes(string);
|
|
20395
20809
|
}
|
|
20396
|
-
|
|
20397
|
-
var
|
|
20398
|
-
|
|
20399
|
-
|
|
20810
|
+
);
|
|
20811
|
+
var fromArray = /* @__PURE__ */ __name((arr) => {
|
|
20812
|
+
return Uint8Array.from(arr);
|
|
20813
|
+
}, "fromArray");
|
|
20814
|
+
var slice = useBuffer ? (
|
|
20815
|
+
// eslint-disable-line operator-linebreak
|
|
20816
|
+
/**
|
|
20817
|
+
* @param {Uint8Array} bytes
|
|
20818
|
+
* @param {number} start
|
|
20819
|
+
* @param {number} end
|
|
20820
|
+
*/
|
|
20821
|
+
// Buffer.slice() returns a view, not a copy, so we need special handling
|
|
20822
|
+
(bytes2, start, end) => {
|
|
20823
|
+
if (isBuffer(bytes2)) {
|
|
20824
|
+
return new Uint8Array(bytes2.subarray(start, end));
|
|
20825
|
+
}
|
|
20826
|
+
return bytes2.slice(start, end);
|
|
20400
20827
|
}
|
|
20401
|
-
|
|
20402
|
-
|
|
20403
|
-
|
|
20404
|
-
|
|
20405
|
-
|
|
20828
|
+
) : (
|
|
20829
|
+
// eslint-disable-line operator-linebreak
|
|
20830
|
+
/**
|
|
20831
|
+
* @param {Uint8Array} bytes
|
|
20832
|
+
* @param {number} start
|
|
20833
|
+
* @param {number} end
|
|
20834
|
+
*/
|
|
20835
|
+
(bytes2, start, end) => {
|
|
20836
|
+
return bytes2.slice(start, end);
|
|
20406
20837
|
}
|
|
20407
|
-
|
|
20408
|
-
|
|
20409
|
-
|
|
20410
|
-
|
|
20411
|
-
|
|
20412
|
-
|
|
20413
|
-
|
|
20414
|
-
|
|
20415
|
-
|
|
20416
|
-
|
|
20417
|
-
|
|
20838
|
+
);
|
|
20839
|
+
var concat = useBuffer ? (
|
|
20840
|
+
// eslint-disable-line operator-linebreak
|
|
20841
|
+
/**
|
|
20842
|
+
* @param {ByteView[]} chunks
|
|
20843
|
+
* @param {number} length
|
|
20844
|
+
* @returns {AllocatedByteView}
|
|
20845
|
+
*/
|
|
20846
|
+
(chunks, length) => {
|
|
20847
|
+
chunks = chunks.map((c) => c instanceof Uint8Array ? c : (
|
|
20848
|
+
// eslint-disable-line operator-linebreak
|
|
20849
|
+
// @ts-ignore
|
|
20850
|
+
globalThis.Buffer.from(c)
|
|
20851
|
+
));
|
|
20852
|
+
return (
|
|
20853
|
+
/** @type {AllocatedByteView} */
|
|
20854
|
+
asU8A(globalThis.Buffer.concat(chunks, length))
|
|
20855
|
+
);
|
|
20418
20856
|
}
|
|
20419
|
-
|
|
20420
|
-
|
|
20857
|
+
) : (
|
|
20858
|
+
// eslint-disable-line operator-linebreak
|
|
20859
|
+
/**
|
|
20860
|
+
* @param {ByteView[]} chunks
|
|
20861
|
+
* @param {number} length
|
|
20862
|
+
* @returns {AllocatedByteView}
|
|
20863
|
+
*/
|
|
20864
|
+
(chunks, length) => {
|
|
20865
|
+
const out = new Uint8Array(length);
|
|
20866
|
+
let off = 0;
|
|
20867
|
+
for (let b of chunks) {
|
|
20868
|
+
if (off + b.length > out.length) {
|
|
20869
|
+
b = b.subarray(0, out.length - off);
|
|
20870
|
+
}
|
|
20871
|
+
out.set(b, off);
|
|
20872
|
+
off += b.length;
|
|
20873
|
+
}
|
|
20874
|
+
return out;
|
|
20421
20875
|
}
|
|
20422
|
-
|
|
20423
|
-
var
|
|
20424
|
-
|
|
20425
|
-
|
|
20426
|
-
|
|
20427
|
-
|
|
20428
|
-
|
|
20429
|
-
|
|
20876
|
+
);
|
|
20877
|
+
var alloc = useBuffer ? (
|
|
20878
|
+
// eslint-disable-line operator-linebreak
|
|
20879
|
+
/**
|
|
20880
|
+
* @param {number} size
|
|
20881
|
+
* @returns {AllocatedByteView}
|
|
20882
|
+
*/
|
|
20883
|
+
(size) => {
|
|
20884
|
+
return globalThis.Buffer.allocUnsafe(size);
|
|
20430
20885
|
}
|
|
20431
|
-
|
|
20432
|
-
|
|
20886
|
+
) : (
|
|
20887
|
+
// eslint-disable-line operator-linebreak
|
|
20888
|
+
/**
|
|
20889
|
+
* @param {number} size
|
|
20890
|
+
* @returns {AllocatedByteView}
|
|
20891
|
+
*/
|
|
20892
|
+
(size) => {
|
|
20893
|
+
return new Uint8Array(size);
|
|
20433
20894
|
}
|
|
20434
|
-
|
|
20435
|
-
|
|
20436
|
-
|
|
20437
|
-
|
|
20895
|
+
);
|
|
20896
|
+
function compare(b1, b2) {
|
|
20897
|
+
if (isBuffer(b1) && isBuffer(b2)) {
|
|
20898
|
+
return b1.compare(b2);
|
|
20438
20899
|
}
|
|
20439
|
-
|
|
20440
|
-
|
|
20441
|
-
|
|
20900
|
+
for (let i = 0; i < b1.length; i++) {
|
|
20901
|
+
if (b1[i] === b2[i]) {
|
|
20902
|
+
continue;
|
|
20903
|
+
}
|
|
20904
|
+
return b1[i] < b2[i] ? -1 : 1;
|
|
20442
20905
|
}
|
|
20443
|
-
|
|
20444
|
-
|
|
20445
|
-
|
|
20446
|
-
|
|
20447
|
-
|
|
20448
|
-
|
|
20449
|
-
|
|
20450
|
-
|
|
20451
|
-
|
|
20452
|
-
|
|
20453
|
-
|
|
20454
|
-
|
|
20455
|
-
|
|
20456
|
-
if (
|
|
20457
|
-
|
|
20458
|
-
|
|
20459
|
-
|
|
20460
|
-
|
|
20461
|
-
|
|
20462
|
-
|
|
20906
|
+
return 0;
|
|
20907
|
+
}
|
|
20908
|
+
__name(compare, "compare");
|
|
20909
|
+
function utf8ToBytes(str) {
|
|
20910
|
+
const out = [];
|
|
20911
|
+
let p = 0;
|
|
20912
|
+
for (let i = 0; i < str.length; i++) {
|
|
20913
|
+
let c = str.charCodeAt(i);
|
|
20914
|
+
if (c < 128) {
|
|
20915
|
+
out[p++] = c;
|
|
20916
|
+
} else if (c < 2048) {
|
|
20917
|
+
out[p++] = c >> 6 | 192;
|
|
20918
|
+
out[p++] = c & 63 | 128;
|
|
20919
|
+
} else if ((c & 64512) === 55296 && i + 1 < str.length && (str.charCodeAt(i + 1) & 64512) === 56320) {
|
|
20920
|
+
c = 65536 + ((c & 1023) << 10) + (str.charCodeAt(++i) & 1023);
|
|
20921
|
+
out[p++] = c >> 18 | 240;
|
|
20922
|
+
out[p++] = c >> 12 & 63 | 128;
|
|
20923
|
+
out[p++] = c >> 6 & 63 | 128;
|
|
20924
|
+
out[p++] = c & 63 | 128;
|
|
20925
|
+
} else {
|
|
20926
|
+
if (c >= 55296 && c <= 57343) {
|
|
20927
|
+
c = 65533;
|
|
20928
|
+
}
|
|
20929
|
+
out[p++] = c >> 12 | 224;
|
|
20930
|
+
out[p++] = c >> 6 & 63 | 128;
|
|
20931
|
+
out[p++] = c & 63 | 128;
|
|
20463
20932
|
}
|
|
20464
20933
|
}
|
|
20465
|
-
return
|
|
20934
|
+
return out;
|
|
20935
|
+
}
|
|
20936
|
+
__name(utf8ToBytes, "utf8ToBytes");
|
|
20937
|
+
|
|
20938
|
+
// ../../node_modules/cborg/lib/bl.js
|
|
20939
|
+
var defaultChunkSize = 256;
|
|
20940
|
+
var Bl = class {
|
|
20941
|
+
static {
|
|
20942
|
+
__name(this, "Bl");
|
|
20943
|
+
}
|
|
20944
|
+
/**
|
|
20945
|
+
* @param {number} [chunkSize]
|
|
20946
|
+
*/
|
|
20947
|
+
constructor(chunkSize = defaultChunkSize) {
|
|
20948
|
+
this.chunkSize = chunkSize;
|
|
20949
|
+
this.cursor = 0;
|
|
20950
|
+
this.maxCursor = -1;
|
|
20951
|
+
this.chunks = [];
|
|
20952
|
+
this._initReuseChunk = null;
|
|
20953
|
+
}
|
|
20954
|
+
reset() {
|
|
20955
|
+
this.cursor = 0;
|
|
20956
|
+
this.maxCursor = -1;
|
|
20957
|
+
if (this.chunks.length) {
|
|
20958
|
+
this.chunks = [];
|
|
20959
|
+
}
|
|
20960
|
+
if (this._initReuseChunk !== null) {
|
|
20961
|
+
this.chunks.push(this._initReuseChunk);
|
|
20962
|
+
this.maxCursor = this._initReuseChunk.length - 1;
|
|
20963
|
+
}
|
|
20964
|
+
}
|
|
20965
|
+
/**
|
|
20966
|
+
* @param {number} byte
|
|
20967
|
+
*/
|
|
20968
|
+
pushByte(byte) {
|
|
20969
|
+
let topChunk = this.chunks[this.chunks.length - 1];
|
|
20970
|
+
if (this.cursor > this.maxCursor) {
|
|
20971
|
+
topChunk = alloc(this.chunkSize);
|
|
20972
|
+
this.chunks.push(topChunk);
|
|
20973
|
+
this.maxCursor += topChunk.length;
|
|
20974
|
+
if (this._initReuseChunk === null) {
|
|
20975
|
+
this._initReuseChunk = topChunk;
|
|
20976
|
+
}
|
|
20977
|
+
}
|
|
20978
|
+
const chunkPos = topChunk.length - (this.maxCursor - this.cursor) - 1;
|
|
20979
|
+
topChunk[chunkPos] = byte;
|
|
20980
|
+
this.cursor++;
|
|
20981
|
+
}
|
|
20982
|
+
/**
|
|
20983
|
+
* @param {ByteView|number[]} bytes
|
|
20984
|
+
*/
|
|
20985
|
+
push(bytes2) {
|
|
20986
|
+
let topChunk = this.chunks[this.chunks.length - 1];
|
|
20987
|
+
const newMax = this.cursor + bytes2.length;
|
|
20988
|
+
if (newMax <= this.maxCursor + 1) {
|
|
20989
|
+
const chunkPos = topChunk.length - (this.maxCursor - this.cursor) - 1;
|
|
20990
|
+
topChunk.set(bytes2, chunkPos);
|
|
20991
|
+
} else {
|
|
20992
|
+
if (topChunk) {
|
|
20993
|
+
const chunkPos = topChunk.length - (this.maxCursor - this.cursor) - 1;
|
|
20994
|
+
if (chunkPos < topChunk.length) {
|
|
20995
|
+
this.chunks[this.chunks.length - 1] = topChunk.subarray(0, chunkPos);
|
|
20996
|
+
this.maxCursor = this.cursor - 1;
|
|
20997
|
+
}
|
|
20998
|
+
}
|
|
20999
|
+
if (bytes2.length < 64 && bytes2.length < this.chunkSize) {
|
|
21000
|
+
topChunk = alloc(this.chunkSize);
|
|
21001
|
+
this.chunks.push(topChunk);
|
|
21002
|
+
this.maxCursor += topChunk.length;
|
|
21003
|
+
if (this._initReuseChunk === null) {
|
|
21004
|
+
this._initReuseChunk = topChunk;
|
|
21005
|
+
}
|
|
21006
|
+
topChunk.set(bytes2, 0);
|
|
21007
|
+
} else {
|
|
21008
|
+
this.chunks.push(bytes2);
|
|
21009
|
+
this.maxCursor += bytes2.length;
|
|
21010
|
+
}
|
|
21011
|
+
}
|
|
21012
|
+
this.cursor += bytes2.length;
|
|
21013
|
+
}
|
|
21014
|
+
/**
|
|
21015
|
+
* @param {boolean} [reset]
|
|
21016
|
+
* @returns {AllocatedByteView}
|
|
21017
|
+
*/
|
|
21018
|
+
toBytes(reset = false) {
|
|
21019
|
+
let byts;
|
|
21020
|
+
if (this.chunks.length === 1) {
|
|
21021
|
+
const chunk = this.chunks[0];
|
|
21022
|
+
if (reset && this.cursor > chunk.length / 2) {
|
|
21023
|
+
byts = this.cursor === chunk.length ? chunk : chunk.subarray(0, this.cursor);
|
|
21024
|
+
this._initReuseChunk = null;
|
|
21025
|
+
this.chunks = [];
|
|
21026
|
+
} else {
|
|
21027
|
+
byts = slice(chunk, 0, this.cursor);
|
|
21028
|
+
}
|
|
21029
|
+
} else {
|
|
21030
|
+
byts = concat(this.chunks, this.cursor);
|
|
21031
|
+
}
|
|
21032
|
+
if (reset) {
|
|
21033
|
+
this.reset();
|
|
21034
|
+
}
|
|
21035
|
+
return byts;
|
|
21036
|
+
}
|
|
21037
|
+
};
|
|
21038
|
+
var U8Bl = class {
|
|
21039
|
+
static {
|
|
21040
|
+
__name(this, "U8Bl");
|
|
21041
|
+
}
|
|
21042
|
+
/**
|
|
21043
|
+
* @param {Uint8Array<T>} dest
|
|
21044
|
+
*/
|
|
21045
|
+
constructor(dest) {
|
|
21046
|
+
this.dest = dest;
|
|
21047
|
+
this.cursor = 0;
|
|
21048
|
+
this.chunks = [dest];
|
|
21049
|
+
}
|
|
21050
|
+
reset() {
|
|
21051
|
+
this.cursor = 0;
|
|
21052
|
+
}
|
|
21053
|
+
/**
|
|
21054
|
+
* @param {number} byte
|
|
21055
|
+
*/
|
|
21056
|
+
pushByte(byte) {
|
|
21057
|
+
if (this.cursor >= this.dest.length) {
|
|
21058
|
+
throw new Error("write out of bounds, destination buffer is too small");
|
|
21059
|
+
}
|
|
21060
|
+
this.dest[this.cursor++] = byte;
|
|
21061
|
+
}
|
|
21062
|
+
/**
|
|
21063
|
+
* @param {ByteView|number[]} bytes
|
|
21064
|
+
*/
|
|
21065
|
+
push(bytes2) {
|
|
21066
|
+
if (this.cursor + bytes2.length > this.dest.length) {
|
|
21067
|
+
throw new Error("write out of bounds, destination buffer is too small");
|
|
21068
|
+
}
|
|
21069
|
+
this.dest.set(bytes2, this.cursor);
|
|
21070
|
+
this.cursor += bytes2.length;
|
|
21071
|
+
}
|
|
21072
|
+
/**
|
|
21073
|
+
* @param {boolean} [reset]
|
|
21074
|
+
* @returns {Uint8Array<T>}
|
|
21075
|
+
*/
|
|
21076
|
+
toBytes(reset = false) {
|
|
21077
|
+
const byts = this.dest.subarray(0, this.cursor);
|
|
21078
|
+
if (reset) {
|
|
21079
|
+
this.reset();
|
|
21080
|
+
}
|
|
21081
|
+
return byts;
|
|
21082
|
+
}
|
|
21083
|
+
};
|
|
21084
|
+
|
|
21085
|
+
// ../../node_modules/cborg/lib/common.js
|
|
21086
|
+
var decodeErrPrefix = "CBOR decode error:";
|
|
21087
|
+
var encodeErrPrefix = "CBOR encode error:";
|
|
21088
|
+
var uintMinorPrefixBytes = [];
|
|
21089
|
+
uintMinorPrefixBytes[23] = 1;
|
|
21090
|
+
uintMinorPrefixBytes[24] = 2;
|
|
21091
|
+
uintMinorPrefixBytes[25] = 3;
|
|
21092
|
+
uintMinorPrefixBytes[26] = 5;
|
|
21093
|
+
uintMinorPrefixBytes[27] = 9;
|
|
21094
|
+
function assertEnoughData(data, pos, need) {
|
|
21095
|
+
if (data.length - pos < need) {
|
|
21096
|
+
throw new Error(`${decodeErrPrefix} not enough data for type`);
|
|
21097
|
+
}
|
|
21098
|
+
}
|
|
21099
|
+
__name(assertEnoughData, "assertEnoughData");
|
|
21100
|
+
|
|
21101
|
+
// ../../node_modules/cborg/lib/0uint.js
|
|
21102
|
+
var uintBoundaries = [24, 256, 65536, 4294967296, BigInt("18446744073709551616")];
|
|
21103
|
+
function readUint8(data, offset, options) {
|
|
21104
|
+
assertEnoughData(data, offset, 1);
|
|
21105
|
+
const value = data[offset];
|
|
21106
|
+
if (options.strict === true && value < uintBoundaries[0]) {
|
|
21107
|
+
throw new Error(`${decodeErrPrefix} integer encoded in more bytes than necessary (strict decode)`);
|
|
21108
|
+
}
|
|
21109
|
+
return value;
|
|
21110
|
+
}
|
|
21111
|
+
__name(readUint8, "readUint8");
|
|
21112
|
+
function readUint16(data, offset, options) {
|
|
21113
|
+
assertEnoughData(data, offset, 2);
|
|
21114
|
+
const value = data[offset] << 8 | data[offset + 1];
|
|
21115
|
+
if (options.strict === true && value < uintBoundaries[1]) {
|
|
21116
|
+
throw new Error(`${decodeErrPrefix} integer encoded in more bytes than necessary (strict decode)`);
|
|
21117
|
+
}
|
|
21118
|
+
return value;
|
|
21119
|
+
}
|
|
21120
|
+
__name(readUint16, "readUint16");
|
|
21121
|
+
function readUint32(data, offset, options) {
|
|
21122
|
+
assertEnoughData(data, offset, 4);
|
|
21123
|
+
const value = data[offset] * 16777216 + (data[offset + 1] << 16) + (data[offset + 2] << 8) + data[offset + 3];
|
|
21124
|
+
if (options.strict === true && value < uintBoundaries[2]) {
|
|
21125
|
+
throw new Error(`${decodeErrPrefix} integer encoded in more bytes than necessary (strict decode)`);
|
|
21126
|
+
}
|
|
21127
|
+
return value;
|
|
21128
|
+
}
|
|
21129
|
+
__name(readUint32, "readUint32");
|
|
21130
|
+
function readUint64(data, offset, options) {
|
|
21131
|
+
assertEnoughData(data, offset, 8);
|
|
21132
|
+
const hi = data[offset] * 16777216 + (data[offset + 1] << 16) + (data[offset + 2] << 8) + data[offset + 3];
|
|
21133
|
+
const lo = data[offset + 4] * 16777216 + (data[offset + 5] << 16) + (data[offset + 6] << 8) + data[offset + 7];
|
|
21134
|
+
const value = (BigInt(hi) << BigInt(32)) + BigInt(lo);
|
|
21135
|
+
if (options.strict === true && value < uintBoundaries[3]) {
|
|
21136
|
+
throw new Error(`${decodeErrPrefix} integer encoded in more bytes than necessary (strict decode)`);
|
|
21137
|
+
}
|
|
21138
|
+
if (value <= Number.MAX_SAFE_INTEGER) {
|
|
21139
|
+
return Number(value);
|
|
21140
|
+
}
|
|
21141
|
+
if (options.allowBigInt === true) {
|
|
21142
|
+
return value;
|
|
21143
|
+
}
|
|
21144
|
+
throw new Error(`${decodeErrPrefix} integers outside of the safe integer range are not supported`);
|
|
21145
|
+
}
|
|
21146
|
+
__name(readUint64, "readUint64");
|
|
21147
|
+
function decodeUint8(data, pos, _minor, options) {
|
|
21148
|
+
return new Token(Type.uint, readUint8(data, pos + 1, options), 2);
|
|
21149
|
+
}
|
|
21150
|
+
__name(decodeUint8, "decodeUint8");
|
|
21151
|
+
function decodeUint16(data, pos, _minor, options) {
|
|
21152
|
+
return new Token(Type.uint, readUint16(data, pos + 1, options), 3);
|
|
21153
|
+
}
|
|
21154
|
+
__name(decodeUint16, "decodeUint16");
|
|
21155
|
+
function decodeUint32(data, pos, _minor, options) {
|
|
21156
|
+
return new Token(Type.uint, readUint32(data, pos + 1, options), 5);
|
|
21157
|
+
}
|
|
21158
|
+
__name(decodeUint32, "decodeUint32");
|
|
21159
|
+
function decodeUint64(data, pos, _minor, options) {
|
|
21160
|
+
return new Token(Type.uint, readUint64(data, pos + 1, options), 9);
|
|
21161
|
+
}
|
|
21162
|
+
__name(decodeUint64, "decodeUint64");
|
|
21163
|
+
function encodeUint(writer, token) {
|
|
21164
|
+
return encodeUintValue(writer, 0, token.value);
|
|
21165
|
+
}
|
|
21166
|
+
__name(encodeUint, "encodeUint");
|
|
21167
|
+
function encodeUintValue(writer, major, uint) {
|
|
21168
|
+
if (uint < uintBoundaries[0]) {
|
|
21169
|
+
const nuint = Number(uint);
|
|
21170
|
+
writer.pushByte(major | nuint);
|
|
21171
|
+
} else if (uint < uintBoundaries[1]) {
|
|
21172
|
+
const nuint = Number(uint);
|
|
21173
|
+
writer.push([major | 24, nuint]);
|
|
21174
|
+
} else if (uint < uintBoundaries[2]) {
|
|
21175
|
+
const nuint = Number(uint);
|
|
21176
|
+
writer.push([major | 25, nuint >>> 8, nuint & 255]);
|
|
21177
|
+
} else if (uint < uintBoundaries[3]) {
|
|
21178
|
+
const nuint = Number(uint);
|
|
21179
|
+
writer.push([major | 26, nuint >>> 24 & 255, nuint >>> 16 & 255, nuint >>> 8 & 255, nuint & 255]);
|
|
21180
|
+
} else {
|
|
21181
|
+
const buint = BigInt(uint);
|
|
21182
|
+
if (buint < uintBoundaries[4]) {
|
|
21183
|
+
const set = [major | 27, 0, 0, 0, 0, 0, 0, 0];
|
|
21184
|
+
let lo = Number(buint & BigInt(4294967295));
|
|
21185
|
+
let hi = Number(buint >> BigInt(32) & BigInt(4294967295));
|
|
21186
|
+
set[8] = lo & 255;
|
|
21187
|
+
lo = lo >> 8;
|
|
21188
|
+
set[7] = lo & 255;
|
|
21189
|
+
lo = lo >> 8;
|
|
21190
|
+
set[6] = lo & 255;
|
|
21191
|
+
lo = lo >> 8;
|
|
21192
|
+
set[5] = lo & 255;
|
|
21193
|
+
set[4] = hi & 255;
|
|
21194
|
+
hi = hi >> 8;
|
|
21195
|
+
set[3] = hi & 255;
|
|
21196
|
+
hi = hi >> 8;
|
|
21197
|
+
set[2] = hi & 255;
|
|
21198
|
+
hi = hi >> 8;
|
|
21199
|
+
set[1] = hi & 255;
|
|
21200
|
+
writer.push(set);
|
|
21201
|
+
} else {
|
|
21202
|
+
throw new Error(`${decodeErrPrefix} encountered BigInt larger than allowable range`);
|
|
21203
|
+
}
|
|
21204
|
+
}
|
|
21205
|
+
}
|
|
21206
|
+
__name(encodeUintValue, "encodeUintValue");
|
|
21207
|
+
encodeUint.encodedSize = /* @__PURE__ */ __name(function encodedSize(token) {
|
|
21208
|
+
return encodeUintValue.encodedSize(token.value);
|
|
21209
|
+
}, "encodedSize");
|
|
21210
|
+
encodeUintValue.encodedSize = /* @__PURE__ */ __name(function encodedSize2(uint) {
|
|
21211
|
+
if (uint < uintBoundaries[0]) {
|
|
21212
|
+
return 1;
|
|
21213
|
+
}
|
|
21214
|
+
if (uint < uintBoundaries[1]) {
|
|
21215
|
+
return 2;
|
|
21216
|
+
}
|
|
21217
|
+
if (uint < uintBoundaries[2]) {
|
|
21218
|
+
return 3;
|
|
21219
|
+
}
|
|
21220
|
+
if (uint < uintBoundaries[3]) {
|
|
21221
|
+
return 5;
|
|
21222
|
+
}
|
|
21223
|
+
return 9;
|
|
21224
|
+
}, "encodedSize");
|
|
21225
|
+
encodeUint.compareTokens = /* @__PURE__ */ __name(function compareTokens(tok1, tok2) {
|
|
21226
|
+
return tok1.value < tok2.value ? -1 : tok1.value > tok2.value ? 1 : 0;
|
|
21227
|
+
}, "compareTokens");
|
|
21228
|
+
|
|
21229
|
+
// ../../node_modules/cborg/lib/1negint.js
|
|
21230
|
+
function decodeNegint8(data, pos, _minor, options) {
|
|
21231
|
+
return new Token(Type.negint, -1 - readUint8(data, pos + 1, options), 2);
|
|
21232
|
+
}
|
|
21233
|
+
__name(decodeNegint8, "decodeNegint8");
|
|
21234
|
+
function decodeNegint16(data, pos, _minor, options) {
|
|
21235
|
+
return new Token(Type.negint, -1 - readUint16(data, pos + 1, options), 3);
|
|
21236
|
+
}
|
|
21237
|
+
__name(decodeNegint16, "decodeNegint16");
|
|
21238
|
+
function decodeNegint32(data, pos, _minor, options) {
|
|
21239
|
+
return new Token(Type.negint, -1 - readUint32(data, pos + 1, options), 5);
|
|
21240
|
+
}
|
|
21241
|
+
__name(decodeNegint32, "decodeNegint32");
|
|
21242
|
+
var neg1b = BigInt(-1);
|
|
21243
|
+
var pos1b = BigInt(1);
|
|
21244
|
+
function decodeNegint64(data, pos, _minor, options) {
|
|
21245
|
+
const int = readUint64(data, pos + 1, options);
|
|
21246
|
+
if (typeof int !== "bigint") {
|
|
21247
|
+
const value = -1 - int;
|
|
21248
|
+
if (value >= Number.MIN_SAFE_INTEGER) {
|
|
21249
|
+
return new Token(Type.negint, value, 9);
|
|
21250
|
+
}
|
|
21251
|
+
}
|
|
21252
|
+
if (options.allowBigInt !== true) {
|
|
21253
|
+
throw new Error(`${decodeErrPrefix} integers outside of the safe integer range are not supported`);
|
|
21254
|
+
}
|
|
21255
|
+
return new Token(Type.negint, neg1b - BigInt(int), 9);
|
|
21256
|
+
}
|
|
21257
|
+
__name(decodeNegint64, "decodeNegint64");
|
|
21258
|
+
function encodeNegint(writer, token) {
|
|
21259
|
+
const negint = token.value;
|
|
21260
|
+
const unsigned = typeof negint === "bigint" ? negint * neg1b - pos1b : negint * -1 - 1;
|
|
21261
|
+
encodeUintValue(writer, token.type.majorEncoded, unsigned);
|
|
21262
|
+
}
|
|
21263
|
+
__name(encodeNegint, "encodeNegint");
|
|
21264
|
+
encodeNegint.encodedSize = /* @__PURE__ */ __name(function encodedSize3(token) {
|
|
21265
|
+
const negint = token.value;
|
|
21266
|
+
const unsigned = typeof negint === "bigint" ? negint * neg1b - pos1b : negint * -1 - 1;
|
|
21267
|
+
if (unsigned < uintBoundaries[0]) {
|
|
21268
|
+
return 1;
|
|
21269
|
+
}
|
|
21270
|
+
if (unsigned < uintBoundaries[1]) {
|
|
21271
|
+
return 2;
|
|
21272
|
+
}
|
|
21273
|
+
if (unsigned < uintBoundaries[2]) {
|
|
21274
|
+
return 3;
|
|
21275
|
+
}
|
|
21276
|
+
if (unsigned < uintBoundaries[3]) {
|
|
21277
|
+
return 5;
|
|
21278
|
+
}
|
|
21279
|
+
return 9;
|
|
21280
|
+
}, "encodedSize");
|
|
21281
|
+
encodeNegint.compareTokens = /* @__PURE__ */ __name(function compareTokens2(tok1, tok2) {
|
|
21282
|
+
return tok1.value < tok2.value ? 1 : tok1.value > tok2.value ? -1 : 0;
|
|
21283
|
+
}, "compareTokens");
|
|
21284
|
+
|
|
21285
|
+
// ../../node_modules/cborg/lib/2bytes.js
|
|
21286
|
+
function toToken(data, pos, prefix, length) {
|
|
21287
|
+
assertEnoughData(data, pos, prefix + length);
|
|
21288
|
+
const buf = data.slice(pos + prefix, pos + prefix + length);
|
|
21289
|
+
return new Token(Type.bytes, buf, prefix + length);
|
|
21290
|
+
}
|
|
21291
|
+
__name(toToken, "toToken");
|
|
21292
|
+
function decodeBytesCompact(data, pos, minor, _options) {
|
|
21293
|
+
return toToken(data, pos, 1, minor);
|
|
21294
|
+
}
|
|
21295
|
+
__name(decodeBytesCompact, "decodeBytesCompact");
|
|
21296
|
+
function decodeBytes8(data, pos, _minor, options) {
|
|
21297
|
+
return toToken(data, pos, 2, readUint8(data, pos + 1, options));
|
|
21298
|
+
}
|
|
21299
|
+
__name(decodeBytes8, "decodeBytes8");
|
|
21300
|
+
function decodeBytes16(data, pos, _minor, options) {
|
|
21301
|
+
return toToken(data, pos, 3, readUint16(data, pos + 1, options));
|
|
21302
|
+
}
|
|
21303
|
+
__name(decodeBytes16, "decodeBytes16");
|
|
21304
|
+
function decodeBytes32(data, pos, _minor, options) {
|
|
21305
|
+
return toToken(data, pos, 5, readUint32(data, pos + 1, options));
|
|
21306
|
+
}
|
|
21307
|
+
__name(decodeBytes32, "decodeBytes32");
|
|
21308
|
+
function decodeBytes64(data, pos, _minor, options) {
|
|
21309
|
+
const l = readUint64(data, pos + 1, options);
|
|
21310
|
+
if (typeof l === "bigint") {
|
|
21311
|
+
throw new Error(`${decodeErrPrefix} 64-bit integer bytes lengths not supported`);
|
|
21312
|
+
}
|
|
21313
|
+
return toToken(data, pos, 9, l);
|
|
21314
|
+
}
|
|
21315
|
+
__name(decodeBytes64, "decodeBytes64");
|
|
21316
|
+
function tokenBytes(token) {
|
|
21317
|
+
if (token.encodedBytes === void 0) {
|
|
21318
|
+
token.encodedBytes = Type.equals(token.type, Type.string) ? fromString(token.value) : token.value;
|
|
21319
|
+
}
|
|
21320
|
+
return token.encodedBytes;
|
|
21321
|
+
}
|
|
21322
|
+
__name(tokenBytes, "tokenBytes");
|
|
21323
|
+
function encodeBytes(writer, token) {
|
|
21324
|
+
const bytes2 = tokenBytes(token);
|
|
21325
|
+
encodeUintValue(writer, token.type.majorEncoded, bytes2.length);
|
|
21326
|
+
writer.push(bytes2);
|
|
21327
|
+
}
|
|
21328
|
+
__name(encodeBytes, "encodeBytes");
|
|
21329
|
+
encodeBytes.encodedSize = /* @__PURE__ */ __name(function encodedSize4(token) {
|
|
21330
|
+
const bytes2 = tokenBytes(token);
|
|
21331
|
+
return encodeUintValue.encodedSize(bytes2.length) + bytes2.length;
|
|
21332
|
+
}, "encodedSize");
|
|
21333
|
+
encodeBytes.compareTokens = /* @__PURE__ */ __name(function compareTokens3(tok1, tok2) {
|
|
21334
|
+
return compareBytes(tokenBytes(tok1), tokenBytes(tok2));
|
|
21335
|
+
}, "compareTokens");
|
|
21336
|
+
function compareBytes(b1, b2) {
|
|
21337
|
+
return b1.length < b2.length ? -1 : b1.length > b2.length ? 1 : compare(b1, b2);
|
|
21338
|
+
}
|
|
21339
|
+
__name(compareBytes, "compareBytes");
|
|
21340
|
+
|
|
21341
|
+
// ../../node_modules/cborg/lib/3string.js
|
|
21342
|
+
var textDecoder = new TextDecoder();
|
|
21343
|
+
var ASCII_THRESHOLD = 32;
|
|
21344
|
+
function toStr(bytes2, start, end) {
|
|
21345
|
+
const len = end - start;
|
|
21346
|
+
if (len < ASCII_THRESHOLD) {
|
|
21347
|
+
let str = "";
|
|
21348
|
+
for (let i = start; i < end; i++) {
|
|
21349
|
+
const c = bytes2[i];
|
|
21350
|
+
if (c & 128) {
|
|
21351
|
+
return textDecoder.decode(bytes2.subarray(start, end));
|
|
21352
|
+
}
|
|
21353
|
+
str += String.fromCharCode(c);
|
|
21354
|
+
}
|
|
21355
|
+
return str;
|
|
21356
|
+
}
|
|
21357
|
+
return textDecoder.decode(bytes2.subarray(start, end));
|
|
21358
|
+
}
|
|
21359
|
+
__name(toStr, "toStr");
|
|
21360
|
+
function toToken2(data, pos, prefix, length, options) {
|
|
21361
|
+
const totLength = prefix + length;
|
|
21362
|
+
assertEnoughData(data, pos, totLength);
|
|
21363
|
+
const tok = new Token(Type.string, toStr(data, pos + prefix, pos + totLength), totLength);
|
|
21364
|
+
if (options.retainStringBytes === true) {
|
|
21365
|
+
tok.byteValue = data.slice(pos + prefix, pos + totLength);
|
|
21366
|
+
}
|
|
21367
|
+
return tok;
|
|
21368
|
+
}
|
|
21369
|
+
__name(toToken2, "toToken");
|
|
21370
|
+
function decodeStringCompact(data, pos, minor, options) {
|
|
21371
|
+
return toToken2(data, pos, 1, minor, options);
|
|
21372
|
+
}
|
|
21373
|
+
__name(decodeStringCompact, "decodeStringCompact");
|
|
21374
|
+
function decodeString8(data, pos, _minor, options) {
|
|
21375
|
+
return toToken2(data, pos, 2, readUint8(data, pos + 1, options), options);
|
|
21376
|
+
}
|
|
21377
|
+
__name(decodeString8, "decodeString8");
|
|
21378
|
+
function decodeString16(data, pos, _minor, options) {
|
|
21379
|
+
return toToken2(data, pos, 3, readUint16(data, pos + 1, options), options);
|
|
21380
|
+
}
|
|
21381
|
+
__name(decodeString16, "decodeString16");
|
|
21382
|
+
function decodeString32(data, pos, _minor, options) {
|
|
21383
|
+
return toToken2(data, pos, 5, readUint32(data, pos + 1, options), options);
|
|
21384
|
+
}
|
|
21385
|
+
__name(decodeString32, "decodeString32");
|
|
21386
|
+
function decodeString64(data, pos, _minor, options) {
|
|
21387
|
+
const l = readUint64(data, pos + 1, options);
|
|
21388
|
+
if (typeof l === "bigint") {
|
|
21389
|
+
throw new Error(`${decodeErrPrefix} 64-bit integer string lengths not supported`);
|
|
21390
|
+
}
|
|
21391
|
+
return toToken2(data, pos, 9, l, options);
|
|
21392
|
+
}
|
|
21393
|
+
__name(decodeString64, "decodeString64");
|
|
21394
|
+
var encodeString = encodeBytes;
|
|
21395
|
+
|
|
21396
|
+
// ../../node_modules/cborg/lib/4array.js
|
|
21397
|
+
function toToken3(_data, _pos, prefix, length) {
|
|
21398
|
+
return new Token(Type.array, length, prefix);
|
|
21399
|
+
}
|
|
21400
|
+
__name(toToken3, "toToken");
|
|
21401
|
+
function decodeArrayCompact(data, pos, minor, _options) {
|
|
21402
|
+
return toToken3(data, pos, 1, minor);
|
|
21403
|
+
}
|
|
21404
|
+
__name(decodeArrayCompact, "decodeArrayCompact");
|
|
21405
|
+
function decodeArray8(data, pos, _minor, options) {
|
|
21406
|
+
return toToken3(data, pos, 2, readUint8(data, pos + 1, options));
|
|
21407
|
+
}
|
|
21408
|
+
__name(decodeArray8, "decodeArray8");
|
|
21409
|
+
function decodeArray16(data, pos, _minor, options) {
|
|
21410
|
+
return toToken3(data, pos, 3, readUint16(data, pos + 1, options));
|
|
21411
|
+
}
|
|
21412
|
+
__name(decodeArray16, "decodeArray16");
|
|
21413
|
+
function decodeArray32(data, pos, _minor, options) {
|
|
21414
|
+
return toToken3(data, pos, 5, readUint32(data, pos + 1, options));
|
|
21415
|
+
}
|
|
21416
|
+
__name(decodeArray32, "decodeArray32");
|
|
21417
|
+
function decodeArray64(data, pos, _minor, options) {
|
|
21418
|
+
const l = readUint64(data, pos + 1, options);
|
|
21419
|
+
if (typeof l === "bigint") {
|
|
21420
|
+
throw new Error(`${decodeErrPrefix} 64-bit integer array lengths not supported`);
|
|
21421
|
+
}
|
|
21422
|
+
return toToken3(data, pos, 9, l);
|
|
21423
|
+
}
|
|
21424
|
+
__name(decodeArray64, "decodeArray64");
|
|
21425
|
+
function decodeArrayIndefinite(data, pos, _minor, options) {
|
|
21426
|
+
if (options.allowIndefinite === false) {
|
|
21427
|
+
throw new Error(`${decodeErrPrefix} indefinite length items not allowed`);
|
|
21428
|
+
}
|
|
21429
|
+
return toToken3(data, pos, 1, Infinity);
|
|
21430
|
+
}
|
|
21431
|
+
__name(decodeArrayIndefinite, "decodeArrayIndefinite");
|
|
21432
|
+
function encodeArray(writer, token) {
|
|
21433
|
+
encodeUintValue(writer, Type.array.majorEncoded, token.value);
|
|
21434
|
+
}
|
|
21435
|
+
__name(encodeArray, "encodeArray");
|
|
21436
|
+
encodeArray.compareTokens = encodeUint.compareTokens;
|
|
21437
|
+
encodeArray.encodedSize = /* @__PURE__ */ __name(function encodedSize5(token) {
|
|
21438
|
+
return encodeUintValue.encodedSize(token.value);
|
|
21439
|
+
}, "encodedSize");
|
|
21440
|
+
|
|
21441
|
+
// ../../node_modules/cborg/lib/5map.js
|
|
21442
|
+
function toToken4(_data, _pos, prefix, length) {
|
|
21443
|
+
return new Token(Type.map, length, prefix);
|
|
21444
|
+
}
|
|
21445
|
+
__name(toToken4, "toToken");
|
|
21446
|
+
function decodeMapCompact(data, pos, minor, _options) {
|
|
21447
|
+
return toToken4(data, pos, 1, minor);
|
|
21448
|
+
}
|
|
21449
|
+
__name(decodeMapCompact, "decodeMapCompact");
|
|
21450
|
+
function decodeMap8(data, pos, _minor, options) {
|
|
21451
|
+
return toToken4(data, pos, 2, readUint8(data, pos + 1, options));
|
|
21452
|
+
}
|
|
21453
|
+
__name(decodeMap8, "decodeMap8");
|
|
21454
|
+
function decodeMap16(data, pos, _minor, options) {
|
|
21455
|
+
return toToken4(data, pos, 3, readUint16(data, pos + 1, options));
|
|
21456
|
+
}
|
|
21457
|
+
__name(decodeMap16, "decodeMap16");
|
|
21458
|
+
function decodeMap32(data, pos, _minor, options) {
|
|
21459
|
+
return toToken4(data, pos, 5, readUint32(data, pos + 1, options));
|
|
21460
|
+
}
|
|
21461
|
+
__name(decodeMap32, "decodeMap32");
|
|
21462
|
+
function decodeMap64(data, pos, _minor, options) {
|
|
21463
|
+
const l = readUint64(data, pos + 1, options);
|
|
21464
|
+
if (typeof l === "bigint") {
|
|
21465
|
+
throw new Error(`${decodeErrPrefix} 64-bit integer map lengths not supported`);
|
|
21466
|
+
}
|
|
21467
|
+
return toToken4(data, pos, 9, l);
|
|
21468
|
+
}
|
|
21469
|
+
__name(decodeMap64, "decodeMap64");
|
|
21470
|
+
function decodeMapIndefinite(data, pos, _minor, options) {
|
|
21471
|
+
if (options.allowIndefinite === false) {
|
|
21472
|
+
throw new Error(`${decodeErrPrefix} indefinite length items not allowed`);
|
|
21473
|
+
}
|
|
21474
|
+
return toToken4(data, pos, 1, Infinity);
|
|
21475
|
+
}
|
|
21476
|
+
__name(decodeMapIndefinite, "decodeMapIndefinite");
|
|
21477
|
+
function encodeMap(writer, token) {
|
|
21478
|
+
encodeUintValue(writer, Type.map.majorEncoded, token.value);
|
|
21479
|
+
}
|
|
21480
|
+
__name(encodeMap, "encodeMap");
|
|
21481
|
+
encodeMap.compareTokens = encodeUint.compareTokens;
|
|
21482
|
+
encodeMap.encodedSize = /* @__PURE__ */ __name(function encodedSize6(token) {
|
|
21483
|
+
return encodeUintValue.encodedSize(token.value);
|
|
21484
|
+
}, "encodedSize");
|
|
21485
|
+
|
|
21486
|
+
// ../../node_modules/cborg/lib/6tag.js
|
|
21487
|
+
function decodeTagCompact(_data, _pos, minor, _options) {
|
|
21488
|
+
return new Token(Type.tag, minor, 1);
|
|
21489
|
+
}
|
|
21490
|
+
__name(decodeTagCompact, "decodeTagCompact");
|
|
21491
|
+
function decodeTag8(data, pos, _minor, options) {
|
|
21492
|
+
return new Token(Type.tag, readUint8(data, pos + 1, options), 2);
|
|
21493
|
+
}
|
|
21494
|
+
__name(decodeTag8, "decodeTag8");
|
|
21495
|
+
function decodeTag16(data, pos, _minor, options) {
|
|
21496
|
+
return new Token(Type.tag, readUint16(data, pos + 1, options), 3);
|
|
21497
|
+
}
|
|
21498
|
+
__name(decodeTag16, "decodeTag16");
|
|
21499
|
+
function decodeTag32(data, pos, _minor, options) {
|
|
21500
|
+
return new Token(Type.tag, readUint32(data, pos + 1, options), 5);
|
|
21501
|
+
}
|
|
21502
|
+
__name(decodeTag32, "decodeTag32");
|
|
21503
|
+
function decodeTag64(data, pos, _minor, options) {
|
|
21504
|
+
return new Token(Type.tag, readUint64(data, pos + 1, options), 9);
|
|
21505
|
+
}
|
|
21506
|
+
__name(decodeTag64, "decodeTag64");
|
|
21507
|
+
function encodeTag(writer, token) {
|
|
21508
|
+
encodeUintValue(writer, Type.tag.majorEncoded, token.value);
|
|
21509
|
+
}
|
|
21510
|
+
__name(encodeTag, "encodeTag");
|
|
21511
|
+
encodeTag.compareTokens = encodeUint.compareTokens;
|
|
21512
|
+
encodeTag.encodedSize = /* @__PURE__ */ __name(function encodedSize7(token) {
|
|
21513
|
+
return encodeUintValue.encodedSize(token.value);
|
|
21514
|
+
}, "encodedSize");
|
|
21515
|
+
|
|
21516
|
+
// ../../node_modules/cborg/lib/7float.js
|
|
21517
|
+
var MINOR_FALSE = 20;
|
|
21518
|
+
var MINOR_TRUE = 21;
|
|
21519
|
+
var MINOR_NULL = 22;
|
|
21520
|
+
var MINOR_UNDEFINED = 23;
|
|
21521
|
+
function decodeUndefined(_data, _pos, _minor, options) {
|
|
21522
|
+
if (options.allowUndefined === false) {
|
|
21523
|
+
throw new Error(`${decodeErrPrefix} undefined values are not supported`);
|
|
21524
|
+
} else if (options.coerceUndefinedToNull === true) {
|
|
21525
|
+
return new Token(Type.null, null, 1);
|
|
21526
|
+
}
|
|
21527
|
+
return new Token(Type.undefined, void 0, 1);
|
|
21528
|
+
}
|
|
21529
|
+
__name(decodeUndefined, "decodeUndefined");
|
|
21530
|
+
function decodeBreak(_data, _pos, _minor, options) {
|
|
21531
|
+
if (options.allowIndefinite === false) {
|
|
21532
|
+
throw new Error(`${decodeErrPrefix} indefinite length items not allowed`);
|
|
21533
|
+
}
|
|
21534
|
+
return new Token(Type.break, void 0, 1);
|
|
21535
|
+
}
|
|
21536
|
+
__name(decodeBreak, "decodeBreak");
|
|
21537
|
+
function createToken(value, bytes2, options) {
|
|
21538
|
+
if (options) {
|
|
21539
|
+
if (options.allowNaN === false && Number.isNaN(value)) {
|
|
21540
|
+
throw new Error(`${decodeErrPrefix} NaN values are not supported`);
|
|
21541
|
+
}
|
|
21542
|
+
if (options.allowInfinity === false && (value === Infinity || value === -Infinity)) {
|
|
21543
|
+
throw new Error(`${decodeErrPrefix} Infinity values are not supported`);
|
|
21544
|
+
}
|
|
21545
|
+
}
|
|
21546
|
+
return new Token(Type.float, value, bytes2);
|
|
21547
|
+
}
|
|
21548
|
+
__name(createToken, "createToken");
|
|
21549
|
+
function decodeFloat16(data, pos, _minor, options) {
|
|
21550
|
+
return createToken(readFloat16(data, pos + 1), 3, options);
|
|
21551
|
+
}
|
|
21552
|
+
__name(decodeFloat16, "decodeFloat16");
|
|
21553
|
+
function decodeFloat32(data, pos, _minor, options) {
|
|
21554
|
+
return createToken(readFloat32(data, pos + 1), 5, options);
|
|
21555
|
+
}
|
|
21556
|
+
__name(decodeFloat32, "decodeFloat32");
|
|
21557
|
+
function decodeFloat64(data, pos, _minor, options) {
|
|
21558
|
+
return createToken(readFloat64(data, pos + 1), 9, options);
|
|
21559
|
+
}
|
|
21560
|
+
__name(decodeFloat64, "decodeFloat64");
|
|
21561
|
+
function encodeFloat(writer, token, options) {
|
|
21562
|
+
const float = token.value;
|
|
21563
|
+
if (float === false) {
|
|
21564
|
+
writer.pushByte(Type.float.majorEncoded | MINOR_FALSE);
|
|
21565
|
+
} else if (float === true) {
|
|
21566
|
+
writer.pushByte(Type.float.majorEncoded | MINOR_TRUE);
|
|
21567
|
+
} else if (float === null) {
|
|
21568
|
+
writer.pushByte(Type.float.majorEncoded | MINOR_NULL);
|
|
21569
|
+
} else if (float === void 0) {
|
|
21570
|
+
writer.pushByte(Type.float.majorEncoded | MINOR_UNDEFINED);
|
|
21571
|
+
} else {
|
|
21572
|
+
let decoded;
|
|
21573
|
+
let success = false;
|
|
21574
|
+
if (!options || options.float64 !== true) {
|
|
21575
|
+
encodeFloat16(float);
|
|
21576
|
+
decoded = readFloat16(ui8a, 1);
|
|
21577
|
+
if (float === decoded || Number.isNaN(float)) {
|
|
21578
|
+
ui8a[0] = 249;
|
|
21579
|
+
writer.push(ui8a.slice(0, 3));
|
|
21580
|
+
success = true;
|
|
21581
|
+
} else {
|
|
21582
|
+
encodeFloat32(float);
|
|
21583
|
+
decoded = readFloat32(ui8a, 1);
|
|
21584
|
+
if (float === decoded) {
|
|
21585
|
+
ui8a[0] = 250;
|
|
21586
|
+
writer.push(ui8a.slice(0, 5));
|
|
21587
|
+
success = true;
|
|
21588
|
+
}
|
|
21589
|
+
}
|
|
21590
|
+
}
|
|
21591
|
+
if (!success) {
|
|
21592
|
+
encodeFloat64(float);
|
|
21593
|
+
decoded = readFloat64(ui8a, 1);
|
|
21594
|
+
ui8a[0] = 251;
|
|
21595
|
+
writer.push(ui8a.slice(0, 9));
|
|
21596
|
+
}
|
|
21597
|
+
}
|
|
21598
|
+
}
|
|
21599
|
+
__name(encodeFloat, "encodeFloat");
|
|
21600
|
+
encodeFloat.encodedSize = /* @__PURE__ */ __name(function encodedSize8(token, options) {
|
|
21601
|
+
const float = token.value;
|
|
21602
|
+
if (float === false || float === true || float === null || float === void 0) {
|
|
21603
|
+
return 1;
|
|
21604
|
+
}
|
|
21605
|
+
if (!options || options.float64 !== true) {
|
|
21606
|
+
encodeFloat16(float);
|
|
21607
|
+
let decoded = readFloat16(ui8a, 1);
|
|
21608
|
+
if (float === decoded || Number.isNaN(float)) {
|
|
21609
|
+
return 3;
|
|
21610
|
+
}
|
|
21611
|
+
encodeFloat32(float);
|
|
21612
|
+
decoded = readFloat32(ui8a, 1);
|
|
21613
|
+
if (float === decoded) {
|
|
21614
|
+
return 5;
|
|
21615
|
+
}
|
|
21616
|
+
}
|
|
21617
|
+
return 9;
|
|
21618
|
+
}, "encodedSize");
|
|
21619
|
+
var buffer = new ArrayBuffer(9);
|
|
21620
|
+
var dataView = new DataView(buffer, 1);
|
|
21621
|
+
var ui8a = new Uint8Array(buffer, 0);
|
|
21622
|
+
function encodeFloat16(inp) {
|
|
21623
|
+
if (inp === Infinity) {
|
|
21624
|
+
dataView.setUint16(0, 31744, false);
|
|
21625
|
+
} else if (inp === -Infinity) {
|
|
21626
|
+
dataView.setUint16(0, 64512, false);
|
|
21627
|
+
} else if (Number.isNaN(inp)) {
|
|
21628
|
+
dataView.setUint16(0, 32256, false);
|
|
21629
|
+
} else {
|
|
21630
|
+
dataView.setFloat32(0, inp);
|
|
21631
|
+
const valu32 = dataView.getUint32(0);
|
|
21632
|
+
const exponent = (valu32 & 2139095040) >> 23;
|
|
21633
|
+
const mantissa = valu32 & 8388607;
|
|
21634
|
+
if (exponent === 255) {
|
|
21635
|
+
dataView.setUint16(0, 31744, false);
|
|
21636
|
+
} else if (exponent === 0) {
|
|
21637
|
+
dataView.setUint16(0, (valu32 & 2147483648) >> 16 | mantissa >> 13, false);
|
|
21638
|
+
} else {
|
|
21639
|
+
const logicalExponent = exponent - 127;
|
|
21640
|
+
if (logicalExponent < -24) {
|
|
21641
|
+
dataView.setUint16(0, 0);
|
|
21642
|
+
} else if (logicalExponent < -14) {
|
|
21643
|
+
dataView.setUint16(0, (valu32 & 2147483648) >> 16 | /* sign bit */
|
|
21644
|
+
1 << 24 + logicalExponent, false);
|
|
21645
|
+
} else {
|
|
21646
|
+
dataView.setUint16(0, (valu32 & 2147483648) >> 16 | logicalExponent + 15 << 10 | mantissa >> 13, false);
|
|
21647
|
+
}
|
|
21648
|
+
}
|
|
21649
|
+
}
|
|
21650
|
+
}
|
|
21651
|
+
__name(encodeFloat16, "encodeFloat16");
|
|
21652
|
+
function readFloat16(ui8a2, pos) {
|
|
21653
|
+
if (ui8a2.length - pos < 2) {
|
|
21654
|
+
throw new Error(`${decodeErrPrefix} not enough data for float16`);
|
|
21655
|
+
}
|
|
21656
|
+
const half = (ui8a2[pos] << 8) + ui8a2[pos + 1];
|
|
21657
|
+
if (half === 31744) {
|
|
21658
|
+
return Infinity;
|
|
21659
|
+
}
|
|
21660
|
+
if (half === 64512) {
|
|
21661
|
+
return -Infinity;
|
|
21662
|
+
}
|
|
21663
|
+
if (half === 32256) {
|
|
21664
|
+
return NaN;
|
|
21665
|
+
}
|
|
21666
|
+
const exp = half >> 10 & 31;
|
|
21667
|
+
const mant = half & 1023;
|
|
21668
|
+
let val;
|
|
21669
|
+
if (exp === 0) {
|
|
21670
|
+
val = mant * 2 ** -24;
|
|
21671
|
+
} else if (exp !== 31) {
|
|
21672
|
+
val = (mant + 1024) * 2 ** (exp - 25);
|
|
21673
|
+
} else {
|
|
21674
|
+
val = mant === 0 ? Infinity : NaN;
|
|
21675
|
+
}
|
|
21676
|
+
return half & 32768 ? -val : val;
|
|
21677
|
+
}
|
|
21678
|
+
__name(readFloat16, "readFloat16");
|
|
21679
|
+
function encodeFloat32(inp) {
|
|
21680
|
+
dataView.setFloat32(0, inp, false);
|
|
21681
|
+
}
|
|
21682
|
+
__name(encodeFloat32, "encodeFloat32");
|
|
21683
|
+
function readFloat32(ui8a2, pos) {
|
|
21684
|
+
if (ui8a2.length - pos < 4) {
|
|
21685
|
+
throw new Error(`${decodeErrPrefix} not enough data for float32`);
|
|
21686
|
+
}
|
|
21687
|
+
const offset = (ui8a2.byteOffset || 0) + pos;
|
|
21688
|
+
return new DataView(ui8a2.buffer, offset, 4).getFloat32(0, false);
|
|
21689
|
+
}
|
|
21690
|
+
__name(readFloat32, "readFloat32");
|
|
21691
|
+
function encodeFloat64(inp) {
|
|
21692
|
+
dataView.setFloat64(0, inp, false);
|
|
21693
|
+
}
|
|
21694
|
+
__name(encodeFloat64, "encodeFloat64");
|
|
21695
|
+
function readFloat64(ui8a2, pos) {
|
|
21696
|
+
if (ui8a2.length - pos < 8) {
|
|
21697
|
+
throw new Error(`${decodeErrPrefix} not enough data for float64`);
|
|
21698
|
+
}
|
|
21699
|
+
const offset = (ui8a2.byteOffset || 0) + pos;
|
|
21700
|
+
return new DataView(ui8a2.buffer, offset, 8).getFloat64(0, false);
|
|
21701
|
+
}
|
|
21702
|
+
__name(readFloat64, "readFloat64");
|
|
21703
|
+
function encodeMajorSevenBytes(token, float64) {
|
|
21704
|
+
const float = token.value;
|
|
21705
|
+
if (float === false) {
|
|
21706
|
+
return Uint8Array.of(Type.float.majorEncoded | MINOR_FALSE);
|
|
21707
|
+
}
|
|
21708
|
+
if (float === true) {
|
|
21709
|
+
return Uint8Array.of(Type.float.majorEncoded | MINOR_TRUE);
|
|
21710
|
+
}
|
|
21711
|
+
if (float === null) {
|
|
21712
|
+
return Uint8Array.of(Type.float.majorEncoded | MINOR_NULL);
|
|
21713
|
+
}
|
|
21714
|
+
if (float === void 0) {
|
|
21715
|
+
return Uint8Array.of(Type.float.majorEncoded | MINOR_UNDEFINED);
|
|
21716
|
+
}
|
|
21717
|
+
if (!float64) {
|
|
21718
|
+
encodeFloat16(float);
|
|
21719
|
+
if (float === readFloat16(ui8a, 1) || Number.isNaN(float)) {
|
|
21720
|
+
ui8a[0] = 249;
|
|
21721
|
+
return ui8a.slice(0, 3);
|
|
21722
|
+
}
|
|
21723
|
+
encodeFloat32(float);
|
|
21724
|
+
if (float === readFloat32(ui8a, 1)) {
|
|
21725
|
+
ui8a[0] = 250;
|
|
21726
|
+
return ui8a.slice(0, 5);
|
|
21727
|
+
}
|
|
21728
|
+
}
|
|
21729
|
+
encodeFloat64(float);
|
|
21730
|
+
ui8a[0] = 251;
|
|
21731
|
+
return ui8a.slice(0, 9);
|
|
21732
|
+
}
|
|
21733
|
+
__name(encodeMajorSevenBytes, "encodeMajorSevenBytes");
|
|
21734
|
+
function majorSevenBytes(token, options) {
|
|
21735
|
+
const tokenEx = (
|
|
21736
|
+
/** @type {TokenEx} */
|
|
21737
|
+
token
|
|
21738
|
+
);
|
|
21739
|
+
const float64 = options?.float64 === true;
|
|
21740
|
+
const cached = float64 ? tokenEx._keyBytesFloat64 : tokenEx._keyBytes;
|
|
21741
|
+
if (cached !== void 0) {
|
|
21742
|
+
return cached;
|
|
21743
|
+
}
|
|
21744
|
+
const bytes2 = encodeMajorSevenBytes(token, float64);
|
|
21745
|
+
if (float64) {
|
|
21746
|
+
tokenEx._keyBytesFloat64 = bytes2;
|
|
21747
|
+
} else {
|
|
21748
|
+
tokenEx._keyBytes = bytes2;
|
|
21749
|
+
}
|
|
21750
|
+
return bytes2;
|
|
21751
|
+
}
|
|
21752
|
+
__name(majorSevenBytes, "majorSevenBytes");
|
|
21753
|
+
encodeFloat.compareTokens = /* @__PURE__ */ __name(function compareTokens4(tok1, tok2, options) {
|
|
21754
|
+
const b1 = majorSevenBytes(tok1, options);
|
|
21755
|
+
const b2 = majorSevenBytes(tok2, options);
|
|
21756
|
+
if (b1.length !== b2.length) {
|
|
21757
|
+
return b1.length < b2.length ? -1 : 1;
|
|
21758
|
+
}
|
|
21759
|
+
return compare(b1, b2);
|
|
21760
|
+
}, "compareTokens");
|
|
21761
|
+
|
|
21762
|
+
// ../../node_modules/cborg/lib/jump.js
|
|
21763
|
+
function invalidMinor(data, pos, minor) {
|
|
21764
|
+
throw new Error(`${decodeErrPrefix} encountered invalid minor (${minor}) for major ${data[pos] >>> 5}`);
|
|
21765
|
+
}
|
|
21766
|
+
__name(invalidMinor, "invalidMinor");
|
|
21767
|
+
function errorer(msg) {
|
|
21768
|
+
return () => {
|
|
21769
|
+
throw new Error(`${decodeErrPrefix} ${msg}`);
|
|
21770
|
+
};
|
|
21771
|
+
}
|
|
21772
|
+
__name(errorer, "errorer");
|
|
21773
|
+
var jump = [];
|
|
21774
|
+
for (let i = 0; i <= 23; i++) {
|
|
21775
|
+
jump[i] = invalidMinor;
|
|
21776
|
+
}
|
|
21777
|
+
jump[24] = decodeUint8;
|
|
21778
|
+
jump[25] = decodeUint16;
|
|
21779
|
+
jump[26] = decodeUint32;
|
|
21780
|
+
jump[27] = decodeUint64;
|
|
21781
|
+
jump[28] = invalidMinor;
|
|
21782
|
+
jump[29] = invalidMinor;
|
|
21783
|
+
jump[30] = invalidMinor;
|
|
21784
|
+
jump[31] = invalidMinor;
|
|
21785
|
+
for (let i = 32; i <= 55; i++) {
|
|
21786
|
+
jump[i] = invalidMinor;
|
|
21787
|
+
}
|
|
21788
|
+
jump[56] = decodeNegint8;
|
|
21789
|
+
jump[57] = decodeNegint16;
|
|
21790
|
+
jump[58] = decodeNegint32;
|
|
21791
|
+
jump[59] = decodeNegint64;
|
|
21792
|
+
jump[60] = invalidMinor;
|
|
21793
|
+
jump[61] = invalidMinor;
|
|
21794
|
+
jump[62] = invalidMinor;
|
|
21795
|
+
jump[63] = invalidMinor;
|
|
21796
|
+
for (let i = 64; i <= 87; i++) {
|
|
21797
|
+
jump[i] = decodeBytesCompact;
|
|
21798
|
+
}
|
|
21799
|
+
jump[88] = decodeBytes8;
|
|
21800
|
+
jump[89] = decodeBytes16;
|
|
21801
|
+
jump[90] = decodeBytes32;
|
|
21802
|
+
jump[91] = decodeBytes64;
|
|
21803
|
+
jump[92] = invalidMinor;
|
|
21804
|
+
jump[93] = invalidMinor;
|
|
21805
|
+
jump[94] = invalidMinor;
|
|
21806
|
+
jump[95] = errorer("indefinite length bytes/strings are not supported");
|
|
21807
|
+
for (let i = 96; i <= 119; i++) {
|
|
21808
|
+
jump[i] = decodeStringCompact;
|
|
21809
|
+
}
|
|
21810
|
+
jump[120] = decodeString8;
|
|
21811
|
+
jump[121] = decodeString16;
|
|
21812
|
+
jump[122] = decodeString32;
|
|
21813
|
+
jump[123] = decodeString64;
|
|
21814
|
+
jump[124] = invalidMinor;
|
|
21815
|
+
jump[125] = invalidMinor;
|
|
21816
|
+
jump[126] = invalidMinor;
|
|
21817
|
+
jump[127] = errorer("indefinite length bytes/strings are not supported");
|
|
21818
|
+
for (let i = 128; i <= 151; i++) {
|
|
21819
|
+
jump[i] = decodeArrayCompact;
|
|
21820
|
+
}
|
|
21821
|
+
jump[152] = decodeArray8;
|
|
21822
|
+
jump[153] = decodeArray16;
|
|
21823
|
+
jump[154] = decodeArray32;
|
|
21824
|
+
jump[155] = decodeArray64;
|
|
21825
|
+
jump[156] = invalidMinor;
|
|
21826
|
+
jump[157] = invalidMinor;
|
|
21827
|
+
jump[158] = invalidMinor;
|
|
21828
|
+
jump[159] = decodeArrayIndefinite;
|
|
21829
|
+
for (let i = 160; i <= 183; i++) {
|
|
21830
|
+
jump[i] = decodeMapCompact;
|
|
21831
|
+
}
|
|
21832
|
+
jump[184] = decodeMap8;
|
|
21833
|
+
jump[185] = decodeMap16;
|
|
21834
|
+
jump[186] = decodeMap32;
|
|
21835
|
+
jump[187] = decodeMap64;
|
|
21836
|
+
jump[188] = invalidMinor;
|
|
21837
|
+
jump[189] = invalidMinor;
|
|
21838
|
+
jump[190] = invalidMinor;
|
|
21839
|
+
jump[191] = decodeMapIndefinite;
|
|
21840
|
+
for (let i = 192; i <= 215; i++) {
|
|
21841
|
+
jump[i] = decodeTagCompact;
|
|
21842
|
+
}
|
|
21843
|
+
jump[216] = decodeTag8;
|
|
21844
|
+
jump[217] = decodeTag16;
|
|
21845
|
+
jump[218] = decodeTag32;
|
|
21846
|
+
jump[219] = decodeTag64;
|
|
21847
|
+
jump[220] = invalidMinor;
|
|
21848
|
+
jump[221] = invalidMinor;
|
|
21849
|
+
jump[222] = invalidMinor;
|
|
21850
|
+
jump[223] = invalidMinor;
|
|
21851
|
+
for (let i = 224; i <= 243; i++) {
|
|
21852
|
+
jump[i] = errorer("simple values are not supported");
|
|
21853
|
+
}
|
|
21854
|
+
jump[244] = invalidMinor;
|
|
21855
|
+
jump[245] = invalidMinor;
|
|
21856
|
+
jump[246] = invalidMinor;
|
|
21857
|
+
jump[247] = decodeUndefined;
|
|
21858
|
+
jump[248] = errorer("simple values are not supported");
|
|
21859
|
+
jump[249] = decodeFloat16;
|
|
21860
|
+
jump[250] = decodeFloat32;
|
|
21861
|
+
jump[251] = decodeFloat64;
|
|
21862
|
+
jump[252] = invalidMinor;
|
|
21863
|
+
jump[253] = invalidMinor;
|
|
21864
|
+
jump[254] = invalidMinor;
|
|
21865
|
+
jump[255] = decodeBreak;
|
|
21866
|
+
var quick = [];
|
|
21867
|
+
for (let i = 0; i < 24; i++) {
|
|
21868
|
+
quick[i] = new Token(Type.uint, i, 1);
|
|
21869
|
+
}
|
|
21870
|
+
for (let i = -1; i >= -24; i--) {
|
|
21871
|
+
quick[31 - i] = new Token(Type.negint, i, 1);
|
|
21872
|
+
}
|
|
21873
|
+
quick[64] = new Token(Type.bytes, new Uint8Array(0), 1);
|
|
21874
|
+
quick[96] = new Token(Type.string, "", 1);
|
|
21875
|
+
quick[128] = new Token(Type.array, 0, 1);
|
|
21876
|
+
quick[160] = new Token(Type.map, 0, 1);
|
|
21877
|
+
quick[244] = new Token(Type.false, false, 1);
|
|
21878
|
+
quick[245] = new Token(Type.true, true, 1);
|
|
21879
|
+
quick[246] = new Token(Type.null, null, 1);
|
|
21880
|
+
function quickEncodeToken(token) {
|
|
21881
|
+
switch (token.type) {
|
|
21882
|
+
case Type.false:
|
|
21883
|
+
return fromArray([244]);
|
|
21884
|
+
case Type.true:
|
|
21885
|
+
return fromArray([245]);
|
|
21886
|
+
case Type.null:
|
|
21887
|
+
return fromArray([246]);
|
|
21888
|
+
case Type.bytes:
|
|
21889
|
+
if (!token.value.length) {
|
|
21890
|
+
return fromArray([64]);
|
|
21891
|
+
}
|
|
21892
|
+
return;
|
|
21893
|
+
case Type.string:
|
|
21894
|
+
if (token.value === "") {
|
|
21895
|
+
return fromArray([96]);
|
|
21896
|
+
}
|
|
21897
|
+
return;
|
|
21898
|
+
case Type.array:
|
|
21899
|
+
if (token.value === 0) {
|
|
21900
|
+
return fromArray([128]);
|
|
21901
|
+
}
|
|
21902
|
+
return;
|
|
21903
|
+
case Type.map:
|
|
21904
|
+
if (token.value === 0) {
|
|
21905
|
+
return fromArray([160]);
|
|
21906
|
+
}
|
|
21907
|
+
return;
|
|
21908
|
+
case Type.uint:
|
|
21909
|
+
if (token.value < 24) {
|
|
21910
|
+
return fromArray([Number(token.value)]);
|
|
21911
|
+
}
|
|
21912
|
+
return;
|
|
21913
|
+
case Type.negint:
|
|
21914
|
+
if (token.value >= -24) {
|
|
21915
|
+
return fromArray([31 - Number(token.value)]);
|
|
21916
|
+
}
|
|
21917
|
+
}
|
|
21918
|
+
}
|
|
21919
|
+
__name(quickEncodeToken, "quickEncodeToken");
|
|
21920
|
+
|
|
21921
|
+
// ../../node_modules/cborg/lib/encode.js
|
|
21922
|
+
var defaultEncodeOptions = {
|
|
21923
|
+
float64: false,
|
|
21924
|
+
mapSorter,
|
|
21925
|
+
quickEncodeToken
|
|
21926
|
+
};
|
|
21927
|
+
var rfc8949EncodeOptions = Object.freeze({
|
|
21928
|
+
mapSorter: rfc8949MapSorter,
|
|
21929
|
+
quickEncodeToken
|
|
21930
|
+
});
|
|
21931
|
+
function makeCborEncoders() {
|
|
21932
|
+
const encoders = [];
|
|
21933
|
+
encoders[Type.uint.major] = encodeUint;
|
|
21934
|
+
encoders[Type.negint.major] = encodeNegint;
|
|
21935
|
+
encoders[Type.bytes.major] = encodeBytes;
|
|
21936
|
+
encoders[Type.string.major] = encodeString;
|
|
21937
|
+
encoders[Type.array.major] = encodeArray;
|
|
21938
|
+
encoders[Type.map.major] = encodeMap;
|
|
21939
|
+
encoders[Type.tag.major] = encodeTag;
|
|
21940
|
+
encoders[Type.float.major] = encodeFloat;
|
|
21941
|
+
return encoders;
|
|
21942
|
+
}
|
|
21943
|
+
__name(makeCborEncoders, "makeCborEncoders");
|
|
21944
|
+
var cborEncoders = makeCborEncoders();
|
|
21945
|
+
var defaultWriter = new Bl();
|
|
21946
|
+
var Ref = class _Ref {
|
|
21947
|
+
static {
|
|
21948
|
+
__name(this, "Ref");
|
|
21949
|
+
}
|
|
21950
|
+
/**
|
|
21951
|
+
* @param {object|any[]} obj
|
|
21952
|
+
* @param {Reference|undefined} parent
|
|
21953
|
+
*/
|
|
21954
|
+
constructor(obj, parent) {
|
|
21955
|
+
this.obj = obj;
|
|
21956
|
+
this.parent = parent;
|
|
21957
|
+
}
|
|
21958
|
+
/**
|
|
21959
|
+
* @param {object|any[]} obj
|
|
21960
|
+
* @returns {boolean}
|
|
21961
|
+
*/
|
|
21962
|
+
includes(obj) {
|
|
21963
|
+
let p = this;
|
|
21964
|
+
do {
|
|
21965
|
+
if (p.obj === obj) {
|
|
21966
|
+
return true;
|
|
21967
|
+
}
|
|
21968
|
+
} while (p = p.parent);
|
|
21969
|
+
return false;
|
|
21970
|
+
}
|
|
21971
|
+
/**
|
|
21972
|
+
* @param {Reference|undefined} stack
|
|
21973
|
+
* @param {object|any[]} obj
|
|
21974
|
+
* @returns {Reference}
|
|
21975
|
+
*/
|
|
21976
|
+
static createCheck(stack, obj) {
|
|
21977
|
+
if (stack && stack.includes(obj)) {
|
|
21978
|
+
throw new Error(`${encodeErrPrefix} object contains circular references`);
|
|
21979
|
+
}
|
|
21980
|
+
return new _Ref(obj, stack);
|
|
21981
|
+
}
|
|
21982
|
+
};
|
|
21983
|
+
var simpleTokens = {
|
|
21984
|
+
null: new Token(Type.null, null),
|
|
21985
|
+
undefined: new Token(Type.undefined, void 0),
|
|
21986
|
+
true: new Token(Type.true, true),
|
|
21987
|
+
false: new Token(Type.false, false),
|
|
21988
|
+
emptyArray: new Token(Type.array, 0),
|
|
21989
|
+
emptyMap: new Token(Type.map, 0)
|
|
21990
|
+
};
|
|
21991
|
+
var typeEncoders = {
|
|
21992
|
+
/**
|
|
21993
|
+
* @param {any} obj
|
|
21994
|
+
* @param {string} _typ
|
|
21995
|
+
* @param {EncodeOptions} _options
|
|
21996
|
+
* @param {Reference} [_refStack]
|
|
21997
|
+
* @returns {TokenOrNestedTokens}
|
|
21998
|
+
*/
|
|
21999
|
+
number(obj, _typ, _options, _refStack) {
|
|
22000
|
+
if (!Number.isInteger(obj) || !Number.isSafeInteger(obj)) {
|
|
22001
|
+
return new Token(Type.float, obj);
|
|
22002
|
+
} else if (obj >= 0) {
|
|
22003
|
+
return new Token(Type.uint, obj);
|
|
22004
|
+
} else {
|
|
22005
|
+
return new Token(Type.negint, obj);
|
|
22006
|
+
}
|
|
22007
|
+
},
|
|
22008
|
+
/**
|
|
22009
|
+
* @param {any} obj
|
|
22010
|
+
* @param {string} _typ
|
|
22011
|
+
* @param {EncodeOptions} _options
|
|
22012
|
+
* @param {Reference} [_refStack]
|
|
22013
|
+
* @returns {TokenOrNestedTokens}
|
|
22014
|
+
*/
|
|
22015
|
+
bigint(obj, _typ, _options, _refStack) {
|
|
22016
|
+
if (obj >= BigInt(0)) {
|
|
22017
|
+
return new Token(Type.uint, obj);
|
|
22018
|
+
} else {
|
|
22019
|
+
return new Token(Type.negint, obj);
|
|
22020
|
+
}
|
|
22021
|
+
},
|
|
22022
|
+
/**
|
|
22023
|
+
* @param {any} obj
|
|
22024
|
+
* @param {string} _typ
|
|
22025
|
+
* @param {EncodeOptions} _options
|
|
22026
|
+
* @param {Reference} [_refStack]
|
|
22027
|
+
* @returns {TokenOrNestedTokens}
|
|
22028
|
+
*/
|
|
22029
|
+
Uint8Array(obj, _typ, _options, _refStack) {
|
|
22030
|
+
return new Token(Type.bytes, obj);
|
|
22031
|
+
},
|
|
22032
|
+
/**
|
|
22033
|
+
* @param {any} obj
|
|
22034
|
+
* @param {string} _typ
|
|
22035
|
+
* @param {EncodeOptions} _options
|
|
22036
|
+
* @param {Reference} [_refStack]
|
|
22037
|
+
* @returns {TokenOrNestedTokens}
|
|
22038
|
+
*/
|
|
22039
|
+
string(obj, _typ, _options, _refStack) {
|
|
22040
|
+
return new Token(Type.string, obj);
|
|
22041
|
+
},
|
|
22042
|
+
/**
|
|
22043
|
+
* @param {any} obj
|
|
22044
|
+
* @param {string} _typ
|
|
22045
|
+
* @param {EncodeOptions} _options
|
|
22046
|
+
* @param {Reference} [_refStack]
|
|
22047
|
+
* @returns {TokenOrNestedTokens}
|
|
22048
|
+
*/
|
|
22049
|
+
boolean(obj, _typ, _options, _refStack) {
|
|
22050
|
+
return obj ? simpleTokens.true : simpleTokens.false;
|
|
22051
|
+
},
|
|
22052
|
+
/**
|
|
22053
|
+
* @param {any} _obj
|
|
22054
|
+
* @param {string} _typ
|
|
22055
|
+
* @param {EncodeOptions} _options
|
|
22056
|
+
* @param {Reference} [_refStack]
|
|
22057
|
+
* @returns {TokenOrNestedTokens}
|
|
22058
|
+
*/
|
|
22059
|
+
null(_obj, _typ, _options, _refStack) {
|
|
22060
|
+
return simpleTokens.null;
|
|
22061
|
+
},
|
|
22062
|
+
/**
|
|
22063
|
+
* @param {any} _obj
|
|
22064
|
+
* @param {string} _typ
|
|
22065
|
+
* @param {EncodeOptions} _options
|
|
22066
|
+
* @param {Reference} [_refStack]
|
|
22067
|
+
* @returns {TokenOrNestedTokens}
|
|
22068
|
+
*/
|
|
22069
|
+
undefined(_obj, _typ, _options, _refStack) {
|
|
22070
|
+
return simpleTokens.undefined;
|
|
22071
|
+
},
|
|
22072
|
+
/**
|
|
22073
|
+
* @param {any} obj
|
|
22074
|
+
* @param {string} _typ
|
|
22075
|
+
* @param {EncodeOptions} _options
|
|
22076
|
+
* @param {Reference} [_refStack]
|
|
22077
|
+
* @returns {TokenOrNestedTokens}
|
|
22078
|
+
*/
|
|
22079
|
+
ArrayBuffer(obj, _typ, _options, _refStack) {
|
|
22080
|
+
return new Token(Type.bytes, new Uint8Array(obj));
|
|
22081
|
+
},
|
|
22082
|
+
/**
|
|
22083
|
+
* @param {any} obj
|
|
22084
|
+
* @param {string} _typ
|
|
22085
|
+
* @param {EncodeOptions} _options
|
|
22086
|
+
* @param {Reference} [_refStack]
|
|
22087
|
+
* @returns {TokenOrNestedTokens}
|
|
22088
|
+
*/
|
|
22089
|
+
DataView(obj, _typ, _options, _refStack) {
|
|
22090
|
+
return new Token(Type.bytes, new Uint8Array(obj.buffer, obj.byteOffset, obj.byteLength));
|
|
22091
|
+
},
|
|
22092
|
+
/**
|
|
22093
|
+
* @param {any} obj
|
|
22094
|
+
* @param {string} _typ
|
|
22095
|
+
* @param {EncodeOptions} options
|
|
22096
|
+
* @param {Reference} [refStack]
|
|
22097
|
+
* @returns {TokenOrNestedTokens}
|
|
22098
|
+
*/
|
|
22099
|
+
Array(obj, _typ, options, refStack) {
|
|
22100
|
+
if (!obj.length) {
|
|
22101
|
+
if (options.addBreakTokens === true) {
|
|
22102
|
+
return [simpleTokens.emptyArray, new Token(Type.break)];
|
|
22103
|
+
}
|
|
22104
|
+
return simpleTokens.emptyArray;
|
|
22105
|
+
}
|
|
22106
|
+
refStack = Ref.createCheck(refStack, obj);
|
|
22107
|
+
const entries = [];
|
|
22108
|
+
let i = 0;
|
|
22109
|
+
for (const e of obj) {
|
|
22110
|
+
entries[i++] = objectToTokens(e, options, refStack);
|
|
22111
|
+
}
|
|
22112
|
+
if (options.addBreakTokens) {
|
|
22113
|
+
return [new Token(Type.array, obj.length), entries, new Token(Type.break)];
|
|
22114
|
+
}
|
|
22115
|
+
return [new Token(Type.array, obj.length), entries];
|
|
22116
|
+
},
|
|
22117
|
+
/**
|
|
22118
|
+
* @param {any} obj
|
|
22119
|
+
* @param {string} typ
|
|
22120
|
+
* @param {EncodeOptions} options
|
|
22121
|
+
* @param {Reference} [refStack]
|
|
22122
|
+
* @returns {TokenOrNestedTokens}
|
|
22123
|
+
*/
|
|
22124
|
+
Object(obj, typ, options, refStack) {
|
|
22125
|
+
const isMap = typ !== "Object";
|
|
22126
|
+
const keys = isMap ? obj.keys() : Object.keys(obj);
|
|
22127
|
+
const maxLength = isMap ? obj.size : keys.length;
|
|
22128
|
+
let entries;
|
|
22129
|
+
if (maxLength) {
|
|
22130
|
+
entries = new Array(maxLength);
|
|
22131
|
+
refStack = Ref.createCheck(refStack, obj);
|
|
22132
|
+
const skipUndefined = !isMap && options.ignoreUndefinedProperties;
|
|
22133
|
+
let i = 0;
|
|
22134
|
+
for (const key of keys) {
|
|
22135
|
+
const value = isMap ? obj.get(key) : obj[key];
|
|
22136
|
+
if (skipUndefined && value === void 0) {
|
|
22137
|
+
continue;
|
|
22138
|
+
}
|
|
22139
|
+
entries[i++] = [
|
|
22140
|
+
objectToTokens(key, options, refStack),
|
|
22141
|
+
objectToTokens(value, options, refStack)
|
|
22142
|
+
];
|
|
22143
|
+
}
|
|
22144
|
+
if (i < maxLength) {
|
|
22145
|
+
entries.length = i;
|
|
22146
|
+
}
|
|
22147
|
+
}
|
|
22148
|
+
if (!entries?.length) {
|
|
22149
|
+
if (options.addBreakTokens === true) {
|
|
22150
|
+
return [simpleTokens.emptyMap, new Token(Type.break)];
|
|
22151
|
+
}
|
|
22152
|
+
return simpleTokens.emptyMap;
|
|
22153
|
+
}
|
|
22154
|
+
sortMapEntries(entries, options);
|
|
22155
|
+
if (options.addBreakTokens) {
|
|
22156
|
+
return [new Token(Type.map, entries.length), entries, new Token(Type.break)];
|
|
22157
|
+
}
|
|
22158
|
+
return [new Token(Type.map, entries.length), entries];
|
|
22159
|
+
},
|
|
22160
|
+
/**
|
|
22161
|
+
* Encode a `Tagged` wrapper as a CBOR tag header followed by the encoded
|
|
22162
|
+
* form of the wrapped value. The value is recursively tokenised through
|
|
22163
|
+
* `objectToTokens()` so any registered `typeEncoders` apply to it.
|
|
22164
|
+
*
|
|
22165
|
+
* @param {any} obj
|
|
22166
|
+
* @param {string} _typ
|
|
22167
|
+
* @param {EncodeOptions} options
|
|
22168
|
+
* @param {Reference} [refStack]
|
|
22169
|
+
* @returns {TokenOrNestedTokens}
|
|
22170
|
+
*/
|
|
22171
|
+
Tagged(obj, _typ, options, refStack) {
|
|
22172
|
+
return [
|
|
22173
|
+
new Token(Type.tag, obj.tag),
|
|
22174
|
+
objectToTokens(obj.value, options, refStack)
|
|
22175
|
+
];
|
|
22176
|
+
}
|
|
22177
|
+
};
|
|
22178
|
+
typeEncoders.Map = typeEncoders.Object;
|
|
22179
|
+
typeEncoders.Buffer = typeEncoders.Uint8Array;
|
|
22180
|
+
for (const typ of "Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" ")) {
|
|
22181
|
+
typeEncoders[`${typ}Array`] = typeEncoders.DataView;
|
|
22182
|
+
}
|
|
22183
|
+
function objectToTokens(obj, options = {}, refStack) {
|
|
22184
|
+
const typ = is(obj);
|
|
22185
|
+
const customTypeEncoder = options && options.typeEncoders && /** @type {OptionalTypeEncoder} */
|
|
22186
|
+
options.typeEncoders[typ] || typeEncoders[typ];
|
|
22187
|
+
if (typeof customTypeEncoder === "function") {
|
|
22188
|
+
const tokens = customTypeEncoder(obj, typ, options, refStack);
|
|
22189
|
+
if (tokens != null) {
|
|
22190
|
+
return tokens;
|
|
22191
|
+
}
|
|
22192
|
+
}
|
|
22193
|
+
const typeEncoder = typeEncoders[typ];
|
|
22194
|
+
if (!typeEncoder) {
|
|
22195
|
+
throw new Error(`${encodeErrPrefix} unsupported type: ${typ}`);
|
|
22196
|
+
}
|
|
22197
|
+
return typeEncoder(obj, typ, options, refStack);
|
|
22198
|
+
}
|
|
22199
|
+
__name(objectToTokens, "objectToTokens");
|
|
22200
|
+
function sortMapEntries(entries, options) {
|
|
22201
|
+
const mapSorter2 = (
|
|
22202
|
+
/** @type {(e1: TokenOrNestedTokens, e2: TokenOrNestedTokens, options?: EncodeOptions) => number} */
|
|
22203
|
+
options.mapSorter
|
|
22204
|
+
);
|
|
22205
|
+
if (mapSorter2) {
|
|
22206
|
+
entries.sort((e1, e2) => mapSorter2(e1, e2, options));
|
|
22207
|
+
}
|
|
22208
|
+
}
|
|
22209
|
+
__name(sortMapEntries, "sortMapEntries");
|
|
22210
|
+
function mapSorter(e1, e2, options) {
|
|
22211
|
+
const keyToken1 = Array.isArray(e1[0]) ? e1[0][0] : e1[0];
|
|
22212
|
+
const keyToken2 = Array.isArray(e2[0]) ? e2[0][0] : e2[0];
|
|
22213
|
+
if (keyToken1.type.major !== keyToken2.type.major) {
|
|
22214
|
+
return keyToken1.type.compare(keyToken2.type);
|
|
22215
|
+
}
|
|
22216
|
+
const major = keyToken1.type.major;
|
|
22217
|
+
const tcmp = cborEncoders[major].compareTokens(keyToken1, keyToken2, options);
|
|
22218
|
+
if (tcmp === 0) {
|
|
22219
|
+
console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone");
|
|
22220
|
+
}
|
|
22221
|
+
return tcmp;
|
|
22222
|
+
}
|
|
22223
|
+
__name(mapSorter, "mapSorter");
|
|
22224
|
+
function rfc8949MapSorter(e1, e2) {
|
|
22225
|
+
if (e1[0] instanceof Token && e2[0] instanceof Token) {
|
|
22226
|
+
const t1 = (
|
|
22227
|
+
/** @type {TokenEx} */
|
|
22228
|
+
e1[0]
|
|
22229
|
+
);
|
|
22230
|
+
const t2 = (
|
|
22231
|
+
/** @type {TokenEx} */
|
|
22232
|
+
e2[0]
|
|
22233
|
+
);
|
|
22234
|
+
if (!t1._keyBytes) {
|
|
22235
|
+
t1._keyBytes = encodeRfc8949(t1.value);
|
|
22236
|
+
}
|
|
22237
|
+
if (!t2._keyBytes) {
|
|
22238
|
+
t2._keyBytes = encodeRfc8949(t2.value);
|
|
22239
|
+
}
|
|
22240
|
+
return compare(t1._keyBytes, t2._keyBytes);
|
|
22241
|
+
}
|
|
22242
|
+
throw new Error("rfc8949MapSorter: complex key types are not supported yet");
|
|
22243
|
+
}
|
|
22244
|
+
__name(rfc8949MapSorter, "rfc8949MapSorter");
|
|
22245
|
+
function encodeRfc8949(data) {
|
|
22246
|
+
return encodeCustom(data, cborEncoders, rfc8949EncodeOptions);
|
|
22247
|
+
}
|
|
22248
|
+
__name(encodeRfc8949, "encodeRfc8949");
|
|
22249
|
+
function tokensToEncoded(writer, tokens, encoders, options) {
|
|
22250
|
+
if (Array.isArray(tokens)) {
|
|
22251
|
+
for (const token of tokens) {
|
|
22252
|
+
tokensToEncoded(writer, token, encoders, options);
|
|
22253
|
+
}
|
|
22254
|
+
} else {
|
|
22255
|
+
encoders[tokens.type.major](writer, tokens, options);
|
|
22256
|
+
}
|
|
22257
|
+
}
|
|
22258
|
+
__name(tokensToEncoded, "tokensToEncoded");
|
|
22259
|
+
var MAJOR_UINT = Type.uint.majorEncoded;
|
|
22260
|
+
var MAJOR_NEGINT = Type.negint.majorEncoded;
|
|
22261
|
+
var MAJOR_BYTES = Type.bytes.majorEncoded;
|
|
22262
|
+
var MAJOR_STRING = Type.string.majorEncoded;
|
|
22263
|
+
var MAJOR_ARRAY = Type.array.majorEncoded;
|
|
22264
|
+
var MAJOR_MAP = Type.map.majorEncoded;
|
|
22265
|
+
var SIMPLE_FALSE = Type.float.majorEncoded | MINOR_FALSE;
|
|
22266
|
+
var SIMPLE_TRUE = Type.float.majorEncoded | MINOR_TRUE;
|
|
22267
|
+
var SIMPLE_NULL = Type.float.majorEncoded | MINOR_NULL;
|
|
22268
|
+
var SIMPLE_UNDEFINED = Type.float.majorEncoded | MINOR_UNDEFINED;
|
|
22269
|
+
var neg1b2 = BigInt(-1);
|
|
22270
|
+
var pos1b2 = BigInt(1);
|
|
22271
|
+
function directEncodeUintValue(writer, major, uint) {
|
|
22272
|
+
if (uint < 24) {
|
|
22273
|
+
writer.pushByte(major | Number(uint));
|
|
22274
|
+
} else {
|
|
22275
|
+
encodeUintValue(writer, major, uint);
|
|
22276
|
+
}
|
|
22277
|
+
}
|
|
22278
|
+
__name(directEncodeUintValue, "directEncodeUintValue");
|
|
22279
|
+
function canDirectEncode(options) {
|
|
22280
|
+
return options.addBreakTokens !== true;
|
|
22281
|
+
}
|
|
22282
|
+
__name(canDirectEncode, "canDirectEncode");
|
|
22283
|
+
function directEncodeMap(writer, data, typ, options, refStack) {
|
|
22284
|
+
const isMap = typ === "Map";
|
|
22285
|
+
const keys = isMap ? data.keys() : Object.keys(data);
|
|
22286
|
+
const maxLength = isMap ? data.size : keys.length;
|
|
22287
|
+
if (!maxLength) {
|
|
22288
|
+
writer.pushByte(MAJOR_MAP);
|
|
22289
|
+
return;
|
|
22290
|
+
}
|
|
22291
|
+
refStack = Ref.createCheck(refStack, data);
|
|
22292
|
+
const skipUndefined = !isMap && options.ignoreUndefinedProperties;
|
|
22293
|
+
const entries = new Array(maxLength);
|
|
22294
|
+
let length = 0;
|
|
22295
|
+
for (const key of keys) {
|
|
22296
|
+
const value = isMap ? data.get(key) : data[key];
|
|
22297
|
+
if (skipUndefined && value === void 0) {
|
|
22298
|
+
continue;
|
|
22299
|
+
}
|
|
22300
|
+
entries[length++] = [objectToTokens(key, options, refStack), value];
|
|
22301
|
+
}
|
|
22302
|
+
if (length === 0) {
|
|
22303
|
+
writer.pushByte(MAJOR_MAP);
|
|
22304
|
+
return;
|
|
22305
|
+
}
|
|
22306
|
+
if (length < maxLength) {
|
|
22307
|
+
entries.length = length;
|
|
22308
|
+
}
|
|
22309
|
+
entries.sort((e1, e2) => mapSorter(e1, e2, options));
|
|
22310
|
+
directEncodeUintValue(writer, MAJOR_MAP, length);
|
|
22311
|
+
for (const [key, value] of entries) {
|
|
22312
|
+
tokensToEncoded(writer, key, cborEncoders, options);
|
|
22313
|
+
directEncode(writer, value, options, refStack);
|
|
22314
|
+
}
|
|
22315
|
+
}
|
|
22316
|
+
__name(directEncodeMap, "directEncodeMap");
|
|
22317
|
+
function directEncode(writer, data, options, refStack) {
|
|
22318
|
+
const typ = is(data);
|
|
22319
|
+
const customEncoder = options.typeEncoders && options.typeEncoders[typ];
|
|
22320
|
+
if (customEncoder) {
|
|
22321
|
+
const tokens = customEncoder(data, typ, options, refStack);
|
|
22322
|
+
if (tokens != null) {
|
|
22323
|
+
tokensToEncoded(writer, tokens, cborEncoders, options);
|
|
22324
|
+
return;
|
|
22325
|
+
}
|
|
22326
|
+
}
|
|
22327
|
+
switch (typ) {
|
|
22328
|
+
case "null":
|
|
22329
|
+
writer.pushByte(SIMPLE_NULL);
|
|
22330
|
+
return;
|
|
22331
|
+
case "undefined":
|
|
22332
|
+
writer.pushByte(SIMPLE_UNDEFINED);
|
|
22333
|
+
return;
|
|
22334
|
+
case "boolean":
|
|
22335
|
+
writer.pushByte(data ? SIMPLE_TRUE : SIMPLE_FALSE);
|
|
22336
|
+
return;
|
|
22337
|
+
case "number":
|
|
22338
|
+
if (!Number.isInteger(data) || !Number.isSafeInteger(data)) {
|
|
22339
|
+
encodeFloat(writer, new Token(Type.float, data), options);
|
|
22340
|
+
} else if (data >= 0) {
|
|
22341
|
+
directEncodeUintValue(writer, MAJOR_UINT, data);
|
|
22342
|
+
} else {
|
|
22343
|
+
directEncodeUintValue(writer, MAJOR_NEGINT, data * -1 - 1);
|
|
22344
|
+
}
|
|
22345
|
+
return;
|
|
22346
|
+
case "bigint":
|
|
22347
|
+
if (data >= BigInt(0)) {
|
|
22348
|
+
directEncodeUintValue(writer, MAJOR_UINT, data);
|
|
22349
|
+
} else {
|
|
22350
|
+
directEncodeUintValue(writer, MAJOR_NEGINT, data * neg1b2 - pos1b2);
|
|
22351
|
+
}
|
|
22352
|
+
return;
|
|
22353
|
+
case "string": {
|
|
22354
|
+
const bytes2 = fromString(data);
|
|
22355
|
+
directEncodeUintValue(writer, MAJOR_STRING, bytes2.length);
|
|
22356
|
+
writer.push(bytes2);
|
|
22357
|
+
return;
|
|
22358
|
+
}
|
|
22359
|
+
case "Uint8Array":
|
|
22360
|
+
directEncodeUintValue(writer, MAJOR_BYTES, data.length);
|
|
22361
|
+
writer.push(data);
|
|
22362
|
+
return;
|
|
22363
|
+
case "Array":
|
|
22364
|
+
if (!data.length) {
|
|
22365
|
+
writer.pushByte(MAJOR_ARRAY);
|
|
22366
|
+
return;
|
|
22367
|
+
}
|
|
22368
|
+
refStack = Ref.createCheck(refStack, data);
|
|
22369
|
+
directEncodeUintValue(writer, MAJOR_ARRAY, data.length);
|
|
22370
|
+
for (const elem of data) {
|
|
22371
|
+
directEncode(writer, elem, options, refStack);
|
|
22372
|
+
}
|
|
22373
|
+
return;
|
|
22374
|
+
case "Object":
|
|
22375
|
+
case "Map":
|
|
22376
|
+
if (options.mapSorter === mapSorter) {
|
|
22377
|
+
directEncodeMap(writer, data, typ, options, refStack);
|
|
22378
|
+
} else {
|
|
22379
|
+
const tokens = typeEncoders.Object(data, typ, options, refStack);
|
|
22380
|
+
tokensToEncoded(writer, tokens, cborEncoders, options);
|
|
22381
|
+
}
|
|
22382
|
+
return;
|
|
22383
|
+
default: {
|
|
22384
|
+
const typeEncoder = typeEncoders[typ];
|
|
22385
|
+
if (!typeEncoder) {
|
|
22386
|
+
throw new Error(`${encodeErrPrefix} unsupported type: ${typ}`);
|
|
22387
|
+
}
|
|
22388
|
+
const tokens = typeEncoder(data, typ, options, refStack);
|
|
22389
|
+
tokensToEncoded(writer, tokens, cborEncoders, options);
|
|
22390
|
+
}
|
|
22391
|
+
}
|
|
22392
|
+
}
|
|
22393
|
+
__name(directEncode, "directEncode");
|
|
22394
|
+
function encodeCustom(data, encoders, options, destination) {
|
|
22395
|
+
const hasDest = destination instanceof Uint8Array;
|
|
22396
|
+
let writeTo = hasDest ? new U8Bl(destination) : defaultWriter;
|
|
22397
|
+
const tokens = objectToTokens(data, options);
|
|
22398
|
+
if (!Array.isArray(tokens) && options.quickEncodeToken) {
|
|
22399
|
+
const quickBytes = options.quickEncodeToken(tokens);
|
|
22400
|
+
if (quickBytes) {
|
|
22401
|
+
if (hasDest) {
|
|
22402
|
+
writeTo.push(quickBytes);
|
|
22403
|
+
return writeTo.toBytes();
|
|
22404
|
+
}
|
|
22405
|
+
return quickBytes;
|
|
22406
|
+
}
|
|
22407
|
+
const encoder = encoders[tokens.type.major];
|
|
22408
|
+
if (encoder.encodedSize) {
|
|
22409
|
+
const size = encoder.encodedSize(tokens, options);
|
|
22410
|
+
if (!hasDest) {
|
|
22411
|
+
writeTo = new Bl(size);
|
|
22412
|
+
}
|
|
22413
|
+
encoder(writeTo, tokens, options);
|
|
22414
|
+
if (writeTo.chunks.length !== 1) {
|
|
22415
|
+
throw new Error(`Unexpected error: pre-calculated length for ${tokens} was wrong`);
|
|
22416
|
+
}
|
|
22417
|
+
return hasDest ? writeTo.toBytes() : asU8A(writeTo.chunks[0]);
|
|
22418
|
+
}
|
|
22419
|
+
}
|
|
22420
|
+
writeTo.reset();
|
|
22421
|
+
tokensToEncoded(writeTo, tokens, encoders, options);
|
|
22422
|
+
return writeTo.toBytes(true);
|
|
22423
|
+
}
|
|
22424
|
+
__name(encodeCustom, "encodeCustom");
|
|
22425
|
+
function encode(data, options) {
|
|
22426
|
+
options = Object.assign({}, defaultEncodeOptions, options);
|
|
22427
|
+
if (canDirectEncode(options)) {
|
|
22428
|
+
defaultWriter.reset();
|
|
22429
|
+
directEncode(defaultWriter, data, options, void 0);
|
|
22430
|
+
return defaultWriter.toBytes(true);
|
|
22431
|
+
}
|
|
22432
|
+
return encodeCustom(data, cborEncoders, options);
|
|
22433
|
+
}
|
|
22434
|
+
__name(encode, "encode");
|
|
22435
|
+
|
|
22436
|
+
// ../../node_modules/cborg/lib/decode.js
|
|
22437
|
+
var defaultDecodeOptions = {
|
|
22438
|
+
strict: false,
|
|
22439
|
+
allowIndefinite: true,
|
|
22440
|
+
allowUndefined: true,
|
|
22441
|
+
allowBigInt: true
|
|
22442
|
+
};
|
|
22443
|
+
var Tokeniser = class {
|
|
22444
|
+
static {
|
|
22445
|
+
__name(this, "Tokeniser");
|
|
22446
|
+
}
|
|
22447
|
+
/**
|
|
22448
|
+
* @param {Uint8Array} data
|
|
22449
|
+
* @param {DecodeOptions} options
|
|
22450
|
+
*/
|
|
22451
|
+
constructor(data, options = {}) {
|
|
22452
|
+
this._pos = 0;
|
|
22453
|
+
this.data = data;
|
|
22454
|
+
this.options = options;
|
|
22455
|
+
}
|
|
22456
|
+
pos() {
|
|
22457
|
+
return this._pos;
|
|
22458
|
+
}
|
|
22459
|
+
done() {
|
|
22460
|
+
return this._pos >= this.data.length;
|
|
22461
|
+
}
|
|
22462
|
+
next() {
|
|
22463
|
+
const byt = this.data[this._pos];
|
|
22464
|
+
let token = quick[byt];
|
|
22465
|
+
if (token === void 0) {
|
|
22466
|
+
const decoder = jump[byt];
|
|
22467
|
+
if (!decoder) {
|
|
22468
|
+
throw new Error(`${decodeErrPrefix} no decoder for major type ${byt >>> 5} (byte 0x${byt.toString(16).padStart(2, "0")})`);
|
|
22469
|
+
}
|
|
22470
|
+
const minor = byt & 31;
|
|
22471
|
+
token = decoder(this.data, this._pos, minor, this.options);
|
|
22472
|
+
}
|
|
22473
|
+
this._pos += token.encodedLength;
|
|
22474
|
+
return token;
|
|
22475
|
+
}
|
|
22476
|
+
};
|
|
22477
|
+
var DONE = /* @__PURE__ */ Symbol.for("DONE");
|
|
22478
|
+
var BREAK = /* @__PURE__ */ Symbol.for("BREAK");
|
|
22479
|
+
function tokenToArray(token, tokeniser, options) {
|
|
22480
|
+
const arr = [];
|
|
22481
|
+
for (let i = 0; i < token.value; i++) {
|
|
22482
|
+
const value = tokensToObject(tokeniser, options);
|
|
22483
|
+
if (value === BREAK) {
|
|
22484
|
+
if (token.value === Infinity) {
|
|
22485
|
+
break;
|
|
22486
|
+
}
|
|
22487
|
+
throw new Error(`${decodeErrPrefix} got unexpected break to lengthed array`);
|
|
22488
|
+
}
|
|
22489
|
+
if (value === DONE) {
|
|
22490
|
+
throw new Error(`${decodeErrPrefix} found array but not enough entries (got ${i}, expected ${token.value})`);
|
|
22491
|
+
}
|
|
22492
|
+
arr[i] = value;
|
|
22493
|
+
}
|
|
22494
|
+
return arr;
|
|
22495
|
+
}
|
|
22496
|
+
__name(tokenToArray, "tokenToArray");
|
|
22497
|
+
function tokenToMap(token, tokeniser, options) {
|
|
22498
|
+
const useMaps = options.useMaps === true;
|
|
22499
|
+
const rejectDuplicateMapKeys = options.rejectDuplicateMapKeys === true;
|
|
22500
|
+
const obj = useMaps ? void 0 : {};
|
|
22501
|
+
const m = useMaps ? /* @__PURE__ */ new Map() : void 0;
|
|
22502
|
+
for (let i = 0; i < token.value; i++) {
|
|
22503
|
+
const key = tokensToObject(tokeniser, options);
|
|
22504
|
+
if (key === BREAK) {
|
|
22505
|
+
if (token.value === Infinity) {
|
|
22506
|
+
break;
|
|
22507
|
+
}
|
|
22508
|
+
throw new Error(`${decodeErrPrefix} got unexpected break to lengthed map`);
|
|
22509
|
+
}
|
|
22510
|
+
if (key === DONE) {
|
|
22511
|
+
throw new Error(`${decodeErrPrefix} found map but not enough entries (got ${i} [no key], expected ${token.value})`);
|
|
22512
|
+
}
|
|
22513
|
+
if (!useMaps && typeof key !== "string") {
|
|
22514
|
+
throw new Error(`${decodeErrPrefix} non-string keys not supported (got ${typeof key})`);
|
|
22515
|
+
}
|
|
22516
|
+
if (rejectDuplicateMapKeys) {
|
|
22517
|
+
if (useMaps && m.has(key) || !useMaps && Object.hasOwn(obj, key)) {
|
|
22518
|
+
throw new Error(`${decodeErrPrefix} found repeat map key "${key}"`);
|
|
22519
|
+
}
|
|
22520
|
+
}
|
|
22521
|
+
const value = tokensToObject(tokeniser, options);
|
|
22522
|
+
if (value === DONE) {
|
|
22523
|
+
throw new Error(`${decodeErrPrefix} found map but not enough entries (got ${i} [no value], expected ${token.value})`);
|
|
22524
|
+
}
|
|
22525
|
+
if (useMaps) {
|
|
22526
|
+
m.set(key, value);
|
|
22527
|
+
} else if (key === "__proto__") {
|
|
22528
|
+
Object.defineProperty(obj, key, { value, configurable: true, enumerable: true, writable: true });
|
|
22529
|
+
} else {
|
|
22530
|
+
obj[key] = value;
|
|
22531
|
+
}
|
|
22532
|
+
}
|
|
22533
|
+
return useMaps ? m : obj;
|
|
22534
|
+
}
|
|
22535
|
+
__name(tokenToMap, "tokenToMap");
|
|
22536
|
+
function* tokenToMapEntries(token, tokeniser, options) {
|
|
22537
|
+
for (let i = 0; i < token.value; i++) {
|
|
22538
|
+
const key = tokensToObject(tokeniser, options);
|
|
22539
|
+
if (key === BREAK) {
|
|
22540
|
+
if (token.value === Infinity) {
|
|
22541
|
+
break;
|
|
22542
|
+
}
|
|
22543
|
+
throw new Error(`${decodeErrPrefix} got unexpected break to lengthed map`);
|
|
22544
|
+
}
|
|
22545
|
+
if (key === DONE) {
|
|
22546
|
+
throw new Error(`${decodeErrPrefix} found map but not enough entries (got ${i} [no key], expected ${token.value})`);
|
|
22547
|
+
}
|
|
22548
|
+
const value = tokensToObject(tokeniser, options);
|
|
22549
|
+
if (value === DONE) {
|
|
22550
|
+
throw new Error(`${decodeErrPrefix} found map but not enough entries (got ${i} [no value], expected ${token.value})`);
|
|
22551
|
+
}
|
|
22552
|
+
yield [key, value];
|
|
22553
|
+
}
|
|
22554
|
+
}
|
|
22555
|
+
__name(tokenToMapEntries, "tokenToMapEntries");
|
|
22556
|
+
function createTagDecodeControl(tokeniser, options) {
|
|
22557
|
+
const decode2 = /* @__PURE__ */ __name(function() {
|
|
22558
|
+
if (decode2._called) {
|
|
22559
|
+
throw new Error(`${decodeErrPrefix} tag decode() may only be called once`);
|
|
22560
|
+
}
|
|
22561
|
+
decode2._called = true;
|
|
22562
|
+
const value = tokensToObject(tokeniser, options);
|
|
22563
|
+
if (value === DONE) {
|
|
22564
|
+
throw new Error(`${decodeErrPrefix} tag content missing`);
|
|
22565
|
+
}
|
|
22566
|
+
if (value === BREAK) {
|
|
22567
|
+
throw new Error(`${decodeErrPrefix} got unexpected break in tag content`);
|
|
22568
|
+
}
|
|
22569
|
+
return value;
|
|
22570
|
+
}, "decode");
|
|
22571
|
+
decode2.entries = function() {
|
|
22572
|
+
if (decode2._called) {
|
|
22573
|
+
throw new Error(`${decodeErrPrefix} tag decode() may only be called once`);
|
|
22574
|
+
}
|
|
22575
|
+
decode2._called = true;
|
|
22576
|
+
const token = tokeniser.next();
|
|
22577
|
+
if (!Type.equals(token.type, Type.map)) {
|
|
22578
|
+
throw new Error(`${decodeErrPrefix} entries() requires map content, got ${token.type.name}`);
|
|
22579
|
+
}
|
|
22580
|
+
const entries = [];
|
|
22581
|
+
for (const entry of tokenToMapEntries(token, tokeniser, options)) {
|
|
22582
|
+
entries.push(entry);
|
|
22583
|
+
}
|
|
22584
|
+
return entries;
|
|
22585
|
+
};
|
|
22586
|
+
decode2._called = false;
|
|
22587
|
+
return decode2;
|
|
22588
|
+
}
|
|
22589
|
+
__name(createTagDecodeControl, "createTagDecodeControl");
|
|
22590
|
+
function tokensToObject(tokeniser, options) {
|
|
22591
|
+
if (tokeniser.done()) {
|
|
22592
|
+
return DONE;
|
|
22593
|
+
}
|
|
22594
|
+
const token = tokeniser.next();
|
|
22595
|
+
if (Type.equals(token.type, Type.break)) {
|
|
22596
|
+
return BREAK;
|
|
22597
|
+
}
|
|
22598
|
+
if (token.type.terminal) {
|
|
22599
|
+
return token.value;
|
|
22600
|
+
}
|
|
22601
|
+
if (Type.equals(token.type, Type.array)) {
|
|
22602
|
+
return tokenToArray(token, tokeniser, options);
|
|
22603
|
+
}
|
|
22604
|
+
if (Type.equals(token.type, Type.map)) {
|
|
22605
|
+
return tokenToMap(token, tokeniser, options);
|
|
22606
|
+
}
|
|
22607
|
+
if (Type.equals(token.type, Type.tag)) {
|
|
22608
|
+
if (options.tags && typeof options.tags[token.value] === "function") {
|
|
22609
|
+
const decodeControl = createTagDecodeControl(tokeniser, options);
|
|
22610
|
+
const result = options.tags[token.value](decodeControl);
|
|
22611
|
+
if (!decodeControl._called) {
|
|
22612
|
+
throw new Error(`${decodeErrPrefix} tag decoder must call decode() or entries()`);
|
|
22613
|
+
}
|
|
22614
|
+
return result;
|
|
22615
|
+
}
|
|
22616
|
+
throw new Error(`${decodeErrPrefix} tag not supported (${token.value})`);
|
|
22617
|
+
}
|
|
22618
|
+
throw new Error("unsupported");
|
|
22619
|
+
}
|
|
22620
|
+
__name(tokensToObject, "tokensToObject");
|
|
22621
|
+
function decodeFirst(data, options) {
|
|
22622
|
+
if (!(data instanceof Uint8Array)) {
|
|
22623
|
+
throw new Error(`${decodeErrPrefix} data to decode must be a Uint8Array`);
|
|
22624
|
+
}
|
|
22625
|
+
options = Object.assign({}, defaultDecodeOptions, options);
|
|
22626
|
+
const u8aData = asU8A(data);
|
|
22627
|
+
const tokeniser = options.tokenizer || new Tokeniser(u8aData, options);
|
|
22628
|
+
const decoded = tokensToObject(tokeniser, options);
|
|
22629
|
+
if (decoded === DONE) {
|
|
22630
|
+
throw new Error(`${decodeErrPrefix} did not find any content to decode`);
|
|
22631
|
+
}
|
|
22632
|
+
if (decoded === BREAK) {
|
|
22633
|
+
throw new Error(`${decodeErrPrefix} got unexpected break`);
|
|
22634
|
+
}
|
|
22635
|
+
return [decoded, data.subarray(tokeniser.pos())];
|
|
22636
|
+
}
|
|
22637
|
+
__name(decodeFirst, "decodeFirst");
|
|
22638
|
+
function decode(data, options) {
|
|
22639
|
+
const [decoded, remainder] = decodeFirst(data, options);
|
|
22640
|
+
if (remainder.length > 0) {
|
|
22641
|
+
throw new Error(`${decodeErrPrefix} too many terminals, data makes no sense`);
|
|
22642
|
+
}
|
|
22643
|
+
return decoded;
|
|
22644
|
+
}
|
|
22645
|
+
__name(decode, "decode");
|
|
22646
|
+
|
|
22647
|
+
// ../../node_modules/cborg/lib/tagged.js
|
|
22648
|
+
var Tagged = class _Tagged {
|
|
22649
|
+
static {
|
|
22650
|
+
__name(this, "Tagged");
|
|
22651
|
+
}
|
|
22652
|
+
/**
|
|
22653
|
+
* @param {number} tag - CBOR tag number, a non-negative integer
|
|
22654
|
+
* @param {any} value - The value to be tagged; encoded recursively
|
|
22655
|
+
*/
|
|
22656
|
+
constructor(tag, value) {
|
|
22657
|
+
if (typeof tag !== "number" || !Number.isInteger(tag) || tag < 0) {
|
|
22658
|
+
throw new TypeError("Tagged: tag must be a non-negative integer");
|
|
22659
|
+
}
|
|
22660
|
+
this.tag = tag;
|
|
22661
|
+
this.value = value;
|
|
22662
|
+
}
|
|
22663
|
+
/**
|
|
22664
|
+
* Build a tag decoder for use in `decode()`'s `tags` option that returns the
|
|
22665
|
+
* decoded content wrapped in a `Tagged` instance, preserving the tag number
|
|
22666
|
+
* for the caller to inspect.
|
|
22667
|
+
*
|
|
22668
|
+
* @param {number} tag - The CBOR tag number this decoder will be registered for
|
|
22669
|
+
* @returns {TaggedTagDecoder}
|
|
22670
|
+
*
|
|
22671
|
+
* @example
|
|
22672
|
+
* import { decode, Tagged } from 'cborg'
|
|
22673
|
+
* const value = decode(bytes, { tags: { 16: Tagged.decoder(16) } })
|
|
22674
|
+
* // value instanceof Tagged; value.tag === 16
|
|
22675
|
+
*/
|
|
22676
|
+
static decoder(tag) {
|
|
22677
|
+
return (decode2) => new _Tagged(tag, decode2());
|
|
22678
|
+
}
|
|
22679
|
+
/**
|
|
22680
|
+
* Build a `tags` option for `decode()` that wraps each listed tag number in
|
|
22681
|
+
* a `Tagged` instance, preserving those tags through decode without
|
|
22682
|
+
* registering a dedicated decoder per tag.
|
|
22683
|
+
*
|
|
22684
|
+
* @param {...number} tagNumbers - One or more CBOR tag numbers to preserve
|
|
22685
|
+
* @returns {{[tagNumber: number]: TaggedTagDecoder}}
|
|
22686
|
+
*
|
|
22687
|
+
* @example
|
|
22688
|
+
* import { decode, Tagged } from 'cborg'
|
|
22689
|
+
* const value = decode(bytes, { tags: Tagged.preserve(16, 96) })
|
|
22690
|
+
*/
|
|
22691
|
+
static preserve(...tagNumbers) {
|
|
22692
|
+
const tags = {};
|
|
22693
|
+
for (const tag of tagNumbers) {
|
|
22694
|
+
tags[tag] = _Tagged.decoder(tag);
|
|
22695
|
+
}
|
|
22696
|
+
return tags;
|
|
22697
|
+
}
|
|
22698
|
+
};
|
|
22699
|
+
Object.defineProperty(Tagged.prototype, Symbol.toStringTag, {
|
|
22700
|
+
value: "Tagged"
|
|
22701
|
+
});
|
|
22702
|
+
|
|
22703
|
+
// src/escrow-nitro-attestation.ts
|
|
22704
|
+
var import_x509 = require("@peculiar/x509");
|
|
22705
|
+
var NitroAttestationError = class extends Error {
|
|
22706
|
+
constructor(reason) {
|
|
22707
|
+
super(`Nitro attestation rejected: ${reason}`);
|
|
22708
|
+
this.reason = reason;
|
|
22709
|
+
this.name = "NitroAttestationError";
|
|
22710
|
+
}
|
|
22711
|
+
static {
|
|
22712
|
+
__name(this, "NitroAttestationError");
|
|
22713
|
+
}
|
|
22714
|
+
};
|
|
22715
|
+
var AWS_ROOT_SHA256 = "641a0321a3e244efe456463195d606317ed7cdcc3c1756e09893f3c68f79bb5b";
|
|
22716
|
+
var fail = /* @__PURE__ */ __name((reason) => {
|
|
22717
|
+
throw new NitroAttestationError(reason);
|
|
22718
|
+
}, "fail");
|
|
22719
|
+
var hex = /* @__PURE__ */ __name((bytes2) => Array.from(bytes2, (byte) => byte.toString(16).padStart(2, "0")).join(""), "hex");
|
|
22720
|
+
var bytes = /* @__PURE__ */ __name((value, reason) => value instanceof Uint8Array && value.length > 0 ? value : fail(reason), "bytes");
|
|
22721
|
+
var map = /* @__PURE__ */ __name((value, reason) => value instanceof Map ? value : fail(reason), "map");
|
|
22722
|
+
var decodeCbor = /* @__PURE__ */ __name((value) => {
|
|
22723
|
+
try {
|
|
22724
|
+
return decode(value, {
|
|
22725
|
+
useMaps: true,
|
|
22726
|
+
rejectDuplicateMapKeys: true,
|
|
22727
|
+
allowIndefinite: false,
|
|
22728
|
+
allowUndefined: false,
|
|
22729
|
+
allowNaN: false,
|
|
22730
|
+
allowInfinity: false,
|
|
22731
|
+
allowBigInt: false
|
|
22732
|
+
});
|
|
22733
|
+
} catch {
|
|
22734
|
+
return fail("cbor");
|
|
22735
|
+
}
|
|
22736
|
+
}, "decodeCbor");
|
|
22737
|
+
var decodeUserData = /* @__PURE__ */ __name((userData) => {
|
|
22738
|
+
let decoded;
|
|
22739
|
+
try {
|
|
22740
|
+
decoded = decode(userData, {
|
|
22741
|
+
useMaps: true,
|
|
22742
|
+
rejectDuplicateMapKeys: true,
|
|
22743
|
+
allowIndefinite: false,
|
|
22744
|
+
allowUndefined: false,
|
|
22745
|
+
allowNaN: false,
|
|
22746
|
+
allowInfinity: false,
|
|
22747
|
+
allowBigInt: false
|
|
22748
|
+
});
|
|
22749
|
+
} catch {
|
|
22750
|
+
return void 0;
|
|
22751
|
+
}
|
|
22752
|
+
if (!(decoded instanceof Map) || decoded.size !== 3) return void 0;
|
|
22753
|
+
const spki = decoded.get(0);
|
|
22754
|
+
const keyId = decoded.get(1);
|
|
22755
|
+
const previousKeyIds = decoded.get(2);
|
|
22756
|
+
const isKeyId = /* @__PURE__ */ __name((value) => typeof value === "string" && /^[A-Za-z0-9._-]{1,128}$/.test(value), "isKeyId");
|
|
22757
|
+
if (!(spki instanceof Uint8Array) || spki.length === 0 || !isKeyId(keyId) || !Array.isArray(previousKeyIds) || previousKeyIds.length > 3 || !previousKeyIds.every(isKeyId)) {
|
|
22758
|
+
return void 0;
|
|
22759
|
+
}
|
|
22760
|
+
return { spki, keyId, previousKeyIds };
|
|
22761
|
+
}, "decodeUserData");
|
|
22762
|
+
var verifyNitroAttestationDocument = /* @__PURE__ */ __name(async (documentB64, {
|
|
22763
|
+
expectedNonce,
|
|
22764
|
+
policy,
|
|
22765
|
+
now = Date.now()
|
|
22766
|
+
}) => {
|
|
22767
|
+
let document;
|
|
22768
|
+
try {
|
|
22769
|
+
if (!documentB64 || documentB64.length > 65536 || !/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(documentB64))
|
|
22770
|
+
fail("cbor");
|
|
22771
|
+
document = base64ToBuffer(documentB64);
|
|
22772
|
+
} catch {
|
|
22773
|
+
return fail("cbor");
|
|
22774
|
+
}
|
|
22775
|
+
const cose = decodeCbor(document[0] === 210 ? document.subarray(1) : document);
|
|
22776
|
+
if (!Array.isArray(cose) || cose.length !== 4) fail("cose");
|
|
22777
|
+
const [protectedValue, unprotectedValue, payloadValue, signatureValue] = cose;
|
|
22778
|
+
const protectedBytes = bytes(protectedValue, "cose");
|
|
22779
|
+
const protectedHeader = map(decodeCbor(protectedBytes), "alg");
|
|
22780
|
+
if (protectedHeader.size !== 1 || protectedHeader.get(1) !== -35) fail("alg");
|
|
22781
|
+
if (map(unprotectedValue, "cose").size !== 0) fail("cose");
|
|
22782
|
+
const payloadBytes = bytes(payloadValue, "cose");
|
|
22783
|
+
const signature = bytes(signatureValue, "signature");
|
|
22784
|
+
if (signature.length !== 96) fail("signature");
|
|
22785
|
+
const payload = map(decodeCbor(payloadBytes), "cbor");
|
|
22786
|
+
const moduleId = payload.get("module_id");
|
|
22787
|
+
const timestamp = payload.get("timestamp");
|
|
22788
|
+
if (typeof moduleId !== "string" || !moduleId || payload.get("digest") !== "SHA384")
|
|
22789
|
+
fail("cbor");
|
|
22790
|
+
if (typeof timestamp !== "number" || !Number.isSafeInteger(timestamp) || timestamp < 0)
|
|
22791
|
+
fail("freshness");
|
|
22792
|
+
const leafDer = bytes(payload.get("certificate"), "chain");
|
|
22793
|
+
const bundle = payload.get("cabundle");
|
|
22794
|
+
if (!Array.isArray(bundle) || !bundle.length || bundle.length > 16) fail("chain");
|
|
22795
|
+
const ders = bundle.map((value) => bytes(value, "chain"));
|
|
22796
|
+
const rootHash = hex(
|
|
22797
|
+
new Uint8Array(await crypto.subtle.digest("SHA-256", new Uint8Array(ders[0])))
|
|
22798
|
+
);
|
|
22799
|
+
if (rootHash !== (policy.rootCertificateSha256 ?? AWS_ROOT_SHA256).toLowerCase()) fail("root");
|
|
22800
|
+
let leaf;
|
|
22801
|
+
try {
|
|
22802
|
+
const chain = [...ders, leafDer].map((der) => new import_x509.X509Certificate(new Uint8Array(der)));
|
|
22803
|
+
for (let i = 0; i < chain.length; i++) {
|
|
22804
|
+
const cert = chain[i];
|
|
22805
|
+
const issuer = chain[Math.max(0, i - 1)];
|
|
22806
|
+
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))
|
|
22807
|
+
fail("chain");
|
|
22808
|
+
if (i < chain.length - 1) {
|
|
22809
|
+
const constraints = cert.getExtension(import_x509.BasicConstraintsExtension);
|
|
22810
|
+
const usage = cert.getExtension(import_x509.KeyUsagesExtension);
|
|
22811
|
+
if (!constraints?.ca || constraints.pathLength !== void 0 && chain.length - i - 2 > constraints.pathLength || usage && !(usage.usages & import_x509.KeyUsageFlags.keyCertSign))
|
|
22812
|
+
fail("chain");
|
|
22813
|
+
}
|
|
22814
|
+
}
|
|
22815
|
+
leaf = chain[chain.length - 1];
|
|
22816
|
+
} catch {
|
|
22817
|
+
return fail("chain");
|
|
22818
|
+
}
|
|
22819
|
+
try {
|
|
22820
|
+
const key = await crypto.subtle.importKey(
|
|
22821
|
+
"spki",
|
|
22822
|
+
leaf.publicKey.rawData,
|
|
22823
|
+
{ name: "ECDSA", namedCurve: "P-384" },
|
|
22824
|
+
false,
|
|
22825
|
+
["verify"]
|
|
22826
|
+
);
|
|
22827
|
+
const structure = encode(["Signature1", protectedBytes, new Uint8Array(), payloadBytes]);
|
|
22828
|
+
if (!await crypto.subtle.verify(
|
|
22829
|
+
{ name: "ECDSA", hash: "SHA-384" },
|
|
22830
|
+
key,
|
|
22831
|
+
new Uint8Array(signature),
|
|
22832
|
+
new Uint8Array(structure)
|
|
22833
|
+
))
|
|
22834
|
+
fail("signature");
|
|
22835
|
+
} catch {
|
|
22836
|
+
return fail("signature");
|
|
22837
|
+
}
|
|
22838
|
+
const rawPcrs = map(payload.get("pcrs"), "pcr");
|
|
22839
|
+
const pcrs = {};
|
|
22840
|
+
for (const [index, value] of rawPcrs) {
|
|
22841
|
+
if (typeof index !== "number" || !Number.isInteger(index) || index < 0 || index > 31)
|
|
22842
|
+
fail("pcr");
|
|
22843
|
+
const pcr = bytes(value, "pcr");
|
|
22844
|
+
if (pcr.length !== 48) fail("pcr");
|
|
22845
|
+
pcrs[index] = hex(pcr);
|
|
22846
|
+
}
|
|
22847
|
+
if (pcrs[0] === "00".repeat(48)) fail("debug");
|
|
22848
|
+
if (!policy.pinnedMeasurements.some(
|
|
22849
|
+
(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]
|
|
22850
|
+
))
|
|
22851
|
+
fail("pcr");
|
|
22852
|
+
const nonce = bytes(payload.get("nonce"), "nonce");
|
|
22853
|
+
if (!(expectedNonce instanceof Uint8Array) || expectedNonce.length !== 32 || nonce.length !== expectedNonce.length)
|
|
22854
|
+
fail("nonce");
|
|
22855
|
+
let difference = 0;
|
|
22856
|
+
for (let i = 0; i < nonce.length; i++) difference |= nonce[i] ^ expectedNonce[i];
|
|
22857
|
+
if (difference !== 0) fail("nonce");
|
|
22858
|
+
const maxAge = policy.maxAgeMs ?? 3e5;
|
|
22859
|
+
if (!Number.isFinite(maxAge) || maxAge < 0 || now - timestamp > maxAge || timestamp > now + 6e4)
|
|
22860
|
+
fail("freshness");
|
|
22861
|
+
const userData = bytes(payload.get("user_data"), "user-data");
|
|
22862
|
+
const newFormat = decodeUserData(new Uint8Array(userData));
|
|
22863
|
+
const spki = newFormat ? newFormat.spki : userData;
|
|
22864
|
+
try {
|
|
22865
|
+
await crypto.subtle.importKey(
|
|
22866
|
+
"spki",
|
|
22867
|
+
new Uint8Array(spki),
|
|
22868
|
+
{ name: "ECDH", namedCurve: "P-256" },
|
|
22869
|
+
false,
|
|
22870
|
+
[]
|
|
22871
|
+
);
|
|
22872
|
+
} catch {
|
|
22873
|
+
return fail("user-data");
|
|
22874
|
+
}
|
|
22875
|
+
return {
|
|
22876
|
+
escrowPublicKeySpkiB64: bufferToBase64(new Uint8Array(spki).buffer),
|
|
22877
|
+
keyId: newFormat?.keyId,
|
|
22878
|
+
previousKeyIds: newFormat?.previousKeyIds ?? [],
|
|
22879
|
+
pcrs,
|
|
22880
|
+
timestamp,
|
|
22881
|
+
moduleId
|
|
22882
|
+
};
|
|
22883
|
+
}, "verifyNitroAttestationDocument");
|
|
22884
|
+
|
|
22885
|
+
// src/escrow-attestation.ts
|
|
22886
|
+
var isRecord3 = /* @__PURE__ */ __name((value) => typeof value === "object" && value !== null && !Array.isArray(value), "isRecord");
|
|
22887
|
+
var normalizePublicKey = /* @__PURE__ */ __name((value) => {
|
|
22888
|
+
const trimmed = value.trim();
|
|
22889
|
+
if (!trimmed || trimmed.length > 512 || !/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(trimmed)) {
|
|
22890
|
+
throw new Error("Invalid escrow attestation public key");
|
|
22891
|
+
}
|
|
22892
|
+
return bufferToBase64(base64ToBuffer(trimmed).buffer);
|
|
22893
|
+
}, "normalizePublicKey");
|
|
22894
|
+
var verifyEnclaveAttestation = /* @__PURE__ */ __name(async (attestation, policy, nonce) => {
|
|
22895
|
+
const isKeyId = /* @__PURE__ */ __name((value) => typeof value === "string" && /^[A-Za-z0-9._-]{1,128}$/.test(value), "isKeyId");
|
|
22896
|
+
const fields = [
|
|
22897
|
+
"mode",
|
|
22898
|
+
"keyId",
|
|
22899
|
+
"previousKeyIds",
|
|
22900
|
+
"publicKey",
|
|
22901
|
+
"measurements",
|
|
22902
|
+
"document",
|
|
22903
|
+
"issuedAt"
|
|
22904
|
+
];
|
|
22905
|
+
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(
|
|
22906
|
+
([key, value]) => !["imageSha384", "pcr0", "pcr1", "pcr2"].includes(key) || typeof value !== "string" || !value || value.length > 1024
|
|
22907
|
+
) || typeof attestation.document !== "string" || !attestation.document || attestation.document.length > 65536 || typeof attestation.issuedAt !== "string" || !Number.isFinite(Date.parse(attestation.issuedAt))) {
|
|
22908
|
+
throw new Error("Invalid escrow attestation");
|
|
22909
|
+
}
|
|
22910
|
+
const plaintextPreviousKeyIds = attestation.previousKeyIds ?? [];
|
|
22911
|
+
if (attestation.mode !== policy.mode) throw new Error("Escrow attestation mode mismatch");
|
|
22912
|
+
if (policy.mode === "nitro") {
|
|
22913
|
+
if (!nonce) throw new NitroAttestationError("nonce");
|
|
22914
|
+
const verified = await verifyNitroAttestationDocument(attestation.document, {
|
|
22915
|
+
expectedNonce: nonce,
|
|
22916
|
+
policy
|
|
22917
|
+
});
|
|
22918
|
+
try {
|
|
22919
|
+
if (normalizePublicKey(attestation.publicKey) !== verified.escrowPublicKeySpkiB64) {
|
|
22920
|
+
throw new NitroAttestationError("user-data");
|
|
22921
|
+
}
|
|
22922
|
+
} catch {
|
|
22923
|
+
throw new NitroAttestationError("user-data");
|
|
22924
|
+
}
|
|
22925
|
+
if (verified.keyId !== void 0 && verified.keyId !== attestation.keyId) {
|
|
22926
|
+
throw new NitroAttestationError("user-data");
|
|
22927
|
+
}
|
|
22928
|
+
if (plaintextPreviousKeyIds.length !== verified.previousKeyIds.length || !plaintextPreviousKeyIds.every((id, index) => id === verified.previousKeyIds[index])) {
|
|
22929
|
+
throw new NitroAttestationError("user-data");
|
|
22930
|
+
}
|
|
22931
|
+
return {
|
|
22932
|
+
publicKey: verified.escrowPublicKeySpkiB64,
|
|
22933
|
+
keyId: attestation.keyId,
|
|
22934
|
+
previousKeyIds: verified.previousKeyIds,
|
|
22935
|
+
mode: "nitro"
|
|
22936
|
+
};
|
|
22937
|
+
}
|
|
22938
|
+
const publicKey = normalizePublicKey(attestation.publicKey);
|
|
22939
|
+
await crypto.subtle.importKey(
|
|
22940
|
+
"spki",
|
|
22941
|
+
base64ToBuffer(publicKey),
|
|
22942
|
+
{ name: "ECDH", namedCurve: "P-256" },
|
|
22943
|
+
false,
|
|
22944
|
+
[]
|
|
22945
|
+
);
|
|
22946
|
+
if (!policy.pinnedPublicKeys.some((pin) => normalizePublicKey(pin) === publicKey)) {
|
|
22947
|
+
throw new Error("Escrow attestation public key is not trusted");
|
|
22948
|
+
}
|
|
22949
|
+
return {
|
|
22950
|
+
publicKey,
|
|
22951
|
+
keyId: attestation.keyId,
|
|
22952
|
+
previousKeyIds: plaintextPreviousKeyIds,
|
|
22953
|
+
mode: attestation.mode
|
|
22954
|
+
};
|
|
22955
|
+
}, "verifyEnclaveAttestation");
|
|
22956
|
+
|
|
22957
|
+
// src/types.ts
|
|
22958
|
+
var import_types = __toESM(require_dist());
|
|
22959
|
+
var EscrowPinUnavailableError = class extends Error {
|
|
22960
|
+
static {
|
|
22961
|
+
__name(this, "EscrowPinUnavailableError");
|
|
22962
|
+
}
|
|
22963
|
+
constructor() {
|
|
22964
|
+
super("PIN recovery is not available for this account.");
|
|
22965
|
+
this.name = "EscrowPinUnavailableError";
|
|
22966
|
+
}
|
|
22967
|
+
};
|
|
22968
|
+
var EscrowPinMismatchError = class extends Error {
|
|
22969
|
+
constructor(attemptsRemaining) {
|
|
22970
|
+
super("Incorrect PIN.");
|
|
22971
|
+
this.attemptsRemaining = attemptsRemaining;
|
|
22972
|
+
this.name = "EscrowPinMismatchError";
|
|
22973
|
+
}
|
|
22974
|
+
static {
|
|
22975
|
+
__name(this, "EscrowPinMismatchError");
|
|
22976
|
+
}
|
|
22977
|
+
};
|
|
22978
|
+
var EscrowPinThrottledError = class extends Error {
|
|
22979
|
+
static {
|
|
22980
|
+
__name(this, "EscrowPinThrottledError");
|
|
22981
|
+
}
|
|
22982
|
+
constructor() {
|
|
22983
|
+
super("Too many tries right now. Wait a minute and try again.");
|
|
22984
|
+
this.name = "EscrowPinThrottledError";
|
|
22985
|
+
}
|
|
22986
|
+
};
|
|
22987
|
+
var EscrowHoldRestartThrottledError = class extends Error {
|
|
22988
|
+
constructor(retryAfter) {
|
|
22989
|
+
super("A recovery request was started recently. Please wait before restarting.");
|
|
22990
|
+
this.retryAfter = retryAfter;
|
|
22991
|
+
this.name = "EscrowHoldRestartThrottledError";
|
|
22992
|
+
}
|
|
22993
|
+
static {
|
|
22994
|
+
__name(this, "EscrowHoldRestartThrottledError");
|
|
22995
|
+
}
|
|
22996
|
+
};
|
|
22997
|
+
var EscrowPinLockedError = class extends Error {
|
|
22998
|
+
static {
|
|
22999
|
+
__name(this, "EscrowPinLockedError");
|
|
23000
|
+
}
|
|
23001
|
+
constructor() {
|
|
23002
|
+
super("Too many incorrect PIN attempts. You can still recover by waiting.");
|
|
23003
|
+
this.name = "EscrowPinLockedError";
|
|
23004
|
+
}
|
|
23005
|
+
};
|
|
23006
|
+
|
|
23007
|
+
// src/escrow-pin.ts
|
|
23008
|
+
var PIN_MIN_LENGTH = 6;
|
|
23009
|
+
var PIN_MAX_LENGTH = 12;
|
|
23010
|
+
var ESCROW_PIN_MAX_ATTEMPTS = 10;
|
|
23011
|
+
var TRIVIAL_PINS = /* @__PURE__ */ new Set([
|
|
23012
|
+
"123456",
|
|
23013
|
+
"654321",
|
|
23014
|
+
"000000",
|
|
23015
|
+
"111111",
|
|
23016
|
+
"121212",
|
|
23017
|
+
"112233",
|
|
23018
|
+
"123123",
|
|
23019
|
+
"696969",
|
|
23020
|
+
"123321"
|
|
23021
|
+
]);
|
|
23022
|
+
var normalizePin = /* @__PURE__ */ __name((raw) => raw.trim().normalize("NFKD").replace(/\D/g, ""), "normalizePin");
|
|
23023
|
+
var validatePin = /* @__PURE__ */ __name((pin) => {
|
|
23024
|
+
const normalized = normalizePin(pin);
|
|
23025
|
+
if (normalized.length < PIN_MIN_LENGTH || normalized.length > PIN_MAX_LENGTH) {
|
|
23026
|
+
return { ok: false, reason: "length" };
|
|
23027
|
+
}
|
|
23028
|
+
if (/^(\d)\1+$/.test(normalized) || "0123456789".includes(normalized) || "9876543210".includes(normalized) || TRIVIAL_PINS.has(normalized)) {
|
|
23029
|
+
return { ok: false, reason: "trivial" };
|
|
23030
|
+
}
|
|
23031
|
+
return { ok: true };
|
|
23032
|
+
}, "validatePin");
|
|
23033
|
+
var generatePinSalt = /* @__PURE__ */ __name(() => bufferToBase64(crypto.getRandomValues(new Uint8Array(16)).buffer), "generatePinSalt");
|
|
23034
|
+
var derivePinProof = /* @__PURE__ */ __name(async (pin, pinSaltBase64) => {
|
|
23035
|
+
const salt = base64ToBuffer(pinSaltBase64);
|
|
23036
|
+
if (salt.length !== 16) throw new Error("Invalid escrow PIN salt length");
|
|
23037
|
+
const key = await deriveKeyFromPassword(normalizePin(pin), salt);
|
|
23038
|
+
try {
|
|
23039
|
+
return bytesToHex(key);
|
|
23040
|
+
} finally {
|
|
23041
|
+
key.fill(0);
|
|
23042
|
+
}
|
|
23043
|
+
}, "derivePinProof");
|
|
23044
|
+
var constantTimeEqualHex = /* @__PURE__ */ __name((a, b) => {
|
|
23045
|
+
if (a.length !== b.length || !/^(?:[0-9a-f]{2})+$/i.test(a) || !/^(?:[0-9a-f]{2})+$/i.test(b)) {
|
|
23046
|
+
return false;
|
|
23047
|
+
}
|
|
23048
|
+
const aBytes = hexToBytes(a);
|
|
23049
|
+
const bBytes = hexToBytes(b);
|
|
23050
|
+
let difference = 0;
|
|
23051
|
+
for (let i = 0; i < aBytes.length; i++) {
|
|
23052
|
+
difference |= aBytes[i] ^ bBytes[i];
|
|
23053
|
+
}
|
|
23054
|
+
return difference === 0;
|
|
23055
|
+
}, "constantTimeEqualHex");
|
|
23056
|
+
|
|
23057
|
+
// src/atomic-operations.ts
|
|
23058
|
+
var ShareVerificationError = class extends Error {
|
|
23059
|
+
constructor(message, combination, expected, got) {
|
|
23060
|
+
super(message);
|
|
23061
|
+
this.combination = combination;
|
|
23062
|
+
this.expected = expected;
|
|
23063
|
+
this.got = got;
|
|
23064
|
+
this.name = "ShareVerificationError";
|
|
23065
|
+
}
|
|
23066
|
+
static {
|
|
23067
|
+
__name(this, "ShareVerificationError");
|
|
23068
|
+
}
|
|
23069
|
+
};
|
|
23070
|
+
var AtomicUpdateError = class extends Error {
|
|
23071
|
+
constructor(message, phase, rolledBack, cause) {
|
|
23072
|
+
super(message);
|
|
23073
|
+
this.phase = phase;
|
|
23074
|
+
this.rolledBack = rolledBack;
|
|
23075
|
+
this.cause = cause;
|
|
23076
|
+
this.name = "AtomicUpdateError";
|
|
23077
|
+
}
|
|
23078
|
+
static {
|
|
23079
|
+
__name(this, "AtomicUpdateError");
|
|
23080
|
+
}
|
|
23081
|
+
};
|
|
23082
|
+
var ShareWriteRejectedError = class extends Error {
|
|
23083
|
+
static {
|
|
23084
|
+
__name(this, "ShareWriteRejectedError");
|
|
23085
|
+
}
|
|
23086
|
+
constructor(message) {
|
|
23087
|
+
super(message);
|
|
23088
|
+
this.name = "ShareWriteRejectedError";
|
|
23089
|
+
}
|
|
23090
|
+
};
|
|
23091
|
+
async function splitAndVerify(privateKey) {
|
|
23092
|
+
const shares = await splitPrivateKey(privateKey);
|
|
23093
|
+
const combinations = [
|
|
23094
|
+
["device+auth", shares.deviceShare, shares.authShare],
|
|
23095
|
+
["device+recovery", shares.deviceShare, shares.recoveryShare],
|
|
23096
|
+
["device+email", shares.deviceShare, shares.emailShare],
|
|
23097
|
+
["auth+recovery", shares.authShare, shares.recoveryShare],
|
|
23098
|
+
["auth+email", shares.authShare, shares.emailShare],
|
|
23099
|
+
["recovery+email", shares.recoveryShare, shares.emailShare]
|
|
23100
|
+
];
|
|
23101
|
+
for (const [name, share1, share2] of combinations) {
|
|
23102
|
+
const reconstructed = await reconstructFromShares([share1, share2]);
|
|
23103
|
+
if (reconstructed !== privateKey) {
|
|
23104
|
+
throw new ShareVerificationError(
|
|
23105
|
+
`Share verification failed for ${name}: reconstruction mismatch`,
|
|
23106
|
+
name,
|
|
23107
|
+
privateKey,
|
|
23108
|
+
reconstructed
|
|
23109
|
+
);
|
|
23110
|
+
}
|
|
23111
|
+
}
|
|
23112
|
+
return {
|
|
20466
23113
|
privateKey,
|
|
20467
23114
|
shares,
|
|
20468
23115
|
verified: true
|
|
@@ -21077,6 +23724,7 @@ function createSSSStrategy(config) {
|
|
|
21077
23724
|
let pendingIdentityRecovery;
|
|
21078
23725
|
let lastServerSnapshot = null;
|
|
21079
23726
|
let escrowEnrollmentInFlight;
|
|
23727
|
+
let staleEscrowReenrollAttempted = false;
|
|
21080
23728
|
let unenrolledRotation;
|
|
21081
23729
|
const escrowRequest = /* @__PURE__ */ __name(async (path, init, pinAttempt = false) => {
|
|
21082
23730
|
const response = await fetch(`${serverUrl}/keys/escrow${path}`, {
|
|
@@ -21124,11 +23772,16 @@ function createSSSStrategy(config) {
|
|
|
21124
23772
|
}, "escrowRequest");
|
|
21125
23773
|
const fetchVerifiedEnclaveKey = /* @__PURE__ */ __name(async () => {
|
|
21126
23774
|
if (!config.escrow?.enabled) throw new Error("Escrow enrollment is disabled");
|
|
21127
|
-
const
|
|
21128
|
-
|
|
21129
|
-
|
|
21130
|
-
|
|
21131
|
-
|
|
23775
|
+
const nonce = crypto.getRandomValues(new Uint8Array(32));
|
|
23776
|
+
const nonceHex = Array.from(nonce, (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
23777
|
+
const { attestation } = await escrowRequest(
|
|
23778
|
+
`/attestation?nonce=${nonceHex}`,
|
|
23779
|
+
{
|
|
23780
|
+
method: "GET",
|
|
23781
|
+
headers: buildHeaders("", void 0, tenantId)
|
|
23782
|
+
}
|
|
23783
|
+
);
|
|
23784
|
+
return verifyEnclaveAttestation(attestation, config.escrow.attestation, nonce);
|
|
21132
23785
|
}, "fetchVerifiedEnclaveKey");
|
|
21133
23786
|
const enrollEscrow = /* @__PURE__ */ __name(async (token, providerType, privateKey, primaryDid, shares, shareVersion, signDidAuthVp, verifiedKey, pinMaterial, clearPin = false) => {
|
|
21134
23787
|
if (!config.escrow?.enabled) throw new Error("Escrow enrollment is disabled");
|
|
@@ -21190,75 +23843,89 @@ function createSSSStrategy(config) {
|
|
|
21190
23843
|
}
|
|
21191
23844
|
const status = await self.fetchServerKeyStatus(params.token, params.providerType);
|
|
21192
23845
|
if (status.escrowOptedOut) return { enrolled: false, reason: "opted-out" };
|
|
21193
|
-
|
|
23846
|
+
const currentlyEnrolled = status.shareVersion !== null && status.recoveryMethods.some(
|
|
21194
23847
|
(method) => method.type === "escrow" && method.shareVersion === status.shareVersion && (Boolean(method.confirmedAt) || "confirmationStatus" in method && method.confirmationStatus === "confirmed")
|
|
21195
|
-
)
|
|
23848
|
+
);
|
|
23849
|
+
const repairingStaleBlob = pin === void 0 && !forceRotate && currentlyEnrolled && !!status.escrowStale && !staleEscrowReenrollAttempted;
|
|
23850
|
+
if (!forceRotate && pin === void 0 && currentlyEnrolled && !repairingStaleBlob)
|
|
21196
23851
|
return { enrolled: true, changed: false };
|
|
23852
|
+
if (repairingStaleBlob) staleEscrowReenrollAttempted = true;
|
|
21197
23853
|
if (!status.primaryDid) throw new Error("Cannot enroll escrow without a primary DID");
|
|
21198
23854
|
if (!params.signDidAuthVp) {
|
|
21199
23855
|
throw new Error("DID proof signing is required for escrow enrollment");
|
|
21200
23856
|
}
|
|
21201
|
-
|
|
21202
|
-
|
|
23857
|
+
try {
|
|
23858
|
+
if (!forceRotate && pin === void 0 && unenrolledRotation && unenrolledRotation.shareVersion === status.shareVersion && unenrolledRotation.primaryDid === status.primaryDid) {
|
|
23859
|
+
const retry = unenrolledRotation;
|
|
23860
|
+
await enrollEscrow(
|
|
23861
|
+
params.token,
|
|
23862
|
+
params.providerType,
|
|
23863
|
+
params.privateKey,
|
|
23864
|
+
retry.primaryDid,
|
|
23865
|
+
retry.shares,
|
|
23866
|
+
retry.shareVersion,
|
|
23867
|
+
params.signDidAuthVp,
|
|
23868
|
+
void 0,
|
|
23869
|
+
void 0,
|
|
23870
|
+
retry.clearPin
|
|
23871
|
+
);
|
|
23872
|
+
unenrolledRotation = void 0;
|
|
23873
|
+
return { enrolled: true, changed: true, shareVersion: retry.shareVersion };
|
|
23874
|
+
}
|
|
23875
|
+
const verifiedKey = await fetchVerifiedEnclaveKey();
|
|
23876
|
+
const pinSalt = pin !== void 0 ? generatePinSalt() : void 0;
|
|
23877
|
+
const pinMaterial = pin !== void 0 && pinSalt !== void 0 ? { pinSalt, pinVerifier: await derivePinProof(pin, pinSalt) } : void 0;
|
|
23878
|
+
const storageId = activeStorageId;
|
|
23879
|
+
const primaryDid = status.primaryDid;
|
|
23880
|
+
const { shares, shareVersion } = await withShareUpdateLock(
|
|
23881
|
+
storage2,
|
|
23882
|
+
storageId,
|
|
23883
|
+
() => persistSharesWithoutLock(
|
|
23884
|
+
params.privateKey,
|
|
23885
|
+
serverUrl,
|
|
23886
|
+
params.token,
|
|
23887
|
+
params.providerType,
|
|
23888
|
+
primaryDid,
|
|
23889
|
+
storage2,
|
|
23890
|
+
storageId,
|
|
23891
|
+
void 0,
|
|
23892
|
+
params.signDidAuthVp,
|
|
23893
|
+
tenantId
|
|
23894
|
+
)
|
|
23895
|
+
);
|
|
23896
|
+
lastEmailShare = shares.emailShare;
|
|
23897
|
+
lastShareVersion = shareVersion;
|
|
23898
|
+
lastServerSnapshot = {
|
|
23899
|
+
currentVersion: shareVersion,
|
|
23900
|
+
resolvedVersion: shareVersion,
|
|
23901
|
+
authShare: shares.authShare,
|
|
23902
|
+
primaryDid: status.primaryDid
|
|
23903
|
+
};
|
|
23904
|
+
unenrolledRotation = pinMaterial ? void 0 : { shares, shareVersion, primaryDid: status.primaryDid, clearPin: forceRotate };
|
|
21203
23905
|
await enrollEscrow(
|
|
21204
23906
|
params.token,
|
|
21205
23907
|
params.providerType,
|
|
21206
23908
|
params.privateKey,
|
|
21207
|
-
|
|
21208
|
-
|
|
21209
|
-
|
|
23909
|
+
status.primaryDid,
|
|
23910
|
+
shares,
|
|
23911
|
+
shareVersion,
|
|
21210
23912
|
params.signDidAuthVp,
|
|
21211
|
-
|
|
21212
|
-
|
|
21213
|
-
|
|
23913
|
+
verifiedKey,
|
|
23914
|
+
pinMaterial,
|
|
23915
|
+
forceRotate
|
|
21214
23916
|
);
|
|
21215
23917
|
unenrolledRotation = void 0;
|
|
21216
|
-
return { enrolled: true, changed: true, shareVersion
|
|
23918
|
+
return { enrolled: true, changed: true, shareVersion };
|
|
23919
|
+
} catch (err) {
|
|
23920
|
+
if (!repairingStaleBlob) throw err;
|
|
23921
|
+
try {
|
|
23922
|
+
if (config.onEscrowError) config.onEscrowError(err);
|
|
23923
|
+
else console.warn("SSS: escrow enrollment failed");
|
|
23924
|
+
} catch {
|
|
23925
|
+
console.warn("SSS: escrow error reporting failed");
|
|
23926
|
+
}
|
|
23927
|
+
return { enrolled: true, changed: false };
|
|
21217
23928
|
}
|
|
21218
|
-
const verifiedKey = await fetchVerifiedEnclaveKey();
|
|
21219
|
-
const pinSalt = pin !== void 0 ? generatePinSalt() : void 0;
|
|
21220
|
-
const pinMaterial = pin !== void 0 && pinSalt !== void 0 ? { pinSalt, pinVerifier: await derivePinProof(pin, pinSalt) } : void 0;
|
|
21221
|
-
const storageId = activeStorageId;
|
|
21222
|
-
const primaryDid = status.primaryDid;
|
|
21223
|
-
const { shares, shareVersion } = await withShareUpdateLock(
|
|
21224
|
-
storage2,
|
|
21225
|
-
storageId,
|
|
21226
|
-
() => persistSharesWithoutLock(
|
|
21227
|
-
params.privateKey,
|
|
21228
|
-
serverUrl,
|
|
21229
|
-
params.token,
|
|
21230
|
-
params.providerType,
|
|
21231
|
-
primaryDid,
|
|
21232
|
-
storage2,
|
|
21233
|
-
storageId,
|
|
21234
|
-
void 0,
|
|
21235
|
-
params.signDidAuthVp,
|
|
21236
|
-
tenantId
|
|
21237
|
-
)
|
|
21238
|
-
);
|
|
21239
|
-
lastEmailShare = shares.emailShare;
|
|
21240
|
-
lastShareVersion = shareVersion;
|
|
21241
|
-
lastServerSnapshot = {
|
|
21242
|
-
currentVersion: shareVersion,
|
|
21243
|
-
resolvedVersion: shareVersion,
|
|
21244
|
-
authShare: shares.authShare,
|
|
21245
|
-
primaryDid: status.primaryDid
|
|
21246
|
-
};
|
|
21247
|
-
unenrolledRotation = pinMaterial ? void 0 : { shares, shareVersion, primaryDid: status.primaryDid, clearPin: forceRotate };
|
|
21248
|
-
await enrollEscrow(
|
|
21249
|
-
params.token,
|
|
21250
|
-
params.providerType,
|
|
21251
|
-
params.privateKey,
|
|
21252
|
-
status.primaryDid,
|
|
21253
|
-
shares,
|
|
21254
|
-
shareVersion,
|
|
21255
|
-
params.signDidAuthVp,
|
|
21256
|
-
verifiedKey,
|
|
21257
|
-
pinMaterial,
|
|
21258
|
-
forceRotate
|
|
21259
|
-
);
|
|
21260
|
-
unenrolledRotation = void 0;
|
|
21261
|
-
return { enrolled: true, changed: true, shareVersion };
|
|
21262
23929
|
}, "ensureEscrowEnrollmentUnguarded");
|
|
21263
23930
|
const recordPromotion = /* @__PURE__ */ __name((primaryDid) => (snapshot) => {
|
|
21264
23931
|
lastEmailShare = void 0;
|
|
@@ -21575,6 +24242,7 @@ function createSSSStrategy(config) {
|
|
|
21575
24242
|
maskedRecoveryEmail: data.maskedRecoveryEmail ?? null,
|
|
21576
24243
|
escrowOptedOut: data.escrowOptedOut === true,
|
|
21577
24244
|
escrowPin: data.escrowPin,
|
|
24245
|
+
escrowStale: data.escrowStale,
|
|
21578
24246
|
sssActivationState: data.sssActivationState ?? "active"
|
|
21579
24247
|
};
|
|
21580
24248
|
},
|
|
@@ -21619,10 +24287,17 @@ function createSSSStrategy(config) {
|
|
|
21619
24287
|
if (!config.escrow?.enabled) return { state: "disabled" };
|
|
21620
24288
|
const status = await this.fetchServerKeyStatus(params.token, params.providerType);
|
|
21621
24289
|
if (status.escrowOptedOut) return { state: "opted-out", escrowPin: status.escrowPin };
|
|
21622
|
-
const
|
|
21623
|
-
(method) => method.type === "escrow" &&
|
|
21624
|
-
)
|
|
21625
|
-
|
|
24290
|
+
const confirmedEscrow = status.recoveryMethods.filter(
|
|
24291
|
+
(method) => method.type === "escrow" && (Boolean(method.confirmedAt) || "confirmationStatus" in method && method.confirmationStatus === "confirmed")
|
|
24292
|
+
);
|
|
24293
|
+
const enrolled = status.shareVersion !== null && confirmedEscrow.some((method) => method.shareVersion === status.shareVersion);
|
|
24294
|
+
if (confirmedEscrow.length > 0 && (!enrolled || status.escrowStale))
|
|
24295
|
+
return {
|
|
24296
|
+
state: "stale",
|
|
24297
|
+
escrowPin: status.escrowPin,
|
|
24298
|
+
staleReason: status.escrowStale
|
|
24299
|
+
};
|
|
24300
|
+
return { state: enrolled ? "enrolled" : "not-enrolled", escrowPin: status.escrowPin };
|
|
21626
24301
|
},
|
|
21627
24302
|
async disableEscrowRecovery(params) {
|
|
21628
24303
|
const status = await this.fetchServerKeyStatus(params.token, params.providerType);
|
|
@@ -21675,7 +24350,7 @@ function createSSSStrategy(config) {
|
|
|
21675
24350
|
const result = await withRotationLock(
|
|
21676
24351
|
() => ensureEscrowEnrollmentUnguarded(this, { ...params, options: { pin } }, storage2)
|
|
21677
24352
|
);
|
|
21678
|
-
if (!result.enrolled) {
|
|
24353
|
+
if (!result.enrolled || !result.changed) {
|
|
21679
24354
|
throw new Error("Automatic recovery is not available for this account.");
|
|
21680
24355
|
}
|
|
21681
24356
|
},
|
|
@@ -21684,7 +24359,7 @@ function createSSSStrategy(config) {
|
|
|
21684
24359
|
const result = await withRotationLock(
|
|
21685
24360
|
() => ensureEscrowEnrollmentUnguarded(this, params, storage2, true)
|
|
21686
24361
|
);
|
|
21687
|
-
if (!result.enrolled) {
|
|
24362
|
+
if (!result.enrolled || !result.changed) {
|
|
21688
24363
|
throw new Error("Automatic recovery is not available for this account.");
|
|
21689
24364
|
}
|
|
21690
24365
|
},
|