@metamask-previews/permission-log-controller 5.1.0-preview-8bfa290fb → 6.0.0-preview-0a30e47

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.
Files changed (44) hide show
  1. package/CHANGELOG.md +16 -8
  2. package/dist/{PermissionLogController-method-action-types.d.mts → PermissionLogController-method-action-types.d.ts} +2 -2
  3. package/dist/PermissionLogController-method-action-types.d.ts.map +1 -0
  4. package/dist/{PermissionLogController-method-action-types.mjs → PermissionLogController-method-action-types.js} +1 -1
  5. package/dist/PermissionLogController-method-action-types.js.map +1 -0
  6. package/dist/{PermissionLogController.d.cts → PermissionLogController.d.ts} +8 -8
  7. package/dist/PermissionLogController.d.ts.map +1 -0
  8. package/dist/PermissionLogController.js +310 -0
  9. package/dist/PermissionLogController.js.map +1 -0
  10. package/dist/{enums.d.cts → enums.d.ts} +2 -2
  11. package/dist/enums.d.ts.map +1 -0
  12. package/dist/{enums.mjs → enums.js} +1 -1
  13. package/dist/enums.js.map +1 -0
  14. package/dist/{index.d.cts → index.d.ts} +4 -4
  15. package/dist/index.d.ts.map +1 -0
  16. package/dist/index.js +2 -0
  17. package/dist/index.js.map +1 -0
  18. package/package.json +15 -19
  19. package/dist/PermissionLogController-method-action-types.cjs +0 -7
  20. package/dist/PermissionLogController-method-action-types.cjs.map +0 -1
  21. package/dist/PermissionLogController-method-action-types.d.cts +0 -37
  22. package/dist/PermissionLogController-method-action-types.d.cts.map +0 -1
  23. package/dist/PermissionLogController-method-action-types.d.mts.map +0 -1
  24. package/dist/PermissionLogController-method-action-types.mjs.map +0 -1
  25. package/dist/PermissionLogController.cjs +0 -267
  26. package/dist/PermissionLogController.cjs.map +0 -1
  27. package/dist/PermissionLogController.d.cts.map +0 -1
  28. package/dist/PermissionLogController.d.mts +0 -86
  29. package/dist/PermissionLogController.d.mts.map +0 -1
  30. package/dist/PermissionLogController.mjs +0 -263
  31. package/dist/PermissionLogController.mjs.map +0 -1
  32. package/dist/enums.cjs +0 -25
  33. package/dist/enums.cjs.map +0 -1
  34. package/dist/enums.d.cts.map +0 -1
  35. package/dist/enums.d.mts +0 -14
  36. package/dist/enums.d.mts.map +0 -1
  37. package/dist/enums.mjs.map +0 -1
  38. package/dist/index.cjs +0 -6
  39. package/dist/index.cjs.map +0 -1
  40. package/dist/index.d.cts.map +0 -1
  41. package/dist/index.d.mts +0 -4
  42. package/dist/index.d.mts.map +0 -1
  43. package/dist/index.mjs +0 -2
  44. package/dist/index.mjs.map +0 -1
package/CHANGELOG.md CHANGED
@@ -7,12 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [6.0.0]
11
+
10
12
  ### Changed
11
13
 
14
+ - **BREAKING:** Drop CommonJS support ([#9536](https://github.com/MetaMask/core/pull/9536))
15
+ - This package is now ESM-only, but can still be used in CommonJS projects via `require(esm)` in modern Node.js versions (22+), or dynamic imports in older Node.js versions.
16
+ - **BREAKING:** Bump minimum Node.js version to 22 ([#9976](https://github.com/MetaMask/core/pull/9976))
17
+ - **BREAKING:** Bump TypeScript target to ES2022 ([#10019](https://github.com/MetaMask/core/pull/10019))
18
+ - This package now ships ES2022 code, requiring a compatible modern environment or bundler configuration to consume.
12
19
  - Bump `@metamask/utils` from `^11.9.0` to `^11.12.0` ([#9074](https://github.com/MetaMask/core/pull/9074), [#10076](https://github.com/MetaMask/core/pull/10076))
13
- - Bump `@metamask/json-rpc-engine` from `^10.2.4` to `^10.5.0` ([#8661](https://github.com/MetaMask/core/pull/8661), [#8746](https://github.com/MetaMask/core/pull/8746), [#8753](https://github.com/MetaMask/core/pull/8753))
14
- - Bump `@metamask/messenger` from `^1.0.0` to `^2.0.0` ([#8364](https://github.com/MetaMask/core/pull/8364), [#8373](https://github.com/MetaMask/core/pull/8373), [#8632](https://github.com/MetaMask/core/pull/8632), [#9392](https://github.com/MetaMask/core/pull/9392))
15
- - Bump `@metamask/base-controller` from `^9.0.1` to `^9.1.0` ([#8457](https://github.com/MetaMask/core/pull/8457))
20
+ - Bump `@metamask/json-rpc-engine` from `^10.2.4` to `^11.0.0` ([#8661](https://github.com/MetaMask/core/pull/8661), [#8746](https://github.com/MetaMask/core/pull/8746), [#8753](https://github.com/MetaMask/core/pull/8753), [#10160](https://github.com/MetaMask/core/pull/10160))
21
+ - Bump `@metamask/messenger` from `^1.0.0` to `^3.0.0` ([#8364](https://github.com/MetaMask/core/pull/8364), [#8373](https://github.com/MetaMask/core/pull/8373), [#8632](https://github.com/MetaMask/core/pull/8632), [#9392](https://github.com/MetaMask/core/pull/9392), [#10160](https://github.com/MetaMask/core/pull/10160))
22
+ - Bump `@metamask/base-controller` from `^9.0.1` to `^10.0.0` ([#8457](https://github.com/MetaMask/core/pull/8457), [#10160](https://github.com/MetaMask/core/pull/10160))
16
23
 
17
24
  ## [5.1.0]
18
25
 
@@ -77,9 +84,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77
84
 
78
85
  ### Changed
79
86
 
80
- - Bump `@metamask/base-controller` from `^7.0.0` to `^8.0.0` ([#5079](https://github.com/MetaMask/core/pull/5079)), ([#5135](https://github.com/MetaMask/core/pull/5135)), ([#5305](https://github.com/MetaMask/core/pull/5305))
81
- - Bump `@metamask/json-rpc-engine` from `^10.0.1` to `^10.0.3` ([#5082](https://github.com/MetaMask/core/pull/5082)), ([#5272](https://github.com/MetaMask/core/pull/5272))
82
- - Bump `@metamask/utils` from `^10.0.0` to `^11.1.0` ([#5080](https://github.com/MetaMask/core/pull/5080)), ([#5223](https://github.com/MetaMask/core/pull/5223))
87
+ - Bump `@metamask/base-controller` from `^7.0.0` to `^8.0.0` ([#5079](https://github.com/MetaMask/core/pull/5079), [#5135](https://github.com/MetaMask/core/pull/5135), [#5305](https://github.com/MetaMask/core/pull/5305))
88
+ - Bump `@metamask/json-rpc-engine` from `^10.0.1` to `^10.0.3` ([#5082](https://github.com/MetaMask/core/pull/5082), [#5272](https://github.com/MetaMask/core/pull/5272))
89
+ - Bump `@metamask/utils` from `^10.0.0` to `^11.1.0` ([#5080](https://github.com/MetaMask/core/pull/5080), [#5223](https://github.com/MetaMask/core/pull/5223))
83
90
  - Bump `nanoid` from `^3.1.31` to `^3.3.8` ([#5073](https://github.com/MetaMask/core/pull/5073))
84
91
 
85
92
  ## [3.0.2]
@@ -113,7 +120,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
113
120
  ["Are the Types Wrong?"](https://arethetypeswrong.github.io/) tool as
114
121
  ["masquerading as CJS"](https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/FalseCJS.md).
115
122
  All of the ATTW checks now pass.
116
- - Remove chunk files ([#4648](https://github.com/MetaMask/core/pull/4648)).
123
+ - Remove chunk files. ([#4648](https://github.com/MetaMask/core/pull/4648))
117
124
  - Previously, the build tool we used to generate JavaScript files extracted
118
125
  common code to "chunk" files. While this was intended to make this package
119
126
  more tree-shakeable, it also made debugging more difficult for our
@@ -159,7 +166,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
159
166
 
160
167
  - Initial release
161
168
 
162
- [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/permission-log-controller@5.1.0...HEAD
169
+ [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/permission-log-controller@6.0.0...HEAD
170
+ [6.0.0]: https://github.com/MetaMask/core/compare/@metamask/permission-log-controller@5.1.0...@metamask/permission-log-controller@6.0.0
163
171
  [5.1.0]: https://github.com/MetaMask/core/compare/@metamask/permission-log-controller@5.0.0...@metamask/permission-log-controller@5.1.0
164
172
  [5.0.0]: https://github.com/MetaMask/core/compare/@metamask/permission-log-controller@4.1.1...@metamask/permission-log-controller@5.0.0
165
173
  [4.1.1]: https://github.com/MetaMask/core/compare/@metamask/permission-log-controller@4.1.0...@metamask/permission-log-controller@4.1.1
@@ -2,7 +2,7 @@
2
2
  * This file is auto generated.
3
3
  * Do not edit manually.
4
4
  */
5
- import type { PermissionLogController } from "./PermissionLogController.mjs";
5
+ import type { PermissionLogController } from './PermissionLogController.js';
6
6
  /**
7
7
  * Updates the exposed account history for the given origin.
8
8
  * Sets the 'last seen' time to Date.now() for the given accounts.
@@ -34,4 +34,4 @@ export type PermissionLogControllerCreateMiddlewareAction = {
34
34
  * Union of all PermissionLogController action types.
35
35
  */
36
36
  export type PermissionLogControllerMethodActions = PermissionLogControllerUpdateAccountsHistoryAction | PermissionLogControllerCreateMiddlewareAction;
37
- //# sourceMappingURL=PermissionLogController-method-action-types.d.mts.map
37
+ //# sourceMappingURL=PermissionLogController-method-action-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PermissionLogController-method-action-types.d.ts","sourceRoot":"","sources":["../src/PermissionLogController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAE5E;;;;;;;;GAQG;AACH,MAAM,MAAM,kDAAkD,GAAG;IAC/D,IAAI,EAAE,+CAA+C,CAAC;IACtD,OAAO,EAAE,uBAAuB,CAAC,uBAAuB,CAAC,CAAC;CAC3D,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,MAAM,6CAA6C,GAAG;IAC1D,IAAI,EAAE,0CAA0C,CAAC;IACjD,OAAO,EAAE,uBAAuB,CAAC,kBAAkB,CAAC,CAAC;CACtD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,oCAAoC,GAC5C,kDAAkD,GAClD,6CAA6C,CAAC"}
@@ -3,4 +3,4 @@
3
3
  * Do not edit manually.
4
4
  */
5
5
  export {};
6
- //# sourceMappingURL=PermissionLogController-method-action-types.mjs.map
6
+ //# sourceMappingURL=PermissionLogController-method-action-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PermissionLogController-method-action-types.js","sourceRoot":"","sources":["../src/PermissionLogController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { PermissionLogController } from './PermissionLogController.js';\n\n/**\n * Updates the exposed account history for the given origin.\n * Sets the 'last seen' time to Date.now() for the given accounts.\n * Does **not** update the 'lastApproved' time for the permission itself.\n * Returns if the accounts array is empty.\n *\n * @param origin - The origin that the accounts are exposed to.\n * @param accounts - The accounts.\n */\nexport type PermissionLogControllerUpdateAccountsHistoryAction = {\n type: `PermissionLogController:updateAccountsHistory`;\n handler: PermissionLogController['updateAccountsHistory'];\n};\n\n/**\n * Create a permissions log middleware. Records permissions activity and history:\n *\n * Activity: requests and responses for restricted and most wallet_ methods.\n *\n * History: for each origin, the last time a permission was granted, including\n * which accounts were exposed, if any.\n *\n * @returns The permissions log middleware.\n */\nexport type PermissionLogControllerCreateMiddlewareAction = {\n type: `PermissionLogController:createMiddleware`;\n handler: PermissionLogController['createMiddleware'];\n};\n\n/**\n * Union of all PermissionLogController action types.\n */\nexport type PermissionLogControllerMethodActions =\n | PermissionLogControllerUpdateAccountsHistoryAction\n | PermissionLogControllerCreateMiddlewareAction;\n"]}
@@ -1,10 +1,10 @@
1
- import { BaseController } from "@metamask/base-controller";
2
- import type { ControllerGetStateAction, ControllerStateChangeEvent } from "@metamask/base-controller";
3
- import type { JsonRpcMiddleware } from "@metamask/json-rpc-engine";
4
- import type { Messenger } from "@metamask/messenger";
5
- import type { Json, JsonRpcRequest, JsonRpcParams } from "@metamask/utils";
6
- import { LOG_METHOD_TYPES } from "./enums.cjs";
7
- import type { PermissionLogControllerMethodActions } from "./PermissionLogController-method-action-types.cjs";
1
+ import { BaseController } from '@metamask/base-controller';
2
+ import type { ControllerGetStateAction, ControllerStateChangeEvent } from '@metamask/base-controller';
3
+ import type { JsonRpcMiddleware } from '@metamask/json-rpc-engine';
4
+ import type { Messenger } from '@metamask/messenger';
5
+ import type { Json, JsonRpcRequest, JsonRpcParams } from '@metamask/utils';
6
+ import { LOG_METHOD_TYPES } from './enums.js';
7
+ import type { PermissionLogControllerMethodActions } from './PermissionLogController-method-action-types.js';
8
8
  export type JsonRpcRequestWithOrigin<Params extends JsonRpcParams = JsonRpcParams> = JsonRpcRequest<Params> & {
9
9
  origin?: string;
10
10
  };
@@ -83,4 +83,4 @@ export declare class PermissionLogController extends BaseController<typeof name,
83
83
  createMiddleware(): JsonRpcMiddleware<JsonRpcParams, Json>;
84
84
  }
85
85
  export {};
86
- //# sourceMappingURL=PermissionLogController.d.cts.map
86
+ //# sourceMappingURL=PermissionLogController.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PermissionLogController.d.ts","sourceRoot":"","sources":["../src/PermissionLogController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAC3B,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,KAAK,EACV,IAAI,EACJ,cAAc,EACd,aAAa,EAEd,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAGL,gBAAgB,EAGjB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,oCAAoC,EAAE,MAAM,kDAAkD,CAAC;AAE7G,MAAM,MAAM,wBAAwB,CAClC,MAAM,SAAS,aAAa,GAAG,aAAa,IAC1C,cAAc,CAAC,MAAM,CAAC,GAAG;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,gBAAgB,EAAE,MAAM,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,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SAAS,CACtD,OAAO,IAAI,EACX,8BAA8B,EAC9B,6BAA6B,CAC9B,CAAC;AAOF,QAAA,MAAM,IAAI,4BAA4B,CAAC;AAOvC;;;GAGG;AACH,qBAAa,uBAAwB,SAAQ,cAAc,CACzD,OAAO,IAAI,EACX,4BAA4B,EAC5B,gCAAgC,CACjC;;IAGC,YAAY,EACV,SAAS,EACT,iBAAiB,EACjB,KAAK,GACN,EAAE,8BAA8B,EAyBhC;IAED;;;;;;;;OAQG;IACH,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,CAU9D;IAED;;;;;;;;;OASG;IACH,gBAAgB,IAAI,iBAAiB,CAAC,aAAa,EAAE,IAAI,CAAC,CAqCzD;CA+PF"}
@@ -0,0 +1,310 @@
1
+ import { BaseController } from '@metamask/base-controller';
2
+ import { hasProperty } from '@metamask/utils';
3
+ import { LOG_IGNORE_METHODS, LOG_LIMIT, LOG_METHOD_TYPES, WALLET_PREFIX, CAVEAT_TYPES, } from './enums.js';
4
+ const defaultState = {
5
+ permissionHistory: {},
6
+ permissionActivityLog: [],
7
+ };
8
+ const name = 'PermissionLogController';
9
+ const MESSENGER_EXPOSED_METHODS = [
10
+ 'updateAccountsHistory',
11
+ 'createMiddleware',
12
+ ];
13
+ /**
14
+ * Controller with middleware for logging requests and responses to restricted
15
+ * and permissions-related methods.
16
+ */
17
+ export class PermissionLogController extends BaseController {
18
+ #restrictedMethods;
19
+ constructor({ messenger, restrictedMethods, state, }) {
20
+ super({
21
+ messenger,
22
+ name,
23
+ metadata: {
24
+ permissionHistory: {
25
+ includeInStateLogs: true,
26
+ persist: true,
27
+ includeInDebugSnapshot: false,
28
+ usedInUi: true,
29
+ },
30
+ permissionActivityLog: {
31
+ includeInStateLogs: true,
32
+ persist: false,
33
+ includeInDebugSnapshot: false,
34
+ usedInUi: false,
35
+ },
36
+ },
37
+ state: { ...defaultState, ...state },
38
+ });
39
+ this.#restrictedMethods = restrictedMethods;
40
+ this.messenger.registerMethodActionHandlers(this, MESSENGER_EXPOSED_METHODS);
41
+ }
42
+ /**
43
+ * Updates the exposed account history for the given origin.
44
+ * Sets the 'last seen' time to Date.now() for the given accounts.
45
+ * Does **not** update the 'lastApproved' time for the permission itself.
46
+ * Returns if the accounts array is empty.
47
+ *
48
+ * @param origin - The origin that the accounts are exposed to.
49
+ * @param accounts - The accounts.
50
+ */
51
+ updateAccountsHistory(origin, accounts) {
52
+ if (accounts.length === 0) {
53
+ return;
54
+ }
55
+ const newEntries = {
56
+ eth_accounts: {
57
+ accounts: this.#getAccountToTimeMap(accounts, Date.now()),
58
+ },
59
+ };
60
+ this.#commitNewHistory(origin, newEntries);
61
+ }
62
+ /**
63
+ * Create a permissions log middleware. Records permissions activity and history:
64
+ *
65
+ * Activity: requests and responses for restricted and most wallet_ methods.
66
+ *
67
+ * History: for each origin, the last time a permission was granted, including
68
+ * which accounts were exposed, if any.
69
+ *
70
+ * @returns The permissions log middleware.
71
+ */
72
+ createMiddleware() {
73
+ return (req, res, next) => {
74
+ const { origin, method } = req;
75
+ const isInternal = method.startsWith(WALLET_PREFIX);
76
+ const isEthRequestAccounts = method === 'eth_requestAccounts';
77
+ // Determine if the method should be logged
78
+ if ((!LOG_IGNORE_METHODS.includes(method) &&
79
+ (isInternal || this.#restrictedMethods.has(method))) ||
80
+ isEthRequestAccounts) {
81
+ const activityEntry = this.#logRequest(req, isInternal);
82
+ const requestedMethods = this.#getRequestedMethods(req);
83
+ // Call next with a return handler for capturing the response
84
+ next((callback) => {
85
+ const time = Date.now();
86
+ this.#logResponse(activityEntry, res, time);
87
+ if (requestedMethods && !res.error && res.result && origin) {
88
+ this.#logPermissionsHistory(requestedMethods, origin, res.result, time, isEthRequestAccounts);
89
+ }
90
+ callback();
91
+ });
92
+ return;
93
+ }
94
+ next();
95
+ };
96
+ }
97
+ /**
98
+ * Get a map from account addresses to the given time.
99
+ *
100
+ * @param accounts - An array of addresses.
101
+ * @param time - A time, e.g. Date.now().
102
+ * @returns A string:number map of addresses to time.
103
+ */
104
+ #getAccountToTimeMap(accounts, time) {
105
+ return accounts.reduce((acc, account) => ({
106
+ ...acc,
107
+ [account]: time,
108
+ }), {});
109
+ }
110
+ /**
111
+ * Creates and commits an activity log entry, without response data.
112
+ *
113
+ * @param request - The request object.
114
+ * @param isInternal - Whether the request is internal.
115
+ * @returns new added activity entry
116
+ */
117
+ #logRequest(request, isInternal) {
118
+ const activityEntry = {
119
+ id: request.id,
120
+ method: request.method,
121
+ methodType: isInternal
122
+ ? LOG_METHOD_TYPES.internal
123
+ : LOG_METHOD_TYPES.restricted,
124
+ origin: request.origin,
125
+ requestTime: Date.now(),
126
+ responseTime: null,
127
+ success: null,
128
+ };
129
+ this.update((state) => {
130
+ const newLogs = [...state.permissionActivityLog, activityEntry];
131
+ state.permissionActivityLog =
132
+ // remove oldest log if exceeding size limit
133
+ newLogs.length > LOG_LIMIT ? newLogs.slice(1) : newLogs;
134
+ });
135
+ return activityEntry;
136
+ }
137
+ /**
138
+ * Adds response data to an existing activity log entry.
139
+ * Entry assumed already committed (i.e., in the log).
140
+ *
141
+ * @param entry - The entry to add a response to.
142
+ * @param response - The response object.
143
+ * @param time - Output from Date.now()
144
+ */
145
+ #logResponse(entry, response, time) {
146
+ if (!entry || !response) {
147
+ return;
148
+ }
149
+ // The JSON-RPC 2.0 specification defines "success" by the presence of
150
+ // either the "result" or "error" property. The specification forbids
151
+ // both properties from being present simultaneously, and our JSON-RPC
152
+ // stack is spec-compliant at the time of writing.
153
+ this.update((state) => {
154
+ state.permissionActivityLog = state.permissionActivityLog.map((log) => {
155
+ // Update the log entry that matches the given entry id
156
+ if (log.id === entry.id) {
157
+ return {
158
+ ...log,
159
+ success: hasProperty(response, 'result'),
160
+ responseTime: time,
161
+ };
162
+ }
163
+ return log;
164
+ });
165
+ });
166
+ }
167
+ /**
168
+ * Create new permissions history log entries, if any, and commit them.
169
+ *
170
+ * @param requestedMethods - The method names corresponding to the requested permissions.
171
+ * @param origin - The origin of the permissions request.
172
+ * @param result - The permissions request response.result.
173
+ * @param time - The time of the request, i.e. Date.now().
174
+ * @param isEthRequestAccounts - Whether the permissions request was 'eth_requestAccounts'.
175
+ */
176
+ #logPermissionsHistory(requestedMethods, origin, result, time, isEthRequestAccounts) {
177
+ let newEntries;
178
+ if (isEthRequestAccounts) {
179
+ // Type assertion: We are assuming that the response data contains
180
+ // a set of accounts if the RPC method is "eth_requestAccounts".
181
+ const accounts = result;
182
+ newEntries = {
183
+ eth_accounts: {
184
+ accounts: this.#getAccountToTimeMap(accounts, time),
185
+ lastApproved: time,
186
+ },
187
+ };
188
+ }
189
+ else {
190
+ // Records new "lastApproved" times for the granted permissions, if any.
191
+ // Special handling for eth_accounts, in order to record the time the
192
+ // accounts were last seen or approved by the origin.
193
+ // Type assertion: We are assuming that the response data contains
194
+ // a set of permissions if the RPC method is "eth_requestPermissions".
195
+ const permissions = result;
196
+ newEntries = permissions.reduce((acc, permission) => {
197
+ const method = permission.parentCapability;
198
+ if (!requestedMethods.includes(method)) {
199
+ return acc;
200
+ }
201
+ if (method === 'eth_accounts') {
202
+ const accounts = this.#getAccountsFromPermission(permission);
203
+ return {
204
+ ...acc,
205
+ [method]: {
206
+ lastApproved: time,
207
+ accounts: this.#getAccountToTimeMap(accounts, time),
208
+ },
209
+ };
210
+ }
211
+ return {
212
+ ...acc,
213
+ [method]: {
214
+ lastApproved: time,
215
+ },
216
+ };
217
+ }, {});
218
+ }
219
+ if (Object.keys(newEntries).length > 0) {
220
+ this.#commitNewHistory(origin, newEntries);
221
+ }
222
+ }
223
+ /**
224
+ * Commit new entries to the permissions history log.
225
+ * Merges the history for the given origin, overwriting existing entries
226
+ * with the same key (permission name).
227
+ *
228
+ * @param origin - The requesting origin.
229
+ * @param newEntries - The new entries to commit.
230
+ */
231
+ #commitNewHistory(origin, newEntries) {
232
+ const { permissionHistory } = this.state;
233
+ // a simple merge updates most permissions
234
+ const oldOriginHistory = permissionHistory[origin] ?? {};
235
+ const newOriginHistory = {
236
+ ...oldOriginHistory,
237
+ ...newEntries,
238
+ };
239
+ // eth_accounts requires special handling, because of information
240
+ // we store about the accounts
241
+ const existingEthAccountsEntry = oldOriginHistory.eth_accounts;
242
+ const newEthAccountsEntry = newEntries.eth_accounts;
243
+ if (existingEthAccountsEntry && newEthAccountsEntry) {
244
+ // we may intend to update just the accounts, not the permission
245
+ // itself
246
+ const lastApproved = newEthAccountsEntry.lastApproved ??
247
+ existingEthAccountsEntry.lastApproved;
248
+ // merge old and new eth_accounts history entries
249
+ newOriginHistory.eth_accounts = {
250
+ lastApproved,
251
+ accounts: {
252
+ ...existingEthAccountsEntry.accounts,
253
+ ...newEthAccountsEntry.accounts,
254
+ },
255
+ };
256
+ }
257
+ this.update((state) => {
258
+ state.permissionHistory = {
259
+ ...permissionHistory,
260
+ [origin]: newOriginHistory,
261
+ };
262
+ });
263
+ }
264
+ /**
265
+ * Get all requested methods from a permissions request.
266
+ *
267
+ * @param request - The request object.
268
+ * @returns The names of the requested permissions.
269
+ */
270
+ #getRequestedMethods(request) {
271
+ const { method, params } = request;
272
+ if (method === 'eth_requestAccounts') {
273
+ return ['eth_accounts'];
274
+ }
275
+ else if (method === `${WALLET_PREFIX}requestPermissions` &&
276
+ params &&
277
+ Array.isArray(params) &&
278
+ params[0] &&
279
+ typeof params[0] === 'object' &&
280
+ !Array.isArray(params[0])) {
281
+ return Object.keys(params[0]);
282
+ }
283
+ return null;
284
+ }
285
+ /**
286
+ * Get the permitted accounts from an eth_accounts permissions object.
287
+ * Returns an empty array if the permission is not eth_accounts.
288
+ *
289
+ * @param permission - The permissions object.
290
+ * @param permission.parentCapability - The permissions parentCapability.
291
+ * @param permission.caveats - The permissions caveats.
292
+ * @returns The permitted accounts.
293
+ */
294
+ #getAccountsFromPermission(permission) {
295
+ if (permission.parentCapability !== 'eth_accounts' || !permission.caveats) {
296
+ return [];
297
+ }
298
+ const accounts = new Set();
299
+ for (const caveat of permission.caveats) {
300
+ if (caveat.type === CAVEAT_TYPES.restrictReturnedAccounts &&
301
+ Array.isArray(caveat.value)) {
302
+ for (const value of caveat.value) {
303
+ accounts.add(value);
304
+ }
305
+ }
306
+ }
307
+ return [...accounts];
308
+ }
309
+ }
310
+ //# sourceMappingURL=PermissionLogController.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PermissionLogController.js","sourceRoot":"","sources":["../src/PermissionLogController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAO3D,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAQ9C,OAAO,EACL,kBAAkB,EAClB,SAAS,EACT,gBAAgB,EAChB,aAAa,EACb,YAAY,GACb,MAAM,YAAY,CAAC;AA4EpB,MAAM,YAAY,GAAiC;IACjD,iBAAiB,EAAE,EAAE;IACrB,qBAAqB,EAAE,EAAE;CAC1B,CAAC;AAEF,MAAM,IAAI,GAAG,yBAAyB,CAAC;AAEvC,MAAM,yBAAyB,GAAG;IAChC,uBAAuB;IACvB,kBAAkB;CACV,CAAC;AAEX;;;GAGG;AACH,MAAM,OAAO,uBAAwB,SAAQ,cAI5C;IACU,kBAAkB,CAAc;IAEzC,YAAY,EACV,SAAS,EACT,iBAAiB,EACjB,KAAK,GAC0B;QAC/B,KAAK,CAAC;YACJ,SAAS;YACT,IAAI;YACJ,QAAQ,EAAE;gBACR,iBAAiB,EAAE;oBACjB,kBAAkB,EAAE,IAAI;oBACxB,OAAO,EAAE,IAAI;oBACb,sBAAsB,EAAE,KAAK;oBAC7B,QAAQ,EAAE,IAAI;iBACf;gBACD,qBAAqB,EAAE;oBACrB,kBAAkB,EAAE,IAAI;oBACxB,OAAO,EAAE,KAAK;oBACd,sBAAsB,EAAE,KAAK;oBAC7B,QAAQ,EAAE,KAAK;iBAChB;aACF;YACD,KAAK,EAAE,EAAE,GAAG,YAAY,EAAE,GAAG,KAAK,EAAE;SACrC,CAAC,CAAC;QACH,IAAI,C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OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;;OAQG;IACH,0BAA0B,CAAC,UAAsB;QAC/C,IAAI,UAAU,CAAC,gBAAgB,KAAK,cAAc,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;YAC1E,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAU,CAAC;QACnC,KAAK,MAAM,MAAM,IAAI,UAAU,CAAC,OAAO,EAAE,CAAC;YACxC,IACE,MAAM,CAAC,IAAI,KAAK,YAAY,CAAC,wBAAwB;gBACrD,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,EAC3B,CAAC;gBACD,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;oBACjC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;gBACtB,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,CAAC,GAAG,QAAQ,CAAC,CAAC;IACvB,CAAC;CACF","sourcesContent":["import { BaseController } from '@metamask/base-controller';\nimport type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n} from '@metamask/base-controller';\nimport type { JsonRpcMiddleware } from '@metamask/json-rpc-engine';\nimport type { Messenger } from '@metamask/messenger';\nimport { hasProperty } from '@metamask/utils';\nimport type {\n Json,\n JsonRpcRequest,\n JsonRpcParams,\n PendingJsonRpcResponse,\n} from '@metamask/utils';\n\nimport {\n LOG_IGNORE_METHODS,\n LOG_LIMIT,\n LOG_METHOD_TYPES,\n WALLET_PREFIX,\n CAVEAT_TYPES,\n} from './enums.js';\nimport type { PermissionLogControllerMethodActions } from './PermissionLogController-method-action-types.js';\n\nexport type JsonRpcRequestWithOrigin<\n Params extends JsonRpcParams = JsonRpcParams,\n> = JsonRpcRequest<Params> & {\n origin?: string;\n};\n\nexport type Caveat = {\n type: string;\n value: string[];\n};\n\nexport type Permission = {\n parentCapability: string;\n caveats?: Caveat[];\n};\n\nexport type PermissionActivityLog = {\n id: string | number | null;\n method: string;\n methodType: LOG_METHOD_TYPES;\n origin?: string;\n requestTime: number;\n responseTime: number | null;\n success: boolean | null;\n};\n\nexport type PermissionLog = {\n accounts?: Record<string, number>;\n lastApproved?: number;\n};\nexport type PermissionEntry = Record<string, PermissionLog>;\n\nexport type PermissionHistory = Record<string, PermissionEntry>;\n\n/**\n *\n * Permission log controller state\n *\n * @property permissionHistory - permission history\n * @property permissionActivityLog - permission activity logs\n */\nexport type PermissionLogControllerState = {\n permissionHistory: PermissionHistory;\n permissionActivityLog: PermissionActivityLog[];\n};\n\nexport type PermissionLogControllerOptions = {\n restrictedMethods: Set<string>;\n state?: Partial<PermissionLogControllerState>;\n messenger: PermissionLogControllerMessenger;\n};\n\nexport type PermissionLogControllerGetStateAction = ControllerGetStateAction<\n typeof name,\n PermissionLogControllerState\n>;\n\nexport type PermissionLogControllerActions =\n | PermissionLogControllerGetStateAction\n | PermissionLogControllerMethodActions;\n\nexport type PermissionLogControllerStateChangeEvent =\n ControllerStateChangeEvent<typeof name, PermissionLogControllerState>;\n\nexport type PermissionLogControllerEvents =\n PermissionLogControllerStateChangeEvent;\n\nexport type PermissionLogControllerMessenger = Messenger<\n typeof name,\n PermissionLogControllerActions,\n PermissionLogControllerEvents\n>;\n\nconst defaultState: PermissionLogControllerState = {\n permissionHistory: {},\n permissionActivityLog: [],\n};\n\nconst name = 'PermissionLogController';\n\nconst MESSENGER_EXPOSED_METHODS = [\n 'updateAccountsHistory',\n 'createMiddleware',\n] as const;\n\n/**\n * Controller with middleware for logging requests and responses to restricted\n * and permissions-related methods.\n */\nexport class PermissionLogController extends BaseController<\n typeof name,\n PermissionLogControllerState,\n PermissionLogControllerMessenger\n> {\n readonly #restrictedMethods: Set<string>;\n\n constructor({\n messenger,\n restrictedMethods,\n state,\n }: PermissionLogControllerOptions) {\n super({\n messenger,\n name,\n metadata: {\n permissionHistory: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n permissionActivityLog: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: false,\n },\n },\n state: { ...defaultState, ...state },\n });\n this.#restrictedMethods = restrictedMethods;\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n }\n\n /**\n * Updates the exposed account history for the given origin.\n * Sets the 'last seen' time to Date.now() for the given accounts.\n * Does **not** update the 'lastApproved' time for the permission itself.\n * Returns if the accounts array is empty.\n *\n * @param origin - The origin that the accounts are exposed to.\n * @param accounts - The accounts.\n */\n updateAccountsHistory(origin: string, accounts: string[]): void {\n if (accounts.length === 0) {\n return;\n }\n const newEntries = {\n eth_accounts: {\n accounts: this.#getAccountToTimeMap(accounts, Date.now()),\n },\n };\n this.#commitNewHistory(origin, newEntries);\n }\n\n /**\n * Create a permissions log middleware. Records permissions activity and history:\n *\n * Activity: requests and responses for restricted and most wallet_ methods.\n *\n * History: for each origin, the last time a permission was granted, including\n * which accounts were exposed, if any.\n *\n * @returns The permissions log middleware.\n */\n createMiddleware(): JsonRpcMiddleware<JsonRpcParams, Json> {\n return (req: JsonRpcRequestWithOrigin, res, next) => {\n const { origin, method } = req;\n const isInternal = method.startsWith(WALLET_PREFIX);\n const isEthRequestAccounts = method === 'eth_requestAccounts';\n\n // Determine if the method should be logged\n if (\n (!LOG_IGNORE_METHODS.includes(method) &&\n (isInternal || this.#restrictedMethods.has(method))) ||\n isEthRequestAccounts\n ) {\n const activityEntry = this.#logRequest(req, isInternal);\n\n const requestedMethods = this.#getRequestedMethods(req);\n\n // Call next with a return handler for capturing the response\n next((callback) => {\n const time = Date.now();\n this.#logResponse(activityEntry, res, time);\n\n if (requestedMethods && !res.error && res.result && origin) {\n this.#logPermissionsHistory(\n requestedMethods,\n origin,\n res.result,\n time,\n isEthRequestAccounts,\n );\n }\n callback();\n });\n return;\n }\n\n next();\n };\n }\n\n /**\n * Get a map from account addresses to the given time.\n *\n * @param accounts - An array of addresses.\n * @param time - A time, e.g. Date.now().\n * @returns A string:number map of addresses to time.\n */\n #getAccountToTimeMap(\n accounts: string[],\n time: number,\n ): Record<string, number> {\n return accounts.reduce(\n (acc, account) => ({\n ...acc,\n [account]: time,\n }),\n {},\n );\n }\n\n /**\n * Creates and commits an activity log entry, without response data.\n *\n * @param request - The request object.\n * @param isInternal - Whether the request is internal.\n * @returns new added activity entry\n */\n #logRequest(\n request: JsonRpcRequestWithOrigin,\n isInternal: boolean,\n ): PermissionActivityLog {\n const activityEntry: PermissionActivityLog = {\n id: request.id,\n method: request.method,\n methodType: isInternal\n ? LOG_METHOD_TYPES.internal\n : LOG_METHOD_TYPES.restricted,\n origin: request.origin,\n requestTime: Date.now(),\n responseTime: null,\n success: null,\n };\n this.update((state) => {\n const newLogs = [...state.permissionActivityLog, activityEntry];\n state.permissionActivityLog =\n // remove oldest log if exceeding size limit\n newLogs.length > LOG_LIMIT ? newLogs.slice(1) : newLogs;\n });\n return activityEntry;\n }\n\n /**\n * Adds response data to an existing activity log entry.\n * Entry assumed already committed (i.e., in the log).\n *\n * @param entry - The entry to add a response to.\n * @param response - The response object.\n * @param time - Output from Date.now()\n */\n #logResponse(\n entry: PermissionActivityLog,\n response: PendingJsonRpcResponse,\n time: number,\n ): void {\n if (!entry || !response) {\n return;\n }\n\n // The JSON-RPC 2.0 specification defines \"success\" by the presence of\n // either the \"result\" or \"error\" property. The specification forbids\n // both properties from being present simultaneously, and our JSON-RPC\n // stack is spec-compliant at the time of writing.\n this.update((state) => {\n state.permissionActivityLog = state.permissionActivityLog.map((log) => {\n // Update the log entry that matches the given entry id\n if (log.id === entry.id) {\n return {\n ...log,\n success: hasProperty(response, 'result'),\n responseTime: time,\n };\n }\n return log;\n });\n });\n }\n\n /**\n * Create new permissions history log entries, if any, and commit them.\n *\n * @param requestedMethods - The method names corresponding to the requested permissions.\n * @param origin - The origin of the permissions request.\n * @param result - The permissions request response.result.\n * @param time - The time of the request, i.e. Date.now().\n * @param isEthRequestAccounts - Whether the permissions request was 'eth_requestAccounts'.\n */\n #logPermissionsHistory(\n requestedMethods: string[],\n origin: string,\n result: Json,\n time: number,\n isEthRequestAccounts: boolean,\n ): void {\n let newEntries: PermissionEntry;\n\n if (isEthRequestAccounts) {\n // Type assertion: We are assuming that the response data contains\n // a set of accounts if the RPC method is \"eth_requestAccounts\".\n const accounts = result as string[];\n newEntries = {\n eth_accounts: {\n accounts: this.#getAccountToTimeMap(accounts, time),\n lastApproved: time,\n },\n };\n } else {\n // Records new \"lastApproved\" times for the granted permissions, if any.\n // Special handling for eth_accounts, in order to record the time the\n // accounts were last seen or approved by the origin.\n // Type assertion: We are assuming that the response data contains\n // a set of permissions if the RPC method is \"eth_requestPermissions\".\n const permissions = result as Permission[];\n newEntries = permissions.reduce((acc: PermissionEntry, permission) => {\n const method = permission.parentCapability;\n\n if (!requestedMethods.includes(method)) {\n return acc;\n }\n\n if (method === 'eth_accounts') {\n const accounts = this.#getAccountsFromPermission(permission);\n return {\n ...acc,\n [method]: {\n lastApproved: time,\n accounts: this.#getAccountToTimeMap(accounts, time),\n },\n };\n }\n\n return {\n ...acc,\n [method]: {\n lastApproved: time,\n },\n };\n }, {});\n }\n\n if (Object.keys(newEntries).length > 0) {\n this.#commitNewHistory(origin, newEntries);\n }\n }\n\n /**\n * Commit new entries to the permissions history log.\n * Merges the history for the given origin, overwriting existing entries\n * with the same key (permission name).\n *\n * @param origin - The requesting origin.\n * @param newEntries - The new entries to commit.\n */\n #commitNewHistory(origin: string, newEntries: PermissionEntry): void {\n const { permissionHistory } = this.state;\n\n // a simple merge updates most permissions\n const oldOriginHistory = permissionHistory[origin] ?? {};\n const newOriginHistory = {\n ...oldOriginHistory,\n ...newEntries,\n };\n\n // eth_accounts requires special handling, because of information\n // we store about the accounts\n const existingEthAccountsEntry = oldOriginHistory.eth_accounts;\n const newEthAccountsEntry = newEntries.eth_accounts;\n\n if (existingEthAccountsEntry && newEthAccountsEntry) {\n // we may intend to update just the accounts, not the permission\n // itself\n const lastApproved =\n newEthAccountsEntry.lastApproved ??\n existingEthAccountsEntry.lastApproved;\n\n // merge old and new eth_accounts history entries\n newOriginHistory.eth_accounts = {\n lastApproved,\n accounts: {\n ...existingEthAccountsEntry.accounts,\n ...newEthAccountsEntry.accounts,\n },\n };\n }\n\n this.update((state) => {\n state.permissionHistory = {\n ...permissionHistory,\n [origin]: newOriginHistory,\n };\n });\n }\n\n /**\n * Get all requested methods from a permissions request.\n *\n * @param request - The request object.\n * @returns The names of the requested permissions.\n */\n #getRequestedMethods(request: JsonRpcRequestWithOrigin): string[] | null {\n const { method, params } = request;\n if (method === 'eth_requestAccounts') {\n return ['eth_accounts'];\n } else if (\n method === `${WALLET_PREFIX}requestPermissions` &&\n params &&\n Array.isArray(params) &&\n params[0] &&\n typeof params[0] === 'object' &&\n !Array.isArray(params[0])\n ) {\n return Object.keys(params[0]);\n }\n return null;\n }\n\n /**\n * Get the permitted accounts from an eth_accounts permissions object.\n * Returns an empty array if the permission is not eth_accounts.\n *\n * @param permission - The permissions object.\n * @param permission.parentCapability - The permissions parentCapability.\n * @param permission.caveats - The permissions caveats.\n * @returns The permitted accounts.\n */\n #getAccountsFromPermission(permission: Permission): string[] {\n if (permission.parentCapability !== 'eth_accounts' || !permission.caveats) {\n return [];\n }\n\n const accounts = new Set<string>();\n for (const caveat of permission.caveats) {\n if (\n caveat.type === CAVEAT_TYPES.restrictReturnedAccounts &&\n Array.isArray(caveat.value)\n ) {\n for (const value of caveat.value) {\n accounts.add(value);\n }\n }\n }\n\n return [...accounts];\n }\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  export declare const WALLET_PREFIX = "wallet_";
2
2
  export declare const CAVEAT_TYPES: Readonly<{
3
- restrictReturnedAccounts: "restrictReturnedAccounts";
3
+ restrictReturnedAccounts: 'restrictReturnedAccounts';
4
4
  }>;
5
5
  export declare const LOG_IGNORE_METHODS: string[];
6
6
  export declare enum LOG_METHOD_TYPES {
@@ -11,4 +11,4 @@ export declare enum LOG_METHOD_TYPES {
11
11
  * The permission activity log size limit.
12
12
  */
13
13
  export declare const LOG_LIMIT = 100;
14
- //# sourceMappingURL=enums.d.cts.map
14
+ //# sourceMappingURL=enums.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enums.d.ts","sourceRoot":"","sources":["../src/enums.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,YAAY,CAAC;AAEvC,eAAO,MAAM,YAAY;8BACG,0BAA0B;EACpD,CAAC;AAEH,eAAO,MAAM,kBAAkB,UAG9B,CAAC;AAKF,oBAAY,gBAAgB;IAC1B,UAAU,eAAe;IACzB,QAAQ,aAAa;CACtB;AAGD;;GAEG;AACH,eAAO,MAAM,SAAS,MAAM,CAAC"}
@@ -19,4 +19,4 @@ export var LOG_METHOD_TYPES;
19
19
  * The permission activity log size limit.
20
20
  */
21
21
  export const LOG_LIMIT = 100;
22
- //# sourceMappingURL=enums.mjs.map
22
+ //# sourceMappingURL=enums.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enums.js","sourceRoot":"","sources":["../src/enums.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,aAAa,GAAG,SAAS,CAAC;AAEvC,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC;IACxC,wBAAwB,EAAE,0BAAmC;CAC9D,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,2BAA2B;IAC3B,mBAAmB;CACpB,CAAC;AAEF,4EAA4E;AAC5E,qEAAqE;AACrE,yDAAyD;AACzD,MAAM,CAAN,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IAC1B,6CAAyB,CAAA;IACzB,yCAAqB,CAAA;AACvB,CAAC,EAHW,gBAAgB,KAAhB,gBAAgB,QAG3B;AACD,wDAAwD;AAExD;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,CAAC","sourcesContent":["export const WALLET_PREFIX = 'wallet_';\n\nexport const CAVEAT_TYPES = Object.freeze({\n restrictReturnedAccounts: 'restrictReturnedAccounts' as const,\n});\n\nexport const LOG_IGNORE_METHODS = [\n 'wallet_registerOnboarding',\n 'wallet_watchAsset',\n];\n\n// This enum should be called `LogMethodTypes`, with PascalCase members, but\n// to maintain backwards compatibility, the rule is disabled for now.\n/* eslint-disable @typescript-eslint/naming-convention */\nexport enum LOG_METHOD_TYPES {\n restricted = 'restricted',\n internal = 'internal',\n}\n/* eslint-enable @typescript-eslint/naming-convention */\n\n/**\n * The permission activity log size limit.\n */\nexport const LOG_LIMIT = 100;\n"]}
@@ -1,4 +1,4 @@
1
- export { PermissionLogController } from "./PermissionLogController.cjs";
2
- export type { PermissionLogControllerUpdateAccountsHistoryAction, PermissionLogControllerCreateMiddlewareAction, } from "./PermissionLogController-method-action-types.cjs";
3
- export type { JsonRpcRequestWithOrigin, Caveat, Permission, PermissionActivityLog, PermissionLog, PermissionEntry, PermissionHistory, PermissionLogControllerActions, PermissionLogControllerGetStateAction, PermissionLogControllerStateChangeEvent, PermissionLogControllerEvents, PermissionLogControllerMessenger, PermissionLogControllerState, PermissionLogControllerOptions, } from "./PermissionLogController.cjs";
4
- //# sourceMappingURL=index.d.cts.map
1
+ export { PermissionLogController } from './PermissionLogController.js';
2
+ export type { PermissionLogControllerUpdateAccountsHistoryAction, PermissionLogControllerCreateMiddlewareAction, } from './PermissionLogController-method-action-types.js';
3
+ export type { JsonRpcRequestWithOrigin, Caveat, Permission, PermissionActivityLog, PermissionLog, PermissionEntry, PermissionHistory, PermissionLogControllerActions, PermissionLogControllerGetStateAction, PermissionLogControllerStateChangeEvent, PermissionLogControllerEvents, PermissionLogControllerMessenger, PermissionLogControllerState, PermissionLogControllerOptions, } from './PermissionLogController.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,YAAY,EACV,kDAAkD,EAClD,6CAA6C,GAC9C,MAAM,kDAAkD,CAAC;AAC1D,YAAY,EACV,wBAAwB,EACxB,MAAM,EACN,UAAU,EACV,qBAAqB,EACrB,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,8BAA8B,EAC9B,qCAAqC,EACrC,uCAAuC,EACvC,6BAA6B,EAC7B,gCAAgC,EAChC,4BAA4B,EAC5B,8BAA8B,GAC/B,MAAM,8BAA8B,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { PermissionLogController } from './PermissionLogController.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC","sourcesContent":["export { PermissionLogController } from './PermissionLogController.js';\nexport type {\n PermissionLogControllerUpdateAccountsHistoryAction,\n PermissionLogControllerCreateMiddlewareAction,\n} from './PermissionLogController-method-action-types.js';\nexport type {\n JsonRpcRequestWithOrigin,\n Caveat,\n Permission,\n PermissionActivityLog,\n PermissionLog,\n PermissionEntry,\n PermissionHistory,\n PermissionLogControllerActions,\n PermissionLogControllerGetStateAction,\n PermissionLogControllerStateChangeEvent,\n PermissionLogControllerEvents,\n PermissionLogControllerMessenger,\n PermissionLogControllerState,\n PermissionLogControllerOptions,\n} from './PermissionLogController.js';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask-previews/permission-log-controller",
3
- "version": "5.1.0-preview-8bfa290fb",
3
+ "version": "6.0.0-preview-0a30e47",
4
4
  "description": "Controller with middleware for logging requests and responses to restricted and permissions-related methods",
5
5
  "keywords": [
6
6
  "Ethereum",
@@ -18,19 +18,12 @@
18
18
  "files": [
19
19
  "dist/"
20
20
  ],
21
+ "type": "module",
21
22
  "sideEffects": false,
22
- "main": "./dist/index.cjs",
23
- "types": "./dist/index.d.cts",
24
23
  "exports": {
25
24
  ".": {
26
- "import": {
27
- "types": "./dist/index.d.mts",
28
- "default": "./dist/index.mjs"
29
- },
30
- "require": {
31
- "types": "./dist/index.d.cts",
32
- "default": "./dist/index.cjs"
33
- }
25
+ "types": "./dist/index.d.ts",
26
+ "default": "./dist/index.js"
34
27
  },
35
28
  "./package.json": "./package.json"
36
29
  },
@@ -39,9 +32,11 @@
39
32
  "registry": "https://registry.npmjs.org/"
40
33
  },
41
34
  "scripts": {
42
- "build": "ts-bridge --project tsconfig.build.json --verbose --clean --no-references",
43
- "build:all": "ts-bridge --project tsconfig.build.json --verbose --clean",
35
+ "build": "tsc --project tsconfig.build.json",
36
+ "build:all": "tsc --build tsconfig.build.json --verbose",
37
+ "build:clean": "yarn build:only-clean && yarn build",
44
38
  "build:docs": "typedoc",
39
+ "build:only-clean": "rimraf './dist' './tsconfig.build.tsbuildinfo'",
45
40
  "changelog:update": "../../scripts/update-changelog.sh @metamask/permission-log-controller",
46
41
  "changelog:validate": "../../scripts/validate-changelog.sh @metamask/permission-log-controller",
47
42
  "lint:tsconfigs": "tsx ../../scripts/lint-tsconfigs/lint-tsconfigs.mts",
@@ -55,27 +50,28 @@
55
50
  "test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch"
56
51
  },
57
52
  "dependencies": {
58
- "@metamask/base-controller": "^9.1.0",
59
- "@metamask/json-rpc-engine": "^10.5.0",
60
- "@metamask/messenger": "^2.0.0",
53
+ "@metamask/base-controller": "^10.0.0",
54
+ "@metamask/json-rpc-engine": "^11.0.0",
55
+ "@metamask/messenger": "^3.0.0",
61
56
  "@metamask/utils": "^11.12.0"
62
57
  },
63
58
  "devDependencies": {
64
59
  "@metamask/auto-changelog": "^6.1.0",
65
- "@ts-bridge/cli": "^0.6.4",
66
60
  "@types/deep-freeze-strict": "^1.1.0",
67
61
  "@types/jest": "^30.0.0",
62
+ "@typescript/native": "npm:typescript@^7.0.2",
68
63
  "deep-freeze-strict": "^1.1.1",
69
64
  "deepmerge": "^4.2.2",
70
65
  "jest": "^30.4.2",
71
66
  "nanoid": "^3.3.8",
67
+ "rimraf": "^5.0.5",
72
68
  "ts-jest": "^29.4.11",
73
69
  "tsx": "^4.20.5",
74
70
  "typedoc": "^0.25.13",
75
71
  "typedoc-plugin-missing-exports": "^2.0.0",
76
- "typescript": "~5.3.3"
72
+ "typescript": "npm:@typescript/typescript6@^6.0.2"
77
73
  },
78
74
  "engines": {
79
- "node": "^18.18 || >=20"
75
+ "node": "^22.14.0 || ^24"
80
76
  }
81
77
  }
@@ -1,7 +0,0 @@
1
- "use strict";
2
- /**
3
- * This file is auto generated.
4
- * Do not edit manually.
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- //# sourceMappingURL=PermissionLogController-method-action-types.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PermissionLogController-method-action-types.cjs","sourceRoot":"","sources":["../src/PermissionLogController-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { PermissionLogController } from './PermissionLogController.js';\n\n/**\n * Updates the exposed account history for the given origin.\n * Sets the 'last seen' time to Date.now() for the given accounts.\n * Does **not** update the 'lastApproved' time for the permission itself.\n * Returns if the accounts array is empty.\n *\n * @param origin - The origin that the accounts are exposed to.\n * @param accounts - The accounts.\n */\nexport type PermissionLogControllerUpdateAccountsHistoryAction = {\n type: `PermissionLogController:updateAccountsHistory`;\n handler: PermissionLogController['updateAccountsHistory'];\n};\n\n/**\n * Create a permissions log middleware. Records permissions activity and history:\n *\n * Activity: requests and responses for restricted and most wallet_ methods.\n *\n * History: for each origin, the last time a permission was granted, including\n * which accounts were exposed, if any.\n *\n * @returns The permissions log middleware.\n */\nexport type PermissionLogControllerCreateMiddlewareAction = {\n type: `PermissionLogController:createMiddleware`;\n handler: PermissionLogController['createMiddleware'];\n};\n\n/**\n * Union of all PermissionLogController action types.\n */\nexport type PermissionLogControllerMethodActions =\n | PermissionLogControllerUpdateAccountsHistoryAction\n | PermissionLogControllerCreateMiddlewareAction;\n"]}