@bcts/xid 1.0.0-alpha.21 → 1.0.0-alpha.23
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/dist/index.cjs +123 -113
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.iife.js +179 -170
- package/dist/index.iife.js.map +1 -1
- package/dist/index.mjs +107 -97
- package/dist/index.mjs.map +1 -1
- package/package.json +14 -14
- package/src/key.ts +1 -1
- package/src/provenance.ts +2 -5
- package/src/service.ts +1 -1
- package/src/xid-document.ts +1 -1
package/dist/index.iife.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
var bctsXid = (function(exports, _bcts_components, _bcts_known_values, _bcts_envelope, _bcts_provenance_mark) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
//#region src/error.ts
|
|
6
|
-
/**
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
//#region src/error.ts
|
|
4
|
+
/**
|
|
7
5
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
8
6
|
* Copyright © 2025-2026 Parity Technologies
|
|
9
7
|
*
|
|
@@ -58,183 +56,180 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
58
56
|
* Returned when attempting to add a duplicate item.
|
|
59
57
|
*/
|
|
60
58
|
static duplicate(item) {
|
|
61
|
-
return new XIDError(
|
|
59
|
+
return new XIDError("DUPLICATE", `duplicate item: ${item}`);
|
|
62
60
|
}
|
|
63
61
|
/**
|
|
64
62
|
* Returned when an item is not found.
|
|
65
63
|
*/
|
|
66
64
|
static notFound(item) {
|
|
67
|
-
return new XIDError(
|
|
65
|
+
return new XIDError("NOT_FOUND", `item not found: ${item}`);
|
|
68
66
|
}
|
|
69
67
|
/**
|
|
70
68
|
* Returned when an item is still referenced by other items.
|
|
71
69
|
*/
|
|
72
70
|
static stillReferenced(item) {
|
|
73
|
-
return new XIDError(
|
|
71
|
+
return new XIDError("STILL_REFERENCED", `item is still referenced: ${item}`);
|
|
74
72
|
}
|
|
75
73
|
/**
|
|
76
74
|
* Returned when a value is invalid or empty.
|
|
77
75
|
*/
|
|
78
76
|
static emptyValue(field) {
|
|
79
|
-
return new XIDError(
|
|
77
|
+
return new XIDError("EMPTY_VALUE", `invalid or empty value: ${field}`);
|
|
80
78
|
}
|
|
81
79
|
/**
|
|
82
80
|
* Returned when an unknown privilege is encountered.
|
|
83
81
|
*/
|
|
84
82
|
static unknownPrivilege() {
|
|
85
|
-
return new XIDError(
|
|
83
|
+
return new XIDError("UNKNOWN_PRIVILEGE", "unknown privilege");
|
|
86
84
|
}
|
|
87
85
|
/**
|
|
88
86
|
* Returned when the XID is invalid.
|
|
89
87
|
*/
|
|
90
88
|
static invalidXid() {
|
|
91
|
-
return new XIDError(
|
|
89
|
+
return new XIDError("INVALID_XID", "invalid XID");
|
|
92
90
|
}
|
|
93
91
|
/**
|
|
94
92
|
* Returned when the inception key is missing.
|
|
95
93
|
*/
|
|
96
94
|
static missingInceptionKey() {
|
|
97
|
-
return new XIDError(
|
|
95
|
+
return new XIDError("MISSING_INCEPTION_KEY", "missing inception key");
|
|
98
96
|
}
|
|
99
97
|
/**
|
|
100
98
|
* Returned when the resolution method is invalid.
|
|
101
99
|
*/
|
|
102
100
|
static invalidResolutionMethod() {
|
|
103
|
-
return new XIDError(
|
|
101
|
+
return new XIDError("INVALID_RESOLUTION_METHOD", "invalid resolution method");
|
|
104
102
|
}
|
|
105
103
|
/**
|
|
106
104
|
* Returned when multiple provenance marks are found.
|
|
107
105
|
*/
|
|
108
106
|
static multipleProvenanceMarks() {
|
|
109
|
-
return new XIDError(
|
|
107
|
+
return new XIDError("MULTIPLE_PROVENANCE_MARKS", "multiple provenance marks");
|
|
110
108
|
}
|
|
111
109
|
/**
|
|
112
110
|
* Returned when an unexpected predicate is encountered.
|
|
113
111
|
*/
|
|
114
112
|
static unexpectedPredicate(predicate) {
|
|
115
|
-
return new XIDError(
|
|
113
|
+
return new XIDError("UNEXPECTED_PREDICATE", `unexpected predicate: ${predicate}`);
|
|
116
114
|
}
|
|
117
115
|
/**
|
|
118
116
|
* Returned when unexpected nested assertions are found.
|
|
119
117
|
*/
|
|
120
118
|
static unexpectedNestedAssertions() {
|
|
121
|
-
return new XIDError(
|
|
119
|
+
return new XIDError("UNEXPECTED_NESTED_ASSERTIONS", "unexpected nested assertions");
|
|
122
120
|
}
|
|
123
121
|
/**
|
|
124
122
|
* Returned when a service has no permissions.
|
|
125
123
|
*/
|
|
126
124
|
static noPermissions(uri) {
|
|
127
|
-
return new XIDError(
|
|
125
|
+
return new XIDError("NO_PERMISSIONS", `no permissions in service '${uri}'`);
|
|
128
126
|
}
|
|
129
127
|
/**
|
|
130
128
|
* Returned when a service has no key or delegate references.
|
|
131
129
|
*/
|
|
132
130
|
static noReferences(uri) {
|
|
133
|
-
return new XIDError(
|
|
131
|
+
return new XIDError("NO_REFERENCES", `no key or delegate references in service '${uri}'`);
|
|
134
132
|
}
|
|
135
133
|
/**
|
|
136
134
|
* Returned when an unknown key reference is found in a service.
|
|
137
135
|
*/
|
|
138
136
|
static unknownKeyReference(reference, uri) {
|
|
139
|
-
return new XIDError(
|
|
137
|
+
return new XIDError("UNKNOWN_KEY_REFERENCE", `unknown key reference ${reference} in service '${uri}'`);
|
|
140
138
|
}
|
|
141
139
|
/**
|
|
142
140
|
* Returned when an unknown delegate reference is found in a service.
|
|
143
141
|
*/
|
|
144
142
|
static unknownDelegateReference(reference, uri) {
|
|
145
|
-
return new XIDError(
|
|
143
|
+
return new XIDError("UNKNOWN_DELEGATE_REFERENCE", `unknown delegate reference ${reference} in service '${uri}'`);
|
|
146
144
|
}
|
|
147
145
|
/**
|
|
148
146
|
* Returned when a key is not found in the XID document.
|
|
149
147
|
*/
|
|
150
148
|
static keyNotFoundInDocument(key) {
|
|
151
|
-
return new XIDError(
|
|
149
|
+
return new XIDError("KEY_NOT_FOUND_IN_DOCUMENT", `key not found in XID document: ${key}`);
|
|
152
150
|
}
|
|
153
151
|
/**
|
|
154
152
|
* Returned when a delegate is not found in the XID document.
|
|
155
153
|
*/
|
|
156
154
|
static delegateNotFoundInDocument(delegate) {
|
|
157
|
-
return new XIDError(
|
|
155
|
+
return new XIDError("DELEGATE_NOT_FOUND_IN_DOCUMENT", `delegate not found in XID document: ${delegate}`);
|
|
158
156
|
}
|
|
159
157
|
/**
|
|
160
158
|
* Returned when the password is invalid.
|
|
161
159
|
*/
|
|
162
160
|
static invalidPassword() {
|
|
163
|
-
return new XIDError(
|
|
161
|
+
return new XIDError("INVALID_PASSWORD", "invalid password");
|
|
164
162
|
}
|
|
165
163
|
/**
|
|
166
164
|
* Returned when the envelope is not signed.
|
|
167
165
|
*/
|
|
168
166
|
static envelopeNotSigned() {
|
|
169
|
-
return new XIDError(
|
|
167
|
+
return new XIDError("ENVELOPE_NOT_SIGNED", "envelope is not signed");
|
|
170
168
|
}
|
|
171
169
|
/**
|
|
172
170
|
* Returned when signature verification fails.
|
|
173
171
|
*/
|
|
174
172
|
static signatureVerificationFailed() {
|
|
175
|
-
return new XIDError(
|
|
173
|
+
return new XIDError("SIGNATURE_VERIFICATION_FAILED", "signature verification failed");
|
|
176
174
|
}
|
|
177
175
|
/**
|
|
178
176
|
* Returned when there is no provenance mark to advance.
|
|
179
177
|
*/
|
|
180
178
|
static noProvenanceMark() {
|
|
181
|
-
return new XIDError(
|
|
179
|
+
return new XIDError("NO_PROVENANCE_MARK", "no provenance mark to advance");
|
|
182
180
|
}
|
|
183
181
|
/**
|
|
184
182
|
* Returned when document already has generator but external generator was provided.
|
|
185
183
|
*/
|
|
186
184
|
static generatorConflict() {
|
|
187
|
-
return new XIDError(
|
|
185
|
+
return new XIDError("GENERATOR_CONFLICT", "document already has generator, cannot provide external generator");
|
|
188
186
|
}
|
|
189
187
|
/**
|
|
190
188
|
* Returned when document does not have generator but needs one.
|
|
191
189
|
*/
|
|
192
190
|
static noGenerator() {
|
|
193
|
-
return new XIDError(
|
|
191
|
+
return new XIDError("NO_GENERATOR", "document does not have generator, must provide external generator");
|
|
194
192
|
}
|
|
195
193
|
/**
|
|
196
194
|
* Returned when generator chain ID doesn't match.
|
|
197
195
|
*/
|
|
198
196
|
static chainIdMismatch(expected, actual) {
|
|
199
|
-
|
|
200
|
-
const actualHex = Array.from(actual).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
201
|
-
return new XIDError(XIDErrorCode.CHAIN_ID_MISMATCH, `generator chain ID mismatch: expected ${expectedHex}, got ${actualHex}`);
|
|
197
|
+
return new XIDError("CHAIN_ID_MISMATCH", `generator chain ID mismatch: expected ${Array.from(expected).map((b) => b.toString(16).padStart(2, "0")).join("")}, got ${Array.from(actual).map((b) => b.toString(16).padStart(2, "0")).join("")}`);
|
|
202
198
|
}
|
|
203
199
|
/**
|
|
204
200
|
* Returned when generator sequence doesn't match.
|
|
205
201
|
*/
|
|
206
202
|
static sequenceMismatch(expected, actual) {
|
|
207
|
-
return new XIDError(
|
|
203
|
+
return new XIDError("SEQUENCE_MISMATCH", `generator sequence mismatch: expected ${expected}, got ${actual}`);
|
|
208
204
|
}
|
|
209
205
|
/**
|
|
210
206
|
* Envelope parsing error wrapper.
|
|
211
207
|
*/
|
|
212
208
|
static envelopeParsing(cause) {
|
|
213
|
-
return new XIDError(
|
|
209
|
+
return new XIDError("ENVELOPE_PARSING", "envelope parsing error", cause);
|
|
214
210
|
}
|
|
215
211
|
/**
|
|
216
212
|
* Component error wrapper.
|
|
217
213
|
*/
|
|
218
214
|
static component(cause) {
|
|
219
|
-
return new XIDError(
|
|
215
|
+
return new XIDError("COMPONENT", "component error", cause);
|
|
220
216
|
}
|
|
221
217
|
/**
|
|
222
218
|
* CBOR error wrapper.
|
|
223
219
|
*/
|
|
224
220
|
static cbor(cause) {
|
|
225
|
-
return new XIDError(
|
|
221
|
+
return new XIDError("CBOR", "CBOR error", cause);
|
|
226
222
|
}
|
|
227
223
|
/**
|
|
228
224
|
* Provenance mark error wrapper.
|
|
229
225
|
*/
|
|
230
226
|
static provenanceMark(cause) {
|
|
231
|
-
return new XIDError(
|
|
227
|
+
return new XIDError("PROVENANCE_MARK", "provenance mark error", cause);
|
|
232
228
|
}
|
|
233
229
|
};
|
|
234
|
-
|
|
235
|
-
//#
|
|
236
|
-
|
|
237
|
-
/**
|
|
230
|
+
//#endregion
|
|
231
|
+
//#region src/privilege.ts
|
|
232
|
+
/**
|
|
238
233
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
239
234
|
* Copyright © 2025-2026 Parity Technologies
|
|
240
235
|
*
|
|
@@ -285,20 +280,20 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
285
280
|
*/
|
|
286
281
|
function privilegeToKnownValue(privilege) {
|
|
287
282
|
switch (privilege) {
|
|
288
|
-
case
|
|
289
|
-
case
|
|
290
|
-
case
|
|
291
|
-
case
|
|
292
|
-
case
|
|
293
|
-
case
|
|
294
|
-
case
|
|
295
|
-
case
|
|
296
|
-
case
|
|
297
|
-
case
|
|
298
|
-
case
|
|
299
|
-
case
|
|
300
|
-
case
|
|
301
|
-
case
|
|
283
|
+
case "All": return _bcts_known_values.PRIVILEGE_ALL;
|
|
284
|
+
case "Auth": return _bcts_known_values.PRIVILEGE_AUTH;
|
|
285
|
+
case "Sign": return _bcts_known_values.PRIVILEGE_SIGN;
|
|
286
|
+
case "Encrypt": return _bcts_known_values.PRIVILEGE_ENCRYPT;
|
|
287
|
+
case "Elide": return _bcts_known_values.PRIVILEGE_ELIDE;
|
|
288
|
+
case "Issue": return _bcts_known_values.PRIVILEGE_ISSUE;
|
|
289
|
+
case "Access": return _bcts_known_values.PRIVILEGE_ACCESS;
|
|
290
|
+
case "Delegate": return _bcts_known_values.PRIVILEGE_DELEGATE;
|
|
291
|
+
case "Verify": return _bcts_known_values.PRIVILEGE_VERIFY;
|
|
292
|
+
case "Update": return _bcts_known_values.PRIVILEGE_UPDATE;
|
|
293
|
+
case "Transfer": return _bcts_known_values.PRIVILEGE_TRANSFER;
|
|
294
|
+
case "Elect": return _bcts_known_values.PRIVILEGE_ELECT;
|
|
295
|
+
case "Burn": return _bcts_known_values.PRIVILEGE_BURN;
|
|
296
|
+
case "Revoke": return _bcts_known_values.PRIVILEGE_REVOKE;
|
|
302
297
|
default: throw XIDError.unknownPrivilege();
|
|
303
298
|
}
|
|
304
299
|
}
|
|
@@ -307,20 +302,20 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
307
302
|
*/
|
|
308
303
|
function privilegeFromKnownValue(knownValue) {
|
|
309
304
|
switch (knownValue.value()) {
|
|
310
|
-
case _bcts_known_values.PRIVILEGE_ALL.value(): return
|
|
311
|
-
case _bcts_known_values.PRIVILEGE_AUTH.value(): return
|
|
312
|
-
case _bcts_known_values.PRIVILEGE_SIGN.value(): return
|
|
313
|
-
case _bcts_known_values.PRIVILEGE_ENCRYPT.value(): return
|
|
314
|
-
case _bcts_known_values.PRIVILEGE_ELIDE.value(): return
|
|
315
|
-
case _bcts_known_values.PRIVILEGE_ISSUE.value(): return
|
|
316
|
-
case _bcts_known_values.PRIVILEGE_ACCESS.value(): return
|
|
317
|
-
case _bcts_known_values.PRIVILEGE_DELEGATE.value(): return
|
|
318
|
-
case _bcts_known_values.PRIVILEGE_VERIFY.value(): return
|
|
319
|
-
case _bcts_known_values.PRIVILEGE_UPDATE.value(): return
|
|
320
|
-
case _bcts_known_values.PRIVILEGE_TRANSFER.value(): return
|
|
321
|
-
case _bcts_known_values.PRIVILEGE_ELECT.value(): return
|
|
322
|
-
case _bcts_known_values.PRIVILEGE_BURN.value(): return
|
|
323
|
-
case _bcts_known_values.PRIVILEGE_REVOKE.value(): return
|
|
305
|
+
case _bcts_known_values.PRIVILEGE_ALL.value(): return "All";
|
|
306
|
+
case _bcts_known_values.PRIVILEGE_AUTH.value(): return "Auth";
|
|
307
|
+
case _bcts_known_values.PRIVILEGE_SIGN.value(): return "Sign";
|
|
308
|
+
case _bcts_known_values.PRIVILEGE_ENCRYPT.value(): return "Encrypt";
|
|
309
|
+
case _bcts_known_values.PRIVILEGE_ELIDE.value(): return "Elide";
|
|
310
|
+
case _bcts_known_values.PRIVILEGE_ISSUE.value(): return "Issue";
|
|
311
|
+
case _bcts_known_values.PRIVILEGE_ACCESS.value(): return "Access";
|
|
312
|
+
case _bcts_known_values.PRIVILEGE_DELEGATE.value(): return "Delegate";
|
|
313
|
+
case _bcts_known_values.PRIVILEGE_VERIFY.value(): return "Verify";
|
|
314
|
+
case _bcts_known_values.PRIVILEGE_UPDATE.value(): return "Update";
|
|
315
|
+
case _bcts_known_values.PRIVILEGE_TRANSFER.value(): return "Transfer";
|
|
316
|
+
case _bcts_known_values.PRIVILEGE_ELECT.value(): return "Elect";
|
|
317
|
+
case _bcts_known_values.PRIVILEGE_BURN.value(): return "Burn";
|
|
318
|
+
case _bcts_known_values.PRIVILEGE_REVOKE.value(): return "Revoke";
|
|
324
319
|
default: throw XIDError.unknownPrivilege();
|
|
325
320
|
}
|
|
326
321
|
}
|
|
@@ -338,10 +333,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
338
333
|
if (envelopeCase.type !== "knownValue") throw XIDError.unknownPrivilege();
|
|
339
334
|
return privilegeFromKnownValue(envelopeCase.value);
|
|
340
335
|
}
|
|
341
|
-
|
|
342
|
-
//#
|
|
343
|
-
|
|
344
|
-
/**
|
|
336
|
+
//#endregion
|
|
337
|
+
//#region src/permissions.ts
|
|
338
|
+
/**
|
|
345
339
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
346
340
|
* Copyright © 2025-2026 Parity Technologies
|
|
347
341
|
*
|
|
@@ -357,24 +351,45 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
357
351
|
* Helper methods for HasPermissions implementers.
|
|
358
352
|
*/
|
|
359
353
|
const HasPermissionsMixin = {
|
|
354
|
+
/**
|
|
355
|
+
* Get the set of allowed privileges.
|
|
356
|
+
*/
|
|
360
357
|
allow(obj) {
|
|
361
358
|
return obj.permissions().allow;
|
|
362
359
|
},
|
|
360
|
+
/**
|
|
361
|
+
* Get the set of denied privileges.
|
|
362
|
+
*/
|
|
363
363
|
deny(obj) {
|
|
364
364
|
return obj.permissions().deny;
|
|
365
365
|
},
|
|
366
|
+
/**
|
|
367
|
+
* Add an allowed privilege.
|
|
368
|
+
*/
|
|
366
369
|
addAllow(obj, privilege) {
|
|
367
370
|
obj.permissionsMut().allow.add(privilege);
|
|
368
371
|
},
|
|
372
|
+
/**
|
|
373
|
+
* Add a denied privilege.
|
|
374
|
+
*/
|
|
369
375
|
addDeny(obj, privilege) {
|
|
370
376
|
obj.permissionsMut().deny.add(privilege);
|
|
371
377
|
},
|
|
378
|
+
/**
|
|
379
|
+
* Remove an allowed privilege.
|
|
380
|
+
*/
|
|
372
381
|
removeAllow(obj, privilege) {
|
|
373
382
|
obj.permissionsMut().allow.delete(privilege);
|
|
374
383
|
},
|
|
384
|
+
/**
|
|
385
|
+
* Remove a denied privilege.
|
|
386
|
+
*/
|
|
375
387
|
removeDeny(obj, privilege) {
|
|
376
388
|
obj.permissionsMut().deny.delete(privilege);
|
|
377
389
|
},
|
|
390
|
+
/**
|
|
391
|
+
* Clear all permissions.
|
|
392
|
+
*/
|
|
378
393
|
clearAllPermissions(obj) {
|
|
379
394
|
obj.permissionsMut().allow.clear();
|
|
380
395
|
obj.permissionsMut().deny.clear();
|
|
@@ -401,7 +416,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
401
416
|
*/
|
|
402
417
|
static newAllowAll() {
|
|
403
418
|
const allow = /* @__PURE__ */ new Set();
|
|
404
|
-
allow.add(
|
|
419
|
+
allow.add("All");
|
|
405
420
|
return new Permissions(allow);
|
|
406
421
|
}
|
|
407
422
|
/**
|
|
@@ -447,14 +462,14 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
447
462
|
* Check if a specific privilege is allowed.
|
|
448
463
|
*/
|
|
449
464
|
isAllowed(privilege) {
|
|
450
|
-
if (this.deny.has(privilege) || this.deny.has(
|
|
451
|
-
return this.allow.has(privilege) || this.allow.has(
|
|
465
|
+
if (this.deny.has(privilege) || this.deny.has("All")) return false;
|
|
466
|
+
return this.allow.has(privilege) || this.allow.has("All");
|
|
452
467
|
}
|
|
453
468
|
/**
|
|
454
469
|
* Check if a specific privilege is denied.
|
|
455
470
|
*/
|
|
456
471
|
isDenied(privilege) {
|
|
457
|
-
return this.deny.has(privilege) || this.deny.has(
|
|
472
|
+
return this.deny.has(privilege) || this.deny.has("All");
|
|
458
473
|
}
|
|
459
474
|
permissions() {
|
|
460
475
|
return this;
|
|
@@ -478,10 +493,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
478
493
|
return new Permissions(new Set(this.allow), new Set(this.deny));
|
|
479
494
|
}
|
|
480
495
|
};
|
|
481
|
-
|
|
482
|
-
//#
|
|
483
|
-
|
|
484
|
-
/**
|
|
496
|
+
//#endregion
|
|
497
|
+
//#region src/name.ts
|
|
498
|
+
/**
|
|
485
499
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
486
500
|
* Copyright © 2025-2026 Parity Technologies
|
|
487
501
|
*
|
|
@@ -495,15 +509,18 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
495
509
|
/**
|
|
496
510
|
* Helper methods for HasNickname implementers.
|
|
497
511
|
*/
|
|
498
|
-
const HasNicknameMixin = {
|
|
512
|
+
const HasNicknameMixin = {
|
|
513
|
+
/**
|
|
514
|
+
* Add a nickname, throwing if one already exists or is empty.
|
|
515
|
+
*/
|
|
516
|
+
addNickname(obj, name) {
|
|
499
517
|
if (obj.nickname() !== "") throw XIDError.duplicate("nickname");
|
|
500
518
|
if (name === "") throw XIDError.emptyValue("nickname");
|
|
501
519
|
obj.setNickname(name);
|
|
502
520
|
} };
|
|
503
|
-
|
|
504
|
-
//#
|
|
505
|
-
|
|
506
|
-
/**
|
|
521
|
+
//#endregion
|
|
522
|
+
//#region src/shared.ts
|
|
523
|
+
/**
|
|
507
524
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
508
525
|
* Copyright © 2025-2026 Parity Technologies
|
|
509
526
|
*
|
|
@@ -565,10 +582,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
565
582
|
return new Shared(this.value);
|
|
566
583
|
}
|
|
567
584
|
};
|
|
568
|
-
|
|
569
|
-
//#
|
|
570
|
-
|
|
571
|
-
/**
|
|
585
|
+
//#endregion
|
|
586
|
+
//#region src/key.ts
|
|
587
|
+
/**
|
|
572
588
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
573
589
|
* Copyright © 2025-2026 Parity Technologies
|
|
574
590
|
*
|
|
@@ -738,7 +754,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
738
754
|
/**
|
|
739
755
|
* Convert to envelope with specified options.
|
|
740
756
|
*/
|
|
741
|
-
intoEnvelopeOpt(privateKeyOptions =
|
|
757
|
+
intoEnvelopeOpt(privateKeyOptions = "Omit") {
|
|
742
758
|
let envelope = _bcts_envelope.Envelope.new(this._publicKeys.taggedCborData());
|
|
743
759
|
if (this._privateKeyData !== void 0) {
|
|
744
760
|
const { data, salt } = this._privateKeyData;
|
|
@@ -746,17 +762,17 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
746
762
|
envelope = envelope.addAssertion(kv$3(_bcts_known_values.PRIVATE_KEY), data.envelope);
|
|
747
763
|
envelope = envelope.addAssertion(kv$3(_bcts_known_values.SALT), salt.toData());
|
|
748
764
|
} else if (data.type === "decrypted") switch (typeof privateKeyOptions === "object" ? privateKeyOptions.type : privateKeyOptions) {
|
|
749
|
-
case
|
|
765
|
+
case "Include":
|
|
750
766
|
envelope = envelope.addAssertion(kv$3(_bcts_known_values.PRIVATE_KEY), data.privateKeys.taggedCborData());
|
|
751
767
|
envelope = envelope.addAssertion(kv$3(_bcts_known_values.SALT), salt.toData());
|
|
752
768
|
break;
|
|
753
|
-
case
|
|
769
|
+
case "Elide": {
|
|
754
770
|
const elidedAssertion = _bcts_envelope.Envelope.newAssertion(kv$3(_bcts_known_values.PRIVATE_KEY), data.privateKeys.taggedCborData()).elide();
|
|
755
771
|
envelope = envelope.addAssertionEnvelope(elidedAssertion);
|
|
756
772
|
envelope = envelope.addAssertion(kv$3(_bcts_known_values.SALT), salt.toData());
|
|
757
773
|
break;
|
|
758
774
|
}
|
|
759
|
-
case
|
|
775
|
+
case "Encrypt":
|
|
760
776
|
if (typeof privateKeyOptions === "object") {
|
|
761
777
|
const privateKeysEnvelope = _bcts_envelope.Envelope.new(data.privateKeys.taggedCborData());
|
|
762
778
|
const method = privateKeyOptions.method ?? (0, _bcts_components.defaultKeyDerivationMethod)();
|
|
@@ -765,7 +781,6 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
765
781
|
envelope = envelope.addAssertion(kv$3(_bcts_known_values.SALT), salt.toData());
|
|
766
782
|
}
|
|
767
783
|
break;
|
|
768
|
-
case XIDPrivateKeyOptions.Omit:
|
|
769
784
|
default: break;
|
|
770
785
|
}
|
|
771
786
|
}
|
|
@@ -775,7 +790,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
775
790
|
return envelope;
|
|
776
791
|
}
|
|
777
792
|
intoEnvelope() {
|
|
778
|
-
return this.intoEnvelopeOpt(
|
|
793
|
+
return this.intoEnvelopeOpt("Omit");
|
|
779
794
|
}
|
|
780
795
|
/**
|
|
781
796
|
* Try to extract a Key from an envelope, optionally with password for decryption.
|
|
@@ -900,10 +915,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
900
915
|
} : void 0, this._nickname, new Set(this._endpoints), this._permissions.clone());
|
|
901
916
|
}
|
|
902
917
|
};
|
|
903
|
-
|
|
904
|
-
//#
|
|
905
|
-
|
|
906
|
-
/**
|
|
918
|
+
//#endregion
|
|
919
|
+
//#region src/service.ts
|
|
920
|
+
/**
|
|
907
921
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
908
922
|
* Copyright © 2025-2026 Parity Technologies
|
|
909
923
|
*
|
|
@@ -1154,9 +1168,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
1154
1168
|
function bytesToHex(bytes) {
|
|
1155
1169
|
return Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
1156
1170
|
}
|
|
1157
|
-
|
|
1158
|
-
//#
|
|
1159
|
-
//#region src/delegate.ts
|
|
1171
|
+
//#endregion
|
|
1172
|
+
//#region src/delegate.ts
|
|
1160
1173
|
let XIDDocumentClass = null;
|
|
1161
1174
|
/**
|
|
1162
1175
|
* Register the XIDDocument class to avoid circular dependency issues.
|
|
@@ -1240,10 +1253,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
1240
1253
|
return new Delegate(Shared.new(this._controller.read().clone()), this._permissions.clone());
|
|
1241
1254
|
}
|
|
1242
1255
|
};
|
|
1243
|
-
|
|
1244
|
-
//#
|
|
1245
|
-
|
|
1246
|
-
/**
|
|
1256
|
+
//#endregion
|
|
1257
|
+
//#region src/provenance.ts
|
|
1258
|
+
/**
|
|
1247
1259
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
1248
1260
|
* Copyright © 2025-2026 Parity Technologies
|
|
1249
1261
|
*
|
|
@@ -1414,7 +1426,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
1414
1426
|
/**
|
|
1415
1427
|
* Convert to envelope with specified options.
|
|
1416
1428
|
*/
|
|
1417
|
-
intoEnvelopeOpt(generatorOptions =
|
|
1429
|
+
intoEnvelopeOpt(generatorOptions = "Omit") {
|
|
1418
1430
|
let envelope = _bcts_envelope.Envelope.new(this._mark.toCborData());
|
|
1419
1431
|
if (this._generator !== void 0) {
|
|
1420
1432
|
const { data, salt } = this._generator;
|
|
@@ -1422,20 +1434,20 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
1422
1434
|
envelope = envelope.addAssertion(kv$1(_bcts_known_values.PROVENANCE_GENERATOR), data.envelope);
|
|
1423
1435
|
envelope = envelope.addAssertion(kv$1(_bcts_known_values.SALT), salt.toData());
|
|
1424
1436
|
} else if (data.type === "decrypted") switch (typeof generatorOptions === "object" ? generatorOptions.type : generatorOptions) {
|
|
1425
|
-
case
|
|
1437
|
+
case "Include": {
|
|
1426
1438
|
const generatorBytes = encodeGeneratorJSON(data.generator.toJSON());
|
|
1427
1439
|
envelope = envelope.addAssertion(kv$1(_bcts_known_values.PROVENANCE_GENERATOR), generatorBytes);
|
|
1428
1440
|
envelope = envelope.addAssertion(kv$1(_bcts_known_values.SALT), salt.toData());
|
|
1429
1441
|
break;
|
|
1430
1442
|
}
|
|
1431
|
-
case
|
|
1443
|
+
case "Elide": {
|
|
1432
1444
|
const generatorBytes2 = encodeGeneratorJSON(data.generator.toJSON());
|
|
1433
1445
|
const elidedAssertion = _bcts_envelope.Envelope.newAssertion(kv$1(_bcts_known_values.PROVENANCE_GENERATOR), generatorBytes2).elide();
|
|
1434
1446
|
envelope = envelope.addAssertionEnvelope(elidedAssertion);
|
|
1435
1447
|
envelope = envelope.addAssertion(kv$1(_bcts_known_values.SALT), salt.toData());
|
|
1436
1448
|
break;
|
|
1437
1449
|
}
|
|
1438
|
-
case
|
|
1450
|
+
case "Encrypt":
|
|
1439
1451
|
if (typeof generatorOptions === "object") {
|
|
1440
1452
|
const generatorBytes3 = encodeGeneratorJSON(data.generator.toJSON());
|
|
1441
1453
|
const wrapped = _bcts_envelope.Envelope.new(generatorBytes3).wrap();
|
|
@@ -1445,14 +1457,13 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
1445
1457
|
envelope = envelope.addAssertion(kv$1(_bcts_known_values.SALT), salt.toData());
|
|
1446
1458
|
}
|
|
1447
1459
|
break;
|
|
1448
|
-
case XIDGeneratorOptions.Omit:
|
|
1449
1460
|
default: break;
|
|
1450
1461
|
}
|
|
1451
1462
|
}
|
|
1452
1463
|
return envelope;
|
|
1453
1464
|
}
|
|
1454
1465
|
intoEnvelope() {
|
|
1455
|
-
return this.intoEnvelopeOpt(
|
|
1466
|
+
return this.intoEnvelopeOpt("Omit");
|
|
1456
1467
|
}
|
|
1457
1468
|
/**
|
|
1458
1469
|
* Try to extract a Provenance from an envelope, optionally with password for decryption.
|
|
@@ -1539,10 +1550,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
1539
1550
|
} : void 0);
|
|
1540
1551
|
}
|
|
1541
1552
|
};
|
|
1542
|
-
|
|
1543
|
-
//#
|
|
1544
|
-
|
|
1545
|
-
/**
|
|
1553
|
+
//#endregion
|
|
1554
|
+
//#region src/xid-document.ts
|
|
1555
|
+
/**
|
|
1546
1556
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
1547
1557
|
* Copyright © 2025-2026 Parity Technologies
|
|
1548
1558
|
*
|
|
@@ -1774,7 +1784,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
1774
1784
|
* Extract inception private keys from an envelope (convenience static method).
|
|
1775
1785
|
*/
|
|
1776
1786
|
static extractInceptionPrivateKeysFromEnvelope(envelope, password) {
|
|
1777
|
-
return XIDDocument.fromEnvelope(envelope, password,
|
|
1787
|
+
return XIDDocument.fromEnvelope(envelope, password, "None").inceptionPrivateKeys();
|
|
1778
1788
|
}
|
|
1779
1789
|
/**
|
|
1780
1790
|
* Get the private key envelope for a specific key, optionally decrypting it.
|
|
@@ -2052,7 +2062,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2052
2062
|
/**
|
|
2053
2063
|
* Convert to envelope with options.
|
|
2054
2064
|
*/
|
|
2055
|
-
toEnvelope(privateKeyOptions =
|
|
2065
|
+
toEnvelope(privateKeyOptions = "Omit", generatorOptions = "Omit", signingOptions = { type: "none" }) {
|
|
2056
2066
|
let envelope = _bcts_envelope.Envelope.newLeaf(this._xid.taggedCbor());
|
|
2057
2067
|
for (const method of this._resolutionMethods) envelope = envelope.addAssertion(kv(_bcts_known_values.DEREFERENCE_VIA), method);
|
|
2058
2068
|
for (const key of this._keys.values()) envelope = envelope.addAssertion(kv(_bcts_known_values.KEY), key.intoEnvelopeOpt(privateKeyOptions));
|
|
@@ -2087,10 +2097,10 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2087
2097
|
/**
|
|
2088
2098
|
* Extract an XIDDocument from an envelope.
|
|
2089
2099
|
*/
|
|
2090
|
-
static fromEnvelope(envelope, password, verifySignature =
|
|
2100
|
+
static fromEnvelope(envelope, password, verifySignature = "None") {
|
|
2091
2101
|
const envelopeExt = envelope;
|
|
2092
2102
|
switch (verifySignature) {
|
|
2093
|
-
case
|
|
2103
|
+
case "None": {
|
|
2094
2104
|
const subject = envelopeExt.subject();
|
|
2095
2105
|
const envelopeToParse = subject.isWrapped() ? subject.tryUnwrap() : envelope;
|
|
2096
2106
|
const attachments = _bcts_envelope.Attachments.fromEnvelope(envelopeToParse);
|
|
@@ -2100,7 +2110,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2100
2110
|
doc._edges = edges;
|
|
2101
2111
|
return doc;
|
|
2102
2112
|
}
|
|
2103
|
-
case
|
|
2113
|
+
case "Inception": {
|
|
2104
2114
|
if (!envelopeExt.subject().isWrapped()) throw XIDError.envelopeNotSigned();
|
|
2105
2115
|
const unwrapped = envelopeExt.tryUnwrap();
|
|
2106
2116
|
const attachments = _bcts_envelope.Attachments.fromEnvelope(unwrapped);
|
|
@@ -2175,13 +2185,13 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2175
2185
|
* Create a signed envelope.
|
|
2176
2186
|
*/
|
|
2177
2187
|
toSignedEnvelope(signingKey) {
|
|
2178
|
-
return this.toSignedEnvelopeOpt(signingKey,
|
|
2188
|
+
return this.toSignedEnvelopeOpt(signingKey, "Omit");
|
|
2179
2189
|
}
|
|
2180
2190
|
/**
|
|
2181
2191
|
* Create a signed envelope with private key options.
|
|
2182
2192
|
*/
|
|
2183
|
-
toSignedEnvelopeOpt(signingKey, privateKeyOptions =
|
|
2184
|
-
return this.toEnvelope(privateKeyOptions,
|
|
2193
|
+
toSignedEnvelopeOpt(signingKey, privateKeyOptions = "Omit") {
|
|
2194
|
+
return this.toEnvelope(privateKeyOptions, "Omit", { type: "none" }).sign(signingKey);
|
|
2185
2195
|
}
|
|
2186
2196
|
/**
|
|
2187
2197
|
* Get the reference for this document.
|
|
@@ -2233,7 +2243,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2233
2243
|
* Try to extract from envelope (alias for fromEnvelope with default options).
|
|
2234
2244
|
*/
|
|
2235
2245
|
static tryFromEnvelope(envelope) {
|
|
2236
|
-
return XIDDocument.fromEnvelope(envelope, void 0,
|
|
2246
|
+
return XIDDocument.fromEnvelope(envelope, void 0, "None");
|
|
2237
2247
|
}
|
|
2238
2248
|
};
|
|
2239
2249
|
registerXIDDocumentClass(XIDDocument);
|
|
@@ -2242,51 +2252,50 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2242
2252
|
for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return false;
|
|
2243
2253
|
return true;
|
|
2244
2254
|
}
|
|
2245
|
-
|
|
2246
|
-
//#
|
|
2247
|
-
//#region src/index.ts
|
|
2255
|
+
//#endregion
|
|
2256
|
+
//#region src/index.ts
|
|
2248
2257
|
const VERSION = "1.0.0-alpha.3";
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
exports
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
exports.
|
|
2265
|
-
exports.
|
|
2266
|
-
exports.
|
|
2267
|
-
exports.
|
|
2268
|
-
exports.
|
|
2269
|
-
exports.
|
|
2270
|
-
exports.
|
|
2271
|
-
exports.
|
|
2272
|
-
exports
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
exports.
|
|
2280
|
-
exports.
|
|
2281
|
-
exports.
|
|
2282
|
-
exports.
|
|
2283
|
-
exports.
|
|
2284
|
-
exports.
|
|
2285
|
-
exports.
|
|
2286
|
-
exports.
|
|
2287
|
-
exports.
|
|
2288
|
-
exports.
|
|
2289
|
-
exports
|
|
2290
|
-
return exports;
|
|
2258
|
+
//#endregion
|
|
2259
|
+
Object.defineProperty(exports, "Attachments", {
|
|
2260
|
+
enumerable: true,
|
|
2261
|
+
get: function() {
|
|
2262
|
+
return _bcts_envelope.Attachments;
|
|
2263
|
+
}
|
|
2264
|
+
});
|
|
2265
|
+
exports.Delegate = Delegate;
|
|
2266
|
+
Object.defineProperty(exports, "Edges", {
|
|
2267
|
+
enumerable: true,
|
|
2268
|
+
get: function() {
|
|
2269
|
+
return _bcts_envelope.Edges;
|
|
2270
|
+
}
|
|
2271
|
+
});
|
|
2272
|
+
exports.HasNicknameMixin = HasNicknameMixin;
|
|
2273
|
+
exports.HasPermissionsMixin = HasPermissionsMixin;
|
|
2274
|
+
exports.Key = Key;
|
|
2275
|
+
exports.Permissions = Permissions;
|
|
2276
|
+
exports.Privilege = Privilege;
|
|
2277
|
+
exports.Provenance = Provenance;
|
|
2278
|
+
exports.Service = Service;
|
|
2279
|
+
exports.Shared = Shared;
|
|
2280
|
+
exports.VERSION = VERSION;
|
|
2281
|
+
Object.defineProperty(exports, "XID", {
|
|
2282
|
+
enumerable: true,
|
|
2283
|
+
get: function() {
|
|
2284
|
+
return _bcts_components.XID;
|
|
2285
|
+
}
|
|
2286
|
+
});
|
|
2287
|
+
exports.XIDDocument = XIDDocument;
|
|
2288
|
+
exports.XIDError = XIDError;
|
|
2289
|
+
exports.XIDErrorCode = XIDErrorCode;
|
|
2290
|
+
exports.XIDGeneratorOptions = XIDGeneratorOptions;
|
|
2291
|
+
exports.XIDPrivateKeyOptions = XIDPrivateKeyOptions;
|
|
2292
|
+
exports.XIDVerifySignature = XIDVerifySignature;
|
|
2293
|
+
exports.privilegeFromEnvelope = privilegeFromEnvelope;
|
|
2294
|
+
exports.privilegeFromKnownValue = privilegeFromKnownValue;
|
|
2295
|
+
exports.privilegeToEnvelope = privilegeToEnvelope;
|
|
2296
|
+
exports.privilegeToKnownValue = privilegeToKnownValue;
|
|
2297
|
+
exports.registerXIDDocumentClass = registerXIDDocumentClass;
|
|
2298
|
+
return exports;
|
|
2291
2299
|
})({}, bctsComponents, bctsKnownValues, bctsEnvelope, bctsProvenanceMark);
|
|
2300
|
+
|
|
2292
2301
|
//# sourceMappingURL=index.iife.js.map
|