@bcts/xid 1.0.0-alpha.13 → 1.0.0-alpha.14
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 +12 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +8 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.iife.js +12 -0
- package/dist/index.iife.js.map +1 -1
- package/dist/index.mjs +12 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
- package/src/xid-document.ts +21 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bcts/xid",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.14",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Blockchain Commons XID for TypeScript",
|
|
6
6
|
"license": "BSD-2-Clause-Patent",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@bcts/eslint": "^0.1.0",
|
|
72
|
-
"@bcts/rand": "^1.0.0-alpha.
|
|
72
|
+
"@bcts/rand": "^1.0.0-alpha.14",
|
|
73
73
|
"@bcts/tsconfig": "^0.1.0",
|
|
74
74
|
"@eslint/js": "^9.39.2",
|
|
75
75
|
"@typescript-eslint/eslint-plugin": "^8.50.1",
|
|
@@ -82,10 +82,10 @@
|
|
|
82
82
|
"vitest": "^4.0.16"
|
|
83
83
|
},
|
|
84
84
|
"dependencies": {
|
|
85
|
-
"@bcts/components": "^1.0.0-alpha.
|
|
86
|
-
"@bcts/dcbor": "^1.0.0-alpha.
|
|
87
|
-
"@bcts/envelope": "^1.0.0-alpha.
|
|
88
|
-
"@bcts/known-values": "^1.0.0-alpha.
|
|
89
|
-
"@bcts/provenance-mark": "^1.0.0-alpha.
|
|
85
|
+
"@bcts/components": "^1.0.0-alpha.14",
|
|
86
|
+
"@bcts/dcbor": "^1.0.0-alpha.14",
|
|
87
|
+
"@bcts/envelope": "^1.0.0-alpha.14",
|
|
88
|
+
"@bcts/known-values": "^1.0.0-alpha.14",
|
|
89
|
+
"@bcts/provenance-mark": "^1.0.0-alpha.14"
|
|
90
90
|
}
|
|
91
91
|
}
|
package/src/xid-document.ts
CHANGED
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
PrivateKeyBase,
|
|
26
26
|
type PrivateKeys,
|
|
27
27
|
type Signer,
|
|
28
|
+
type EncapsulationPublicKey,
|
|
28
29
|
} from "@bcts/components";
|
|
29
30
|
import {
|
|
30
31
|
type ProvenanceMark,
|
|
@@ -306,6 +307,26 @@ export class XIDDocument implements EnvelopeEncodable {
|
|
|
306
307
|
return this.inceptionKey()?.privateKeys();
|
|
307
308
|
}
|
|
308
309
|
|
|
310
|
+
/**
|
|
311
|
+
* Get the encryption key (encapsulation public key) for this document.
|
|
312
|
+
*
|
|
313
|
+
* Prefers the inception key for encryption. If no inception key is available,
|
|
314
|
+
* falls back to the first key in the document.
|
|
315
|
+
*/
|
|
316
|
+
encryptionKey(): EncapsulationPublicKey | undefined {
|
|
317
|
+
// Prefer the inception key for encryption
|
|
318
|
+
const inceptionKey = this.inceptionKey();
|
|
319
|
+
if (inceptionKey !== undefined) {
|
|
320
|
+
return inceptionKey.publicKeys().encapsulationPublicKey();
|
|
321
|
+
}
|
|
322
|
+
// Fall back to first key
|
|
323
|
+
const firstKey = this._keys.values().next().value;
|
|
324
|
+
if (firstKey !== undefined) {
|
|
325
|
+
return firstKey.publicKeys().encapsulationPublicKey();
|
|
326
|
+
}
|
|
327
|
+
return undefined;
|
|
328
|
+
}
|
|
329
|
+
|
|
309
330
|
/**
|
|
310
331
|
* Remove the inception key from the document.
|
|
311
332
|
*/
|