@metamask-previews/eth-snap-keyring 4.3.2-preview-37040eb → 4.3.2-preview-8d6e44e

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.
@@ -0,0 +1,63 @@
1
+ /**
2
+ * A case-insensitive map that stores key-value pairs.
3
+ */
4
+ export declare class CaseInsensitiveMap<Value> extends Map<string, Value> {
5
+ /**
6
+ * Create a new case-insensitive map from a plain object.
7
+ *
8
+ * @param obj - An object with entries to initialize the map with.
9
+ * @returns A new case-insensitive map with all entries from `obj`.
10
+ */
11
+ static fromObject<Value>(obj: Record<string, Value>): CaseInsensitiveMap<Value>;
12
+ /**
13
+ * Return a plain object with all entries from this map.
14
+ *
15
+ * @returns A plain object with all entries from this map.
16
+ */
17
+ toObject(): Record<string, Value>;
18
+ /**
19
+ * Return the value associated to the given key, or `undefined` if the key is
20
+ * not found.
21
+ *
22
+ * @param key - The key to get the value for.
23
+ * @returns The value associated to the given key, or `undefined` if the key
24
+ * is not found.
25
+ */
26
+ get(key: string): Value | undefined;
27
+ /**
28
+ * Return the value associated with the given key, or throw an error if the
29
+ * key is not found.
30
+ *
31
+ * @param key - The key to look up in the map.
32
+ * @param name - Optional name of the key to include in the error message.
33
+ * @returns The value associated with the given key.
34
+ */
35
+ getOrThrow(key: string, name?: string): Value;
36
+ /**
37
+ * Check whether the given key is present in the map.
38
+ *
39
+ * @param key - The key to check for.
40
+ * @returns `true` if the key is present in the map, `false` otherwise.
41
+ */
42
+ has(key: string): boolean;
43
+ /**
44
+ * Set the value for the given key. If the key already exists in the map, its
45
+ * value will be updated.
46
+ *
47
+ * The key is converted to lowercase before being stored in the map to ensure
48
+ * case-insensitivity.
49
+ *
50
+ * @param key - The key to set the value for.
51
+ * @param value - The value to set.
52
+ * @returns The map instance.
53
+ */
54
+ set(key: string, value: Value): this;
55
+ /**
56
+ * Delete the entry for the given key.
57
+ *
58
+ * @param key - The key to delete the entry for.
59
+ * @returns `true` if the entry was present in the map, `false` otherwise.
60
+ */
61
+ delete(key: string): boolean;
62
+ }
63
+ //# sourceMappingURL=CaseInsensitiveMap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CaseInsensitiveMap.d.ts","sourceRoot":"","sources":["../src/CaseInsensitiveMap.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,qBAAa,kBAAkB,CAAC,KAAK,CAAE,SAAQ,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC;IAC/D;;;;;OAKG;IACH,MAAM,CAAC,UAAU,CAAC,KAAK,EACrB,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GACzB,kBAAkB,CAAC,KAAK,CAAC;IAI5B;;;;OAIG;IACH,QAAQ,IAAI,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC;IAIjC;;;;;;;OAOG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,GAAG,SAAS;IAInC;;;;;;;OAOG;IACH,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,SAAQ,GAAG,KAAK;IAI5C;;;;;OAKG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAIzB;;;;;;;;;;OAUG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI;IAIpC;;;;;OAKG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;CAG7B"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * A deferred promise can be resolved by a caller different from the one who
3
+ * created it.
4
+ *
5
+ * Example:
6
+ * - "A" creates a deferred promise "P", adds it to a list, and awaits it
7
+ * - "B" gets "P" from the list and resolves it
8
+ * - "A" gets the resolved value
9
+ */
10
+ export declare class DeferredPromise<Type> {
11
+ promise: Promise<Type>;
12
+ resolve: (value: Type | PromiseLike<Type>) => void;
13
+ reject: (reason?: any) => void;
14
+ constructor();
15
+ }
16
+ //# sourceMappingURL=DeferredPromise.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DeferredPromise.d.ts","sourceRoot":"","sources":["../src/DeferredPromise.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,qBAAa,eAAe,CAAC,IAAI;IAC/B,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAEvB,OAAO,EAAE,CAAC,KAAK,EAAE,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,KAAK,IAAI,CAAoB;IAEtE,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,IAAI,CAAoB;;CAenD"}
@@ -0,0 +1,46 @@
1
+ import { KeyringClient } from '@metamask/keyring-api';
2
+ import type { SnapController } from '@metamask/snaps-controllers';
3
+ import type { SnapId } from '@metamask/snaps-sdk';
4
+ import type { HandlerType } from '@metamask/snaps-utils';
5
+ /**
6
+ * A `KeyringClient` that allows the communication with a snap through the
7
+ * `SnapController`.
8
+ */
9
+ export declare class KeyringSnapControllerClient extends KeyringClient {
10
+ #private;
11
+ /**
12
+ * Create a new instance of `KeyringSnapControllerClient`.
13
+ *
14
+ * The `handlerType` argument has a hard-coded default `string` value instead
15
+ * of a `HandlerType` value to prevent the `@metamask/snaps-utils` module
16
+ * from being required at runtime.
17
+ *
18
+ * @param args - Constructor arguments.
19
+ * @param args.controller - The `SnapController` instance to use.
20
+ * @param args.snapId - The ID of the snap to use (default: `'undefined'`).
21
+ * @param args.origin - The sender's origin (default: `'metamask'`).
22
+ * @param args.handler - The handler type (default: `'onKeyringRequest'`).
23
+ */
24
+ constructor({ controller, snapId, origin, handler, }: {
25
+ controller: SnapController;
26
+ snapId?: SnapId;
27
+ origin?: string;
28
+ handler?: HandlerType;
29
+ });
30
+ /**
31
+ * Create a new instance of `KeyringSnapControllerClient` with the specified
32
+ * `snapId`.
33
+ *
34
+ * @param snapId - The ID of the snap to use in the new instance.
35
+ * @returns A new instance of `KeyringSnapControllerClient` with the
36
+ * specified snap ID.
37
+ */
38
+ withSnapId(snapId: SnapId): KeyringSnapControllerClient;
39
+ /**
40
+ * Get the `SnapController` instance used by this client.
41
+ *
42
+ * @returns The `SnapController` instance used by this client.
43
+ */
44
+ getController(): SnapController;
45
+ }
46
+ //# sourceMappingURL=KeyringSnapControllerClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KeyringSnapControllerClient.d.ts","sourceRoot":"","sources":["../src/KeyringSnapControllerClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAe,MAAM,uBAAuB,CAAC;AAEnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAoDzD;;;GAGG;AACH,qBAAa,2BAA4B,SAAQ,aAAa;;IAG5D;;;;;;;;;;;;OAYG;gBACS,EACV,UAAU,EACV,MAA8B,EAC9B,MAAmB,EACnB,OAA2C,GAC5C,EAAE;QACD,UAAU,EAAE,cAAc,CAAC;QAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,OAAO,CAAC,EAAE,WAAW,CAAC;KACvB;IAKD;;;;;;;OAOG;IACH,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,2BAA2B;IAOvD;;;;OAIG;IACH,aAAa,IAAI,cAAc;CAGhC"}
@@ -0,0 +1,203 @@
1
+ import type { SnapId } from '@metamask/snaps-sdk';
2
+ /**
3
+ * Error thrown when an invalid Snap ID is encountered.
4
+ */
5
+ export declare class InvalidSnapIdError extends Error {
6
+ /**
7
+ * The ID of the Snap that caused the error.
8
+ */
9
+ snapId: SnapId;
10
+ /**
11
+ * The key of the element that caused the error.
12
+ */
13
+ key: string;
14
+ /**
15
+ * Creates an instance of `InvalidSnapIdError`.
16
+ *
17
+ * @param snapId - The invalid Snap ID.
18
+ * @param key - The key associated with the invalid Snap ID.
19
+ */
20
+ constructor(snapId: SnapId, key: string);
21
+ }
22
+ /**
23
+ * A map that associates a string key with a value that has a `snapId`
24
+ * property. Note that the key is case-insensitive.
25
+ *
26
+ * The `snapId` property is used to ensure that only the Snap that added an
27
+ * item to the map can modify or delete it.
28
+ */
29
+ export declare class SnapIdMap<Value extends {
30
+ snapId: SnapId;
31
+ }> {
32
+ #private;
33
+ /**
34
+ * Creates a new `SnapIdMap` object.
35
+ *
36
+ * Example:
37
+ *
38
+ * ```ts
39
+ * const items = [
40
+ * ['foo', { snapId: '1', name: 'foo' }],
41
+ * ['bar', { snapId: '1', name: 'bar' }],
42
+ * ];
43
+ * const map = new SnapIdMap(items);
44
+ * ```
45
+ *
46
+ * @param iterable - An iterable object whose elements are key-value pairs.
47
+ * Each key-value pair will be added to the new map.
48
+ */
49
+ constructor(iterable?: Iterable<readonly [string, Value]>);
50
+ /**
51
+ * Returns a plain object with the same key-value pairs as this map.
52
+ *
53
+ * Example:
54
+ *
55
+ * ```ts
56
+ * const items = [
57
+ * ['foo', { snapId: '1', name: 'foo' }],
58
+ * ['bar', { snapId: '1', name: 'bar' }],
59
+ * ];
60
+ * const map = new SnapIdMap(items);
61
+ * map.toObject();
62
+ * // Returns
63
+ * // {
64
+ * // foo: { snapId: '1', name: 'foo' },
65
+ * // bar: { snapId: '1', name: 'bar' },
66
+ * // }
67
+ * ```
68
+ *
69
+ * @returns A plain object with the same key-value pairs as this map.
70
+ */
71
+ toObject(): Record<string, Value>;
72
+ /**
73
+ * Returns a new `SnapIdMap` object from an plain object.
74
+ *
75
+ * Example:
76
+ *
77
+ * ```ts
78
+ * const obj = {
79
+ * foo: { snapId: '1', name: 'foo' },
80
+ * bar: { snapId: '1', name: 'bar' },
81
+ * };
82
+ * const map = SnapIdMap.fromObject(obj);
83
+ * ```
84
+ *
85
+ * @param obj - A plain object whose elements will be added to the new map.
86
+ * @returns A new `SnapIdMap` containing the elements of the given object.
87
+ */
88
+ static fromObject<Value extends {
89
+ snapId: SnapId;
90
+ }>(obj: Record<string, Value>): SnapIdMap<Value>;
91
+ /**
92
+ * Gets a value from the map.
93
+ *
94
+ * If the given key is not present in the map or the Snap ID of the value is
95
+ * different from the given Snap ID, returns `undefined`.
96
+ *
97
+ * Example:
98
+ *
99
+ * ```ts
100
+ * const map = new SnapIdMap();
101
+ * map.set('foo', { snapId: '1', name: 'foo' });
102
+ * map.get('1', 'foo'); // Returns { snapId: '1', name: 'foo' }
103
+ * map.get('2', 'foo'); // Returns `undefined`
104
+ * map.get('1', 'bar'); // Returns `undefined`
105
+ * ```
106
+ *
107
+ * @param snapId - Snap ID present in the value to get.
108
+ * @param key - Key of the element to get.
109
+ * @returns The value associated with the given key and Snap ID.
110
+ */
111
+ get(snapId: SnapId, key: string): Value | undefined;
112
+ /**
113
+ * Checks if a key is present in the map.
114
+ *
115
+ * If the given key is not present in the map or the Snap ID of the value is
116
+ * different from the given Snap ID, returns `false`.
117
+ *
118
+ * Example:
119
+ *
120
+ * ```ts
121
+ * const map = new SnapIdMap();
122
+ * map.set('foo', { snapId: '1', name: 'foo' });
123
+ * map.has('1', 'foo'); // Returns `true`
124
+ * map.has('2', 'foo'); // Returns `false`
125
+ * map.has('1', 'bar'); // Returns `false`
126
+ * ```
127
+ *
128
+ * @param snapId - Snap ID present in the value to check.
129
+ * @param key - Key of the element to check.
130
+ * @returns `true` if the key is present in the map and the Snap ID of the
131
+ * value is equal to the given Snap ID, `false` otherwise.
132
+ */
133
+ has(snapId: SnapId, key: string): boolean;
134
+ /**
135
+ * Deletes a key from the map.
136
+ *
137
+ * If the given key is not present in the map or the Snap IDs don't match,
138
+ * returns `false` and does nothing.
139
+ *
140
+ * Example:
141
+ *
142
+ * ```ts
143
+ * const map = new SnapIdMap();
144
+ * map.set('foo', { snapId: '1', name: 'foo' });
145
+ * map.delete('2', 'foo'); // Returns `false`
146
+ * map.delete('1', 'bar'); // Returns `false`
147
+ * map.delete('1', 'foo'); // Returns `true`
148
+ * ```
149
+ *
150
+ * @param snapId - Snap ID present in the value to delete.
151
+ * @param key - Key of the element to delete.
152
+ * @returns `true` if the key was present in the map and the Snap ID of the
153
+ * value was equal to the given Snap ID, `false` otherwise.
154
+ */
155
+ delete(snapId: SnapId, key: string): boolean;
156
+ /**
157
+ * Adds or updates a key-value pair in the map.
158
+ *
159
+ * Note that this method has a different behavior from the `Map.set`.
160
+ *
161
+ * - If the given key is not already present in the map, this method adds the
162
+ * key-value pair to the map.
163
+ *
164
+ * - If the given key is already present in the map and the Snap IDs match,
165
+ * this method updates the value associated with the key.
166
+ *
167
+ * - However, if the given key is already present in the map but the Snap IDs
168
+ * do not match, this method throws an error.
169
+ *
170
+ * @param key - Key of the element to add or update.
171
+ * @param value - Value of the element to add or update.
172
+ * @returns The map itself.
173
+ */
174
+ set(key: string, value: Value): this;
175
+ /**
176
+ * Returns an iterable of the values in the map.
177
+ *
178
+ * Example:
179
+ *
180
+ * ```ts
181
+ * const map = new SnapIdMap([
182
+ * ['foo', { snapId: '1', name: 'foo' }],
183
+ * ['bar', { snapId: '1', name: 'bar' }],
184
+ * ]);
185
+ * const values = [...map.values()];
186
+ * // Returns
187
+ * // [
188
+ * // { snapId: '1', name: 'foo' },
189
+ * // { snapId: '1', name: 'bar' },
190
+ * // ]
191
+ * ```
192
+ *
193
+ * @returns An iterable of the values in the map.
194
+ */
195
+ values(): IterableIterator<Value>;
196
+ /**
197
+ * Returns the number of key-value pairs in the map.
198
+ *
199
+ * @returns The number of key-value pairs in the map.
200
+ */
201
+ get size(): number;
202
+ }
203
+ //# sourceMappingURL=SnapIdMap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SnapIdMap.d.ts","sourceRoot":"","sources":["../src/SnapIdMap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAIlD;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C;;OAEG;IACH,MAAM,EAAE,M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import type { TypedTransaction } from '@ethereumjs/tx';
3
+ import type { TypedDataV1, TypedMessage } from '@metamask/eth-sig-util';
4
+ import { SignTypedDataVersion } from '@metamask/eth-sig-util';
5
+ import type { EthBaseTransaction, EthBaseUserOperation, EthUserOperation, EthUserOperationPatch, InternalAccount, KeyringAccount, KeyringExecutionContext } from '@metamask/keyring-api';
6
+ import type { SnapController } from '@metamask/snaps-controllers';
7
+ import type { SnapId } from '@metamask/snaps-sdk';
8
+ import type { Json } from '@metamask/utils';
9
+ import { EventEmitter } from 'events';
10
+ import type { SnapMessage } from './types';
11
+ export declare const SNAP_KEYRING_TYPE = "Snap Keyring";
12
+ /**
13
+ * Snap keyring state.
14
+ *
15
+ * This state is persisted by the keyring controller and passed to the Snap
16
+ * keyring when it's created.
17
+ */
18
+ export declare type KeyringState = {
19
+ accounts: Record<string, {
20
+ account: KeyringAccount;
21
+ snapId: SnapId;
22
+ }>;
23
+ };
24
+ /**
25
+ * Snap keyring callbacks.
26
+ *
27
+ * These callbacks are used to interact with other components.
28
+ */
29
+ export declare type SnapKeyringCallbacks = {
30
+ saveState: () => Promise<void>;
31
+ addressExists(address: string): Promise<boolean>;
32
+ addAccount(address: string, snapId: SnapId, handleUserInput: (accepted: boolean) => Promise<void>, accountNameSuggestion?: string, displayConfirmation?: boolean): Promise<void>;
33
+ removeAccount(address: string, snapId: SnapId, handleUserInput: (accepted: boolean) => Promise<void>): Promise<void>;
34
+ redirectUser(snapId: SnapId, url: string, message: string): Promise<void>;
35
+ };
36
+ /**
37
+ * Keyring bridge implementation to support Snaps.
38
+ */
39
+ export declare class SnapKeyring extends EventEmitter {
40
+ #private;
41
+ static type: string;
42
+ type: string;
43
+ /**
44
+ * Create a new Snap keyring.
45
+ *
46
+ * @param controller - Snaps controller.
47
+ * @param callbacks - Callbacks used to interact with other components.
48
+ * @returns A new Snap keyring.
49
+ */
50
+ constructor(controller: SnapController, callbacks: SnapKeyringCallbacks);
51
+ /**
52
+ * Handle a message from a Snap.
53
+ *
54
+ * @param snapId - ID of the Snap.
55
+ * @param message - Message sent by the Snap.
56
+ * @returns The execution result.
57
+ */
58
+ handleKeyringSnapMessage(snapId: SnapId, message: SnapMessage): Promise<Json>;
59
+ /**
60
+ * Serialize the keyring state.
61
+ *
62
+ * @returns Serialized keyring state.
63
+ */
64
+ serialize(): Promise<KeyringState>;
65
+ /**
66
+ * Deserialize the keyring state into this keyring.
67
+ *
68
+ * @param state - Serialized keyring state.
69
+ */
70
+ deserialize(state: KeyringState | undefined): Promise<void>;
71
+ /**
72
+ * Get the addresses of the accounts in this keyring.
73
+ *
74
+ * @returns The addresses of the accounts in this keyring.
75
+ */
76
+ getAccounts(): Promise<string[]>;
77
+ /**
78
+ * Get the addresses of the accounts associated with a given Snap.
79
+ *
80
+ * @param snapId - Snap ID to filter by.
81
+ * @returns The addresses of the accounts associated with the given Snap.
82
+ */
83
+ getAccountsBySnapId(snapId: SnapId): Promise<string[]>;
84
+ /**
85
+ * Sign a transaction.
86
+ *
87
+ * @param address - Sender's address.
88
+ * @param transaction - Transaction.
89
+ * @param _opts - Transaction options (not used).
90
+ */
91
+ signTransaction(address: string, transaction: TypedTransaction, _opts?: {}): Promise<Json | TypedTransaction>;
92
+ /**
93
+ * Sign a typed data message.
94
+ *
95
+ * @param address - Signer's address.
96
+ * @param data - Data to sign.
97
+ * @param opts - Signing options.
98
+ * @returns The signature.
99
+ */
100
+ signTypedData(address: string, data: Record<string, unknown>[] | TypedDataV1 | TypedMessage<any>, opts?: {
101
+ version: SignTypedDataVersion;
102
+ }): Promise<string>;
103
+ /**
104
+ * Sign a message.
105
+ *
106
+ * @param address - Signer's address.
107
+ * @param hash - Data to sign.
108
+ * @returns The signature.
109
+ */
110
+ signMessage(address: string, hash: any): Promise<string>;
111
+ /**
112
+ * Sign a personal message.
113
+ *
114
+ * Note: KeyringController says this should return a Buffer but it actually
115
+ * expects a string.
116
+ *
117
+ * @param address - Signer's address.
118
+ * @param data - Data to sign.
119
+ * @returns Promise of the signature.
120
+ */
121
+ signPersonalMessage(address: string, data: any): Promise<string>;
122
+ /**
123
+ * Convert a base transaction to a base UserOperation.
124
+ *
125
+ * @param address - Address of the sender.
126
+ * @param transactions - Base transactions to include in the UserOperation.
127
+ * @param context - Keyring execution context.
128
+ * @returns A pseudo-UserOperation that can be used to construct a real.
129
+ */
130
+ prepareUserOperation(address: string, transactions: EthBaseTransaction[], context: KeyringExecutionContext): Promise<EthBaseUserOperation>;
131
+ /**
132
+ * Patches properties of a UserOperation. Currently, only the
133
+ * `paymasterAndData` can be patched.
134
+ *
135
+ * @param address - Address of the sender.
136
+ * @param userOp - UserOperation to patch.
137
+ * @param context - Keyring execution context.
138
+ * @returns A patch to apply to the UserOperation.
139
+ */
140
+ patchUserOperation(address: string, userOp: EthUserOperation, context: KeyringExecutionContext): Promise<EthUserOperationPatch>;
141
+ /**
142
+ * Signs an UserOperation.
143
+ *
144
+ * @param address - Address of the sender.
145
+ * @param userOp - UserOperation to sign.
146
+ * @param context - Leyring execution context.
147
+ * @returns The signature of the UserOperation.
148
+ */
149
+ signUserOperation(address: string, userOp: EthUserOperation, context: KeyringExecutionContext): Promise<string>;
150
+ /**
151
+ * Gets the private data associated with the given address so
152
+ * that it may be exported.
153
+ *
154
+ * If this keyring contains duplicate public keys the first
155
+ * matching address is exported.
156
+ *
157
+ * Used by the UI to export an account.
158
+ *
159
+ * @param _address - Address of the account to export.
160
+ */
161
+ exportAccount(_address: string): [Uint8Array, Json] | undefined;
162
+ /**
163
+ * Removes the account matching the given address.
164
+ *
165
+ * @param address - Address of the account to remove.
166
+ */
167
+ removeAccount(address: string): Promise<void>;
168
+ /**
169
+ * Return an internal account object for a given address.
170
+ *
171
+ * @param address - Address of the account to return.
172
+ * @returns An internal account object for the given address.
173
+ */
174
+ getAccountByAddress(address: string): InternalAccount | undefined;
175
+ /**
176
+ * List all Snap keyring accounts.
177
+ *
178
+ * @returns An array containing all Snap keyring accounts.
179
+ */
180
+ listAccounts(): InternalAccount[];
181
+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URL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,+BAA+B,CAAC"}
@@ -0,0 +1,5 @@
1
+ /// <reference types="debug" />
2
+ import { createModuleLogger } from '@metamask/utils';
3
+ export declare const projectLogger: import("debug").Debugger;
4
+ export { createModuleLogger };
5
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":";AAEA,OAAO,EAAuB,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAE1E,eAAO,MAAM,aAAa,0BAA0C,CAAC;AAErE,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { Infer } from '@metamask/superstruct';
2
+ export declare const SnapMessageStruct: import("@metamask/superstruct").Struct<{
3
+ method: string;
4
+ params?: import("@metamask/utils").Json[] | Record<string, import("@metamask/utils").Json> | undefined;
5
+ }, {
6
+ method: import("@metamask/superstruct").Struct<string, null>;
7
+ params: import("@metamask/superstruct").Struct<import("@metamask/utils").Json[] | Record<string, import("@metamask/utils").Json> | undefined, null>;
8
+ }>;
9
+ /**
10
+ * Message sent by the snap to manage accounts and requests.
11
+ */
12
+ export declare type SnapMessage = Infer<typeof SnapMessageStruct>;
13
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAWnD,eAAO,MAAM,iBAAiB;;;;;;EAG5B,CAAC;AAEH;;GAEG;AACH,oBAAY,WAAW,GAAG,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC"}
package/dist/util.d.ts ADDED
@@ -0,0 +1,53 @@
1
+ import type { Struct } from '@metamask/superstruct';
2
+ import type { Json } from '@metamask/utils';
3
+ /**
4
+ * Assert that a value is valid according to a struct.
5
+ *
6
+ * It is similar to superstruct's mask function, but it does not ignore extra
7
+ * properties.
8
+ *
9
+ * @param value - Value to check.
10
+ * @param struct - Struct to validate the value against.
11
+ * @param message - Error message to throw if the value is not valid.
12
+ * @returns The value if it is valid.
13
+ */
14
+ export declare function strictMask<Type, Schema>(value: unknown, struct: Struct<Type, Schema>, message?: string): Type;
15
+ /**
16
+ * Remove duplicate entries from an array.
17
+ *
18
+ * @param array - Array to remove duplicates from.
19
+ * @returns Array with duplicates removed.
20
+ */
21
+ export declare function unique<Type>(array: Type[] | Iterable<Type>): Type[];
22
+ /**
23
+ * Convert a value to a valid JSON object.
24
+ *
25
+ * The function chains JSON.stringify and JSON.parse to ensure that the result
26
+ * is a valid JSON object. In objects, undefined values are removed, and in
27
+ * arrays, they are replaced with null.
28
+ *
29
+ * @param value - Value to convert to JSON.
30
+ * @returns JSON representation of the value.
31
+ */
32
+ export declare function toJson<Type extends Json = Json>(value: any): Type;
33
+ /**
34
+ * Asserts that the given value is defined.
35
+ *
36
+ * @param value - Value to check.
37
+ */
38
+ export declare function ensureDefined<Type>(value: Type | undefined): asserts value is Type;
39
+ /**
40
+ * Helper function that throws an error.
41
+ *
42
+ * @param message - Error message to throw.
43
+ */
44
+ export declare function throwError(message: string): never;
45
+ /**
46
+ * Compares two strings for equality, ignoring case.
47
+ *
48
+ * @param a - The first string to compare.
49
+ * @param b - The second string to compare.
50
+ * @returns `true` if the strings are equal, ignoring case. `false` otherwise.
51
+ */
52
+ export declare function equalsIgnoreCase(a: string, b: string): boolean;
53
+ //# sourceMappingURL=util.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAE5C;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EACrC,KAAK,EAAE,OAAO,EACd,MAAM,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,EAC5B,OAAO,CAAC,EAAE,MAAM,GACf,IAAI,CAGN;AAED;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,QAAQ,CAAC,IAAI,CAAC,GAAG,IAAI,EAAE,CAEnE;AAED;;;;;;;;;GASG;AACH,wBAAgB,MAAM,CAAC,IAAI,SAAS,IAAI,GAAG,IAAI,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI,CAEjE;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAChC,KAAK,EAAE,IAAI,GAAG,SAAS,GACtB,OAAO,CAAC,KAAK,IAAI,IAAI,CAIvB;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,KAAK,CAEjD;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAE9D"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask-previews/eth-snap-keyring",
3
- "version": "4.3.2-preview-37040eb",
3
+ "version": "4.3.2-preview-8d6e44e",
4
4
  "description": "Snaps keyring bridge.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -18,7 +18,6 @@
18
18
  "build:force": "tsc --build tsconfig.build.json --force",
19
19
  "changelog:update": "../../scripts/update-changelog.sh @metamask/eth-snap-keyring",
20
20
  "changelog:validate": "../../scripts/validate-changelog.sh @metamask/eth-snap-keyring",
21
- "prepack": "./scripts/prepack.sh",
22
21
  "publish:preview": "yarn npm publish --tag preview",
23
22
  "test": "jest && jest-it-up",
24
23
  "test:clean": "jest --clearCache",