wative-core 1.2.2 → 2.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.
Files changed (62) hide show
  1. package/CHANGELOG.md +136 -0
  2. package/LICENSE +55 -0
  3. package/README.md +496 -0
  4. package/dist/artifacts/evm/index.cjs +1 -0
  5. package/dist/artifacts/evm/index.d.cts +6 -0
  6. package/dist/artifacts/evm/index.d.ts +6 -0
  7. package/dist/artifacts/evm/index.js +1 -0
  8. package/dist/artifacts/svm/index.cjs +1 -0
  9. package/dist/artifacts/svm/index.d.cts +9 -0
  10. package/dist/artifacts/svm/index.d.ts +9 -0
  11. package/dist/artifacts/svm/index.js +1 -0
  12. package/dist/container-provider-C59yqd5Z.d.ts +48 -0
  13. package/dist/container-provider-i614LDE1.d.cts +48 -0
  14. package/dist/evm-BLml33LX.d.cts +34 -0
  15. package/dist/evm-DTzqGlL6.d.ts +34 -0
  16. package/dist/file-sink-B73MuigK.d.cts +44 -0
  17. package/dist/file-sink-LS4hyXXi.d.ts +44 -0
  18. package/dist/index.cjs +1 -0
  19. package/dist/index.d.cts +194 -0
  20. package/dist/index.d.ts +194 -0
  21. package/dist/index.js +1 -0
  22. package/dist/index.node.cjs +1 -0
  23. package/dist/index.node.d.cts +6 -0
  24. package/dist/index.node.d.ts +6 -0
  25. package/dist/index.node.js +1 -0
  26. package/dist/node/index.cjs +1 -0
  27. package/dist/node/index.d.cts +7 -0
  28. package/dist/node/index.d.ts +7 -0
  29. package/dist/node/index.js +1 -0
  30. package/dist/svm-CCzqNAWM.d.cts +59 -0
  31. package/dist/svm-DieFbh9k.d.ts +59 -0
  32. package/dist/workspace-CamTHxso.d.cts +737 -0
  33. package/dist/workspace-CamTHxso.d.ts +737 -0
  34. package/package.json +85 -39
  35. package/tests/01-quick-start.test.cjs +37 -0
  36. package/tests/02-hd-account.test.cjs +71 -0
  37. package/tests/03-pk-account.test.cjs +59 -0
  38. package/tests/04-network-management.test.cjs +94 -0
  39. package/tests/05-asset-management.test.cjs +117 -0
  40. package/tests/06-address-signing.test.cjs +55 -0
  41. package/tests/07-custom-provider.test.cjs +164 -0
  42. package/tests/08-persistence.test.cjs +105 -0
  43. package/tests/09-workspace-filter.test.cjs +84 -0
  44. package/tests/10-default-network.test.cjs +70 -0
  45. package/tests/11-subpath-imports.test.cjs +21 -0
  46. package/tests/12-logger.test.cjs +44 -0
  47. package/tests/13-workspace-config.test.cjs +43 -0
  48. package/tests/14-esm-runtime.test.mjs +81 -0
  49. package/tests/15-package-resolution.test.cjs +76 -0
  50. package/tests/16-known-answer-vectors.test.cjs +141 -0
  51. package/tests/17-locked-state.test.cjs +162 -0
  52. package/tests/README.md +72 -0
  53. package/lib/account.d.ts +0 -69
  54. package/lib/index.d.ts +0 -6
  55. package/lib/index.esm.js +0 -1
  56. package/lib/index.umd.js +0 -1
  57. package/lib/mnemonic.d.ts +0 -3
  58. package/lib/utils.d.ts +0 -21
  59. package/src/account.ts +0 -749
  60. package/src/index.ts +0 -11
  61. package/src/mnemonic.ts +0 -2084
  62. package/src/utils.ts +0 -132
@@ -0,0 +1,194 @@
1
+ import { P as Provider, w as RecordType, z as Slug, R as Record$1, i as ChainVM } from './workspace-CamTHxso.cjs';
2
+ export { A as Account, a as AccountCollection, b as AccountOrgType, c as Address, d as Asset, e as AssetBalance, f as AssetCollection, g as AssetId, h as AssetInitObject, C as ChainId, j as ConsoleSink, E as EvmAddress, k as EvmRawTx, l as EvmTransaction, m as EvmTxBuildParams, n as EvmTxType, L as LogLevel, o as LogRecord, p as LogSink, q as Logger, r as LoggerConfig, N as Network, s as NetworkCollection, t as NetworkInit, u as NetworkLike, v as RecordInit, S as Settling, x as SimulationResult, y as SinkConfig, B as SvmAddress, D as SvmTransaction, F as SvmTxBuildParams, T as Transaction, G as TransactionReceipt, H as TransactionStateChange, I as TransactionStatus, J as TransactionTracker, W as Wallet, K as WalletCollection, M as WativeError, O as WativeErrorCode, Q as WativeErrorOpts, U as Workspace, V as WorkspaceConfig, X as newMnemonic } from './workspace-CamTHxso.cjs';
3
+ import { a as ContainerProvider } from './container-provider-i614LDE1.cjs';
4
+ export { C as ContainerEntry } from './container-provider-i614LDE1.cjs';
5
+ export { C as Contract } from './evm-BLml33LX.cjs';
6
+ export { P as Program, S as SvmInstruction } from './svm-CCzqNAWM.cjs';
7
+
8
+ type StorageDurability = "persistent" | "best-effort";
9
+ interface IdbProviderOptions {
10
+
11
+ readonly acknowledgeEvictionRisk?: boolean;
12
+
13
+ readonly indexedDB?: IDBFactory;
14
+
15
+ readonly storageManager?: Pick<StorageManager, "persist" | "persisted" | "estimate"> | null;
16
+ }
17
+ interface StorageQuota {
18
+ readonly usage?: number;
19
+ readonly quota?: number;
20
+ }
21
+ declare class IdbProvider extends ContainerProvider {
22
+ #private;
23
+ readonly databaseName: string;
24
+
25
+ readonly durability: StorageDurability;
26
+
27
+ readonly quota: StorageQuota;
28
+ private constructor();
29
+
30
+ static create(databaseName: string, opts?: IdbProviderOptions): Promise<IdbProvider>;
31
+
32
+ initialize(): Promise<void>;
33
+
34
+ protected _exist(key: string): Promise<boolean>;
35
+
36
+ protected _listItems(key: string): Promise<string[]>;
37
+ protected _read(key: string): Promise<Uint8Array>;
38
+
39
+ protected _write(key: string, data: Uint8Array): Promise<void>;
40
+ protected _remove(key: string): Promise<void>;
41
+
42
+ protected _ensureDir(_key: string): Promise<void>;
43
+ close(): Promise<void>;
44
+
45
+ static destroy(databaseName: string, opts?: Pick<IdbProviderOptions, "indexedDB">): Promise<void>;
46
+ }
47
+
48
+ declare class FileProvider extends Provider {
49
+ constructor(rootPath: string);
50
+ protected _exist(_path: string): boolean;
51
+ protected _listItems(_path: string): string[];
52
+ protected _read(_path: string): Uint8Array;
53
+ protected _write(_path: string, _data: Uint8Array): void;
54
+ protected _remove(_path: string): void;
55
+ protected _ensureDir(_path: string): void;
56
+ unlockContainer(_password: string): Promise<boolean>;
57
+ lockContainer(): Promise<void>;
58
+ isContainerUnlocked(): boolean;
59
+ loadRecord<T>(_type: RecordType, _slug?: Slug): Promise<Record$1<T>>;
60
+ loadRecords<T>(_type: RecordType): Promise<ReadonlyArray<Record$1<T>>>;
61
+ writeRecord<T>(_type: RecordType, _slug: Slug, _value: T): Promise<void>;
62
+ dropRecord(_type: RecordType, _slug: Slug): Promise<void>;
63
+ close(): Promise<void>;
64
+
65
+ static probe(_rootPath: string): boolean;
66
+ }
67
+
68
+ declare class DbProvider extends Provider {
69
+ constructor(connectionString: string);
70
+ protected _exist(_path: string): boolean | Promise<boolean>;
71
+ protected _listItems(_path: string): string[] | Promise<string[]>;
72
+ protected _read(_path: string): Uint8Array | Promise<Uint8Array>;
73
+ protected _write(_path: string, _data: Uint8Array): void | Promise<void>;
74
+ protected _remove(_path: string): void | Promise<void>;
75
+ protected _ensureDir(_path: string): void | Promise<void>;
76
+ unlockContainer(_password: string): Promise<boolean>;
77
+ lockContainer(): Promise<void>;
78
+ isContainerUnlocked(): boolean;
79
+ loadRecord<T>(_type: RecordType, _slug?: Slug): Promise<Record$1<T>>;
80
+ loadRecords<T>(_type: RecordType): Promise<ReadonlyArray<Record$1<T>>>;
81
+ writeRecord<T>(_type: RecordType, _slug: Slug, _value: T): Promise<void>;
82
+ dropRecord(_type: RecordType, _slug: Slug): Promise<void>;
83
+ close(): Promise<void>;
84
+ }
85
+
86
+ declare abstract class Cipher {
87
+ readonly id: string;
88
+ protected constructor(id: string);
89
+
90
+ abstract encrypt(input: Uint8Array, secret: Uint8Array): Uint8Array;
91
+
92
+ abstract decrypt(input: Uint8Array, secret: Uint8Array): Uint8Array;
93
+ }
94
+
95
+ interface AesGcmCipherOptions {
96
+ ivLength?: number;
97
+ tagLength?: number;
98
+ }
99
+ declare class AesGcmCipher extends Cipher {
100
+ #private;
101
+ constructor(opts?: AesGcmCipherOptions);
102
+ encrypt(plaintext: Uint8Array, key: Uint8Array): Uint8Array;
103
+ decrypt(blob: Uint8Array, key: Uint8Array): Uint8Array;
104
+ }
105
+
106
+ interface Argon2KdfOptions {
107
+
108
+ time?: number;
109
+
110
+ memory?: number;
111
+
112
+ parallelism?: number;
113
+
114
+ hashLength?: number;
115
+ }
116
+
117
+ declare class Argon2Kdf extends Cipher {
118
+ #private;
119
+ constructor(opts?: Argon2KdfOptions);
120
+
121
+ encrypt(password: Uint8Array, salt: Uint8Array): Uint8Array;
122
+
123
+ decrypt(_input: Uint8Array, _secret: Uint8Array): never;
124
+ }
125
+
126
+ type PasswordWeaknessCode = "TOO_SHORT" | "NO_UPPERCASE" | "NO_LOWERCASE" | "NO_DIGIT" | "NO_SYMBOL" | "REPEATED_CHARS" | "SEQUENTIAL_CHARS" | "USERNAME_SUBSTRING" | "FORBIDDEN_WORD" | "REUSED_FROM_HISTORY" | "LEADING_TRAILING_WHITESPACE" | "MIXED_UNICODE_NORMALIZATION" | "INVISIBLE_CHARACTERS";
127
+ interface PasswordWeakness {
128
+ readonly code: PasswordWeaknessCode;
129
+ readonly severity: "critical" | "warning" | "info";
130
+ readonly message: string;
131
+ readonly fix?: string;
132
+ }
133
+
134
+ declare const PasswordScore: {
135
+ readonly VeryWeak: 0;
136
+ readonly Weak: 1;
137
+ readonly Fair: 2;
138
+ readonly Strong: 3;
139
+ readonly VeryStrong: 4;
140
+ };
141
+ type PasswordScore = typeof PasswordScore[keyof typeof PasswordScore];
142
+ interface PasswordCheckResult {
143
+ readonly score: PasswordScore;
144
+ readonly entropyBits: number;
145
+ readonly weaknesses: ReadonlyArray<PasswordWeakness>;
146
+ readonly passable: boolean;
147
+ readonly summary: string;
148
+ }
149
+ interface PasswordPolicyOptions {
150
+ minScore?: PasswordScore;
151
+ minLength?: number;
152
+ requireUppercase?: boolean;
153
+ requireLowercase?: boolean;
154
+ requireDigit?: boolean;
155
+ requireSymbol?: boolean;
156
+ forbiddenWords?: string[];
157
+ }
158
+ interface PasswordCheckContext {
159
+ username?: string;
160
+ history?: string[];
161
+ }
162
+ declare class PasswordPolicy {
163
+ #private;
164
+ constructor(opts?: PasswordPolicyOptions);
165
+ check(password: string, context?: PasswordCheckContext): PasswordCheckResult;
166
+
167
+ enforce(password: string, context?: PasswordCheckContext): void;
168
+ }
169
+
170
+ interface NetworkConfig {
171
+ readonly slug: string;
172
+ readonly name: string;
173
+ readonly chainId: number;
174
+ readonly rpcUrl: string;
175
+ readonly vm: ChainVM;
176
+ readonly nativeCurrency: {
177
+ readonly name: string;
178
+ readonly symbol: string;
179
+ readonly decimals: number;
180
+ };
181
+ }
182
+ declare const BUILTIN_NETWORKS: Record<string, NetworkConfig>;
183
+ interface AssetInit {
184
+ readonly id: number;
185
+ readonly symbol: string;
186
+ readonly name: string;
187
+ readonly decimals: number;
188
+ readonly contractAddress: string | null;
189
+ readonly displayDecimals?: number;
190
+ readonly displayStatus?: boolean;
191
+ }
192
+ declare const BUILTIN_ASSETS: Record<string, ReadonlyArray<AssetInit>>;
193
+
194
+ export { AesGcmCipher, type AesGcmCipherOptions, Argon2Kdf, type Argon2KdfOptions, type AssetInit, BUILTIN_ASSETS, BUILTIN_NETWORKS, ChainVM, Cipher, ContainerProvider, DbProvider, FileProvider, IdbProvider, type IdbProviderOptions, type PasswordCheckResult, PasswordPolicy, type PasswordPolicyOptions, PasswordScore, type PasswordWeakness, type PasswordWeaknessCode, Provider, Record$1 as Record, RecordType, Slug, type StorageDurability, type StorageQuota };
@@ -0,0 +1,194 @@
1
+ import { P as Provider, w as RecordType, z as Slug, R as Record$1, i as ChainVM } from './workspace-CamTHxso.js';
2
+ export { A as Account, a as AccountCollection, b as AccountOrgType, c as Address, d as Asset, e as AssetBalance, f as AssetCollection, g as AssetId, h as AssetInitObject, C as ChainId, j as ConsoleSink, E as EvmAddress, k as EvmRawTx, l as EvmTransaction, m as EvmTxBuildParams, n as EvmTxType, L as LogLevel, o as LogRecord, p as LogSink, q as Logger, r as LoggerConfig, N as Network, s as NetworkCollection, t as NetworkInit, u as NetworkLike, v as RecordInit, S as Settling, x as SimulationResult, y as SinkConfig, B as SvmAddress, D as SvmTransaction, F as SvmTxBuildParams, T as Transaction, G as TransactionReceipt, H as TransactionStateChange, I as TransactionStatus, J as TransactionTracker, W as Wallet, K as WalletCollection, M as WativeError, O as WativeErrorCode, Q as WativeErrorOpts, U as Workspace, V as WorkspaceConfig, X as newMnemonic } from './workspace-CamTHxso.js';
3
+ import { a as ContainerProvider } from './container-provider-C59yqd5Z.js';
4
+ export { C as ContainerEntry } from './container-provider-C59yqd5Z.js';
5
+ export { C as Contract } from './evm-DTzqGlL6.js';
6
+ export { P as Program, S as SvmInstruction } from './svm-DieFbh9k.js';
7
+
8
+ type StorageDurability = "persistent" | "best-effort";
9
+ interface IdbProviderOptions {
10
+
11
+ readonly acknowledgeEvictionRisk?: boolean;
12
+
13
+ readonly indexedDB?: IDBFactory;
14
+
15
+ readonly storageManager?: Pick<StorageManager, "persist" | "persisted" | "estimate"> | null;
16
+ }
17
+ interface StorageQuota {
18
+ readonly usage?: number;
19
+ readonly quota?: number;
20
+ }
21
+ declare class IdbProvider extends ContainerProvider {
22
+ #private;
23
+ readonly databaseName: string;
24
+
25
+ readonly durability: StorageDurability;
26
+
27
+ readonly quota: StorageQuota;
28
+ private constructor();
29
+
30
+ static create(databaseName: string, opts?: IdbProviderOptions): Promise<IdbProvider>;
31
+
32
+ initialize(): Promise<void>;
33
+
34
+ protected _exist(key: string): Promise<boolean>;
35
+
36
+ protected _listItems(key: string): Promise<string[]>;
37
+ protected _read(key: string): Promise<Uint8Array>;
38
+
39
+ protected _write(key: string, data: Uint8Array): Promise<void>;
40
+ protected _remove(key: string): Promise<void>;
41
+
42
+ protected _ensureDir(_key: string): Promise<void>;
43
+ close(): Promise<void>;
44
+
45
+ static destroy(databaseName: string, opts?: Pick<IdbProviderOptions, "indexedDB">): Promise<void>;
46
+ }
47
+
48
+ declare class FileProvider extends Provider {
49
+ constructor(rootPath: string);
50
+ protected _exist(_path: string): boolean;
51
+ protected _listItems(_path: string): string[];
52
+ protected _read(_path: string): Uint8Array;
53
+ protected _write(_path: string, _data: Uint8Array): void;
54
+ protected _remove(_path: string): void;
55
+ protected _ensureDir(_path: string): void;
56
+ unlockContainer(_password: string): Promise<boolean>;
57
+ lockContainer(): Promise<void>;
58
+ isContainerUnlocked(): boolean;
59
+ loadRecord<T>(_type: RecordType, _slug?: Slug): Promise<Record$1<T>>;
60
+ loadRecords<T>(_type: RecordType): Promise<ReadonlyArray<Record$1<T>>>;
61
+ writeRecord<T>(_type: RecordType, _slug: Slug, _value: T): Promise<void>;
62
+ dropRecord(_type: RecordType, _slug: Slug): Promise<void>;
63
+ close(): Promise<void>;
64
+
65
+ static probe(_rootPath: string): boolean;
66
+ }
67
+
68
+ declare class DbProvider extends Provider {
69
+ constructor(connectionString: string);
70
+ protected _exist(_path: string): boolean | Promise<boolean>;
71
+ protected _listItems(_path: string): string[] | Promise<string[]>;
72
+ protected _read(_path: string): Uint8Array | Promise<Uint8Array>;
73
+ protected _write(_path: string, _data: Uint8Array): void | Promise<void>;
74
+ protected _remove(_path: string): void | Promise<void>;
75
+ protected _ensureDir(_path: string): void | Promise<void>;
76
+ unlockContainer(_password: string): Promise<boolean>;
77
+ lockContainer(): Promise<void>;
78
+ isContainerUnlocked(): boolean;
79
+ loadRecord<T>(_type: RecordType, _slug?: Slug): Promise<Record$1<T>>;
80
+ loadRecords<T>(_type: RecordType): Promise<ReadonlyArray<Record$1<T>>>;
81
+ writeRecord<T>(_type: RecordType, _slug: Slug, _value: T): Promise<void>;
82
+ dropRecord(_type: RecordType, _slug: Slug): Promise<void>;
83
+ close(): Promise<void>;
84
+ }
85
+
86
+ declare abstract class Cipher {
87
+ readonly id: string;
88
+ protected constructor(id: string);
89
+
90
+ abstract encrypt(input: Uint8Array, secret: Uint8Array): Uint8Array;
91
+
92
+ abstract decrypt(input: Uint8Array, secret: Uint8Array): Uint8Array;
93
+ }
94
+
95
+ interface AesGcmCipherOptions {
96
+ ivLength?: number;
97
+ tagLength?: number;
98
+ }
99
+ declare class AesGcmCipher extends Cipher {
100
+ #private;
101
+ constructor(opts?: AesGcmCipherOptions);
102
+ encrypt(plaintext: Uint8Array, key: Uint8Array): Uint8Array;
103
+ decrypt(blob: Uint8Array, key: Uint8Array): Uint8Array;
104
+ }
105
+
106
+ interface Argon2KdfOptions {
107
+
108
+ time?: number;
109
+
110
+ memory?: number;
111
+
112
+ parallelism?: number;
113
+
114
+ hashLength?: number;
115
+ }
116
+
117
+ declare class Argon2Kdf extends Cipher {
118
+ #private;
119
+ constructor(opts?: Argon2KdfOptions);
120
+
121
+ encrypt(password: Uint8Array, salt: Uint8Array): Uint8Array;
122
+
123
+ decrypt(_input: Uint8Array, _secret: Uint8Array): never;
124
+ }
125
+
126
+ type PasswordWeaknessCode = "TOO_SHORT" | "NO_UPPERCASE" | "NO_LOWERCASE" | "NO_DIGIT" | "NO_SYMBOL" | "REPEATED_CHARS" | "SEQUENTIAL_CHARS" | "USERNAME_SUBSTRING" | "FORBIDDEN_WORD" | "REUSED_FROM_HISTORY" | "LEADING_TRAILING_WHITESPACE" | "MIXED_UNICODE_NORMALIZATION" | "INVISIBLE_CHARACTERS";
127
+ interface PasswordWeakness {
128
+ readonly code: PasswordWeaknessCode;
129
+ readonly severity: "critical" | "warning" | "info";
130
+ readonly message: string;
131
+ readonly fix?: string;
132
+ }
133
+
134
+ declare const PasswordScore: {
135
+ readonly VeryWeak: 0;
136
+ readonly Weak: 1;
137
+ readonly Fair: 2;
138
+ readonly Strong: 3;
139
+ readonly VeryStrong: 4;
140
+ };
141
+ type PasswordScore = typeof PasswordScore[keyof typeof PasswordScore];
142
+ interface PasswordCheckResult {
143
+ readonly score: PasswordScore;
144
+ readonly entropyBits: number;
145
+ readonly weaknesses: ReadonlyArray<PasswordWeakness>;
146
+ readonly passable: boolean;
147
+ readonly summary: string;
148
+ }
149
+ interface PasswordPolicyOptions {
150
+ minScore?: PasswordScore;
151
+ minLength?: number;
152
+ requireUppercase?: boolean;
153
+ requireLowercase?: boolean;
154
+ requireDigit?: boolean;
155
+ requireSymbol?: boolean;
156
+ forbiddenWords?: string[];
157
+ }
158
+ interface PasswordCheckContext {
159
+ username?: string;
160
+ history?: string[];
161
+ }
162
+ declare class PasswordPolicy {
163
+ #private;
164
+ constructor(opts?: PasswordPolicyOptions);
165
+ check(password: string, context?: PasswordCheckContext): PasswordCheckResult;
166
+
167
+ enforce(password: string, context?: PasswordCheckContext): void;
168
+ }
169
+
170
+ interface NetworkConfig {
171
+ readonly slug: string;
172
+ readonly name: string;
173
+ readonly chainId: number;
174
+ readonly rpcUrl: string;
175
+ readonly vm: ChainVM;
176
+ readonly nativeCurrency: {
177
+ readonly name: string;
178
+ readonly symbol: string;
179
+ readonly decimals: number;
180
+ };
181
+ }
182
+ declare const BUILTIN_NETWORKS: Record<string, NetworkConfig>;
183
+ interface AssetInit {
184
+ readonly id: number;
185
+ readonly symbol: string;
186
+ readonly name: string;
187
+ readonly decimals: number;
188
+ readonly contractAddress: string | null;
189
+ readonly displayDecimals?: number;
190
+ readonly displayStatus?: boolean;
191
+ }
192
+ declare const BUILTIN_ASSETS: Record<string, ReadonlyArray<AssetInit>>;
193
+
194
+ export { AesGcmCipher, type AesGcmCipherOptions, Argon2Kdf, type Argon2KdfOptions, type AssetInit, BUILTIN_ASSETS, BUILTIN_NETWORKS, ChainVM, Cipher, ContainerProvider, DbProvider, FileProvider, IdbProvider, type IdbProviderOptions, type PasswordCheckResult, PasswordPolicy, type PasswordPolicyOptions, PasswordScore, type PasswordWeakness, type PasswordWeaknessCode, Provider, Record$1 as Record, RecordType, Slug, type StorageDurability, type StorageQuota };