@degenerate/sharedata 0.2.7 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/README.md +31 -0
  2. package/dist/index.d.ts +16 -0
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +20 -0
  5. package/dist/manager/share-data-manager-events.d.ts +27 -0
  6. package/dist/manager/share-data-manager-events.d.ts.map +1 -0
  7. package/dist/manager/share-data-manager-events.js +2 -0
  8. package/dist/manager/share-data-manager.d.ts +84 -0
  9. package/dist/manager/share-data-manager.d.ts.map +1 -0
  10. package/dist/manager/share-data-manager.js +210 -0
  11. package/dist/persistence/block-factory-registry.d.ts +51 -0
  12. package/dist/persistence/block-factory-registry.d.ts.map +1 -0
  13. package/dist/persistence/block-factory-registry.js +36 -0
  14. package/dist/persistence/deserialize-share-data.d.ts +18 -0
  15. package/dist/persistence/deserialize-share-data.d.ts.map +1 -0
  16. package/dist/persistence/deserialize-share-data.js +144 -0
  17. package/dist/persistence/file-share-data-repository.d.ts +30 -0
  18. package/dist/persistence/file-share-data-repository.d.ts.map +1 -0
  19. package/dist/persistence/file-share-data-repository.js +147 -0
  20. package/dist/persistence/firestore-share-data-repository.d.ts +38 -0
  21. package/dist/persistence/firestore-share-data-repository.d.ts.map +1 -0
  22. package/dist/persistence/firestore-share-data-repository.js +78 -0
  23. package/dist/persistence/in-memory-share-data-repository.d.ts +19 -0
  24. package/dist/persistence/in-memory-share-data-repository.d.ts.map +1 -0
  25. package/dist/persistence/in-memory-share-data-repository.js +48 -0
  26. package/dist/persistence/serialize-share-data.d.ts +22 -0
  27. package/dist/persistence/serialize-share-data.d.ts.map +1 -0
  28. package/dist/persistence/serialize-share-data.js +62 -0
  29. package/dist/persistence/share-data-repository.d.ts +49 -0
  30. package/dist/persistence/share-data-repository.d.ts.map +1 -0
  31. package/dist/persistence/share-data-repository.js +2 -0
  32. package/dist/share-data/creation/create-share-data-initial-crypto.d.ts +11 -0
  33. package/dist/share-data/creation/create-share-data-initial-crypto.d.ts.map +1 -0
  34. package/dist/share-data/creation/create-share-data-initial-crypto.js +26 -0
  35. package/dist/share-data/helpers/calculate-share-data-string.d.ts +21 -0
  36. package/dist/share-data/helpers/calculate-share-data-string.d.ts.map +1 -0
  37. package/dist/share-data/helpers/calculate-share-data-string.js +71 -0
  38. package/dist/share-data/helpers/config/default-share-data-string.config.d.ts +7 -0
  39. package/dist/share-data/helpers/config/default-share-data-string.config.d.ts.map +1 -0
  40. package/dist/share-data/helpers/config/default-share-data-string.config.js +25 -0
  41. package/dist/share-data/helpers/config/stringify.d.ts +5 -0
  42. package/dist/share-data/helpers/config/stringify.d.ts.map +1 -0
  43. package/dist/share-data/helpers/config/stringify.js +10 -0
  44. package/dist/share-data/helpers/get-array-string.d.ts +6 -0
  45. package/dist/share-data/helpers/get-array-string.d.ts.map +1 -0
  46. package/dist/share-data/helpers/get-array-string.js +17 -0
  47. package/dist/share-data/proofs/creation/build-transaction-proposal-signer.d.ts +57 -0
  48. package/dist/share-data/proofs/creation/build-transaction-proposal-signer.d.ts.map +1 -0
  49. package/dist/share-data/proofs/creation/build-transaction-proposal-signer.js +36 -0
  50. package/dist/share-data/proofs/creation/create-share-data-proposal-proof.d.ts +12 -0
  51. package/dist/share-data/proofs/creation/create-share-data-proposal-proof.d.ts.map +1 -0
  52. package/dist/share-data/proofs/creation/create-share-data-proposal-proof.js +41 -0
  53. package/dist/share-data/proofs/creation/create-transaction-proposal-proof.d.ts +27 -0
  54. package/dist/share-data/proofs/creation/create-transaction-proposal-proof.d.ts.map +1 -0
  55. package/dist/share-data/proofs/creation/create-transaction-proposal-proof.js +58 -0
  56. package/dist/share-data/proofs/helpers/create-share-data-string-to-sign.d.ts +12 -0
  57. package/dist/share-data/proofs/helpers/create-share-data-string-to-sign.d.ts.map +1 -0
  58. package/dist/share-data/proofs/helpers/create-share-data-string-to-sign.js +17 -0
  59. package/dist/share-data/proofs/helpers/create-transaction-proposal-string-to-sign.d.ts +24 -0
  60. package/dist/share-data/proofs/helpers/create-transaction-proposal-string-to-sign.d.ts.map +1 -0
  61. package/dist/share-data/proofs/helpers/create-transaction-proposal-string-to-sign.js +29 -0
  62. package/dist/share-data/proofs/helpers/get-previous-hash-from-share-data.d.ts +9 -0
  63. package/dist/share-data/proofs/helpers/get-previous-hash-from-share-data.d.ts.map +1 -0
  64. package/dist/share-data/proofs/helpers/get-previous-hash-from-share-data.js +28 -0
  65. package/dist/share-data/proofs/helpers/hash-proposed-state.d.ts +12 -0
  66. package/dist/share-data/proofs/helpers/hash-proposed-state.d.ts.map +1 -0
  67. package/dist/share-data/proofs/helpers/hash-proposed-state.js +18 -0
  68. package/dist/share-data/proofs/testing/test-proof-signer.d.ts +53 -0
  69. package/dist/share-data/proofs/testing/test-proof-signer.d.ts.map +1 -0
  70. package/dist/share-data/proofs/testing/test-proof-signer.js +113 -0
  71. package/dist/share-data/proofs/verification/verify-share-data-proposal-proof.d.ts +40 -0
  72. package/dist/share-data/proofs/verification/verify-share-data-proposal-proof.d.ts.map +1 -0
  73. package/dist/share-data/proofs/verification/verify-share-data-proposal-proof.js +126 -0
  74. package/dist/share-data/proofs/verification/verify-transaction-proposal-proof.d.ts +37 -0
  75. package/dist/share-data/proofs/verification/verify-transaction-proposal-proof.d.ts.map +1 -0
  76. package/dist/share-data/proofs/verification/verify-transaction-proposal-proof.js +125 -0
  77. package/dist/share-data/share-data.d.ts +180 -27
  78. package/dist/share-data/share-data.d.ts.map +1 -1
  79. package/dist/share-data/share-data.js +303 -60
  80. package/package.json +31 -13
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ShareData = void 0;
4
4
  const rules_1 = require("@degenerate/rules");
5
5
  const generic_1 = require("@degenerate/generic");
6
+ const verify_share_data_proposal_proof_1 = require("./proofs/verification/verify-share-data-proposal-proof");
7
+ const verify_transaction_proposal_proof_1 = require("./proofs/verification/verify-transaction-proposal-proof");
6
8
  /**
7
9
  * This contains the interface for the share data object
8
10
  */
@@ -10,48 +12,84 @@ class ShareData {
10
12
  /**
11
13
  * This is the constructor for the share data object
12
14
  * @param id the id of the share data
15
+ * @param creationPublicKey the public key of the creator of the share data
13
16
  */
14
- constructor(id) {
15
- this.isLocked = false;
16
- this._version = 1,
17
- this._id = id;
17
+ constructor(id, creationPublicKey, signingCurve = generic_1.EllipticalCurvesSigning.Curve25519) {
18
+ this._id = id;
19
+ this._creationHash = '';
20
+ this._creationSignature = '';
21
+ this._creationPublicKey = creationPublicKey,
22
+ this._version = 1,
23
+ this._isLocked = false;
24
+ this._lastUpdated = 0;
18
25
  this._rules = [];
19
26
  this._functions = [];
20
27
  this._transactionHistory = [];
21
28
  this._events = [];
22
- this._data = {};
29
+ this._currentState = {};
30
+ this._cryptoProofs = [];
31
+ this._signingCurve = signingCurve;
32
+ this._structuralProofs = [];
23
33
  }
24
- //#region Getters and Setters
25
34
  /**
26
- * This adds a rule to the share block.
27
- * @param rule the rule to add to the share block
35
+ * This initializes the cryptographic properties of the share data
36
+ * @param creationPublicKey the public key of the creator of the share data (in hex format)
37
+ * @param creationHash the hash of the share data
38
+ * @param creationSignature the cryptographic signature of the share data
28
39
  */
29
- addRule(rule) {
30
- if (this.isLocked) {
31
- throw new generic_1.ShareDataIsLockedError(this._id, generic_1.ShareDataTypes.RULE);
40
+ initializeCrypto(initialCryptoData) {
41
+ // Implement the logic to initialize the cryptographic properties
42
+ if (this._creationSignature || this._creationHash || this._lastUpdated != 0) {
43
+ throw new generic_1.ShareDataCryptoAlreadyExistsError(this._id);
32
44
  }
33
- this._rules.push(rule);
45
+ if (initialCryptoData.publicKey !== this._creationPublicKey) {
46
+ throw new generic_1.CryptoInitializationPublicKeyIsDifferentError(this._id);
47
+ }
48
+ // check that the share data proof is valid.
49
+ this._lastUpdated = initialCryptoData.timestamp;
50
+ this._creationHash = initialCryptoData.shareDataHash;
51
+ this._creationSignature = initialCryptoData.shareDataSignature;
34
52
  }
53
+ //#region Validation
35
54
  /**
36
- * This gets the rules for the share block
55
+ * This validates the cryptographic properties of the share data
37
56
  */
38
- get rules() {
39
- return this._rules;
57
+ // validateRuleUpdate = (ruleToAdd )
58
+ //#endregion Validation
59
+ /**
60
+ * This validates the cryptographic properties of the share data
61
+ * @param creationPublicKey the public key of the creator of the share data (in hex format)
62
+ */
63
+ //#region Getters and Setters
64
+ /**
65
+ * get the creation hash
66
+ */
67
+ get creationHash() {
68
+ return this._creationHash;
40
69
  }
41
70
  /**
42
- * This gets the transaction history for the share block
71
+ * get the creation public key
43
72
  */
44
- addFunction(func) {
45
- if (this.isLocked) {
46
- throw new generic_1.ShareDataIsLockedError(this._id, generic_1.ShareDataTypes.FUNCTION);
47
- }
48
- this._functions.push(func);
73
+ get creationPublicKey() {
74
+ return this._creationPublicKey;
49
75
  }
50
76
  /**
51
- * This gets the functions for the share block
77
+ * get the creation signature
52
78
  */
53
- get functions() {
54
- return this._functions;
79
+ get creationSignature() {
80
+ return this._creationSignature;
81
+ }
82
+ /**
83
+ * This gets all cryptographic proofs for the share data
84
+ */
85
+ get cryptoProofs() {
86
+ return this._cryptoProofs;
87
+ }
88
+ /**
89
+ * This returns the current state of data for the share block
90
+ */
91
+ get currentState() {
92
+ return this._currentState;
55
93
  }
56
94
  /**
57
95
  * This gets the events for the sharedata
@@ -59,6 +97,62 @@ class ShareData {
59
97
  get events() {
60
98
  return this._events;
61
99
  }
100
+ /**
101
+ * This gets the functions for the share block
102
+ */
103
+ get functions() {
104
+ return this._functions;
105
+ }
106
+ /**
107
+ * This gets the id for the share data
108
+ */
109
+ get id() {
110
+ return this._id;
111
+ }
112
+ /**
113
+ * This get whether the share data is locked
114
+ */
115
+ get isLocked() {
116
+ return this._isLocked;
117
+ }
118
+ /**
119
+ * This gets the last timestamp (in milliseconds) that the share data was updated
120
+ */
121
+ get lastUpdated() {
122
+ return this._lastUpdated;
123
+ }
124
+ /**
125
+ * This gets the rules for the share block
126
+ */
127
+ get rules() {
128
+ return this._rules;
129
+ }
130
+ /**
131
+ * This gets the elliptical curve used for signing
132
+ */
133
+ get signingCurve() {
134
+ return this._signingCurve;
135
+ }
136
+ /**
137
+ * This gets the structure proofs for the share data
138
+ */
139
+ get structuralProofs() {
140
+ return this._structuralProofs;
141
+ }
142
+ /**
143
+ * This gets the transaction history for the share block
144
+ */
145
+ get transactionHistory() {
146
+ return this._transactionHistory;
147
+ }
148
+ /**
149
+ * This gets the version of the share data
150
+ */
151
+ get version() {
152
+ return this._version;
153
+ }
154
+ //#endregion Getters and Setters
155
+ //#region Adders
62
156
  /**
63
157
  * This adds an event to the share data
64
158
  * @param event the event to add
@@ -67,16 +161,53 @@ class ShareData {
67
161
  this._events.push(event);
68
162
  }
69
163
  /**
70
- * This adds a transaction to the share block
71
- * @param rulesEvaluation the evaluation of the rules (result)
72
- * @param transactionFunction the function that was run
164
+ * This adds a function to the share block.
165
+ * @param func the function to add to the share block
166
+ */
167
+ addFunction(func, cryptoProof) {
168
+ if (this._isLocked) {
169
+ throw new generic_1.ShareDataIsLockedError(this._id, generic_1.ShareDataTypes.FUNCTION);
170
+ }
171
+ // Verify against the share-data state as it stands BEFORE this
172
+ // function is appended. The signer signed over that pre-append
173
+ // snapshot, so verifying after the push would always fail.
174
+ this.verifyStructuralProof(cryptoProof);
175
+ this._structuralProofs.push(cryptoProof);
176
+ this._functions.push(func);
177
+ }
178
+ /**
179
+ * This adds a rule to the share block.
180
+ * @param rule the rule to add to the share block
73
181
  */
74
- addTransactionAlreadyValidated(proposedData, rulesEvaluation, transactionFunction) {
182
+ addRule(rule, cryptoProof) {
183
+ if (this._isLocked) {
184
+ throw new generic_1.ShareDataIsLockedError(this._id, generic_1.ShareDataTypes.RULE);
185
+ }
186
+ // Same pre-append verification as addFunction — the signer signed
187
+ // over the state before this rule was added.
188
+ this.verifyStructuralProof(cryptoProof);
189
+ this._structuralProofs.push(cryptoProof);
190
+ this._rules.push(rule);
191
+ }
192
+ /**
193
+ * Append a pre-validated transaction to the history. Pass `transactionTime`
194
+ * when the caller needs the recorded timestamp to be deterministic — for
195
+ * example, when a wire-format payload is being reconstructed and the
196
+ * resulting share-data state must hash identically to the one the
197
+ * remote signer produced. Omit it for ordinary live calls; defaults to
198
+ * `Date.now()`.
199
+ *
200
+ * Pass `proof` when replaying a persisted transaction so the rebuilt
201
+ * history entry carries the same proposal proof the live entry did. The
202
+ * canonical share-data hash folds `transactionHistory` in, so omitting the
203
+ * proof here would make a replayed block hash differently from the original
204
+ * and break verification of any later transaction's proof.
205
+ */
206
+ addTransactionAlreadyValidated(proposedData, rulesEvaluation, transactionFunction, transactionTime = Date.now(), proof) {
75
207
  // make sure the function is known.
76
208
  if (!this._functions.includes(transactionFunction)) {
77
209
  throw new Error('The function is not known');
78
210
  }
79
- const transactionTime = Date.now(); // get the current time
80
211
  const transactionId = this._transactionHistory.length + 1; // get the transaction id
81
212
  const ruleOutcome = (rulesEvaluation.proposedResult && rulesEvaluation.currentResult);
82
213
  const transaction = {
@@ -85,76 +216,188 @@ class ShareData {
85
216
  transactionFunction,
86
217
  transactionId: transactionId.toString(),
87
218
  transactionTime,
219
+ ...(proof ? { proof } : {}),
88
220
  };
89
221
  // the outcome of the rules is valid write the data to be the new current data.
90
222
  if (ruleOutcome) {
91
- this._data = proposedData;
223
+ this._currentState = proposedData;
92
224
  }
93
225
  this._transactionHistory.push(transaction);
94
226
  }
95
227
  /**
96
228
  * This adds a transaction to the share block but the transaction has not yet been validated
97
229
  *
230
+ * The unsigned/internal apply path: it runs the rule engine and records the
231
+ * outcome but carries no proposal proof, so it does NOT attest that any key
232
+ * holder authorized the change. New runtime mutations should go through
233
+ * {@link addTransaction}, which verifies a transaction proposal proof first.
234
+ * Retained for internal replay/seed callers that operate before the signed
235
+ * boundary is in play.
236
+ *
98
237
  * @param proposedData the proposed data
99
238
  * @param transactionFunction the function that was attempted
100
239
  */
101
240
  addTransactionNotValidated(proposedData, transactionFunction) {
241
+ return this.evaluateAndApply(proposedData, transactionFunction);
242
+ }
243
+ /**
244
+ * Signed runtime mutation path. Verifies that `proof` cryptographically
245
+ * authorizes applying `transactionFunction` to move this share-data to
246
+ * exactly `proposedData`, then runs the rule engine and records the
247
+ * outcome. The recorded history entry carries `proof`, so the audit log
248
+ * itself holds the signature — not merely "which function ran."
249
+ *
250
+ * Four gates, in order:
251
+ * 1. The function must be registered on this block.
252
+ * 2. The function must be addressable (`id` set) and the proof must be
253
+ * minted for that same id (`proof.purpose === transactionFunction.id`).
254
+ * This binds the proof to *this* function so a proof minted for one
255
+ * function can't be replayed to drive another even if the proposed
256
+ * state would satisfy both functions' rules.
257
+ * 3. The proof's signer must be authorized for this block —
258
+ * `proof.publicKey === creationPublicKey`. Signature validity alone
259
+ * only proves *someone* signed the transition; this binds the
260
+ * *authorized* someone (the block's creation key, the same key the
261
+ * HTTP create/delete ACL authorizes against). Without it any valid
262
+ * keypair could sign a legal transition.
263
+ * 4. The proof must verify against the current state AND `proposedData`
264
+ * (closes the amount-replay hole — see
265
+ * `verifyTransactionProposalProof`).
266
+ *
267
+ * Throws {@link ShareDataTransactionNotAuthorizedError} when the signer is
268
+ * not authorized (gate 3), {@link ShareDataTransactionProofFailedError} on
269
+ * any other auth failure — both before the rule engine runs and before any
270
+ * state is touched.
271
+ *
272
+ * @param proposedData the proposed next state
273
+ * @param transactionFunction the function producing `proposedData`
274
+ * @param proof the transaction proposal proof authorizing the change
275
+ */
276
+ addTransaction(proposedData, transactionFunction, proof) {
277
+ // Gate 1: function registered on this block.
278
+ if (!this._functions.includes(transactionFunction)) {
279
+ throw new Error('The function is not known');
280
+ }
281
+ // Gate 2: bind the proof to this specific function. The signed runtime
282
+ // path requires addressable functions — an id-less function cannot be
283
+ // the subject of a proof, so reject rather than silently skip the
284
+ // binding.
285
+ const functionId = transactionFunction.id;
286
+ if (typeof functionId !== 'string' || functionId.length < 1) {
287
+ throw new generic_1.ShareDataTransactionProofFailedError(this._id);
288
+ }
289
+ if (proof.purpose !== functionId) {
290
+ throw new generic_1.ShareDataTransactionProofFailedError(this._id);
291
+ }
292
+ // Gate 3: bind the proposer identity. Only the block's creation key may
293
+ // authorize runtime mutations. Checked before the (more expensive)
294
+ // signature verification so an unauthorized signer fails fast.
295
+ if (proof.publicKey !== this._creationPublicKey) {
296
+ throw new generic_1.ShareDataTransactionNotAuthorizedError(this._id, proof.publicKey);
297
+ }
298
+ // Gate 4: proof binds current state + proposed state + chain position.
299
+ this.verifyTransactionProof(proof, proposedData);
300
+ return this.evaluateAndApply(proposedData, transactionFunction, proof);
301
+ }
302
+ /**
303
+ * Shared rule-evaluate → apply-if-valid → record path used by both
304
+ * {@link addTransactionNotValidated} (no proof) and {@link addTransaction}
305
+ * (proof already verified by the caller). When `proof` is supplied it is
306
+ * recorded on the history entry so the audit log carries the signature.
307
+ */
308
+ evaluateAndApply(proposedData, transactionFunction, proof) {
102
309
  // make sure the function is known.
103
310
  if (!this._functions.includes(transactionFunction)) {
104
311
  // throw ShareDataFunctionBeingAppliedDoesNotExistOnShareDataError
105
312
  throw new Error('The function is not known');
106
313
  }
107
- // // evaluate the rules.
108
- // const rulesEvalOutcome = evaluateRules('transaction', this._data, proposedData, this._rules);
109
- const rulesOutcome = (0, rules_1.startRuleEvaluation)(this._id, transactionFunction, this.functions, this._rules, this._data, proposedData);
110
- const transactionTime = Date.now(); // get the current time
111
- const transactionId = this._transactionHistory.length + 1; // get the transaction id
314
+ const rulesOutcome = (0, rules_1.startRuleEvaluation)(this._id, transactionFunction, this.functions, this._rules, this._currentState, proposedData);
315
+ const transactionTime = Date.now();
316
+ const transactionId = (this._transactionHistory.length + 1).toString();
112
317
  const transaction = {
113
318
  ruleOutcome: rulesOutcome.isValidProposal,
114
319
  ruleFailures: [],
115
320
  transactionFunction,
116
- transactionId: transactionId.toString(),
321
+ transactionId,
117
322
  transactionTime,
323
+ ...(proof ? { proof } : {}),
118
324
  };
119
- // update the data if the rules are valid
120
325
  if (rulesOutcome.isValidProposal) {
121
- this._data = proposedData;
326
+ this._currentState = proposedData;
122
327
  }
123
- // add the transaction to the history
124
328
  this._transactionHistory.push(transaction);
329
+ return { accepted: rulesOutcome.isValidProposal, transactionId };
125
330
  }
126
- /**
127
- * This gets the transaction history for the share block
128
- */
129
- get transactionHistory() {
130
- return this._transactionHistory;
131
- }
132
- /**
133
- * This returns the current state of data for the share block
134
- */
135
- get data() {
136
- return this._data;
137
- }
138
- /**
139
- * This gets the version of the share data
140
- */
141
- get version() {
142
- return this._version;
143
- }
331
+ //#region Adders
332
+ //#region Copy
144
333
  /**
145
334
  * This copies a share data object to a new transaction number
146
335
  * @param transactionNumber the number of the transaction to run until.
336
+ * @param publicKey the public key of the application that will be the new owner of the share data
147
337
  */
148
- copyTo(transactionNumber) {
338
+ copyTo(transactionNumber, publicKey) {
149
339
  // return share data with a new ID
150
- const newShareData = new ShareData(`${this._id}-${transactionNumber}`);
340
+ const newShareData = new ShareData(`${this._id}-${transactionNumber}`, publicKey);
151
341
  newShareData._rules = [...this._rules];
152
342
  newShareData._functions = [...this._functions];
153
343
  newShareData._transactionHistory = [...this._transactionHistory];
154
344
  newShareData._events = [...this._events];
155
- newShareData._data = { ...this._data };
345
+ newShareData._currentState = { ...this._currentState };
156
346
  newShareData._version = this._version;
157
347
  return newShareData;
158
348
  }
349
+ //#endregion Copy
350
+ //#region Crypto Proofs
351
+ /**
352
+ * This adds a cryptographic proof to the share data
353
+ * @param proof the cryptographic proof to add
354
+ */
355
+ addCryptoProof(proof) {
356
+ this._cryptoProofs.push(proof);
357
+ }
358
+ /**
359
+ * Verifies that `proof` is a faithful attestation of this share-data's
360
+ * current structural state under `proof.purpose`. Returns `true` on
361
+ * success; throws `ShareDataStructuralProofFailedError` on any mismatch
362
+ * (hash, previousHash, signature, or purpose).
363
+ */
364
+ verifyStructuralProof(proof, curve = this._signingCurve) {
365
+ return (0, verify_share_data_proposal_proof_1.verifyShareDataProposalProof)(proof, this, curve);
366
+ }
367
+ /**
368
+ * Verifies that `proof` authorizes applying a transaction that moves this
369
+ * share-data to exactly `proposedData`. Unlike {@link verifyStructuralProof}
370
+ * (which binds only the current state under a purpose), this additionally
371
+ * binds the proposed state — a proof minted for one proposed state will not
372
+ * verify against any other. Returns `true`; throws
373
+ * `ShareDataTransactionProofFailedError` on any mismatch.
374
+ */
375
+ verifyTransactionProof(proof, proposedData, curve = this._signingCurve) {
376
+ return (0, verify_transaction_proposal_proof_1.verifyTransactionProposalProof)(proof, this, proposedData, curve);
377
+ }
378
+ //#endregion Crypto Proofs
379
+ //#region Structure Proofs
380
+ /**
381
+ * This adds a structure proof to the share data
382
+ * @param proof the structure proof to add
383
+ */
384
+ addStructuralProof(proof) {
385
+ if (this._structuralProofs.includes(proof)) {
386
+ throw new generic_1.ShareDataStructuralProofFailedError(this._id);
387
+ }
388
+ this._structuralProofs.push(proof);
389
+ }
390
+ //#region Initialization
391
+ /**
392
+ * This initializes the share data object and locks it
393
+ */
394
+ initialize() {
395
+ // Perform any necessary initialization steps here
396
+ // Lock the share data object
397
+ this._isLocked = true;
398
+ }
159
399
  }
160
400
  exports.ShareData = ShareData;
401
+ const itiem2 = new ShareData('1', '1234');
402
+ const item = new ShareData('1', '1234');
403
+ item.initialize();
package/package.json CHANGED
@@ -1,22 +1,40 @@
1
1
  {
2
2
  "name": "@degenerate/sharedata",
3
- "version": "0.2.7",
3
+ "version": "0.3.1",
4
4
  "description": "This contains the ShareData Adaptive Framework Ecosystem (SAFE) network core code",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "default": "./dist/index.js"
11
+ }
12
+ },
13
+ "publishConfig": {
14
+ "access": "public"
15
+ },
7
16
  "scripts": {
8
17
  "build": "rm -rf dist/* && tsc -p tsconfig.pkg.json",
9
18
  "compile": "rm -rf dist/* && tsc -p tsconfig.pkg.json",
10
- "test": "jest --forceExit --detectOpenHandles --verbose --silent=false --env node --config tsconfig.pkg.json",
11
- "test:coverage": "jest --forceExit --coverage --detectOpenHandles --verbose --silent=false --env node --config tsconfig.pkg.json",
19
+ "test": "jest --forceExit --detectOpenHandles --verbose --silent=false --env node",
20
+ "test:coverage": "jest --forceExit --coverage --detectOpenHandles --verbose --silent=false --env node ",
12
21
  "test:clearCache": "jest --clearCache"
13
22
  },
14
23
  "devDependencies": {
15
- "@types/jest": "^29.5.14",
16
- "@types/node": "^22.8.0",
17
- "jest": "^29.7.0",
18
- "ts-jest": "^29.2.5",
19
- "typescript": "^5.6.3"
24
+ "@types/jest": "^30.0.0",
25
+ "@types/node": "^22.19.18",
26
+ "firebase-admin": "^13.10.0",
27
+ "jest": "^30.4.2",
28
+ "ts-jest": "^29.4.9",
29
+ "typescript": "^6.0.3"
30
+ },
31
+ "peerDependencies": {
32
+ "firebase-admin": "^13.10.0"
33
+ },
34
+ "peerDependenciesMeta": {
35
+ "firebase-admin": {
36
+ "optional": true
37
+ }
20
38
  },
21
39
  "keywords": [
22
40
  "ShareData Adaptive Framework Ecosystem",
@@ -31,13 +49,13 @@
31
49
  "url": "https://github.com/syncrude/safe/issues"
32
50
  },
33
51
  "homepage": "https://github.com/syncrude/safe#readme",
34
- "gitHead": "29034ad37b42e7ec71a842e679b6c8a257d7cb6a",
52
+ "gitHead": "c33ed2f06679f5bd76c2eccf7054212c1820a014",
35
53
  "dependencies": {
36
- "@degenerate/generic": "^0.2.7",
37
- "@degenerate/rules": "^0.2.7",
38
- "zod": "^3.24.1"
54
+ "@degenerate/generic": "^0.3.0",
55
+ "@degenerate/rules": "^0.3.0",
56
+ "zod": "^4.4.3"
39
57
  },
40
58
  "engines": {
41
- "node": "22.x"
59
+ "node": ">=22"
42
60
  }
43
61
  }