@metamask-previews/message-manager 11.0.3-preview-77ba063e → 11.0.3-preview-e5e6db48

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.
@@ -4,15 +4,16 @@ exports.DecryptMessageManager = void 0;
4
4
  const controller_utils_1 = require("@metamask/controller-utils");
5
5
  const AbstractMessageManager_1 = require("./AbstractMessageManager.cjs");
6
6
  const utils_1 = require("./utils.cjs");
7
+ const managerName = 'DecryptMessageManager';
7
8
  /**
8
9
  * Controller in charge of managing - storing, adding, removing, updating - DecryptMessages.
9
10
  */
10
11
  class DecryptMessageManager extends AbstractMessageManager_1.AbstractMessageManager {
11
- constructor({ additionalFinishStatuses, messenger, name, securityProviderRequest, state, }) {
12
+ constructor({ additionalFinishStatuses, messenger, securityProviderRequest, state, }) {
12
13
  super({
13
14
  additionalFinishStatuses,
14
15
  messenger,
15
- name,
16
+ name: managerName,
16
17
  securityProviderRequest,
17
18
  state,
18
19
  });
@@ -59,7 +60,7 @@ class DecryptMessageManager extends AbstractMessageManager_1.AbstractMessageMana
59
60
  const messageData = this.createUnapprovedMessage(updatedMessageParams, controller_utils_1.ApprovalType.EthDecrypt, req);
60
61
  const messageId = messageData.id;
61
62
  await this.addMessage(messageData);
62
- this.messagingSystem.publish(`${this.name}:unapprovedMessage`, {
63
+ this.messagingSystem.publish(`${managerName}:unapprovedMessage`, {
63
64
  ...updatedMessageParams,
64
65
  metamaskId: messageId,
65
66
  });
@@ -1 +1 @@
1
- {"version":3,"file":"DecryptMessageManager.cjs","sourceRoot":"","sources":["../src/DecryptMessageManager.ts"],"names":[],"mappings":";;;AAKA,iEAA0D;AAU1D,yEAAkE;AAClE,uCAA6E;AAmE7E;;GAEG;AACH,MAAa,qBAAsB,SAAQ,+CAM1C;IACC,YAAY,EACV,wBAAwB,EACxB,SAAS,EACT,IAAI,EACJ,uBAAuB,EACvB,KAAK,GACwB;QAC7B,KAAK,CAAC;YACJ,wBAAwB;YACxB,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,CAAC;QAE3B,MAAM,SAAS,GAAG,WAAW,CAAC,EAAE,CAAC;QAEjC,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;QACnC,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,IAAc,oBAAoB,EAAE;YACvE,GAAG,oBAAoB;YACvB,UAAU,EAAE,SAAS;SACtB,CAAC,CAAC;QACH,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;;;;;OAMG;IACH,qBAAqB,CACnB,aAA2C;QAE3C,OAAO,aAAa,CAAC,UAAU,CAAC;QAChC,OAAO,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IACxC,CAAC;CACF;AAxHD,sDAwHC","sourcesContent":["import type {\n ActionConstraint,\n EventConstraint,\n RestrictedControllerMessenger,\n} from '@metamask/base-controller';\nimport { ApprovalType } from '@metamask/controller-utils';\n\nimport type {\n AbstractMessage,\n AbstractMessageParams,\n AbstractMessageParamsMetamask,\n MessageManagerState,\n OriginalRequest,\n SecurityProviderRequest,\n} from './AbstractMessageManager';\nimport { AbstractMessageManager } from './AbstractMessageManager';\nimport { normalizeMessageData, validateDecryptedMessageData } from './utils';\n\nexport type DecryptMessageManagerState = MessageManagerState<DecryptMessage>;\n\nexport type DecryptMessageManagerUnapprovedMessageAddedEvent = {\n type: `${string}:unapprovedMessage`;\n payload: [AbstractMessageParamsMetamask];\n};\n\nexport type DecryptMessageManagerMessenger = RestrictedControllerMessenger<\n string,\n ActionConstraint,\n EventConstraint | DecryptMessageManagerUnapprovedMessageAddedEvent,\n string,\n string\n>;\n\ntype DecryptMessageManagerOptions = {\n messenger: DecryptMessageManagerMessenger;\n name: string;\n securityProviderRequest?: SecurityProviderRequest;\n state?: MessageManagerState<DecryptMessage>;\n additionalFinishStatuses?: string[];\n};\n\n/**\n * @type DecryptMessage\n *\n * Represents and contains data about a 'eth_decrypt' type signature request.\n * These are created when a signature for an eth_decrypt call is requested.\n * @property id - An id to track and identify the message object\n * @property messageParams - The parameters to pass to the eth_decrypt method once the request is approved\n * @property type - The json-prc signing method for which a signature request has been made.\n * A 'DecryptMessage' which always has a 'eth_decrypt' type\n */\nexport type DecryptMessage = AbstractMessage & {\n messageParams: DecryptMessageParams;\n};\n\n/**\n * @type DecryptMessageParams\n *\n * Represents the parameters to pass to the eth_decrypt method once the request is approved.\n * @property data - A hex string conversion of the raw buffer data of the signature request\n */\nexport type DecryptMessageParams = AbstractMessageParams & {\n data: string;\n};\n\n/**\n * @type DecryptMessageParamsMetamask\n *\n * Represents the parameters to pass to the eth_decrypt method once the request is approved\n * plus data added by MetaMask.\n * @property metamaskId - Added for tracking and identification within MetaMask\n * @property data - A hex string conversion of the raw buffer data of the signature request\n * @property from - Address to sign this message from\n * @property origin? - Added for request origin identification\n */\n// This interface was created before this ESLint rule was added.\n// Convert to a `type` in a future major version.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport interface DecryptMessageParamsMetamask\n extends AbstractMessageParamsMetamask {\n data: string;\n}\n\n/**\n * Controller in charge of managing - storing, adding, removing, updating - DecryptMessages.\n */\nexport class DecryptMessageManager extends AbstractMessageManager<\n DecryptMessage,\n DecryptMessageParams,\n DecryptMessageParamsMetamask,\n ActionConstraint,\n EventConstraint | DecryptMessageManagerUnapprovedMessageAddedEvent\n> {\n constructor({\n additionalFinishStatuses,\n messenger,\n name,\n securityProviderRequest,\n state,\n }: DecryptMessageManagerOptions) {\n super({\n additionalFinishStatuses,\n messenger,\n name,\n securityProviderRequest,\n state,\n });\n }\n\n /**\n * Creates a new Message with an 'unapproved' status using the passed messageParams.\n * this.addMessage is called to add the new Message to this.messages, and to save the unapproved Messages.\n *\n * @param messageParams - The params for the personal_sign call to be made after the message is approved.\n * @param req - The original request object possibly containing the origin.\n * @returns Promise resolving to the raw data of the signature request.\n */\n async addUnapprovedMessageAsync(\n messageParams: DecryptMessageParams,\n req?: OriginalRequest,\n ): Promise<string> {\n validateDecryptedMessageData(messageParams);\n const messageId = await this.addUnapprovedMessage(messageParams, req);\n\n return new Promise((resolve, reject) => {\n this.internalEvents.once(\n `${messageId}:finished`,\n (data: DecryptMessage) => {\n switch (data.status) {\n case 'decrypted':\n return resolve(data.rawSig as string);\n case 'rejected':\n return reject(\n new Error(\n 'MetaMask DecryptMessage: User denied message decryption.',\n ),\n );\n case 'errored':\n return reject(\n new Error(\n 'MetaMask DecryptMessage: This message cannot be decrypted.',\n ),\n );\n default:\n return reject(\n new Error(\n `MetaMask DecryptMessage: Unknown problem: ${JSON.stringify(\n messageParams,\n )}`,\n ),\n );\n }\n },\n );\n });\n }\n\n /**\n * Creates a new Message with an 'unapproved' status using the passed messageParams.\n * this.addMessage is called to add the new Message to this.messages, and to save the\n * unapproved Messages.\n *\n * @param messageParams - The params for the personal_sign call to be made after the message\n * is approved.\n * @param req - The original request object possibly containing the origin.\n * @returns The id of the newly created message.\n */\n async addUnapprovedMessage(\n messageParams: DecryptMessageParams,\n req?: OriginalRequest,\n ) {\n const updatedMessageParams = this.addRequestToMessageParams(\n messageParams,\n req,\n ) satisfies DecryptMessageParams;\n messageParams.data = normalizeMessageData(messageParams.data);\n\n const messageData = this.createUnapprovedMessage(\n updatedMessageParams,\n ApprovalType.EthDecrypt,\n req,\n ) satisfies DecryptMessage;\n\n const messageId = messageData.id;\n\n await this.addMessage(messageData);\n this.messagingSystem.publish(`${this.name as string}:unapprovedMessage`, {\n ...updatedMessageParams,\n metamaskId: messageId,\n });\n return messageId;\n }\n\n /**\n * Removes the metamaskId property from passed messageParams and returns a promise which\n * resolves the updated messageParams.\n *\n * @param messageParams - The messageParams to modify.\n * @returns Promise resolving to the messageParams with the metamaskId property removed.\n */\n prepMessageForSigning(\n messageParams: DecryptMessageParamsMetamask,\n ): Promise<DecryptMessageParams> {\n delete messageParams.metamaskId;\n return Promise.resolve(messageParams);\n }\n}\n"]}
1
+ {"version":3,"file":"DecryptMessageManager.cjs","sourceRoot":"","sources":["../src/DecryptMessageManager.ts"],"names":[],"mapp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AAM,oBAAoB,GAAG,IAAI,CAAC,yBAAyB,CACzD,aAAa,EACb,GAAG,CAC2B,CAAC;QACjC,aAAa,CAAC,IAAI,GAAG,IAAA,4BAAoB,EAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAE9D,MAAM,WAAW,GAAG,IAAI,CAAC,uBAAuB,CAC9C,oBAAoB,EACpB,+BAAY,CAAC,UAAU,EACvB,GAAG,CACqB,CAAC;QAE3B,MAAM,SAAS,GAAG,WAAW,CAAC,EAAE,CAAC;QAEjC,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;QACnC,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,GAAG,WAAW,oBAAoB,EAAE;YAC/D,GAAG,oBAAoB;YACvB,UAAU,EAAE,SAAS;SACtB,CAAC,CAAC;QACH,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;;;;;OAMG;IACH,qBAAqB,CACnB,aAA2C;QAE3C,OAAO,aAAa,CAAC,UAAU,CAAC;QAChC,OAAO,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IACxC,CAAC;CACF;AAvHD,sDAuHC","sourcesContent":["import type {\n ActionConstraint,\n EventConstraint,\n RestrictedControllerMessenger,\n} from '@metamask/base-controller';\nimport { ApprovalType } from '@metamask/controller-utils';\n\nimport type {\n AbstractMessage,\n AbstractMessageParams,\n AbstractMessageParamsMetamask,\n MessageManagerState,\n OriginalRequest,\n SecurityProviderRequest,\n} from './AbstractMessageManager';\nimport { AbstractMessageManager } from './AbstractMessageManager';\nimport { normalizeMessageData, validateDecryptedMessageData } from './utils';\n\nconst managerName = 'DecryptMessageManager';\n\nexport type DecryptMessageManagerState = MessageManagerState<DecryptMessage>;\n\nexport type DecryptMessageManagerUnapprovedMessageAddedEvent = {\n type: `${typeof managerName}:unapprovedMessage`;\n payload: [AbstractMessageParamsMetamask];\n};\n\nexport type DecryptMessageManagerMessenger = RestrictedControllerMessenger<\n string,\n ActionConstraint,\n EventConstraint | DecryptMessageManagerUnapprovedMessageAddedEvent,\n string,\n string\n>;\n\ntype DecryptMessageManagerOptions = {\n messenger: DecryptMessageManagerMessenger;\n securityProviderRequest?: SecurityProviderRequest;\n state?: MessageManagerState<DecryptMessage>;\n additionalFinishStatuses?: string[];\n};\n\n/**\n * @type DecryptMessage\n *\n * Represents and contains data about a 'eth_decrypt' type signature request.\n * These are created when a signature for an eth_decrypt call is requested.\n * @property id - An id to track and identify the message object\n * @property messageParams - The parameters to pass to the eth_decrypt method once the request is approved\n * @property type - The json-prc signing method for which a signature request has been made.\n * A 'DecryptMessage' which always has a 'eth_decrypt' type\n */\nexport type DecryptMessage = AbstractMessage & {\n messageParams: DecryptMessageParams;\n};\n\n/**\n * @type DecryptMessageParams\n *\n * Represents the parameters to pass to the eth_decrypt method once the request is approved.\n * @property data - A hex string conversion of the raw buffer data of the signature request\n */\nexport type DecryptMessageParams = AbstractMessageParams & {\n data: string;\n};\n\n/**\n * @type DecryptMessageParamsMetamask\n *\n * Represents the parameters to pass to the eth_decrypt method once the request is approved\n * plus data added by MetaMask.\n * @property metamaskId - Added for tracking and identification within MetaMask\n * @property data - A hex string conversion of the raw buffer data of the signature request\n * @property from - Address to sign this message from\n * @property origin? - Added for request origin identification\n */\n// This interface was created before this ESLint rule was added.\n// Convert to a `type` in a future major version.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport interface DecryptMessageParamsMetamask\n extends AbstractMessageParamsMetamask {\n data: string;\n}\n\n/**\n * Controller in charge of managing - storing, adding, removing, updating - DecryptMessages.\n */\nexport class DecryptMessageManager extends AbstractMessageManager<\n DecryptMessage,\n DecryptMessageParams,\n DecryptMessageParamsMetamask,\n ActionConstraint,\n EventConstraint | DecryptMessageManagerUnapprovedMessageAddedEvent\n> {\n constructor({\n additionalFinishStatuses,\n messenger,\n securityProviderRequest,\n state,\n }: DecryptMessageManagerOptions) {\n super({\n additionalFinishStatuses,\n messenger,\n name: managerName,\n securityProviderRequest,\n state,\n });\n }\n\n /**\n * Creates a new Message with an 'unapproved' status using the passed messageParams.\n * this.addMessage is called to add the new Message to this.messages, and to save the unapproved Messages.\n *\n * @param messageParams - The params for the personal_sign call to be made after the message is approved.\n * @param req - The original request object possibly containing the origin.\n * @returns Promise resolving to the raw data of the signature request.\n */\n async addUnapprovedMessageAsync(\n messageParams: DecryptMessageParams,\n req?: OriginalRequest,\n ): Promise<string> {\n validateDecryptedMessageData(messageParams);\n const messageId = await this.addUnapprovedMessage(messageParams, req);\n\n return new Promise((resolve, reject) => {\n this.internalEvents.once(\n `${messageId}:finished`,\n (data: DecryptMessage) => {\n switch (data.status) {\n case 'decrypted':\n return resolve(data.rawSig as string);\n case 'rejected':\n return reject(\n new Error(\n 'MetaMask DecryptMessage: User denied message decryption.',\n ),\n );\n case 'errored':\n return reject(\n new Error(\n 'MetaMask DecryptMessage: This message cannot be decrypted.',\n ),\n );\n default:\n return reject(\n new Error(\n `MetaMask DecryptMessage: Unknown problem: ${JSON.stringify(\n messageParams,\n )}`,\n ),\n );\n }\n },\n );\n });\n }\n\n /**\n * Creates a new Message with an 'unapproved' status using the passed messageParams.\n * this.addMessage is called to add the new Message to this.messages, and to save the\n * unapproved Messages.\n *\n * @param messageParams - The params for the personal_sign call to be made after the message\n * is approved.\n * @param req - The original request object possibly containing the origin.\n * @returns The id of the newly created message.\n */\n async addUnapprovedMessage(\n messageParams: DecryptMessageParams,\n req?: OriginalRequest,\n ) {\n const updatedMessageParams = this.addRequestToMessageParams(\n messageParams,\n req,\n ) satisfies DecryptMessageParams;\n messageParams.data = normalizeMessageData(messageParams.data);\n\n const messageData = this.createUnapprovedMessage(\n updatedMessageParams,\n ApprovalType.EthDecrypt,\n req,\n ) satisfies DecryptMessage;\n\n const messageId = messageData.id;\n\n await this.addMessage(messageData);\n this.messagingSystem.publish(`${managerName}:unapprovedMessage`, {\n ...updatedMessageParams,\n metamaskId: messageId,\n });\n return messageId;\n }\n\n /**\n * Removes the metamaskId property from passed messageParams and returns a promise which\n * resolves the updated messageParams.\n *\n * @param messageParams - The messageParams to modify.\n * @returns Promise resolving to the messageParams with the metamaskId property removed.\n */\n prepMessageForSigning(\n messageParams: DecryptMessageParamsMetamask,\n ): Promise<DecryptMessageParams> {\n delete messageParams.metamaskId;\n return Promise.resolve(messageParams);\n }\n}\n"]}
@@ -1,15 +1,15 @@
1
1
  import type { ActionConstraint, EventConstraint, RestrictedControllerMessenger } from "@metamask/base-controller";
2
2
  import type { AbstractMessage, AbstractMessageParams, AbstractMessageParamsMetamask, MessageManagerState, OriginalRequest, SecurityProviderRequest } from "./AbstractMessageManager.cjs";
3
3
  import { AbstractMessageManager } from "./AbstractMessageManager.cjs";
4
+ declare const managerName = "DecryptMessageManager";
4
5
  export type DecryptMessageManagerState = MessageManagerState<DecryptMessage>;
5
6
  export type DecryptMessageManagerUnapprovedMessageAddedEvent = {
6
- type: `${string}:unapprovedMessage`;
7
+ type: `${typeof managerName}:unapprovedMessage`;
7
8
  payload: [AbstractMessageParamsMetamask];
8
9
  };
9
10
  export type DecryptMessageManagerMessenger = RestrictedControllerMessenger<string, ActionConstraint, EventConstraint | DecryptMessageManagerUnapprovedMessageAddedEvent, string, string>;
10
11
  type DecryptMessageManagerOptions = {
11
12
  messenger: DecryptMessageManagerMessenger;
12
- name: string;
13
13
  securityProviderRequest?: SecurityProviderRequest;
14
14
  state?: MessageManagerState<DecryptMessage>;
15
15
  additionalFinishStatuses?: string[];
@@ -53,7 +53,7 @@ export interface DecryptMessageParamsMetamask extends AbstractMessageParamsMetam
53
53
  * Controller in charge of managing - storing, adding, removing, updating - DecryptMessages.
54
54
  */
55
55
  export declare class DecryptMessageManager extends AbstractMessageManager<DecryptMessage, DecryptMessageParams, DecryptMessageParamsMetamask, ActionConstraint, EventConstraint | DecryptMessageManagerUnapprovedMessageAddedEvent> {
56
- constructor({ additionalFinishStatuses, messenger, name, securityProviderRequest, state, }: DecryptMessageManagerOptions);
56
+ constructor({ additionalFinishStatuses, messenger, securityProviderRequest, state, }: DecryptMessageManagerOptions);
57
57
  /**
58
58
  * Creates a new Message with an 'unapproved' status using the passed messageParams.
59
59
  * this.addMessage is called to add the new Message to this.messages, and to save the unapproved Messages.
@@ -1 +1 @@
1
- {"version":3,"file":"DecryptMessageManager.d.cts","sourceRoot":"","sources":["../src/DecryptMessageManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,6BAA6B,EAC9B,kCAAkC;AAGnC,OAAO,KAAK,EACV,eAAe,EACf,qBAAqB,EACrB,6BAA6B,EAC7B,mBAAmB,EACnB,eAAe,EACf,uBAAuB,EACxB,qCAAiC;AAClC,OAAO,EAAE,sBAAsB,EAAE,qCAAiC;AAGlE,MAAM,MAAM,0BAA0B,GAAG,mBAAmB,CAAC,cAAc,CAAC,CAAC;AAE7E,MAAM,MAAM,gDAAgD,GAAG;IAC7D,IAAI,EAAE,GAAG,MAAM,oBAAoB,CAAC;IACpC,OAAO,EAAE,CAAC,6BAA6B,CAAC,CAAC;CAC1C,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG,6BAA6B,CACxE,MAAM,EACN,gBAAgB,EAChB,eAAe,GAAG,gDAAgD,EAClE,MAAM,EACN,MAAM,CACP,CAAC;AAEF,KAAK,4BAA4B,GAAG;IAClC,SAAS,EAAE,8BAA8B,CAAC;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,uBAAuB,CAAC,EAAE,uBAAuB,CAAC;IAClD,KAAK,CAAC,EAAE,mBAAmB,CAAC,cAAc,CAAC,CAAC;IAC5C,wBAAwB,CAAC,EAAE,MAAM,EAAE,CAAC;CACrC,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,MAAM,cAAc,GAAG,eAAe,GAAG;IAC7C,aAAa,EAAE,oBAAoB,CAAC;CACrC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,oBAAoB,GAAG,qBAAqB,GAAG;IACzD,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;;;;;;;;GASG;AAIH,MAAM,WAAW,4BACf,SAAQ,6BAA6B;IACrC,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,qBAAa,qBAAsB,SAAQ,sBAAsB,CAC/D,cAAc,EACd,oBAAoB,EACpB,4BAA4B,EAC5B,gBAAgB,EAChB,eAAe,GAAG,gDAAgD,CACnE;gBACa,EACV,wBAAwB,EACxB,SAAS,EACT,IAAI,EACJ,uBAAuB,EACvB,KAAK,GACN,EAAE,4BAA4B;IAU/B;;;;;;;OAOG;IACG,yBAAyB,CAC7B,aAAa,EAAE,oBAAoB,EACnC,GAAG,CAAC,EAAE,eAAe,GACpB,OAAO,CAAC,MAAM,CAAC;IAqClB;;;;;;;;;OASG;IACG,oBAAoB,CACxB,aAAa,EAAE,oBAAoB,EACnC,GAAG,CAAC,EAAE,eAAe;IAwBvB;;;;;;OAMG;IACH,qBAAqB,CACnB,aAAa,EAAE,4BAA4B,GAC1C,OAAO,CAAC,oBAAoB,CAAC;CAIjC"}
1
+ {"version":3,"file":"DecryptMessageManager.d.cts","sourceRoot":"","sources":["../src/DecryptMessageManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,6BAA6B,EAC9B,kCAAkC;AAGnC,OAAO,KAAK,EACV,eAAe,EACf,qBAAqB,EACrB,6BAA6B,EAC7B,mBAAmB,EACnB,eAAe,EACf,uBAAuB,EACxB,qCAAiC;AAClC,OAAO,EAAE,sBAAsB,EAAE,qCAAiC;AAGlE,QAAA,MAAM,WAAW,0BAA0B,CAAC;AAE5C,MAAM,MAAM,0BAA0B,GAAG,mBAAmB,CAAC,cAAc,CAAC,CAAC;AAE7E,MAAM,MAAM,gDAAgD,GAAG;IAC7D,IAAI,EAAE,GAAG,OAAO,WAAW,oBAAoB,CAAC;IAChD,OAAO,EAAE,CAAC,6BAA6B,CAAC,CAAC;CAC1C,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG,6BAA6B,CACxE,MAAM,EACN,gBAAgB,EAChB,eAAe,GAAG,gDAAgD,EAClE,MAAM,EACN,MAAM,CACP,CAAC;AAEF,KAAK,4BAA4B,GAAG;IAClC,SAAS,EAAE,8BAA8B,CAAC;IAC1C,uBAAuB,CAAC,EAAE,uBAAuB,CAAC;IAClD,KAAK,CAAC,EAAE,mBAAmB,CAAC,cAAc,CAAC,CAAC;IAC5C,wBAAwB,CAAC,EAAE,MAAM,EAAE,CAAC;CACrC,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,MAAM,cAAc,GAAG,eAAe,GAAG;IAC7C,aAAa,EAAE,oBAAoB,CAAC;CACrC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,oBAAoB,GAAG,qBAAqB,GAAG;IACzD,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;;;;;;;;GASG;AAIH,MAAM,WAAW,4BACf,SAAQ,6BAA6B;IACrC,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,qBAAa,qBAAsB,SAAQ,sBAAsB,CAC/D,cAAc,EACd,oBAAoB,EACpB,4BAA4B,EAC5B,gBAAgB,EAChB,eAAe,GAAG,gDAAgD,CACnE;gBACa,EACV,wBAAwB,EACxB,SAAS,EACT,uBAAuB,EACvB,KAAK,GACN,EAAE,4BAA4B;IAU/B;;;;;;;OAOG;IACG,yBAAyB,CAC7B,aAAa,EAAE,oBAAoB,EACnC,GAAG,CAAC,EAAE,eAAe,GACpB,OAAO,CAAC,MAAM,CAAC;IAqClB;;;;;;;;;OASG;IACG,oBAAoB,CACxB,aAAa,EAAE,oBAAoB,EACnC,GAAG,CAAC,EAAE,eAAe;IAwBvB;;;;;;OAMG;IACH,qBAAqB,CACnB,aAAa,EAAE,4BAA4B,GAC1C,OAAO,CAAC,oBAAoB,CAAC;CAIjC"}
@@ -1,15 +1,15 @@
1
1
  import type { ActionConstraint, EventConstraint, RestrictedControllerMessenger } from "@metamask/base-controller";
2
2
  import type { AbstractMessage, AbstractMessageParams, AbstractMessageParamsMetamask, MessageManagerState, OriginalRequest, SecurityProviderRequest } from "./AbstractMessageManager.mjs";
3
3
  import { AbstractMessageManager } from "./AbstractMessageManager.mjs";
4
+ declare const managerName = "DecryptMessageManager";
4
5
  export type DecryptMessageManagerState = MessageManagerState<DecryptMessage>;
5
6
  export type DecryptMessageManagerUnapprovedMessageAddedEvent = {
6
- type: `${string}:unapprovedMessage`;
7
+ type: `${typeof managerName}:unapprovedMessage`;
7
8
  payload: [AbstractMessageParamsMetamask];
8
9
  };
9
10
  export type DecryptMessageManagerMessenger = RestrictedControllerMessenger<string, ActionConstraint, EventConstraint | DecryptMessageManagerUnapprovedMessageAddedEvent, string, string>;
10
11
  type DecryptMessageManagerOptions = {
11
12
  messenger: DecryptMessageManagerMessenger;
12
- name: string;
13
13
  securityProviderRequest?: SecurityProviderRequest;
14
14
  state?: MessageManagerState<DecryptMessage>;
15
15
  additionalFinishStatuses?: string[];
@@ -53,7 +53,7 @@ export interface DecryptMessageParamsMetamask extends AbstractMessageParamsMetam
53
53
  * Controller in charge of managing - storing, adding, removing, updating - DecryptMessages.
54
54
  */
55
55
  export declare class DecryptMessageManager extends AbstractMessageManager<DecryptMessage, DecryptMessageParams, DecryptMessageParamsMetamask, ActionConstraint, EventConstraint | DecryptMessageManagerUnapprovedMessageAddedEvent> {
56
- constructor({ additionalFinishStatuses, messenger, name, securityProviderRequest, state, }: DecryptMessageManagerOptions);
56
+ constructor({ additionalFinishStatuses, messenger, securityProviderRequest, state, }: DecryptMessageManagerOptions);
57
57
  /**
58
58
  * Creates a new Message with an 'unapproved' status using the passed messageParams.
59
59
  * this.addMessage is called to add the new Message to this.messages, and to save the unapproved Messages.
@@ -1 +1 @@
1
- {"version":3,"file":"DecryptMessageManager.d.mts","sourceRoot":"","sources":["../src/DecryptMessageManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,6BAA6B,EAC9B,kCAAkC;AAGnC,OAAO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AAEF;;;;;;;;;GASG;AACH,MAAM,MAAM,cAAc,GAAG,eAAe,GAAG;IAC7C,aAAa,EAAE,oBAAoB,CAAC;CACrC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,oBAAoB,GAAG,qBAAqB,GAAG;IACzD,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;;;;;;;;GASG;AAIH,MAAM,WAAW,4BACf,SAAQ,6BAA6B;IACrC,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,qBAAa,qBAAsB,SAAQ,sBAAsB,CAC/D,cAAc,EACd,oBAAoB,EACpB,4BAA4B,EAC5B,gBAAgB,EAChB,eAAe,GAAG,gDAAgD,CACnE;gBACa,EACV,wBAAwB,EACxB,SAAS,EACT,uBAAuB,EACvB,KAAK,GACN,EAAE,4BAA4B;IAU/B;;;;;;;OAOG;IACG,yBAAyB,CAC7B,aAAa,EAAE,oBAAoB,EACnC,GAAG,CAAC,EAAE,eAAe,GACpB,OAAO,CAAC,MAAM,CAAC;IAqClB;;;;;;;;;OASG;IACG,oBAAoB,CACxB,aAAa,EAAE,oBAAoB,EACnC,GAAG,CAAC,EAAE,eAAe;IAwBvB;;;;;;OAMG;IACH,qBAAqB,CACnB,aAAa,EAAE,4BAA4B,GAC1C,OAAO,CAAC,oBAAoB,CAAC;CAIjC"}
@@ -1,15 +1,16 @@
1
1
  import { ApprovalType } from "@metamask/controller-utils";
2
2
  import { AbstractMessageManager } from "./AbstractMessageManager.mjs";
3
3
  import { normalizeMessageData, validateDecryptedMessageData } from "./utils.mjs";
4
+ const managerName = 'DecryptMessageManager';
4
5
  /**
5
6
  * Controller in charge of managing - storing, adding, removing, updating - DecryptMessages.
6
7
  */
7
8
  export class DecryptMessageManager extends AbstractMessageManager {
8
- constructor({ additionalFinishStatuses, messenger, name, securityProviderRequest, state, }) {
9
+ constructor({ additionalFinishStatuses, messenger, securityProviderRequest, state, }) {
9
10
  super({
10
11
  additionalFinishStatuses,
11
12
  messenger,
12
- name,
13
+ name: managerName,
13
14
  securityProviderRequest,
14
15
  state,
15
16
  });
@@ -56,7 +57,7 @@ export class DecryptMessageManager extends AbstractMessageManager {
56
57
  const messageData = this.createUnapprovedMessage(updatedMessageParams, ApprovalType.EthDecrypt, req);
57
58
  const messageId = messageData.id;
58
59
  await this.addMessage(messageData);
59
- this.messagingSystem.publish(`${this.name}:unapprovedMessage`, {
60
+ this.messagingSystem.publish(`${managerName}:unapprovedMessage`, {
60
61
  ...updatedMessageParams,
61
62
  metamaskId: messageId,
62
63
  });
@@ -1 +1 @@
1
- {"version":3,"file":"DecryptMessageManager.mjs","sourceRoot":"","sources":["../src/DecryptMessageManager.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,mCAAmC;AAU1D,OAAO,EAAE,sBAAsB,EAAE,qCAAiC;AAClE,OAAO,EAAE,oBAAoB,EAAE,4BAA4B,EAAE,oBAAgB;AAmE7E;;GAEG;AACH,MAAM,OAAO,qBAAsB,SAAQ,sBAM1C;IACC,YAAY,EACV,wBAAwB,EACxB,SAAS,EACT,IAAI,EACJ,uBAAuB,EACvB,KAAK,GACwB;QAC7B,KAAK,CAAC;YACJ,wBAAwB;YACxB,SAAS;YACT,IAAI;YACJ,uBAAuB;YACvB,KAAK;SACN,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,yBAAyB,CAC7B,aAAmC,EACnC,GAAqB;QAErB,4BAA4B,CAAC,aAAa,CAAC,CAAC;QAC5C,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC;QAEtE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,IAAI,CAAC,cAAc,CAAC,IAAI,CACtB,GAAG,SAAS,WAAW,EACvB,CAAC,IAAoB,EAAE,EAAE;gBACvB,QAAQ,IAAI,CAAC,MAAM,EAAE;oBACnB,KAAK,W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ger,\n} from '@metamask/base-controller';\nimport { ApprovalType } from '@metamask/controller-utils';\n\nimport type {\n AbstractMessage,\n AbstractMessageParams,\n AbstractMessageParamsMetamask,\n MessageManagerState,\n OriginalRequest,\n SecurityProviderRequest,\n} from './AbstractMessageManager';\nimport { AbstractMessageManager } from './AbstractMessageManager';\nimport { normalizeMessageData, validateDecryptedMessageData } from './utils';\n\nexport type DecryptMessageManagerState = MessageManagerState<DecryptMessage>;\n\nexport type DecryptMessageManagerUnapprovedMessageAddedEvent = {\n type: `${string}:unapprovedMessage`;\n payload: [AbstractMessageParamsMetamask];\n};\n\nexport type DecryptMessageManagerMessenger = RestrictedControllerMessenger<\n string,\n ActionConstraint,\n EventConstraint | DecryptMessageManagerUnapprovedMessageAddedEvent,\n string,\n string\n>;\n\ntype DecryptMessageManagerOptions = {\n messenger: DecryptMessageManagerMessenger;\n name: string;\n securityProviderRequest?: SecurityProviderRequest;\n state?: MessageManagerState<DecryptMessage>;\n additionalFinishStatuses?: string[];\n};\n\n/**\n * @type DecryptMessage\n *\n * Represents and contains data about a 'eth_decrypt' type signature request.\n * These are created when a signature for an eth_decrypt call is requested.\n * @property id - An id to track and identify the message object\n * @property messageParams - The parameters to pass to the eth_decrypt method once the request is approved\n * @property type - The json-prc signing method for which a signature request has been made.\n * A 'DecryptMessage' which always has a 'eth_decrypt' type\n */\nexport type DecryptMessage = AbstractMessage & {\n messageParams: DecryptMessageParams;\n};\n\n/**\n * @type DecryptMessageParams\n *\n * Represents the parameters to pass to the eth_decrypt method once the request is approved.\n * @property data - A hex string conversion of the raw buffer data of the signature request\n */\nexport type DecryptMessageParams = AbstractMessageParams & {\n data: string;\n};\n\n/**\n * @type DecryptMessageParamsMetamask\n *\n * Represents the parameters to pass to the eth_decrypt method once the request is approved\n * plus data added by MetaMask.\n * @property metamaskId - Added for tracking and identification within MetaMask\n * @property data - A hex string conversion of the raw buffer data of the signature request\n * @property from - Address to sign this message from\n * @property origin? - Added for request origin identification\n */\n// This interface was created before this ESLint rule was added.\n// Convert to a `type` in a future major version.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport interface DecryptMessageParamsMetamask\n extends AbstractMessageParamsMetamask {\n data: string;\n}\n\n/**\n * Controller in charge of managing - storing, adding, removing, updating - DecryptMessages.\n */\nexport class DecryptMessageManager extends AbstractMessageManager<\n DecryptMessage,\n DecryptMessageParams,\n DecryptMessageParamsMetamask,\n ActionConstraint,\n EventConstraint | DecryptMessageManagerUnapprovedMessageAddedEvent\n> {\n constructor({\n additionalFinishStatuses,\n messenger,\n name,\n securityProviderRequest,\n state,\n }: DecryptMessageManagerOptions) {\n super({\n additionalFinishStatuses,\n messenger,\n name,\n securityProviderRequest,\n state,\n });\n }\n\n /**\n * Creates a new Message with an 'unapproved' status using the passed messageParams.\n * this.addMessage is called to add the new Message to this.messages, and to save the unapproved Messages.\n *\n * @param messageParams - The params for the personal_sign call to be made after the message is approved.\n * @param req - The original request object possibly containing the origin.\n * @returns Promise resolving to the raw data of the signature request.\n */\n async addUnapprovedMessageAsync(\n messageParams: DecryptMessageParams,\n req?: OriginalRequest,\n ): Promise<string> {\n validateDecryptedMessageData(messageParams);\n const messageId = await this.addUnapprovedMessage(messageParams, req);\n\n return new Promise((resolve, reject) => {\n this.internalEvents.once(\n `${messageId}:finished`,\n (data: DecryptMessage) => {\n switch (data.status) {\n case 'decrypted':\n return resolve(data.rawSig as string);\n case 'rejected':\n return reject(\n new Error(\n 'MetaMask DecryptMessage: User denied message decryption.',\n ),\n );\n case 'errored':\n return reject(\n new Error(\n 'MetaMask DecryptMessage: This message cannot be decrypted.',\n ),\n );\n default:\n return reject(\n new Error(\n `MetaMask DecryptMessage: Unknown problem: ${JSON.stringify(\n messageParams,\n )}`,\n ),\n );\n }\n },\n );\n });\n }\n\n /**\n * Creates a new Message with an 'unapproved' status using the passed messageParams.\n * this.addMessage is called to add the new Message to this.messages, and to save the\n * unapproved Messages.\n *\n * @param messageParams - The params for the personal_sign call to be made after the message\n * is approved.\n * @param req - The original request object possibly containing the origin.\n * @returns The id of the newly created message.\n */\n async addUnapprovedMessage(\n messageParams: DecryptMessageParams,\n req?: OriginalRequest,\n ) {\n const updatedMessageParams = this.addRequestToMessageParams(\n messageParams,\n req,\n ) satisfies DecryptMessageParams;\n messageParams.data = normalizeMessageData(messageParams.data);\n\n const messageData = this.createUnapprovedMessage(\n updatedMessageParams,\n ApprovalType.EthDecrypt,\n req,\n ) satisfies DecryptMessage;\n\n const messageId = messageData.id;\n\n await this.addMessage(messageData);\n this.messagingSystem.publish(`${this.name as string}:unapprovedMessage`, {\n ...updatedMessageParams,\n metamaskId: messageId,\n });\n return messageId;\n }\n\n /**\n * Removes the metamaskId property from passed messageParams and returns a promise which\n * resolves the updated messageParams.\n *\n * @param messageParams - The messageParams to modify.\n * @returns Promise resolving to the messageParams with the metamaskId property removed.\n */\n prepMessageForSigning(\n messageParams: DecryptMessageParamsMetamask,\n ): Promise<DecryptMessageParams> {\n delete messageParams.metamaskId;\n return Promise.resolve(messageParams);\n }\n}\n"]}
1
+ {"version":3,"file":"DecryptMessageManager.mjs","sourceRoot":"","sources":["../src/DecryptMessageManager.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,mCAAmC;AAU1D,OAAO,EAAE,sBAAsB,EAAE,qCAAiC;AAClE,OAAO,EAAE,oBAAoB,EAAE,4BAA4B,EAAE,oBAAgB;AAE7E,MAAM,WAAW,GAAG,uBAAuB,CAAC;AAkE5C;;GAEG;AACH,MAAM,OAAO,qBAAsB,SAAQ,sBAM1C;IACC,YAAY,EACV,wBAAwB,EACxB,SAAS,EACT,uBAAuB,EACvB,KAAK,GACwB;QAC7B,KAAK,CAAC;YACJ,wBAAwB;YACxB,SAAS;YACT,IAAI,EAAE,WAAW;YACjB,uBAAuB;YACvB,KAAK;SACN,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,yBAAyB,CAC7B,aAAmC,EACnC,GAAqB;QAErB,4BAA4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BAAoB,EAAE;YAC/D,GAAG,oBAAoB;YACvB,UAAU,EAAE,SAAS;SACtB,CAAC,CAAC;QACH,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;;;;;OAMG;IACH,qBAAqB,CACnB,aAA2C;QAE3C,OAAO,aAAa,CAAC,UAAU,CAAC;QAChC,OAAO,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IACxC,CAAC;CACF","sourcesContent":["import type {\n ActionConstraint,\n EventConstraint,\n RestrictedControllerMessenger,\n} from '@metamask/base-controller';\nimport { ApprovalType } from '@metamask/controller-utils';\n\nimport type {\n AbstractMessage,\n AbstractMessageParams,\n AbstractMessageParamsMetamask,\n MessageManagerState,\n OriginalRequest,\n SecurityProviderRequest,\n} from './AbstractMessageManager';\nimport { AbstractMessageManager } from './AbstractMessageManager';\nimport { normalizeMessageData, validateDecryptedMessageData } from './utils';\n\nconst managerName = 'DecryptMessageManager';\n\nexport type DecryptMessageManagerState = MessageManagerState<DecryptMessage>;\n\nexport type DecryptMessageManagerUnapprovedMessageAddedEvent = {\n type: `${typeof managerName}:unapprovedMessage`;\n payload: [AbstractMessageParamsMetamask];\n};\n\nexport type DecryptMessageManagerMessenger = RestrictedControllerMessenger<\n string,\n ActionConstraint,\n EventConstraint | DecryptMessageManagerUnapprovedMessageAddedEvent,\n string,\n string\n>;\n\ntype DecryptMessageManagerOptions = {\n messenger: DecryptMessageManagerMessenger;\n securityProviderRequest?: SecurityProviderRequest;\n state?: MessageManagerState<DecryptMessage>;\n additionalFinishStatuses?: string[];\n};\n\n/**\n * @type DecryptMessage\n *\n * Represents and contains data about a 'eth_decrypt' type signature request.\n * These are created when a signature for an eth_decrypt call is requested.\n * @property id - An id to track and identify the message object\n * @property messageParams - The parameters to pass to the eth_decrypt method once the request is approved\n * @property type - The json-prc signing method for which a signature request has been made.\n * A 'DecryptMessage' which always has a 'eth_decrypt' type\n */\nexport type DecryptMessage = AbstractMessage & {\n messageParams: DecryptMessageParams;\n};\n\n/**\n * @type DecryptMessageParams\n *\n * Represents the parameters to pass to the eth_decrypt method once the request is approved.\n * @property data - A hex string conversion of the raw buffer data of the signature request\n */\nexport type DecryptMessageParams = AbstractMessageParams & {\n data: string;\n};\n\n/**\n * @type DecryptMessageParamsMetamask\n *\n * Represents the parameters to pass to the eth_decrypt method once the request is approved\n * plus data added by MetaMask.\n * @property metamaskId - Added for tracking and identification within MetaMask\n * @property data - A hex string conversion of the raw buffer data of the signature request\n * @property from - Address to sign this message from\n * @property origin? - Added for request origin identification\n */\n// This interface was created before this ESLint rule was added.\n// Convert to a `type` in a future major version.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport interface DecryptMessageParamsMetamask\n extends AbstractMessageParamsMetamask {\n data: string;\n}\n\n/**\n * Controller in charge of managing - storing, adding, removing, updating - DecryptMessages.\n */\nexport class DecryptMessageManager extends AbstractMessageManager<\n DecryptMessage,\n DecryptMessageParams,\n DecryptMessageParamsMetamask,\n ActionConstraint,\n EventConstraint | DecryptMessageManagerUnapprovedMessageAddedEvent\n> {\n constructor({\n additionalFinishStatuses,\n messenger,\n securityProviderRequest,\n state,\n }: DecryptMessageManagerOptions) {\n super({\n additionalFinishStatuses,\n messenger,\n name: managerName,\n securityProviderRequest,\n state,\n });\n }\n\n /**\n * Creates a new Message with an 'unapproved' status using the passed messageParams.\n * this.addMessage is called to add the new Message to this.messages, and to save the unapproved Messages.\n *\n * @param messageParams - The params for the personal_sign call to be made after the message is approved.\n * @param req - The original request object possibly containing the origin.\n * @returns Promise resolving to the raw data of the signature request.\n */\n async addUnapprovedMessageAsync(\n messageParams: DecryptMessageParams,\n req?: OriginalRequest,\n ): Promise<string> {\n validateDecryptedMessageData(messageParams);\n const messageId = await this.addUnapprovedMessage(messageParams, req);\n\n return new Promise((resolve, reject) => {\n this.internalEvents.once(\n `${messageId}:finished`,\n (data: DecryptMessage) => {\n switch (data.status) {\n case 'decrypted':\n return resolve(data.rawSig as string);\n case 'rejected':\n return reject(\n new Error(\n 'MetaMask DecryptMessage: User denied message decryption.',\n ),\n );\n case 'errored':\n return reject(\n new Error(\n 'MetaMask DecryptMessage: This message cannot be decrypted.',\n ),\n );\n default:\n return reject(\n new Error(\n `MetaMask DecryptMessage: Unknown problem: ${JSON.stringify(\n messageParams,\n )}`,\n ),\n );\n }\n },\n );\n });\n }\n\n /**\n * Creates a new Message with an 'unapproved' status using the passed messageParams.\n * this.addMessage is called to add the new Message to this.messages, and to save the\n * unapproved Messages.\n *\n * @param messageParams - The params for the personal_sign call to be made after the message\n * is approved.\n * @param req - The original request object possibly containing the origin.\n * @returns The id of the newly created message.\n */\n async addUnapprovedMessage(\n messageParams: DecryptMessageParams,\n req?: OriginalRequest,\n ) {\n const updatedMessageParams = this.addRequestToMessageParams(\n messageParams,\n req,\n ) satisfies DecryptMessageParams;\n messageParams.data = normalizeMessageData(messageParams.data);\n\n const messageData = this.createUnapprovedMessage(\n updatedMessageParams,\n ApprovalType.EthDecrypt,\n req,\n ) satisfies DecryptMessage;\n\n const messageId = messageData.id;\n\n await this.addMessage(messageData);\n this.messagingSystem.publish(`${managerName}:unapprovedMessage`, {\n ...updatedMessageParams,\n metamaskId: messageId,\n });\n return messageId;\n }\n\n /**\n * Removes the metamaskId property from passed messageParams and returns a promise which\n * resolves the updated messageParams.\n *\n * @param messageParams - The messageParams to modify.\n * @returns Promise resolving to the messageParams with the metamaskId property removed.\n */\n prepMessageForSigning(\n messageParams: DecryptMessageParamsMetamask,\n ): Promise<DecryptMessageParams> {\n delete messageParams.metamaskId;\n return Promise.resolve(messageParams);\n }\n}\n"]}
@@ -4,15 +4,16 @@ exports.EncryptionPublicKeyManager = void 0;
4
4
  const controller_utils_1 = require("@metamask/controller-utils");
5
5
  const AbstractMessageManager_1 = require("./AbstractMessageManager.cjs");
6
6
  const utils_1 = require("./utils.cjs");
7
+ const managerName = 'EncryptionPublicKeyManager';
7
8
  /**
8
9
  * Controller in charge of managing - storing, adding, removing, updating - Messages.
9
10
  */
10
11
  class EncryptionPublicKeyManager extends AbstractMessageManager_1.AbstractMessageManager {
11
- constructor({ additionalFinishStatuses, messenger, name, securityProviderRequest, state, }) {
12
+ constructor({ additionalFinishStatuses, messenger, securityProviderRequest, state, }) {
12
13
  super({
13
14
  additionalFinishStatuses,
14
15
  messenger,
15
- name,
16
+ name: managerName,
16
17
  securityProviderRequest,
17
18
  state,
18
19
  });
@@ -1 +1 @@
1
- {"version":3,"file":"EncryptionPublicKeyManager.cjs","sourceRoot":"","sources":["../src/EncryptionPublicKeyManager.ts"],"names":[],"mappings":";;;AAKA,iEAA0D;AAU1D,yEAAkE;AAClE,uCAAiE;AAiEjE;;GAEG;AACH,MAAa,0BAA2B,SAAQ,+CAM/C;IACC,YAAY,EACV,wBAAwB,EACxB,SAAS,EACT,IAAI,EACJ,uBAAuB,EACvB,KAAK,GAC6B;QAClC,KAAK,CAAC;YACJ,wBAAwB;YACxB,SAAS;YACT,IAAI;YACJ,uBAAuB;YACvB,KAAK;SACN,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,yBAAyB,CAC7B,aAAwC,EACxC,GAAqB;QAErB,IAAA,8CAAsC,EAAC,aAAa,CAAC,CAAC;QACtD,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC;QAEtE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,IAAI,CAAC,cAAc,CAAC,IAAI,CACtB,GAAG,SAAS,WAAW,EACvB,CAAC,IAAyB,EAAE,EAAE;gBAC5B,QAAQ,IAAI,CAAC,MAAM,EAAE;oBACnB,KAAK,UAAU;wBACb,OAAO,OAAO,CAAC,IAAI,CAAC,MAAgB,CAAC,CAAC;oBACxC,KAAK,UAAU;wBACb,OAAO,MAAM,CACX,IAAI,KAAK,CACP,wEAAwE,CACzE,CACF,CAAC;oBACJ;wBACE,OAAO,MAAM,CACX,IAAI,KAAK,CACP,kDAAkD,IAAI,CAAC,SAAS,CAC9D,aAAa,CACd,EAAE,CACJ,CACF,CAAC;iBACL;YACH,CAAC,CACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK,CAAC,oBAAoB,CACxB,aAAwC,EACxC,GAAqB;QAErB,MAAM,oBAAoB,GAAG,IAAI,CAAC,yBAAyB,CACzD,aAAa,EACb,GAAG,CACgC,CAAC;QAEtC,MAAM,WAAW,GAAG,IAAI,CAAC,uBAAuB,CAC9C,oBAAoB,EACpB,+BAAY,CAAC,yBAAyB,EACtC,GAAG,CAC0B,CAAC;QAEhC,MAAM,SAAS,GAAG,WAAW,CAAC,EAAE,CAAC;QAEjC,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;QACnC,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,IAAc,oBAAoB,EAAE;YACvE,GAAG,oBAAoB;YACvB,UAAU,EAAE,SAAS;SACtB,CAAC,CAAC;QACH,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;;;;;OAMG;IACH,qBAAqB,CACnB,aAAgD;QAEhD,OAAO,aAAa,CAAC,UAAU,CAAC;QAChC,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,aAAa,CAAC,IAAI,EAAE,CAAC,CAAC;IACvD,CAAC;CACF;AAjHD,gEAiHC;AAED,kBAAe,0BAA0B,CAAC","sourcesContent":["import type {\n ActionConstraint,\n EventConstraint,\n RestrictedControllerMessenger,\n} from '@metamask/base-controller';\nimport { ApprovalType } from '@metamask/controller-utils';\n\nimport type {\n AbstractMessage,\n AbstractMessageParams,\n AbstractMessageParamsMetamask,\n MessageManagerState,\n OriginalRequest,\n SecurityProviderRequest,\n} from './AbstractMessageManager';\nimport { AbstractMessageManager } from './AbstractMessageManager';\nimport { validateEncryptionPublicKeyMessageData } from './utils';\n\nexport type EncryptionPublicKeyManagerState =\n MessageManagerState<EncryptionPublicKey>;\n\nexport type EncryptionPublicKeyManagerUnapprovedMessageAddedEvent = {\n type: `${string}:unapprovedMessage`;\n payload: [AbstractMessageParamsMetamask];\n};\n\nexport type EncryptionPublicKeyManagerMessenger = RestrictedControllerMessenger<\n string,\n ActionConstraint,\n EventConstraint | EncryptionPublicKeyManagerUnapprovedMessageAddedEvent,\n string,\n string\n>;\n\ntype EncryptionPublicKeyManagerOptions = {\n messenger: EncryptionPublicKeyManagerMessenger;\n name: string;\n securityProviderRequest?: SecurityProviderRequest;\n state?: MessageManagerState<EncryptionPublicKey>;\n additionalFinishStatuses?: string[];\n};\n\n/**\n * @type EncryptionPublicKey\n *\n * Represents and contains data about a 'eth_getEncryptionPublicKey' type request.\n * These are created when an encryption public key is requested.\n * @property id - An id to track and identify the message object\n * @property messageParams - The parameters to pass to the eth_getEncryptionPublicKey method once the request is approved\n * @property type - The json-prc method for which an encryption public key request has been made.\n * A 'Message' which always has a 'eth_getEncryptionPublicKey' type\n * @property rawSig - Encryption public key\n */\nexport type EncryptionPublicKey = AbstractMessage & {\n messageParams: EncryptionPublicKeyParams;\n};\n\n/**\n * @type EncryptionPublicKeyParams\n *\n * Represents the parameters to pass to the method once the request is approved.\n * @property from - Address from which to extract the encryption public key\n * @property origin? - Added for request origin identification\n */\nexport type EncryptionPublicKeyParams = AbstractMessageParams;\n\n/**\n * @type MessageParamsMetamask\n *\n * Represents the parameters to pass to the eth_getEncryptionPublicKey method once the request is approved\n * plus data added by MetaMask.\n * @property metamaskId - Added for tracking and identification within MetaMask\n * @property data - Encryption public key\n * @property from - Address from which to extract the encryption public key\n * @property origin? - Added for request origin identification\n */\nexport type EncryptionPublicKeyParamsMetamask =\n AbstractMessageParamsMetamask & {\n data: string;\n };\n\n/**\n * Controller in charge of managing - storing, adding, removing, updating - Messages.\n */\nexport class EncryptionPublicKeyManager extends AbstractMessageManager<\n EncryptionPublicKey,\n EncryptionPublicKeyParams,\n EncryptionPublicKeyParamsMetamask,\n ActionConstraint,\n EventConstraint | EncryptionPublicKeyManagerUnapprovedMessageAddedEvent\n> {\n constructor({\n additionalFinishStatuses,\n messenger,\n name,\n securityProviderRequest,\n state,\n }: EncryptionPublicKeyManagerOptions) {\n super({\n additionalFinishStatuses,\n messenger,\n name,\n securityProviderRequest,\n state,\n });\n }\n\n /**\n * Creates a new Message with an 'unapproved' status using the passed messageParams.\n * this.addMessage is called to add the new Message to this.messages, and to save the unapproved Messages.\n *\n * @param messageParams - The params for the eth_getEncryptionPublicKey call to be made after the message is approved.\n * @param req - The original request object possibly containing the origin.\n * @returns Promise resolving to the raw data of the request.\n */\n async addUnapprovedMessageAsync(\n messageParams: EncryptionPublicKeyParams,\n req?: OriginalRequest,\n ): Promise<string> {\n validateEncryptionPublicKeyMessageData(messageParams);\n const messageId = await this.addUnapprovedMessage(messageParams, req);\n\n return new Promise((resolve, reject) => {\n this.internalEvents.once(\n `${messageId}:finished`,\n (data: EncryptionPublicKey) => {\n switch (data.status) {\n case 'received':\n return resolve(data.rawSig as string);\n case 'rejected':\n return reject(\n new Error(\n 'MetaMask EncryptionPublicKey: User denied message EncryptionPublicKey.',\n ),\n );\n default:\n return reject(\n new Error(\n `MetaMask EncryptionPublicKey: Unknown problem: ${JSON.stringify(\n messageParams,\n )}`,\n ),\n );\n }\n },\n );\n });\n }\n\n /**\n * Creates a new Message with an 'unapproved' status using the passed messageParams.\n * this.addMessage is called to add the new Message to this.messages, and to save the\n * unapproved Messages.\n *\n * @param messageParams - The params for the eth_getEncryptionPublicKey call to be made after the message\n * is approved.\n * @param req - The original request object possibly containing the origin.\n * @returns The id of the newly created message.\n */\n async addUnapprovedMessage(\n messageParams: EncryptionPublicKeyParams,\n req?: OriginalRequest,\n ): Promise<string> {\n const updatedMessageParams = this.addRequestToMessageParams(\n messageParams,\n req,\n ) satisfies EncryptionPublicKeyParams;\n\n const messageData = this.createUnapprovedMessage(\n updatedMessageParams,\n ApprovalType.EthGetEncryptionPublicKey,\n req,\n ) satisfies EncryptionPublicKey;\n\n const messageId = messageData.id;\n\n await this.addMessage(messageData);\n this.messagingSystem.publish(`${this.name as string}:unapprovedMessage`, {\n ...updatedMessageParams,\n metamaskId: messageId,\n });\n return messageId;\n }\n\n /**\n * Removes the metamaskId property from passed messageParams and returns a promise which\n * resolves the updated messageParams.\n *\n * @param messageParams - The messageParams to modify.\n * @returns Promise resolving to the messageParams with the metamaskId property removed.\n */\n prepMessageForSigning(\n messageParams: EncryptionPublicKeyParamsMetamask,\n ): Promise<EncryptionPublicKeyParams> {\n delete messageParams.metamaskId;\n return Promise.resolve({ from: messageParams.data });\n }\n}\n\nexport default EncryptionPublicKeyManager;\n"]}
1
+ {"version":3,"file":"EncryptionPublicKeyManager.cjs","sourceRoot":"","sources":["../src/EncryptionPublicKeyManager.ts"],"names":[],"mappings":";;;AAKA,iEAA0D;AAU1D,yEAAkE;AAClE,uCAAiE;AAEjE,MAAM,WAAW,GAAG,4BAA4B,CAAC;AAgEjD;;GAEG;AACH,MAAa,0BAA2B,SAAQ,+CAM/C;IACC,YAAY,EACV,wBAAwB,EACxB,SAAS,EACT,uBAAuB,EACvB,KAAK,GAC6B;QAClC,KAAK,CAAC;YACJ,wBAAwB;YACxB,SAAS;YACT,IAAI,EAAE,WAAW;YACjB,uBAAuB;YACvB,KAAK;SACN,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,yBAAyB,CAC7B,aAAwC,EACxC,GAAqB;QAErB,IAAA,8CAAsC,EAAC,aAAa,CAAC,CAAC;QACtD,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC;QAEtE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,IAAI,CAAC,cAAc,CAAC,IAAI,CACtB,GAAG,SAAS,WAAW,EACvB,CAAC,IAAyB,EAAE,EAAE;gBAC5B,QAAQ,IAAI,CAAC,MAAM,EAAE;oBACnB,KAAK,UAAU;wBACb,OAAO,OAAO,CAAC,IAAI,CAAC,MAAgB,CAAC,CAAC;oBACxC,KAAK,UAAU;wBACb,OAAO,MAAM,CACX,IAAI,KAAK,CACP,wEAAwE,CACzE,CACF,CAAC;oBACJ;wBACE,OAAO,MAAM,CACX,IAAI,KAAK,CACP,kDAAkD,IAAI,CAAC,SAAS,CAC9D,aAAa,CACd,EAAE,CACJ,CACF,CAAC;iBACL;YACH,CAAC,CACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK,CAAC,oBAAoB,CACxB,aAAwC,EACxC,GAAqB;QAErB,MAAM,oBAAoB,GAAG,IAAI,CAAC,yBAAyB,CACzD,aAAa,EACb,GAAG,CACgC,CAAC;QAEtC,MAAM,WAAW,GAAG,IAAI,CAAC,uBAAuB,CAC9C,oBAAoB,EACpB,+BAAY,CAAC,yBAAyB,EACtC,GAAG,CAC0B,CAAC;QAEhC,MAAM,SAAS,GAAG,WAAW,CAAC,EAAE,CAAC;QAEjC,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;QACnC,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,IAAc,oBAAoB,EAAE;YACvE,GAAG,oBAAoB;YACvB,UAAU,EAAE,SAAS;SACtB,CAAC,CAAC;QACH,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;;;;;OAMG;IACH,qBAAqB,CACnB,aAAgD;QAEhD,OAAO,aAAa,CAAC,UAAU,CAAC;QAChC,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,aAAa,CAAC,IAAI,EAAE,CAAC,CAAC;IACvD,CAAC;CACF;AAhHD,gEAgHC;AAED,kBAAe,0BAA0B,CAAC","sourcesContent":["import type {\n ActionConstraint,\n EventConstraint,\n RestrictedControllerMessenger,\n} from '@metamask/base-controller';\nimport { ApprovalType } from '@metamask/controller-utils';\n\nimport type {\n AbstractMessage,\n AbstractMessageParams,\n AbstractMessageParamsMetamask,\n MessageManagerState,\n OriginalRequest,\n SecurityProviderRequest,\n} from './AbstractMessageManager';\nimport { AbstractMessageManager } from './AbstractMessageManager';\nimport { validateEncryptionPublicKeyMessageData } from './utils';\n\nconst managerName = 'EncryptionPublicKeyManager';\n\nexport type EncryptionPublicKeyManagerState =\n MessageManagerState<EncryptionPublicKey>;\n\nexport type EncryptionPublicKeyManagerUnapprovedMessageAddedEvent = {\n type: `${typeof managerName}:unapprovedMessage`;\n payload: [AbstractMessageParamsMetamask];\n};\n\nexport type EncryptionPublicKeyManagerMessenger = RestrictedControllerMessenger<\n string,\n ActionConstraint,\n EventConstraint | EncryptionPublicKeyManagerUnapprovedMessageAddedEvent,\n string,\n string\n>;\n\ntype EncryptionPublicKeyManagerOptions = {\n messenger: EncryptionPublicKeyManagerMessenger;\n securityProviderRequest?: SecurityProviderRequest;\n state?: MessageManagerState<EncryptionPublicKey>;\n additionalFinishStatuses?: string[];\n};\n\n/**\n * @type EncryptionPublicKey\n *\n * Represents and contains data about a 'eth_getEncryptionPublicKey' type request.\n * These are created when an encryption public key is requested.\n * @property id - An id to track and identify the message object\n * @property messageParams - The parameters to pass to the eth_getEncryptionPublicKey method once the request is approved\n * @property type - The json-prc method for which an encryption public key request has been made.\n * A 'Message' which always has a 'eth_getEncryptionPublicKey' type\n * @property rawSig - Encryption public key\n */\nexport type EncryptionPublicKey = AbstractMessage & {\n messageParams: EncryptionPublicKeyParams;\n};\n\n/**\n * @type EncryptionPublicKeyParams\n *\n * Represents the parameters to pass to the method once the request is approved.\n * @property from - Address from which to extract the encryption public key\n * @property origin? - Added for request origin identification\n */\nexport type EncryptionPublicKeyParams = AbstractMessageParams;\n\n/**\n * @type MessageParamsMetamask\n *\n * Represents the parameters to pass to the eth_getEncryptionPublicKey method once the request is approved\n * plus data added by MetaMask.\n * @property metamaskId - Added for tracking and identification within MetaMask\n * @property data - Encryption public key\n * @property from - Address from which to extract the encryption public key\n * @property origin? - Added for request origin identification\n */\nexport type EncryptionPublicKeyParamsMetamask =\n AbstractMessageParamsMetamask & {\n data: string;\n };\n\n/**\n * Controller in charge of managing - storing, adding, removing, updating - Messages.\n */\nexport class EncryptionPublicKeyManager extends AbstractMessageManager<\n EncryptionPublicKey,\n EncryptionPublicKeyParams,\n EncryptionPublicKeyParamsMetamask,\n ActionConstraint,\n EventConstraint | EncryptionPublicKeyManagerUnapprovedMessageAddedEvent\n> {\n constructor({\n additionalFinishStatuses,\n messenger,\n securityProviderRequest,\n state,\n }: EncryptionPublicKeyManagerOptions) {\n super({\n additionalFinishStatuses,\n messenger,\n name: managerName,\n securityProviderRequest,\n state,\n });\n }\n\n /**\n * Creates a new Message with an 'unapproved' status using the passed messageParams.\n * this.addMessage is called to add the new Message to this.messages, and to save the unapproved Messages.\n *\n * @param messageParams - The params for the eth_getEncryptionPublicKey call to be made after the message is approved.\n * @param req - The original request object possibly containing the origin.\n * @returns Promise resolving to the raw data of the request.\n */\n async addUnapprovedMessageAsync(\n messageParams: EncryptionPublicKeyParams,\n req?: OriginalRequest,\n ): Promise<string> {\n validateEncryptionPublicKeyMessageData(messageParams);\n const messageId = await this.addUnapprovedMessage(messageParams, req);\n\n return new Promise((resolve, reject) => {\n this.internalEvents.once(\n `${messageId}:finished`,\n (data: EncryptionPublicKey) => {\n switch (data.status) {\n case 'received':\n return resolve(data.rawSig as string);\n case 'rejected':\n return reject(\n new Error(\n 'MetaMask EncryptionPublicKey: User denied message EncryptionPublicKey.',\n ),\n );\n default:\n return reject(\n new Error(\n `MetaMask EncryptionPublicKey: Unknown problem: ${JSON.stringify(\n messageParams,\n )}`,\n ),\n );\n }\n },\n );\n });\n }\n\n /**\n * Creates a new Message with an 'unapproved' status using the passed messageParams.\n * this.addMessage is called to add the new Message to this.messages, and to save the\n * unapproved Messages.\n *\n * @param messageParams - The params for the eth_getEncryptionPublicKey call to be made after the message\n * is approved.\n * @param req - The original request object possibly containing the origin.\n * @returns The id of the newly created message.\n */\n async addUnapprovedMessage(\n messageParams: EncryptionPublicKeyParams,\n req?: OriginalRequest,\n ): Promise<string> {\n const updatedMessageParams = this.addRequestToMessageParams(\n messageParams,\n req,\n ) satisfies EncryptionPublicKeyParams;\n\n const messageData = this.createUnapprovedMessage(\n updatedMessageParams,\n ApprovalType.EthGetEncryptionPublicKey,\n req,\n ) satisfies EncryptionPublicKey;\n\n const messageId = messageData.id;\n\n await this.addMessage(messageData);\n this.messagingSystem.publish(`${this.name as string}:unapprovedMessage`, {\n ...updatedMessageParams,\n metamaskId: messageId,\n });\n return messageId;\n }\n\n /**\n * Removes the metamaskId property from passed messageParams and returns a promise which\n * resolves the updated messageParams.\n *\n * @param messageParams - The messageParams to modify.\n * @returns Promise resolving to the messageParams with the metamaskId property removed.\n */\n prepMessageForSigning(\n messageParams: EncryptionPublicKeyParamsMetamask,\n ): Promise<EncryptionPublicKeyParams> {\n delete messageParams.metamaskId;\n return Promise.resolve({ from: messageParams.data });\n }\n}\n\nexport default EncryptionPublicKeyManager;\n"]}
@@ -1,15 +1,15 @@
1
1
  import type { ActionConstraint, EventConstraint, RestrictedControllerMessenger } from "@metamask/base-controller";
2
2
  import type { AbstractMessage, AbstractMessageParams, AbstractMessageParamsMetamask, MessageManagerState, OriginalRequest, SecurityProviderRequest } from "./AbstractMessageManager.cjs";
3
3
  import { AbstractMessageManager } from "./AbstractMessageManager.cjs";
4
+ declare const managerName = "EncryptionPublicKeyManager";
4
5
  export type EncryptionPublicKeyManagerState = MessageManagerState<EncryptionPublicKey>;
5
6
  export type EncryptionPublicKeyManagerUnapprovedMessageAddedEvent = {
6
- type: `${string}:unapprovedMessage`;
7
+ type: `${typeof managerName}:unapprovedMessage`;
7
8
  payload: [AbstractMessageParamsMetamask];
8
9
  };
9
10
  export type EncryptionPublicKeyManagerMessenger = RestrictedControllerMessenger<string, ActionConstraint, EventConstraint | EncryptionPublicKeyManagerUnapprovedMessageAddedEvent, string, string>;
10
11
  type EncryptionPublicKeyManagerOptions = {
11
12
  messenger: EncryptionPublicKeyManagerMessenger;
12
- name: string;
13
13
  securityProviderRequest?: SecurityProviderRequest;
14
14
  state?: MessageManagerState<EncryptionPublicKey>;
15
15
  additionalFinishStatuses?: string[];
@@ -53,7 +53,7 @@ export type EncryptionPublicKeyParamsMetamask = AbstractMessageParamsMetamask &
53
53
  * Controller in charge of managing - storing, adding, removing, updating - Messages.
54
54
  */
55
55
  export declare class EncryptionPublicKeyManager extends AbstractMessageManager<EncryptionPublicKey, EncryptionPublicKeyParams, EncryptionPublicKeyParamsMetamask, ActionConstraint, EventConstraint | EncryptionPublicKeyManagerUnapprovedMessageAddedEvent> {
56
- constructor({ additionalFinishStatuses, messenger, name, securityProviderRequest, state, }: EncryptionPublicKeyManagerOptions);
56
+ constructor({ additionalFinishStatuses, messenger, securityProviderRequest, state, }: EncryptionPublicKeyManagerOptions);
57
57
  /**
58
58
  * Creates a new Message with an 'unapproved' status using the passed messageParams.
59
59
  * this.addMessage is called to add the new Message to this.messages, and to save the unapproved Messages.
@@ -1 +1 @@
1
- {"version":3,"file":"EncryptionPublicKeyManager.d.cts","sourceRoot":"","sources":["../src/EncryptionPublicKeyManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,6BAA6B,EAC9B,kCAAkC;AAGnC,OAAO,KAAK,EACV,eAAe,EACf,qBAAqB,EACrB,6BAA6B,EAC7B,mBAAmB,EACnB,eAAe,EACf,uBAAuB,EACxB,qCAAiC;AAClC,OAAO,EAAE,sBAAsB,EAAE,qCAAiC;AAGlE,MAAM,MAAM,+BAA+B,GACzC,mBAAmB,CAAC,mBAAmB,CAAC,CAAC;AAE3C,MAAM,MAAM,qDAAqD,GAAG;IAClE,IAAI,EAAE,GAAG,MAAM,oBAAoB,CAAC;IACpC,OAAO,EAAE,CAAC,6BAA6B,CAAC,CAAC;CAC1C,CAAC;AAEF,MAAM,MAAM,mCAAmC,GAAG,6BAA6B,CAC7E,MAAM,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BAAmB,EACnB,yBAAyB,EACzB,iCAAiC,EACjC,gBAAgB,EAChB,eAAe,GAAG,qDAAqD,CACxE;gBACa,EACV,wBAAwB,EACxB,SAAS,EACT,uBAAuB,EACvB,KAAK,GACN,EAAE,iCAAiC;IAUpC;;;;;;;OAOG;IACG,yBAAyB,CAC7B,aAAa,EAAE,yBAAyB,EACxC,GAAG,CAAC,EAAE,eAAe,GACpB,OAAO,CAAC,MAAM,CAAC;IA+BlB;;;;;;;;;OASG;IACG,oBAAoB,CACxB,aAAa,EAAE,yBAAyB,EACxC,GAAG,CAAC,EAAE,eAAe,GACpB,OAAO,CAAC,MAAM,CAAC;IAsBlB;;;;;;OAMG;IACH,qBAAqB,CACnB,aAAa,EAAE,iCAAiC,GAC/C,OAAO,CAAC,yBAAyB,CAAC;CAItC;AAED,eAAe,0BAA0B,CAAC"}
@@ -1,15 +1,15 @@
1
1
  import type { ActionConstraint, EventConstraint, RestrictedControllerMessenger } from "@metamask/base-controller";
2
2
  import type { AbstractMessage, AbstractMessageParams, AbstractMessageParamsMetamask, MessageManagerState, OriginalRequest, SecurityProviderRequest } from "./AbstractMessageManager.mjs";
3
3
  import { AbstractMessageManager } from "./AbstractMessageManager.mjs";
4
+ declare const managerName = "EncryptionPublicKeyManager";
4
5
  export type EncryptionPublicKeyManagerState = MessageManagerState<EncryptionPublicKey>;
5
6
  export type EncryptionPublicKeyManagerUnapprovedMessageAddedEvent = {
6
- type: `${string}:unapprovedMessage`;
7
+ type: `${typeof managerName}:unapprovedMessage`;
7
8
  payload: [AbstractMessageParamsMetamask];
8
9
  };
9
10
  export type EncryptionPublicKeyManagerMessenger = RestrictedControllerMessenger<string, ActionConstraint, EventConstraint | EncryptionPublicKeyManagerUnapprovedMessageAddedEvent, string, string>;
10
11
  type EncryptionPublicKeyManagerOptions = {
11
12
  messenger: EncryptionPublicKeyManagerMessenger;
12
- name: string;
13
13
  securityProviderRequest?: SecurityProviderRequest;
14
14
  state?: MessageManagerState<EncryptionPublicKey>;
15
15
  additionalFinishStatuses?: string[];
@@ -53,7 +53,7 @@ export type EncryptionPublicKeyParamsMetamask = AbstractMessageParamsMetamask &
53
53
  * Controller in charge of managing - storing, adding, removing, updating - Messages.
54
54
  */
55
55
  export declare class EncryptionPublicKeyManager extends AbstractMessageManager<EncryptionPublicKey, EncryptionPublicKeyParams, EncryptionPublicKeyParamsMetamask, ActionConstraint, EventConstraint | EncryptionPublicKeyManagerUnapprovedMessageAddedEvent> {
56
- constructor({ additionalFinishStatuses, messenger, name, securityProviderRequest, state, }: EncryptionPublicKeyManagerOptions);
56
+ constructor({ additionalFinishStatuses, messenger, securityProviderRequest, state, }: EncryptionPublicKeyManagerOptions);
57
57
  /**
58
58
  * Creates a new Message with an 'unapproved' status using the passed messageParams.
59
59
  * this.addMessage is called to add the new Message to this.messages, and to save the unapproved Messages.
@@ -1 +1 @@
1
- {"version":3,"file":"EncryptionPublicKeyManager.d.mts","sourceRoot":"","sources":["../src/EncryptionPublicKeyManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,6BAA6B,EAC9B,kCAAkC;AAGnC,OAAO,KAAK,EACV,eAAe,EACf,qBAAqB,EACrB,6BAA6B,EAC7B,mBAAmB,EACnB,eAAe,EACf,uBAAuB,EACxB,qCAAiC;AAClC,OAAO,EAAE,sBAAsB,EAAE,qCAAiC;AAGlE,MAAM,MAAM,+BAA+B,GACzC,mBAAmB,CAAC,mBAAmB,CAAC,CAAC;AAE3C,MAAM,MAAM,qDAAqD,GAAG;IAClE,IAAI,EAAE,GAAG,MAAM,oBAAoB,CAAC;IACpC,OAAO,EAAE,CAAC,6BAA6B,CAAC,CAAC;CAC1C,CAAC;AAEF,MAAM,MAAM,mCAAmC,GAAG,6BAA6B,CAC7E,MAAM,EACN,gBAAgB,EAChB,eAAe,GAAG,qDAAqD,EACvE,MAAM,EACN,MAAM,CACP,CAAC;AAEF,KAAK,iCAAiC,GAAG;IACvC,SAAS,EAAE,mCAAmC,CAAC;IAC/C,IAAI,EAAE,MAAM,CAAC;IACb,uBAAuB,CAAC,EAAE,uBAAuB,CAAC;IAClD,KAAK,CAAC,EAAE,mBAAmB,CAAC,mBAAmB,CAAC,CAAC;IACjD,wBAAwB,CAAC,EAAE,MAAM,EAAE,CAAC;CACrC,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,MAAM,mBAAmB,GAAG,eAAe,GAAG;IAClD,aAAa,EAAE,yBAAyB,CAAC;CAC1C,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,yBAAyB,GAAG,qBAAqB,CAAC;AAE9D;;;;;;;;;GASG;AACH,MAAM,MAAM,iCAAiC,GAC3C,6BAA6B,GAAG;IAC9B,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEJ;;GAEG;AACH,qBAAa,0BAA2B,SAAQ,sBAAsB,CACpE,mBAAmB,EACnB,yBAAyB,EACzB,iCAAiC,EACjC,gBAAgB,EAChB,eAAe,GAAG,qDAAqD,CACxE;gBACa,EACV,wBAAwB,EACxB,SAAS,EACT,IAAI,EACJ,uBAAuB,EACvB,KAAK,GACN,EAAE,iCAAiC;IAUpC;;;;;;;OAOG;IACG,yBAAyB,CAC7B,aAAa,EAAE,yBAAyB,EACxC,GAAG,CAAC,EAAE,eAAe,GACpB,OAAO,CAAC,MAAM,CAAC;IA+BlB;;;;;;;;;OASG;IACG,oBAAoB,CACxB,aAAa,EAAE,yBAAyB,EACxC,GAAG,CAAC,EAAE,eAAe,GACpB,OAAO,CAAC,MAAM,CAAC;IAsBlB;;;;;;OAMG;IACH,qBAAqB,CACnB,aAAa,EAAE,iCAAiC,GAC/C,OAAO,CAAC,yBAAyB,CAAC;CAItC;AAED,eAAe,0BAA0B,CAAC"}
1
+ {"version":3,"file":"EncryptionPublicKeyManager.d.mts","sourceRoot":"","sources":["../src/EncryptionPublicKeyManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,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ACT,uBAAuB,EACvB,KAAK,GACN,EAAE,iCAAiC;IAUpC;;;;;;;OAOG;IACG,yBAAyB,CAC7B,aAAa,EAAE,yBAAyB,EACxC,GAAG,CAAC,EAAE,eAAe,GACpB,OAAO,CAAC,MAAM,CAAC;IA+BlB;;;;;;;;;OASG;IACG,oBAAoB,CACxB,aAAa,EAAE,yBAAyB,EACxC,GAAG,CAAC,EAAE,eAAe,GACpB,OAAO,CAAC,MAAM,CAAC;IAsBlB;;;;;;OAMG;IACH,qBAAqB,CACnB,aAAa,EAAE,iCAAiC,GAC/C,OAAO,CAAC,yBAAyB,CAAC;CAItC;AAED,eAAe,0BAA0B,CAAC"}
@@ -1,15 +1,16 @@
1
1
  import { ApprovalType } from "@metamask/controller-utils";
2
2
  import { AbstractMessageManager } from "./AbstractMessageManager.mjs";
3
3
  import { validateEncryptionPublicKeyMessageData } from "./utils.mjs";
4
+ const managerName = 'EncryptionPublicKeyManager';
4
5
  /**
5
6
  * Controller in charge of managing - storing, adding, removing, updating - Messages.
6
7
  */
7
8
  export class EncryptionPublicKeyManager extends AbstractMessageManager {
8
- constructor({ additionalFinishStatuses, messenger, name, securityProviderRequest, state, }) {
9
+ constructor({ additionalFinishStatuses, messenger, securityProviderRequest, state, }) {
9
10
  super({
10
11
  additionalFinishStatuses,
11
12
  messenger,
12
- name,
13
+ name: managerName,
13
14
  securityProviderRequest,
14
15
  state,
15
16
  });
@@ -1 +1 @@
1
- {"version":3,"file":"EncryptionPublicKeyManager.mjs","sourceRoot":"","sources":["../src/EncryptionPublicKeyManager.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,mCAAmC;AAU1D,OAAO,EAAE,sBAAsB,EAAE,qCAAiC;AAClE,OAAO,EAAE,sCAAsC,EAAE,oBAAgB;AAiEjE;;GAEG;AACH,MAAM,OAAO,0BAA2B,SAAQ,sBAM/C;IACC,YAAY,EACV,wBAAwB,EACxB,SAAS,EACT,IAAI,EACJ,uBAAuB,EACvB,KAAK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AAC,eAAe,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,IAAc,oBAAoB,EAAE;YACvE,GAAG,oBAAoB;YACvB,UAAU,EAAE,SAAS;SACtB,CAAC,CAAC;QACH,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;;;;;OAMG;IACH,qBAAqB,CACnB,aAAgD;QAEhD,OAAO,aAAa,CAAC,UAAU,CAAC;QAChC,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,aAAa,CAAC,IAAI,EAAE,CAAC,CAAC;IACvD,CAAC;CACF;AAED,eAAe,0BAA0B,CAAC","sourcesContent":["import type {\n ActionConstraint,\n EventConstraint,\n RestrictedControllerMessenger,\n} from '@metamask/base-controller';\nimport { ApprovalType } from '@metamask/controller-utils';\n\nimport type {\n AbstractMessage,\n AbstractMessageParams,\n AbstractMessageParamsMetamask,\n MessageManagerState,\n OriginalRequest,\n SecurityProviderRequest,\n} from './AbstractMessageManager';\nimport { AbstractMessageManager } from './AbstractMessageManager';\nimport { validateEncryptionPublicKeyMessageData } from './utils';\n\nexport type EncryptionPublicKeyManagerState =\n MessageManagerState<EncryptionPublicKey>;\n\nexport type EncryptionPublicKeyManagerUnapprovedMessageAddedEvent = {\n type: `${string}:unapprovedMessage`;\n payload: [AbstractMessageParamsMetamask];\n};\n\nexport type EncryptionPublicKeyManagerMessenger = RestrictedControllerMessenger<\n string,\n ActionConstraint,\n EventConstraint | EncryptionPublicKeyManagerUnapprovedMessageAddedEvent,\n string,\n string\n>;\n\ntype EncryptionPublicKeyManagerOptions = {\n messenger: EncryptionPublicKeyManagerMessenger;\n name: string;\n securityProviderRequest?: SecurityProviderRequest;\n state?: MessageManagerState<EncryptionPublicKey>;\n additionalFinishStatuses?: string[];\n};\n\n/**\n * @type EncryptionPublicKey\n *\n * Represents and contains data about a 'eth_getEncryptionPublicKey' type request.\n * These are created when an encryption public key is requested.\n * @property id - An id to track and identify the message object\n * @property messageParams - The parameters to pass to the eth_getEncryptionPublicKey method once the request is approved\n * @property type - The json-prc method for which an encryption public key request has been made.\n * A 'Message' which always has a 'eth_getEncryptionPublicKey' type\n * @property rawSig - Encryption public key\n */\nexport type EncryptionPublicKey = AbstractMessage & {\n messageParams: EncryptionPublicKeyParams;\n};\n\n/**\n * @type EncryptionPublicKeyParams\n *\n * Represents the parameters to pass to the method once the request is approved.\n * @property from - Address from which to extract the encryption public key\n * @property origin? - Added for request origin identification\n */\nexport type EncryptionPublicKeyParams = AbstractMessageParams;\n\n/**\n * @type MessageParamsMetamask\n *\n * Represents the parameters to pass to the eth_getEncryptionPublicKey method once the request is approved\n * plus data added by MetaMask.\n * @property metamaskId - Added for tracking and identification within MetaMask\n * @property data - Encryption public key\n * @property from - Address from which to extract the encryption public key\n * @property origin? - Added for request origin identification\n */\nexport type EncryptionPublicKeyParamsMetamask =\n AbstractMessageParamsMetamask & {\n data: string;\n };\n\n/**\n * Controller in charge of managing - storing, adding, removing, updating - Messages.\n */\nexport class EncryptionPublicKeyManager extends AbstractMessageManager<\n EncryptionPublicKey,\n EncryptionPublicKeyParams,\n EncryptionPublicKeyParamsMetamask,\n ActionConstraint,\n EventConstraint | EncryptionPublicKeyManagerUnapprovedMessageAddedEvent\n> {\n constructor({\n additionalFinishStatuses,\n messenger,\n name,\n securityProviderRequest,\n state,\n }: EncryptionPublicKeyManagerOptions) {\n super({\n additionalFinishStatuses,\n messenger,\n name,\n securityProviderRequest,\n state,\n });\n }\n\n /**\n * Creates a new Message with an 'unapproved' status using the passed messageParams.\n * this.addMessage is called to add the new Message to this.messages, and to save the unapproved Messages.\n *\n * @param messageParams - The params for the eth_getEncryptionPublicKey call to be made after the message is approved.\n * @param req - The original request object possibly containing the origin.\n * @returns Promise resolving to the raw data of the request.\n */\n async addUnapprovedMessageAsync(\n messageParams: EncryptionPublicKeyParams,\n req?: OriginalRequest,\n ): Promise<string> {\n validateEncryptionPublicKeyMessageData(messageParams);\n const messageId = await this.addUnapprovedMessage(messageParams, req);\n\n return new Promise((resolve, reject) => {\n this.internalEvents.once(\n `${messageId}:finished`,\n (data: EncryptionPublicKey) => {\n switch (data.status) {\n case 'received':\n return resolve(data.rawSig as string);\n case 'rejected':\n return reject(\n new Error(\n 'MetaMask EncryptionPublicKey: User denied message EncryptionPublicKey.',\n ),\n );\n default:\n return reject(\n new Error(\n `MetaMask EncryptionPublicKey: Unknown problem: ${JSON.stringify(\n messageParams,\n )}`,\n ),\n );\n }\n },\n );\n });\n }\n\n /**\n * Creates a new Message with an 'unapproved' status using the passed messageParams.\n * this.addMessage is called to add the new Message to this.messages, and to save the\n * unapproved Messages.\n *\n * @param messageParams - The params for the eth_getEncryptionPublicKey call to be made after the message\n * is approved.\n * @param req - The original request object possibly containing the origin.\n * @returns The id of the newly created message.\n */\n async addUnapprovedMessage(\n messageParams: EncryptionPublicKeyParams,\n req?: OriginalRequest,\n ): Promise<string> {\n const updatedMessageParams = this.addRequestToMessageParams(\n messageParams,\n req,\n ) satisfies EncryptionPublicKeyParams;\n\n const messageData = this.createUnapprovedMessage(\n updatedMessageParams,\n ApprovalType.EthGetEncryptionPublicKey,\n req,\n ) satisfies EncryptionPublicKey;\n\n const messageId = messageData.id;\n\n await this.addMessage(messageData);\n this.messagingSystem.publish(`${this.name as string}:unapprovedMessage`, {\n ...updatedMessageParams,\n metamaskId: messageId,\n });\n return messageId;\n }\n\n /**\n * Removes the metamaskId property from passed messageParams and returns a promise which\n * resolves the updated messageParams.\n *\n * @param messageParams - The messageParams to modify.\n * @returns Promise resolving to the messageParams with the metamaskId property removed.\n */\n prepMessageForSigning(\n messageParams: EncryptionPublicKeyParamsMetamask,\n ): Promise<EncryptionPublicKeyParams> {\n delete messageParams.metamaskId;\n return Promise.resolve({ from: messageParams.data });\n }\n}\n\nexport default EncryptionPublicKeyManager;\n"]}
1
+ {"version":3,"file":"EncryptionPublicKeyManager.mjs","sourceRoot":"","sources":["../src/EncryptionPublicKeyManager.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,m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AAa,EACb,GAAG,CACgC,CAAC;QAEtC,MAAM,WAAW,GAAG,IAAI,CAAC,uBAAuB,CAC9C,oBAAoB,EACpB,YAAY,CAAC,yBAAyB,EACtC,GAAG,CAC0B,CAAC;QAEhC,MAAM,SAAS,GAAG,WAAW,CAAC,EAAE,CAAC;QAEjC,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;QACnC,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,IAAc,oBAAoB,EAAE;YACvE,GAAG,oBAAoB;YACvB,UAAU,EAAE,SAAS;SACtB,CAAC,CAAC;QACH,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;;;;;OAMG;IACH,qBAAqB,CACnB,aAAgD;QAEhD,OAAO,aAAa,CAAC,UAAU,CAAC;QAChC,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,aAAa,CAAC,IAAI,EAAE,CAAC,CAAC;IACvD,CAAC;CACF;AAED,eAAe,0BAA0B,CAAC","sourcesContent":["import type {\n ActionConstraint,\n EventConstraint,\n RestrictedControllerMessenger,\n} from '@metamask/base-controller';\nimport { ApprovalType } from '@metamask/controller-utils';\n\nimport type {\n AbstractMessage,\n AbstractMessageParams,\n AbstractMessageParamsMetamask,\n MessageManagerState,\n OriginalRequest,\n SecurityProviderRequest,\n} from './AbstractMessageManager';\nimport { AbstractMessageManager } from './AbstractMessageManager';\nimport { validateEncryptionPublicKeyMessageData } from './utils';\n\nconst managerName = 'EncryptionPublicKeyManager';\n\nexport type EncryptionPublicKeyManagerState =\n MessageManagerState<EncryptionPublicKey>;\n\nexport type EncryptionPublicKeyManagerUnapprovedMessageAddedEvent = {\n type: `${typeof managerName}:unapprovedMessage`;\n payload: [AbstractMessageParamsMetamask];\n};\n\nexport type EncryptionPublicKeyManagerMessenger = RestrictedControllerMessenger<\n string,\n ActionConstraint,\n EventConstraint | EncryptionPublicKeyManagerUnapprovedMessageAddedEvent,\n string,\n string\n>;\n\ntype EncryptionPublicKeyManagerOptions = {\n messenger: EncryptionPublicKeyManagerMessenger;\n securityProviderRequest?: SecurityProviderRequest;\n state?: MessageManagerState<EncryptionPublicKey>;\n additionalFinishStatuses?: string[];\n};\n\n/**\n * @type EncryptionPublicKey\n *\n * Represents and contains data about a 'eth_getEncryptionPublicKey' type request.\n * These are created when an encryption public key is requested.\n * @property id - An id to track and identify the message object\n * @property messageParams - The parameters to pass to the eth_getEncryptionPublicKey method once the request is approved\n * @property type - The json-prc method for which an encryption public key request has been made.\n * A 'Message' which always has a 'eth_getEncryptionPublicKey' type\n * @property rawSig - Encryption public key\n */\nexport type EncryptionPublicKey = AbstractMessage & {\n messageParams: EncryptionPublicKeyParams;\n};\n\n/**\n * @type EncryptionPublicKeyParams\n *\n * Represents the parameters to pass to the method once the request is approved.\n * @property from - Address from which to extract the encryption public key\n * @property origin? - Added for request origin identification\n */\nexport type EncryptionPublicKeyParams = AbstractMessageParams;\n\n/**\n * @type MessageParamsMetamask\n *\n * Represents the parameters to pass to the eth_getEncryptionPublicKey method once the request is approved\n * plus data added by MetaMask.\n * @property metamaskId - Added for tracking and identification within MetaMask\n * @property data - Encryption public key\n * @property from - Address from which to extract the encryption public key\n * @property origin? - Added for request origin identification\n */\nexport type EncryptionPublicKeyParamsMetamask =\n AbstractMessageParamsMetamask & {\n data: string;\n };\n\n/**\n * Controller in charge of managing - storing, adding, removing, updating - Messages.\n */\nexport class EncryptionPublicKeyManager extends AbstractMessageManager<\n EncryptionPublicKey,\n EncryptionPublicKeyParams,\n EncryptionPublicKeyParamsMetamask,\n ActionConstraint,\n EventConstraint | EncryptionPublicKeyManagerUnapprovedMessageAddedEvent\n> {\n constructor({\n additionalFinishStatuses,\n messenger,\n securityProviderRequest,\n state,\n }: EncryptionPublicKeyManagerOptions) {\n super({\n additionalFinishStatuses,\n messenger,\n name: managerName,\n securityProviderRequest,\n state,\n });\n }\n\n /**\n * Creates a new Message with an 'unapproved' status using the passed messageParams.\n * this.addMessage is called to add the new Message to this.messages, and to save the unapproved Messages.\n *\n * @param messageParams - The params for the eth_getEncryptionPublicKey call to be made after the message is approved.\n * @param req - The original request object possibly containing the origin.\n * @returns Promise resolving to the raw data of the request.\n */\n async addUnapprovedMessageAsync(\n messageParams: EncryptionPublicKeyParams,\n req?: OriginalRequest,\n ): Promise<string> {\n validateEncryptionPublicKeyMessageData(messageParams);\n const messageId = await this.addUnapprovedMessage(messageParams, req);\n\n return new Promise((resolve, reject) => {\n this.internalEvents.once(\n `${messageId}:finished`,\n (data: EncryptionPublicKey) => {\n switch (data.status) {\n case 'received':\n return resolve(data.rawSig as string);\n case 'rejected':\n return reject(\n new Error(\n 'MetaMask EncryptionPublicKey: User denied message EncryptionPublicKey.',\n ),\n );\n default:\n return reject(\n new Error(\n `MetaMask EncryptionPublicKey: Unknown problem: ${JSON.stringify(\n messageParams,\n )}`,\n ),\n );\n }\n },\n );\n });\n }\n\n /**\n * Creates a new Message with an 'unapproved' status using the passed messageParams.\n * this.addMessage is called to add the new Message to this.messages, and to save the\n * unapproved Messages.\n *\n * @param messageParams - The params for the eth_getEncryptionPublicKey call to be made after the message\n * is approved.\n * @param req - The original request object possibly containing the origin.\n * @returns The id of the newly created message.\n */\n async addUnapprovedMessage(\n messageParams: EncryptionPublicKeyParams,\n req?: OriginalRequest,\n ): Promise<string> {\n const updatedMessageParams = this.addRequestToMessageParams(\n messageParams,\n req,\n ) satisfies EncryptionPublicKeyParams;\n\n const messageData = this.createUnapprovedMessage(\n updatedMessageParams,\n ApprovalType.EthGetEncryptionPublicKey,\n req,\n ) satisfies EncryptionPublicKey;\n\n const messageId = messageData.id;\n\n await this.addMessage(messageData);\n this.messagingSystem.publish(`${this.name as string}:unapprovedMessage`, {\n ...updatedMessageParams,\n metamaskId: messageId,\n });\n return messageId;\n }\n\n /**\n * Removes the metamaskId property from passed messageParams and returns a promise which\n * resolves the updated messageParams.\n *\n * @param messageParams - The messageParams to modify.\n * @returns Promise resolving to the messageParams with the metamaskId property removed.\n */\n prepMessageForSigning(\n messageParams: EncryptionPublicKeyParamsMetamask,\n ): Promise<EncryptionPublicKeyParams> {\n delete messageParams.metamaskId;\n return Promise.resolve({ from: messageParams.data });\n }\n}\n\nexport default EncryptionPublicKeyManager;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask-previews/message-manager",
3
- "version": "11.0.3-preview-77ba063e",
3
+ "version": "11.0.3-preview-e5e6db48",
4
4
  "description": "Stores and manages interactions with signing requests",
5
5
  "keywords": [
6
6
  "MetaMask",