Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@metamask/message-manager

Package Overview
Dependencies
Maintainers
9
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@metamask/message-manager - npm Package Compare versions

Comparing version 6.0.0 to 7.0.0

10

CHANGELOG.md

@@ -9,2 +9,9 @@ # Changelog

## [7.0.0]
### Added
- Added `waitForFinishStatus` to `AbstractMessageManager` which is waiting for the message to be proccesed and resolve. ([#1377](https://github.com/MetaMask/core/pull/1377))
### Changed
- **BREAKING:** Removed `addUnapprovedMessageAsync` methods from `PersonalMessageManager`, `TypedMessageManager` and `MessageManager` because it's not consumed by `SignatureController` anymore. ([#1377](https://github.com/MetaMask/core/pull/1377))
## [6.0.0]

@@ -77,3 +84,4 @@ ### Added

[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/message-manager@6.0.0...HEAD
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/message-manager@7.0.0...HEAD
[7.0.0]: https://github.com/MetaMask/core/compare/@metamask/message-manager@6.0.0...@metamask/message-manager@7.0.0
[6.0.0]: https://github.com/MetaMask/core/compare/@metamask/message-manager@5.0.0...@metamask/message-manager@6.0.0

@@ -80,0 +88,0 @@ [5.0.0]: https://github.com/MetaMask/core/compare/@metamask/message-manager@4.0.0...@metamask/message-manager@5.0.0

@@ -34,2 +34,3 @@ /// <reference types="node" />

metadata?: Json;
error?: string;
}

@@ -230,2 +231,13 @@ /**

/**
* Creates a new Message with an 'unapproved' status using the passed messageParams.
* this.addMessage is called to add the new Message to this.messages, and to save the
* unapproved Messages.
*
* @param messageParams - Message parameters for the message to add
* @param req - The original request object possibly containing the origin.
* @param version? - The version of the JSON RPC protocol the request is using.
* @returns The id of the newly created message.
*/
abstract addUnapprovedMessage(messageParams: PM, request: OriginalRequest, version?: string): Promise<string>;
/**
* Sets a Message status to 'rejected' via a call to this.setMessageStatus.

@@ -236,4 +248,12 @@ *

rejectMessage(messageId: string): void;
/**
* Creates a promise which will resolve or reject when the message process is finished.
*
* @param messageParamsWithId - The params for the personal_sign call to be made after the message is approved.
* @param messageName - The name of the message
* @returns Promise resolving to the raw data of the signature request.
*/
waitForFinishStatus(messageParamsWithId: AbstractMessageParamsMetamask, messageName: string): Promise<string>;
}
export default AbstractMessageManager;
//# sourceMappingURL=AbstractMessageManager.d.ts.map

@@ -11,2 +11,13 @@ "use strict";

};
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -255,2 +266,28 @@ exports.AbstractMessageManager = void 0;

}
/**
* Creates a promise which will resolve or reject when the message process is finished.
*
* @param messageParamsWithId - The params for the personal_sign call to be made after the message is approved.
* @param messageName - The name of the message
* @returns Promise resolving to the raw data of the signature request.
*/
waitForFinishStatus(messageParamsWithId, messageName) {
return __awaiter(this, void 0, void 0, function* () {
const { metamaskId: messageId } = messageParamsWithId, messageParams = __rest(messageParamsWithId, ["metamaskId"]);
return new Promise((resolve, reject) => {
this.hub.once(`${messageId}:finished`, (data) => {
switch (data.status) {
case 'signed':
return resolve(data.rawSig);
case 'rejected':
return reject(new Error(`MetaMask ${messageName} Signature: User denied message signature.`));
case 'errored':
return reject(new Error(`MetaMask ${messageName} Signature: ${data.error}`));
default:
return reject(new Error(`MetaMask ${messageName} Signature: Unknown problem: ${JSON.stringify(messageParams)}`));
}
});
});
});
}
}

@@ -257,0 +294,0 @@ exports.AbstractMessageManager = AbstractMessageManager;

9

dist/MessageManager.d.ts

@@ -50,11 +50,2 @@ import { AbstractMessageManager, AbstractMessage, AbstractMessageParams, AbstractMessageParamsMetamask, OriginalRequest } from './AbstractMessageManager';

* Creates a new Message with an 'unapproved' status using the passed messageParams.
* this.addMessage is called to add the new Message to this.messages, and to save the unapproved Messages.
*
* @param messageParams - The params for the eth_sign call to be made after the message is approved.
* @param req - The original request object possibly containing the origin.
* @returns Promise resolving to the raw data of the signature request.
*/
addUnapprovedMessageAsync(messageParams: MessageParams, req?: OriginalRequest): Promise<string>;
/**
* Creates a new Message with an 'unapproved' status using the passed messageParams.
* this.addMessage is called to add the new Message to this.messages, and to save the

@@ -61,0 +52,0 @@ * unapproved Messages.

@@ -29,28 +29,2 @@ "use strict";

* Creates a new Message with an 'unapproved' status using the passed messageParams.
* this.addMessage is called to add the new Message to this.messages, and to save the unapproved Messages.
*
* @param messageParams - The params for the eth_sign call to be made after the message is approved.
* @param req - The original request object possibly containing the origin.
* @returns Promise resolving to the raw data of the signature request.
*/
addUnapprovedMessageAsync(messageParams, req) {
return __awaiter(this, void 0, void 0, function* () {
(0, utils_1.validateSignMessageData)(messageParams);
const messageId = yield this.addUnapprovedMessage(messageParams, req);
return new Promise((resolve, reject) => {
this.hub.once(`${messageId}:finished`, (data) => {
switch (data.status) {
case 'signed':
return resolve(data.rawSig);
case 'rejected':
return reject(new Error('MetaMask Message Signature: User denied message signature.'));
default:
return reject(new Error(`MetaMask Message Signature: Unknown problem: ${JSON.stringify(messageParams)}`));
}
});
});
});
}
/**
* Creates a new Message with an 'unapproved' status using the passed messageParams.
* this.addMessage is called to add the new Message to this.messages, and to save the

@@ -66,2 +40,3 @@ * unapproved Messages.

return __awaiter(this, void 0, void 0, function* () {
(0, utils_1.validateSignMessageData)(messageParams);
if (req) {

@@ -68,0 +43,0 @@ messageParams.origin = req.origin;

@@ -52,11 +52,2 @@ import { SIWEMessage } from '@metamask/controller-utils';

* Creates a new Message with an 'unapproved' status using the passed messageParams.
* this.addMessage is called to add the new Message to this.messages, and to save the unapproved Messages.
*
* @param messageParams - The params for the personal_sign call to be made after the message is approved.
* @param req - The original request object possibly containing the origin.
* @returns Promise resolving to the raw data of the signature request.
*/
addUnapprovedMessageAsync(messageParams: PersonalMessageParams, req?: OriginalRequest): Promise<string>;
/**
* Creates a new Message with an 'unapproved' status using the passed messageParams.
* this.addMessage is called to add the new Message to this.messages, and to save the

@@ -63,0 +54,0 @@ * unapproved Messages.

@@ -30,28 +30,2 @@ "use strict";

* Creates a new Message with an 'unapproved' status using the passed messageParams.
* this.addMessage is called to add the new Message to this.messages, and to save the unapproved Messages.
*
* @param messageParams - The params for the personal_sign call to be made after the message is approved.
* @param req - The original request object possibly containing the origin.
* @returns Promise resolving to the raw data of the signature request.
*/
addUnapprovedMessageAsync(messageParams, req) {
return __awaiter(this, void 0, void 0, function* () {
(0, utils_1.validateSignMessageData)(messageParams);
const messageId = yield this.addUnapprovedMessage(messageParams, req);
return new Promise((resolve, reject) => {
this.hub.once(`${messageId}:finished`, (data) => {
switch (data.status) {
case 'signed':
return resolve(data.rawSig);
case 'rejected':
return reject(new Error('MetaMask Personal Message Signature: User denied message signature.'));
default:
return reject(new Error(`MetaMask Personal Message Signature: Unknown problem: ${JSON.stringify(messageParams)}`));
}
});
});
});
}
/**
* Creates a new Message with an 'unapproved' status using the passed messageParams.
* this.addMessage is called to add the new Message to this.messages, and to save the

@@ -67,2 +41,3 @@ * unapproved Messages.

return __awaiter(this, void 0, void 0, function* () {
(0, utils_1.validateSignMessageData)(messageParams);
if (req) {

@@ -69,0 +44,0 @@ messageParams.origin = req.origin;

@@ -64,12 +64,2 @@ import { AbstractMessageManager, AbstractMessage, AbstractMessageParams, AbstractMessageParamsMetamask, OriginalRequest } from './AbstractMessageManager';

* Creates a new TypedMessage with an 'unapproved' status using the passed messageParams.
* this.addMessage is called to add the new TypedMessage to this.messages, and to save the unapproved TypedMessages.
*
* @param messageParams - The params for the eth_signTypedData call to be made after the message is approved.
* @param version - Compatibility version EIP712.
* @param req - The original request object possibly containing the origin.
* @returns Promise resolving to the raw data of the signature request.
*/
addUnapprovedMessageAsync(messageParams: TypedMessageParams, version: string, req?: OriginalRequest): Promise<string>;
/**
* Creates a new TypedMessage with an 'unapproved' status using the passed messageParams.
* this.addMessage is called to add the new TypedMessage to this.messages, and to save the

@@ -80,7 +70,7 @@ * unapproved TypedMessages.

* is approved.
* @param req - The original request object possibly containing the origin.
* @param version - Compatibility version EIP712.
* @param req - The original request object possibly containing the origin.
* @returns The id of the newly created TypedMessage.
*/
addUnapprovedMessage(messageParams: TypedMessageParams, version: string, req?: OriginalRequest): Promise<string>;
addUnapprovedMessage(messageParams: TypedMessageParams, req?: OriginalRequest, version?: string): Promise<string>;
/**

@@ -87,0 +77,0 @@ * Sets a TypedMessage status to 'errored' via a call to this.setMessageStatus.

@@ -29,10 +29,12 @@ "use strict";

* Creates a new TypedMessage with an 'unapproved' status using the passed messageParams.
* this.addMessage is called to add the new TypedMessage to this.messages, and to save the unapproved TypedMessages.
* this.addMessage is called to add the new TypedMessage to this.messages, and to save the
* unapproved TypedMessages.
*
* @param messageParams - The params for the eth_signTypedData call to be made after the message is approved.
* @param messageParams - The params for the 'eth_signTypedData' call to be made after the message
* is approved.
* @param req - The original request object possibly containing the origin.
* @param version - Compatibility version EIP712.
* @param req - The original request object possibly containing the origin.
* @returns Promise resolving to the raw data of the signature request.
* @returns The id of the newly created TypedMessage.
*/
addUnapprovedMessageAsync(messageParams, version, req) {
addUnapprovedMessage(messageParams, req, version) {
var _a;

@@ -47,32 +49,2 @@ return __awaiter(this, void 0, void 0, function* () {

}
const messageId = yield this.addUnapprovedMessage(messageParams, version, req);
return new Promise((resolve, reject) => {
this.hub.once(`${messageId}:finished`, (data) => {
switch (data.status) {
case 'signed':
return resolve(data.rawSig);
case 'rejected':
return reject(new Error('MetaMask Typed Message Signature: User denied message signature.'));
case 'errored':
return reject(new Error(`MetaMask Typed Message Signature: ${data.error}`));
default:
return reject(new Error(`MetaMask Typed Message Signature: Unknown problem: ${JSON.stringify(messageParams)}`));
}
});
});
});
}
/**
* Creates a new TypedMessage with an 'unapproved' status using the passed messageParams.
* this.addMessage is called to add the new TypedMessage to this.messages, and to save the
* unapproved TypedMessages.
*
* @param messageParams - The params for the 'eth_signTypedData' call to be made after the message
* is approved.
* @param version - Compatibility version EIP712.
* @param req - The original request object possibly containing the origin.
* @returns The id of the newly created TypedMessage.
*/
addUnapprovedMessage(messageParams, version, req) {
return __awaiter(this, void 0, void 0, function* () {
const messageId = (0, uuid_1.v1)();

@@ -79,0 +51,0 @@ const messageParamsMetamask = Object.assign(Object.assign({}, messageParams), { metamaskId: messageId, version });

{
"name": "@metamask/message-manager",
"version": "6.0.0",
"version": "7.0.0",
"description": "Stores and manages interactions with signing requests",

@@ -5,0 +5,0 @@ "keywords": [

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc