@metamask-previews/gator-permissions-controller 0.0.0-preview-2a00636 → 0.1.0-preview-d71561e3
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 +4 -1
- package/dist/GatorPermissionsController.cjs +4 -2
- package/dist/GatorPermissionsController.cjs.map +1 -1
- package/dist/GatorPermissionsController.d.cts.map +1 -1
- package/dist/GatorPermissionsController.d.mts.map +1 -1
- package/dist/GatorPermissionsController.mjs +4 -2
- package/dist/GatorPermissionsController.mjs.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/test/mocks.cjs +10 -25
- package/dist/test/mocks.cjs.map +1 -1
- package/dist/test/mocks.d.cts +3 -2
- package/dist/test/mocks.d.cts.map +1 -1
- package/dist/test/mocks.d.mts +3 -2
- package/dist/test/mocks.d.mts.map +1 -1
- package/dist/test/mocks.mjs +10 -25
- package/dist/test/mocks.mjs.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +19 -94
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +19 -94
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/package.json +8 -2
package/dist/types.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { PermissionTypes, Signer, BasePermission, NativeTokenStreamPermission, NativeTokenPeriodicPermission, Erc20TokenStreamPermission, Erc20TokenPeriodicPermission, Rule, MetaMaskBasePermissionData } from "@metamask/7715-permission-types";
|
|
1
2
|
import type { Hex } from "@metamask/utils";
|
|
2
3
|
/**
|
|
3
4
|
* Enum for the error codes of the gator permissions controller.
|
|
@@ -17,92 +18,24 @@ export declare enum GatorPermissionsSnapRpcMethod {
|
|
|
17
18
|
*/
|
|
18
19
|
PermissionProviderGetGrantedPermissions = "permissionsProvider_getGrantedPermissions"
|
|
19
20
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
* Data structure varies by permission type.
|
|
24
|
-
*/
|
|
25
|
-
data: Record<string, unknown>;
|
|
26
|
-
/**
|
|
27
|
-
* set of restrictions or conditions that a signer must abide by when redeeming a Permission.
|
|
28
|
-
*/
|
|
29
|
-
rules?: Record<string, unknown>;
|
|
30
|
-
};
|
|
31
|
-
export type MetaMaskBasePermissionData = {
|
|
32
|
-
/**
|
|
33
|
-
* A human-readable explanation of why the permission is being requested.
|
|
34
|
-
*/
|
|
35
|
-
justification: string;
|
|
36
|
-
};
|
|
37
|
-
export type NativeTokenStreamPermission = BasePermission & {
|
|
38
|
-
type: 'native-token-stream';
|
|
39
|
-
data: MetaMaskBasePermissionData & {
|
|
40
|
-
initialAmount?: Hex;
|
|
41
|
-
maxAmount?: Hex;
|
|
42
|
-
amountPerSecond: Hex;
|
|
43
|
-
startTime: number;
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
export type NativeTokenPeriodicPermission = BasePermission & {
|
|
47
|
-
type: 'native-token-periodic';
|
|
48
|
-
data: MetaMaskBasePermissionData & {
|
|
49
|
-
periodAmount: Hex;
|
|
50
|
-
periodDuration: number;
|
|
51
|
-
startTime: number;
|
|
52
|
-
};
|
|
53
|
-
};
|
|
54
|
-
export type Erc20TokenStreamPermission = BasePermission & {
|
|
55
|
-
type: 'erc20-token-stream';
|
|
56
|
-
data: MetaMaskBasePermissionData & {
|
|
57
|
-
initialAmount?: Hex;
|
|
58
|
-
maxAmount?: Hex;
|
|
59
|
-
amountPerSecond: Hex;
|
|
60
|
-
startTime: number;
|
|
61
|
-
tokenAddress: Hex;
|
|
62
|
-
};
|
|
63
|
-
};
|
|
64
|
-
export type Erc20TokenPeriodicPermission = BasePermission & {
|
|
65
|
-
type: 'erc20-token-periodic';
|
|
66
|
-
data: MetaMaskBasePermissionData & {
|
|
67
|
-
periodAmount: Hex;
|
|
68
|
-
periodDuration: number;
|
|
69
|
-
startTime: number;
|
|
70
|
-
tokenAddress: Hex;
|
|
71
|
-
};
|
|
72
|
-
};
|
|
21
|
+
/**
|
|
22
|
+
* Represents a custom permission that are not of the standard ERC-7715 permission types.
|
|
23
|
+
*/
|
|
73
24
|
export type CustomPermission = BasePermission & {
|
|
74
25
|
type: 'custom';
|
|
75
26
|
data: MetaMaskBasePermissionData & Record<string, unknown>;
|
|
76
27
|
};
|
|
77
28
|
/**
|
|
78
|
-
* Represents the type of the ERC-7715 permissions that can be granted.
|
|
79
|
-
*/
|
|
80
|
-
export type PermissionTypes = NativeTokenStreamPermission | NativeTokenPeriodicPermission | Erc20TokenStreamPermission | Erc20TokenPeriodicPermission | CustomPermission;
|
|
81
|
-
/**
|
|
82
|
-
* Represents an ERC-7715 account signer type.
|
|
29
|
+
* Represents the type of the ERC-7715 permissions that can be granted including custom permissions.
|
|
83
30
|
*/
|
|
84
|
-
export type
|
|
85
|
-
type: 'account';
|
|
86
|
-
data: {
|
|
87
|
-
address: Hex;
|
|
88
|
-
};
|
|
89
|
-
};
|
|
90
|
-
/**
|
|
91
|
-
* Represents an ERC-7715 wallet signer type.
|
|
92
|
-
*
|
|
93
|
-
*/
|
|
94
|
-
export type WalletSigner = {
|
|
95
|
-
type: 'wallet';
|
|
96
|
-
data: Record<string, unknown>;
|
|
97
|
-
};
|
|
98
|
-
export type SignerParam = AccountSigner | WalletSigner;
|
|
31
|
+
export type PermissionTypesWithCustom = PermissionTypes | CustomPermission;
|
|
99
32
|
/**
|
|
100
33
|
* Represents a ERC-7715 permission request.
|
|
101
34
|
*
|
|
102
35
|
* @template Signer - The type of the signer provided, either an AccountSigner or WalletSigner.
|
|
103
36
|
* @template Permission - The type of the permission provided.
|
|
104
37
|
*/
|
|
105
|
-
export type PermissionRequest<TSigner extends
|
|
38
|
+
export type PermissionRequest<TSigner extends Signer, TPermission extends PermissionTypesWithCustom> = {
|
|
106
39
|
/**
|
|
107
40
|
* hex-encoding of uint256 defined the chain with EIP-155
|
|
108
41
|
*/
|
|
@@ -113,14 +46,6 @@ export type PermissionRequest<TSigner extends SignerParam, TPermission extends P
|
|
|
113
46
|
* It is optional to let the user choose which account to grant permission from.
|
|
114
47
|
*/
|
|
115
48
|
address?: Hex;
|
|
116
|
-
/**
|
|
117
|
-
* unix timestamp in seconds
|
|
118
|
-
*/
|
|
119
|
-
expiry: number;
|
|
120
|
-
/**
|
|
121
|
-
* Boolean value that allows DApp to define whether the permission can be attenuated–adjusted to meet the user’s terms.
|
|
122
|
-
*/
|
|
123
|
-
isAdjustmentAllowed: boolean;
|
|
124
49
|
/**
|
|
125
50
|
* An account that is associated with the recipient of the granted 7715 permission or alternatively the wallet will manage the session.
|
|
126
51
|
*/
|
|
@@ -129,6 +54,7 @@ export type PermissionRequest<TSigner extends SignerParam, TPermission extends P
|
|
|
129
54
|
* Defines the allowed behavior the signer can do on behalf of the account.
|
|
130
55
|
*/
|
|
131
56
|
permission: TPermission;
|
|
57
|
+
rules?: Rule[] | null;
|
|
132
58
|
};
|
|
133
59
|
/**
|
|
134
60
|
* Represents a ERC-7715 permission response.
|
|
@@ -136,20 +62,20 @@ export type PermissionRequest<TSigner extends SignerParam, TPermission extends P
|
|
|
136
62
|
* @template Signer - The type of the signer provided, either an AccountSigner or WalletSigner.
|
|
137
63
|
* @template Permission - The type of the permission provided.
|
|
138
64
|
*/
|
|
139
|
-
export type PermissionResponse<TSigner extends
|
|
65
|
+
export type PermissionResponse<TSigner extends Signer, TPermission extends PermissionTypesWithCustom> = PermissionRequest<TSigner, TPermission> & {
|
|
140
66
|
/**
|
|
141
67
|
* Is a catch-all to identify a permission for revoking permissions or submitting
|
|
142
68
|
* Defined in ERC-7710.
|
|
143
69
|
*/
|
|
144
70
|
context: Hex;
|
|
145
71
|
/**
|
|
146
|
-
* The
|
|
72
|
+
* The dependencyInfo field is required and contains information needed to deploy accounts.
|
|
147
73
|
* Each entry specifies a factory contract and its associated deployment data.
|
|
148
74
|
* If no account deployment is needed when redeeming the permission, this array must be empty.
|
|
149
75
|
* When non-empty, DApps MUST deploy the accounts by calling the factory contract with factoryData as the calldata.
|
|
150
76
|
* Defined in ERC-4337.
|
|
151
77
|
*/
|
|
152
|
-
|
|
78
|
+
dependencyInfo: {
|
|
153
79
|
factory: Hex;
|
|
154
80
|
factoryData: Hex;
|
|
155
81
|
}[];
|
|
@@ -167,14 +93,14 @@ export type PermissionResponse<TSigner extends SignerParam, TPermission extends
|
|
|
167
93
|
* @template Signer - The type of the signer provided, either an AccountSigner or WalletSigner.
|
|
168
94
|
* @template Permission - The type of the permission provided.
|
|
169
95
|
*/
|
|
170
|
-
export type PermissionResponseSanitized<TSigner extends
|
|
96
|
+
export type PermissionResponseSanitized<TSigner extends Signer, TPermission extends PermissionTypesWithCustom> = Omit<PermissionResponse<TSigner, TPermission>, 'dependencyInfo' | 'signer' | 'rules'>;
|
|
171
97
|
/**
|
|
172
98
|
* Represents a gator ERC-7715 granted(ie. signed by an user account) permission entry that is stored in profile sync.
|
|
173
99
|
*
|
|
174
100
|
* @template Signer - The type of the signer provided, either an AccountSigner or WalletSigner.
|
|
175
101
|
* @template Permission - The type of the permission provided
|
|
176
102
|
*/
|
|
177
|
-
export type StoredGatorPermission<TSigner extends
|
|
103
|
+
export type StoredGatorPermission<TSigner extends Signer, TPermission extends PermissionTypesWithCustom> = {
|
|
178
104
|
permissionResponse: PermissionResponse<TSigner, TPermission>;
|
|
179
105
|
siteOrigin: string;
|
|
180
106
|
};
|
|
@@ -184,7 +110,7 @@ export type StoredGatorPermission<TSigner extends SignerParam, TPermission exten
|
|
|
184
110
|
* @template Signer - The type of the signer provided, either an AccountSigner or WalletSigner.
|
|
185
111
|
* @template Permission - The type of the permission provided.
|
|
186
112
|
*/
|
|
187
|
-
export type StoredGatorPermissionSanitized<TSigner extends
|
|
113
|
+
export type StoredGatorPermissionSanitized<TSigner extends Signer, TPermission extends PermissionTypesWithCustom> = {
|
|
188
114
|
permissionResponse: PermissionResponseSanitized<TSigner, TPermission>;
|
|
189
115
|
siteOrigin: string;
|
|
190
116
|
};
|
|
@@ -193,19 +119,19 @@ export type StoredGatorPermissionSanitized<TSigner extends SignerParam, TPermiss
|
|
|
193
119
|
*/
|
|
194
120
|
export type GatorPermissionsMap = {
|
|
195
121
|
'native-token-stream': {
|
|
196
|
-
[chainId: Hex]: StoredGatorPermissionSanitized<
|
|
122
|
+
[chainId: Hex]: StoredGatorPermissionSanitized<Signer, NativeTokenStreamPermission>[];
|
|
197
123
|
};
|
|
198
124
|
'native-token-periodic': {
|
|
199
|
-
[chainId: Hex]: StoredGatorPermissionSanitized<
|
|
125
|
+
[chainId: Hex]: StoredGatorPermissionSanitized<Signer, NativeTokenPeriodicPermission>[];
|
|
200
126
|
};
|
|
201
127
|
'erc20-token-stream': {
|
|
202
|
-
[chainId: Hex]: StoredGatorPermissionSanitized<
|
|
128
|
+
[chainId: Hex]: StoredGatorPermissionSanitized<Signer, Erc20TokenStreamPermission>[];
|
|
203
129
|
};
|
|
204
130
|
'erc20-token-periodic': {
|
|
205
|
-
[chainId: Hex]: StoredGatorPermissionSanitized<
|
|
131
|
+
[chainId: Hex]: StoredGatorPermissionSanitized<Signer, Erc20TokenPeriodicPermission>[];
|
|
206
132
|
};
|
|
207
133
|
other: {
|
|
208
|
-
[chainId: Hex]: StoredGatorPermissionSanitized<
|
|
134
|
+
[chainId: Hex]: StoredGatorPermissionSanitized<Signer, CustomPermission>[];
|
|
209
135
|
};
|
|
210
136
|
};
|
|
211
137
|
/**
|
|
@@ -220,5 +146,4 @@ export type GatorPermissionsMapByPermissionType<TPermissionType extends Supporte
|
|
|
220
146
|
* Represents an array of gator permissions for a given permission type and chainId.
|
|
221
147
|
*/
|
|
222
148
|
export type GatorPermissionsListByPermissionTypeAndChainId<TPermissionType extends SupportedGatorPermissionType> = GatorPermissionsMap[TPermissionType][Hex];
|
|
223
|
-
export {};
|
|
224
149
|
//# sourceMappingURL=types.d.mts.map
|
package/dist/types.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAE3C;;GAEG;AACH,oBAAY,mCAAmC;IAC7C,0BAA0B,kCAAkC;IAC5D,0BAA0B,kCAAkC;IAC5D,6BAA6B,qCAAqC;IAClE,qCAAqC,8CAA8C;CACpF;AAED;;GAEG;AACH,oBAAY,6BAA6B;IACvC;;OAEG;IACH,uCAAuC,8CAA8C;CACtF;AAED
|
|
1
|
+
{"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"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"}
|
package/dist/types.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAaA;;GAEG;AACH,MAAM,CAAN,IAAY,mCAKX;AALD,WAAY,mCAAmC;IAC7C,mGAA4D,CAAA;IAC5D,mGAA4D,CAAA;IAC5D,yGAAkE,CAAA;IAClE,0HAAmF,CAAA;AACrF,CAAC,EALW,mCAAmC,KAAnC,mCAAmC,QAK9C;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,6BAKX;AALD,WAAY,6BAA6B;IACvC;;OAEG;IACH,sHAAqF,CAAA;AACvF,CAAC,EALW,6BAA6B,KAA7B,6BAA6B,QAKxC","sourcesContent":["import type {\n PermissionTypes,\n Signer,\n BasePermission,\n NativeTokenStreamPermission,\n NativeTokenPeriodicPermission,\n Erc20TokenStreamPermission,\n Erc20TokenPeriodicPermission,\n Rule,\n MetaMaskBasePermissionData,\n} from '@metamask/7715-permission-types';\nimport type { Hex } from '@metamask/utils';\n\n/**\n * Enum for the error codes of the gator permissions controller.\n */\nexport enum GatorPermissionsControllerErrorCode {\n GatorPermissionsFetchError = 'gator-permissions-fetch-error',\n GatorPermissionsNotEnabled = 'gator-permissions-not-enabled',\n GatorPermissionsProviderError = 'gator-permissions-provider-error',\n GatorPermissionsMapSerializationError = 'gator-permissions-map-serialization-error',\n}\n\n/**\n * Enum for the RPC methods of the gator permissions provider snap.\n */\nexport enum GatorPermissionsSnapRpcMethod {\n /**\n * This method is used by the metamask to request a permissions provider to get granted permissions for all sites.\n */\n PermissionProviderGetGrantedPermissions = 'permissionsProvider_getGrantedPermissions',\n}\n\n/**\n * Represents a custom permission that are not of the standard ERC-7715 permission types.\n */\nexport type CustomPermission = BasePermission & {\n type: 'custom';\n data: MetaMaskBasePermissionData & Record<string, unknown>;\n};\n\n/**\n * Represents the type of the ERC-7715 permissions that can be granted including custom permissions.\n */\nexport type PermissionTypesWithCustom = PermissionTypes | CustomPermission;\n\n/**\n * Represents a ERC-7715 permission request.\n *\n * @template Signer - The type of the signer provided, either an AccountSigner or WalletSigner.\n * @template Permission - The type of the permission provided.\n */\nexport type PermissionRequest<\n TSigner extends Signer,\n TPermission extends PermissionTypesWithCustom,\n> = {\n /**\n * hex-encoding of uint256 defined the chain with EIP-155\n */\n chainId: Hex;\n\n /**\n *\n * The account being targeted for this permission request.\n * It is optional to let the user choose which account to grant permission from.\n */\n address?: Hex;\n\n /**\n * An account that is associated with the recipient of the granted 7715 permission or alternatively the wallet will manage the session.\n */\n signer: TSigner;\n\n /**\n * Defines the allowed behavior the signer can do on behalf of the account.\n */\n permission: TPermission;\n\n rules?: Rule[] | null;\n};\n\n/**\n * Represents a ERC-7715 permission response.\n *\n * @template Signer - The type of the signer provided, either an AccountSigner or WalletSigner.\n * @template Permission - The type of the permission provided.\n */\nexport type PermissionResponse<\n TSigner extends Signer,\n TPermission extends PermissionTypesWithCustom,\n> = PermissionRequest<TSigner, TPermission> & {\n /**\n * Is a catch-all to identify a permission for revoking permissions or submitting\n * Defined in ERC-7710.\n */\n context: Hex;\n\n /**\n * The dependencyInfo field is required and contains information needed to deploy accounts.\n * Each entry specifies a factory contract and its associated deployment data.\n * If no account deployment is needed when redeeming the permission, this array must be empty.\n * When non-empty, DApps MUST deploy the accounts by calling the factory contract with factoryData as the calldata.\n * Defined in ERC-4337.\n */\n dependencyInfo: {\n factory: Hex;\n factoryData: Hex;\n }[];\n\n /**\n * If the signer type is account then delegationManager is required as defined in ERC-7710.\n */\n signerMeta: {\n delegationManager: Hex;\n };\n};\n\n/**\n * Represents a sanitized version of the PermissionResponse type.\n * Some fields have been removed but the fields are still present in profile sync.\n *\n * @template Signer - The type of the signer provided, either an AccountSigner or WalletSigner.\n * @template Permission - The type of the permission provided.\n */\nexport type PermissionResponseSanitized<\n TSigner extends Signer,\n TPermission extends PermissionTypesWithCustom,\n> = Omit<\n PermissionResponse<TSigner, TPermission>,\n 'dependencyInfo' | 'signer' | 'rules'\n>;\n\n/**\n * Represents a gator ERC-7715 granted(ie. signed by an user account) permission entry that is stored in profile sync.\n *\n * @template Signer - The type of the signer provided, either an AccountSigner or WalletSigner.\n * @template Permission - The type of the permission provided\n */\nexport type StoredGatorPermission<\n TSigner extends Signer,\n TPermission extends PermissionTypesWithCustom,\n> = {\n permissionResponse: PermissionResponse<TSigner, TPermission>;\n siteOrigin: string;\n};\n\n/**\n * Represents a sanitized version of the StoredGatorPermission type. Some fields have been removed but the fields are still present in profile sync.\n *\n * @template Signer - The type of the signer provided, either an AccountSigner or WalletSigner.\n * @template Permission - The type of the permission provided.\n */\nexport type StoredGatorPermissionSanitized<\n TSigner extends Signer,\n TPermission extends PermissionTypesWithCustom,\n> = {\n permissionResponse: PermissionResponseSanitized<TSigner, TPermission>;\n siteOrigin: string;\n};\n\n/**\n * Represents a map of gator permissions by chainId and permission type.\n */\nexport type GatorPermissionsMap = {\n 'native-token-stream': {\n [chainId: Hex]: StoredGatorPermissionSanitized<\n Signer,\n NativeTokenStreamPermission\n >[];\n };\n 'native-token-periodic': {\n [chainId: Hex]: StoredGatorPermissionSanitized<\n Signer,\n NativeTokenPeriodicPermission\n >[];\n };\n 'erc20-token-stream': {\n [chainId: Hex]: StoredGatorPermissionSanitized<\n Signer,\n Erc20TokenStreamPermission\n >[];\n };\n 'erc20-token-periodic': {\n [chainId: Hex]: StoredGatorPermissionSanitized<\n Signer,\n Erc20TokenPeriodicPermission\n >[];\n };\n other: {\n [chainId: Hex]: StoredGatorPermissionSanitized<Signer, CustomPermission>[];\n };\n};\n\n/**\n * Represents the supported permission type(e.g. 'native-token-stream', 'native-token-periodic', 'erc20-token-stream', 'erc20-token-periodic') of the gator permissions map.\n */\nexport type SupportedGatorPermissionType = keyof GatorPermissionsMap;\n\n/**\n * Represents a map of gator permissions for a given permission type with key of chainId. The value being an array of gator permissions for that chainId.\n */\nexport type GatorPermissionsMapByPermissionType<\n TPermissionType extends SupportedGatorPermissionType,\n> = GatorPermissionsMap[TPermissionType];\n\n/**\n * Represents an array of gator permissions for a given permission type and chainId.\n */\nexport type GatorPermissionsListByPermissionTypeAndChainId<\n TPermissionType extends SupportedGatorPermissionType,\n> = GatorPermissionsMap[TPermissionType][Hex];\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask-previews/gator-permissions-controller",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.0-preview-d71561e3",
|
|
4
4
|
"description": "Controller for managing gator permissions with profile sync integration",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"MetaMask",
|
|
@@ -47,7 +47,8 @@
|
|
|
47
47
|
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@metamask/
|
|
50
|
+
"@metamask/7715-permission-types": "^0.3.0",
|
|
51
|
+
"@metamask/base-controller": "^8.3.0",
|
|
51
52
|
"@metamask/snaps-sdk": "^9.0.0",
|
|
52
53
|
"@metamask/snaps-utils": "^11.0.0",
|
|
53
54
|
"@metamask/utils": "^11.4.2"
|
|
@@ -75,5 +76,10 @@
|
|
|
75
76
|
"publishConfig": {
|
|
76
77
|
"access": "public",
|
|
77
78
|
"registry": "https://registry.npmjs.org/"
|
|
79
|
+
},
|
|
80
|
+
"lavamoat": {
|
|
81
|
+
"allowScripts": {
|
|
82
|
+
"@lavamoat/preinstall-always-fail": false
|
|
83
|
+
}
|
|
78
84
|
}
|
|
79
85
|
}
|