@dstorage-tech/dstorage-sdk 0.0.4 → 0.0.6

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 (62) hide show
  1. package/README.md +24 -4
  2. package/dist/browser.d.mts +2 -189
  3. package/dist/browser.mjs +1774 -2130
  4. package/dist/errors.d.mts +0 -3
  5. package/dist/errors.d.ts +0 -3
  6. package/dist/errors.js +0 -5
  7. package/dist/errors.mjs +0 -5
  8. package/dist/index.d.mts +2 -189
  9. package/dist/index.d.ts +2 -189
  10. package/dist/index.js +1844 -2199
  11. package/dist/index.mjs +1823 -2175
  12. package/package.json +2 -1
  13. package/dist/KeypairEncryptionAdapter-AE75YC4W-AOWNSH2M.mjs +0 -9
  14. package/dist/KeypairEncryptionAdapter-AE75YC4W-BAVHRNNJ.mjs +0 -1
  15. package/dist/KeypairEncryptionAdapter-AE75YC4W-BEYO4RUO.mjs +0 -1
  16. package/dist/KeypairEncryptionAdapter-AE75YC4W-VAOH6AAL.mjs +0 -9
  17. package/dist/KeypairEncryptionAdapter-XUKCLRFU-6ERIZN2M.mjs +0 -1
  18. package/dist/MnemonicEncryptionAdapter-J6IE5OKA-6DFVUVD6.mjs +0 -1
  19. package/dist/MnemonicEncryptionAdapter-J6IE5OKA-O5AJPX42.mjs +0 -1
  20. package/dist/MnemonicEncryptionAdapter-J6IE5OKA-SI6TBLTQ.mjs +0 -9
  21. package/dist/MnemonicEncryptionAdapter-J6IE5OKA-WEPFOTSJ.mjs +0 -9
  22. package/dist/MnemonicEncryptionAdapter-RCHUETBP-ELAMJMMO.mjs +0 -1
  23. package/dist/PasswordEncryptionAdapter-CWOXUGR4-2YZ64B4A.mjs +0 -1
  24. package/dist/PasswordEncryptionAdapter-CWOXUGR4-DCEGC2NX.mjs +0 -1
  25. package/dist/PasswordEncryptionAdapter-CWOXUGR4-QEGGYPFJ.mjs +0 -13
  26. package/dist/PasswordEncryptionAdapter-CWOXUGR4-ZYUBUYUI.mjs +0 -13
  27. package/dist/PasswordEncryptionAdapter-ECHND672-XVBPHPPT.mjs +0 -1
  28. package/dist/chunk-4YMF57VY.mjs +0 -1
  29. package/dist/chunk-5MZ7FPPY.mjs +0 -1
  30. package/dist/chunk-5P4EW2YL.mjs +0 -1
  31. package/dist/chunk-5RW7SGA7.mjs +0 -1
  32. package/dist/chunk-62RSKZ6T.mjs +0 -118
  33. package/dist/chunk-BBJCQFWP.mjs +0 -275
  34. package/dist/chunk-EYF3263P.mjs +0 -2049
  35. package/dist/chunk-GUYENY5N.mjs +0 -1
  36. package/dist/chunk-L5QD6GHB.mjs +0 -101
  37. package/dist/chunk-PKHRAYFD.mjs +0 -1
  38. package/dist/chunk-PLAOCKSS.mjs +0 -101
  39. package/dist/chunk-QKA2DCR6.mjs +0 -118
  40. package/dist/chunk-RPSRFFXN.mjs +0 -275
  41. package/dist/chunk-TESUOXRJ.mjs +0 -1
  42. package/dist/chunk-TMLXCRJU.mjs +0 -1
  43. package/dist/chunk-TNRKN4LB.mjs +0 -1
  44. package/dist/chunk-TSZ37JDY.mjs +0 -2596
  45. package/dist/chunk-U3MS6KMF.mjs +0 -1
  46. package/dist/chunk-UBALMYIY.mjs +0 -2049
  47. package/dist/chunk-UOOF4V2Y.mjs +0 -1
  48. package/dist/chunk-Z2TH6U4C.mjs +0 -3
  49. package/dist/chunk-ZEPZ4QDD.mjs +0 -1
  50. package/dist/chunk-ZGUY5EIR.mjs +0 -1
  51. package/dist/contract-api-AO4RGPLT-4HRCMSCE.mjs +0 -279
  52. package/dist/contract-api-AO4RGPLT-ADH6ZDKC.mjs +0 -279
  53. package/dist/contract-api-AO4RGPLT-PAMIPEI3.mjs +0 -1
  54. package/dist/contract-api-AO4RGPLT-W3RSVP5A.mjs +0 -1
  55. package/dist/contract-api-AO4RGPLT-WENYDV6I.mjs +0 -1
  56. package/dist/contract-api-TJ7JPHZA-ZWP3EH7D.mjs +0 -279
  57. package/dist/dataregistry-simulator-E6RTGGWT-QGCYR3VF.mjs +0 -1
  58. package/dist/dist-655VYUPJ.mjs +0 -1
  59. package/dist/dist-MEZZWKP4.mjs +0 -1
  60. package/dist/dist-UD4WRMYJ.mjs +0 -65
  61. package/dist/esm5-AGBDHMNS.mjs +0 -1
  62. package/dist/in-memory-private-state-NGOP37V7-XFJFNFCQ.mjs +0 -1
package/dist/errors.d.mts CHANGED
@@ -90,8 +90,6 @@ declare const CoreErrorCode: {
90
90
  readonly LIST_REFS_NOT_SUPPORTED: 10061;
91
91
  readonly REMOVE_REF_REQUIRES_CHAIN: 10070;
92
92
  readonly REMOVE_REF_NOT_SUPPORTED: 10071;
93
- readonly META_TX_REQUIRES_ENCRYPTION: 10080;
94
- readonly PREPARE_UPLOAD_NO_PROVIDERS: 10081;
95
93
  readonly MANIFEST_INVALID_STRUCTURE: 10090;
96
94
  readonly MANIFEST_CHUNK_COUNT_MISMATCH: 10091;
97
95
  readonly MANIFEST_NOT_CONTIGUOUS: 10092;
@@ -99,7 +97,6 @@ declare const CoreErrorCode: {
99
97
  readonly CHUNK_OVERFLOWS_TOTAL_SIZE: 10094;
100
98
  readonly REASSEMBLY_SIZE_MISMATCH: 10095;
101
99
  readonly NOT_INITIALIZED: 10100;
102
- readonly META_TX_UNKNOWN_STEP: 10200;
103
100
  readonly UNKNOWN_ERROR: 10999;
104
101
  };
105
102
  type CoreErrorCode = (typeof CoreErrorCode)[keyof typeof CoreErrorCode];
package/dist/errors.d.ts CHANGED
@@ -90,8 +90,6 @@ declare const CoreErrorCode: {
90
90
  readonly LIST_REFS_NOT_SUPPORTED: 10061;
91
91
  readonly REMOVE_REF_REQUIRES_CHAIN: 10070;
92
92
  readonly REMOVE_REF_NOT_SUPPORTED: 10071;
93
- readonly META_TX_REQUIRES_ENCRYPTION: 10080;
94
- readonly PREPARE_UPLOAD_NO_PROVIDERS: 10081;
95
93
  readonly MANIFEST_INVALID_STRUCTURE: 10090;
96
94
  readonly MANIFEST_CHUNK_COUNT_MISMATCH: 10091;
97
95
  readonly MANIFEST_NOT_CONTIGUOUS: 10092;
@@ -99,7 +97,6 @@ declare const CoreErrorCode: {
99
97
  readonly CHUNK_OVERFLOWS_TOTAL_SIZE: 10094;
100
98
  readonly REASSEMBLY_SIZE_MISMATCH: 10095;
101
99
  readonly NOT_INITIALIZED: 10100;
102
- readonly META_TX_UNKNOWN_STEP: 10200;
103
100
  readonly UNKNOWN_ERROR: 10999;
104
101
  };
105
102
  type CoreErrorCode = (typeof CoreErrorCode)[keyof typeof CoreErrorCode];
package/dist/errors.js CHANGED
@@ -2265,9 +2265,6 @@ var CoreErrorCode = {
2265
2265
  // removeReference — 10070-10079
2266
2266
  REMOVE_REF_REQUIRES_CHAIN: 10070,
2267
2267
  REMOVE_REF_NOT_SUPPORTED: 10071,
2268
- // executeMetaTransaction / prepareUploadCrypto — 10080-10089
2269
- META_TX_REQUIRES_ENCRYPTION: 10080,
2270
- PREPARE_UPLOAD_NO_PROVIDERS: 10081,
2271
2268
  // manifest / chunking — 10090-10099
2272
2269
  MANIFEST_INVALID_STRUCTURE: 10090,
2273
2270
  MANIFEST_CHUNK_COUNT_MISMATCH: 10091,
@@ -2277,8 +2274,6 @@ var CoreErrorCode = {
2277
2274
  REASSEMBLY_SIZE_MISMATCH: 10095,
2278
2275
  // init state — 10100-10109
2279
2276
  NOT_INITIALIZED: 10100,
2280
- // MetaTx — 10200-10209
2281
- META_TX_UNKNOWN_STEP: 10200,
2282
2277
  // generic catch-all — 10999
2283
2278
  UNKNOWN_ERROR: 10999
2284
2279
  };
package/dist/errors.mjs CHANGED
@@ -2236,9 +2236,6 @@ var CoreErrorCode = {
2236
2236
  // removeReference — 10070-10079
2237
2237
  REMOVE_REF_REQUIRES_CHAIN: 10070,
2238
2238
  REMOVE_REF_NOT_SUPPORTED: 10071,
2239
- // executeMetaTransaction / prepareUploadCrypto — 10080-10089
2240
- META_TX_REQUIRES_ENCRYPTION: 10080,
2241
- PREPARE_UPLOAD_NO_PROVIDERS: 10081,
2242
2239
  // manifest / chunking — 10090-10099
2243
2240
  MANIFEST_INVALID_STRUCTURE: 10090,
2244
2241
  MANIFEST_CHUNK_COUNT_MISMATCH: 10091,
@@ -2248,8 +2245,6 @@ var CoreErrorCode = {
2248
2245
  REASSEMBLY_SIZE_MISMATCH: 10095,
2249
2246
  // init state — 10100-10109
2250
2247
  NOT_INITIALIZED: 10100,
2251
- // MetaTx — 10200-10209
2252
- META_TX_UNKNOWN_STEP: 10200,
2253
2248
  // generic catch-all — 10999
2254
2249
  UNKNOWN_ERROR: 10999
2255
2250
  };
package/dist/index.d.mts CHANGED
@@ -2374,170 +2374,6 @@ declare const METADATA_ONLY_OWNER_SECRET_SALT: Uint8Array;
2374
2374
  */
2375
2375
  declare const chunkAad: (index: number, total: number) => Uint8Array;
2376
2376
 
2377
- /**
2378
- * @dstorage/core — metaTx/types.ts
2379
- *
2380
- * All public interfaces and type aliases for the MetaTx orchestrator.
2381
- */
2382
-
2383
- type MetaTxStepId = "estimate" | "encrypt" | "payment_storage" | "upload" | "chain_reference" | "complete";
2384
- type MetaTxStepStatus = "pending" | "running" | "done" | "error";
2385
- interface MetaTxStepState {
2386
- id: MetaTxStepId;
2387
- label: string;
2388
- description: string;
2389
- status: MetaTxStepStatus;
2390
- /** Live detail message updated during the step */
2391
- detail?: string;
2392
- /** Duration in ms (set when done) */
2393
- durationMs?: number;
2394
- startedAt?: number;
2395
- }
2396
- interface MetaTxProgress {
2397
- steps: MetaTxStepState[];
2398
- currentStepId: MetaTxStepId | null;
2399
- overallStatus: "idle" | "awaiting_confirmation" | "running" | "complete" | "error";
2400
- /** Cost estimate — set after 'estimate' step completes */
2401
- estimate?: CostEstimate;
2402
- /** Final receipt — set when complete */
2403
- receipt?: MetaTxReceipt;
2404
- /** Error message if overallStatus is 'error' */
2405
- error?: string;
2406
- }
2407
- interface MetaTxReceipt {
2408
- dataId: string;
2409
- storageId: string;
2410
- /** Undefined when no chain adapter is configured (storage-only mode). */
2411
- chainRefId?: string;
2412
- /** Original file info */
2413
- file: {
2414
- name: string;
2415
- type: string;
2416
- sizeBytes: number;
2417
- };
2418
- /** Payment receipts */
2419
- storagePayment: PaymentReceipt;
2420
- /** Undefined when no chain adapter is configured. */
2421
- chainPayment?: PaymentReceipt;
2422
- /** Tokens used */
2423
- storageToken: TokenSymbol;
2424
- /** Undefined when no chain adapter is configured. */
2425
- chainToken?: TokenSymbol;
2426
- /** Contract invoked (if selected) */
2427
- contract?: {
2428
- address: string;
2429
- name: string;
2430
- };
2431
- completedAt: number;
2432
- /** Duration of the full meta-transaction in ms */
2433
- totalDurationMs: number;
2434
- }
2435
- interface MetaTxConfig {
2436
- /** Optional metadata to attach to the on-chain reference */
2437
- metadata?: Record<string, string>;
2438
- /** Selected contract address (from the contract registry) */
2439
- contractAddress?: string;
2440
- /** Selected contract name (for display / receipt) */
2441
- contractName?: string;
2442
- }
2443
- /**
2444
- * Crypto materials for a single upload: a fresh random DEK wrapped in a
2445
- * key envelope, ready to encrypt payload and storageId.
2446
- *
2447
- * For private uploads: uploadScheme encrypts content; dek is the per-upload
2448
- * Data Encryption Key used both to encrypt content AND to derive
2449
- * ownerSecret = HKDF(dek, rawStorageId). Any KEK holder can re-derive the
2450
- * ownerSecret by unwrapping the envelope DEK.
2451
- * For public uploads: uploadScheme is null; ownerSeed is a random secret wrapped
2452
- * under every KEK in keyEnvelope, and ownerSecret = HKDF(ownerSeed, rawStorageId).
2453
- * Any single KEK holder can re-derive the ownerSecret by unwrapping the envelope.
2454
- */
2455
- interface UploadCrypto {
2456
- /** XChaChaScheme built from a fresh random DEK. null for public uploads. */
2457
- uploadScheme: CryptoScheme | null;
2458
- /** JSON-encoded KeyEnvelope wrapping the DEK (private) or ownerSeed (public) under every KEK. */
2459
- keyEnvelope: string;
2460
- /** Encryption scheme identifier to record on-chain. "" for public uploads. */
2461
- encryptionScheme: EncryptionScheme;
2462
- /**
2463
- * The raw per-upload DEK for private uploads; undefined for public uploads.
2464
- * Used by MetaTx to derive ownerSecret = HKDF(dek, rawStorageId) after upload.
2465
- * Not stored anywhere — must not be persisted.
2466
- */
2467
- dek?: Uint8Array;
2468
- /**
2469
- * The raw ownerSeed for public uploads; undefined for private uploads.
2470
- * Used by MetaTx to derive ownerSecret = HKDF(ownerSeed, rawStorageId) after upload.
2471
- * Not stored anywhere — must not be persisted.
2472
- */
2473
- ownerSeed?: Uint8Array;
2474
- }
2475
- /**
2476
- * Minimal SDK surface required by MetaTx.
2477
- * Implemented by DStorage — MetaTx receives the SDK instance directly
2478
- * rather than individual adapters/keys/address to avoid redundant constructor args.
2479
- */
2480
- interface DStorageContext {
2481
- readonly storageAdapter: StorageAdapter;
2482
- readonly chainAdapter: ChainAdapter | undefined;
2483
- /** Wallet address of the connected user, or null if using init() / facade mode. */
2484
- readonly connectedAddress: string | null;
2485
- /**
2486
- * Generate a fresh random DEK, wrap it under the KEK, and return the
2487
- * upload crypto materials needed to encrypt payload and storageId.
2488
- * @param isPublic Pass true to skip encryption (returns null scheme + no envelope).
2489
- */
2490
- prepareUploadCrypto(isPublic?: boolean): Promise<UploadCrypto>;
2491
- /** Estimate the full cost (storage + chain) for a given payload size. */
2492
- estimateCost(sizeBytes: number): Promise<CostEstimate>;
2493
- }
2494
-
2495
- /**
2496
- * @dstorage/core — metaTx/utils.ts
2497
- *
2498
- * Helpers used internally by MetaTx and one exported utility.
2499
- */
2500
-
2501
- /**
2502
- * Return the default chain payment token for a given chain provider name.
2503
- */
2504
- declare function defaultChainToken(chainProvider: string): TokenSymbol;
2505
-
2506
- /**
2507
- * @dstorage/core — metaTx/MetaTx.ts
2508
- *
2509
- * The MetaTx orchestrator.
2510
- *
2511
- * Presents a single conceptual action to the user while internally executing:
2512
- * [0] Estimate → compute storage + chain costs
2513
- * [1] Encrypt → XChaCha20-Poly1305 encrypt the file client-side
2514
- * [2] PayStorage → simulate storage payment (AR / MOCK)
2515
- * [3] Upload → upload encrypted blob to decentralised storage
2516
- * [4] Reference → pay chain fee + write CID + metadata reference on-chain
2517
- * [✓] Complete → return full receipt
2518
- *
2519
- * Usage:
2520
- * const metaTx = new MetaTx(dStorage);
2521
- * metaTx.onProgress((progress) => updateUI(progress));
2522
- * const receipt = await metaTx.execute(file);
2523
- */
2524
-
2525
- declare class MetaTx {
2526
- private sdk;
2527
- private progressCallback;
2528
- private steps;
2529
- private startedAt;
2530
- constructor(sdk: DStorageContext);
2531
- /** Register a progress listener. Called after every step state change. */
2532
- onProgress(cb: (progress: MetaTxProgress) => void): this;
2533
- execute(file: File, config?: MetaTxConfig): Promise<MetaTxReceipt>;
2534
- private startStep;
2535
- private updateStepDetail;
2536
- private completeStep;
2537
- private getStep;
2538
- private emit;
2539
- }
2540
-
2541
2377
  /**
2542
2378
  * @dstorage/core — dStorage.ts
2543
2379
  *
@@ -2556,7 +2392,7 @@ declare class MetaTx {
2556
2392
  * await ds.removeReference(chainRefId);
2557
2393
  */
2558
2394
 
2559
- declare class DStorage implements DStorageContext {
2395
+ declare class DStorage {
2560
2396
  private config;
2561
2397
  private wallet;
2562
2398
  /** Encryption adapters — each wraps/unwraps per-upload DEKs using its own algorithm. */
@@ -2713,26 +2549,6 @@ declare class DStorage implements DStorageContext {
2713
2549
  * Estimate the full cost (storage + chain) for a given payload size before committing.
2714
2550
  */
2715
2551
  estimateCost(sizeBytes: number): Promise<CostEstimate>;
2716
- /**
2717
- * Execute a full meta-transaction for a file:
2718
- * estimate → encrypt → pay storage → upload → pay chain → write reference
2719
- *
2720
- * Presents the entire flow as a single action with step-by-step progress.
2721
- *
2722
- * @param file The File to encrypt and store
2723
- * @param onProgress Callback fired on every step state change
2724
- * @param config Optional token overrides and metadata
2725
- */
2726
- executeMetaTransaction(file: File, onProgress: (progress: MetaTxProgress) => void, config?: MetaTxConfig): Promise<MetaTxReceipt>;
2727
- /**
2728
- * Generate a fresh random DEK, wrap it under the KEK(s), and return the crypto
2729
- * materials needed by MetaTx to encrypt payload and storageId.
2730
- *
2731
- * For private stores: the DEK is wrapped under every available KEK. The ownerSecret
2732
- * can later be re-derived as HKDF(dek, rawStorageId) by any KEK holder.
2733
- * For public stores: a random ownerSeed is generated and wrapped under all KEKs (same pattern).
2734
- */
2735
- prepareUploadCrypto(isPublic?: boolean): Promise<UploadCrypto>;
2736
2552
  /**
2737
2553
  * Upload large content by splitting into CHUNK_SIZE pieces, encrypting each
2738
2554
  * independently, and storing a manifest that ties them together.
@@ -2816,8 +2632,6 @@ declare const CoreErrorCode: {
2816
2632
  readonly LIST_REFS_NOT_SUPPORTED: 10061;
2817
2633
  readonly REMOVE_REF_REQUIRES_CHAIN: 10070;
2818
2634
  readonly REMOVE_REF_NOT_SUPPORTED: 10071;
2819
- readonly META_TX_REQUIRES_ENCRYPTION: 10080;
2820
- readonly PREPARE_UPLOAD_NO_PROVIDERS: 10081;
2821
2635
  readonly MANIFEST_INVALID_STRUCTURE: 10090;
2822
2636
  readonly MANIFEST_CHUNK_COUNT_MISMATCH: 10091;
2823
2637
  readonly MANIFEST_NOT_CONTIGUOUS: 10092;
@@ -2825,7 +2639,6 @@ declare const CoreErrorCode: {
2825
2639
  readonly CHUNK_OVERFLOWS_TOTAL_SIZE: 10094;
2826
2640
  readonly REASSEMBLY_SIZE_MISMATCH: 10095;
2827
2641
  readonly NOT_INITIALIZED: 10100;
2828
- readonly META_TX_UNKNOWN_STEP: 10200;
2829
2642
  readonly UNKNOWN_ERROR: 10999;
2830
2643
  };
2831
2644
  type CoreErrorCode = (typeof CoreErrorCode)[keyof typeof CoreErrorCode];
@@ -2840,4 +2653,4 @@ declare class StorePartialError extends DStorageError {
2840
2653
  }
2841
2654
  declare function isStorePartialError(err: unknown): err is StorePartialError;
2842
2655
 
2843
- export { ARWEAVE_LOCAL, type AdapterWalletProvider, type ArweaveBundlerAdapterConfig, ArweaveBundlerStorageAdapter, type ArweaveLocalAdapterConfig, type ArweaveLocalBalance, ArweaveLocalError, ArweaveLocalHelper, type ArweaveLocalHelperConfig, type ArweaveLocalInfo, ArweaveLocalStorageAdapter, ArweavePaymentAdapter, ArweaveStorageAdapter, CHUNK_SIZE, type ChunkEntry, type ChunkManifest, CoreErrorCode, type CostEstimate, CryptoErrorCode, type CryptoScheme, DStorage, type DStorageConfig, type DStorageContext, DStorageError, type EncryptionAdapter, EncryptionErrorCode, type EncryptionScheme, type FromKdfParamsConfig, HttpGatewayChainAdapter, type HttpGatewayChainAdapterConfig, KDF_PRESETS, type KdfPreset, KeyDeriver, type KeyEnvelope, type KeyWrapper, KeypairEncryptionAdapter, type ListReferencesOptions, type Logger, MANIFEST_AAD, METADATA_AAD, METADATA_ONLY_OWNER_SECRET_SALT, type MLKemVariant, ManagedPaymentAdapter, MetaTx, type MetaTxConfig, type MetaTxProgress, type MetaTxReceipt, type MetaTxStepId, type MetaTxStepState, type MetaTxStepStatus, MidnightChainAdapter, type MidnightChainAdapterConfig, MidnightSimulatorChainAdapter, MnemonicEncryptionAdapter, NETWORKS, PAYLOAD_AAD, PasswordEncryptionAdapter, type PasswordEncryptionAdapterConfig, type RegisterReferenceOptions, type RegisterReferenceResult, type RetrieveResult, type StoreOptions, StorePartialError, type StoreProgress, type StoreRecovery, type StoreResult, type StoredKdfParams, type UpdateResult, type UploadCrypto, type WalletAddresses, type WalletInfo, type WrappedDekResult, type XChaChaPayload, XChaChaScheme, arlocalGateway, base64urlToBytes, buildKeyEnvelope, bytesToBase64url, chunkAad, computeBlake3, computeBlake3Hex, decryptStorageIdXChaCha, decryptXChaCha, defaultChainToken, deriveKek, deriveOwnerSecret, deriveSymmetricKeyFromSeed, deserializeXChaChaPayload, encryptStorageIdXChaCha, encryptXChaCha, findWrapper, generateDek, generatePqsPassword, hexToBytes, isDStorageError, isManifest, isStorePartialError, mlkemGenerateKeypair, mlkemGenerateKeypairFromSeed, mlkemUnwrapDek, mlkemWrapDek, parseKeyEnvelope, serializeKeyEnvelope, serializeXChaChaPayload, unwrapKey, waitForFacadeSync, wrapKey };
2656
+ export { ARWEAVE_LOCAL, type AdapterWalletProvider, type ArweaveBundlerAdapterConfig, ArweaveBundlerStorageAdapter, type ArweaveLocalAdapterConfig, type ArweaveLocalBalance, ArweaveLocalError, ArweaveLocalHelper, type ArweaveLocalHelperConfig, type ArweaveLocalInfo, ArweaveLocalStorageAdapter, ArweavePaymentAdapter, ArweaveStorageAdapter, CHUNK_SIZE, type ChunkEntry, type ChunkManifest, CoreErrorCode, type CostEstimate, CryptoErrorCode, type CryptoScheme, DStorage, type DStorageConfig, DStorageError, type EncryptionAdapter, EncryptionErrorCode, type EncryptionScheme, type FromKdfParamsConfig, HttpGatewayChainAdapter, type HttpGatewayChainAdapterConfig, KDF_PRESETS, type KdfPreset, KeyDeriver, type KeyEnvelope, type KeyWrapper, KeypairEncryptionAdapter, type ListReferencesOptions, type Logger, MANIFEST_AAD, METADATA_AAD, METADATA_ONLY_OWNER_SECRET_SALT, type MLKemVariant, ManagedPaymentAdapter, MidnightChainAdapter, type MidnightChainAdapterConfig, MidnightSimulatorChainAdapter, MnemonicEncryptionAdapter, NETWORKS, PAYLOAD_AAD, PasswordEncryptionAdapter, type PasswordEncryptionAdapterConfig, type RegisterReferenceOptions, type RegisterReferenceResult, type RetrieveResult, type StoreOptions, StorePartialError, type StoreProgress, type StoreRecovery, type StoreResult, type StoredKdfParams, type UpdateResult, type WalletAddresses, type WalletInfo, type WrappedDekResult, type XChaChaPayload, XChaChaScheme, arlocalGateway, base64urlToBytes, buildKeyEnvelope, bytesToBase64url, chunkAad, computeBlake3, computeBlake3Hex, decryptStorageIdXChaCha, decryptXChaCha, deriveKek, deriveOwnerSecret, deriveSymmetricKeyFromSeed, deserializeXChaChaPayload, encryptStorageIdXChaCha, encryptXChaCha, findWrapper, generateDek, generatePqsPassword, hexToBytes, isDStorageError, isManifest, isStorePartialError, mlkemGenerateKeypair, mlkemGenerateKeypairFromSeed, mlkemUnwrapDek, mlkemWrapDek, parseKeyEnvelope, serializeKeyEnvelope, serializeXChaChaPayload, unwrapKey, waitForFacadeSync, wrapKey };
package/dist/index.d.ts CHANGED
@@ -2374,170 +2374,6 @@ declare const METADATA_ONLY_OWNER_SECRET_SALT: Uint8Array;
2374
2374
  */
2375
2375
  declare const chunkAad: (index: number, total: number) => Uint8Array;
2376
2376
 
2377
- /**
2378
- * @dstorage/core — metaTx/types.ts
2379
- *
2380
- * All public interfaces and type aliases for the MetaTx orchestrator.
2381
- */
2382
-
2383
- type MetaTxStepId = "estimate" | "encrypt" | "payment_storage" | "upload" | "chain_reference" | "complete";
2384
- type MetaTxStepStatus = "pending" | "running" | "done" | "error";
2385
- interface MetaTxStepState {
2386
- id: MetaTxStepId;
2387
- label: string;
2388
- description: string;
2389
- status: MetaTxStepStatus;
2390
- /** Live detail message updated during the step */
2391
- detail?: string;
2392
- /** Duration in ms (set when done) */
2393
- durationMs?: number;
2394
- startedAt?: number;
2395
- }
2396
- interface MetaTxProgress {
2397
- steps: MetaTxStepState[];
2398
- currentStepId: MetaTxStepId | null;
2399
- overallStatus: "idle" | "awaiting_confirmation" | "running" | "complete" | "error";
2400
- /** Cost estimate — set after 'estimate' step completes */
2401
- estimate?: CostEstimate;
2402
- /** Final receipt — set when complete */
2403
- receipt?: MetaTxReceipt;
2404
- /** Error message if overallStatus is 'error' */
2405
- error?: string;
2406
- }
2407
- interface MetaTxReceipt {
2408
- dataId: string;
2409
- storageId: string;
2410
- /** Undefined when no chain adapter is configured (storage-only mode). */
2411
- chainRefId?: string;
2412
- /** Original file info */
2413
- file: {
2414
- name: string;
2415
- type: string;
2416
- sizeBytes: number;
2417
- };
2418
- /** Payment receipts */
2419
- storagePayment: PaymentReceipt;
2420
- /** Undefined when no chain adapter is configured. */
2421
- chainPayment?: PaymentReceipt;
2422
- /** Tokens used */
2423
- storageToken: TokenSymbol;
2424
- /** Undefined when no chain adapter is configured. */
2425
- chainToken?: TokenSymbol;
2426
- /** Contract invoked (if selected) */
2427
- contract?: {
2428
- address: string;
2429
- name: string;
2430
- };
2431
- completedAt: number;
2432
- /** Duration of the full meta-transaction in ms */
2433
- totalDurationMs: number;
2434
- }
2435
- interface MetaTxConfig {
2436
- /** Optional metadata to attach to the on-chain reference */
2437
- metadata?: Record<string, string>;
2438
- /** Selected contract address (from the contract registry) */
2439
- contractAddress?: string;
2440
- /** Selected contract name (for display / receipt) */
2441
- contractName?: string;
2442
- }
2443
- /**
2444
- * Crypto materials for a single upload: a fresh random DEK wrapped in a
2445
- * key envelope, ready to encrypt payload and storageId.
2446
- *
2447
- * For private uploads: uploadScheme encrypts content; dek is the per-upload
2448
- * Data Encryption Key used both to encrypt content AND to derive
2449
- * ownerSecret = HKDF(dek, rawStorageId). Any KEK holder can re-derive the
2450
- * ownerSecret by unwrapping the envelope DEK.
2451
- * For public uploads: uploadScheme is null; ownerSeed is a random secret wrapped
2452
- * under every KEK in keyEnvelope, and ownerSecret = HKDF(ownerSeed, rawStorageId).
2453
- * Any single KEK holder can re-derive the ownerSecret by unwrapping the envelope.
2454
- */
2455
- interface UploadCrypto {
2456
- /** XChaChaScheme built from a fresh random DEK. null for public uploads. */
2457
- uploadScheme: CryptoScheme | null;
2458
- /** JSON-encoded KeyEnvelope wrapping the DEK (private) or ownerSeed (public) under every KEK. */
2459
- keyEnvelope: string;
2460
- /** Encryption scheme identifier to record on-chain. "" for public uploads. */
2461
- encryptionScheme: EncryptionScheme;
2462
- /**
2463
- * The raw per-upload DEK for private uploads; undefined for public uploads.
2464
- * Used by MetaTx to derive ownerSecret = HKDF(dek, rawStorageId) after upload.
2465
- * Not stored anywhere — must not be persisted.
2466
- */
2467
- dek?: Uint8Array;
2468
- /**
2469
- * The raw ownerSeed for public uploads; undefined for private uploads.
2470
- * Used by MetaTx to derive ownerSecret = HKDF(ownerSeed, rawStorageId) after upload.
2471
- * Not stored anywhere — must not be persisted.
2472
- */
2473
- ownerSeed?: Uint8Array;
2474
- }
2475
- /**
2476
- * Minimal SDK surface required by MetaTx.
2477
- * Implemented by DStorage — MetaTx receives the SDK instance directly
2478
- * rather than individual adapters/keys/address to avoid redundant constructor args.
2479
- */
2480
- interface DStorageContext {
2481
- readonly storageAdapter: StorageAdapter;
2482
- readonly chainAdapter: ChainAdapter | undefined;
2483
- /** Wallet address of the connected user, or null if using init() / facade mode. */
2484
- readonly connectedAddress: string | null;
2485
- /**
2486
- * Generate a fresh random DEK, wrap it under the KEK, and return the
2487
- * upload crypto materials needed to encrypt payload and storageId.
2488
- * @param isPublic Pass true to skip encryption (returns null scheme + no envelope).
2489
- */
2490
- prepareUploadCrypto(isPublic?: boolean): Promise<UploadCrypto>;
2491
- /** Estimate the full cost (storage + chain) for a given payload size. */
2492
- estimateCost(sizeBytes: number): Promise<CostEstimate>;
2493
- }
2494
-
2495
- /**
2496
- * @dstorage/core — metaTx/utils.ts
2497
- *
2498
- * Helpers used internally by MetaTx and one exported utility.
2499
- */
2500
-
2501
- /**
2502
- * Return the default chain payment token for a given chain provider name.
2503
- */
2504
- declare function defaultChainToken(chainProvider: string): TokenSymbol;
2505
-
2506
- /**
2507
- * @dstorage/core — metaTx/MetaTx.ts
2508
- *
2509
- * The MetaTx orchestrator.
2510
- *
2511
- * Presents a single conceptual action to the user while internally executing:
2512
- * [0] Estimate → compute storage + chain costs
2513
- * [1] Encrypt → XChaCha20-Poly1305 encrypt the file client-side
2514
- * [2] PayStorage → simulate storage payment (AR / MOCK)
2515
- * [3] Upload → upload encrypted blob to decentralised storage
2516
- * [4] Reference → pay chain fee + write CID + metadata reference on-chain
2517
- * [✓] Complete → return full receipt
2518
- *
2519
- * Usage:
2520
- * const metaTx = new MetaTx(dStorage);
2521
- * metaTx.onProgress((progress) => updateUI(progress));
2522
- * const receipt = await metaTx.execute(file);
2523
- */
2524
-
2525
- declare class MetaTx {
2526
- private sdk;
2527
- private progressCallback;
2528
- private steps;
2529
- private startedAt;
2530
- constructor(sdk: DStorageContext);
2531
- /** Register a progress listener. Called after every step state change. */
2532
- onProgress(cb: (progress: MetaTxProgress) => void): this;
2533
- execute(file: File, config?: MetaTxConfig): Promise<MetaTxReceipt>;
2534
- private startStep;
2535
- private updateStepDetail;
2536
- private completeStep;
2537
- private getStep;
2538
- private emit;
2539
- }
2540
-
2541
2377
  /**
2542
2378
  * @dstorage/core — dStorage.ts
2543
2379
  *
@@ -2556,7 +2392,7 @@ declare class MetaTx {
2556
2392
  * await ds.removeReference(chainRefId);
2557
2393
  */
2558
2394
 
2559
- declare class DStorage implements DStorageContext {
2395
+ declare class DStorage {
2560
2396
  private config;
2561
2397
  private wallet;
2562
2398
  /** Encryption adapters — each wraps/unwraps per-upload DEKs using its own algorithm. */
@@ -2713,26 +2549,6 @@ declare class DStorage implements DStorageContext {
2713
2549
  * Estimate the full cost (storage + chain) for a given payload size before committing.
2714
2550
  */
2715
2551
  estimateCost(sizeBytes: number): Promise<CostEstimate>;
2716
- /**
2717
- * Execute a full meta-transaction for a file:
2718
- * estimate → encrypt → pay storage → upload → pay chain → write reference
2719
- *
2720
- * Presents the entire flow as a single action with step-by-step progress.
2721
- *
2722
- * @param file The File to encrypt and store
2723
- * @param onProgress Callback fired on every step state change
2724
- * @param config Optional token overrides and metadata
2725
- */
2726
- executeMetaTransaction(file: File, onProgress: (progress: MetaTxProgress) => void, config?: MetaTxConfig): Promise<MetaTxReceipt>;
2727
- /**
2728
- * Generate a fresh random DEK, wrap it under the KEK(s), and return the crypto
2729
- * materials needed by MetaTx to encrypt payload and storageId.
2730
- *
2731
- * For private stores: the DEK is wrapped under every available KEK. The ownerSecret
2732
- * can later be re-derived as HKDF(dek, rawStorageId) by any KEK holder.
2733
- * For public stores: a random ownerSeed is generated and wrapped under all KEKs (same pattern).
2734
- */
2735
- prepareUploadCrypto(isPublic?: boolean): Promise<UploadCrypto>;
2736
2552
  /**
2737
2553
  * Upload large content by splitting into CHUNK_SIZE pieces, encrypting each
2738
2554
  * independently, and storing a manifest that ties them together.
@@ -2816,8 +2632,6 @@ declare const CoreErrorCode: {
2816
2632
  readonly LIST_REFS_NOT_SUPPORTED: 10061;
2817
2633
  readonly REMOVE_REF_REQUIRES_CHAIN: 10070;
2818
2634
  readonly REMOVE_REF_NOT_SUPPORTED: 10071;
2819
- readonly META_TX_REQUIRES_ENCRYPTION: 10080;
2820
- readonly PREPARE_UPLOAD_NO_PROVIDERS: 10081;
2821
2635
  readonly MANIFEST_INVALID_STRUCTURE: 10090;
2822
2636
  readonly MANIFEST_CHUNK_COUNT_MISMATCH: 10091;
2823
2637
  readonly MANIFEST_NOT_CONTIGUOUS: 10092;
@@ -2825,7 +2639,6 @@ declare const CoreErrorCode: {
2825
2639
  readonly CHUNK_OVERFLOWS_TOTAL_SIZE: 10094;
2826
2640
  readonly REASSEMBLY_SIZE_MISMATCH: 10095;
2827
2641
  readonly NOT_INITIALIZED: 10100;
2828
- readonly META_TX_UNKNOWN_STEP: 10200;
2829
2642
  readonly UNKNOWN_ERROR: 10999;
2830
2643
  };
2831
2644
  type CoreErrorCode = (typeof CoreErrorCode)[keyof typeof CoreErrorCode];
@@ -2840,4 +2653,4 @@ declare class StorePartialError extends DStorageError {
2840
2653
  }
2841
2654
  declare function isStorePartialError(err: unknown): err is StorePartialError;
2842
2655
 
2843
- export { ARWEAVE_LOCAL, type AdapterWalletProvider, type ArweaveBundlerAdapterConfig, ArweaveBundlerStorageAdapter, type ArweaveLocalAdapterConfig, type ArweaveLocalBalance, ArweaveLocalError, ArweaveLocalHelper, type ArweaveLocalHelperConfig, type ArweaveLocalInfo, ArweaveLocalStorageAdapter, ArweavePaymentAdapter, ArweaveStorageAdapter, CHUNK_SIZE, type ChunkEntry, type ChunkManifest, CoreErrorCode, type CostEstimate, CryptoErrorCode, type CryptoScheme, DStorage, type DStorageConfig, type DStorageContext, DStorageError, type EncryptionAdapter, EncryptionErrorCode, type EncryptionScheme, type FromKdfParamsConfig, HttpGatewayChainAdapter, type HttpGatewayChainAdapterConfig, KDF_PRESETS, type KdfPreset, KeyDeriver, type KeyEnvelope, type KeyWrapper, KeypairEncryptionAdapter, type ListReferencesOptions, type Logger, MANIFEST_AAD, METADATA_AAD, METADATA_ONLY_OWNER_SECRET_SALT, type MLKemVariant, ManagedPaymentAdapter, MetaTx, type MetaTxConfig, type MetaTxProgress, type MetaTxReceipt, type MetaTxStepId, type MetaTxStepState, type MetaTxStepStatus, MidnightChainAdapter, type MidnightChainAdapterConfig, MidnightSimulatorChainAdapter, MnemonicEncryptionAdapter, NETWORKS, PAYLOAD_AAD, PasswordEncryptionAdapter, type PasswordEncryptionAdapterConfig, type RegisterReferenceOptions, type RegisterReferenceResult, type RetrieveResult, type StoreOptions, StorePartialError, type StoreProgress, type StoreRecovery, type StoreResult, type StoredKdfParams, type UpdateResult, type UploadCrypto, type WalletAddresses, type WalletInfo, type WrappedDekResult, type XChaChaPayload, XChaChaScheme, arlocalGateway, base64urlToBytes, buildKeyEnvelope, bytesToBase64url, chunkAad, computeBlake3, computeBlake3Hex, decryptStorageIdXChaCha, decryptXChaCha, defaultChainToken, deriveKek, deriveOwnerSecret, deriveSymmetricKeyFromSeed, deserializeXChaChaPayload, encryptStorageIdXChaCha, encryptXChaCha, findWrapper, generateDek, generatePqsPassword, hexToBytes, isDStorageError, isManifest, isStorePartialError, mlkemGenerateKeypair, mlkemGenerateKeypairFromSeed, mlkemUnwrapDek, mlkemWrapDek, parseKeyEnvelope, serializeKeyEnvelope, serializeXChaChaPayload, unwrapKey, waitForFacadeSync, wrapKey };
2656
+ export { ARWEAVE_LOCAL, type AdapterWalletProvider, type ArweaveBundlerAdapterConfig, ArweaveBundlerStorageAdapter, type ArweaveLocalAdapterConfig, type ArweaveLocalBalance, ArweaveLocalError, ArweaveLocalHelper, type ArweaveLocalHelperConfig, type ArweaveLocalInfo, ArweaveLocalStorageAdapter, ArweavePaymentAdapter, ArweaveStorageAdapter, CHUNK_SIZE, type ChunkEntry, type ChunkManifest, CoreErrorCode, type CostEstimate, CryptoErrorCode, type CryptoScheme, DStorage, type DStorageConfig, DStorageError, type EncryptionAdapter, EncryptionErrorCode, type EncryptionScheme, type FromKdfParamsConfig, HttpGatewayChainAdapter, type HttpGatewayChainAdapterConfig, KDF_PRESETS, type KdfPreset, KeyDeriver, type KeyEnvelope, type KeyWrapper, KeypairEncryptionAdapter, type ListReferencesOptions, type Logger, MANIFEST_AAD, METADATA_AAD, METADATA_ONLY_OWNER_SECRET_SALT, type MLKemVariant, ManagedPaymentAdapter, MidnightChainAdapter, type MidnightChainAdapterConfig, MidnightSimulatorChainAdapter, MnemonicEncryptionAdapter, NETWORKS, PAYLOAD_AAD, PasswordEncryptionAdapter, type PasswordEncryptionAdapterConfig, type RegisterReferenceOptions, type RegisterReferenceResult, type RetrieveResult, type StoreOptions, StorePartialError, type StoreProgress, type StoreRecovery, type StoreResult, type StoredKdfParams, type UpdateResult, type WalletAddresses, type WalletInfo, type WrappedDekResult, type XChaChaPayload, XChaChaScheme, arlocalGateway, base64urlToBytes, buildKeyEnvelope, bytesToBase64url, chunkAad, computeBlake3, computeBlake3Hex, decryptStorageIdXChaCha, decryptXChaCha, deriveKek, deriveOwnerSecret, deriveSymmetricKeyFromSeed, deserializeXChaChaPayload, encryptStorageIdXChaCha, encryptXChaCha, findWrapper, generateDek, generatePqsPassword, hexToBytes, isDStorageError, isManifest, isStorePartialError, mlkemGenerateKeypair, mlkemGenerateKeypairFromSeed, mlkemUnwrapDek, mlkemWrapDek, parseKeyEnvelope, serializeKeyEnvelope, serializeXChaChaPayload, unwrapKey, waitForFacadeSync, wrapKey };