@metamask-previews/keyring-controller 27.1.1-preview-4f4c98e → 27.1.1-preview-eb263b0ee
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/CHANGELOG.md +0 -4
- package/dist/KeyringController-method-action-types.cjs +7 -0
- package/dist/KeyringController-method-action-types.cjs.map +1 -0
- package/dist/{KeyringController-method-action-types.d.ts → KeyringController-method-action-types.d.cts} +2 -2
- package/dist/KeyringController-method-action-types.d.cts.map +1 -0
- package/dist/KeyringController-method-action-types.d.mts +491 -0
- package/dist/KeyringController-method-action-types.d.mts.map +1 -0
- package/dist/{KeyringController-method-action-types.js → KeyringController-method-action-types.mjs} +1 -1
- package/dist/KeyringController-method-action-types.mjs.map +1 -0
- package/dist/KeyringController.cjs +2018 -0
- package/dist/KeyringController.cjs.map +1 -0
- package/dist/{KeyringController.d.ts → KeyringController.d.cts} +13 -13
- package/dist/KeyringController.d.cts.map +1 -0
- package/dist/KeyringController.d.mts +825 -0
- package/dist/KeyringController.d.mts.map +1 -0
- package/dist/{KeyringController.js → KeyringController.mjs} +24 -31
- package/dist/KeyringController.mjs.map +1 -0
- package/dist/constants.cjs +48 -0
- package/dist/constants.cjs.map +1 -0
- package/dist/{constants.d.ts → constants.d.cts} +1 -1
- package/dist/constants.d.cts.map +1 -0
- package/dist/constants.d.mts +44 -0
- package/dist/constants.d.mts.map +1 -0
- package/dist/{constants.js → constants.mjs} +1 -1
- package/dist/constants.mjs.map +1 -0
- package/dist/errors.cjs +114 -0
- package/dist/errors.cjs.map +1 -0
- package/dist/{errors.d.ts → errors.d.cts} +1 -1
- package/dist/errors.d.cts.map +1 -0
- package/dist/errors.d.mts +91 -0
- package/dist/errors.d.mts.map +1 -0
- package/dist/{errors.js → errors.mjs} +2 -2
- package/dist/errors.mjs.map +1 -0
- package/dist/index.cjs +22 -0
- package/dist/index.cjs.map +1 -0
- package/dist/{index.d.ts → index.d.cts} +6 -6
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +6 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +4 -0
- package/dist/index.mjs.map +1 -0
- package/dist/types.cjs +3 -0
- package/dist/types.cjs.map +1 -0
- package/dist/{types.d.ts → types.d.cts} +2 -2
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.mts +80 -0
- package/dist/types.d.mts.map +1 -0
- package/dist/types.mjs +2 -0
- package/dist/types.mjs.map +1 -0
- package/package.json +18 -13
- package/dist/KeyringController-method-action-types.d.ts.map +0 -1
- package/dist/KeyringController-method-action-types.js.map +0 -1
- package/dist/KeyringController.d.ts.map +0 -1
- package/dist/KeyringController.js.map +0 -1
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js.map +0 -1
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -4
- package/dist/index.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export declare enum KeyringControllerErrorMessage {
|
|
2
|
+
NoKeyring = "KeyringController - No keyring found",
|
|
3
|
+
KeyringNotFound = "KeyringController - Keyring not found.",
|
|
4
|
+
UnsafeDirectKeyringAccess = "KeyringController - Returning keyring instances is unsafe",
|
|
5
|
+
WrongPasswordType = "KeyringController - Password must be of type string.",
|
|
6
|
+
WrongEncryptionKeyType = "KeyringController - Encryption key must be of type string.",
|
|
7
|
+
InvalidEmptyPassword = "KeyringController - Password cannot be empty.",
|
|
8
|
+
NoFirstAccount = "KeyringController - First Account not found.",
|
|
9
|
+
DuplicatedAccount = "KeyringController - The account you are trying to import is a duplicate",
|
|
10
|
+
VaultError = "KeyringController - Cannot unlock without a previous vault.",
|
|
11
|
+
VaultDataError = "KeyringController - The decrypted vault has an unexpected shape.",
|
|
12
|
+
UnsupportedEncryptionKeyExport = "KeyringController - The encryptor does not support encryption key export.",
|
|
13
|
+
UnsupportedGenerateRandomMnemonic = "KeyringController - The current keyring does not support the method generateRandomMnemonic.",
|
|
14
|
+
UnsupportedExportAccount = "`KeyringController - The keyring for the current address does not support the method exportAccount",
|
|
15
|
+
UnsupportedRemoveAccount = "`KeyringController - The keyring for the current address does not support the method removeAccount",
|
|
16
|
+
UnsupportedSignTransaction = "KeyringController - The keyring for the current address does not support the method signTransaction.",
|
|
17
|
+
UnsupportedSignMessage = "KeyringController - The keyring for the current address does not support the method signMessage.",
|
|
18
|
+
UnsupportedSignPersonalMessage = "KeyringController - The keyring for the current address does not support the method signPersonalMessage.",
|
|
19
|
+
UnsupportedSignEip7702Authorization = "KeyringController - The keyring for the current address does not support the method signEip7702Authorization.",
|
|
20
|
+
UnsupportedGetEncryptionPublicKey = "KeyringController - The keyring for the current address does not support the method getEncryptionPublicKey.",
|
|
21
|
+
UnsupportedDecryptMessage = "KeyringController - The keyring for the current address does not support the method decryptMessage.",
|
|
22
|
+
UnsupportedSignTypedMessage = "KeyringController - The keyring for the current address does not support the method signTypedMessage.",
|
|
23
|
+
UnsupportedGetAppKeyAddress = "KeyringController - The keyring for the current address does not support the method getAppKeyAddress.",
|
|
24
|
+
UnsupportedExportAppKeyForAddress = "KeyringController - The keyring for the current address does not support the method exportAppKeyForAddress.",
|
|
25
|
+
UnsupportedPrepareUserOperation = "KeyringController - The keyring for the current address does not support the method prepareUserOperation.",
|
|
26
|
+
UnsupportedPatchUserOperation = "KeyringController - The keyring for the current address does not support the method patchUserOperation.",
|
|
27
|
+
UnsupportedSignUserOperation = "KeyringController - The keyring for the current address does not support the method signUserOperation.",
|
|
28
|
+
UnsupportedVerifySeedPhrase = "KeyringController - The keyring does not support the method verifySeedPhrase.",
|
|
29
|
+
MissingEip7702AuthorizationContractAddress = "KeyringController - The EIP-7702 Authorization is invalid. No contract address provided.",
|
|
30
|
+
NoAccountOnKeychain = "KeyringController - The keychain doesn't have accounts.",
|
|
31
|
+
ControllerLocked = "KeyringController - The operation cannot be completed while the controller is locked.",
|
|
32
|
+
MissingCredentials = "KeyringController - Cannot persist vault without password and encryption key",
|
|
33
|
+
MissingVaultData = "KeyringController - Cannot persist vault without vault information",
|
|
34
|
+
ExpiredCredentials = "KeyringController - Encryption key and salt provided are expired",
|
|
35
|
+
NoKeyringBuilder = "KeyringController - No keyringBuilder found for keyring",
|
|
36
|
+
DataType = "KeyringController - Incorrect data type provided",
|
|
37
|
+
NoHdKeyring = "KeyringController - No HD Keyring found",
|
|
38
|
+
ControllerLockRequired = "KeyringController - attempt to update vault during a non mutually exclusive operation",
|
|
39
|
+
LastAccountInPrimaryKeyring = "KeyringController - Last account in primary keyring cannot be removed",
|
|
40
|
+
EncryptionKeyNotSet = "KeyringController - Encryption key not set",
|
|
41
|
+
KeyringV2NotSupported = "KeyringController - The selected keyring does not support the KeyringV2 API.",
|
|
42
|
+
CannotRemovePrimaryKeyring = "KeyringController - Cannot remove the primary keyring"
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=constants.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.mts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,oBAAY,6BAA6B;IACvC,SAAS,yCAAyC;IAClD,eAAe,2CAA2C;IAC1D,yBAAyB,8DAA8D;IACvF,iBAAiB,yDAAyD;IAC1E,sBAAsB,+DAA+D;IACrF,oBAAoB,kDAAkD;IACtE,cAAc,iDAAiD;IAC/D,iBAAiB,4EAA4E;IAC7F,UAAU,gEAAgE;IAC1E,cAAc,qEAAqE;IACnF,8BAA8B,8EAA8E;IAC5G,iCAAiC,gGAAgG;IACjI,wBAAwB,uGAAuG;IAC/H,wBAAwB,uGAAuG;IAC/H,0BAA0B,yGAAyG;IACnI,sBAAsB,qGAAqG;IAC3H,8BAA8B,6GAA6G;IAC3I,mCAAmC,kHAAkH;IACrJ,iCAAiC,gHAAgH;IACjJ,yBAAyB,wGAAwG;IACjI,2BAA2B,0GAA0G;IACrI,2BAA2B,0GAA0G;IACrI,iCAAiC,gHAAgH;IACjJ,+BAA+B,8GAA8G;IAC7I,6BAA6B,4GAA4G;IACzI,4BAA4B,2GAA2G;IACvI,2BAA2B,kFAAkF;IAC7G,0CAA0C,6FAA6F;IACvI,mBAAmB,4DAA4D;IAC/E,gBAAgB,0FAA0F;IAC1G,kBAAkB,iFAAiF;IACnG,gBAAgB,uEAAuE;IACvF,kBAAkB,qEAAqE;IACvF,gBAAgB,4DAA4D;IAC5E,QAAQ,qDAAqD;IAC7D,WAAW,4CAA4C;IACvD,sBAAsB,0FAA0F;IAChH,2BAA2B,0EAA0E;IACrG,mBAAmB,+CAA+C;IAClE,qBAAqB,iFAAiF;IACtG,0BAA0B,0DAA0D;CACrF"}
|
|
@@ -42,4 +42,4 @@ export var KeyringControllerErrorMessage;
|
|
|
42
42
|
KeyringControllerErrorMessage["KeyringV2NotSupported"] = "KeyringController - The selected keyring does not support the KeyringV2 API.";
|
|
43
43
|
KeyringControllerErrorMessage["CannotRemovePrimaryKeyring"] = "KeyringController - Cannot remove the primary keyring";
|
|
44
44
|
})(KeyringControllerErrorMessage || (KeyringControllerErrorMessage = {}));
|
|
45
|
-
//# sourceMappingURL=constants.
|
|
45
|
+
//# sourceMappingURL=constants.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.mjs","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,6BA0CX;AA1CD,WAAY,6BAA6B;IACvC,mFAAkD,CAAA;IAClD,2FAA0D,CAAA;IAC1D,wHAAuF,CAAA;IACvF,2GAA0E,CAAA;IAC1E,sHAAqF,CAAA;IACrF,uGAAsE,CAAA;IACtE,gGAA+D,CAAA;IAC/D,8HAA6F,CAAA;IAC7F,2GAA0E,CAAA;IAC1E,oHAAmF,CAAA;IACnF,6IAA4G,CAAA;IAC5G,kKAAiI,CAAA;IACjI,gKAA+H,CAAA;IAC/H,gKAA+H,CAAA;IAC/H,oKAAmI,CAAA;IACnI,4JAA2H,CAAA;IAC3H,4KAA2I,CAAA;IAC3I,sLAAqJ,CAAA;IACrJ,kLAAiJ,CAAA;IACjJ,kKAAiI,CAAA;IACjI,sKAAqI,CAAA;IACrI,sKAAqI,CAAA;IACrI,kLAAiJ,CAAA;IACjJ,8KAA6I,CAAA;IAC7I,0KAAyI,CAAA;IACzI,wKAAuI,CAAA;IACvI,8IAA6G,CAAA;IAC7G,wKAAuI,CAAA;IACvI,gHAA+E,CAAA;IAC/E,2IAA0G,CAAA;IAC1G,oIAAmG,CAAA;IACnG,wHAAuF,CAAA;IACvF,wHAAuF,CAAA;IACvF,6GAA4E,CAAA;IAC5E,8FAA6D,CAAA;IAC7D,wFAAuD,CAAA;IACvD,iJAAgH,CAAA;IAChH,sIAAqG,CAAA;IACrG,mGAAkE,CAAA;IAClE,uIAAsG,CAAA;IACtG,qHAAoF,CAAA;AACtF,CAAC,EA1CW,6BAA6B,KAA7B,6BAA6B,QA0CxC","sourcesContent":["export enum KeyringControllerErrorMessage {\n NoKeyring = 'KeyringController - No keyring found',\n KeyringNotFound = 'KeyringController - Keyring not found.',\n UnsafeDirectKeyringAccess = 'KeyringController - Returning keyring instances is unsafe',\n WrongPasswordType = 'KeyringController - Password must be of type string.',\n WrongEncryptionKeyType = 'KeyringController - Encryption key must be of type string.',\n InvalidEmptyPassword = 'KeyringController - Password cannot be empty.',\n NoFirstAccount = 'KeyringController - First Account not found.',\n DuplicatedAccount = 'KeyringController - The account you are trying to import is a duplicate',\n VaultError = 'KeyringController - Cannot unlock without a previous vault.',\n VaultDataError = 'KeyringController - The decrypted vault has an unexpected shape.',\n UnsupportedEncryptionKeyExport = 'KeyringController - The encryptor does not support encryption key export.',\n UnsupportedGenerateRandomMnemonic = 'KeyringController - The current keyring does not support the method generateRandomMnemonic.',\n UnsupportedExportAccount = '`KeyringController - The keyring for the current address does not support the method exportAccount',\n UnsupportedRemoveAccount = '`KeyringController - The keyring for the current address does not support the method removeAccount',\n UnsupportedSignTransaction = 'KeyringController - The keyring for the current address does not support the method signTransaction.',\n UnsupportedSignMessage = 'KeyringController - The keyring for the current address does not support the method signMessage.',\n UnsupportedSignPersonalMessage = 'KeyringController - The keyring for the current address does not support the method signPersonalMessage.',\n UnsupportedSignEip7702Authorization = 'KeyringController - The keyring for the current address does not support the method signEip7702Authorization.',\n UnsupportedGetEncryptionPublicKey = 'KeyringController - The keyring for the current address does not support the method getEncryptionPublicKey.',\n UnsupportedDecryptMessage = 'KeyringController - The keyring for the current address does not support the method decryptMessage.',\n UnsupportedSignTypedMessage = 'KeyringController - The keyring for the current address does not support the method signTypedMessage.',\n UnsupportedGetAppKeyAddress = 'KeyringController - The keyring for the current address does not support the method getAppKeyAddress.',\n UnsupportedExportAppKeyForAddress = 'KeyringController - The keyring for the current address does not support the method exportAppKeyForAddress.',\n UnsupportedPrepareUserOperation = 'KeyringController - The keyring for the current address does not support the method prepareUserOperation.',\n UnsupportedPatchUserOperation = 'KeyringController - The keyring for the current address does not support the method patchUserOperation.',\n UnsupportedSignUserOperation = 'KeyringController - The keyring for the current address does not support the method signUserOperation.',\n UnsupportedVerifySeedPhrase = 'KeyringController - The keyring does not support the method verifySeedPhrase.',\n MissingEip7702AuthorizationContractAddress = 'KeyringController - The EIP-7702 Authorization is invalid. No contract address provided.',\n NoAccountOnKeychain = \"KeyringController - The keychain doesn't have accounts.\",\n ControllerLocked = 'KeyringController - The operation cannot be completed while the controller is locked.',\n MissingCredentials = 'KeyringController - Cannot persist vault without password and encryption key',\n MissingVaultData = 'KeyringController - Cannot persist vault without vault information',\n ExpiredCredentials = 'KeyringController - Encryption key and salt provided are expired',\n NoKeyringBuilder = 'KeyringController - No keyringBuilder found for keyring',\n DataType = 'KeyringController - Incorrect data type provided',\n NoHdKeyring = 'KeyringController - No HD Keyring found',\n ControllerLockRequired = 'KeyringController - attempt to update vault during a non mutually exclusive operation',\n LastAccountInPrimaryKeyring = 'KeyringController - Last account in primary keyring cannot be removed',\n EncryptionKeyNotSet = 'KeyringController - Encryption key not set',\n KeyringV2NotSupported = 'KeyringController - The selected keyring does not support the KeyringV2 API.',\n CannotRemovePrimaryKeyring = 'KeyringController - Cannot remove the primary keyring',\n}\n"]}
|
package/dist/errors.cjs
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isKeyringNotFoundError = exports.isKeyringControllerError = exports.KeyringControllerError = void 0;
|
|
4
|
+
const constants_js_1 = require("./constants.cjs");
|
|
5
|
+
/**
|
|
6
|
+
* Error class for KeyringController-related errors.
|
|
7
|
+
*
|
|
8
|
+
* This error class extends the standard Error class and supports:
|
|
9
|
+
* - Error chaining via the `cause` property (ES2022 standard)
|
|
10
|
+
* - Optional error codes for programmatic error handling
|
|
11
|
+
* - Additional context data for debugging
|
|
12
|
+
* - Backward compatibility with the legacy `originalError` property
|
|
13
|
+
*/
|
|
14
|
+
class KeyringControllerError extends Error {
|
|
15
|
+
/**
|
|
16
|
+
* Creates a new KeyringControllerError.
|
|
17
|
+
*
|
|
18
|
+
* @param message - The error message.
|
|
19
|
+
* @param options - Error options or an Error object for backward compatibility.
|
|
20
|
+
*/
|
|
21
|
+
constructor(message, options) {
|
|
22
|
+
super(message);
|
|
23
|
+
this.name = 'KeyringControllerError';
|
|
24
|
+
// Support both new signature (options object) and legacy signature (Error as second param)
|
|
25
|
+
const cause = options instanceof Error ? options : options?.cause;
|
|
26
|
+
const code = options instanceof Error ? undefined : options?.code;
|
|
27
|
+
const context = options instanceof Error ? undefined : options?.context;
|
|
28
|
+
// Set cause property for error chaining (ES2022 standard)
|
|
29
|
+
if (cause) {
|
|
30
|
+
this.cause = cause;
|
|
31
|
+
// Maintain backward compatibility with originalError
|
|
32
|
+
this.originalError = cause;
|
|
33
|
+
}
|
|
34
|
+
// Set code and data if provided
|
|
35
|
+
if (code) {
|
|
36
|
+
this.code = code;
|
|
37
|
+
}
|
|
38
|
+
if (context) {
|
|
39
|
+
this.context = context;
|
|
40
|
+
}
|
|
41
|
+
// Ensure proper prototype chain for instanceof checks
|
|
42
|
+
Object.setPrototypeOf(this, KeyringControllerError.prototype);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Returns a JSON representation of the error.
|
|
46
|
+
* Useful for logging and error reporting.
|
|
47
|
+
*
|
|
48
|
+
* @returns JSON representation of the error.
|
|
49
|
+
*/
|
|
50
|
+
toJSON() {
|
|
51
|
+
return {
|
|
52
|
+
name: this.name,
|
|
53
|
+
message: this.message,
|
|
54
|
+
code: this.code,
|
|
55
|
+
context: this.context,
|
|
56
|
+
stack: this.stack,
|
|
57
|
+
cause: this.cause
|
|
58
|
+
? {
|
|
59
|
+
name: this.cause.name,
|
|
60
|
+
message: this.cause.message,
|
|
61
|
+
stack: this.cause.stack,
|
|
62
|
+
}
|
|
63
|
+
: undefined,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Returns a string representation of the error chain.
|
|
68
|
+
* Includes all chained errors for better debugging.
|
|
69
|
+
*
|
|
70
|
+
* @returns String representation of the error chain.
|
|
71
|
+
*/
|
|
72
|
+
toString() {
|
|
73
|
+
let result = `${this.name}: ${this.message}`;
|
|
74
|
+
if (this.code) {
|
|
75
|
+
result += ` [${this.code}]`;
|
|
76
|
+
}
|
|
77
|
+
if (this.cause) {
|
|
78
|
+
result += `\n Caused by: ${this.cause}`;
|
|
79
|
+
}
|
|
80
|
+
return result;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
exports.KeyringControllerError = KeyringControllerError;
|
|
84
|
+
/**
|
|
85
|
+
* Returns `true` if the error is a `KeyringControllerError`.
|
|
86
|
+
*
|
|
87
|
+
* Uses duck-typing on `error.name` rather than `instanceof` so that the check
|
|
88
|
+
* remains correct when multiple major versions of `@metamask/keyring-controller`
|
|
89
|
+
* coexist in the dependency tree (different versions produce different classes,
|
|
90
|
+
* so `instanceof` would return `false` for errors from another version).
|
|
91
|
+
*
|
|
92
|
+
* @param error - The value to check.
|
|
93
|
+
* @returns Whether the error is a `KeyringControllerError`.
|
|
94
|
+
*/
|
|
95
|
+
function isKeyringControllerError(error) {
|
|
96
|
+
return (typeof error === 'object' &&
|
|
97
|
+
error !== null &&
|
|
98
|
+
error.name === 'KeyringControllerError');
|
|
99
|
+
}
|
|
100
|
+
exports.isKeyringControllerError = isKeyringControllerError;
|
|
101
|
+
/**
|
|
102
|
+
* Returns `true` if the error is a `KeyringNotFound` error thrown by
|
|
103
|
+
* `KeyringController:withKeyring`. Use this to distinguish a missing keyring
|
|
104
|
+
* from other failures and apply fallback logic.
|
|
105
|
+
*
|
|
106
|
+
* @param error - The value to check.
|
|
107
|
+
* @returns Whether the error is a `KeyringNotFound` error.
|
|
108
|
+
*/
|
|
109
|
+
function isKeyringNotFoundError(error) {
|
|
110
|
+
return (isKeyringControllerError(error) &&
|
|
111
|
+
error.message === constants_js_1.KeyringControllerErrorMessage.KeyringNotFound);
|
|
112
|
+
}
|
|
113
|
+
exports.isKeyringNotFoundError = isKeyringNotFoundError;
|
|
114
|
+
//# sourceMappingURL=errors.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.cjs","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";;;AAAA,kDAA+D;AAuB/D;;;;;;;;GAQG;AACH,MAAa,sBAAuB,SAAQ,KAAK;IAsB/C;;;;;OAKG;IACH,YACE,OAAe,EACf,OAA+C;QAE/C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;QAErC,2FAA2F;QAC3F,MAAM,KAAK,GAAG,OAAO,YAAY,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,EAAE,KAAK,CAAC;QAClE,MAAM,IAAI,GAAG,OAAO,YAAY,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,EAAE,IAAI,CAAC;QAClE,MAAM,OAAO,GAAG,OAAO,YAAY,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC;QAExE,0DAA0D;QAC1D,IAAI,KAAK,EAAE,CAAC;YACV,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;YACnB,qDAAqD;YACrD,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC;QAC7B,CAAC;QAED,gCAAgC;QAChC,IAAI,IAAI,EAAE,CAAC;YACT,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACnB,CAAC;QACD,IAAI,OAAO,EAAE,CAAC;YACZ,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACzB,CAAC;QAED,sDAAsD;QACtD,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,sBAAsB,CAAC,SAAS,CAAC,CAAC;IAChE,CAAC;IAED;;;;;OAKG;IACH,MAAM;QACJ,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,KAAK,EAAE,IAAI,CAAC,KAAK;gBACf,CAAC,CAAC;oBACE,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI;oBACrB,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO;oBAC3B,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK;iBACxB;gBACH,CAAC,CAAC,SAAS;SACd,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACH,QAAQ;QACN,IAAI,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,OAAO,EAAE,CAAC;QAE7C,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YACd,MAAM,IAAI,KAAK,IAAI,CAAC,IAAI,GAAG,CAAC;QAC9B,CAAC;QAED,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,kBAAkB,IAAI,CAAC,KAAK,EAAE,CAAC;QAC3C,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AArGD,wDAqGC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,wBAAwB,CACtC,KAAc;IAEd,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACb,KAA4B,CAAC,IAAI,KAAK,wBAAwB,CAChE,CAAC;AACJ,CAAC;AARD,4DAQC;AAED;;;;;;;GAOG;AACH,SAAgB,sBAAsB,CACpC,KAAc;IAEd,OAAO,CACL,wBAAwB,CAAC,KAAK,CAAC;QAC/B,KAAK,CAAC,OAAO,KAAK,4CAA6B,CAAC,eAAe,CAChE,CAAC;AACJ,CAAC;AAPD,wDAOC","sourcesContent":["import { KeyringControllerErrorMessage } from './constants.js';\n\n/**\n * Options for creating a KeyringControllerError.\n */\nexport type KeyringControllerErrorOptions = {\n /**\n * The underlying error that caused this error (for error chaining).\n * Uses the standard Error.cause property (ES2022).\n */\n cause?: Error;\n /**\n * Optional error code for programmatic error handling.\n * This can be used to identify specific error types without string matching.\n */\n code?: string;\n /**\n * Additional context data associated with the error.\n * Useful for debugging and error reporting.\n */\n context?: Record<string, unknown>;\n};\n\n/**\n * Error class for KeyringController-related errors.\n *\n * This error class extends the standard Error class and supports:\n * - Error chaining via the `cause` property (ES2022 standard)\n * - Optional error codes for programmatic error handling\n * - Additional context data for debugging\n * - Backward compatibility with the legacy `originalError` property\n */\nexport class KeyringControllerError extends Error {\n /**\n * Optional error code for programmatic error handling.\n */\n code?: string;\n\n /**\n * Additional context data associated with the error.\n */\n context?: Record<string, unknown>;\n\n /**\n * The underlying error that caused this error (ES2022 standard).\n * This is set manually for compatibility with older TypeScript versions.\n */\n cause?: Error;\n\n /**\n * @deprecated Use `cause` instead. This property is maintained for backward compatibility.\n */\n originalError?: Error;\n\n /**\n * Creates a new KeyringControllerError.\n *\n * @param message - The error message.\n * @param options - Error options or an Error object for backward compatibility.\n */\n constructor(\n message: string,\n options?: KeyringControllerErrorOptions | Error,\n ) {\n super(message);\n this.name = 'KeyringControllerError';\n\n // Support both new signature (options object) and legacy signature (Error as second param)\n const cause = options instanceof Error ? options : options?.cause;\n const code = options instanceof Error ? undefined : options?.code;\n const context = options instanceof Error ? undefined : options?.context;\n\n // Set cause property for error chaining (ES2022 standard)\n if (cause) {\n this.cause = cause;\n // Maintain backward compatibility with originalError\n this.originalError = cause;\n }\n\n // Set code and data if provided\n if (code) {\n this.code = code;\n }\n if (context) {\n this.context = context;\n }\n\n // Ensure proper prototype chain for instanceof checks\n Object.setPrototypeOf(this, KeyringControllerError.prototype);\n }\n\n /**\n * Returns a JSON representation of the error.\n * Useful for logging and error reporting.\n *\n * @returns JSON representation of the error.\n */\n toJSON(): Record<string, unknown> {\n return {\n name: this.name,\n message: this.message,\n code: this.code,\n context: this.context,\n stack: this.stack,\n cause: this.cause\n ? {\n name: this.cause.name,\n message: this.cause.message,\n stack: this.cause.stack,\n }\n : undefined,\n };\n }\n\n /**\n * Returns a string representation of the error chain.\n * Includes all chained errors for better debugging.\n *\n * @returns String representation of the error chain.\n */\n toString(): string {\n let result = `${this.name}: ${this.message}`;\n\n if (this.code) {\n result += ` [${this.code}]`;\n }\n\n if (this.cause) {\n result += `\\n Caused by: ${this.cause}`;\n }\n\n return result;\n }\n}\n\n/**\n * Returns `true` if the error is a `KeyringControllerError`.\n *\n * Uses duck-typing on `error.name` rather than `instanceof` so that the check\n * remains correct when multiple major versions of `@metamask/keyring-controller`\n * coexist in the dependency tree (different versions produce different classes,\n * so `instanceof` would return `false` for errors from another version).\n *\n * @param error - The value to check.\n * @returns Whether the error is a `KeyringControllerError`.\n */\nexport function isKeyringControllerError(\n error: unknown,\n): error is KeyringControllerError {\n return (\n typeof error === 'object' &&\n error !== null &&\n (error as { name?: unknown }).name === 'KeyringControllerError'\n );\n}\n\n/**\n * Returns `true` if the error is a `KeyringNotFound` error thrown by\n * `KeyringController:withKeyring`. Use this to distinguish a missing keyring\n * from other failures and apply fallback logic.\n *\n * @param error - The value to check.\n * @returns Whether the error is a `KeyringNotFound` error.\n */\nexport function isKeyringNotFoundError(\n error: unknown,\n): error is KeyringControllerError {\n return (\n isKeyringControllerError(error) &&\n error.message === KeyringControllerErrorMessage.KeyringNotFound\n );\n}\n"]}
|
|
@@ -88,4 +88,4 @@ export declare function isKeyringControllerError(error: unknown): error is Keyri
|
|
|
88
88
|
* @returns Whether the error is a `KeyringNotFound` error.
|
|
89
89
|
*/
|
|
90
90
|
export declare function isKeyringNotFoundError(error: unknown): error is KeyringControllerError;
|
|
91
|
-
//# sourceMappingURL=errors.d.
|
|
91
|
+
//# sourceMappingURL=errors.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.cts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,MAAM,6BAA6B,GAAG;IAC1C;;;OAGG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC;IACd;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC,CAAC;AAEF;;;;;;;;GAQG;AACH,qBAAa,sBAAuB,SAAQ,KAAK;IAC/C;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAElC;;;OAGG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC;IAEd;;OAEG;IACH,aAAa,CAAC,EAAE,KAAK,CAAC;IAEtB;;;;;OAKG;gBAED,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,6BAA6B,GAAG,KAAK;IA6BjD;;;;;OAKG;IACH,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAiBjC;;;;;OAKG;IACH,QAAQ,IAAI,MAAM;CAanB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,sBAAsB,CAMjC;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,sBAAsB,CAKjC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options for creating a KeyringControllerError.
|
|
3
|
+
*/
|
|
4
|
+
export type KeyringControllerErrorOptions = {
|
|
5
|
+
/**
|
|
6
|
+
* The underlying error that caused this error (for error chaining).
|
|
7
|
+
* Uses the standard Error.cause property (ES2022).
|
|
8
|
+
*/
|
|
9
|
+
cause?: Error;
|
|
10
|
+
/**
|
|
11
|
+
* Optional error code for programmatic error handling.
|
|
12
|
+
* This can be used to identify specific error types without string matching.
|
|
13
|
+
*/
|
|
14
|
+
code?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Additional context data associated with the error.
|
|
17
|
+
* Useful for debugging and error reporting.
|
|
18
|
+
*/
|
|
19
|
+
context?: Record<string, unknown>;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Error class for KeyringController-related errors.
|
|
23
|
+
*
|
|
24
|
+
* This error class extends the standard Error class and supports:
|
|
25
|
+
* - Error chaining via the `cause` property (ES2022 standard)
|
|
26
|
+
* - Optional error codes for programmatic error handling
|
|
27
|
+
* - Additional context data for debugging
|
|
28
|
+
* - Backward compatibility with the legacy `originalError` property
|
|
29
|
+
*/
|
|
30
|
+
export declare class KeyringControllerError extends Error {
|
|
31
|
+
/**
|
|
32
|
+
* Optional error code for programmatic error handling.
|
|
33
|
+
*/
|
|
34
|
+
code?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Additional context data associated with the error.
|
|
37
|
+
*/
|
|
38
|
+
context?: Record<string, unknown>;
|
|
39
|
+
/**
|
|
40
|
+
* The underlying error that caused this error (ES2022 standard).
|
|
41
|
+
* This is set manually for compatibility with older TypeScript versions.
|
|
42
|
+
*/
|
|
43
|
+
cause?: Error;
|
|
44
|
+
/**
|
|
45
|
+
* @deprecated Use `cause` instead. This property is maintained for backward compatibility.
|
|
46
|
+
*/
|
|
47
|
+
originalError?: Error;
|
|
48
|
+
/**
|
|
49
|
+
* Creates a new KeyringControllerError.
|
|
50
|
+
*
|
|
51
|
+
* @param message - The error message.
|
|
52
|
+
* @param options - Error options or an Error object for backward compatibility.
|
|
53
|
+
*/
|
|
54
|
+
constructor(message: string, options?: KeyringControllerErrorOptions | Error);
|
|
55
|
+
/**
|
|
56
|
+
* Returns a JSON representation of the error.
|
|
57
|
+
* Useful for logging and error reporting.
|
|
58
|
+
*
|
|
59
|
+
* @returns JSON representation of the error.
|
|
60
|
+
*/
|
|
61
|
+
toJSON(): Record<string, unknown>;
|
|
62
|
+
/**
|
|
63
|
+
* Returns a string representation of the error chain.
|
|
64
|
+
* Includes all chained errors for better debugging.
|
|
65
|
+
*
|
|
66
|
+
* @returns String representation of the error chain.
|
|
67
|
+
*/
|
|
68
|
+
toString(): string;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Returns `true` if the error is a `KeyringControllerError`.
|
|
72
|
+
*
|
|
73
|
+
* Uses duck-typing on `error.name` rather than `instanceof` so that the check
|
|
74
|
+
* remains correct when multiple major versions of `@metamask/keyring-controller`
|
|
75
|
+
* coexist in the dependency tree (different versions produce different classes,
|
|
76
|
+
* so `instanceof` would return `false` for errors from another version).
|
|
77
|
+
*
|
|
78
|
+
* @param error - The value to check.
|
|
79
|
+
* @returns Whether the error is a `KeyringControllerError`.
|
|
80
|
+
*/
|
|
81
|
+
export declare function isKeyringControllerError(error: unknown): error is KeyringControllerError;
|
|
82
|
+
/**
|
|
83
|
+
* Returns `true` if the error is a `KeyringNotFound` error thrown by
|
|
84
|
+
* `KeyringController:withKeyring`. Use this to distinguish a missing keyring
|
|
85
|
+
* from other failures and apply fallback logic.
|
|
86
|
+
*
|
|
87
|
+
* @param error - The value to check.
|
|
88
|
+
* @returns Whether the error is a `KeyringNotFound` error.
|
|
89
|
+
*/
|
|
90
|
+
export declare function isKeyringNotFoundError(error: unknown): error is KeyringControllerError;
|
|
91
|
+
//# sourceMappingURL=errors.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.mts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,MAAM,6BAA6B,GAAG;IAC1C;;;OAGG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC;IACd;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC,CAAC;AAEF;;;;;;;;GAQG;AACH,qBAAa,sBAAuB,SAAQ,KAAK;IAC/C;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAElC;;;OAGG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC;IAEd;;OAEG;IACH,aAAa,CAAC,EAAE,KAAK,CAAC;IAEtB;;;;;OAKG;gBAED,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,6BAA6B,GAAG,KAAK;IA6BjD;;;;;OAKG;IACH,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAiBjC;;;;;OAKG;IACH,QAAQ,IAAI,MAAM;CAanB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,sBAAsB,CAMjC;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,sBAAsB,CAKjC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { KeyringControllerErrorMessage } from
|
|
1
|
+
import { KeyringControllerErrorMessage } from "./constants.mjs";
|
|
2
2
|
/**
|
|
3
3
|
* Error class for KeyringController-related errors.
|
|
4
4
|
*
|
|
@@ -105,4 +105,4 @@ export function isKeyringNotFoundError(error) {
|
|
|
105
105
|
return (isKeyringControllerError(error) &&
|
|
106
106
|
error.message === KeyringControllerErrorMessage.KeyringNotFound);
|
|
107
107
|
}
|
|
108
|
-
//# sourceMappingURL=errors.
|
|
108
|
+
//# sourceMappingURL=errors.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.mjs","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,wBAAuB;AAuB/D;;;;;;;;GAQG;AACH,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAsB/C;;;;;OAKG;IACH,YACE,OAAe,EACf,OAA+C;QAE/C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;QAErC,2FAA2F;QAC3F,MAAM,KAAK,GAAG,OAAO,YAAY,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,EAAE,KAAK,CAAC;QAClE,MAAM,IAAI,GAAG,OAAO,YAAY,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,EAAE,IAAI,CAAC;QAClE,MAAM,OAAO,GAAG,OAAO,YAAY,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC;QAExE,0DAA0D;QAC1D,IAAI,KAAK,EAAE,CAAC;YACV,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;YACnB,qDAAqD;YACrD,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC;QAC7B,CAAC;QAED,gCAAgC;QAChC,IAAI,IAAI,EAAE,CAAC;YACT,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACnB,CAAC;QACD,IAAI,OAAO,EAAE,CAAC;YACZ,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACzB,CAAC;QAED,sDAAsD;QACtD,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,sBAAsB,CAAC,SAAS,CAAC,CAAC;IAChE,CAAC;IAED;;;;;OAKG;IACH,MAAM;QACJ,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,KAAK,EAAE,IAAI,CAAC,KAAK;gBACf,CAAC,CAAC;oBACE,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI;oBACrB,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO;oBAC3B,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK;iBACxB;gBACH,CAAC,CAAC,SAAS;SACd,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACH,QAAQ;QACN,IAAI,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,OAAO,EAAE,CAAC;QAE7C,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YACd,MAAM,IAAI,KAAK,IAAI,CAAC,IAAI,GAAG,CAAC;QAC9B,CAAC;QAED,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,kBAAkB,IAAI,CAAC,KAAK,EAAE,CAAC;QAC3C,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,wBAAwB,CACtC,KAAc;IAEd,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACb,KAA4B,CAAC,IAAI,KAAK,wBAAwB,CAChE,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,sBAAsB,CACpC,KAAc;IAEd,OAAO,CACL,wBAAwB,CAAC,KAAK,CAAC;QAC/B,KAAK,CAAC,OAAO,KAAK,6BAA6B,CAAC,eAAe,CAChE,CAAC;AACJ,CAAC","sourcesContent":["import { KeyringControllerErrorMessage } from './constants.js';\n\n/**\n * Options for creating a KeyringControllerError.\n */\nexport type KeyringControllerErrorOptions = {\n /**\n * The underlying error that caused this error (for error chaining).\n * Uses the standard Error.cause property (ES2022).\n */\n cause?: Error;\n /**\n * Optional error code for programmatic error handling.\n * This can be used to identify specific error types without string matching.\n */\n code?: string;\n /**\n * Additional context data associated with the error.\n * Useful for debugging and error reporting.\n */\n context?: Record<string, unknown>;\n};\n\n/**\n * Error class for KeyringController-related errors.\n *\n * This error class extends the standard Error class and supports:\n * - Error chaining via the `cause` property (ES2022 standard)\n * - Optional error codes for programmatic error handling\n * - Additional context data for debugging\n * - Backward compatibility with the legacy `originalError` property\n */\nexport class KeyringControllerError extends Error {\n /**\n * Optional error code for programmatic error handling.\n */\n code?: string;\n\n /**\n * Additional context data associated with the error.\n */\n context?: Record<string, unknown>;\n\n /**\n * The underlying error that caused this error (ES2022 standard).\n * This is set manually for compatibility with older TypeScript versions.\n */\n cause?: Error;\n\n /**\n * @deprecated Use `cause` instead. This property is maintained for backward compatibility.\n */\n originalError?: Error;\n\n /**\n * Creates a new KeyringControllerError.\n *\n * @param message - The error message.\n * @param options - Error options or an Error object for backward compatibility.\n */\n constructor(\n message: string,\n options?: KeyringControllerErrorOptions | Error,\n ) {\n super(message);\n this.name = 'KeyringControllerError';\n\n // Support both new signature (options object) and legacy signature (Error as second param)\n const cause = options instanceof Error ? options : options?.cause;\n const code = options instanceof Error ? undefined : options?.code;\n const context = options instanceof Error ? undefined : options?.context;\n\n // Set cause property for error chaining (ES2022 standard)\n if (cause) {\n this.cause = cause;\n // Maintain backward compatibility with originalError\n this.originalError = cause;\n }\n\n // Set code and data if provided\n if (code) {\n this.code = code;\n }\n if (context) {\n this.context = context;\n }\n\n // Ensure proper prototype chain for instanceof checks\n Object.setPrototypeOf(this, KeyringControllerError.prototype);\n }\n\n /**\n * Returns a JSON representation of the error.\n * Useful for logging and error reporting.\n *\n * @returns JSON representation of the error.\n */\n toJSON(): Record<string, unknown> {\n return {\n name: this.name,\n message: this.message,\n code: this.code,\n context: this.context,\n stack: this.stack,\n cause: this.cause\n ? {\n name: this.cause.name,\n message: this.cause.message,\n stack: this.cause.stack,\n }\n : undefined,\n };\n }\n\n /**\n * Returns a string representation of the error chain.\n * Includes all chained errors for better debugging.\n *\n * @returns String representation of the error chain.\n */\n toString(): string {\n let result = `${this.name}: ${this.message}`;\n\n if (this.code) {\n result += ` [${this.code}]`;\n }\n\n if (this.cause) {\n result += `\\n Caused by: ${this.cause}`;\n }\n\n return result;\n }\n}\n\n/**\n * Returns `true` if the error is a `KeyringControllerError`.\n *\n * Uses duck-typing on `error.name` rather than `instanceof` so that the check\n * remains correct when multiple major versions of `@metamask/keyring-controller`\n * coexist in the dependency tree (different versions produce different classes,\n * so `instanceof` would return `false` for errors from another version).\n *\n * @param error - The value to check.\n * @returns Whether the error is a `KeyringControllerError`.\n */\nexport function isKeyringControllerError(\n error: unknown,\n): error is KeyringControllerError {\n return (\n typeof error === 'object' &&\n error !== null &&\n (error as { name?: unknown }).name === 'KeyringControllerError'\n );\n}\n\n/**\n * Returns `true` if the error is a `KeyringNotFound` error thrown by\n * `KeyringController:withKeyring`. Use this to distinguish a missing keyring\n * from other failures and apply fallback logic.\n *\n * @param error - The value to check.\n * @returns Whether the error is a `KeyringNotFound` error.\n */\nexport function isKeyringNotFoundError(\n error: unknown,\n): error is KeyringControllerError {\n return (\n isKeyringControllerError(error) &&\n error.message === KeyringControllerErrorMessage.KeyringNotFound\n );\n}\n"]}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.KeyringControllerErrorMessage = void 0;
|
|
18
|
+
__exportStar(require("./KeyringController.cjs"), exports);
|
|
19
|
+
__exportStar(require("./errors.cjs"), exports);
|
|
20
|
+
var constants_js_1 = require("./constants.cjs");
|
|
21
|
+
Object.defineProperty(exports, "KeyringControllerErrorMessage", { enumerable: true, get: function () { return constants_js_1.KeyringControllerErrorMessage; } });
|
|
22
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,0DAAuC;AAuCvC,+CAA4B;AAC5B,gDAA+D;AAAtD,6HAAA,6BAA6B,OAAA","sourcesContent":["export * from './KeyringController.js';\nexport type {\n KeyringControllerAddNewAccountAction,\n KeyringControllerCreateNewVaultAndRestoreAction,\n KeyringControllerCreateNewVaultAndKeychainAction,\n KeyringControllerAddNewKeyringAction,\n KeyringControllerIsUnlockedAction,\n KeyringControllerGetAccountsAction,\n KeyringControllerGetEncryptionPublicKeyAction,\n KeyringControllerDecryptMessageAction,\n KeyringControllerGetKeyringForAccountAction,\n KeyringControllerGetKeyringsByTypeAction,\n KeyringControllerPersistAllKeyringsAction,\n KeyringControllerRemoveAccountAction,\n KeyringControllerSignMessageAction,\n KeyringControllerSignEip7702AuthorizationAction,\n KeyringControllerSignPersonalMessageAction,\n KeyringControllerSignTransactionAction,\n KeyringControllerSignTypedMessageAction,\n KeyringControllerPrepareUserOperationAction,\n KeyringControllerPatchUserOperationAction,\n KeyringControllerSignUserOperationAction,\n KeyringControllerWithControllerAction,\n KeyringControllerWithKeyringAction,\n KeyringControllerWithKeyringUnsafeAction,\n KeyringControllerWithKeyringV2Action,\n KeyringControllerWithKeyringV2UnsafeAction,\n KeyringControllerExportSeedPhraseAction,\n KeyringControllerVerifyPasswordAction,\n KeyringControllerExportAccountAction,\n KeyringControllerImportAccountWithStrategyAction,\n KeyringControllerSetLockedAction,\n KeyringControllerChangePasswordAction,\n KeyringControllerSubmitEncryptionKeyAction,\n KeyringControllerExportEncryptionKeyAction,\n KeyringControllerSubmitPasswordAction,\n KeyringControllerGetAccountKeyringTypeAction,\n} from './KeyringController-method-action-types.js';\nexport type * from './types.js';\nexport * from './errors.js';\nexport { KeyringControllerErrorMessage } from './constants.js';\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export type { KeyringControllerAddNewAccountAction, KeyringControllerCreateNewVaultAndRestoreAction, KeyringControllerCreateNewVaultAndKeychainAction, KeyringControllerAddNewKeyringAction, KeyringControllerIsUnlockedAction, KeyringControllerGetAccountsAction, KeyringControllerGetEncryptionPublicKeyAction, KeyringControllerDecryptMessageAction, KeyringControllerGetKeyringForAccountAction, KeyringControllerGetKeyringsByTypeAction, KeyringControllerPersistAllKeyringsAction, KeyringControllerRemoveAccountAction, KeyringControllerSignMessageAction, KeyringControllerSignEip7702AuthorizationAction, KeyringControllerSignPersonalMessageAction, KeyringControllerSignTransactionAction, KeyringControllerSignTypedMessageAction, KeyringControllerPrepareUserOperationAction, KeyringControllerPatchUserOperationAction, KeyringControllerSignUserOperationAction, KeyringControllerWithControllerAction, KeyringControllerWithKeyringAction, KeyringControllerWithKeyringUnsafeAction, KeyringControllerWithKeyringV2Action, KeyringControllerWithKeyringV2UnsafeAction, KeyringControllerExportSeedPhraseAction, KeyringControllerVerifyPasswordAction, KeyringControllerExportAccountAction, KeyringControllerImportAccountWithStrategyAction, KeyringControllerSetLockedAction, KeyringControllerChangePasswordAction, KeyringControllerSubmitEncryptionKeyAction, KeyringControllerExportEncryptionKeyAction, KeyringControllerSubmitPasswordAction, KeyringControllerGetAccountKeyringTypeAction, } from
|
|
3
|
-
export type * from
|
|
4
|
-
export * from
|
|
5
|
-
export { KeyringControllerErrorMessage } from
|
|
6
|
-
//# sourceMappingURL=index.d.
|
|
1
|
+
export * from "./KeyringController.cjs";
|
|
2
|
+
export type { KeyringControllerAddNewAccountAction, KeyringControllerCreateNewVaultAndRestoreAction, KeyringControllerCreateNewVaultAndKeychainAction, KeyringControllerAddNewKeyringAction, KeyringControllerIsUnlockedAction, KeyringControllerGetAccountsAction, KeyringControllerGetEncryptionPublicKeyAction, KeyringControllerDecryptMessageAction, KeyringControllerGetKeyringForAccountAction, KeyringControllerGetKeyringsByTypeAction, KeyringControllerPersistAllKeyringsAction, KeyringControllerRemoveAccountAction, KeyringControllerSignMessageAction, KeyringControllerSignEip7702AuthorizationAction, KeyringControllerSignPersonalMessageAction, KeyringControllerSignTransactionAction, KeyringControllerSignTypedMessageAction, KeyringControllerPrepareUserOperationAction, KeyringControllerPatchUserOperationAction, KeyringControllerSignUserOperationAction, KeyringControllerWithControllerAction, KeyringControllerWithKeyringAction, KeyringControllerWithKeyringUnsafeAction, KeyringControllerWithKeyringV2Action, KeyringControllerWithKeyringV2UnsafeAction, KeyringControllerExportSeedPhraseAction, KeyringControllerVerifyPasswordAction, KeyringControllerExportAccountAction, KeyringControllerImportAccountWithStrategyAction, KeyringControllerSetLockedAction, KeyringControllerChangePasswordAction, KeyringControllerSubmitEncryptionKeyAction, KeyringControllerExportEncryptionKeyAction, KeyringControllerSubmitPasswordAction, KeyringControllerGetAccountKeyringTypeAction, } from "./KeyringController-method-action-types.cjs";
|
|
3
|
+
export type * from "./types.cjs";
|
|
4
|
+
export * from "./errors.cjs";
|
|
5
|
+
export { KeyringControllerErrorMessage } from "./constants.cjs";
|
|
6
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wCAAuC;AACvC,YAAY,EACV,oCAAoC,EACpC,+CAA+C,EAC/C,gDAAgD,EAChD,oCAAoC,EACpC,iCAAiC,EACjC,kCAAkC,EAClC,6CAA6C,EAC7C,qCAAqC,EACrC,2CAA2C,EAC3C,wCAAwC,EACxC,yCAAyC,EACzC,oCAAoC,EACpC,kCAAkC,EAClC,+CAA+C,EAC/C,0CAA0C,EAC1C,sCAAsC,EACtC,uCAAuC,EACvC,2CAA2C,EAC3C,yCAAyC,EACzC,wCAAwC,EACxC,qCAAqC,EACrC,kCAAkC,EAClC,wCAAwC,EACxC,oCAAoC,EACpC,0CAA0C,EAC1C,uCAAuC,EACvC,qCAAqC,EACrC,oCAAoC,EACpC,gDAAgD,EAChD,gCAAgC,EAChC,qCAAqC,EACrC,0CAA0C,EAC1C,0CAA0C,EAC1C,qCAAqC,EACrC,4CAA4C,GAC7C,oDAAmD;AACpD,iCAAgC;AAChC,6BAA4B;AAC5B,OAAO,EAAE,6BAA6B,EAAE,wBAAuB"}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from "./KeyringController.mjs";
|
|
2
|
+
export type { KeyringControllerAddNewAccountAction, KeyringControllerCreateNewVaultAndRestoreAction, KeyringControllerCreateNewVaultAndKeychainAction, KeyringControllerAddNewKeyringAction, KeyringControllerIsUnlockedAction, KeyringControllerGetAccountsAction, KeyringControllerGetEncryptionPublicKeyAction, KeyringControllerDecryptMessageAction, KeyringControllerGetKeyringForAccountAction, KeyringControllerGetKeyringsByTypeAction, KeyringControllerPersistAllKeyringsAction, KeyringControllerRemoveAccountAction, KeyringControllerSignMessageAction, KeyringControllerSignEip7702AuthorizationAction, KeyringControllerSignPersonalMessageAction, KeyringControllerSignTransactionAction, KeyringControllerSignTypedMessageAction, KeyringControllerPrepareUserOperationAction, KeyringControllerPatchUserOperationAction, KeyringControllerSignUserOperationAction, KeyringControllerWithControllerAction, KeyringControllerWithKeyringAction, KeyringControllerWithKeyringUnsafeAction, KeyringControllerWithKeyringV2Action, KeyringControllerWithKeyringV2UnsafeAction, KeyringControllerExportSeedPhraseAction, KeyringControllerVerifyPasswordAction, KeyringControllerExportAccountAction, KeyringControllerImportAccountWithStrategyAction, KeyringControllerSetLockedAction, KeyringControllerChangePasswordAction, KeyringControllerSubmitEncryptionKeyAction, KeyringControllerExportEncryptionKeyAction, KeyringControllerSubmitPasswordAction, KeyringControllerGetAccountKeyringTypeAction, } from "./KeyringController-method-action-types.mjs";
|
|
3
|
+
export type * from "./types.mjs";
|
|
4
|
+
export * from "./errors.mjs";
|
|
5
|
+
export { KeyringControllerErrorMessage } from "./constants.mjs";
|
|
6
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wCAAuC;AACvC,YAAY,EACV,oCAAoC,EACpC,+CAA+C,EAC/C,gDAAgD,EAChD,oCAAoC,EACpC,iCAAiC,EACjC,kCAAkC,EAClC,6CAA6C,EAC7C,qCAAqC,EACrC,2CAA2C,EAC3C,wCAAwC,EACxC,yCAAyC,EACzC,oCAAoC,EACpC,kCAAkC,EAClC,+CAA+C,EAC/C,0CAA0C,EAC1C,sCAAsC,EACtC,uCAAuC,EACvC,2CAA2C,EAC3C,yCAAyC,EACzC,wCAAwC,EACxC,qCAAqC,EACrC,kCAAkC,EAClC,wCAAwC,EACxC,oCAAoC,EACpC,0CAA0C,EAC1C,uCAAuC,EACvC,qCAAqC,EACrC,oCAAoC,EACpC,gDAAgD,EAChD,gCAAgC,EAChC,qCAAqC,EACrC,0CAA0C,EAC1C,0CAA0C,EAC1C,qCAAqC,EACrC,4CAA4C,GAC7C,oDAAmD;AACpD,iCAAgC;AAChC,6BAA4B;AAC5B,OAAO,EAAE,6BAA6B,EAAE,wBAAuB"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wCAAuC;AAuCvC,6BAA4B;AAC5B,OAAO,EAAE,6BAA6B,EAAE,wBAAuB","sourcesContent":["export * from './KeyringController.js';\nexport type {\n KeyringControllerAddNewAccountAction,\n KeyringControllerCreateNewVaultAndRestoreAction,\n KeyringControllerCreateNewVaultAndKeychainAction,\n KeyringControllerAddNewKeyringAction,\n KeyringControllerIsUnlockedAction,\n KeyringControllerGetAccountsAction,\n KeyringControllerGetEncryptionPublicKeyAction,\n KeyringControllerDecryptMessageAction,\n KeyringControllerGetKeyringForAccountAction,\n KeyringControllerGetKeyringsByTypeAction,\n KeyringControllerPersistAllKeyringsAction,\n KeyringControllerRemoveAccountAction,\n KeyringControllerSignMessageAction,\n KeyringControllerSignEip7702AuthorizationAction,\n KeyringControllerSignPersonalMessageAction,\n KeyringControllerSignTransactionAction,\n KeyringControllerSignTypedMessageAction,\n KeyringControllerPrepareUserOperationAction,\n KeyringControllerPatchUserOperationAction,\n KeyringControllerSignUserOperationAction,\n KeyringControllerWithControllerAction,\n KeyringControllerWithKeyringAction,\n KeyringControllerWithKeyringUnsafeAction,\n KeyringControllerWithKeyringV2Action,\n KeyringControllerWithKeyringV2UnsafeAction,\n KeyringControllerExportSeedPhraseAction,\n KeyringControllerVerifyPasswordAction,\n KeyringControllerExportAccountAction,\n KeyringControllerImportAccountWithStrategyAction,\n KeyringControllerSetLockedAction,\n KeyringControllerChangePasswordAction,\n KeyringControllerSubmitEncryptionKeyAction,\n KeyringControllerExportEncryptionKeyAction,\n KeyringControllerSubmitPasswordAction,\n KeyringControllerGetAccountKeyringTypeAction,\n} from './KeyringController-method-action-types.js';\nexport type * from './types.js';\nexport * from './errors.js';\nexport { KeyringControllerErrorMessage } from './constants.js';\n"]}
|
package/dist/types.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { SIWEMessage } from '@metamask/controller-utils';\n\n/**\n * AbstractMessageParams\n *\n * Represents the parameters to pass to the signing method once the signature request is approved.\n *\n * from - Address from which the message is processed\n * origin? - Added for request origin identification\n * requestId? - Original request id\n * deferSetAsSigned? - Whether to defer setting the message as signed immediately after the keyring is told to sign it\n */\nexport type AbstractMessageParams = {\n from: string;\n origin?: string;\n requestId?: number;\n deferSetAsSigned?: boolean;\n};\n\n/**\n * Eip7702AuthorizationParams\n *\n * Represents the parameters for EIP-7702 authorization signing requests.\n *\n * chainId - The chain ID\n * contractAddress - The contract address\n * nonce - The nonce\n */\nexport type Eip7702AuthorizationParams = {\n chainId: number;\n contractAddress: string;\n nonce: number;\n} & AbstractMessageParams;\n\n/**\n * PersonalMessageParams\n *\n * Represents the parameters for personal signing messages.\n *\n * data - The data to sign\n * siwe? - The SIWE message\n */\nexport type PersonalMessageParams = {\n data: string;\n siwe?: SIWEMessage;\n} & AbstractMessageParams;\n\n/**\n * SignTypedDataMessageV3V4\n *\n * Represents the structure of a typed data message for EIP-712 signing requests.\n *\n * types - The types of the message\n * domain - The domain of the message\n * primaryType - The primary type of the message\n * message - The message\n */\nexport type SignTypedDataMessageV3V4 = {\n types: Record<string, unknown>;\n domain: Record<string, unknown>;\n primaryType: string;\n message: unknown;\n};\n\n/**\n * TypedMessageParams\n *\n * Represents the parameters for typed signing messages.\n *\n * data - The data to sign\n */\nexport type TypedMessageParams = {\n data: Record<string, unknown>[] | string | SignTypedDataMessageV3V4;\n} & AbstractMessageParams;\n\n/**\n * Credentials for re-authenticating the keyring during sensitive operations\n * such as `exportSeedPhrase` and `exportAccount`.\n */\nexport type Credentials =\n | { password: string }\n | { encryptionKey: string; encryptionSalt?: string };\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SIWEMessage } from
|
|
1
|
+
import type { SIWEMessage } from "@metamask/controller-utils";
|
|
2
2
|
/**
|
|
3
3
|
* AbstractMessageParams
|
|
4
4
|
*
|
|
@@ -77,4 +77,4 @@ export type Credentials = {
|
|
|
77
77
|
encryptionKey: string;
|
|
78
78
|
encryptionSalt?: string;
|
|
79
79
|
};
|
|
80
|
-
//# sourceMappingURL=types.d.
|
|
80
|
+
//# sourceMappingURL=types.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,mCAAmC;AAE9D;;;;;;;;;GASG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;CACf,GAAG,qBAAqB,CAAC;AAE1B;;;;;;;GAOG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,WAAW,CAAC;CACpB,GAAG,qBAAqB,CAAC;AAE1B;;;;;;;;;GASG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACrC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,MAAM,GAAG,wBAAwB,CAAC;CACrE,GAAG,qBAAqB,CAAC;AAE1B;;;GAGG;AACH,MAAM,MAAM,WAAW,GACnB;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,GACpB;IAAE,aAAa,EAAE,MAAM,CAAC;IAAC,cAAc,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC"}
|
package/dist/types.d.mts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { SIWEMessage } from "@metamask/controller-utils";
|
|
2
|
+
/**
|
|
3
|
+
* AbstractMessageParams
|
|
4
|
+
*
|
|
5
|
+
* Represents the parameters to pass to the signing method once the signature request is approved.
|
|
6
|
+
*
|
|
7
|
+
* from - Address from which the message is processed
|
|
8
|
+
* origin? - Added for request origin identification
|
|
9
|
+
* requestId? - Original request id
|
|
10
|
+
* deferSetAsSigned? - Whether to defer setting the message as signed immediately after the keyring is told to sign it
|
|
11
|
+
*/
|
|
12
|
+
export type AbstractMessageParams = {
|
|
13
|
+
from: string;
|
|
14
|
+
origin?: string;
|
|
15
|
+
requestId?: number;
|
|
16
|
+
deferSetAsSigned?: boolean;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Eip7702AuthorizationParams
|
|
20
|
+
*
|
|
21
|
+
* Represents the parameters for EIP-7702 authorization signing requests.
|
|
22
|
+
*
|
|
23
|
+
* chainId - The chain ID
|
|
24
|
+
* contractAddress - The contract address
|
|
25
|
+
* nonce - The nonce
|
|
26
|
+
*/
|
|
27
|
+
export type Eip7702AuthorizationParams = {
|
|
28
|
+
chainId: number;
|
|
29
|
+
contractAddress: string;
|
|
30
|
+
nonce: number;
|
|
31
|
+
} & AbstractMessageParams;
|
|
32
|
+
/**
|
|
33
|
+
* PersonalMessageParams
|
|
34
|
+
*
|
|
35
|
+
* Represents the parameters for personal signing messages.
|
|
36
|
+
*
|
|
37
|
+
* data - The data to sign
|
|
38
|
+
* siwe? - The SIWE message
|
|
39
|
+
*/
|
|
40
|
+
export type PersonalMessageParams = {
|
|
41
|
+
data: string;
|
|
42
|
+
siwe?: SIWEMessage;
|
|
43
|
+
} & AbstractMessageParams;
|
|
44
|
+
/**
|
|
45
|
+
* SignTypedDataMessageV3V4
|
|
46
|
+
*
|
|
47
|
+
* Represents the structure of a typed data message for EIP-712 signing requests.
|
|
48
|
+
*
|
|
49
|
+
* types - The types of the message
|
|
50
|
+
* domain - The domain of the message
|
|
51
|
+
* primaryType - The primary type of the message
|
|
52
|
+
* message - The message
|
|
53
|
+
*/
|
|
54
|
+
export type SignTypedDataMessageV3V4 = {
|
|
55
|
+
types: Record<string, unknown>;
|
|
56
|
+
domain: Record<string, unknown>;
|
|
57
|
+
primaryType: string;
|
|
58
|
+
message: unknown;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* TypedMessageParams
|
|
62
|
+
*
|
|
63
|
+
* Represents the parameters for typed signing messages.
|
|
64
|
+
*
|
|
65
|
+
* data - The data to sign
|
|
66
|
+
*/
|
|
67
|
+
export type TypedMessageParams = {
|
|
68
|
+
data: Record<string, unknown>[] | string | SignTypedDataMessageV3V4;
|
|
69
|
+
} & AbstractMessageParams;
|
|
70
|
+
/**
|
|
71
|
+
* Credentials for re-authenticating the keyring during sensitive operations
|
|
72
|
+
* such as `exportSeedPhrase` and `exportAccount`.
|
|
73
|
+
*/
|
|
74
|
+
export type Credentials = {
|
|
75
|
+
password: string;
|
|
76
|
+
} | {
|
|
77
|
+
encryptionKey: string;
|
|
78
|
+
encryptionSalt?: string;
|
|
79
|
+
};
|
|
80
|
+
//# sourceMappingURL=types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,mCAAmC;AAE9D;;;;;;;;;GASG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;CACf,GAAG,qBAAqB,CAAC;AAE1B;;;;;;;GAOG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,WAAW,CAAC;CACpB,GAAG,qBAAqB,CAAC;AAE1B;;;;;;;;;GASG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACrC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,MAAM,GAAG,wBAAwB,CAAC;CACrE,GAAG,qBAAqB,CAAC;AAE1B;;;GAGG;AACH,MAAM,MAAM,WAAW,GACnB;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,GACpB;IAAE,aAAa,EAAE,MAAM,CAAC;IAAC,cAAc,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC"}
|
package/dist/types.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { SIWEMessage } from '@metamask/controller-utils';\n\n/**\n * AbstractMessageParams\n *\n * Represents the parameters to pass to the signing method once the signature request is approved.\n *\n * from - Address from which the message is processed\n * origin? - Added for request origin identification\n * requestId? - Original request id\n * deferSetAsSigned? - Whether to defer setting the message as signed immediately after the keyring is told to sign it\n */\nexport type AbstractMessageParams = {\n from: string;\n origin?: string;\n requestId?: number;\n deferSetAsSigned?: boolean;\n};\n\n/**\n * Eip7702AuthorizationParams\n *\n * Represents the parameters for EIP-7702 authorization signing requests.\n *\n * chainId - The chain ID\n * contractAddress - The contract address\n * nonce - The nonce\n */\nexport type Eip7702AuthorizationParams = {\n chainId: number;\n contractAddress: string;\n nonce: number;\n} & AbstractMessageParams;\n\n/**\n * PersonalMessageParams\n *\n * Represents the parameters for personal signing messages.\n *\n * data - The data to sign\n * siwe? - The SIWE message\n */\nexport type PersonalMessageParams = {\n data: string;\n siwe?: SIWEMessage;\n} & AbstractMessageParams;\n\n/**\n * SignTypedDataMessageV3V4\n *\n * Represents the structure of a typed data message for EIP-712 signing requests.\n *\n * types - The types of the message\n * domain - The domain of the message\n * primaryType - The primary type of the message\n * message - The message\n */\nexport type SignTypedDataMessageV3V4 = {\n types: Record<string, unknown>;\n domain: Record<string, unknown>;\n primaryType: string;\n message: unknown;\n};\n\n/**\n * TypedMessageParams\n *\n * Represents the parameters for typed signing messages.\n *\n * data - The data to sign\n */\nexport type TypedMessageParams = {\n data: Record<string, unknown>[] | string | SignTypedDataMessageV3V4;\n} & AbstractMessageParams;\n\n/**\n * Credentials for re-authenticating the keyring during sensitive operations\n * such as `exportSeedPhrase` and `exportAccount`.\n */\nexport type Credentials =\n | { password: string }\n | { encryptionKey: string; encryptionSalt?: string };\n"]}
|