@metamask/gator-permissions-controller 0.8.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -1
- package/dist/GatorPermissionsController.cjs +2 -2
- package/dist/GatorPermissionsController.cjs.map +1 -1
- package/dist/GatorPermissionsController.d.cts +1 -1
- package/dist/GatorPermissionsController.d.cts.map +1 -1
- package/dist/GatorPermissionsController.d.mts +1 -1
- package/dist/GatorPermissionsController.d.mts.map +1 -1
- package/dist/GatorPermissionsController.mjs +2 -2
- package/dist/GatorPermissionsController.mjs.map +1 -1
- package/dist/decodePermission/decodePermission.cjs +2 -2
- package/dist/decodePermission/decodePermission.cjs.map +1 -1
- package/dist/decodePermission/decodePermission.d.cts.map +1 -1
- package/dist/decodePermission/decodePermission.d.mts.map +1 -1
- package/dist/decodePermission/decodePermission.mjs +2 -2
- package/dist/decodePermission/decodePermission.mjs.map +1 -1
- package/dist/decodePermission/types.cjs.map +1 -1
- package/dist/decodePermission/types.d.cts +3 -3
- package/dist/decodePermission/types.d.cts.map +1 -1
- package/dist/decodePermission/types.d.mts +3 -3
- package/dist/decodePermission/types.d.mts.map +1 -1
- package/dist/decodePermission/types.mjs.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/test/mocks.cjs +20 -45
- package/dist/test/mocks.cjs.map +1 -1
- package/dist/test/mocks.d.cts +7 -7
- package/dist/test/mocks.d.cts.map +1 -1
- package/dist/test/mocks.d.mts +7 -7
- package/dist/test/mocks.d.mts.map +1 -1
- package/dist/test/mocks.mjs +20 -45
- package/dist/test/mocks.mjs.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +23 -29
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +23 -29
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/package.json +7 -7
package/dist/types.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PermissionTypes,
|
|
1
|
+
import type { PermissionTypes, BasePermission, NativeTokenStreamPermission, NativeTokenPeriodicPermission, Erc20TokenStreamPermission, Erc20TokenPeriodicPermission, Rule, MetaMaskBasePermissionData, Erc20TokenRevocationPermission } from "@metamask/7715-permission-types";
|
|
2
2
|
import type { Delegation } from "@metamask/delegation-core";
|
|
3
3
|
import type { Hex } from "@metamask/utils";
|
|
4
4
|
/**
|
|
@@ -39,10 +39,10 @@ export type PermissionTypesWithCustom = PermissionTypes | CustomPermission;
|
|
|
39
39
|
/**
|
|
40
40
|
* Represents a ERC-7715 permission request.
|
|
41
41
|
*
|
|
42
|
-
* @template
|
|
42
|
+
* @template to - The type of the signer provided, either an AccountSigner or WalletSigner.
|
|
43
43
|
* @template Permission - The type of the permission provided.
|
|
44
44
|
*/
|
|
45
|
-
export type PermissionRequest<
|
|
45
|
+
export type PermissionRequest<TPermission extends PermissionTypesWithCustom> = {
|
|
46
46
|
/**
|
|
47
47
|
* hex-encoding of uint256 defined the chain with EIP-155
|
|
48
48
|
*/
|
|
@@ -52,13 +52,13 @@ export type PermissionRequest<TSigner extends Signer, TPermission extends Permis
|
|
|
52
52
|
* The account being targeted for this permission request.
|
|
53
53
|
* It is optional to let the user choose which account to grant permission from.
|
|
54
54
|
*/
|
|
55
|
-
|
|
55
|
+
from?: Hex;
|
|
56
56
|
/**
|
|
57
|
-
*
|
|
57
|
+
* A field that identifies the DApp session account associated with the permission
|
|
58
58
|
*/
|
|
59
|
-
|
|
59
|
+
to: Hex;
|
|
60
60
|
/**
|
|
61
|
-
* Defines the allowed behavior the
|
|
61
|
+
* Defines the allowed behavior the `to` account can do on behalf of the `from` account.
|
|
62
62
|
*/
|
|
63
63
|
permission: TPermission;
|
|
64
64
|
rules?: Rule[] | null;
|
|
@@ -66,10 +66,9 @@ export type PermissionRequest<TSigner extends Signer, TPermission extends Permis
|
|
|
66
66
|
/**
|
|
67
67
|
* Represents a ERC-7715 permission response.
|
|
68
68
|
*
|
|
69
|
-
* @template Signer - The type of the signer provided, either an AccountSigner or WalletSigner.
|
|
70
69
|
* @template Permission - The type of the permission provided.
|
|
71
70
|
*/
|
|
72
|
-
export type PermissionResponse<
|
|
71
|
+
export type PermissionResponse<TPermission extends PermissionTypesWithCustom> = PermissionRequest<TPermission> & {
|
|
73
72
|
/**
|
|
74
73
|
* Is a catch-all to identify a permission for revoking permissions or submitting
|
|
75
74
|
* Defined in ERC-7710.
|
|
@@ -82,33 +81,29 @@ export type PermissionResponse<TSigner extends Signer, TPermission extends Permi
|
|
|
82
81
|
* When non-empty, DApps MUST deploy the accounts by calling the factory contract with factoryData as the calldata.
|
|
83
82
|
* Defined in ERC-4337.
|
|
84
83
|
*/
|
|
85
|
-
|
|
84
|
+
dependencies: {
|
|
86
85
|
factory: Hex;
|
|
87
86
|
factoryData: Hex;
|
|
88
87
|
}[];
|
|
89
88
|
/**
|
|
90
|
-
*
|
|
89
|
+
* Is required as defined in ERC-7710.
|
|
91
90
|
*/
|
|
92
|
-
|
|
93
|
-
delegationManager: Hex;
|
|
94
|
-
};
|
|
91
|
+
delegationManager: Hex;
|
|
95
92
|
};
|
|
96
93
|
/**
|
|
97
94
|
* Represents a sanitized version of the PermissionResponse type.
|
|
98
|
-
* Internal fields (
|
|
95
|
+
* Internal fields (dependencies, to) are removed
|
|
99
96
|
*
|
|
100
|
-
* @template Signer - The type of the signer provided, either an AccountSigner or WalletSigner.
|
|
101
97
|
* @template Permission - The type of the permission provided.
|
|
102
98
|
*/
|
|
103
|
-
export type PermissionResponseSanitized<
|
|
99
|
+
export type PermissionResponseSanitized<TPermission extends PermissionTypesWithCustom> = Omit<PermissionResponse<TPermission>, 'dependencies' | 'to'>;
|
|
104
100
|
/**
|
|
105
101
|
* Represents a gator ERC-7715 granted(ie. signed by an user account) permission entry that is stored in profile sync.
|
|
106
102
|
*
|
|
107
|
-
* @template Signer - The type of the signer provided, either an AccountSigner or WalletSigner.
|
|
108
103
|
* @template Permission - The type of the permission provided
|
|
109
104
|
*/
|
|
110
|
-
export type StoredGatorPermission<
|
|
111
|
-
permissionResponse: PermissionResponse<
|
|
105
|
+
export type StoredGatorPermission<TPermission extends PermissionTypesWithCustom> = {
|
|
106
|
+
permissionResponse: PermissionResponse<TPermission>;
|
|
112
107
|
siteOrigin: string;
|
|
113
108
|
/**
|
|
114
109
|
* Flag indicating whether this permission has been revoked.
|
|
@@ -118,11 +113,10 @@ export type StoredGatorPermission<TSigner extends Signer, TPermission extends Pe
|
|
|
118
113
|
/**
|
|
119
114
|
* Represents a sanitized version of the StoredGatorPermission type. Some fields have been removed but the fields are still present in profile sync.
|
|
120
115
|
*
|
|
121
|
-
* @template Signer - The type of the signer provided, either an AccountSigner or WalletSigner.
|
|
122
116
|
* @template Permission - The type of the permission provided.
|
|
123
117
|
*/
|
|
124
|
-
export type StoredGatorPermissionSanitized<
|
|
125
|
-
permissionResponse: PermissionResponseSanitized<
|
|
118
|
+
export type StoredGatorPermissionSanitized<TPermission extends PermissionTypesWithCustom> = {
|
|
119
|
+
permissionResponse: PermissionResponseSanitized<TPermission>;
|
|
126
120
|
siteOrigin: string;
|
|
127
121
|
/**
|
|
128
122
|
* Flag indicating whether this permission has been revoked.
|
|
@@ -134,22 +128,22 @@ export type StoredGatorPermissionSanitized<TSigner extends Signer, TPermission e
|
|
|
134
128
|
*/
|
|
135
129
|
export type GatorPermissionsMap = {
|
|
136
130
|
'erc20-token-revocation': {
|
|
137
|
-
[chainId: Hex]: StoredGatorPermissionSanitized<
|
|
131
|
+
[chainId: Hex]: StoredGatorPermissionSanitized<Erc20TokenRevocationPermission>[];
|
|
138
132
|
};
|
|
139
133
|
'native-token-stream': {
|
|
140
|
-
[chainId: Hex]: StoredGatorPermissionSanitized<
|
|
134
|
+
[chainId: Hex]: StoredGatorPermissionSanitized<NativeTokenStreamPermission>[];
|
|
141
135
|
};
|
|
142
136
|
'native-token-periodic': {
|
|
143
|
-
[chainId: Hex]: StoredGatorPermissionSanitized<
|
|
137
|
+
[chainId: Hex]: StoredGatorPermissionSanitized<NativeTokenPeriodicPermission>[];
|
|
144
138
|
};
|
|
145
139
|
'erc20-token-stream': {
|
|
146
|
-
[chainId: Hex]: StoredGatorPermissionSanitized<
|
|
140
|
+
[chainId: Hex]: StoredGatorPermissionSanitized<Erc20TokenStreamPermission>[];
|
|
147
141
|
};
|
|
148
142
|
'erc20-token-periodic': {
|
|
149
|
-
[chainId: Hex]: StoredGatorPermissionSanitized<
|
|
143
|
+
[chainId: Hex]: StoredGatorPermissionSanitized<Erc20TokenPeriodicPermission>[];
|
|
150
144
|
};
|
|
151
145
|
other: {
|
|
152
|
-
[chainId: Hex]: StoredGatorPermissionSanitized<
|
|
146
|
+
[chainId: Hex]: StoredGatorPermissionSanitized<CustomPermission>[];
|
|
153
147
|
};
|
|
154
148
|
};
|
|
155
149
|
/**
|
package/dist/types.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,
|
|
1
|
+
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,2BAA2B,EAC3B,6BAA6B,EAC7B,0BAA0B,EAC1B,4BAA4B,EAC5B,IAAI,EACJ,0BAA0B,EAC1B,8BAA8B,EAC/B,wCAAwC;AACzC,OAAO,KAAK,EAAE,UAAU,EAAE,kCAAkC;AAC5D,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAE3C;;GAEG;AACH,oBAAY,mCAAmC;IAC7C,0BAA0B,kCAAkC;IAC5D,0BAA0B,kCAAkC;IAC5D,6BAA6B,qCAAqC;IAClE,qCAAqC,8CAA8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,mBAAmB,CAAC,eAAe,CAAC,CAAC;AAEzC;;GAEG;AACH,MAAM,MAAM,8CAA8C,CACxD,eAAe,SAAS,4BAA4B,IAClD,mBAAmB,CAAC,eAAe,CAAC,CAAC,GAAG,CAAC,CAAC;AAE9C;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAClC,UAAU,CAAC,GAAG,CAAC,EACf,SAAS,GAAG,WAAW,GAAG,UAAU,GAAG,WAAW,CACnD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;OAEG;IACH,iBAAiB,EAAE,GAAG,CAAC;CACxB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG;IACpC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,iBAAiB,EAAE,GAAG,CAAC;CACxB,CAAC"}
|
package/dist/types.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PermissionTypes,
|
|
1
|
+
import type { PermissionTypes, BasePermission, NativeTokenStreamPermission, NativeTokenPeriodicPermission, Erc20TokenStreamPermission, Erc20TokenPeriodicPermission, Rule, MetaMaskBasePermissionData, Erc20TokenRevocationPermission } from "@metamask/7715-permission-types";
|
|
2
2
|
import type { Delegation } from "@metamask/delegation-core";
|
|
3
3
|
import type { Hex } from "@metamask/utils";
|
|
4
4
|
/**
|
|
@@ -39,10 +39,10 @@ export type PermissionTypesWithCustom = PermissionTypes | CustomPermission;
|
|
|
39
39
|
/**
|
|
40
40
|
* Represents a ERC-7715 permission request.
|
|
41
41
|
*
|
|
42
|
-
* @template
|
|
42
|
+
* @template to - The type of the signer provided, either an AccountSigner or WalletSigner.
|
|
43
43
|
* @template Permission - The type of the permission provided.
|
|
44
44
|
*/
|
|
45
|
-
export type PermissionRequest<
|
|
45
|
+
export type PermissionRequest<TPermission extends PermissionTypesWithCustom> = {
|
|
46
46
|
/**
|
|
47
47
|
* hex-encoding of uint256 defined the chain with EIP-155
|
|
48
48
|
*/
|
|
@@ -52,13 +52,13 @@ export type PermissionRequest<TSigner extends Signer, TPermission extends Permis
|
|
|
52
52
|
* The account being targeted for this permission request.
|
|
53
53
|
* It is optional to let the user choose which account to grant permission from.
|
|
54
54
|
*/
|
|
55
|
-
|
|
55
|
+
from?: Hex;
|
|
56
56
|
/**
|
|
57
|
-
*
|
|
57
|
+
* A field that identifies the DApp session account associated with the permission
|
|
58
58
|
*/
|
|
59
|
-
|
|
59
|
+
to: Hex;
|
|
60
60
|
/**
|
|
61
|
-
* Defines the allowed behavior the
|
|
61
|
+
* Defines the allowed behavior the `to` account can do on behalf of the `from` account.
|
|
62
62
|
*/
|
|
63
63
|
permission: TPermission;
|
|
64
64
|
rules?: Rule[] | null;
|
|
@@ -66,10 +66,9 @@ export type PermissionRequest<TSigner extends Signer, TPermission extends Permis
|
|
|
66
66
|
/**
|
|
67
67
|
* Represents a ERC-7715 permission response.
|
|
68
68
|
*
|
|
69
|
-
* @template Signer - The type of the signer provided, either an AccountSigner or WalletSigner.
|
|
70
69
|
* @template Permission - The type of the permission provided.
|
|
71
70
|
*/
|
|
72
|
-
export type PermissionResponse<
|
|
71
|
+
export type PermissionResponse<TPermission extends PermissionTypesWithCustom> = PermissionRequest<TPermission> & {
|
|
73
72
|
/**
|
|
74
73
|
* Is a catch-all to identify a permission for revoking permissions or submitting
|
|
75
74
|
* Defined in ERC-7710.
|
|
@@ -82,33 +81,29 @@ export type PermissionResponse<TSigner extends Signer, TPermission extends Permi
|
|
|
82
81
|
* When non-empty, DApps MUST deploy the accounts by calling the factory contract with factoryData as the calldata.
|
|
83
82
|
* Defined in ERC-4337.
|
|
84
83
|
*/
|
|
85
|
-
|
|
84
|
+
dependencies: {
|
|
86
85
|
factory: Hex;
|
|
87
86
|
factoryData: Hex;
|
|
88
87
|
}[];
|
|
89
88
|
/**
|
|
90
|
-
*
|
|
89
|
+
* Is required as defined in ERC-7710.
|
|
91
90
|
*/
|
|
92
|
-
|
|
93
|
-
delegationManager: Hex;
|
|
94
|
-
};
|
|
91
|
+
delegationManager: Hex;
|
|
95
92
|
};
|
|
96
93
|
/**
|
|
97
94
|
* Represents a sanitized version of the PermissionResponse type.
|
|
98
|
-
* Internal fields (
|
|
95
|
+
* Internal fields (dependencies, to) are removed
|
|
99
96
|
*
|
|
100
|
-
* @template Signer - The type of the signer provided, either an AccountSigner or WalletSigner.
|
|
101
97
|
* @template Permission - The type of the permission provided.
|
|
102
98
|
*/
|
|
103
|
-
export type PermissionResponseSanitized<
|
|
99
|
+
export type PermissionResponseSanitized<TPermission extends PermissionTypesWithCustom> = Omit<PermissionResponse<TPermission>, 'dependencies' | 'to'>;
|
|
104
100
|
/**
|
|
105
101
|
* Represents a gator ERC-7715 granted(ie. signed by an user account) permission entry that is stored in profile sync.
|
|
106
102
|
*
|
|
107
|
-
* @template Signer - The type of the signer provided, either an AccountSigner or WalletSigner.
|
|
108
103
|
* @template Permission - The type of the permission provided
|
|
109
104
|
*/
|
|
110
|
-
export type StoredGatorPermission<
|
|
111
|
-
permissionResponse: PermissionResponse<
|
|
105
|
+
export type StoredGatorPermission<TPermission extends PermissionTypesWithCustom> = {
|
|
106
|
+
permissionResponse: PermissionResponse<TPermission>;
|
|
112
107
|
siteOrigin: string;
|
|
113
108
|
/**
|
|
114
109
|
* Flag indicating whether this permission has been revoked.
|
|
@@ -118,11 +113,10 @@ export type StoredGatorPermission<TSigner extends Signer, TPermission extends Pe
|
|
|
118
113
|
/**
|
|
119
114
|
* Represents a sanitized version of the StoredGatorPermission type. Some fields have been removed but the fields are still present in profile sync.
|
|
120
115
|
*
|
|
121
|
-
* @template Signer - The type of the signer provided, either an AccountSigner or WalletSigner.
|
|
122
116
|
* @template Permission - The type of the permission provided.
|
|
123
117
|
*/
|
|
124
|
-
export type StoredGatorPermissionSanitized<
|
|
125
|
-
permissionResponse: PermissionResponseSanitized<
|
|
118
|
+
export type StoredGatorPermissionSanitized<TPermission extends PermissionTypesWithCustom> = {
|
|
119
|
+
permissionResponse: PermissionResponseSanitized<TPermission>;
|
|
126
120
|
siteOrigin: string;
|
|
127
121
|
/**
|
|
128
122
|
* Flag indicating whether this permission has been revoked.
|
|
@@ -134,22 +128,22 @@ export type StoredGatorPermissionSanitized<TSigner extends Signer, TPermission e
|
|
|
134
128
|
*/
|
|
135
129
|
export type GatorPermissionsMap = {
|
|
136
130
|
'erc20-token-revocation': {
|
|
137
|
-
[chainId: Hex]: StoredGatorPermissionSanitized<
|
|
131
|
+
[chainId: Hex]: StoredGatorPermissionSanitized<Erc20TokenRevocationPermission>[];
|
|
138
132
|
};
|
|
139
133
|
'native-token-stream': {
|
|
140
|
-
[chainId: Hex]: StoredGatorPermissionSanitized<
|
|
134
|
+
[chainId: Hex]: StoredGatorPermissionSanitized<NativeTokenStreamPermission>[];
|
|
141
135
|
};
|
|
142
136
|
'native-token-periodic': {
|
|
143
|
-
[chainId: Hex]: StoredGatorPermissionSanitized<
|
|
137
|
+
[chainId: Hex]: StoredGatorPermissionSanitized<NativeTokenPeriodicPermission>[];
|
|
144
138
|
};
|
|
145
139
|
'erc20-token-stream': {
|
|
146
|
-
[chainId: Hex]: StoredGatorPermissionSanitized<
|
|
140
|
+
[chainId: Hex]: StoredGatorPermissionSanitized<Erc20TokenStreamPermission>[];
|
|
147
141
|
};
|
|
148
142
|
'erc20-token-periodic': {
|
|
149
|
-
[chainId: Hex]: StoredGatorPermissionSanitized<
|
|
143
|
+
[chainId: Hex]: StoredGatorPermissionSanitized<Erc20TokenPeriodicPermission>[];
|
|
150
144
|
};
|
|
151
145
|
other: {
|
|
152
|
-
[chainId: Hex]: StoredGatorPermissionSanitized<
|
|
146
|
+
[chainId: Hex]: StoredGatorPermissionSanitized<CustomPermission>[];
|
|
153
147
|
};
|
|
154
148
|
};
|
|
155
149
|
/**
|
package/dist/types.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../src/types.ts"],"names":[],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AC,EAAE,CAAC;KACpE,CAAC;IACF,oBAAoB,EAAE;QACpB,CACE,OAAO,EAAE,GAAG,GACX,8BAA8B,CAAC,0BAA0B,CAAC,EAAE,CAAC;KACjE,CAAC;IACF,sBAAsB,EAAE;QACtB,CACE,OAAO,EAAE,GAAG,GACX,8BAA8B,CAAC,4BAA4B,CAAC,EAAE,CAAC;KACnE,CAAC;IACF,KAAK,EAAE;QACL,CAAC,OAAO,EAAE,GAAG,GAAG,8BAA8B,CAAC,gBAAgB,CAAC,EAAE,CAAC;KACpE,CAAC;CACH,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,4BAA4B,GAAG,MAAM,mBAAmB,CAAC;AAErE;;GAEG;AACH,MAAM,MAAM,mCAAmC,CAC7C,eAAe,SAAS,4BAA4B,IAClD,mBAAmB,CAAC,eAAe,CAAC,CAAC;AAEzC;;GAEG;AACH,MAAM,MAAM,8CAA8C,CACxD,eAAe,SAAS,4BAA4B,IAClD,mBAAmB,CAAC,eAAe,CAAC,CAAC,GAAG,CAAC,CAAC;AAE9C;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAClC,UAAU,CAAC,GAAG,CAAC,EACf,SAAS,GAAG,WAAW,GAAG,UAAU,GAAG,WAAW,CACnD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;OAEG;IACH,iBAAiB,EAAE,GAAG,CAAC;CACxB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG;IACpC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,iBAAiB,EAAE,GAAG,CAAC;CACxB,CAAC"}
|
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":"AAcA;;GAEG;AACH,MAAM,CAAN,IAAY,mCAOX;AAPD,WAAY,mCAAmC;IAC7C,mGAA4D,CAAA;IAC5D,mGAA4D,CAAA;IAC5D,yGAAkE,CAAA;IAClE,0HAAmF,CAAA;IACnF,4FAAqD,CAAA;IACrD,yFAAkD,CAAA;AACpD,CAAC,EAPW,mCAAmC,KAAnC,mCAAmC,QAO9C;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,6BASX;AATD,WAAY,6BAA6B;IACvC;;OAEG;IACH,sHAAqF,CAAA;IACrF;;OAEG;IACH,4GAA2E,CAAA;AAC7E,CAAC,EATW,6BAA6B,KAA7B,6BAA6B,QASxC","sourcesContent":["import type {\n PermissionTypes,\n BasePermission,\n NativeTokenStreamPermission,\n NativeTokenPeriodicPermission,\n Erc20TokenStreamPermission,\n Erc20TokenPeriodicPermission,\n Rule,\n MetaMaskBasePermissionData,\n Erc20TokenRevocationPermission,\n} from '@metamask/7715-permission-types';\nimport type { Delegation } from '@metamask/delegation-core';\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 PermissionDecodingError = 'permission-decoding-error',\n OriginNotAllowedError = 'origin-not-allowed-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 * This method is used by the metamask to submit a revocation to the permissions provider.\n */\n PermissionProviderSubmitRevocation = 'permissionsProvider_submitRevocation',\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 to - The type of the signer provided, either an AccountSigner or WalletSigner.\n * @template Permission - The type of the permission provided.\n */\nexport type PermissionRequest<TPermission extends PermissionTypesWithCustom> = {\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 from?: Hex;\n\n /**\n * A field that identifies the DApp session account associated with the permission\n */\n to: Hex;\n\n /**\n * Defines the allowed behavior the `to` account can do on behalf of the `from` account.\n */\n permission: TPermission;\n\n rules?: Rule[] | null;\n};\n\n/**\n * Represents a ERC-7715 permission response.\n *\n * @template Permission - The type of the permission provided.\n */\nexport type PermissionResponse<TPermission extends PermissionTypesWithCustom> =\n PermissionRequest<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 dependencies: {\n factory: Hex;\n factoryData: Hex;\n }[];\n\n /**\n * Is required as defined in ERC-7710.\n */\n delegationManager: Hex;\n };\n\n/**\n * Represents a sanitized version of the PermissionResponse type.\n * Internal fields (dependencies, to) are removed\n *\n * @template Permission - The type of the permission provided.\n */\nexport type PermissionResponseSanitized<\n TPermission extends PermissionTypesWithCustom,\n> = Omit<PermissionResponse<TPermission>, 'dependencies' | 'to'>;\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 Permission - The type of the permission provided\n */\nexport type StoredGatorPermission<\n TPermission extends PermissionTypesWithCustom,\n> = {\n permissionResponse: PermissionResponse<TPermission>;\n siteOrigin: string;\n /**\n * Flag indicating whether this permission has been revoked.\n */\n isRevoked?: boolean;\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 Permission - The type of the permission provided.\n */\nexport type StoredGatorPermissionSanitized<\n TPermission extends PermissionTypesWithCustom,\n> = {\n permissionResponse: PermissionResponseSanitized<TPermission>;\n siteOrigin: string;\n /**\n * Flag indicating whether this permission has been revoked.\n */\n isRevoked?: boolean;\n};\n\n/**\n * Represents a map of gator permissions by chainId and permission type.\n */\nexport type GatorPermissionsMap = {\n 'erc20-token-revocation': {\n [\n chainId: Hex\n ]: StoredGatorPermissionSanitized<Erc20TokenRevocationPermission>[];\n };\n 'native-token-stream': {\n [\n chainId: Hex\n ]: StoredGatorPermissionSanitized<NativeTokenStreamPermission>[];\n };\n 'native-token-periodic': {\n [\n chainId: Hex\n ]: StoredGatorPermissionSanitized<NativeTokenPeriodicPermission>[];\n };\n 'erc20-token-stream': {\n [\n chainId: Hex\n ]: StoredGatorPermissionSanitized<Erc20TokenStreamPermission>[];\n };\n 'erc20-token-periodic': {\n [\n chainId: Hex\n ]: StoredGatorPermissionSanitized<Erc20TokenPeriodicPermission>[];\n };\n other: {\n [chainId: Hex]: StoredGatorPermissionSanitized<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\n/**\n * Represents the details of a delegation, that are required to decode a permission.\n */\nexport type DelegationDetails = Pick<\n Delegation<Hex>,\n 'caveats' | 'delegator' | 'delegate' | 'authority'\n>;\n\n/**\n * Represents the parameters for submitting a revocation.\n */\nexport type RevocationParams = {\n /**\n * The permission context as a hex string that identifies the permission to revoke.\n */\n permissionContext: Hex;\n};\n\n/**\n * Represents the parameters for adding a pending revocation.\n */\nexport type PendingRevocationParams = {\n /**\n * The transaction metadata ID to monitor.\n */\n txId: string;\n /**\n * The permission context as a hex string that identifies the permission to revoke.\n */\n permissionContext: Hex;\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask/gator-permissions-controller",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Controller for managing gator permissions with profile sync integration",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"MetaMask",
|
|
@@ -48,16 +48,16 @@
|
|
|
48
48
|
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@metamask/7715-permission-types": "^0.
|
|
51
|
+
"@metamask/7715-permission-types": "^0.5.0",
|
|
52
52
|
"@metamask/base-controller": "^9.0.0",
|
|
53
53
|
"@metamask/delegation-core": "^0.2.0",
|
|
54
54
|
"@metamask/delegation-deployments": "^0.12.0",
|
|
55
55
|
"@metamask/messenger": "^0.3.0",
|
|
56
|
-
"@metamask/snaps-controllers": "^
|
|
57
|
-
"@metamask/snaps-sdk": "^
|
|
58
|
-
"@metamask/snaps-utils": "^11.
|
|
59
|
-
"@metamask/transaction-controller": "^62.
|
|
60
|
-
"@metamask/utils": "^11.
|
|
56
|
+
"@metamask/snaps-controllers": "^17.2.0",
|
|
57
|
+
"@metamask/snaps-sdk": "^10.3.0",
|
|
58
|
+
"@metamask/snaps-utils": "^11.7.0",
|
|
59
|
+
"@metamask/transaction-controller": "^62.9.1",
|
|
60
|
+
"@metamask/utils": "^11.9.0"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@lavamoat/allow-scripts": "^3.0.4",
|