@metamask-previews/logging-controller 6.1.1-preview-6bf4b220 → 6.1.1-preview-77daf0c7

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 CHANGED
@@ -7,12 +7,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
- ### Changed
11
-
12
- - **BREAKING:** Use new `Messenger` from `@metamask/messenger` ([#6463](https://github.com/MetaMask/core/pull/6463))
13
- - Previously, `LoggingController` accepted a `RestrictedMessenger` instance from `@metamask/base-controller`.
14
- - **BREAKING:** Metadata property `anonymous` renamed to `includeInDebugSnapshot` ([#6463](https://github.com/MetaMask/core/pull/6463))
15
-
16
10
  ## [6.1.1]
17
11
 
18
12
  ### Changed
@@ -7,14 +7,14 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
7
7
  var _LoggingController_instances, _LoggingController_generateId;
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.LoggingController = void 0;
10
- const next_1 = require("@metamask/base-controller/next");
10
+ const base_controller_1 = require("@metamask/base-controller");
11
11
  const uuid_1 = require("uuid");
12
12
  const name = 'LoggingController';
13
13
  const metadata = {
14
14
  logs: {
15
15
  includeInStateLogs: true,
16
16
  persist: true,
17
- includeInDebugSnapshot: false,
17
+ anonymous: false,
18
18
  usedInUi: false,
19
19
  },
20
20
  };
@@ -24,7 +24,7 @@ const defaultState = {
24
24
  /**
25
25
  * Controller that manages a list of logs for signature requests.
26
26
  */
27
- class LoggingController extends next_1.BaseController {
27
+ class LoggingController extends base_controller_1.BaseController {
28
28
  /**
29
29
  * Creates a LoggingController instance.
30
30
  *
@@ -43,7 +43,7 @@ class LoggingController extends next_1.BaseController {
43
43
  },
44
44
  });
45
45
  _LoggingController_instances.add(this);
46
- this.messenger.registerActionHandler(`${name}:add`, (log) => this.add(log));
46
+ this.messagingSystem.registerActionHandler(`${name}:add`, (log) => this.add(log));
47
47
  }
48
48
  /**
49
49
  * Add log to the state.
@@ -1 +1 @@
1
- {"version":3,"file":"LoggingController.cjs","sourceRoot":"","sources":["../src/LoggingController.ts"],"names":[],"mappings":";;;;;;;;;AAKA,yDAAgE;AAEhE,+BAAoC;AA0BpC,MAAM,IAAI,GAAG,mBAAmB,CAAC;AA8BjC,MAAM,QAAQ,GAA0C;IACtD,IAAI,EAAE;QACJ,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,sBAAsB,EAAE,KAAK;QAC7B,QAAQ,EAAE,KAAK;KAChB;CACF,CAAC;AAEF,MAAM,YAAY,GAAG;IACnB,IAAI,EAAE,EAAE;CACT,CAAC;AAEF;;GAEG;AACH,MAAa,iBAAkB,SAAQ,qBAItC;IACC;;;;;;OAMG;IACH,YAAY,EACV,SAAS,EACT,KAAK,GAIN;QACC,KAAK,CAAC;YACJ,IAAI;YACJ,QAAQ;YACR,SAAS;YACT,KAAK,EAAE;gBACL,GAAG,YAAY;gBACf,GAAG,KAAK;aACT;SACF,CAAC,CAAC;;QAEH,IAAI,CAAC,SAAS,CAAC,qBAAqB,CAAC,GAAG,IAAI,MAAe,EAAE,CAAC,GAAQ,EAAE,EAAE,CACxE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CACd,CAAC;IACJ,CAAC;IAmBD;;;;OAIG;IACH,GAAG,CAAC,GAAQ;QACV,MAAM,MAAM,GAAa;YACvB,EAAE,EAAE,uBAAA,IAAI,mEAAY,MAAhB,IAAI,CAAc;YACtB,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;YACrB,GAAG;SACJ,CAAC;QAEF,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;YACpB,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC;QACjC,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;YACpB,KAAK,CAAC,IAAI,GAAG,EAAE,CAAC;QAClB,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA5ED,8CA4EC;;IAhCG,IAAI,EAAE,GAAG,IAAA,SAAM,GAAE,CAAC;IAClB,OAAO,EAAE,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE;QAC5B,EAAE,GAAG,IAAA,SAAM,GAAE,CAAC;KACf;IACD,OAAO,EAAE,CAAC;AACZ,CAAC","sourcesContent":["import type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n StateMetadata,\n} from '@metamask/base-controller/next';\nimport { BaseController } from '@metamask/base-controller/next';\nimport type { Messenger } from '@metamask/messenger';\nimport { v1 as random } from 'uuid';\n\nimport type { Log } from './logTypes';\n\n/**\n * LogEntry is the entry that will be added to the logging controller state.\n * It consists of a entry key that must be on of the Log union types, and an\n * additional id and timestamp.\n */\nexport type LogEntry = {\n id: string;\n timestamp: number;\n log: Log;\n};\n\n/**\n * Logging controller state\n *\n * @property logs - An object of logs indexed by their ids\n */\nexport type LoggingControllerState = {\n logs: {\n [id: string]: LogEntry;\n };\n};\n\nconst name = 'LoggingController';\n\n/**\n * An action to add log messages to the controller state.\n */\nexport type AddLog = {\n type: `${typeof name}:add`;\n handler: LoggingController['add'];\n};\n\nexport type LoggingControllerGetStateAction = ControllerGetStateAction<\n typeof name,\n LoggingControllerState\n>;\n\nexport type LoggingControllerActions = LoggingControllerGetStateAction | AddLog;\n\nexport type LoggingControllerStateChangeEvent = ControllerStateChangeEvent<\n typeof name,\n LoggingControllerState\n>;\n\nexport type LoggingControllerEvents = LoggingControllerStateChangeEvent;\n\nexport type LoggingControllerMessenger = Messenger<\n typeof name,\n LoggingControllerActions,\n LoggingControllerEvents\n>;\n\nconst metadata: StateMetadata<LoggingControllerState> = {\n logs: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: false,\n usedInUi: false,\n },\n};\n\nconst defaultState = {\n logs: {},\n};\n\n/**\n * Controller that manages a list of logs for signature requests.\n */\nexport class LoggingController extends BaseController<\n typeof name,\n LoggingControllerState,\n LoggingControllerMessenger\n> {\n /**\n * Creates a LoggingController instance.\n *\n * @param options - Constructor options\n * @param options.messenger - An instance of the Messenger\n * @param options.state - Initial state to set on this controller.\n */\n constructor({\n messenger,\n state,\n }: {\n messenger: LoggingControllerMessenger;\n state?: Partial<LoggingControllerState>;\n }) {\n super({\n name,\n metadata,\n messenger,\n state: {\n ...defaultState,\n ...state,\n },\n });\n\n this.messenger.registerActionHandler(`${name}:add` as const, (log: Log) =>\n this.add(log),\n );\n }\n\n /**\n * Method to generate a randomId and ensures no collision with existing ids.\n *\n * We may want to end up using a hashing mechanism to make ids deterministic\n * by the *data* passed in, and then make each key an array of logs that\n * match that id.\n *\n * @returns unique id\n */\n #generateId(): string {\n let id = random();\n while (id in this.state.logs) {\n id = random();\n }\n return id;\n }\n\n /**\n * Add log to the state.\n *\n * @param log - Log to add to the controller\n */\n add(log: Log) {\n const newLog: LogEntry = {\n id: this.#generateId(),\n timestamp: Date.now(),\n log,\n };\n\n this.update((state) => {\n state.logs[newLog.id] = newLog;\n });\n }\n\n /**\n * Removes all log entries.\n */\n clear() {\n this.update((state) => {\n state.logs = {};\n });\n }\n}\n"]}
1
+ {"version":3,"file":"LoggingController.cjs","sourceRoot":"","sources":["../src/LoggingController.ts"],"names":[],"mappings":";;;;;;;;;AAKA,+DAA2D;AAC3D,+BAAoC;AA0BpC,MAAM,IAAI,GAAG,mBAAmB,CAAC;AAgCjC,MAAM,QAAQ,GAAG;IACf,IAAI,EAAE;QACJ,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,SAAS,EAAE,KAAK;QAChB,QAAQ,EAAE,KAAK;KAChB;CACF,CAAC;AAEF,MAAM,YAAY,GAAG;IACnB,IAAI,EAAE,EAAE;CACT,CAAC;AAEF;;GAEG;AACH,MAAa,iBAAkB,SAAQ,gCAItC;IACC;;;;;;OAMG;IACH,YAAY,EACV,SAAS,EACT,KAAK,GAIN;QACC,KAAK,CAAC;YACJ,IAAI;YACJ,QAAQ;YACR,SAAS;YACT,KAAK,EAAE;gBACL,GAAG,YAAY;gBACf,GAAG,KAAK;aACT;SACF,CAAC,CAAC;;QAEH,IAAI,CAAC,eAAe,CAAC,qBAAqB,CACxC,GAAG,IAAI,MAAe,EACtB,CAAC,GAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAC5B,CAAC;IACJ,CAAC;IAmBD;;;;OAIG;IACH,GAAG,CAAC,GAAQ;QACV,MAAM,MAAM,GAAa;YACvB,EAAE,EAAE,uBAAA,IAAI,mEAAY,MAAhB,IAAI,CAAc;YACtB,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;YACrB,GAAG;SACJ,CAAC;QAEF,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;YACpB,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC;QACjC,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;YACpB,KAAK,CAAC,IAAI,GAAG,EAAE,CAAC;QAClB,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA7ED,8CA6EC;;IAhCG,IAAI,EAAE,GAAG,IAAA,SAAM,GAAE,CAAC;IAClB,OAAO,EAAE,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE;QAC5B,EAAE,GAAG,IAAA,SAAM,GAAE,CAAC;KACf;IACD,OAAO,EAAE,CAAC;AACZ,CAAC","sourcesContent":["import type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n RestrictedMessenger,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport { v1 as random } from 'uuid';\n\nimport type { Log } from './logTypes';\n\n/**\n * LogEntry is the entry that will be added to the logging controller state.\n * It consists of a entry key that must be on of the Log union types, and an\n * additional id and timestamp.\n */\nexport type LogEntry = {\n id: string;\n timestamp: number;\n log: Log;\n};\n\n/**\n * Logging controller state\n *\n * @property logs - An object of logs indexed by their ids\n */\nexport type LoggingControllerState = {\n logs: {\n [id: string]: LogEntry;\n };\n};\n\nconst name = 'LoggingController';\n\n/**\n * An action to add log messages to the controller state.\n */\nexport type AddLog = {\n type: `${typeof name}:add`;\n handler: LoggingController['add'];\n};\n\nexport type LoggingControllerGetStateAction = ControllerGetStateAction<\n typeof name,\n LoggingControllerState\n>;\n\nexport type LoggingControllerActions = LoggingControllerGetStateAction | AddLog;\n\nexport type LoggingControllerStateChangeEvent = ControllerStateChangeEvent<\n typeof name,\n LoggingControllerState\n>;\n\nexport type LoggingControllerEvents = LoggingControllerStateChangeEvent;\n\nexport type LoggingControllerMessenger = RestrictedMessenger<\n typeof name,\n LoggingControllerActions,\n LoggingControllerEvents,\n never,\n never\n>;\n\nconst metadata = {\n logs: {\n includeInStateLogs: true,\n persist: true,\n anonymous: false,\n usedInUi: false,\n },\n};\n\nconst defaultState = {\n logs: {},\n};\n\n/**\n * Controller that manages a list of logs for signature requests.\n */\nexport class LoggingController extends BaseController<\n typeof name,\n LoggingControllerState,\n LoggingControllerMessenger\n> {\n /**\n * Creates a LoggingController instance.\n *\n * @param options - Constructor options\n * @param options.messenger - An instance of the Messenger\n * @param options.state - Initial state to set on this controller.\n */\n constructor({\n messenger,\n state,\n }: {\n messenger: LoggingControllerMessenger;\n state?: Partial<LoggingControllerState>;\n }) {\n super({\n name,\n metadata,\n messenger,\n state: {\n ...defaultState,\n ...state,\n },\n });\n\n this.messagingSystem.registerActionHandler(\n `${name}:add` as const,\n (log: Log) => this.add(log),\n );\n }\n\n /**\n * Method to generate a randomId and ensures no collision with existing ids.\n *\n * We may want to end up using a hashing mechanism to make ids deterministic\n * by the *data* passed in, and then make each key an array of logs that\n * match that id.\n *\n * @returns unique id\n */\n #generateId(): string {\n let id = random();\n while (id in this.state.logs) {\n id = random();\n }\n return id;\n }\n\n /**\n * Add log to the state.\n *\n * @param log - Log to add to the controller\n */\n add(log: Log) {\n const newLog: LogEntry = {\n id: this.#generateId(),\n timestamp: Date.now(),\n log,\n };\n\n this.update((state) => {\n state.logs[newLog.id] = newLog;\n });\n }\n\n /**\n * Removes all log entries.\n */\n clear() {\n this.update((state) => {\n state.logs = {};\n });\n }\n}\n"]}
@@ -1,6 +1,5 @@
1
- import type { ControllerGetStateAction, ControllerStateChangeEvent } from "@metamask/base-controller/next";
2
- import { BaseController } from "@metamask/base-controller/next";
3
- import type { Messenger } from "@metamask/messenger";
1
+ import type { ControllerGetStateAction, ControllerStateChangeEvent, RestrictedMessenger } from "@metamask/base-controller";
2
+ import { BaseController } from "@metamask/base-controller";
4
3
  import type { Log } from "./logTypes/index.cjs";
5
4
  /**
6
5
  * LogEntry is the entry that will be added to the logging controller state.
@@ -34,7 +33,7 @@ export type LoggingControllerGetStateAction = ControllerGetStateAction<typeof na
34
33
  export type LoggingControllerActions = LoggingControllerGetStateAction | AddLog;
35
34
  export type LoggingControllerStateChangeEvent = ControllerStateChangeEvent<typeof name, LoggingControllerState>;
36
35
  export type LoggingControllerEvents = LoggingControllerStateChangeEvent;
37
- export type LoggingControllerMessenger = Messenger<typeof name, LoggingControllerActions, LoggingControllerEvents>;
36
+ export type LoggingControllerMessenger = RestrictedMessenger<typeof name, LoggingControllerActions, LoggingControllerEvents, never, never>;
38
37
  /**
39
38
  * Controller that manages a list of logs for signature requests.
40
39
  */
@@ -1 +1 @@
1
- {"version":3,"file":"LoggingController.d.cts","sourceRoot":"","sources":["../src/LoggingController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAE3B,uCAAuC;AACxC,OAAO,EAAE,cAAc,EAAE,uCAAuC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AAGrD,OAAO,KAAK,EAAE,GAAG,EAAE,6BAAmB;AA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,0BAA0B,CAAC;QACtC,KAAK,CAAC,EAAE,OAAO,CAAC,sBAAsB,CAAC,CAAC;KACzC;IAkCD;;;;OAIG;IACH,GAAG,CAAC,GAAG,EAAE,GAAG;IAYZ;;OAEG;IACH,KAAK;CAKN"}
@@ -1,6 +1,5 @@
1
- import type { ControllerGetStateAction, ControllerStateChangeEvent } from "@metamask/base-controller/next";
2
- import { BaseController } from "@metamask/base-controller/next";
3
- import type { Messenger } from "@metamask/messenger";
1
+ import type { ControllerGetStateAction, ControllerStateChangeEvent, RestrictedMessenger } from "@metamask/base-controller";
2
+ import { BaseController } from "@metamask/base-controller";
4
3
  import type { Log } from "./logTypes/index.mjs";
5
4
  /**
6
5
  * LogEntry is the entry that will be added to the logging controller state.
@@ -34,7 +33,7 @@ export type LoggingControllerGetStateAction = ControllerGetStateAction<typeof na
34
33
  export type LoggingControllerActions = LoggingControllerGetStateAction | AddLog;
35
34
  export type LoggingControllerStateChangeEvent = ControllerStateChangeEvent<typeof name, LoggingControllerState>;
36
35
  export type LoggingControllerEvents = LoggingControllerStateChangeEvent;
37
- export type LoggingControllerMessenger = Messenger<typeof name, LoggingControllerActions, LoggingControllerEvents>;
36
+ export type LoggingControllerMessenger = RestrictedMessenger<typeof name, LoggingControllerActions, LoggingControllerEvents, never, never>;
38
37
  /**
39
38
  * Controller that manages a list of logs for signature requests.
40
39
  */
@@ -1 +1 @@
1
- {"version":3,"file":"LoggingController.d.mts","sourceRoot":"","sources":["../src/LoggingController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAE3B,uCAAuC;AACxC,OAAO,EAAE,cAAc,EAAE,uCAAuC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AAGrD,OAAO,KAAK,EAAE,GAAG,EAAE,6BAAmB;AAEtC;;;;GAIG;AACH,MAAM,MAAM,QAAQ,GAAG;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,GAAG,CAAC;CACV,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACnC,IAAI,EAAE;QACJ,CAAC,EAAE,EAAE,MAAM,GAAG,QAAQ,CAAC;KACxB,CAAC;CACH,CAAC;AAEF,QAAA,MAAM,IAAI,sBAAsB,CAAC;AAEjC;;GAEG;AACH,MAAM,MAAM,MAAM,GAAG;IACnB,IAAI,EAAE,GAAG,OAAO,IAAI,MAAM,CAAC;IAC3B,OAAO,EAAE,iBAAiB,CAAC,KAAK,CAAC,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,+BAA+B,GAAG,wBAAwB,CACpE,OAAO,IAAI,EACX,sBAAsB,CACvB,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG,+BAA+B,GAAG,MAAM,CAAC;AAEhF,MAAM,MAAM,iCAAiC,GAAG,0BAA0B,CACxE,OAAO,IAAI,EACX,sBAAsB,CACvB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG,iCAAiC,CAAC;AAExE,MAAM,MAAM,0BAA0B,GAAG,SAAS,CAChD,OAAO,IAAI,EACX,wBAAwB,EACxB,uBAAuB,CACxB,CAAC;AAeF;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,cAAc,CACnD,OAAO,IAAI,EACX,sBAAsB,EACtB,0BAA0B,CAC3B;;IACC;;;;;;OAMG;gBACS,EACV,SAAS,EACT,KAAK,GACN,EAAE;QACD,SAAS,EAAE,0BAA0B,CAAC;QACtC,KAAK,CAAC,EAAE,OAAO,CAAC,sBAAsB,CAAC,CAAC;KACzC;IAiCD;;;;OAIG;IACH,GAAG,CAAC,GAAG,EAAE,GAAG;IAYZ;;OAEG;IACH,KAAK;CAKN"}
1
+ {"version":3,"file":"LoggingController.d.mts","sourceRoot":"","sources":["../src/LoggingController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAC1B,mBAAmB,EACpB,kCAAkC;A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AG,CAAC,GAAG,EAAE,GAAG;IAYZ;;OAEG;IACH,KAAK;CAKN"}
@@ -4,14 +4,14 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
4
4
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
5
  };
6
6
  var _LoggingController_instances, _LoggingController_generateId;
7
- import { BaseController } from "@metamask/base-controller/next";
7
+ import { BaseController } from "@metamask/base-controller";
8
8
  import { v1 as random } from "uuid";
9
9
  const name = 'LoggingController';
10
10
  const metadata = {
11
11
  logs: {
12
12
  includeInStateLogs: true,
13
13
  persist: true,
14
- includeInDebugSnapshot: false,
14
+ anonymous: false,
15
15
  usedInUi: false,
16
16
  },
17
17
  };
@@ -40,7 +40,7 @@ export class LoggingController extends BaseController {
40
40
  },
41
41
  });
42
42
  _LoggingController_instances.add(this);
43
- this.messenger.registerActionHandler(`${name}:add`, (log) => this.add(log));
43
+ this.messagingSystem.registerActionHandler(`${name}:add`, (log) => this.add(log));
44
44
  }
45
45
  /**
46
46
  * Add log to the state.
@@ -1 +1 @@
1
- {"version":3,"file":"LoggingController.mjs","sourceRoot":"","sources":["../src/LoggingController.ts"],"names":[],"mappings":";;;;;;AAKA,OAAO,EAAE,cAAc,EAAE,uCAAuC;AAEhE,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,aAAa;AA0BpC,MAAM,IAAI,GAAG,mBAAmB,CAAC;AA8BjC,MAAM,QAAQ,GAA0C;IACtD,IAAI,EAAE;QACJ,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,sBAAsB,EAAE,KAAK;QAC7B,QAAQ,EAAE,KAAK;KAChB;CACF,CAAC;AAEF,MAAM,YAAY,GAAG;IACnB,IAAI,EAAE,EAAE;CACT,CAAC;AAEF;;GAEG;AACH,MAAM,OAAO,iBAAkB,SAAQ,cAItC;IACC;;;;;;OAMG;IACH,YAAY,EACV,SAAS,EACT,KAAK,GAIN;QACC,KAAK,CAAC;YACJ,IAAI;YACJ,QAAQ;YACR,SAAS;YACT,KAAK,EAAE;gBACL,GAAG,YAAY;gBACf,GAAG,KAAK;aACT;SACF,CAAC,CAAC;;QAEH,IAAI,CAAC,SAAS,CAAC,qBAAqB,CAAC,GAAG,IAAI,MAAe,EAAE,CAAC,GAAQ,EAAE,EAAE,CACxE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CACd,CAAC;IACJ,CAAC;IAmBD;;;;OAIG;IACH,GAAG,CAAC,GAAQ;QACV,MAAM,MAAM,GAAa;YACvB,EAAE,EAAE,uBAAA,IAAI,mEAAY,MAAhB,IAAI,CAAc;YACtB,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;YACrB,GAAG;SACJ,CAAC;QAEF,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;YACpB,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC;QACjC,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;YACpB,KAAK,CAAC,IAAI,GAAG,EAAE,CAAC;QAClB,CAAC,CAAC,CAAC;IACL,CAAC;CACF;;IAhCG,IAAI,EAAE,GAAG,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE;QAC5B,EAAE,GAAG,MAAM,EAAE,CAAC;KACf;IACD,OAAO,EAAE,CAAC;AACZ,CAAC","sourcesContent":["import type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n StateMetadata,\n} from '@metamask/base-controller/next';\nimport { BaseController } from '@metamask/base-controller/next';\nimport type { Messenger } from '@metamask/messenger';\nimport { v1 as random } from 'uuid';\n\nimport type { Log } from './logTypes';\n\n/**\n * LogEntry is the entry that will be added to the logging controller state.\n * It consists of a entry key that must be on of the Log union types, and an\n * additional id and timestamp.\n */\nexport type LogEntry = {\n id: string;\n timestamp: number;\n log: Log;\n};\n\n/**\n * Logging controller state\n *\n * @property logs - An object of logs indexed by their ids\n */\nexport type LoggingControllerState = {\n logs: {\n [id: string]: LogEntry;\n };\n};\n\nconst name = 'LoggingController';\n\n/**\n * An action to add log messages to the controller state.\n */\nexport type AddLog = {\n type: `${typeof name}:add`;\n handler: LoggingController['add'];\n};\n\nexport type LoggingControllerGetStateAction = ControllerGetStateAction<\n typeof name,\n LoggingControllerState\n>;\n\nexport type LoggingControllerActions = LoggingControllerGetStateAction | AddLog;\n\nexport type LoggingControllerStateChangeEvent = ControllerStateChangeEvent<\n typeof name,\n LoggingControllerState\n>;\n\nexport type LoggingControllerEvents = LoggingControllerStateChangeEvent;\n\nexport type LoggingControllerMessenger = Messenger<\n typeof name,\n LoggingControllerActions,\n LoggingControllerEvents\n>;\n\nconst metadata: StateMetadata<LoggingControllerState> = {\n logs: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: false,\n usedInUi: false,\n },\n};\n\nconst defaultState = {\n logs: {},\n};\n\n/**\n * Controller that manages a list of logs for signature requests.\n */\nexport class LoggingController extends BaseController<\n typeof name,\n LoggingControllerState,\n LoggingControllerMessenger\n> {\n /**\n * Creates a LoggingController instance.\n *\n * @param options - Constructor options\n * @param options.messenger - An instance of the Messenger\n * @param options.state - Initial state to set on this controller.\n */\n constructor({\n messenger,\n state,\n }: {\n messenger: LoggingControllerMessenger;\n state?: Partial<LoggingControllerState>;\n }) {\n super({\n name,\n metadata,\n messenger,\n state: {\n ...defaultState,\n ...state,\n },\n });\n\n this.messenger.registerActionHandler(`${name}:add` as const, (log: Log) =>\n this.add(log),\n );\n }\n\n /**\n * Method to generate a randomId and ensures no collision with existing ids.\n *\n * We may want to end up using a hashing mechanism to make ids deterministic\n * by the *data* passed in, and then make each key an array of logs that\n * match that id.\n *\n * @returns unique id\n */\n #generateId(): string {\n let id = random();\n while (id in this.state.logs) {\n id = random();\n }\n return id;\n }\n\n /**\n * Add log to the state.\n *\n * @param log - Log to add to the controller\n */\n add(log: Log) {\n const newLog: LogEntry = {\n id: this.#generateId(),\n timestamp: Date.now(),\n log,\n };\n\n this.update((state) => {\n state.logs[newLog.id] = newLog;\n });\n }\n\n /**\n * Removes all log entries.\n */\n clear() {\n this.update((state) => {\n state.logs = {};\n });\n }\n}\n"]}
1
+ {"version":3,"file":"LoggingController.mjs","sourceRoot":"","sources":["../src/LoggingController.ts"],"names":[],"mappings":";;;;;;AAKA,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,aAAa;AA0BpC,MAAM,IAAI,GAAG,mBAAmB,CAAC;AAgCjC,MAAM,QAAQ,GAAG;IACf,IAAI,EAAE;QACJ,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,SAAS,EAAE,KAAK;QAChB,QAAQ,EAAE,KAAK;KAChB;CACF,CAAC;AAEF,MAAM,YAAY,GAAG;IACnB,IAAI,EAAE,EAAE;CACT,CAAC;AAEF;;GAEG;AACH,MAAM,OAAO,iBAAkB,SAAQ,cAItC;IACC;;;;;;OAMG;IACH,YAAY,EACV,SAAS,EACT,KAAK,GAIN;QACC,KAAK,CAAC;YACJ,IAAI;YACJ,QAAQ;YACR,SAAS;YACT,KAAK,EAAE;gBACL,GAAG,YAAY;gBACf,GAAG,KAAK;aACT;SACF,CAAC,CAAC;;QAEH,IAAI,CAAC,eAAe,CAAC,qBAAqB,CACxC,GAAG,IAAI,MAAe,EACtB,CAAC,GAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAC5B,CAAC;IACJ,CAAC;IAmBD;;;;OAIG;IACH,GAAG,CAAC,GAAQ;QACV,MAAM,MAAM,GAAa;YACvB,EAAE,EAAE,uBAAA,IAAI,mEAAY,MAAhB,IAAI,CAAc;YACtB,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;YACrB,GAAG;SACJ,CAAC;QAEF,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;YACpB,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC;QACjC,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;YACpB,KAAK,CAAC,IAAI,GAAG,EAAE,CAAC;QAClB,CAAC,CAAC,CAAC;IACL,CAAC;CACF;;IAhCG,IAAI,EAAE,GAAG,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE;QAC5B,EAAE,GAAG,MAAM,EAAE,CAAC;KACf;IACD,OAAO,EAAE,CAAC;AACZ,CAAC","sourcesContent":["import type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n RestrictedMessenger,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport { v1 as random } from 'uuid';\n\nimport type { Log } from './logTypes';\n\n/**\n * LogEntry is the entry that will be added to the logging controller state.\n * It consists of a entry key that must be on of the Log union types, and an\n * additional id and timestamp.\n */\nexport type LogEntry = {\n id: string;\n timestamp: number;\n log: Log;\n};\n\n/**\n * Logging controller state\n *\n * @property logs - An object of logs indexed by their ids\n */\nexport type LoggingControllerState = {\n logs: {\n [id: string]: LogEntry;\n };\n};\n\nconst name = 'LoggingController';\n\n/**\n * An action to add log messages to the controller state.\n */\nexport type AddLog = {\n type: `${typeof name}:add`;\n handler: LoggingController['add'];\n};\n\nexport type LoggingControllerGetStateAction = ControllerGetStateAction<\n typeof name,\n LoggingControllerState\n>;\n\nexport type LoggingControllerActions = LoggingControllerGetStateAction | AddLog;\n\nexport type LoggingControllerStateChangeEvent = ControllerStateChangeEvent<\n typeof name,\n LoggingControllerState\n>;\n\nexport type LoggingControllerEvents = LoggingControllerStateChangeEvent;\n\nexport type LoggingControllerMessenger = RestrictedMessenger<\n typeof name,\n LoggingControllerActions,\n LoggingControllerEvents,\n never,\n never\n>;\n\nconst metadata = {\n logs: {\n includeInStateLogs: true,\n persist: true,\n anonymous: false,\n usedInUi: false,\n },\n};\n\nconst defaultState = {\n logs: {},\n};\n\n/**\n * Controller that manages a list of logs for signature requests.\n */\nexport class LoggingController extends BaseController<\n typeof name,\n LoggingControllerState,\n LoggingControllerMessenger\n> {\n /**\n * Creates a LoggingController instance.\n *\n * @param options - Constructor options\n * @param options.messenger - An instance of the Messenger\n * @param options.state - Initial state to set on this controller.\n */\n constructor({\n messenger,\n state,\n }: {\n messenger: LoggingControllerMessenger;\n state?: Partial<LoggingControllerState>;\n }) {\n super({\n name,\n metadata,\n messenger,\n state: {\n ...defaultState,\n ...state,\n },\n });\n\n this.messagingSystem.registerActionHandler(\n `${name}:add` as const,\n (log: Log) => this.add(log),\n );\n }\n\n /**\n * Method to generate a randomId and ensures no collision with existing ids.\n *\n * We may want to end up using a hashing mechanism to make ids deterministic\n * by the *data* passed in, and then make each key an array of logs that\n * match that id.\n *\n * @returns unique id\n */\n #generateId(): string {\n let id = random();\n while (id in this.state.logs) {\n id = random();\n }\n return id;\n }\n\n /**\n * Add log to the state.\n *\n * @param log - Log to add to the controller\n */\n add(log: Log) {\n const newLog: LogEntry = {\n id: this.#generateId(),\n timestamp: Date.now(),\n log,\n };\n\n this.update((state) => {\n state.logs[newLog.id] = newLog;\n });\n }\n\n /**\n * Removes all log entries.\n */\n clear() {\n this.update((state) => {\n state.logs = {};\n });\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask-previews/logging-controller",
3
- "version": "6.1.1-preview-6bf4b220",
3
+ "version": "6.1.1-preview-77daf0c7",
4
4
  "description": "Manages logging data to assist users and support staff",
5
5
  "keywords": [
6
6
  "MetaMask",
@@ -49,7 +49,6 @@
49
49
  "dependencies": {
50
50
  "@metamask/base-controller": "^8.4.2",
51
51
  "@metamask/controller-utils": "^11.14.1",
52
- "@metamask/messenger": "^0.3.0",
53
52
  "uuid": "^8.3.2"
54
53
  },
55
54
  "devDependencies": {