@kynesyslabs/demosdk 2.8.9 → 2.8.11

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.
@@ -2,42 +2,55 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.StorageProgram = void 0;
4
4
  const crypto_1 = require("crypto");
5
- // REVIEW: Storage Program class for key-value storage with access control
5
+ const StorageProgramTransaction_1 = require("../types/blockchain/TransactionSubtypes/StorageProgramTransaction");
6
+ // REVIEW: Unified Storage Program class for both JSON and Binary storage with robust ACL
6
7
  /**
7
- * Storage Program class for creating and managing key-value storage on Demos Network
8
+ * StorageProgram - Unified storage solution for Demos Network
9
+ *
10
+ * Supports both JSON (structured) and Binary (raw) data storage
11
+ * with robust access control and size-based pricing.
8
12
  *
9
13
  * Features:
10
14
  * - Deterministic address derivation (stor-{sha256})
11
- * - Key-value storage with 128KB limit
12
- * - Access control (private, public, restricted, deployer-only)
13
- * - Nested data structures (max 64 levels)
15
+ * - Dual encoding: JSON key-value or raw binary
16
+ * - Robust ACL: owner, allowed, blacklisted, public, groups
17
+ * - Size limit: 1MB for both encodings
18
+ * - Pricing: 1 DEM per 10KB
19
+ * - Permanent storage, owner/ACL-deletable only
20
+ * - IPFS-ready (stubs for future hybrid storage)
14
21
  *
15
22
  * @example
16
23
  * ```typescript
17
24
  * import { StorageProgram } from '@kynesyslabs/demosdk'
18
25
  *
19
- * // Derive storage address
20
- * const address = StorageProgram.deriveStorageAddress(
21
- * 'myDeployerAddress',
22
- * 'myAppConfig',
23
- * 'randomSalt123'
26
+ * // Create JSON storage program
27
+ * const jsonPayload = StorageProgram.createStorageProgram(
28
+ * 'demos1abc...',
29
+ * 'myConfig',
30
+ * { apiKey: 'secret', settings: { theme: 'dark' } },
31
+ * 'json',
32
+ * { mode: 'public' }
24
33
  * )
25
34
  *
26
- * // Create storage program
27
- * const payload = StorageProgram.createStorageProgram(
28
- * 'myDeployerAddress',
29
- * 'myAppConfig',
30
- * { apiKey: 'secret', endpoint: 'https://api.example.com' },
31
- * 'public',
32
- * 'randomSalt123'
35
+ * // Create Binary storage program
36
+ * const binaryPayload = StorageProgram.createStorageProgram(
37
+ * 'demos1abc...',
38
+ * 'myImage',
39
+ * Buffer.from(imageData).toString('base64'),
40
+ * 'binary',
41
+ * { mode: 'restricted', allowed: ['demos1user1...'] },
42
+ * { metadata: { filename: 'avatar.png', mimeType: 'image/png' } }
33
43
  * )
34
44
  * ```
35
45
  */
36
46
  class StorageProgram {
47
+ // ========================================================================
48
+ // Address Derivation
49
+ // ========================================================================
37
50
  /**
38
51
  * Derive a deterministic storage program address
39
52
  *
40
- * @param deployerAddress - Address of the program deployer
53
+ * @param deployerAddress - Address of the program deployer (will be owner)
41
54
  * @param programName - Name of the storage program
42
55
  * @param salt - Optional random salt for uniqueness (default: empty string)
43
56
  * @returns Storage address in format: stor-{first 40 chars of sha256}
@@ -60,64 +73,103 @@ class StorageProgram {
60
73
  const addressHash = hash.substring(0, 40);
61
74
  return `stor-${addressHash}`;
62
75
  }
76
+ // ========================================================================
77
+ // Program Operations
78
+ // ========================================================================
63
79
  /**
64
80
  * Create a new Storage Program
65
81
  *
66
- * @param deployerAddress - Address creating the storage program (will be the deployer)
67
- * @param programName - Name of the storage program
68
- * @param initialData - Initial key-value data to store
69
- * @param accessControl - Access control mode (default: 'private')
70
- * @param salt - Optional random salt for address derivation
71
- * @param allowedAddresses - List of allowed addresses (for 'restricted' mode)
82
+ * @param deployerAddress - Address creating the storage program (becomes owner)
83
+ * @param programName - Unique name for the program
84
+ * @param data - Initial data (JSON object or base64 binary string)
85
+ * @param encoding - "json" or "binary" (default: "json")
86
+ * @param acl - Access control configuration (default: owner-only)
87
+ * @param options - Additional options (salt, metadata, storageLocation)
72
88
  * @returns StorageProgramPayload for transaction creation
73
89
  *
74
90
  * @example
75
91
  * ```typescript
92
+ * // JSON storage with public read access
76
93
  * const payload = StorageProgram.createStorageProgram(
77
94
  * 'demos1abc...',
78
- * 'userPreferences',
79
- * { theme: 'dark', language: 'en' },
80
- * 'private'
95
+ * 'appConfig',
96
+ * { version: '1.0', features: ['auth', 'storage'] },
97
+ * 'json',
98
+ * { mode: 'public' }
99
+ * )
100
+ *
101
+ * // Binary storage with group access
102
+ * const payload = StorageProgram.createStorageProgram(
103
+ * 'demos1abc...',
104
+ * 'teamDocument',
105
+ * base64EncodedPdf,
106
+ * 'binary',
107
+ * {
108
+ * mode: 'restricted',
109
+ * groups: {
110
+ * editors: { members: ['demos1a...', 'demos1b...'], permissions: ['read', 'write'] },
111
+ * viewers: { members: ['demos1c...'], permissions: ['read'] }
112
+ * }
113
+ * },
114
+ * { metadata: { filename: 'report.pdf', mimeType: 'application/pdf' } }
81
115
  * )
82
116
  * ```
83
117
  */
84
- static createStorageProgram(deployerAddress, programName, initialData, accessControl = "private", salt, allowedAddresses) {
85
- // Derive storage address
86
- const storageAddress = this.deriveStorageAddress(deployerAddress, programName, salt || "");
118
+ static createStorageProgram(deployerAddress, programName, data, encoding = "json", acl, options) {
119
+ const storageAddress = this.deriveStorageAddress(deployerAddress, programName, options?.salt || "");
120
+ const fullACL = {
121
+ mode: acl?.mode || "owner",
122
+ allowed: acl?.allowed,
123
+ blacklisted: acl?.blacklisted,
124
+ groups: acl?.groups,
125
+ };
87
126
  return {
88
127
  operation: "CREATE_STORAGE_PROGRAM",
89
128
  storageAddress,
90
129
  programName,
91
- data: initialData,
92
- accessControl,
93
- allowedAddresses,
94
- salt,
130
+ encoding,
131
+ data,
132
+ acl: fullACL,
133
+ salt: options?.salt,
134
+ metadata: options?.metadata,
135
+ storageLocation: options?.storageLocation || "onchain",
95
136
  };
96
137
  }
97
138
  /**
98
- * Write or update key-value data in a Storage Program
139
+ * Write/update data in a Storage Program
99
140
  *
100
141
  * @param storageAddress - The storage program address (stor-{hash})
101
- * @param data - Key-value data to write/update
142
+ * @param data - Data to write (JSON object or base64 binary string)
143
+ * @param encoding - "json" or "binary" (default: "json")
102
144
  * @returns StorageProgramPayload for transaction creation
103
145
  *
104
146
  * @example
105
147
  * ```typescript
148
+ * // Update JSON data
149
+ * const payload = StorageProgram.writeStorage(
150
+ * 'stor-7a8b9c...',
151
+ * { newKey: 'value', existingKey: 'updatedValue' },
152
+ * 'json'
153
+ * )
154
+ *
155
+ * // Update binary data
106
156
  * const payload = StorageProgram.writeStorage(
107
157
  * 'stor-7a8b9c...',
108
- * { newKey: 'value', existingKey: 'updatedValue' }
158
+ * newBase64Content,
159
+ * 'binary'
109
160
  * )
110
161
  * ```
111
162
  */
112
- static writeStorage(storageAddress, data) {
163
+ static writeStorage(storageAddress, data, encoding = "json") {
113
164
  return {
114
165
  operation: "WRITE_STORAGE",
115
166
  storageAddress,
116
167
  data,
168
+ encoding,
117
169
  };
118
170
  }
119
171
  /**
120
- * Read data from a Storage Program (query operation, not a transaction)
172
+ * Read data from a Storage Program (creates payload for RPC)
121
173
  *
122
174
  * Note: This creates a payload for validation purposes.
123
175
  * Actual reads should use RPC endpoints like GET /storage-program/:address
@@ -141,39 +193,51 @@ class StorageProgram {
141
193
  };
142
194
  }
143
195
  /**
144
- * Update access control settings for a Storage Program (deployer only)
196
+ * Update access control settings for a Storage Program (owner only)
145
197
  *
146
198
  * @param storageAddress - The storage program address
147
- * @param accessControl - New access control mode
148
- * @param allowedAddresses - Updated list of allowed addresses (for 'restricted' mode)
199
+ * @param acl - New access control configuration
149
200
  * @returns StorageProgramPayload for transaction creation
150
201
  *
151
202
  * @example
152
203
  * ```typescript
153
- * // Change from private to public
204
+ * // Change to public access
205
+ * const payload = StorageProgram.updateAccessControl(
206
+ * 'stor-7a8b9c...',
207
+ * { mode: 'public' }
208
+ * )
209
+ *
210
+ * // Add users to blacklist
154
211
  * const payload = StorageProgram.updateAccessControl(
155
212
  * 'stor-7a8b9c...',
156
- * 'public'
213
+ * {
214
+ * mode: 'public',
215
+ * blacklisted: ['demos1bad...', 'demos1spam...']
216
+ * }
157
217
  * )
158
218
  *
159
- * // Set restricted access with allowlist
219
+ * // Set up group-based access
160
220
  * const payload = StorageProgram.updateAccessControl(
161
221
  * 'stor-7a8b9c...',
162
- * 'restricted',
163
- * ['demos1user1...', 'demos1user2...']
222
+ * {
223
+ * mode: 'restricted',
224
+ * groups: {
225
+ * admins: { members: ['demos1admin...'], permissions: ['read', 'write', 'delete'] },
226
+ * users: { members: ['demos1user1...', 'demos1user2...'], permissions: ['read'] }
227
+ * }
228
+ * }
164
229
  * )
165
230
  * ```
166
231
  */
167
- static updateAccessControl(storageAddress, accessControl, allowedAddresses) {
232
+ static updateAccessControl(storageAddress, acl) {
168
233
  return {
169
234
  operation: "UPDATE_ACCESS_CONTROL",
170
235
  storageAddress,
171
- accessControl,
172
- allowedAddresses,
236
+ acl: acl,
173
237
  };
174
238
  }
175
239
  /**
176
- * Delete an entire Storage Program (deployer only)
240
+ * Delete a Storage Program (owner/ACL-permissioned only)
177
241
  *
178
242
  * WARNING: This operation is irreversible and will delete all stored data.
179
243
  *
@@ -191,44 +255,91 @@ class StorageProgram {
191
255
  storageAddress,
192
256
  };
193
257
  }
258
+ // ========================================================================
259
+ // Validation Helpers
260
+ // ========================================================================
194
261
  /**
195
- * Validate storage size against 128KB limit
262
+ * Validate data size against 1MB limit
196
263
  *
197
- * @param data - The data object to validate
198
- * @returns true if size is within limit, false otherwise
264
+ * @param data - Data to validate (JSON object or base64 string)
265
+ * @param encoding - Encoding type ("json" or "binary")
266
+ * @returns true if size is within 1MB limit, false otherwise
199
267
  *
200
268
  * @example
201
269
  * ```typescript
202
- * const data = { key: 'value', nested: { data: 'here' } }
203
- * if (StorageProgram.validateSize(data)) {
270
+ * // Validate JSON data
271
+ * if (StorageProgram.validateSize({ key: 'value' }, 'json')) {
272
+ * // Safe to store
273
+ * }
274
+ *
275
+ * // Validate binary data
276
+ * if (StorageProgram.validateSize(base64String, 'binary')) {
204
277
  * // Safe to store
205
278
  * }
206
279
  * ```
207
280
  */
208
- static validateSize(data) {
209
- const jsonString = JSON.stringify(data);
210
- const sizeInBytes = new TextEncoder().encode(jsonString).length;
211
- const maxSizeInBytes = 128 * 1024; // 128KB
212
- return sizeInBytes <= maxSizeInBytes;
281
+ static validateSize(data, encoding = "json") {
282
+ const sizeBytes = this.getDataSize(data, encoding);
283
+ return sizeBytes <= StorageProgramTransaction_1.STORAGE_PROGRAM_CONSTANTS.MAX_SIZE_BYTES;
213
284
  }
214
285
  /**
215
- * Get the size of data in bytes
286
+ * Get data size in bytes
216
287
  *
217
- * @param data - The data object to measure
288
+ * @param data - Data to measure (JSON object or base64 string)
289
+ * @param encoding - Encoding type ("json" or "binary")
218
290
  * @returns Size in bytes
219
291
  *
220
292
  * @example
221
293
  * ```typescript
222
- * const size = StorageProgram.getDataSize({ key: 'value' })
294
+ * const size = StorageProgram.getDataSize({ key: 'value' }, 'json')
223
295
  * console.log(`Data size: ${size} bytes`)
224
296
  * ```
225
297
  */
226
- static getDataSize(data) {
227
- const jsonString = JSON.stringify(data);
228
- return new TextEncoder().encode(jsonString).length;
298
+ static getDataSize(data, encoding = "json") {
299
+ if (encoding === "binary") {
300
+ // Binary data is base64 encoded, decode to get actual size
301
+ // Base64 encoding: every 4 chars = 3 bytes
302
+ const base64String = data;
303
+ // Remove padding and calculate
304
+ const padding = (base64String.match(/=/g) || []).length;
305
+ return Math.floor((base64String.length * 3) / 4) - padding;
306
+ }
307
+ else {
308
+ // JSON data - measure serialized size
309
+ const jsonString = JSON.stringify(data);
310
+ return new TextEncoder().encode(jsonString).length;
311
+ }
312
+ }
313
+ /**
314
+ * Calculate storage fee based on data size
315
+ *
316
+ * Pricing: 1 DEM per 10KB (minimum 1 DEM)
317
+ *
318
+ * @param data - Data to calculate fee for (JSON object or base64 string)
319
+ * @param encoding - Encoding type ("json" or "binary")
320
+ * @returns Fee in DEM (bigint)
321
+ *
322
+ * @example
323
+ * ```typescript
324
+ * const fee = StorageProgram.calculateStorageFee({ key: 'value' }, 'json')
325
+ * console.log(`Storage fee: ${fee} DEM`)
326
+ *
327
+ * // Examples:
328
+ * // 5KB -> 1 DEM
329
+ * // 15KB -> 2 DEM
330
+ * // 100KB -> 10 DEM
331
+ * // 1MB -> 103 DEM
332
+ * ```
333
+ */
334
+ static calculateStorageFee(data, encoding = "json") {
335
+ const sizeBytes = this.getDataSize(data, encoding);
336
+ const chunks = Math.ceil(sizeBytes / StorageProgramTransaction_1.STORAGE_PROGRAM_CONSTANTS.PRICING_CHUNK_BYTES);
337
+ return BigInt(Math.max(1, chunks)) * StorageProgramTransaction_1.STORAGE_PROGRAM_CONSTANTS.FEE_PER_CHUNK;
229
338
  }
230
339
  /**
231
- * Validate nesting depth (max 64 levels)
340
+ * Validate JSON nesting depth (max 64 levels)
341
+ *
342
+ * Only applicable for JSON encoding.
232
343
  *
233
344
  * @param data - The data object to validate
234
345
  * @param maxDepth - Maximum allowed nesting depth (default: 64)
@@ -242,7 +353,7 @@ class StorageProgram {
242
353
  * }
243
354
  * ```
244
355
  */
245
- static validateNestingDepth(data, maxDepth = 64) {
356
+ static validateNestingDepth(data, maxDepth = StorageProgramTransaction_1.STORAGE_PROGRAM_CONSTANTS.MAX_JSON_NESTING_DEPTH) {
246
357
  const getDepth = (obj, currentDepth = 1) => {
247
358
  if (typeof obj !== "object" || obj === null) {
248
359
  return currentDepth;
@@ -252,6 +363,173 @@ class StorageProgram {
252
363
  };
253
364
  return getDepth(data) <= maxDepth;
254
365
  }
366
+ // ========================================================================
367
+ // ACL Helpers
368
+ // ========================================================================
369
+ /**
370
+ * Check if an address has permission for an operation
371
+ *
372
+ * ACL Resolution Priority:
373
+ * 1. Owner -> FULL ACCESS (always)
374
+ * 2. Blacklisted -> DENIED (even if in allowed/groups)
375
+ * 3. Allowed -> permissions granted
376
+ * 4. Groups -> check group permissions
377
+ * 5. Mode fallback: owner/restricted -> DENIED, public -> READ only
378
+ *
379
+ * @param acl - Access control configuration
380
+ * @param ownerAddress - Owner address of the storage program
381
+ * @param requestingAddress - Address requesting permission
382
+ * @param permission - Permission type to check
383
+ * @returns true if permission is granted
384
+ *
385
+ * @example
386
+ * ```typescript
387
+ * const acl = { mode: 'public', blacklisted: ['demos1spam...'] }
388
+ * const canRead = StorageProgram.checkPermission(acl, owner, user, 'read')
389
+ * ```
390
+ */
391
+ static checkPermission(acl, ownerAddress, requestingAddress, permission) {
392
+ // 1. Owner always has full access
393
+ if (requestingAddress === ownerAddress)
394
+ return true;
395
+ // 2. Blacklisted addresses are always denied
396
+ if (acl.blacklisted?.includes(requestingAddress))
397
+ return false;
398
+ // 3. Check allowed list (grants all permissions)
399
+ if (acl.allowed?.includes(requestingAddress))
400
+ return true;
401
+ // 4. Check groups
402
+ if (acl.groups) {
403
+ for (const group of Object.values(acl.groups)) {
404
+ if (group.members.includes(requestingAddress) && group.permissions.includes(permission)) {
405
+ return true;
406
+ }
407
+ }
408
+ }
409
+ // 5. Fall back to mode
410
+ switch (acl.mode) {
411
+ case "public":
412
+ return permission === "read"; // Public allows read only
413
+ case "owner":
414
+ case "restricted":
415
+ default:
416
+ return false;
417
+ }
418
+ }
419
+ /**
420
+ * Create a public ACL (anyone can read, owner writes)
421
+ *
422
+ * @returns StorageProgramACL configured for public read access
423
+ *
424
+ * @example
425
+ * ```typescript
426
+ * const acl = StorageProgram.publicACL()
427
+ * // { mode: 'public' }
428
+ * ```
429
+ */
430
+ static publicACL() {
431
+ return { mode: "public" };
432
+ }
433
+ /**
434
+ * Create a private/owner-only ACL
435
+ *
436
+ * @returns StorageProgramACL configured for owner-only access
437
+ *
438
+ * @example
439
+ * ```typescript
440
+ * const acl = StorageProgram.privateACL()
441
+ * // { mode: 'owner' }
442
+ * ```
443
+ */
444
+ static privateACL() {
445
+ return { mode: "owner" };
446
+ }
447
+ /**
448
+ * Create a restricted ACL with allowed addresses
449
+ *
450
+ * @param allowed - List of addresses allowed to access
451
+ * @returns StorageProgramACL configured for restricted access
452
+ *
453
+ * @example
454
+ * ```typescript
455
+ * const acl = StorageProgram.restrictedACL(['demos1a...', 'demos1b...'])
456
+ * // { mode: 'restricted', allowed: ['demos1a...', 'demos1b...'] }
457
+ * ```
458
+ */
459
+ static restrictedACL(allowed) {
460
+ return { mode: "restricted", allowed };
461
+ }
462
+ /**
463
+ * Create a group-based ACL
464
+ *
465
+ * @param groups - Named groups with members and permissions
466
+ * @returns StorageProgramACL configured for group-based access
467
+ *
468
+ * @example
469
+ * ```typescript
470
+ * const acl = StorageProgram.groupACL({
471
+ * admins: { members: ['demos1admin...'], permissions: ['read', 'write', 'delete'] },
472
+ * editors: { members: ['demos1ed1...', 'demos1ed2...'], permissions: ['read', 'write'] },
473
+ * viewers: { members: ['demos1view...'], permissions: ['read'] }
474
+ * })
475
+ * ```
476
+ */
477
+ static groupACL(groups) {
478
+ return { mode: "restricted", groups };
479
+ }
480
+ /**
481
+ * Create an ACL with a blacklist
482
+ *
483
+ * @param mode - Base mode ('public' or 'restricted')
484
+ * @param blacklisted - Addresses to block
485
+ * @param allowed - Optional allowed addresses (for restricted mode)
486
+ * @returns StorageProgramACL with blacklist configured
487
+ *
488
+ * @example
489
+ * ```typescript
490
+ * // Public but block spam addresses
491
+ * const acl = StorageProgram.blacklistACL('public', ['demos1spam...'])
492
+ * ```
493
+ */
494
+ static blacklistACL(mode, blacklisted, allowed) {
495
+ return { mode, blacklisted, allowed };
496
+ }
497
+ // ========================================================================
498
+ // Legacy Compatibility Methods
499
+ // ========================================================================
500
+ /**
501
+ * @deprecated Use createStorageProgram with acl parameter instead.
502
+ * Kept for backward compatibility.
503
+ *
504
+ * Create a new Storage Program with legacy access control
505
+ */
506
+ static createStorageProgramLegacy(deployerAddress, programName, initialData, accessControl = "private", salt, allowedAddresses) {
507
+ const storageAddress = this.deriveStorageAddress(deployerAddress, programName, salt || "");
508
+ return {
509
+ operation: "CREATE_STORAGE_PROGRAM",
510
+ storageAddress,
511
+ programName,
512
+ data: initialData,
513
+ encoding: "json",
514
+ accessControl,
515
+ allowedAddresses,
516
+ salt,
517
+ };
518
+ }
519
+ /**
520
+ * @deprecated Use updateAccessControl with acl parameter instead.
521
+ * Kept for backward compatibility.
522
+ *
523
+ * Update access control with legacy mode
524
+ */
525
+ static updateAccessControlLegacy(storageAddress, accessControl, allowedAddresses) {
526
+ return {
527
+ operation: "UPDATE_ACCESS_CONTROL",
528
+ storageAddress,
529
+ accessControl,
530
+ allowedAddresses,
531
+ };
532
+ }
255
533
  }
256
534
  exports.StorageProgram = StorageProgram;
257
535
  //# sourceMappingURL=StorageProgram.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"StorageProgram.js","sourceRoot":"","sources":["../../../src/storage/StorageProgram.ts"],"names":[],"mappings":";;;AAAA,mCAAmC;AAOnC,0EAA0E;AAE1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAa,cAAc;IACvB;;;;;;;;;;;;;;;;;OAiBG;IACH,MAAM,CAAC,oBAAoB,CACvB,eAAuB,EACvB,WAAmB,EACnB,OAAe,EAAE;QAEjB,sDAAsD;QACtD,MAAM,SAAS,GAAG,GAAG,eAAe,IAAI,WAAW,IAAI,IAAI,EAAE,CAAA;QAE7D,4CAA4C;QAC5C,MAAM,IAAI,GAAG,IAAA,mBAAU,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QACjE,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;QAEzC,OAAO,QAAQ,WAAW,EAAE,CAAA;IAChC,CAAC;IAED;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,MAAM,CAAC,oBAAoB,CACvB,eAAuB,EACvB,WAAmB,EACnB,WAAgC,EAChC,gBAA6C,SAAS,EACtD,IAAa,EACb,gBAA2B;QAE3B,yBAAyB;QACzB,MAAM,cAAc,GAAG,IAAI,CAAC,oBAAoB,CAC5C,eAAe,EACf,WAAW,EACX,IAAI,IAAI,EAAE,CACb,CAAA;QAED,OAAO;YACH,SAAS,EAAE,wBAAwB;YACnC,cAAc;YACd,WA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MAAM,EAAE,CAAA;IACzC,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,YAAY,CACf,IAAoB,EACpB,WAAqB,EACrB,OAAkB;QAElB,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,CAAA;IACzC,CAAC;IAED,2EAA2E;IAC3E,+BAA+B;IAC/B,2EAA2E;IAE3E;;;;;OAKG;IACH,MAAM,CAAC,0BAA0B,CAC7B,eAAuB,EACvB,WAAmB,EACnB,WAAgC,EAChC,gBAA6C,SAAS,EACtD,IAAa,EACb,gBAA2B;QAE3B,MAAM,cAAc,GAAG,IAAI,CAAC,oBAAoB,CAC5C,eAAe,EACf,WAAW,EACX,IAAI,IAAI,EAAE,CACb,CAAA;QAED,OAAO;YACH,SAAS,EAAE,wBAAwB;YACnC,cAAc;YACd,WAAW;YACX,IAAI,EAAE,WAAW;YACjB,QAAQ,EAAE,MAAM;YAChB,aAAa;YACb,gBAAgB;YAChB,IAAI;SACP,CAAA;IACL,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,yBAAyB,CAC5B,cAAsB,EACtB,aAA0C,EAC1C,gBAA2B;QAE3B,OAAO;YACH,SAAS,EAAE,uBAAuB;YAClC,cAAc;YACd,aAAa;YACb,gBAAgB;SACnB,CAAA;IACL,CAAC;CACJ;AAzjBD,wCAyjBC"}
@@ -1,2 +1,3 @@
1
1
  export { StorageProgram } from "./StorageProgram";
2
- export type { StorageProgramPayload, StorageProgramAccessControl, StorageProgramOperation, StorageProgramTransactionContent, StorageProgramTransaction, } from "../types/blockchain/TransactionSubtypes/StorageProgramTransaction";
2
+ export type { StorageProgramOperation, StorageEncoding, StorageLocation, StorageACLMode, StorageGroupPermissions, StorageProgramACL, StorageProgramPayload, StorageProgramTransactionContent, StorageProgramTransaction, StorageProgramAccessControl, } from "../types/blockchain/TransactionSubtypes/StorageProgramTransaction";
3
+ export { STORAGE_PROGRAM_CONSTANTS, isStorageProgramPayload, isValidEncoding, isValidStorageLocation, } from "../types/blockchain/TransactionSubtypes/StorageProgramTransaction";
@@ -1,6 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.StorageProgram = void 0;
3
+ exports.isValidStorageLocation = exports.isValidEncoding = exports.isStorageProgramPayload = exports.STORAGE_PROGRAM_CONSTANTS = exports.StorageProgram = void 0;
4
4
  var StorageProgram_1 = require("./StorageProgram");
5
5
  Object.defineProperty(exports, "StorageProgram", { enumerable: true, get: function () { return StorageProgram_1.StorageProgram; } });
6
+ var StorageProgramTransaction_1 = require("../types/blockchain/TransactionSubtypes/StorageProgramTransaction");
7
+ Object.defineProperty(exports, "STORAGE_PROGRAM_CONSTANTS", { enumerable: true, get: function () { return StorageProgramTransaction_1.STORAGE_PROGRAM_CONSTANTS; } });
8
+ Object.defineProperty(exports, "isStorageProgramPayload", { enumerable: true, get: function () { return StorageProgramTransaction_1.isStorageProgramPayload; } });
9
+ Object.defineProperty(exports, "isValidEncoding", { enumerable: true, get: function () { return StorageProgramTransaction_1.isValidEncoding; } });
10
+ Object.defineProperty(exports, "isValidStorageLocation", { enumerable: true, get: function () { return StorageProgramTransaction_1.isValidStorageLocation; } });
6
11
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/storage/index.ts"],"names":[],"mappings":";;;AAAA,mDAAiD;AAAxC,gHAAA,cAAc,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/storage/index.ts"],"names":[],"mappings":";;;AAAA,mDAAiD;AAAxC,gHAAA,cAAc,OAAA;AAiBvB,+GAK0E;AAJtE,sIAAA,yBAAyB,OAAA;AACzB,oIAAA,uBAAuB,OAAA;AACvB,4HAAA,eAAe,OAAA;AACf,mIAAA,sBAAsB,OAAA"}
@@ -51,6 +51,8 @@ export interface AttestationTokenResponse {
51
51
  expiresAt: number;
52
52
  /** Number of retry attempts remaining */
53
53
  retriesLeft: number;
54
+ /** Transaction hash of the attestation request */
55
+ txHash: string;
54
56
  }
55
57
  /**
56
58
  * Response from storeProof
@@ -228,6 +230,7 @@ export declare class TLSNotaryService {
228
230
  tokenId: string;
229
231
  proxyUrl: string;
230
232
  expiresAt: number;
233
+ requestTxHash: string;
231
234
  }>;
232
235
  /**
233
236
  * Request attestation token and create a pre-configured TLSNotary instance
@@ -280,6 +283,7 @@ export declare class TLSNotaryService {
280
283
  tokenId: string;
281
284
  proxyUrl: string;
282
285
  expiresAt: number;
286
+ requestTxHash: string;
283
287
  }>;
284
288
  /**
285
289
  * Store a TLSNotary proof on-chain or IPFS
@@ -130,6 +130,7 @@ class TLSNotaryService {
130
130
  tokenId,
131
131
  expiresAt: Date.now() + (proxyResponse.expiresIn || 30000),
132
132
  retriesLeft: proxyResponse.retriesLeft ?? 3,
133
+ txHash,
133
134
  };
134
135
  }
135
136
  /**
@@ -226,6 +227,7 @@ class TLSNotaryService {
226
227
  tokenId,
227
228
  expiresAt: Date.now() + (proxyResponse.expiresIn || 30000),
228
229
  retriesLeft: proxyResponse.retriesLeft ?? 3,
230
+ txHash,
229
231
  };
230
232
  }
231
233
  /**
@@ -294,6 +296,7 @@ class TLSNotaryService {
294
296
  tokenId: tokenResponse.tokenId,
295
297
  proxyUrl: tokenResponse.proxyUrl,
296
298
  expiresAt: tokenResponse.expiresAt,
299
+ requestTxHash: tokenResponse.txHash,
297
300
  };
298
301
  }
299
302
  /**
@@ -370,6 +373,7 @@ class TLSNotaryService {
370
373
  tokenId: tokenResponse.tokenId,
371
374
  proxyUrl: tokenResponse.proxyUrl,
372
375
  expiresAt: tokenResponse.expiresAt,
376
+ requestTxHash: tokenResponse.txHash,
373
377
  };
374
378
  }
375
379
  /**