@wishknish/knishio-client-ts 0.9.5 → 0.9.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -124,6 +124,42 @@ interface GraphQLClient$1 {
124
124
  getUri(): string;
125
125
  }
126
126
 
127
+ interface SecretStorageMetadata {
128
+ bundleHash: string;
129
+ label?: string;
130
+ createdAt: number;
131
+ hardwareBacked: boolean;
132
+ providerType: string;
133
+ }
134
+ interface EncryptedSecretPayload {
135
+ version: 1;
136
+ ciphertext: string;
137
+ iv: string;
138
+ salt: string;
139
+ tag?: string;
140
+ algorithm: 'AES-GCM' | 'AES-CBC';
141
+ iterations?: number;
142
+ metadata: SecretStorageMetadata;
143
+ }
144
+ interface ISecretStorageProvider {
145
+ readonly providerType: string;
146
+ isHardwareBacked(): boolean;
147
+ isAvailable(): Promise<boolean>;
148
+ storeSecret(bundleHash: string, secret: string, options?: {
149
+ label?: string;
150
+ passphrase?: string;
151
+ }): Promise<void>;
152
+ retrieveSecret(bundleHash: string, options?: {
153
+ passphrase?: string;
154
+ }): Promise<string | null>;
155
+ deleteSecret(bundleHash: string): Promise<boolean>;
156
+ hasSecret(bundleHash: string): Promise<boolean>;
157
+ listSecrets(): Promise<SecretStorageMetadata[]>;
158
+ withSecret<T>(bundleHash: string, fn: (secret: string) => Promise<T> | T, options?: {
159
+ passphrase?: string;
160
+ }): Promise<T>;
161
+ }
162
+
127
163
  type WalletAddress = WalletAddressPattern & {
128
164
  readonly __brand: 'WalletAddress';
129
165
  };
@@ -472,6 +508,27 @@ declare class Atom {
472
508
  static groupByIsotope(atoms: Atom[]): Record<AtomIsotope, Atom[]>;
473
509
  }
474
510
 
511
+ declare class TokenUnit {
512
+ id: string;
513
+ name: string;
514
+ metas: Record<string, any>;
515
+ constructor(id: string, name: string, metas?: Record<string, any>);
516
+ static createFromGraphQL(data: {
517
+ id: string;
518
+ name: string;
519
+ metas?: any;
520
+ }): TokenUnit;
521
+ static createFromDB(data: [string, string, Record<string, any>?]): TokenUnit;
522
+ getFragmentZone(): any | null;
523
+ getFusedTokenUnits(): any | null;
524
+ toData(): [string, string, Record<string, any>];
525
+ toGraphQLResponse(): {
526
+ id: string;
527
+ name: string;
528
+ metas: string;
529
+ };
530
+ }
531
+
475
532
  declare class Wallet {
476
533
  token: string;
477
534
  balance: string;
@@ -515,7 +572,7 @@ declare class Wallet {
515
572
  static generateAddress(key: string): string;
516
573
  static generatePosition(saltLength?: number): string;
517
574
  static isBundleHash(maybeBundleHash: unknown): maybeBundleHash is string;
518
- static getTokenUnits(unitsData: any[]): any[];
575
+ static getTokenUnits(unitsData: Array<[string, string, Record<string, any>?]>): TokenUnit[];
519
576
  createRemainder(secret: string): Wallet;
520
577
  initBatchId({ sourceWallet, isRemainder }: {
521
578
  sourceWallet: Wallet;
@@ -729,6 +786,10 @@ declare class Molecule {
729
786
  amount: number;
730
787
  walletBundle?: string | null;
731
788
  }): Molecule;
789
+ replenishToken({ amount, units }: {
790
+ amount: number;
791
+ units?: Array<[string, string, Record<string, any>?]>;
792
+ }): Molecule;
732
793
  initAuthorization({ meta }: {
733
794
  meta: Record<string, any>;
734
795
  }): Molecule;
@@ -1142,6 +1203,7 @@ declare class ResponseRequestAuthorization extends ResponseProposeMolecule {
1142
1203
  declare class KnishIOClient {
1143
1204
  private $__secret;
1144
1205
  private $__bundle;
1206
+ private $__secretStorage;
1145
1207
  private $__cellSlug;
1146
1208
  private $__encrypt;
1147
1209
  private $__uris;
@@ -1168,6 +1230,7 @@ declare class KnishIOClient {
1168
1230
  serverSdkVersion?: number;
1169
1231
  logging?: boolean;
1170
1232
  defaultRequestPolicy?: RequestPolicy | null;
1233
+ secretStorage?: ISecretStorageProvider | null;
1171
1234
  });
1172
1235
  initialize({ uri, cellSlug, socket, client, serverSdkVersion, logging, defaultRequestPolicy }: {
1173
1236
  uri: string | string[];
@@ -1197,6 +1260,11 @@ declare class KnishIOClient {
1197
1260
  getCellSlug(): string | null;
1198
1261
  hasSecret(): boolean;
1199
1262
  getSecret(): string;
1263
+ setSecretStorage(storage: ISecretStorageProvider, bundleHash?: string): void;
1264
+ getSecretStorage(): ISecretStorageProvider | null;
1265
+ retrieveSecret(options?: {
1266
+ passphrase?: string;
1267
+ }): Promise<string | null>;
1200
1268
  hasBundle(): boolean;
1201
1269
  getBundle(): string;
1202
1270
  setRemainderWallet(remainderWallet: Wallet): void;
@@ -1396,10 +1464,10 @@ declare class KnishIOClient {
1396
1464
  units?: string[] | null;
1397
1465
  sourceWallet?: Wallet | null;
1398
1466
  }): Promise<Response>;
1399
- replenishToken({ token, amount, units, sourceWallet: _sourceWallet }: {
1467
+ replenishToken({ token, amount, units, sourceWallet }: {
1400
1468
  token: TokenSlug | string;
1401
1469
  amount?: number | string | null;
1402
- units?: string[] | null;
1470
+ units?: Array<[string, string, Record<string, any>?]> | null;
1403
1471
  sourceWallet?: Wallet | null;
1404
1472
  }): Promise<Response>;
1405
1473
  fuseToken({ bundleHash: _bundleHash, tokenSlug, newTokenUnit: _newTokenUnit, fusedTokenUnitIds: _fusedTokenUnitIds, sourceWallet: _sourceWallet }: {
@@ -1795,27 +1863,6 @@ declare class MutationAppendRequest extends MutationProposeMolecule {
1795
1863
  createResponse(json: any): ResponseAppendRequest;
1796
1864
  }
1797
1865
 
1798
- declare class TokenUnit {
1799
- id: string;
1800
- name: string;
1801
- metas: Record<string, any>;
1802
- constructor(id: string, name: string, metas?: Record<string, any>);
1803
- static createFromGraphQL(data: {
1804
- id: string;
1805
- name: string;
1806
- metas?: any;
1807
- }): TokenUnit;
1808
- static createFromDB(data: [string, string, Record<string, any>?]): TokenUnit;
1809
- getFragmentZone(): any | null;
1810
- getFusedTokenUnits(): any | null;
1811
- toData(): [string, string, Record<string, any>];
1812
- toGraphQLResponse(): {
1813
- id: string;
1814
- name: string;
1815
- metas: string;
1816
- };
1817
- }
1818
-
1819
1866
  declare class PolicyMeta {
1820
1867
  policy: Record<string, any>;
1821
1868
  constructor(policy?: Record<string, any>, metaKeys?: string[]);
@@ -1963,6 +2010,13 @@ declare class WalletCredentialException extends BaseException {
1963
2010
  static bundleMismatch(expected: string, actual: string): WalletCredentialException;
1964
2011
  }
1965
2012
 
2013
+ declare class SecretStorageException extends BaseException {
2014
+ constructor(message?: string, options?: BaseExceptionOptions);
2015
+ static notFound(bundleHash: string): SecretStorageException;
2016
+ static decryptionFailed(reason?: string): SecretStorageException;
2017
+ static unavailable(provider: string, reason?: string): SecretStorageException;
2018
+ }
2019
+
1966
2020
  declare class InvalidResponseException extends BaseException {
1967
2021
  constructor(message?: string, options?: BaseExceptionOptions);
1968
2022
  static malformedJson(error: string): InvalidResponseException;
@@ -2074,12 +2128,83 @@ declare const EXCEPTION_CODES: {
2074
2128
  readonly NETWORK_ERROR: "NETWORK_ERROR";
2075
2129
  };
2076
2130
 
2077
- declare const SDK_VERSION = "0.9.5";
2131
+ declare class MemorySecretStorageProvider implements ISecretStorageProvider {
2132
+ readonly providerType = "memory";
2133
+ private secrets;
2134
+ isHardwareBacked(): boolean;
2135
+ isAvailable(): Promise<boolean>;
2136
+ storeSecret(bundleHash: string, secret: string, options?: {
2137
+ label?: string;
2138
+ passphrase?: string;
2139
+ }): Promise<void>;
2140
+ retrieveSecret(bundleHash: string): Promise<string | null>;
2141
+ deleteSecret(bundleHash: string): Promise<boolean>;
2142
+ hasSecret(bundleHash: string): Promise<boolean>;
2143
+ listSecrets(): Promise<SecretStorageMetadata[]>;
2144
+ withSecret<T>(bundleHash: string, fn: (secret: string) => Promise<T> | T): Promise<T>;
2145
+ clear(): void;
2146
+ }
2147
+
2148
+ interface IStorageBackend {
2149
+ getItem(key: string): Promise<string | null> | string | null;
2150
+ setItem(key: string, value: string): Promise<void> | void;
2151
+ removeItem(key: string): Promise<boolean | void> | boolean | void;
2152
+ keys(): Promise<string[]> | string[];
2153
+ }
2154
+ declare class MemoryStorageBackend implements IStorageBackend {
2155
+ private store;
2156
+ getItem(key: string): string | null;
2157
+ setItem(key: string, value: string): void;
2158
+ removeItem(key: string): boolean;
2159
+ keys(): string[];
2160
+ }
2161
+ declare class WebCryptoSecretStorageProvider implements ISecretStorageProvider {
2162
+ readonly providerType = "webcrypto-aes-gcm";
2163
+ private backend;
2164
+ private defaultPassphrase?;
2165
+ private hardwareBacked;
2166
+ constructor(options?: {
2167
+ backend?: IStorageBackend;
2168
+ defaultPassphrase?: string;
2169
+ hardwareBacked?: boolean;
2170
+ });
2171
+ isHardwareBacked(): boolean;
2172
+ isAvailable(): Promise<boolean>;
2173
+ private deriveKey;
2174
+ storeSecret(bundleHash: string, secret: string, options?: {
2175
+ label?: string;
2176
+ passphrase?: string;
2177
+ }): Promise<void>;
2178
+ retrieveSecret(bundleHash: string, options?: {
2179
+ passphrase?: string;
2180
+ }): Promise<string | null>;
2181
+ deleteSecret(bundleHash: string): Promise<boolean>;
2182
+ hasSecret(bundleHash: string): Promise<boolean>;
2183
+ listSecrets(): Promise<SecretStorageMetadata[]>;
2184
+ withSecret<T>(bundleHash: string, fn: (secret: string) => Promise<T> | T, options?: {
2185
+ passphrase?: string;
2186
+ }): Promise<T>;
2187
+ }
2188
+
2189
+ interface CreateSecretStorageOptions {
2190
+ type?: 'webcrypto' | 'memory';
2191
+ defaultPassphrase?: string;
2192
+ backend?: IStorageBackend;
2193
+ hardwareBacked?: boolean;
2194
+ }
2195
+ declare function createDefaultSecretStorage(options?: CreateSecretStorageOptions): ISecretStorageProvider;
2196
+
2197
+ declare function zeroizeBytes(buffer: Uint8Array | number[]): void;
2198
+ declare function withSecureBytes<T>(bytes: Uint8Array, fn: (bytes: Uint8Array) => Promise<T> | T): Promise<T>;
2199
+ declare function withSecureString<T>(secret: string, fn: (cleanSecret: string) => Promise<T> | T): Promise<T>;
2200
+ declare function constantTimeCompare(a: Uint8Array | string, b: Uint8Array | string): boolean;
2201
+
2202
+ declare const SDK_VERSION = "0.9.7";
2078
2203
  declare const SDK_NAME = "KnishIO-Client-TS";
2079
2204
  declare const COMPATIBLE_SERVER_VERSIONS: number[];
2080
2205
  declare const SDK_INFO: {
2081
2206
  readonly name: "KnishIO-Client-TS";
2082
- readonly version: "0.9.5";
2207
+ readonly version: "0.9.7";
2083
2208
  readonly description: "TypeScript SDK for Knish.IO post-blockchain distributed ledger";
2084
2209
  readonly compatibleServerVersions: number[];
2085
2210
  readonly features: readonly ["Post-quantum cryptography (XMSS, ML-KEM768)", "Cross-platform compatibility", "Type-safe APIs", "DAG-based transaction processing", "GraphQL integration", "Real-time subscriptions", "Cellular architecture support"];
@@ -2107,7 +2232,7 @@ declare const DevUtils: {
2107
2232
  nodeVersion: string;
2108
2233
  environment: string;
2109
2234
  name: "KnishIO-Client-TS";
2110
- version: "0.9.5";
2235
+ version: "0.9.7";
2111
2236
  description: "TypeScript SDK for Knish.IO post-blockchain distributed ledger";
2112
2237
  compatibleServerVersions: number[];
2113
2238
  features: readonly ["Post-quantum cryptography (XMSS, ML-KEM768)", "Cross-platform compatibility", "Type-safe APIs", "DAG-based transaction processing", "GraphQL integration", "Real-time subscriptions", "Cellular architecture support"];
@@ -2134,7 +2259,7 @@ declare const KnishIO: {
2134
2259
  SDK_VERSION: string;
2135
2260
  SDK_INFO: {
2136
2261
  readonly name: "KnishIO-Client-TS";
2137
- readonly version: "0.9.5";
2262
+ readonly version: "0.9.7";
2138
2263
  readonly description: "TypeScript SDK for Knish.IO post-blockchain distributed ledger";
2139
2264
  readonly compatibleServerVersions: number[];
2140
2265
  readonly features: readonly ["Post-quantum cryptography (XMSS, ML-KEM768)", "Cross-platform compatibility", "Type-safe APIs", "DAG-based transaction processing", "GraphQL integration", "Real-time subscriptions", "Cellular architecture support"];
@@ -2147,4 +2272,4 @@ declare const KnishIO: {
2147
2272
  };
2148
2273
  };
2149
2274
 
2150
- export { Atom, AtomIndexException, type AtomIsotope, AtomMeta, type AtomParams, AtomsMissingException, type AuthParams, AuthToken, type BalanceQueryParams, type Base17Hash, BaseException, type BaseResponse, type BundleHash, type BundleHashOptions, COMPATIBLE_SERVER_VERSIONS, CRYPTO_CONSTANTS, type CellSlug, CheckMolecule, type CreateTokenParams, DevUtils, Dot, EXCEPTION_CODES, EXCEPTION_TYPES, EXTENDED_COMPATIBILITY_TEST_VECTORS, type EmbeddingStatusItem, ExceptionFactory, GraphQLClient, type GraphQLError, type GraphQLRequest, type GraphQLResponse, type HexString, InvalidResponseException, type KeyGenerationOptions, KnishIO, KnishIOClient, type KnishIOClientConfig, Meta$1 as Meta, type MetaData, type MetaId, type MetaQueryParams, type MetaType, type MolecularHash, MolecularHashMismatchException, Molecule, type MoleculeParams, Mutation, MutationAppendRequest, MutationCreateMeta, MutationCreateToken, MutationCreateWallet, type MutationOperation, MutationPeering, MutationProposeMolecule, MutationRequestAuthorization, MutationRequestTokens, MutationTransferTokens, PolicyMeta, type Position, type PositionGenerationOptions, Query, QueryAtom, QueryBalance, QueryBatch, QueryContinuId, QueryEmbeddingStatus, QueryMetaType, QueryMetaTypeViaAtom, type QueryOperation, QueryWalletBundle, QueryWalletList, type RequestTokensParams, Response, ResponseAppendRequest, ResponseAtom, ResponseBalance, ResponseContinuId, ResponseCreateMeta, ResponseCreateToken, ResponseCreateWallet, ResponseEmbeddingStatus, ResponseMetaType, ResponseMetaTypeViaAtom, ResponsePeering, ResponseProposeMolecule, ResponseRequestAuthorization, ResponseRequestTokens, ResponseTransferTokens, ResponseWalletBundle, ResponseWalletList, type SDKConfig, SDK_INFO, SDK_NAME, SDK_VERSION, type SHAKE256Options, type SecretGenerationOptions, SignatureMismatchException, type SignatureOptions, type TokenSlug, TokenUnit, TransferBalanceException, type TransferParams, type ValidationResult$1 as ValidationResult, type VerificationOptions, Wallet, type WalletAddress, WalletCredentialException, type WalletParams, type WalletQueryParams, base64ToHex, bufferToHexString, capitalize, charsetBaseConvert, chunkArray, chunkSubstr, configureSDK, convertToBase17, createBundleHash, createMolecularHash, createPosition, createTokenSlug, createWalletAddress, deepCloning, diff, enumerateMolecularHash, generateBatchId, generateBundleHash, generateOTSSignature, generatePosition, generateSecret, generateWalletAddress, generateWalletKey, getSDKConfig, hexStringToBuffer, hexToBase64, intersect, isAtomIsotope, isBundleHash, isHex, isHexString, isMolecularHash, isNumeric, isPosition, isWalletAddress, normalizeMolecularHash, randomString, runCompatibilityTests, runExtendedCompatibilityTests, shake256, toCamelCase, toSnakeCase, truncate, validateBundleHash, validateMolecularHashForSignature, validateOTSSignature, validatePosition, validateSecret, validateWalletAddress, verifyOTSSignature };
2275
+ export { Atom, AtomIndexException, type AtomIsotope, AtomMeta, type AtomParams, AtomsMissingException, type AuthParams, AuthToken, type BalanceQueryParams, type Base17Hash, BaseException, type BaseResponse, type BundleHash, type BundleHashOptions, COMPATIBLE_SERVER_VERSIONS, CRYPTO_CONSTANTS, type CellSlug, CheckMolecule, type CreateSecretStorageOptions, type CreateTokenParams, DevUtils, Dot, EXCEPTION_CODES, EXCEPTION_TYPES, EXTENDED_COMPATIBILITY_TEST_VECTORS, type EmbeddingStatusItem, type EncryptedSecretPayload, ExceptionFactory, GraphQLClient, type GraphQLError, type GraphQLRequest, type GraphQLResponse, type HexString, type ISecretStorageProvider, type IStorageBackend, InvalidResponseException, type KeyGenerationOptions, KnishIO, KnishIOClient, type KnishIOClientConfig, MemorySecretStorageProvider, MemoryStorageBackend, Meta$1 as Meta, type MetaData, type MetaId, type MetaQueryParams, type MetaType, type MolecularHash, MolecularHashMismatchException, Molecule, type MoleculeParams, Mutation, MutationAppendRequest, MutationCreateMeta, MutationCreateToken, MutationCreateWallet, type MutationOperation, MutationPeering, MutationProposeMolecule, MutationRequestAuthorization, MutationRequestTokens, MutationTransferTokens, PolicyMeta, type Position, type PositionGenerationOptions, Query, QueryAtom, QueryBalance, QueryBatch, QueryContinuId, QueryEmbeddingStatus, QueryMetaType, QueryMetaTypeViaAtom, type QueryOperation, QueryWalletBundle, QueryWalletList, type RequestTokensParams, Response, ResponseAppendRequest, ResponseAtom, ResponseBalance, ResponseContinuId, ResponseCreateMeta, ResponseCreateToken, ResponseCreateWallet, ResponseEmbeddingStatus, ResponseMetaType, ResponseMetaTypeViaAtom, ResponsePeering, ResponseProposeMolecule, ResponseRequestAuthorization, ResponseRequestTokens, ResponseTransferTokens, ResponseWalletBundle, ResponseWalletList, type SDKConfig, SDK_INFO, SDK_NAME, SDK_VERSION, type SHAKE256Options, type SecretGenerationOptions, SecretStorageException, type SecretStorageMetadata, SignatureMismatchException, type SignatureOptions, type TokenSlug, TokenUnit, TransferBalanceException, type TransferParams, type ValidationResult$1 as ValidationResult, type VerificationOptions, Wallet, type WalletAddress, WalletCredentialException, type WalletParams, type WalletQueryParams, WebCryptoSecretStorageProvider, base64ToHex, bufferToHexString, capitalize, charsetBaseConvert, chunkArray, chunkSubstr, configureSDK, constantTimeCompare, convertToBase17, createBundleHash, createDefaultSecretStorage, createMolecularHash, createPosition, createTokenSlug, createWalletAddress, deepCloning, diff, enumerateMolecularHash, generateBatchId, generateBundleHash, generateOTSSignature, generatePosition, generateSecret, generateWalletAddress, generateWalletKey, getSDKConfig, hexStringToBuffer, hexToBase64, intersect, isAtomIsotope, isBundleHash, isHex, isHexString, isMolecularHash, isNumeric, isPosition, isWalletAddress, normalizeMolecularHash, randomString, runCompatibilityTests, runExtendedCompatibilityTests, shake256, toCamelCase, toSnakeCase, truncate, validateBundleHash, validateMolecularHashForSignature, validateOTSSignature, validatePosition, validateSecret, validateWalletAddress, verifyOTSSignature, withSecureBytes, withSecureString, zeroizeBytes };
package/dist/index.d.ts CHANGED
@@ -124,6 +124,42 @@ interface GraphQLClient$1 {
124
124
  getUri(): string;
125
125
  }
126
126
 
127
+ interface SecretStorageMetadata {
128
+ bundleHash: string;
129
+ label?: string;
130
+ createdAt: number;
131
+ hardwareBacked: boolean;
132
+ providerType: string;
133
+ }
134
+ interface EncryptedSecretPayload {
135
+ version: 1;
136
+ ciphertext: string;
137
+ iv: string;
138
+ salt: string;
139
+ tag?: string;
140
+ algorithm: 'AES-GCM' | 'AES-CBC';
141
+ iterations?: number;
142
+ metadata: SecretStorageMetadata;
143
+ }
144
+ interface ISecretStorageProvider {
145
+ readonly providerType: string;
146
+ isHardwareBacked(): boolean;
147
+ isAvailable(): Promise<boolean>;
148
+ storeSecret(bundleHash: string, secret: string, options?: {
149
+ label?: string;
150
+ passphrase?: string;
151
+ }): Promise<void>;
152
+ retrieveSecret(bundleHash: string, options?: {
153
+ passphrase?: string;
154
+ }): Promise<string | null>;
155
+ deleteSecret(bundleHash: string): Promise<boolean>;
156
+ hasSecret(bundleHash: string): Promise<boolean>;
157
+ listSecrets(): Promise<SecretStorageMetadata[]>;
158
+ withSecret<T>(bundleHash: string, fn: (secret: string) => Promise<T> | T, options?: {
159
+ passphrase?: string;
160
+ }): Promise<T>;
161
+ }
162
+
127
163
  type WalletAddress = WalletAddressPattern & {
128
164
  readonly __brand: 'WalletAddress';
129
165
  };
@@ -472,6 +508,27 @@ declare class Atom {
472
508
  static groupByIsotope(atoms: Atom[]): Record<AtomIsotope, Atom[]>;
473
509
  }
474
510
 
511
+ declare class TokenUnit {
512
+ id: string;
513
+ name: string;
514
+ metas: Record<string, any>;
515
+ constructor(id: string, name: string, metas?: Record<string, any>);
516
+ static createFromGraphQL(data: {
517
+ id: string;
518
+ name: string;
519
+ metas?: any;
520
+ }): TokenUnit;
521
+ static createFromDB(data: [string, string, Record<string, any>?]): TokenUnit;
522
+ getFragmentZone(): any | null;
523
+ getFusedTokenUnits(): any | null;
524
+ toData(): [string, string, Record<string, any>];
525
+ toGraphQLResponse(): {
526
+ id: string;
527
+ name: string;
528
+ metas: string;
529
+ };
530
+ }
531
+
475
532
  declare class Wallet {
476
533
  token: string;
477
534
  balance: string;
@@ -515,7 +572,7 @@ declare class Wallet {
515
572
  static generateAddress(key: string): string;
516
573
  static generatePosition(saltLength?: number): string;
517
574
  static isBundleHash(maybeBundleHash: unknown): maybeBundleHash is string;
518
- static getTokenUnits(unitsData: any[]): any[];
575
+ static getTokenUnits(unitsData: Array<[string, string, Record<string, any>?]>): TokenUnit[];
519
576
  createRemainder(secret: string): Wallet;
520
577
  initBatchId({ sourceWallet, isRemainder }: {
521
578
  sourceWallet: Wallet;
@@ -729,6 +786,10 @@ declare class Molecule {
729
786
  amount: number;
730
787
  walletBundle?: string | null;
731
788
  }): Molecule;
789
+ replenishToken({ amount, units }: {
790
+ amount: number;
791
+ units?: Array<[string, string, Record<string, any>?]>;
792
+ }): Molecule;
732
793
  initAuthorization({ meta }: {
733
794
  meta: Record<string, any>;
734
795
  }): Molecule;
@@ -1142,6 +1203,7 @@ declare class ResponseRequestAuthorization extends ResponseProposeMolecule {
1142
1203
  declare class KnishIOClient {
1143
1204
  private $__secret;
1144
1205
  private $__bundle;
1206
+ private $__secretStorage;
1145
1207
  private $__cellSlug;
1146
1208
  private $__encrypt;
1147
1209
  private $__uris;
@@ -1168,6 +1230,7 @@ declare class KnishIOClient {
1168
1230
  serverSdkVersion?: number;
1169
1231
  logging?: boolean;
1170
1232
  defaultRequestPolicy?: RequestPolicy | null;
1233
+ secretStorage?: ISecretStorageProvider | null;
1171
1234
  });
1172
1235
  initialize({ uri, cellSlug, socket, client, serverSdkVersion, logging, defaultRequestPolicy }: {
1173
1236
  uri: string | string[];
@@ -1197,6 +1260,11 @@ declare class KnishIOClient {
1197
1260
  getCellSlug(): string | null;
1198
1261
  hasSecret(): boolean;
1199
1262
  getSecret(): string;
1263
+ setSecretStorage(storage: ISecretStorageProvider, bundleHash?: string): void;
1264
+ getSecretStorage(): ISecretStorageProvider | null;
1265
+ retrieveSecret(options?: {
1266
+ passphrase?: string;
1267
+ }): Promise<string | null>;
1200
1268
  hasBundle(): boolean;
1201
1269
  getBundle(): string;
1202
1270
  setRemainderWallet(remainderWallet: Wallet): void;
@@ -1396,10 +1464,10 @@ declare class KnishIOClient {
1396
1464
  units?: string[] | null;
1397
1465
  sourceWallet?: Wallet | null;
1398
1466
  }): Promise<Response>;
1399
- replenishToken({ token, amount, units, sourceWallet: _sourceWallet }: {
1467
+ replenishToken({ token, amount, units, sourceWallet }: {
1400
1468
  token: TokenSlug | string;
1401
1469
  amount?: number | string | null;
1402
- units?: string[] | null;
1470
+ units?: Array<[string, string, Record<string, any>?]> | null;
1403
1471
  sourceWallet?: Wallet | null;
1404
1472
  }): Promise<Response>;
1405
1473
  fuseToken({ bundleHash: _bundleHash, tokenSlug, newTokenUnit: _newTokenUnit, fusedTokenUnitIds: _fusedTokenUnitIds, sourceWallet: _sourceWallet }: {
@@ -1795,27 +1863,6 @@ declare class MutationAppendRequest extends MutationProposeMolecule {
1795
1863
  createResponse(json: any): ResponseAppendRequest;
1796
1864
  }
1797
1865
 
1798
- declare class TokenUnit {
1799
- id: string;
1800
- name: string;
1801
- metas: Record<string, any>;
1802
- constructor(id: string, name: string, metas?: Record<string, any>);
1803
- static createFromGraphQL(data: {
1804
- id: string;
1805
- name: string;
1806
- metas?: any;
1807
- }): TokenUnit;
1808
- static createFromDB(data: [string, string, Record<string, any>?]): TokenUnit;
1809
- getFragmentZone(): any | null;
1810
- getFusedTokenUnits(): any | null;
1811
- toData(): [string, string, Record<string, any>];
1812
- toGraphQLResponse(): {
1813
- id: string;
1814
- name: string;
1815
- metas: string;
1816
- };
1817
- }
1818
-
1819
1866
  declare class PolicyMeta {
1820
1867
  policy: Record<string, any>;
1821
1868
  constructor(policy?: Record<string, any>, metaKeys?: string[]);
@@ -1963,6 +2010,13 @@ declare class WalletCredentialException extends BaseException {
1963
2010
  static bundleMismatch(expected: string, actual: string): WalletCredentialException;
1964
2011
  }
1965
2012
 
2013
+ declare class SecretStorageException extends BaseException {
2014
+ constructor(message?: string, options?: BaseExceptionOptions);
2015
+ static notFound(bundleHash: string): SecretStorageException;
2016
+ static decryptionFailed(reason?: string): SecretStorageException;
2017
+ static unavailable(provider: string, reason?: string): SecretStorageException;
2018
+ }
2019
+
1966
2020
  declare class InvalidResponseException extends BaseException {
1967
2021
  constructor(message?: string, options?: BaseExceptionOptions);
1968
2022
  static malformedJson(error: string): InvalidResponseException;
@@ -2074,12 +2128,83 @@ declare const EXCEPTION_CODES: {
2074
2128
  readonly NETWORK_ERROR: "NETWORK_ERROR";
2075
2129
  };
2076
2130
 
2077
- declare const SDK_VERSION = "0.9.5";
2131
+ declare class MemorySecretStorageProvider implements ISecretStorageProvider {
2132
+ readonly providerType = "memory";
2133
+ private secrets;
2134
+ isHardwareBacked(): boolean;
2135
+ isAvailable(): Promise<boolean>;
2136
+ storeSecret(bundleHash: string, secret: string, options?: {
2137
+ label?: string;
2138
+ passphrase?: string;
2139
+ }): Promise<void>;
2140
+ retrieveSecret(bundleHash: string): Promise<string | null>;
2141
+ deleteSecret(bundleHash: string): Promise<boolean>;
2142
+ hasSecret(bundleHash: string): Promise<boolean>;
2143
+ listSecrets(): Promise<SecretStorageMetadata[]>;
2144
+ withSecret<T>(bundleHash: string, fn: (secret: string) => Promise<T> | T): Promise<T>;
2145
+ clear(): void;
2146
+ }
2147
+
2148
+ interface IStorageBackend {
2149
+ getItem(key: string): Promise<string | null> | string | null;
2150
+ setItem(key: string, value: string): Promise<void> | void;
2151
+ removeItem(key: string): Promise<boolean | void> | boolean | void;
2152
+ keys(): Promise<string[]> | string[];
2153
+ }
2154
+ declare class MemoryStorageBackend implements IStorageBackend {
2155
+ private store;
2156
+ getItem(key: string): string | null;
2157
+ setItem(key: string, value: string): void;
2158
+ removeItem(key: string): boolean;
2159
+ keys(): string[];
2160
+ }
2161
+ declare class WebCryptoSecretStorageProvider implements ISecretStorageProvider {
2162
+ readonly providerType = "webcrypto-aes-gcm";
2163
+ private backend;
2164
+ private defaultPassphrase?;
2165
+ private hardwareBacked;
2166
+ constructor(options?: {
2167
+ backend?: IStorageBackend;
2168
+ defaultPassphrase?: string;
2169
+ hardwareBacked?: boolean;
2170
+ });
2171
+ isHardwareBacked(): boolean;
2172
+ isAvailable(): Promise<boolean>;
2173
+ private deriveKey;
2174
+ storeSecret(bundleHash: string, secret: string, options?: {
2175
+ label?: string;
2176
+ passphrase?: string;
2177
+ }): Promise<void>;
2178
+ retrieveSecret(bundleHash: string, options?: {
2179
+ passphrase?: string;
2180
+ }): Promise<string | null>;
2181
+ deleteSecret(bundleHash: string): Promise<boolean>;
2182
+ hasSecret(bundleHash: string): Promise<boolean>;
2183
+ listSecrets(): Promise<SecretStorageMetadata[]>;
2184
+ withSecret<T>(bundleHash: string, fn: (secret: string) => Promise<T> | T, options?: {
2185
+ passphrase?: string;
2186
+ }): Promise<T>;
2187
+ }
2188
+
2189
+ interface CreateSecretStorageOptions {
2190
+ type?: 'webcrypto' | 'memory';
2191
+ defaultPassphrase?: string;
2192
+ backend?: IStorageBackend;
2193
+ hardwareBacked?: boolean;
2194
+ }
2195
+ declare function createDefaultSecretStorage(options?: CreateSecretStorageOptions): ISecretStorageProvider;
2196
+
2197
+ declare function zeroizeBytes(buffer: Uint8Array | number[]): void;
2198
+ declare function withSecureBytes<T>(bytes: Uint8Array, fn: (bytes: Uint8Array) => Promise<T> | T): Promise<T>;
2199
+ declare function withSecureString<T>(secret: string, fn: (cleanSecret: string) => Promise<T> | T): Promise<T>;
2200
+ declare function constantTimeCompare(a: Uint8Array | string, b: Uint8Array | string): boolean;
2201
+
2202
+ declare const SDK_VERSION = "0.9.7";
2078
2203
  declare const SDK_NAME = "KnishIO-Client-TS";
2079
2204
  declare const COMPATIBLE_SERVER_VERSIONS: number[];
2080
2205
  declare const SDK_INFO: {
2081
2206
  readonly name: "KnishIO-Client-TS";
2082
- readonly version: "0.9.5";
2207
+ readonly version: "0.9.7";
2083
2208
  readonly description: "TypeScript SDK for Knish.IO post-blockchain distributed ledger";
2084
2209
  readonly compatibleServerVersions: number[];
2085
2210
  readonly features: readonly ["Post-quantum cryptography (XMSS, ML-KEM768)", "Cross-platform compatibility", "Type-safe APIs", "DAG-based transaction processing", "GraphQL integration", "Real-time subscriptions", "Cellular architecture support"];
@@ -2107,7 +2232,7 @@ declare const DevUtils: {
2107
2232
  nodeVersion: string;
2108
2233
  environment: string;
2109
2234
  name: "KnishIO-Client-TS";
2110
- version: "0.9.5";
2235
+ version: "0.9.7";
2111
2236
  description: "TypeScript SDK for Knish.IO post-blockchain distributed ledger";
2112
2237
  compatibleServerVersions: number[];
2113
2238
  features: readonly ["Post-quantum cryptography (XMSS, ML-KEM768)", "Cross-platform compatibility", "Type-safe APIs", "DAG-based transaction processing", "GraphQL integration", "Real-time subscriptions", "Cellular architecture support"];
@@ -2134,7 +2259,7 @@ declare const KnishIO: {
2134
2259
  SDK_VERSION: string;
2135
2260
  SDK_INFO: {
2136
2261
  readonly name: "KnishIO-Client-TS";
2137
- readonly version: "0.9.5";
2262
+ readonly version: "0.9.7";
2138
2263
  readonly description: "TypeScript SDK for Knish.IO post-blockchain distributed ledger";
2139
2264
  readonly compatibleServerVersions: number[];
2140
2265
  readonly features: readonly ["Post-quantum cryptography (XMSS, ML-KEM768)", "Cross-platform compatibility", "Type-safe APIs", "DAG-based transaction processing", "GraphQL integration", "Real-time subscriptions", "Cellular architecture support"];
@@ -2147,4 +2272,4 @@ declare const KnishIO: {
2147
2272
  };
2148
2273
  };
2149
2274
 
2150
- export { Atom, AtomIndexException, type AtomIsotope, AtomMeta, type AtomParams, AtomsMissingException, type AuthParams, AuthToken, type BalanceQueryParams, type Base17Hash, BaseException, type BaseResponse, type BundleHash, type BundleHashOptions, COMPATIBLE_SERVER_VERSIONS, CRYPTO_CONSTANTS, type CellSlug, CheckMolecule, type CreateTokenParams, DevUtils, Dot, EXCEPTION_CODES, EXCEPTION_TYPES, EXTENDED_COMPATIBILITY_TEST_VECTORS, type EmbeddingStatusItem, ExceptionFactory, GraphQLClient, type GraphQLError, type GraphQLRequest, type GraphQLResponse, type HexString, InvalidResponseException, type KeyGenerationOptions, KnishIO, KnishIOClient, type KnishIOClientConfig, Meta$1 as Meta, type MetaData, type MetaId, type MetaQueryParams, type MetaType, type MolecularHash, MolecularHashMismatchException, Molecule, type MoleculeParams, Mutation, MutationAppendRequest, MutationCreateMeta, MutationCreateToken, MutationCreateWallet, type MutationOperation, MutationPeering, MutationProposeMolecule, MutationRequestAuthorization, MutationRequestTokens, MutationTransferTokens, PolicyMeta, type Position, type PositionGenerationOptions, Query, QueryAtom, QueryBalance, QueryBatch, QueryContinuId, QueryEmbeddingStatus, QueryMetaType, QueryMetaTypeViaAtom, type QueryOperation, QueryWalletBundle, QueryWalletList, type RequestTokensParams, Response, ResponseAppendRequest, ResponseAtom, ResponseBalance, ResponseContinuId, ResponseCreateMeta, ResponseCreateToken, ResponseCreateWallet, ResponseEmbeddingStatus, ResponseMetaType, ResponseMetaTypeViaAtom, ResponsePeering, ResponseProposeMolecule, ResponseRequestAuthorization, ResponseRequestTokens, ResponseTransferTokens, ResponseWalletBundle, ResponseWalletList, type SDKConfig, SDK_INFO, SDK_NAME, SDK_VERSION, type SHAKE256Options, type SecretGenerationOptions, SignatureMismatchException, type SignatureOptions, type TokenSlug, TokenUnit, TransferBalanceException, type TransferParams, type ValidationResult$1 as ValidationResult, type VerificationOptions, Wallet, type WalletAddress, WalletCredentialException, type WalletParams, type WalletQueryParams, base64ToHex, bufferToHexString, capitalize, charsetBaseConvert, chunkArray, chunkSubstr, configureSDK, convertToBase17, createBundleHash, createMolecularHash, createPosition, createTokenSlug, createWalletAddress, deepCloning, diff, enumerateMolecularHash, generateBatchId, generateBundleHash, generateOTSSignature, generatePosition, generateSecret, generateWalletAddress, generateWalletKey, getSDKConfig, hexStringToBuffer, hexToBase64, intersect, isAtomIsotope, isBundleHash, isHex, isHexString, isMolecularHash, isNumeric, isPosition, isWalletAddress, normalizeMolecularHash, randomString, runCompatibilityTests, runExtendedCompatibilityTests, shake256, toCamelCase, toSnakeCase, truncate, validateBundleHash, validateMolecularHashForSignature, validateOTSSignature, validatePosition, validateSecret, validateWalletAddress, verifyOTSSignature };
2275
+ export { Atom, AtomIndexException, type AtomIsotope, AtomMeta, type AtomParams, AtomsMissingException, type AuthParams, AuthToken, type BalanceQueryParams, type Base17Hash, BaseException, type BaseResponse, type BundleHash, type BundleHashOptions, COMPATIBLE_SERVER_VERSIONS, CRYPTO_CONSTANTS, type CellSlug, CheckMolecule, type CreateSecretStorageOptions, type CreateTokenParams, DevUtils, Dot, EXCEPTION_CODES, EXCEPTION_TYPES, EXTENDED_COMPATIBILITY_TEST_VECTORS, type EmbeddingStatusItem, type EncryptedSecretPayload, ExceptionFactory, GraphQLClient, type GraphQLError, type GraphQLRequest, type GraphQLResponse, type HexString, type ISecretStorageProvider, type IStorageBackend, InvalidResponseException, type KeyGenerationOptions, KnishIO, KnishIOClient, type KnishIOClientConfig, MemorySecretStorageProvider, MemoryStorageBackend, Meta$1 as Meta, type MetaData, type MetaId, type MetaQueryParams, type MetaType, type MolecularHash, MolecularHashMismatchException, Molecule, type MoleculeParams, Mutation, MutationAppendRequest, MutationCreateMeta, MutationCreateToken, MutationCreateWallet, type MutationOperation, MutationPeering, MutationProposeMolecule, MutationRequestAuthorization, MutationRequestTokens, MutationTransferTokens, PolicyMeta, type Position, type PositionGenerationOptions, Query, QueryAtom, QueryBalance, QueryBatch, QueryContinuId, QueryEmbeddingStatus, QueryMetaType, QueryMetaTypeViaAtom, type QueryOperation, QueryWalletBundle, QueryWalletList, type RequestTokensParams, Response, ResponseAppendRequest, ResponseAtom, ResponseBalance, ResponseContinuId, ResponseCreateMeta, ResponseCreateToken, ResponseCreateWallet, ResponseEmbeddingStatus, ResponseMetaType, ResponseMetaTypeViaAtom, ResponsePeering, ResponseProposeMolecule, ResponseRequestAuthorization, ResponseRequestTokens, ResponseTransferTokens, ResponseWalletBundle, ResponseWalletList, type SDKConfig, SDK_INFO, SDK_NAME, SDK_VERSION, type SHAKE256Options, type SecretGenerationOptions, SecretStorageException, type SecretStorageMetadata, SignatureMismatchException, type SignatureOptions, type TokenSlug, TokenUnit, TransferBalanceException, type TransferParams, type ValidationResult$1 as ValidationResult, type VerificationOptions, Wallet, type WalletAddress, WalletCredentialException, type WalletParams, type WalletQueryParams, WebCryptoSecretStorageProvider, base64ToHex, bufferToHexString, capitalize, charsetBaseConvert, chunkArray, chunkSubstr, configureSDK, constantTimeCompare, convertToBase17, createBundleHash, createDefaultSecretStorage, createMolecularHash, createPosition, createTokenSlug, createWalletAddress, deepCloning, diff, enumerateMolecularHash, generateBatchId, generateBundleHash, generateOTSSignature, generatePosition, generateSecret, generateWalletAddress, generateWalletKey, getSDKConfig, hexStringToBuffer, hexToBase64, intersect, isAtomIsotope, isBundleHash, isHex, isHexString, isMolecularHash, isNumeric, isPosition, isWalletAddress, normalizeMolecularHash, randomString, runCompatibilityTests, runExtendedCompatibilityTests, shake256, toCamelCase, toSnakeCase, truncate, validateBundleHash, validateMolecularHashForSignature, validateOTSSignature, validatePosition, validateSecret, validateWalletAddress, verifyOTSSignature, withSecureBytes, withSecureString, zeroizeBytes };