@metamask/permission-controller 8.0.0 → 8.0.1
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 +52 -1
- package/dist/errors.d.ts +1 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/rpc-methods/requestPermissions.d.ts +1 -1
- package/dist/rpc-methods/requestPermissions.d.ts.map +1 -1
- package/dist/rpc-methods/requestPermissions.js +2 -10
- package/dist/rpc-methods/requestPermissions.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# Changelog
|
|
2
|
+
|
|
2
3
|
All notable changes to this project will be documented in this file.
|
|
3
4
|
|
|
4
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
@@ -6,8 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
6
7
|
|
|
7
8
|
## [Unreleased]
|
|
8
9
|
|
|
10
|
+
## [8.0.1]
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- Bump `@metamask/rpc-errors` to `^6.2.1` ([#3954](https://github.com/MetaMask/core/pull/3954), [#3970](https://github.com/MetaMask/core/pull/3970))
|
|
15
|
+
|
|
9
16
|
## [8.0.0]
|
|
17
|
+
|
|
10
18
|
### Changed
|
|
19
|
+
|
|
11
20
|
- **BREAKING:** Bump `@metamask/approval-controller` peer dependency to `^5.1.2` ([#3821](https://github.com/MetaMask/core/pull/3821))
|
|
12
21
|
- Bump `@metamask/utils` to `^8.3.0` ([#3769](https://github.com/MetaMask/core/pull/3769))
|
|
13
22
|
- Bump `@metamask/base-controller` to `^4.1.1` ([#3760](https://github.com/MetaMask/core/pull/3760), [#3821](https://github.com/MetaMask/core/pull/3821))
|
|
@@ -15,24 +24,32 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
15
24
|
- Bump `@metamask/json-rpc-engine` to `^7.3.2` ([#3821](https://github.com/MetaMask/core/pull/3821))
|
|
16
25
|
|
|
17
26
|
## [7.1.0]
|
|
27
|
+
|
|
18
28
|
### Added
|
|
29
|
+
|
|
19
30
|
- Add `SubjectMetadataController:addSubjectMetadata` action ([#3733](https://github.com/MetaMask/core/pull/3733))
|
|
20
31
|
|
|
21
32
|
## [7.0.0]
|
|
33
|
+
|
|
22
34
|
### Changed
|
|
35
|
+
|
|
23
36
|
- **BREAKING:** Bump `@metamask/approval-controller` peer dependency from `^5.0.0` to `^5.1.1` ([#3680](https://github.com/MetaMask/core/pull/3680), [#3695](https://github.com/MetaMask/core/pull/3695))
|
|
24
37
|
- Bump `@metamask/base-controller` to `^4.0.1` ([#3695](https://github.com/MetaMask/core/pull/3695))
|
|
25
38
|
- Bump `@metamask/controller-utils` to `^8.0.1` ([#3695](https://github.com/MetaMask/core/pull/3695), [#3678](https://github.com/MetaMask/core/pull/3678), [#3667](https://github.com/MetaMask/core/pull/3667), [#3580](https://github.com/MetaMask/core/pull/3580))
|
|
26
39
|
- Bump `@metamask/json-rpc-engine` to `^7.3.1` ([#3695](https://github.com/MetaMask/core/pull/3695))
|
|
27
40
|
|
|
28
41
|
### Fixed
|
|
42
|
+
|
|
29
43
|
- Remove `@metamask/approval-controller` dependency ([#3607](https://github.com/MetaMask/core/pull/3607))
|
|
30
44
|
|
|
31
45
|
## [6.0.0]
|
|
46
|
+
|
|
32
47
|
### Added
|
|
48
|
+
|
|
33
49
|
- Add new handler to `permissionRpcMethods.handlers` for `wallet_revokePermissions` RPC method ([#1889](https://github.com/MetaMask/core/pull/1889))
|
|
34
50
|
|
|
35
51
|
### Changed
|
|
52
|
+
|
|
36
53
|
- **BREAKING:** Bump `@metamask/base-controller` to ^4.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063))
|
|
37
54
|
- This is breaking because the type of the `messenger` has backward-incompatible changes. See the changelog for this package for more.
|
|
38
55
|
- **BREAKING:** Update `PermittedRpcMethodHooks` type so it must support signature for `wallet_revokePermission` hook ([#1889](https://github.com/MetaMask/core/pull/1889))
|
|
@@ -40,7 +57,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
40
57
|
- Bump `@metamask/controller-utils` to ^6.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063))
|
|
41
58
|
|
|
42
59
|
## [5.0.1]
|
|
60
|
+
|
|
43
61
|
### Changed
|
|
62
|
+
|
|
44
63
|
- Bump `@metamask/json-rpc-engine` from `^7.1.0` to `^7.2.0` ([#1895](https://github.com/MetaMask/core/pull/1895))
|
|
45
64
|
- Bump dependency on `@metamask/rpc-errors` to ^6.1.0 ([#1653](https://github.com/MetaMask/core/pull/1653))
|
|
46
65
|
- Bump dependency and peer dependency on `@metamask/approval-controller` to ^4.0.1
|
|
@@ -48,7 +67,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
48
67
|
- Bump `@metamask/auto-changelog` from `^3.2.0` to `^3.4.3` ([#1870](https://github.com/MetaMask/core/pull/1870), [#1905](https://github.com/MetaMask/core/pull/1905), [#1997](https://github.com/MetaMask/core/pull/1997))
|
|
49
68
|
|
|
50
69
|
## [5.0.0]
|
|
70
|
+
|
|
51
71
|
### Changed
|
|
72
|
+
|
|
52
73
|
- **BREAKING:** Remove `undefined` from RestrictedMethodParameters type union and from type parameter for RestrictedMethodOptions ([#1749])(https://github.com/MetaMask/core/pull/1749))
|
|
53
74
|
- **BREAKING:** Update from `json-rpc-engine@^6.1.0` to `@metamask/json-rpc-engine@^7.1.1` ([#1749])(https://github.com/MetaMask/core/pull/1749))
|
|
54
75
|
- Update from `eth-rpc-errors@^4.0.2` to `@metamask/rpc-errors@^6.0.0` ([#1749])(https://github.com/MetaMask/core/pull/1749))
|
|
@@ -58,27 +79,37 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
58
79
|
- Bump dependency on `@metamask/controller-utils` to ^5.0.2
|
|
59
80
|
|
|
60
81
|
## [4.1.2]
|
|
82
|
+
|
|
61
83
|
### Changed
|
|
84
|
+
|
|
62
85
|
- Update TypeScript to v4.8.x ([#1718](https://github.com/MetaMask/core/pull/1718))
|
|
63
86
|
- Bump dependency on `@metamask/controller-utils` to ^5.0.0
|
|
64
87
|
|
|
65
88
|
## [4.1.1]
|
|
89
|
+
|
|
66
90
|
### Changed
|
|
91
|
+
|
|
67
92
|
- Bump dependency and peer dependency on `@metamask/approval-controller` to ^3.5.1
|
|
68
93
|
- Bump dependency on `@metamask/base-controller` to ^3.2.1
|
|
69
94
|
- Bump dependency on `@metamask/controller-utils` to ^4.3.2
|
|
70
95
|
|
|
71
96
|
## [4.1.0]
|
|
97
|
+
|
|
72
98
|
### Changed
|
|
99
|
+
|
|
73
100
|
- Update `@metamask/utils` to `^6.2.0` ([#1514](https://github.com/MetaMask/core/pull/1514))
|
|
74
101
|
|
|
75
102
|
## [4.0.1]
|
|
103
|
+
|
|
76
104
|
### Fixed
|
|
105
|
+
|
|
77
106
|
- Fix permissions RPC method types ([#1464](https://github.com/MetaMask/core/pull/1464))
|
|
78
107
|
- The RPC method handlers were mistakenly typed as an array rather than a tuple
|
|
79
108
|
|
|
80
109
|
## [4.0.0]
|
|
110
|
+
|
|
81
111
|
### Changed
|
|
112
|
+
|
|
82
113
|
- **BREAKING:** Bump to Node 16 ([#1262](https://github.com/MetaMask/core/pull/1262))
|
|
83
114
|
- **BREAKING:** Update `@metamask/approval-controller` dependency and peer dependency
|
|
84
115
|
- The export `permissionRpcMethods` has a slightly different type; the second generic type variable of the `getPermissions` handler is now `undefined` rather than `void` ([#1372](https://github.com/MetaMask/core/pull/1372))
|
|
@@ -87,6 +118,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
87
118
|
- Change type of constructor parameter `unrestrictedMethods` to be readonly ([#1395](https://github.com/MetaMask/core/pull/1395))
|
|
88
119
|
|
|
89
120
|
### Removed
|
|
121
|
+
|
|
90
122
|
- **BREAKING**: Remove namespaced permissions ([#1337](https://github.com/MetaMask/core/pull/1337))
|
|
91
123
|
- Namespaced permissions are no longer supported. Consumers should replace namespaced permissions with equivalent caveat-based implementations.
|
|
92
124
|
- **BREAKING**: Remove `targetKey` concept ([#1337](https://github.com/MetaMask/core/pull/1337))
|
|
@@ -94,48 +126,67 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
94
126
|
- The `targetKey` property of permission specifications has been renamed to `targetName`.
|
|
95
127
|
|
|
96
128
|
## [3.2.0]
|
|
129
|
+
|
|
97
130
|
### Added
|
|
131
|
+
|
|
98
132
|
- Allow restricting permissions by subject type ([#1233](https://github.com/MetaMask/core/pull/1233))
|
|
99
133
|
|
|
100
134
|
### Changed
|
|
135
|
+
|
|
101
136
|
- Move `SubjectMetadataController` to permission-controller package ([#1234](https://github.com/MetaMask/core/pull/1234))
|
|
102
137
|
- Update minimum `eth-rpc-errors` version from `4.0.0` to `4.0.2` ([#1215](https://github.com/MetaMask/core/pull/1215))
|
|
103
138
|
|
|
104
139
|
## [3.1.0]
|
|
140
|
+
|
|
105
141
|
### Added
|
|
142
|
+
|
|
106
143
|
- Add side-effects to permissions ([#1069](https://github.com/MetaMask/core/pull/1069))
|
|
107
144
|
|
|
108
145
|
## [3.0.0]
|
|
146
|
+
|
|
109
147
|
### Removed
|
|
148
|
+
|
|
110
149
|
- **BREAKING:** Remove `isomorphic-fetch` ([#1106](https://github.com/MetaMask/controllers/pull/1106))
|
|
111
150
|
- Consumers must now import `isomorphic-fetch` or another polyfill themselves if they are running in an environment without `fetch`
|
|
112
151
|
|
|
113
152
|
## [2.0.0]
|
|
153
|
+
|
|
114
154
|
### Added
|
|
155
|
+
|
|
115
156
|
- Add `updateCaveat` action ([#1071](https://github.com/MetaMask/core/pull/1071))
|
|
116
157
|
|
|
117
158
|
### Changed
|
|
159
|
+
|
|
118
160
|
- **BREAKING:** Update `@metamask/network-controller` peer dependency to v3 ([#1041](https://github.com/MetaMask/controllers/pull/1041))
|
|
119
161
|
- Rename this repository to `core` ([#1031](https://github.com/MetaMask/controllers/pull/1031))
|
|
120
162
|
- Update `@metamask/controller-utils` package ([#1041](https://github.com/MetaMask/controllers/pull/1041))
|
|
121
163
|
|
|
122
164
|
## [1.0.2]
|
|
165
|
+
|
|
123
166
|
### Fixed
|
|
167
|
+
|
|
124
168
|
- This package will now warn if a required package is not present ([#1003](https://github.com/MetaMask/core/pull/1003))
|
|
125
169
|
|
|
126
170
|
## [1.0.1]
|
|
171
|
+
|
|
127
172
|
### Changed
|
|
173
|
+
|
|
128
174
|
- Relax dependencies on `@metamask/approval-controller`, `@metamask/base-controller` and `@metamask/controller-utils` (use `^` instead of `~`) ([#998](https://github.com/MetaMask/core/pull/998))
|
|
129
175
|
|
|
130
176
|
## [1.0.0]
|
|
177
|
+
|
|
131
178
|
### Added
|
|
179
|
+
|
|
132
180
|
- Initial release
|
|
181
|
+
|
|
133
182
|
- As a result of converting our shared controllers repo into a monorepo ([#831](https://github.com/MetaMask/core/pull/831)), we've created this package from select parts of [`@metamask/controllers` v33.0.0](https://github.com/MetaMask/core/tree/v33.0.0), namely:
|
|
183
|
+
|
|
134
184
|
- Everything in `src/permissions`
|
|
135
185
|
|
|
136
186
|
All changes listed after this point were applied to this package following the monorepo conversion.
|
|
137
187
|
|
|
138
|
-
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/permission-controller@8.0.
|
|
188
|
+
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/permission-controller@8.0.1...HEAD
|
|
189
|
+
[8.0.1]: https://github.com/MetaMask/core/compare/@metamask/permission-controller@8.0.0...@metamask/permission-controller@8.0.1
|
|
139
190
|
[8.0.0]: https://github.com/MetaMask/core/compare/@metamask/permission-controller@7.1.0...@metamask/permission-controller@8.0.0
|
|
140
191
|
[7.1.0]: https://github.com/MetaMask/core/compare/@metamask/permission-controller@7.0.0...@metamask/permission-controller@7.1.0
|
|
141
192
|
[7.0.0]: https://github.com/MetaMask/core/compare/@metamask/permission-controller@6.0.0...@metamask/permission-controller@7.0.0
|
package/dist/errors.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export declare function unauthorized(opts: UnauthorizedArg): import("@metamask/r
|
|
|
19
19
|
* @param data - Optional data for context.
|
|
20
20
|
* @returns The built error
|
|
21
21
|
*/
|
|
22
|
-
export declare function methodNotFound(method: string, data?: DataWithOptionalCause): JsonRpcError<import("@metamask/rpc-errors
|
|
22
|
+
export declare function methodNotFound(method: string, data?: DataWithOptionalCause): JsonRpcError<import("@metamask/rpc-errors").OptionalDataWithOptionalCause>;
|
|
23
23
|
declare type InvalidParamsArg = {
|
|
24
24
|
message?: string;
|
|
25
25
|
data?: DataWithOptionalCause;
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAIL,YAAY,EACb,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD,aAAK,eAAe,GAAG;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,eAAe,iFAMjD;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,qBAAqB,
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAIL,YAAY,EACb,MAAM,sBAAsB,CAAC;AAE9B,OAAO,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M;CAM5E;AAED,qBAAa,oBAAqB,SAAQ,KAAK;IACtC,IAAI,EAAE;QACX,UAAU,EAAE,MAAM,CAAC;QACnB,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;gBAEU,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;CAMnE;AAED,qBAAa,oBAAqB,SAAQ,KAAK;IACtC,IAAI,EAAE;QACX,UAAU,EAAE,MAAM,CAAC;QACnB,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;gBAEU,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;CAMnE;AAED,qBAAa,gCAAiC,SAAQ,KAAK;IAClD,IAAI,EAAE;QACX,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACpC,cAAc,EAAE,cAAc,CAAC;KAChC,CAAC;gBAGA,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACnC,cAAc,EAAE,cAAc;CAOjC;AAED,qBAAa,+BAAgC,SAAQ,KAAK;gBAC5C,EAAE,EAAE,MAAM;CAGvB"}
|
|
@@ -3,7 +3,7 @@ import type { PermittedHandlerExport } from '../utils';
|
|
|
3
3
|
export declare const requestPermissionsHandler: PermittedHandlerExport<RequestPermissionsHooks, [
|
|
4
4
|
RequestedPermissions
|
|
5
5
|
], PermissionConstraint[]>;
|
|
6
|
-
declare type RequestPermissions = (requestedPermissions: RequestedPermissions
|
|
6
|
+
declare type RequestPermissions = (requestedPermissions: RequestedPermissions) => Promise<[
|
|
7
7
|
Record<string, PermissionConstraint>,
|
|
8
8
|
{
|
|
9
9
|
id: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requestPermissions.d.ts","sourceRoot":"","sources":["../../src/rpc-methods/requestPermissions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"requestPermissions.d.ts","sourceRoot":"","sources":["../../src/rpc-methods/requestPermissions.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAChF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAGvD,eAAO,MAAM,yBAAyB,EAAE,sBAAsB,CAC5D,uBAAuB,EACvB;IAAC,oBAAoB;CAAC,EACtB,oBAAoB,EAAE,CAOvB,CAAC;AAEF,aAAK,kBAAkB,GAAG,CACxB,oBAAoB,EAAE,oBAAoB,KACvC,OAAO,CACV;IAAC,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC;IAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;CAAC,CACvE,CAAC;AAEF,oBAAY,uBAAuB,GAAG;IACpC,2BAA2B,EAAE,kBAAkB,CAAC;CACjD,CAAC"}
|
|
@@ -11,7 +11,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.requestPermissionsHandler = void 0;
|
|
13
13
|
const controller_utils_1 = require("@metamask/controller-utils");
|
|
14
|
-
const rpc_errors_1 = require("@metamask/rpc-errors");
|
|
15
14
|
const errors_1 = require("../errors");
|
|
16
15
|
const utils_1 = require("../utils");
|
|
17
16
|
exports.requestPermissionsHandler = {
|
|
@@ -34,19 +33,12 @@ exports.requestPermissionsHandler = {
|
|
|
34
33
|
*/
|
|
35
34
|
function requestPermissionsImplementation(req, res, _next, end, { requestPermissionsForOrigin }) {
|
|
36
35
|
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
-
const {
|
|
38
|
-
if ((typeof id !== 'number' && typeof id !== 'string') ||
|
|
39
|
-
(typeof id === 'string' && !id)) {
|
|
40
|
-
return end(rpc_errors_1.rpcErrors.invalidRequest({
|
|
41
|
-
message: 'Invalid request: Must specify a valid id.',
|
|
42
|
-
data: { request: req },
|
|
43
|
-
}));
|
|
44
|
-
}
|
|
36
|
+
const { params } = req;
|
|
45
37
|
if (!Array.isArray(params) || !(0, controller_utils_1.isPlainObject)(params[0])) {
|
|
46
38
|
return end((0, errors_1.invalidParams)({ data: { request: req } }));
|
|
47
39
|
}
|
|
48
40
|
const [requestedPermissions] = params;
|
|
49
|
-
const [grantedPermissions] = yield requestPermissionsForOrigin(requestedPermissions
|
|
41
|
+
const [grantedPermissions] = yield requestPermissionsForOrigin(requestedPermissions);
|
|
50
42
|
// `wallet_requestPermission` is specified to return an array.
|
|
51
43
|
res.result = Object.values(grantedPermissions);
|
|
52
44
|
return end();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requestPermissions.js","sourceRoot":"","sources":["../../src/rpc-methods/requestPermissions.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iEAA2D;
|
|
1
|
+
{"version":3,"file":"requestPermissions.js","sourceRoot":"","sources":["../../src/rpc-methods/requestPermissions.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iEAA2D;AAI3D,sCAA0C;AAG1C,oCAAuC;AAE1B,QAAA,yBAAyB,GAIlC;IACF,WAAW,EAAE,CAAC,mBAAW,CAAC,kBAAkB,CAAC;IAC7C,cAAc,EAAE,gCAAgC;IAChD,SAAS,EAAE;QACT,2BAA2B,EAAE,IAAI;KAClC;CACF,CAAC;AAYF;;;;;;;;;;GAUG;AACH,SAAe,gCAAgC,CAC7C,GAA2C,EAC3C,GAAmD,EACnD,KAAc,EACd,GAA6B,EAC7B,EAAE,2BAA2B,EAA2B;;QAExD,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC;QAEvB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,IAAA,gCAAa,EAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE;YACvD,OAAO,GAAG,CAAC,IAAA,sBAAa,EAAC,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC;SACvD;QAED,MAAM,CAAC,oBAAoB,CAAC,GAAG,MAAM,CAAC;QACtC,MAAM,CAAC,kBAAkB,CAAC,GAAG,MAAM,2BAA2B,CAC5D,oBAAoB,CACrB,CAAC;QAEF,8DAA8D;QAC9D,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC;QAC/C,OAAO,GAAG,EAAE,CAAC;IACf,CAAC;CAAA","sourcesContent":["import { isPlainObject } from '@metamask/controller-utils';\nimport type { JsonRpcEngineEndCallback } from '@metamask/json-rpc-engine';\nimport type { JsonRpcRequest, PendingJsonRpcResponse } from '@metamask/utils';\n\nimport { invalidParams } from '../errors';\nimport type { PermissionConstraint, RequestedPermissions } from '../Permission';\nimport type { PermittedHandlerExport } from '../utils';\nimport { MethodNames } from '../utils';\n\nexport const requestPermissionsHandler: PermittedHandlerExport<\n RequestPermissionsHooks,\n [RequestedPermissions],\n PermissionConstraint[]\n> = {\n methodNames: [MethodNames.requestPermissions],\n implementation: requestPermissionsImplementation,\n hookNames: {\n requestPermissionsForOrigin: true,\n },\n};\n\ntype RequestPermissions = (\n requestedPermissions: RequestedPermissions,\n) => Promise<\n [Record<string, PermissionConstraint>, { id: string; origin: string }]\n>;\n\nexport type RequestPermissionsHooks = {\n requestPermissionsForOrigin: RequestPermissions;\n};\n\n/**\n * Request Permissions implementation to be used in JsonRpcEngine middleware.\n *\n * @param req - The JsonRpcEngine request\n * @param res - The JsonRpcEngine result object\n * @param _next - JsonRpcEngine next() callback - unused\n * @param end - JsonRpcEngine end() callback\n * @param options - Method hooks passed to the method implementation\n * @param options.requestPermissionsForOrigin - The specific method hook needed for this method implementation\n * @returns A promise that resolves to nothing\n */\nasync function requestPermissionsImplementation(\n req: JsonRpcRequest<[RequestedPermissions]>,\n res: PendingJsonRpcResponse<PermissionConstraint[]>,\n _next: unknown,\n end: JsonRpcEngineEndCallback,\n { requestPermissionsForOrigin }: RequestPermissionsHooks,\n): Promise<void> {\n const { params } = req;\n\n if (!Array.isArray(params) || !isPlainObject(params[0])) {\n return end(invalidParams({ data: { request: req } }));\n }\n\n const [requestedPermissions] = params;\n const [grantedPermissions] = await requestPermissionsForOrigin(\n requestedPermissions,\n );\n\n // `wallet_requestPermission` is specified to return an array.\n res.result = Object.values(grantedPermissions);\n return end();\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask/permission-controller",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.1",
|
|
4
4
|
"description": "Mediates access to JSON-RPC methods, used to interact with pieces of the MetaMask stack, via middleware for json-rpc-engine",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"MetaMask",
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@metamask/base-controller": "^4.1.1",
|
|
35
|
-
"@metamask/controller-utils": "^8.0.
|
|
35
|
+
"@metamask/controller-utils": "^8.0.3",
|
|
36
36
|
"@metamask/json-rpc-engine": "^7.3.2",
|
|
37
|
-
"@metamask/rpc-errors": "^6.1
|
|
37
|
+
"@metamask/rpc-errors": "^6.2.1",
|
|
38
38
|
"@metamask/utils": "^8.3.0",
|
|
39
39
|
"@types/deep-freeze-strict": "^1.1.0",
|
|
40
40
|
"deep-freeze-strict": "^1.1.1",
|