cojson 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/.eslintrc.cjs +11 -8
  2. package/dist/coValue.d.ts +97 -0
  3. package/dist/coValue.js +381 -0
  4. package/dist/coValue.js.map +1 -0
  5. package/dist/coValue.test.d.ts +1 -0
  6. package/dist/coValue.test.js +78 -0
  7. package/dist/coValue.test.js.map +1 -0
  8. package/dist/contentType.d.ts +15 -0
  9. package/dist/contentType.js +7 -0
  10. package/dist/contentType.js.map +1 -0
  11. package/dist/contentType.test.d.ts +1 -0
  12. package/dist/contentType.test.js +149 -0
  13. package/dist/contentType.test.js.map +1 -0
  14. package/dist/contentTypes/coList.d.ts +11 -0
  15. package/dist/contentTypes/coList.js +16 -0
  16. package/dist/contentTypes/coList.js.map +1 -0
  17. package/dist/contentTypes/coMap.d.ts +56 -0
  18. package/dist/contentTypes/coMap.js +126 -0
  19. package/dist/contentTypes/coMap.js.map +1 -0
  20. package/dist/contentTypes/coStream.d.ts +11 -0
  21. package/dist/contentTypes/coStream.js +16 -0
  22. package/dist/contentTypes/coStream.js.map +1 -0
  23. package/dist/contentTypes/static.d.ts +11 -0
  24. package/dist/contentTypes/static.js +14 -0
  25. package/dist/contentTypes/static.js.map +1 -0
  26. package/dist/crypto.d.ts +97 -0
  27. package/dist/crypto.js +156 -0
  28. package/dist/crypto.js.map +1 -0
  29. package/dist/crypto.test.d.ts +1 -0
  30. package/dist/crypto.test.js +115 -0
  31. package/dist/crypto.test.js.map +1 -0
  32. package/dist/ids.d.ts +7 -0
  33. package/dist/ids.js +2 -0
  34. package/dist/ids.js.map +1 -0
  35. package/dist/index.d.ts +19 -0
  36. package/dist/index.js +13 -0
  37. package/dist/index.js.map +1 -0
  38. package/dist/jsonValue.d.ts +7 -0
  39. package/dist/jsonValue.js +2 -0
  40. package/dist/jsonValue.js.map +1 -0
  41. package/dist/node.d.ts +33 -0
  42. package/dist/node.js +113 -0
  43. package/dist/node.js.map +1 -0
  44. package/dist/permissions.d.ts +54 -0
  45. package/dist/permissions.js +218 -0
  46. package/dist/permissions.js.map +1 -0
  47. package/dist/permissions.test.d.ts +1 -0
  48. package/dist/permissions.test.js +794 -0
  49. package/dist/permissions.test.js.map +1 -0
  50. package/dist/sync.d.ts +80 -0
  51. package/dist/sync.js +271 -0
  52. package/dist/sync.js.map +1 -0
  53. package/dist/sync.test.d.ts +1 -0
  54. package/dist/sync.test.js +826 -0
  55. package/dist/sync.test.js.map +1 -0
  56. package/package.json +5 -4
  57. package/src/coValue.test.ts +3 -4
  58. package/src/coValue.ts +11 -11
  59. package/src/contentType.test.ts +3 -3
  60. package/src/contentType.ts +6 -6
  61. package/src/contentTypes/coList.ts +4 -4
  62. package/src/contentTypes/coMap.ts +6 -6
  63. package/src/contentTypes/coStream.ts +4 -4
  64. package/src/contentTypes/static.ts +5 -5
  65. package/src/crypto.test.ts +1 -1
  66. package/src/crypto.ts +2 -2
  67. package/src/index.ts +8 -8
  68. package/src/jsonValue.ts +1 -1
  69. package/src/node.ts +6 -7
  70. package/src/permissions.test.ts +5 -5
  71. package/src/permissions.ts +7 -7
  72. package/src/sync.test.ts +7 -7
  73. package/src/sync.ts +6 -6
  74. package/tsconfig.json +1 -7
  75. package/dist/coValue.mjs +0 -437
  76. package/dist/coValue.test.mjs +0 -122
  77. package/dist/contentType.mjs +0 -7
  78. package/dist/contentType.test.mjs +0 -179
  79. package/dist/contentTypes/coList.mjs +0 -18
  80. package/dist/contentTypes/coMap.mjs +0 -126
  81. package/dist/contentTypes/coStream.mjs +0 -18
  82. package/dist/contentTypes/static.mjs +0 -16
  83. package/dist/crypto.mjs +0 -207
  84. package/dist/crypto.test.mjs +0 -155
  85. package/dist/ids.mjs +0 -1
  86. package/dist/index.mjs +0 -21
  87. package/dist/jsonValue.mjs +0 -1
  88. package/dist/node.mjs +0 -144
  89. package/dist/permissions.mjs +0 -244
  90. package/dist/permissions.test.mjs +0 -985
  91. package/dist/sync.mjs +0 -318
  92. package/dist/sync.test.mjs +0 -861
@@ -1,179 +0,0 @@
1
- "use strict";
2
- import {
3
- agentIDfromSessionID,
4
- getAgent,
5
- getAgentID,
6
- newRandomAgentCredential,
7
- newRandomSessionID
8
- } from "./coValue";
9
- import { createdNowUnique } from "./crypto";
10
- import { LocalNode } from "./node";
11
- test("Empty COJSON Map works", () => {
12
- const agentCredential = newRandomAgentCredential("agent1");
13
- const node = new LocalNode(
14
- agentCredential,
15
- newRandomSessionID(getAgentID(getAgent(agentCredential)))
16
- );
17
- const coValue = node.createCoValue({
18
- type: "comap",
19
- ruleset: { type: "unsafeAllowAll" },
20
- meta: null,
21
- ...createdNowUnique()
22
- });
23
- const content = coValue.getCurrentContent();
24
- if (content.type !== "comap") {
25
- throw new Error("Expected map");
26
- }
27
- expect(content.type).toEqual("comap");
28
- expect([...content.keys()]).toEqual([]);
29
- expect(content.toJSON()).toEqual({});
30
- });
31
- test("Can insert and delete Map entries in edit()", () => {
32
- const agentCredential = newRandomAgentCredential("agent1");
33
- const node = new LocalNode(
34
- agentCredential,
35
- newRandomSessionID(getAgentID(getAgent(agentCredential)))
36
- );
37
- const coValue = node.createCoValue({
38
- type: "comap",
39
- ruleset: { type: "unsafeAllowAll" },
40
- meta: null,
41
- ...createdNowUnique()
42
- });
43
- const content = coValue.getCurrentContent();
44
- if (content.type !== "comap") {
45
- throw new Error("Expected map");
46
- }
47
- expect(content.type).toEqual("comap");
48
- content.edit((editable) => {
49
- editable.set("hello", "world", "trusting");
50
- expect(editable.get("hello")).toEqual("world");
51
- editable.set("foo", "bar", "trusting");
52
- expect(editable.get("foo")).toEqual("bar");
53
- expect([...editable.keys()]).toEqual(["hello", "foo"]);
54
- editable.delete("foo", "trusting");
55
- expect(editable.get("foo")).toEqual(void 0);
56
- });
57
- });
58
- test("Can get map entry values at different points in time", () => {
59
- const agentCredential = newRandomAgentCredential("agent1");
60
- const node = new LocalNode(
61
- agentCredential,
62
- newRandomSessionID(getAgentID(getAgent(agentCredential)))
63
- );
64
- const coValue = node.createCoValue({
65
- type: "comap",
66
- ruleset: { type: "unsafeAllowAll" },
67
- meta: null,
68
- ...createdNowUnique()
69
- });
70
- const content = coValue.getCurrentContent();
71
- if (content.type !== "comap") {
72
- throw new Error("Expected map");
73
- }
74
- expect(content.type).toEqual("comap");
75
- content.edit((editable) => {
76
- const beforeA = Date.now();
77
- while (Date.now() < beforeA + 10) {
78
- }
79
- editable.set("hello", "A", "trusting");
80
- const beforeB = Date.now();
81
- while (Date.now() < beforeB + 10) {
82
- }
83
- editable.set("hello", "B", "trusting");
84
- const beforeC = Date.now();
85
- while (Date.now() < beforeC + 10) {
86
- }
87
- editable.set("hello", "C", "trusting");
88
- expect(editable.get("hello")).toEqual("C");
89
- expect(editable.getAtTime("hello", Date.now())).toEqual("C");
90
- expect(editable.getAtTime("hello", beforeA)).toEqual(void 0);
91
- expect(editable.getAtTime("hello", beforeB)).toEqual("A");
92
- expect(editable.getAtTime("hello", beforeC)).toEqual("B");
93
- });
94
- });
95
- test("Can get all historic values of key", () => {
96
- const agentCredential = newRandomAgentCredential("agent1");
97
- const node = new LocalNode(
98
- agentCredential,
99
- newRandomSessionID(getAgentID(getAgent(agentCredential)))
100
- );
101
- const coValue = node.createCoValue({
102
- type: "comap",
103
- ruleset: { type: "unsafeAllowAll" },
104
- meta: null,
105
- ...createdNowUnique()
106
- });
107
- const content = coValue.getCurrentContent();
108
- if (content.type !== "comap") {
109
- throw new Error("Expected map");
110
- }
111
- expect(content.type).toEqual("comap");
112
- content.edit((editable) => {
113
- var _a, _b, _c, _d;
114
- editable.set("hello", "A", "trusting");
115
- const txA = editable.getLastTxID("hello");
116
- editable.set("hello", "B", "trusting");
117
- const txB = editable.getLastTxID("hello");
118
- editable.delete("hello", "trusting");
119
- const txDel = editable.getLastTxID("hello");
120
- editable.set("hello", "C", "trusting");
121
- const txC = editable.getLastTxID("hello");
122
- expect(
123
- editable.getHistory("hello")
124
- ).toEqual([
125
- {
126
- txID: txA,
127
- value: "A",
128
- at: txA && ((_a = coValue.getTx(txA)) == null ? void 0 : _a.madeAt)
129
- },
130
- {
131
- txID: txB,
132
- value: "B",
133
- at: txB && ((_b = coValue.getTx(txB)) == null ? void 0 : _b.madeAt)
134
- },
135
- {
136
- txID: txDel,
137
- value: void 0,
138
- at: txDel && ((_c = coValue.getTx(txDel)) == null ? void 0 : _c.madeAt)
139
- },
140
- {
141
- txID: txC,
142
- value: "C",
143
- at: txC && ((_d = coValue.getTx(txC)) == null ? void 0 : _d.madeAt)
144
- }
145
- ]);
146
- });
147
- });
148
- test("Can get last tx ID for a key", () => {
149
- const agentCredential = newRandomAgentCredential("agent1");
150
- const node = new LocalNode(
151
- agentCredential,
152
- newRandomSessionID(getAgentID(getAgent(agentCredential)))
153
- );
154
- const coValue = node.createCoValue({
155
- type: "comap",
156
- ruleset: { type: "unsafeAllowAll" },
157
- meta: null,
158
- ...createdNowUnique()
159
- });
160
- const content = coValue.getCurrentContent();
161
- if (content.type !== "comap") {
162
- throw new Error("Expected map");
163
- }
164
- expect(content.type).toEqual("comap");
165
- content.edit((editable) => {
166
- var _a, _b, _c, _d;
167
- expect(editable.getLastTxID("hello")).toEqual(void 0);
168
- editable.set("hello", "A", "trusting");
169
- const sessionID = (_a = editable.getLastTxID("hello")) == null ? void 0 : _a.sessionID;
170
- expect(sessionID && agentIDfromSessionID(sessionID)).toEqual(
171
- getAgentID(getAgent(agentCredential))
172
- );
173
- expect((_b = editable.getLastTxID("hello")) == null ? void 0 : _b.txIndex).toEqual(0);
174
- editable.set("hello", "B", "trusting");
175
- expect((_c = editable.getLastTxID("hello")) == null ? void 0 : _c.txIndex).toEqual(1);
176
- editable.set("hello", "C", "trusting");
177
- expect((_d = editable.getLastTxID("hello")) == null ? void 0 : _d.txIndex).toEqual(2);
178
- });
179
- });
@@ -1,18 +0,0 @@
1
- "use strict";
2
- export class CoList {
3
- id;
4
- type = "colist";
5
- coValue;
6
- constructor(coValue) {
7
- this.id = coValue.id;
8
- this.coValue = coValue;
9
- }
10
- toJSON() {
11
- throw new Error("Method not implemented.");
12
- }
13
- subscribe(listener) {
14
- return this.coValue.subscribe((content) => {
15
- listener(content);
16
- });
17
- }
18
- }
@@ -1,126 +0,0 @@
1
- "use strict";
2
- export class CoMap {
3
- id;
4
- coValue;
5
- type = "comap";
6
- ops;
7
- constructor(coValue) {
8
- this.id = coValue.id;
9
- this.coValue = coValue;
10
- this.ops = {};
11
- this.fillOpsFromCoValue();
12
- }
13
- fillOpsFromCoValue() {
14
- this.ops = {};
15
- for (const { txID, changes, madeAt } of this.coValue.getValidSortedTransactions()) {
16
- for (const [changeIdx, changeUntyped] of changes.entries()) {
17
- const change = changeUntyped;
18
- let entries = this.ops[change.key];
19
- if (!entries) {
20
- entries = [];
21
- this.ops[change.key] = entries;
22
- }
23
- entries.push({
24
- txID,
25
- madeAt,
26
- changeIdx,
27
- ...change
28
- });
29
- }
30
- }
31
- }
32
- keys() {
33
- return Object.keys(this.ops);
34
- }
35
- get(key) {
36
- const ops = this.ops[key];
37
- if (!ops) {
38
- return void 0;
39
- }
40
- const lastEntry = ops[ops.length - 1];
41
- if (lastEntry.op === "delete") {
42
- return void 0;
43
- } else {
44
- return lastEntry.value;
45
- }
46
- }
47
- getAtTime(key, time) {
48
- const ops = this.ops[key];
49
- if (!ops) {
50
- return void 0;
51
- }
52
- const lastOpBeforeOrAtTime = ops.findLast((op) => op.madeAt <= time);
53
- if (!lastOpBeforeOrAtTime) {
54
- return void 0;
55
- }
56
- if (lastOpBeforeOrAtTime.op === "delete") {
57
- return void 0;
58
- } else {
59
- return lastOpBeforeOrAtTime.value;
60
- }
61
- }
62
- getLastTxID(key) {
63
- const ops = this.ops[key];
64
- if (!ops) {
65
- return void 0;
66
- }
67
- const lastEntry = ops[ops.length - 1];
68
- return lastEntry.txID;
69
- }
70
- getHistory(key) {
71
- const ops = this.ops[key];
72
- if (!ops) {
73
- return [];
74
- }
75
- const history = [];
76
- for (const op of ops) {
77
- if (op.op === "delete") {
78
- history.push({ at: op.madeAt, txID: op.txID, value: void 0 });
79
- } else {
80
- history.push({ at: op.madeAt, txID: op.txID, value: op.value });
81
- }
82
- }
83
- return history;
84
- }
85
- toJSON() {
86
- const json = {};
87
- for (const key of this.keys()) {
88
- const value = this.get(key);
89
- if (value !== void 0) {
90
- json[key] = value;
91
- }
92
- }
93
- return json;
94
- }
95
- edit(changer) {
96
- const editable = new WriteableCoMap(this.coValue);
97
- changer(editable);
98
- return new CoMap(this.coValue);
99
- }
100
- subscribe(listener) {
101
- return this.coValue.subscribe((content) => {
102
- listener(content);
103
- });
104
- }
105
- }
106
- export class WriteableCoMap extends CoMap {
107
- set(key, value, privacy = "private") {
108
- this.coValue.makeTransaction([
109
- {
110
- op: "insert",
111
- key,
112
- value
113
- }
114
- ], privacy);
115
- this.fillOpsFromCoValue();
116
- }
117
- delete(key, privacy = "private") {
118
- this.coValue.makeTransaction([
119
- {
120
- op: "delete",
121
- key
122
- }
123
- ], privacy);
124
- this.fillOpsFromCoValue();
125
- }
126
- }
@@ -1,18 +0,0 @@
1
- "use strict";
2
- export class CoStream {
3
- id;
4
- type = "costream";
5
- coValue;
6
- constructor(coValue) {
7
- this.id = coValue.id;
8
- this.coValue = coValue;
9
- }
10
- toJSON() {
11
- throw new Error("Method not implemented.");
12
- }
13
- subscribe(listener) {
14
- return this.coValue.subscribe((content) => {
15
- listener(content);
16
- });
17
- }
18
- }
@@ -1,16 +0,0 @@
1
- "use strict";
2
- export class Static {
3
- id;
4
- type = "static";
5
- coValue;
6
- constructor(coValue) {
7
- this.id = coValue.id;
8
- this.coValue = coValue;
9
- }
10
- toJSON() {
11
- throw new Error("Method not implemented.");
12
- }
13
- subscribe(listener) {
14
- throw new Error("Method not implemented.");
15
- }
16
- }
package/dist/crypto.mjs DELETED
@@ -1,207 +0,0 @@
1
- "use strict";
2
- import { ed25519, x25519 } from "@noble/curves/ed25519";
3
- import { xsalsa20_poly1305, xsalsa20 } from "@noble/ciphers/salsa";
4
- import { base58, base64url } from "@scure/base";
5
- import stableStringify from "fast-json-stable-stringify";
6
- import { blake3 } from "@noble/hashes/blake3";
7
- import { randomBytes } from "@noble/ciphers/webcrypto/utils";
8
- const textEncoder = new TextEncoder();
9
- const textDecoder = new TextDecoder();
10
- export function newRandomSignatory() {
11
- return `signatorySecret_z${base58.encode(
12
- ed25519.utils.randomPrivateKey()
13
- )}`;
14
- }
15
- export function signatorySecretToBytes(secret) {
16
- return base58.decode(secret.substring("signatorySecret_z".length));
17
- }
18
- export function signatorySecretFromBytes(bytes) {
19
- return `signatorySecret_z${base58.encode(bytes)}`;
20
- }
21
- export function getSignatoryID(secret) {
22
- return `signatory_z${base58.encode(
23
- ed25519.getPublicKey(
24
- base58.decode(secret.substring("signatorySecret_z".length))
25
- )
26
- )}`;
27
- }
28
- export function sign(secret, message) {
29
- const signature = ed25519.sign(
30
- textEncoder.encode(stableStringify(message)),
31
- base58.decode(secret.substring("signatorySecret_z".length))
32
- );
33
- return `signature_z${base58.encode(signature)}`;
34
- }
35
- export function verify(signature, message, id) {
36
- return ed25519.verify(
37
- base58.decode(signature.substring("signature_z".length)),
38
- textEncoder.encode(stableStringify(message)),
39
- base58.decode(id.substring("signatory_z".length))
40
- );
41
- }
42
- export function newRandomRecipient() {
43
- return `recipientSecret_z${base58.encode(x25519.utils.randomPrivateKey())}`;
44
- }
45
- export function recipientSecretToBytes(secret) {
46
- return base58.decode(secret.substring("recipientSecret_z".length));
47
- }
48
- export function recipientSecretFromBytes(bytes) {
49
- return `recipientSecret_z${base58.encode(bytes)}`;
50
- }
51
- export function getRecipientID(secret) {
52
- return `recipient_z${base58.encode(
53
- x25519.getPublicKey(
54
- base58.decode(secret.substring("recipientSecret_z".length))
55
- )
56
- )}`;
57
- }
58
- export function seal(message, from, to, nOnceMaterial) {
59
- const nOnce = blake3(
60
- textEncoder.encode(stableStringify(nOnceMaterial))
61
- ).slice(0, 24);
62
- const recipientsSorted = Array.from(to).sort();
63
- const recipientPubs = recipientsSorted.map((recipient) => {
64
- return base58.decode(recipient.substring("recipient_z".length));
65
- });
66
- const senderPriv = base58.decode(
67
- from.substring("recipientSecret_z".length)
68
- );
69
- const plaintext = textEncoder.encode(stableStringify(message));
70
- const sealedSet = {};
71
- for (let i = 0; i < recipientsSorted.length; i++) {
72
- const recipient = recipientsSorted[i];
73
- const sharedSecret = x25519.getSharedSecret(
74
- senderPriv,
75
- recipientPubs[i]
76
- );
77
- const sealedBytes = xsalsa20_poly1305(sharedSecret, nOnce).encrypt(
78
- plaintext
79
- );
80
- sealedSet[recipient] = `sealed_U${base64url.encode(
81
- sealedBytes
82
- )}`;
83
- }
84
- return sealedSet;
85
- }
86
- export function openAs(sealedSet, recipient, from, nOnceMaterial) {
87
- const nOnce = blake3(
88
- textEncoder.encode(stableStringify(nOnceMaterial))
89
- ).slice(0, 24);
90
- const recipientPriv = base58.decode(
91
- recipient.substring("recipientSecret_z".length)
92
- );
93
- const senderPub = base58.decode(from.substring("recipient_z".length));
94
- const sealed = sealedSet[getRecipientID(recipient)];
95
- if (!sealed) {
96
- return void 0;
97
- }
98
- const sealedBytes = base64url.decode(sealed.substring("sealed_U".length));
99
- const sharedSecret = x25519.getSharedSecret(recipientPriv, senderPub);
100
- const plaintext = xsalsa20_poly1305(sharedSecret, nOnce).decrypt(
101
- sealedBytes
102
- );
103
- try {
104
- return JSON.parse(textDecoder.decode(plaintext));
105
- } catch (e) {
106
- console.error("Failed to decrypt/parse sealed message", e);
107
- return void 0;
108
- }
109
- }
110
- export function secureHash(value) {
111
- return `hash_z${base58.encode(
112
- blake3(textEncoder.encode(stableStringify(value)))
113
- )}`;
114
- }
115
- export class StreamingHash {
116
- state;
117
- constructor(fromClone) {
118
- this.state = fromClone || blake3.create({});
119
- }
120
- update(value) {
121
- this.state.update(textEncoder.encode(stableStringify(value)));
122
- }
123
- digest() {
124
- const hash = this.state.digest();
125
- return `hash_z${base58.encode(hash)}`;
126
- }
127
- clone() {
128
- return new StreamingHash(this.state.clone());
129
- }
130
- }
131
- export function shortHash(value) {
132
- return `shortHash_z${base58.encode(
133
- blake3(textEncoder.encode(stableStringify(value))).slice(0, 19)
134
- )}`;
135
- }
136
- export function newRandomKeySecret() {
137
- return {
138
- secret: `keySecret_z${base58.encode(randomBytes(32))}`,
139
- id: `key_z${base58.encode(randomBytes(12))}`
140
- };
141
- }
142
- function encrypt(value, keySecret, nOnceMaterial) {
143
- const keySecretBytes = base58.decode(
144
- keySecret.substring("keySecret_z".length)
145
- );
146
- const nOnce = blake3(
147
- textEncoder.encode(stableStringify(nOnceMaterial))
148
- ).slice(0, 24);
149
- const plaintext = textEncoder.encode(stableStringify(value));
150
- const ciphertext = xsalsa20(keySecretBytes, nOnce, plaintext);
151
- return `encrypted_U${base64url.encode(ciphertext)}`;
152
- }
153
- export function encryptForTransaction(value, keySecret, nOnceMaterial) {
154
- return encrypt(value, keySecret, nOnceMaterial);
155
- }
156
- export function sealKeySecret(keys) {
157
- const nOnceMaterial = {
158
- sealed: keys.toSeal.id,
159
- sealing: keys.sealing.id
160
- };
161
- return {
162
- sealed: keys.toSeal.id,
163
- sealing: keys.sealing.id,
164
- encrypted: encrypt(
165
- keys.toSeal.secret,
166
- keys.sealing.secret,
167
- nOnceMaterial
168
- )
169
- };
170
- }
171
- function decrypt(encrypted, keySecret, nOnceMaterial) {
172
- const keySecretBytes = base58.decode(
173
- keySecret.substring("keySecret_z".length)
174
- );
175
- const nOnce = blake3(
176
- textEncoder.encode(stableStringify(nOnceMaterial))
177
- ).slice(0, 24);
178
- const ciphertext = base64url.decode(
179
- encrypted.substring("encrypted_U".length)
180
- );
181
- const plaintext = xsalsa20(keySecretBytes, nOnce, ciphertext);
182
- try {
183
- return JSON.parse(textDecoder.decode(plaintext));
184
- } catch (e) {
185
- return void 0;
186
- }
187
- }
188
- export function decryptForTransaction(encrypted, keySecret, nOnceMaterial) {
189
- return decrypt(encrypted, keySecret, nOnceMaterial);
190
- }
191
- export function unsealKeySecret(sealedInfo, sealingSecret) {
192
- const nOnceMaterial = {
193
- sealed: sealedInfo.sealed,
194
- sealing: sealedInfo.sealing
195
- };
196
- return decrypt(sealedInfo.encrypted, sealingSecret, nOnceMaterial);
197
- }
198
- export function uniquenessForHeader() {
199
- return `z${base58.encode(randomBytes(12))}`;
200
- }
201
- export function createdNowUnique() {
202
- const createdAt = (/* @__PURE__ */ new Date()).toISOString();
203
- return {
204
- createdAt,
205
- uniqueness: uniquenessForHeader()
206
- };
207
- }