@wishknish/knishio-client-ts 1.0.0 → 1.2.0

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
@@ -141,14 +141,17 @@ interface EncryptedSecretPayload {
141
141
  iterations?: number;
142
142
  metadata: SecretStorageMetadata;
143
143
  }
144
+ interface StorageOptions {
145
+ label?: string;
146
+ passphrase?: string;
147
+ recoveryPassphrase?: string;
148
+ allowUnrecoverable?: boolean;
149
+ }
144
150
  interface ISecretStorageProvider {
145
151
  readonly providerType: string;
146
152
  isHardwareBacked(): boolean;
147
153
  isAvailable(): Promise<boolean>;
148
- storeSecret(bundleHash: string, secret: string, options?: {
149
- label?: string;
150
- passphrase?: string;
151
- }): Promise<void>;
154
+ storeSecret(bundleHash: string, secret: string, options?: StorageOptions): Promise<void>;
152
155
  retrieveSecret(bundleHash: string, options?: {
153
156
  passphrase?: string;
154
157
  }): Promise<string | null>;
@@ -158,6 +161,9 @@ interface ISecretStorageProvider {
158
161
  withSecret<T>(bundleHash: string, fn: (secret: string) => Promise<T> | T, options?: {
159
162
  passphrase?: string;
160
163
  }): Promise<T>;
164
+ recoverSecret(bundleHash: string, recoveryPassphrase: string, options?: {
165
+ label?: string;
166
+ }): Promise<void>;
161
167
  }
162
168
 
163
169
  type WalletAddress = WalletAddressPattern & {
@@ -2021,6 +2027,7 @@ declare class SecretStorageException extends BaseException {
2021
2027
  static notFound(bundleHash: string): SecretStorageException;
2022
2028
  static decryptionFailed(reason?: string): SecretStorageException;
2023
2029
  static unavailable(provider: string, reason?: string): SecretStorageException;
2030
+ static validationError(message: string): SecretStorageException;
2024
2031
  }
2025
2032
 
2026
2033
  declare class InvalidResponseException extends BaseException {
@@ -2137,18 +2144,19 @@ declare const EXCEPTION_CODES: {
2137
2144
  declare class MemorySecretStorageProvider implements ISecretStorageProvider {
2138
2145
  readonly providerType = "memory";
2139
2146
  private secrets;
2147
+ private recoverySecrets;
2140
2148
  isHardwareBacked(): boolean;
2141
2149
  isAvailable(): Promise<boolean>;
2142
- storeSecret(bundleHash: string, secret: string, options?: {
2143
- label?: string;
2144
- passphrase?: string;
2145
- }): Promise<void>;
2150
+ storeSecret(bundleHash: string, secret: string, options?: StorageOptions): Promise<void>;
2146
2151
  retrieveSecret(bundleHash: string): Promise<string | null>;
2147
2152
  deleteSecret(bundleHash: string): Promise<boolean>;
2148
2153
  hasSecret(bundleHash: string): Promise<boolean>;
2149
2154
  listSecrets(): Promise<SecretStorageMetadata[]>;
2150
2155
  withSecret<T>(bundleHash: string, fn: (secret: string) => Promise<T> | T): Promise<T>;
2151
2156
  clear(): void;
2157
+ recoverSecret(bundleHash: string, recoveryPassphrase: string, options?: {
2158
+ label?: string;
2159
+ }): Promise<void>;
2152
2160
  }
2153
2161
 
2154
2162
  interface IStorageBackend {
@@ -2168,35 +2176,161 @@ declare class WebCryptoSecretStorageProvider implements ISecretStorageProvider {
2168
2176
  readonly providerType = "webcrypto-aes-gcm";
2169
2177
  private backend;
2170
2178
  private defaultPassphrase?;
2171
- private hardwareBacked;
2172
2179
  constructor(options?: {
2173
2180
  backend?: IStorageBackend;
2174
2181
  defaultPassphrase?: string;
2175
- hardwareBacked?: boolean;
2176
2182
  });
2177
2183
  isHardwareBacked(): boolean;
2178
2184
  isAvailable(): Promise<boolean>;
2179
- private deriveKey;
2180
- storeSecret(bundleHash: string, secret: string, options?: {
2185
+ storeSecret(bundleHash: string, secret: string, options?: StorageOptions): Promise<void>;
2186
+ retrieveSecret(bundleHash: string, options?: {
2187
+ passphrase?: string;
2188
+ }): Promise<string | null>;
2189
+ deleteSecret(bundleHash: string): Promise<boolean>;
2190
+ hasSecret(bundleHash: string): Promise<boolean>;
2191
+ listSecrets(): Promise<SecretStorageMetadata[]>;
2192
+ withSecret<T>(bundleHash: string, fn: (secret: string) => Promise<T> | T, options?: {
2193
+ passphrase?: string;
2194
+ }): Promise<T>;
2195
+ recoverSecret(bundleHash: string, recoveryPassphrase: string, options?: {
2181
2196
  label?: string;
2182
2197
  passphrase?: string;
2183
2198
  }): Promise<void>;
2199
+ }
2200
+
2201
+ declare class FileStorageBackend implements IStorageBackend {
2202
+ readonly filePath: string;
2203
+ private store;
2204
+ private loaded;
2205
+ constructor(filePath: string);
2206
+ private getFs;
2207
+ private ensureLoaded;
2208
+ private persist;
2209
+ getItem(key: string): Promise<string | null>;
2210
+ setItem(key: string, value: string): Promise<void>;
2211
+ removeItem(key: string): Promise<boolean>;
2212
+ keys(): Promise<string[]>;
2213
+ }
2214
+
2215
+ declare class WebStorageBackend implements IStorageBackend {
2216
+ private readonly storage;
2217
+ readonly prefix: string;
2218
+ constructor(storage?: Storage, prefix?: string);
2219
+ getItem(key: string): string | null;
2220
+ setItem(key: string, value: string): void;
2221
+ removeItem(key: string): boolean;
2222
+ keys(): string[];
2223
+ }
2224
+
2225
+ interface WebAuthnPrfSecretStorageOptions {
2226
+ backend: IStorageBackend;
2227
+ rp: {
2228
+ id?: string;
2229
+ name: string;
2230
+ };
2231
+ user: {
2232
+ id: Uint8Array;
2233
+ name: string;
2234
+ displayName: string;
2235
+ };
2236
+ credentials?: Pick<CredentialsContainer, 'create' | 'get'>;
2237
+ alias?: string;
2238
+ }
2239
+ declare class WebAuthnPrfSecretStorageProvider implements ISecretStorageProvider {
2240
+ readonly providerType = "webauthn-prf";
2241
+ private backend;
2242
+ private rp;
2243
+ private user;
2244
+ private credentialsContainer?;
2245
+ private alias;
2246
+ private cachedPassphrase?;
2247
+ constructor(options: WebAuthnPrfSecretStorageOptions);
2248
+ private get credentials();
2249
+ private get recordKey();
2250
+ isHardwareBacked(): boolean;
2251
+ isAvailable(): Promise<boolean>;
2252
+ enroll(): Promise<void>;
2253
+ private unlock;
2254
+ lock(): void;
2255
+ unenroll(): Promise<void>;
2256
+ storeSecret(bundleHash: string, secret: string, options?: StorageOptions): Promise<void>;
2184
2257
  retrieveSecret(bundleHash: string, options?: {
2185
2258
  passphrase?: string;
2186
2259
  }): Promise<string | null>;
2260
+ withSecret<T>(bundleHash: string, fn: (secret: string) => Promise<T> | T, options?: {
2261
+ passphrase?: string;
2262
+ }): Promise<T>;
2187
2263
  deleteSecret(bundleHash: string): Promise<boolean>;
2188
2264
  hasSecret(bundleHash: string): Promise<boolean>;
2189
2265
  listSecrets(): Promise<SecretStorageMetadata[]>;
2266
+ recoverSecret(bundleHash: string, recoveryPassphrase: string, options?: {
2267
+ label?: string;
2268
+ }): Promise<void>;
2269
+ }
2270
+
2271
+ interface IKeyStore {
2272
+ get(name: string): Promise<CryptoKey | undefined>;
2273
+ put(name: string, key: CryptoKey): Promise<void>;
2274
+ delete(name: string): Promise<boolean>;
2275
+ }
2276
+ declare class MemoryKeyStore implements IKeyStore {
2277
+ private keys;
2278
+ get(name: string): Promise<CryptoKey | undefined>;
2279
+ put(name: string, key: CryptoKey): Promise<void>;
2280
+ delete(name: string): Promise<boolean>;
2281
+ }
2282
+ declare class IndexedDbKeyStore implements IKeyStore {
2283
+ private dbName;
2284
+ private storeName;
2285
+ constructor(dbName?: string);
2286
+ private getDb;
2287
+ get(name: string): Promise<CryptoKey | undefined>;
2288
+ put(name: string, key: CryptoKey): Promise<void>;
2289
+ delete(name: string): Promise<boolean>;
2290
+ }
2291
+ interface NonExtractableKeyStorageOptions {
2292
+ backend: IStorageBackend;
2293
+ keyStore?: IKeyStore;
2294
+ alias?: string;
2295
+ }
2296
+ declare class NonExtractableKeySecretStorageProvider implements ISecretStorageProvider {
2297
+ readonly providerType = "webcrypto-nonextractable";
2298
+ private backend;
2299
+ private keyStore;
2300
+ private alias;
2301
+ private cachedPassphrase?;
2302
+ constructor(options: NonExtractableKeyStorageOptions);
2303
+ private get recordKey();
2304
+ private get kekStoreKey();
2305
+ isHardwareBacked(): boolean;
2306
+ isAvailable(): Promise<boolean>;
2307
+ private unlock;
2308
+ lock(): void;
2309
+ unenroll(): Promise<void>;
2310
+ storeSecret(bundleHash: string, secret: string, options?: StorageOptions): Promise<void>;
2311
+ retrieveSecret(bundleHash: string, options?: {
2312
+ passphrase?: string;
2313
+ }): Promise<string | null>;
2190
2314
  withSecret<T>(bundleHash: string, fn: (secret: string) => Promise<T> | T, options?: {
2191
2315
  passphrase?: string;
2192
2316
  }): Promise<T>;
2317
+ deleteSecret(bundleHash: string): Promise<boolean>;
2318
+ hasSecret(bundleHash: string): Promise<boolean>;
2319
+ listSecrets(): Promise<SecretStorageMetadata[]>;
2320
+ recoverSecret(bundleHash: string, recoveryPassphrase: string, options?: {
2321
+ label?: string;
2322
+ }): Promise<void>;
2193
2323
  }
2194
2324
 
2325
+ declare const SECRET_KEY_PREFIX = "knishio:secret:";
2326
+ declare const RECOVERY_KEY_PREFIX = "knishio:recovery:";
2327
+ declare function sealEnvelope(secret: string, passphrase: string, metadata: SecretStorageMetadata): Promise<EncryptedSecretPayload>;
2328
+ declare function openEnvelope(payload: EncryptedSecretPayload, passphrase: string): Promise<Uint8Array>;
2329
+
2195
2330
  interface CreateSecretStorageOptions {
2196
2331
  type?: 'webcrypto' | 'memory';
2197
2332
  defaultPassphrase?: string;
2198
2333
  backend?: IStorageBackend;
2199
- hardwareBacked?: boolean;
2200
2334
  }
2201
2335
  declare function createDefaultSecretStorage(options?: CreateSecretStorageOptions): ISecretStorageProvider;
2202
2336
 
@@ -2205,12 +2339,12 @@ declare function withSecureBytes<T>(bytes: Uint8Array, fn: (bytes: Uint8Array) =
2205
2339
  declare function withSecureString<T>(secret: string, fn: (cleanSecret: string) => Promise<T> | T): Promise<T>;
2206
2340
  declare function constantTimeCompare(a: Uint8Array | string, b: Uint8Array | string): boolean;
2207
2341
 
2208
- declare const SDK_VERSION = "1.0.0";
2342
+ declare const SDK_VERSION = "1.2.0";
2209
2343
  declare const SDK_NAME = "KnishIO-Client-TS";
2210
2344
  declare const COMPATIBLE_SERVER_VERSIONS: number[];
2211
2345
  declare const SDK_INFO: {
2212
2346
  readonly name: "KnishIO-Client-TS";
2213
- readonly version: "1.0.0";
2347
+ readonly version: "1.2.0";
2214
2348
  readonly description: "TypeScript SDK for Knish.IO post-blockchain distributed ledger";
2215
2349
  readonly compatibleServerVersions: number[];
2216
2350
  readonly features: readonly ["Post-quantum cryptography (XMSS, ML-KEM-1024)", "Cross-platform compatibility", "Type-safe APIs", "DAG-based transaction processing", "GraphQL integration", "Real-time subscriptions", "Cellular architecture support"];
@@ -2238,7 +2372,7 @@ declare const DevUtils: {
2238
2372
  nodeVersion: string;
2239
2373
  environment: string;
2240
2374
  name: "KnishIO-Client-TS";
2241
- version: "1.0.0";
2375
+ version: "1.2.0";
2242
2376
  description: "TypeScript SDK for Knish.IO post-blockchain distributed ledger";
2243
2377
  compatibleServerVersions: number[];
2244
2378
  features: readonly ["Post-quantum cryptography (XMSS, ML-KEM-1024)", "Cross-platform compatibility", "Type-safe APIs", "DAG-based transaction processing", "GraphQL integration", "Real-time subscriptions", "Cellular architecture support"];
@@ -2265,7 +2399,7 @@ declare const KnishIO: {
2265
2399
  SDK_VERSION: string;
2266
2400
  SDK_INFO: {
2267
2401
  readonly name: "KnishIO-Client-TS";
2268
- readonly version: "1.0.0";
2402
+ readonly version: "1.2.0";
2269
2403
  readonly description: "TypeScript SDK for Knish.IO post-blockchain distributed ledger";
2270
2404
  readonly compatibleServerVersions: number[];
2271
2405
  readonly features: readonly ["Post-quantum cryptography (XMSS, ML-KEM-1024)", "Cross-platform compatibility", "Type-safe APIs", "DAG-based transaction processing", "GraphQL integration", "Real-time subscriptions", "Cellular architecture support"];
@@ -2278,4 +2412,4 @@ declare const KnishIO: {
2278
2412
  };
2279
2413
  };
2280
2414
 
2281
- 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 };
2415
+ 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, FileStorageBackend, GraphQLClient, type GraphQLError, type GraphQLRequest, type GraphQLResponse, type HexString, type IKeyStore, type ISecretStorageProvider, type IStorageBackend, IndexedDbKeyStore, InvalidResponseException, type KeyGenerationOptions, KnishIO, KnishIOClient, type KnishIOClientConfig, MemoryKeyStore, 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, NonExtractableKeySecretStorageProvider, type NonExtractableKeyStorageOptions, PolicyMeta, type Position, type PositionGenerationOptions, Query, QueryAtom, QueryBalance, QueryBatch, QueryContinuId, QueryEmbeddingStatus, QueryMetaType, QueryMetaTypeViaAtom, type QueryOperation, QueryWalletBundle, QueryWalletList, RECOVERY_KEY_PREFIX, 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, SECRET_KEY_PREFIX, type SHAKE256Options, type SecretGenerationOptions, SecretStorageException, type SecretStorageMetadata, SignatureMismatchException, type SignatureOptions, type StorageOptions, type TokenSlug, TokenUnit, TransferBalanceException, type TransferParams, type ValidationResult$1 as ValidationResult, type VerificationOptions, Wallet, type WalletAddress, WalletCredentialException, type WalletParams, type WalletQueryParams, type WebAuthnPrfSecretStorageOptions, WebAuthnPrfSecretStorageProvider, WebCryptoSecretStorageProvider, WebStorageBackend, 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, openEnvelope, randomString, runCompatibilityTests, runExtendedCompatibilityTests, sealEnvelope, shake256, toCamelCase, toSnakeCase, truncate, validateBundleHash, validateMolecularHashForSignature, validateOTSSignature, validatePosition, validateSecret, validateWalletAddress, verifyOTSSignature, withSecureBytes, withSecureString, zeroizeBytes };
package/dist/index.d.ts CHANGED
@@ -141,14 +141,17 @@ interface EncryptedSecretPayload {
141
141
  iterations?: number;
142
142
  metadata: SecretStorageMetadata;
143
143
  }
144
+ interface StorageOptions {
145
+ label?: string;
146
+ passphrase?: string;
147
+ recoveryPassphrase?: string;
148
+ allowUnrecoverable?: boolean;
149
+ }
144
150
  interface ISecretStorageProvider {
145
151
  readonly providerType: string;
146
152
  isHardwareBacked(): boolean;
147
153
  isAvailable(): Promise<boolean>;
148
- storeSecret(bundleHash: string, secret: string, options?: {
149
- label?: string;
150
- passphrase?: string;
151
- }): Promise<void>;
154
+ storeSecret(bundleHash: string, secret: string, options?: StorageOptions): Promise<void>;
152
155
  retrieveSecret(bundleHash: string, options?: {
153
156
  passphrase?: string;
154
157
  }): Promise<string | null>;
@@ -158,6 +161,9 @@ interface ISecretStorageProvider {
158
161
  withSecret<T>(bundleHash: string, fn: (secret: string) => Promise<T> | T, options?: {
159
162
  passphrase?: string;
160
163
  }): Promise<T>;
164
+ recoverSecret(bundleHash: string, recoveryPassphrase: string, options?: {
165
+ label?: string;
166
+ }): Promise<void>;
161
167
  }
162
168
 
163
169
  type WalletAddress = WalletAddressPattern & {
@@ -2021,6 +2027,7 @@ declare class SecretStorageException extends BaseException {
2021
2027
  static notFound(bundleHash: string): SecretStorageException;
2022
2028
  static decryptionFailed(reason?: string): SecretStorageException;
2023
2029
  static unavailable(provider: string, reason?: string): SecretStorageException;
2030
+ static validationError(message: string): SecretStorageException;
2024
2031
  }
2025
2032
 
2026
2033
  declare class InvalidResponseException extends BaseException {
@@ -2137,18 +2144,19 @@ declare const EXCEPTION_CODES: {
2137
2144
  declare class MemorySecretStorageProvider implements ISecretStorageProvider {
2138
2145
  readonly providerType = "memory";
2139
2146
  private secrets;
2147
+ private recoverySecrets;
2140
2148
  isHardwareBacked(): boolean;
2141
2149
  isAvailable(): Promise<boolean>;
2142
- storeSecret(bundleHash: string, secret: string, options?: {
2143
- label?: string;
2144
- passphrase?: string;
2145
- }): Promise<void>;
2150
+ storeSecret(bundleHash: string, secret: string, options?: StorageOptions): Promise<void>;
2146
2151
  retrieveSecret(bundleHash: string): Promise<string | null>;
2147
2152
  deleteSecret(bundleHash: string): Promise<boolean>;
2148
2153
  hasSecret(bundleHash: string): Promise<boolean>;
2149
2154
  listSecrets(): Promise<SecretStorageMetadata[]>;
2150
2155
  withSecret<T>(bundleHash: string, fn: (secret: string) => Promise<T> | T): Promise<T>;
2151
2156
  clear(): void;
2157
+ recoverSecret(bundleHash: string, recoveryPassphrase: string, options?: {
2158
+ label?: string;
2159
+ }): Promise<void>;
2152
2160
  }
2153
2161
 
2154
2162
  interface IStorageBackend {
@@ -2168,35 +2176,161 @@ declare class WebCryptoSecretStorageProvider implements ISecretStorageProvider {
2168
2176
  readonly providerType = "webcrypto-aes-gcm";
2169
2177
  private backend;
2170
2178
  private defaultPassphrase?;
2171
- private hardwareBacked;
2172
2179
  constructor(options?: {
2173
2180
  backend?: IStorageBackend;
2174
2181
  defaultPassphrase?: string;
2175
- hardwareBacked?: boolean;
2176
2182
  });
2177
2183
  isHardwareBacked(): boolean;
2178
2184
  isAvailable(): Promise<boolean>;
2179
- private deriveKey;
2180
- storeSecret(bundleHash: string, secret: string, options?: {
2185
+ storeSecret(bundleHash: string, secret: string, options?: StorageOptions): Promise<void>;
2186
+ retrieveSecret(bundleHash: string, options?: {
2187
+ passphrase?: string;
2188
+ }): Promise<string | null>;
2189
+ deleteSecret(bundleHash: string): Promise<boolean>;
2190
+ hasSecret(bundleHash: string): Promise<boolean>;
2191
+ listSecrets(): Promise<SecretStorageMetadata[]>;
2192
+ withSecret<T>(bundleHash: string, fn: (secret: string) => Promise<T> | T, options?: {
2193
+ passphrase?: string;
2194
+ }): Promise<T>;
2195
+ recoverSecret(bundleHash: string, recoveryPassphrase: string, options?: {
2181
2196
  label?: string;
2182
2197
  passphrase?: string;
2183
2198
  }): Promise<void>;
2199
+ }
2200
+
2201
+ declare class FileStorageBackend implements IStorageBackend {
2202
+ readonly filePath: string;
2203
+ private store;
2204
+ private loaded;
2205
+ constructor(filePath: string);
2206
+ private getFs;
2207
+ private ensureLoaded;
2208
+ private persist;
2209
+ getItem(key: string): Promise<string | null>;
2210
+ setItem(key: string, value: string): Promise<void>;
2211
+ removeItem(key: string): Promise<boolean>;
2212
+ keys(): Promise<string[]>;
2213
+ }
2214
+
2215
+ declare class WebStorageBackend implements IStorageBackend {
2216
+ private readonly storage;
2217
+ readonly prefix: string;
2218
+ constructor(storage?: Storage, prefix?: string);
2219
+ getItem(key: string): string | null;
2220
+ setItem(key: string, value: string): void;
2221
+ removeItem(key: string): boolean;
2222
+ keys(): string[];
2223
+ }
2224
+
2225
+ interface WebAuthnPrfSecretStorageOptions {
2226
+ backend: IStorageBackend;
2227
+ rp: {
2228
+ id?: string;
2229
+ name: string;
2230
+ };
2231
+ user: {
2232
+ id: Uint8Array;
2233
+ name: string;
2234
+ displayName: string;
2235
+ };
2236
+ credentials?: Pick<CredentialsContainer, 'create' | 'get'>;
2237
+ alias?: string;
2238
+ }
2239
+ declare class WebAuthnPrfSecretStorageProvider implements ISecretStorageProvider {
2240
+ readonly providerType = "webauthn-prf";
2241
+ private backend;
2242
+ private rp;
2243
+ private user;
2244
+ private credentialsContainer?;
2245
+ private alias;
2246
+ private cachedPassphrase?;
2247
+ constructor(options: WebAuthnPrfSecretStorageOptions);
2248
+ private get credentials();
2249
+ private get recordKey();
2250
+ isHardwareBacked(): boolean;
2251
+ isAvailable(): Promise<boolean>;
2252
+ enroll(): Promise<void>;
2253
+ private unlock;
2254
+ lock(): void;
2255
+ unenroll(): Promise<void>;
2256
+ storeSecret(bundleHash: string, secret: string, options?: StorageOptions): Promise<void>;
2184
2257
  retrieveSecret(bundleHash: string, options?: {
2185
2258
  passphrase?: string;
2186
2259
  }): Promise<string | null>;
2260
+ withSecret<T>(bundleHash: string, fn: (secret: string) => Promise<T> | T, options?: {
2261
+ passphrase?: string;
2262
+ }): Promise<T>;
2187
2263
  deleteSecret(bundleHash: string): Promise<boolean>;
2188
2264
  hasSecret(bundleHash: string): Promise<boolean>;
2189
2265
  listSecrets(): Promise<SecretStorageMetadata[]>;
2266
+ recoverSecret(bundleHash: string, recoveryPassphrase: string, options?: {
2267
+ label?: string;
2268
+ }): Promise<void>;
2269
+ }
2270
+
2271
+ interface IKeyStore {
2272
+ get(name: string): Promise<CryptoKey | undefined>;
2273
+ put(name: string, key: CryptoKey): Promise<void>;
2274
+ delete(name: string): Promise<boolean>;
2275
+ }
2276
+ declare class MemoryKeyStore implements IKeyStore {
2277
+ private keys;
2278
+ get(name: string): Promise<CryptoKey | undefined>;
2279
+ put(name: string, key: CryptoKey): Promise<void>;
2280
+ delete(name: string): Promise<boolean>;
2281
+ }
2282
+ declare class IndexedDbKeyStore implements IKeyStore {
2283
+ private dbName;
2284
+ private storeName;
2285
+ constructor(dbName?: string);
2286
+ private getDb;
2287
+ get(name: string): Promise<CryptoKey | undefined>;
2288
+ put(name: string, key: CryptoKey): Promise<void>;
2289
+ delete(name: string): Promise<boolean>;
2290
+ }
2291
+ interface NonExtractableKeyStorageOptions {
2292
+ backend: IStorageBackend;
2293
+ keyStore?: IKeyStore;
2294
+ alias?: string;
2295
+ }
2296
+ declare class NonExtractableKeySecretStorageProvider implements ISecretStorageProvider {
2297
+ readonly providerType = "webcrypto-nonextractable";
2298
+ private backend;
2299
+ private keyStore;
2300
+ private alias;
2301
+ private cachedPassphrase?;
2302
+ constructor(options: NonExtractableKeyStorageOptions);
2303
+ private get recordKey();
2304
+ private get kekStoreKey();
2305
+ isHardwareBacked(): boolean;
2306
+ isAvailable(): Promise<boolean>;
2307
+ private unlock;
2308
+ lock(): void;
2309
+ unenroll(): Promise<void>;
2310
+ storeSecret(bundleHash: string, secret: string, options?: StorageOptions): Promise<void>;
2311
+ retrieveSecret(bundleHash: string, options?: {
2312
+ passphrase?: string;
2313
+ }): Promise<string | null>;
2190
2314
  withSecret<T>(bundleHash: string, fn: (secret: string) => Promise<T> | T, options?: {
2191
2315
  passphrase?: string;
2192
2316
  }): Promise<T>;
2317
+ deleteSecret(bundleHash: string): Promise<boolean>;
2318
+ hasSecret(bundleHash: string): Promise<boolean>;
2319
+ listSecrets(): Promise<SecretStorageMetadata[]>;
2320
+ recoverSecret(bundleHash: string, recoveryPassphrase: string, options?: {
2321
+ label?: string;
2322
+ }): Promise<void>;
2193
2323
  }
2194
2324
 
2325
+ declare const SECRET_KEY_PREFIX = "knishio:secret:";
2326
+ declare const RECOVERY_KEY_PREFIX = "knishio:recovery:";
2327
+ declare function sealEnvelope(secret: string, passphrase: string, metadata: SecretStorageMetadata): Promise<EncryptedSecretPayload>;
2328
+ declare function openEnvelope(payload: EncryptedSecretPayload, passphrase: string): Promise<Uint8Array>;
2329
+
2195
2330
  interface CreateSecretStorageOptions {
2196
2331
  type?: 'webcrypto' | 'memory';
2197
2332
  defaultPassphrase?: string;
2198
2333
  backend?: IStorageBackend;
2199
- hardwareBacked?: boolean;
2200
2334
  }
2201
2335
  declare function createDefaultSecretStorage(options?: CreateSecretStorageOptions): ISecretStorageProvider;
2202
2336
 
@@ -2205,12 +2339,12 @@ declare function withSecureBytes<T>(bytes: Uint8Array, fn: (bytes: Uint8Array) =
2205
2339
  declare function withSecureString<T>(secret: string, fn: (cleanSecret: string) => Promise<T> | T): Promise<T>;
2206
2340
  declare function constantTimeCompare(a: Uint8Array | string, b: Uint8Array | string): boolean;
2207
2341
 
2208
- declare const SDK_VERSION = "1.0.0";
2342
+ declare const SDK_VERSION = "1.2.0";
2209
2343
  declare const SDK_NAME = "KnishIO-Client-TS";
2210
2344
  declare const COMPATIBLE_SERVER_VERSIONS: number[];
2211
2345
  declare const SDK_INFO: {
2212
2346
  readonly name: "KnishIO-Client-TS";
2213
- readonly version: "1.0.0";
2347
+ readonly version: "1.2.0";
2214
2348
  readonly description: "TypeScript SDK for Knish.IO post-blockchain distributed ledger";
2215
2349
  readonly compatibleServerVersions: number[];
2216
2350
  readonly features: readonly ["Post-quantum cryptography (XMSS, ML-KEM-1024)", "Cross-platform compatibility", "Type-safe APIs", "DAG-based transaction processing", "GraphQL integration", "Real-time subscriptions", "Cellular architecture support"];
@@ -2238,7 +2372,7 @@ declare const DevUtils: {
2238
2372
  nodeVersion: string;
2239
2373
  environment: string;
2240
2374
  name: "KnishIO-Client-TS";
2241
- version: "1.0.0";
2375
+ version: "1.2.0";
2242
2376
  description: "TypeScript SDK for Knish.IO post-blockchain distributed ledger";
2243
2377
  compatibleServerVersions: number[];
2244
2378
  features: readonly ["Post-quantum cryptography (XMSS, ML-KEM-1024)", "Cross-platform compatibility", "Type-safe APIs", "DAG-based transaction processing", "GraphQL integration", "Real-time subscriptions", "Cellular architecture support"];
@@ -2265,7 +2399,7 @@ declare const KnishIO: {
2265
2399
  SDK_VERSION: string;
2266
2400
  SDK_INFO: {
2267
2401
  readonly name: "KnishIO-Client-TS";
2268
- readonly version: "1.0.0";
2402
+ readonly version: "1.2.0";
2269
2403
  readonly description: "TypeScript SDK for Knish.IO post-blockchain distributed ledger";
2270
2404
  readonly compatibleServerVersions: number[];
2271
2405
  readonly features: readonly ["Post-quantum cryptography (XMSS, ML-KEM-1024)", "Cross-platform compatibility", "Type-safe APIs", "DAG-based transaction processing", "GraphQL integration", "Real-time subscriptions", "Cellular architecture support"];
@@ -2278,4 +2412,4 @@ declare const KnishIO: {
2278
2412
  };
2279
2413
  };
2280
2414
 
2281
- 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 };
2415
+ 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, FileStorageBackend, GraphQLClient, type GraphQLError, type GraphQLRequest, type GraphQLResponse, type HexString, type IKeyStore, type ISecretStorageProvider, type IStorageBackend, IndexedDbKeyStore, InvalidResponseException, type KeyGenerationOptions, KnishIO, KnishIOClient, type KnishIOClientConfig, MemoryKeyStore, 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, NonExtractableKeySecretStorageProvider, type NonExtractableKeyStorageOptions, PolicyMeta, type Position, type PositionGenerationOptions, Query, QueryAtom, QueryBalance, QueryBatch, QueryContinuId, QueryEmbeddingStatus, QueryMetaType, QueryMetaTypeViaAtom, type QueryOperation, QueryWalletBundle, QueryWalletList, RECOVERY_KEY_PREFIX, 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, SECRET_KEY_PREFIX, type SHAKE256Options, type SecretGenerationOptions, SecretStorageException, type SecretStorageMetadata, SignatureMismatchException, type SignatureOptions, type StorageOptions, type TokenSlug, TokenUnit, TransferBalanceException, type TransferParams, type ValidationResult$1 as ValidationResult, type VerificationOptions, Wallet, type WalletAddress, WalletCredentialException, type WalletParams, type WalletQueryParams, type WebAuthnPrfSecretStorageOptions, WebAuthnPrfSecretStorageProvider, WebCryptoSecretStorageProvider, WebStorageBackend, 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, openEnvelope, randomString, runCompatibilityTests, runExtendedCompatibilityTests, sealEnvelope, shake256, toCamelCase, toSnakeCase, truncate, validateBundleHash, validateMolecularHashForSignature, validateOTSSignature, validatePosition, validateSecret, validateWalletAddress, verifyOTSSignature, withSecureBytes, withSecureString, zeroizeBytes };