@metamask-previews/message-manager 7.3.0-preview.3dbf14f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +120 -0
- package/LICENSE +20 -0
- package/README.md +15 -0
- package/dist/AbstractMessageManager.d.ts +258 -0
- package/dist/AbstractMessageManager.d.ts.map +1 -0
- package/dist/AbstractMessageManager.js +294 -0
- package/dist/AbstractMessageManager.js.map +1 -0
- package/dist/DecryptMessageManager.d.ts +75 -0
- package/dist/DecryptMessageManager.d.ts.map +1 -0
- package/dist/DecryptMessageManager.js +97 -0
- package/dist/DecryptMessageManager.js.map +1 -0
- package/dist/EncryptionPublicKeyManager.d.ts +76 -0
- package/dist/EncryptionPublicKeyManager.d.ts.map +1 -0
- package/dist/EncryptionPublicKeyManager.js +95 -0
- package/dist/EncryptionPublicKeyManager.js.map +1 -0
- package/dist/MessageManager.d.ts +70 -0
- package/dist/MessageManager.d.ts.map +1 -0
- package/dist/MessageManager.js +72 -0
- package/dist/MessageManager.js.map +1 -0
- package/dist/PersonalMessageManager.d.ts +72 -0
- package/dist/PersonalMessageManager.d.ts.map +1 -0
- package/dist/PersonalMessageManager.js +75 -0
- package/dist/PersonalMessageManager.js.map +1 -0
- package/dist/TypedMessageManager.d.ts +98 -0
- package/dist/TypedMessageManager.d.ts.map +1 -0
- package/dist/TypedMessageManager.js +101 -0
- package/dist/TypedMessageManager.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/utils.d.ts +51 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +145 -0
- package/dist/utils.js.map +1 -0
- package/package.json +57 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
All notable changes to this project will be documented in this file.
|
|
3
|
+
|
|
4
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
5
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
|
+
|
|
7
|
+
## [Unreleased]
|
|
8
|
+
|
|
9
|
+
## [7.3.0]
|
|
10
|
+
### Changed
|
|
11
|
+
- Add Blockaid validation response to messages ([#1541](https://github.com/MetaMask/core/pull/1541))
|
|
12
|
+
|
|
13
|
+
## [7.2.0]
|
|
14
|
+
### Changed
|
|
15
|
+
- Update `@metamask/utils` to `^6.2.0` ([#1514](https://github.com/MetaMask/core/pull/1514))
|
|
16
|
+
|
|
17
|
+
## [7.1.0]
|
|
18
|
+
### Changed
|
|
19
|
+
- Replace eth-sig-util with @metamask/eth-sig-util ([#1483](https://github.com/MetaMask/core/pull/1483))
|
|
20
|
+
|
|
21
|
+
## [7.0.2]
|
|
22
|
+
### Fixed
|
|
23
|
+
- Avoid race condition when creating typed messages ([#1467](https://github.com/MetaMask/core/pull/1467))
|
|
24
|
+
|
|
25
|
+
## [7.0.1]
|
|
26
|
+
### Fixed
|
|
27
|
+
- eth_signTypedData_v4 and v3 should take an object as well as string for data parameter. ([#1438](https://github.com/MetaMask/core/pull/1438))
|
|
28
|
+
|
|
29
|
+
## [7.0.0]
|
|
30
|
+
### Added
|
|
31
|
+
- Added `waitForFinishStatus` to `AbstractMessageManager` which is waiting for the message to be proccesed and resolve. ([#1377](https://github.com/MetaMask/core/pull/1377))
|
|
32
|
+
|
|
33
|
+
### Changed
|
|
34
|
+
- **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))
|
|
35
|
+
|
|
36
|
+
## [6.0.0]
|
|
37
|
+
### Added
|
|
38
|
+
- Add `getAllMessages` and `setMetadata` methods to message managers ([#1364](https://github.com/MetaMask/core/pull/1364))
|
|
39
|
+
- A new optional `metadata` property has been added to the message type as well
|
|
40
|
+
- Add support for deferred signing ([#1364](https://github.com/MetaMask/core/pull/1364))
|
|
41
|
+
- `deferSetAsSigned` has been added as a message parameter. This is used to tell the signature controller to not mark this message as signed when the keyring is asked to sign it.
|
|
42
|
+
- Add the `setMessageStatusInProgress` method to set a message status to `inProgress` ([#1339](https://github.com/MetaMask/core/pull/1339))
|
|
43
|
+
|
|
44
|
+
### Changed
|
|
45
|
+
- **BREAKING:** The `getCurrentChainId` constructor parameter for each message manager now expects a `Hex` return type rather than a decimal string ([#1367](https://github.com/MetaMask/core/pull/1367))
|
|
46
|
+
- Note that while every message manager class accepts this as a constructor parameter, it's only used by the `TypedMessageManager` at the moment
|
|
47
|
+
- Add `@metamask/utils` dependency ([#1370](https://github.com/MetaMask/core/pull/1370))
|
|
48
|
+
|
|
49
|
+
## [5.0.0]
|
|
50
|
+
### Fixed
|
|
51
|
+
- **BREAKING:** Add chain validation to `eth_signTypedData_v4` signature requests ([#1331](https://github.com/MetaMask/core/pull/1331))
|
|
52
|
+
|
|
53
|
+
## [4.0.0]
|
|
54
|
+
### Changed
|
|
55
|
+
- **BREAKING:** Change type of `securityProviderResponse` to `Record` ([#1214](https://github.com/MetaMask/core/pull/1214))
|
|
56
|
+
- **BREAKING:** Update to Node 16 ([#1262](https://github.com/MetaMask/core/pull/1262))
|
|
57
|
+
|
|
58
|
+
## [3.1.1]
|
|
59
|
+
### Fixed
|
|
60
|
+
- Ensure message updates get saved in state even when they aren't emitted right away ([#1245](https://github.com/MetaMask/core/pull/1245))
|
|
61
|
+
- The `updateMessage` method included in each message manager accepted an `emitUpdate` boolean argument that would enable to caller to prevent that update from updating the badge (which displays the count of pending confirmations). Unfortunately this option would also prevent the update from being saved in state.
|
|
62
|
+
- This method has been updated to ensure message updates are saved in state, even when the badge update event is suppressed
|
|
63
|
+
|
|
64
|
+
## [3.1.0]
|
|
65
|
+
### Added
|
|
66
|
+
- Add DecryptMessageManager ([#1149](https://github.com/MetaMask/core/pull/1149))
|
|
67
|
+
|
|
68
|
+
## [3.0.0]
|
|
69
|
+
### Added
|
|
70
|
+
- Add EncryptionPublicKeyManager ([#1144](https://github.com/MetaMask/core/pull/1144))
|
|
71
|
+
- Add security provider request to AbstractMessageManager ([#1145](https://github.com/MetaMask/core/pull/1145))
|
|
72
|
+
|
|
73
|
+
### Changed
|
|
74
|
+
- **BREAKING:** The methods `addMessage` and `addUnapprovedMessage` on each "message manager" controller are now asynchronous ([#1145](https://github.com/MetaMask/core/pull/1145))
|
|
75
|
+
|
|
76
|
+
## [2.1.0]
|
|
77
|
+
### Added
|
|
78
|
+
- Add SIWE detection support for PersonalMessageManager ([#1139](https://github.com/MetaMask/core/pull/1139))
|
|
79
|
+
|
|
80
|
+
## [2.0.0]
|
|
81
|
+
### Removed
|
|
82
|
+
- **BREAKING:** Remove `isomorphic-fetch` ([#1106](https://github.com/MetaMask/controllers/pull/1106))
|
|
83
|
+
- Consumers must now import `isomorphic-fetch` or another polyfill themselves if they are running in an environment without `fetch`
|
|
84
|
+
|
|
85
|
+
## [1.0.2]
|
|
86
|
+
### Changed
|
|
87
|
+
- Rename this repository to `core` ([#1031](https://github.com/MetaMask/controllers/pull/1031))
|
|
88
|
+
- Update `@metamask/controller-utils` package ([#1041](https://github.com/MetaMask/controllers/pull/1041))
|
|
89
|
+
|
|
90
|
+
## [1.0.1]
|
|
91
|
+
### Changed
|
|
92
|
+
- Relax dependencies on `@metamask/base-controller` and `@metamask/controller-utils` (use `^` instead of `~`) ([#998](https://github.com/MetaMask/core/pull/998))
|
|
93
|
+
|
|
94
|
+
## [1.0.0]
|
|
95
|
+
### Added
|
|
96
|
+
- Initial release
|
|
97
|
+
- As a result of converting our shared controllers repo into a monorepo ([#831](https://github.com/MetaMask/core/pull/831)), we've created this package from select parts of [`@metamask/controllers` v33.0.0](https://github.com/MetaMask/core/tree/v33.0.0), namely:
|
|
98
|
+
- Everything in `src/message-manager`
|
|
99
|
+
- Message manager-related functions in `src/util.ts` and accompanying tests
|
|
100
|
+
|
|
101
|
+
All changes listed after this point were applied to this package following the monorepo conversion.
|
|
102
|
+
|
|
103
|
+
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/message-manager@7.3.0...HEAD
|
|
104
|
+
[7.3.0]: https://github.com/MetaMask/core/compare/@metamask/message-manager@7.2.0...@metamask/message-manager@7.3.0
|
|
105
|
+
[7.2.0]: https://github.com/MetaMask/core/compare/@metamask/message-manager@7.1.0...@metamask/message-manager@7.2.0
|
|
106
|
+
[7.1.0]: https://github.com/MetaMask/core/compare/@metamask/message-manager@7.0.2...@metamask/message-manager@7.1.0
|
|
107
|
+
[7.0.2]: https://github.com/MetaMask/core/compare/@metamask/message-manager@7.0.1...@metamask/message-manager@7.0.2
|
|
108
|
+
[7.0.1]: https://github.com/MetaMask/core/compare/@metamask/message-manager@7.0.0...@metamask/message-manager@7.0.1
|
|
109
|
+
[7.0.0]: https://github.com/MetaMask/core/compare/@metamask/message-manager@6.0.0...@metamask/message-manager@7.0.0
|
|
110
|
+
[6.0.0]: https://github.com/MetaMask/core/compare/@metamask/message-manager@5.0.0...@metamask/message-manager@6.0.0
|
|
111
|
+
[5.0.0]: https://github.com/MetaMask/core/compare/@metamask/message-manager@4.0.0...@metamask/message-manager@5.0.0
|
|
112
|
+
[4.0.0]: https://github.com/MetaMask/core/compare/@metamask/message-manager@3.1.1...@metamask/message-manager@4.0.0
|
|
113
|
+
[3.1.1]: https://github.com/MetaMask/core/compare/@metamask/message-manager@3.1.0...@metamask/message-manager@3.1.1
|
|
114
|
+
[3.1.0]: https://github.com/MetaMask/core/compare/@metamask/message-manager@3.0.0...@metamask/message-manager@3.1.0
|
|
115
|
+
[3.0.0]: https://github.com/MetaMask/core/compare/@metamask/message-manager@2.1.0...@metamask/message-manager@3.0.0
|
|
116
|
+
[2.1.0]: https://github.com/MetaMask/core/compare/@metamask/message-manager@2.0.0...@metamask/message-manager@2.1.0
|
|
117
|
+
[2.0.0]: https://github.com/MetaMask/core/compare/@metamask/message-manager@1.0.2...@metamask/message-manager@2.0.0
|
|
118
|
+
[1.0.2]: https://github.com/MetaMask/core/compare/@metamask/message-manager@1.0.1...@metamask/message-manager@1.0.2
|
|
119
|
+
[1.0.1]: https://github.com/MetaMask/core/compare/@metamask/message-manager@1.0.0...@metamask/message-manager@1.0.1
|
|
120
|
+
[1.0.0]: https://github.com/MetaMask/core/releases/tag/@metamask/message-manager@1.0.0
|
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018 MetaMask
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
package/README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# `@metamask/message-manager`
|
|
2
|
+
|
|
3
|
+
Stores and manages interactions with signing requests.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
`yarn add @metamask/message-manager`
|
|
8
|
+
|
|
9
|
+
or
|
|
10
|
+
|
|
11
|
+
`npm install @metamask/message-manager`
|
|
12
|
+
|
|
13
|
+
## Contributing
|
|
14
|
+
|
|
15
|
+
This package is part of a monorepo. Instructions for contributing can be found in the [monorepo README](https://github.com/MetaMask/core#readme).
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { BaseConfig, BaseState } from '@metamask/base-controller';
|
|
3
|
+
import { BaseController } from '@metamask/base-controller';
|
|
4
|
+
import type { Hex, Json } from '@metamask/utils';
|
|
5
|
+
import { EventEmitter } from 'events';
|
|
6
|
+
/**
|
|
7
|
+
* @type OriginalRequest
|
|
8
|
+
*
|
|
9
|
+
* Represents the original request object for adding a message.
|
|
10
|
+
* @property origin? - Is it is specified, represents the origin
|
|
11
|
+
*/
|
|
12
|
+
export interface OriginalRequest {
|
|
13
|
+
origin?: string;
|
|
14
|
+
securityAlertResponse?: Record<string, Json>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* @type Message
|
|
18
|
+
*
|
|
19
|
+
* Represents and contains data about a signing type signature request.
|
|
20
|
+
* @property id - An id to track and identify the message object
|
|
21
|
+
* @property type - The json-prc signing method for which a signature request has been made.
|
|
22
|
+
* A 'Message' which always has a signing type
|
|
23
|
+
* @property rawSig - Raw data of the signature request
|
|
24
|
+
* @property securityProviderResponse - Response from a security provider, whether it is malicious or not
|
|
25
|
+
* @property metadata - Additional data for the message, for example external identifiers
|
|
26
|
+
*/
|
|
27
|
+
export interface AbstractMessage {
|
|
28
|
+
id: string;
|
|
29
|
+
time: number;
|
|
30
|
+
status: string;
|
|
31
|
+
type: string;
|
|
32
|
+
rawSig?: string;
|
|
33
|
+
securityProviderResponse?: Record<string, Json>;
|
|
34
|
+
securityAlertResponse?: Record<string, Json>;
|
|
35
|
+
metadata?: Json;
|
|
36
|
+
error?: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* @type MessageParams
|
|
40
|
+
*
|
|
41
|
+
* Represents the parameters to pass to the signing method once the signature request is approved.
|
|
42
|
+
* @property from - Address from which the message is processed
|
|
43
|
+
* @property origin? - Added for request origin identification
|
|
44
|
+
* @property deferSetAsSigned? - Whether to defer setting the message as signed immediately after the keyring is told to sign it
|
|
45
|
+
*/
|
|
46
|
+
export interface AbstractMessageParams {
|
|
47
|
+
from: string;
|
|
48
|
+
origin?: string;
|
|
49
|
+
deferSetAsSigned?: boolean;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* @type MessageParamsMetamask
|
|
53
|
+
*
|
|
54
|
+
* Represents the parameters to pass to the signing method once the signature request is approved
|
|
55
|
+
* plus data added by MetaMask.
|
|
56
|
+
* @property metamaskId - Added for tracking and identification within MetaMask
|
|
57
|
+
* @property from - Address from which the message is processed
|
|
58
|
+
* @property origin? - Added for request origin identification
|
|
59
|
+
*/
|
|
60
|
+
export interface AbstractMessageParamsMetamask extends AbstractMessageParams {
|
|
61
|
+
metamaskId?: string;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* @type MessageManagerState
|
|
65
|
+
*
|
|
66
|
+
* Message Manager state
|
|
67
|
+
* @property unapprovedMessages - A collection of all Messages in the 'unapproved' state
|
|
68
|
+
* @property unapprovedMessagesCount - The count of all Messages in this.unapprovedMessages
|
|
69
|
+
*/
|
|
70
|
+
export interface MessageManagerState<M extends AbstractMessage> extends BaseState {
|
|
71
|
+
unapprovedMessages: {
|
|
72
|
+
[key: string]: M;
|
|
73
|
+
};
|
|
74
|
+
unapprovedMessagesCount: number;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* A function for verifying a message, whether it is malicious or not
|
|
78
|
+
*/
|
|
79
|
+
export declare type SecurityProviderRequest = (requestData: AbstractMessage, messageType: string) => Promise<Json>;
|
|
80
|
+
declare type getCurrentChainId = () => Hex;
|
|
81
|
+
/**
|
|
82
|
+
* Controller in charge of managing - storing, adding, removing, updating - Messages.
|
|
83
|
+
*/
|
|
84
|
+
export declare abstract class AbstractMessageManager<M extends AbstractMessage, P extends AbstractMessageParams, PM extends AbstractMessageParamsMetamask> extends BaseController<BaseConfig, MessageManagerState<M>> {
|
|
85
|
+
protected messages: M[];
|
|
86
|
+
protected getCurrentChainId: getCurrentChainId | undefined;
|
|
87
|
+
private readonly securityProviderRequest;
|
|
88
|
+
private readonly additionalFinishStatuses;
|
|
89
|
+
/**
|
|
90
|
+
* Saves the unapproved messages, and their count to state.
|
|
91
|
+
*
|
|
92
|
+
* @param emitUpdateBadge - Whether to emit the updateBadge event.
|
|
93
|
+
*/
|
|
94
|
+
protected saveMessageList(emitUpdateBadge?: boolean): void;
|
|
95
|
+
/**
|
|
96
|
+
* Updates the status of a Message in this.messages.
|
|
97
|
+
*
|
|
98
|
+
* @param messageId - The id of the Message to update.
|
|
99
|
+
* @param status - The new status of the Message.
|
|
100
|
+
*/
|
|
101
|
+
protected setMessageStatus(messageId: string, status: string): void;
|
|
102
|
+
/**
|
|
103
|
+
* Sets a Message in this.messages to the passed Message if the ids are equal.
|
|
104
|
+
* Then saves the unapprovedMessage list to storage.
|
|
105
|
+
*
|
|
106
|
+
* @param message - A Message that will replace an existing Message (with the id) in this.messages.
|
|
107
|
+
* @param emitUpdateBadge - Whether to emit the updateBadge event.
|
|
108
|
+
*/
|
|
109
|
+
protected updateMessage(message: M, emitUpdateBadge?: boolean): void;
|
|
110
|
+
/**
|
|
111
|
+
* Verifies a message is malicious or not by checking it against a security provider.
|
|
112
|
+
*
|
|
113
|
+
* @param message - The message to verify.
|
|
114
|
+
* @returns A promise that resolves to a secured message with additional security provider response data.
|
|
115
|
+
*/
|
|
116
|
+
private securityCheck;
|
|
117
|
+
/**
|
|
118
|
+
* EventEmitter instance used to listen to specific message events
|
|
119
|
+
*/
|
|
120
|
+
hub: EventEmitter;
|
|
121
|
+
/**
|
|
122
|
+
* Name of this controller used during composition
|
|
123
|
+
*/
|
|
124
|
+
name: string;
|
|
125
|
+
/**
|
|
126
|
+
* Creates an AbstractMessageManager instance.
|
|
127
|
+
*
|
|
128
|
+
* @param config - Initial options used to configure this controller.
|
|
129
|
+
* @param state - Initial state to set on this controller.
|
|
130
|
+
* @param securityProviderRequest - A function for verifying a message, whether it is malicious or not.
|
|
131
|
+
* @param additionalFinishStatuses - Optional list of statuses that are accepted to emit a finished event.
|
|
132
|
+
* @param getCurrentChainId - Optional function to get the current chainId.
|
|
133
|
+
*/
|
|
134
|
+
constructor(config?: Partial<BaseConfig>, state?: Partial<MessageManagerState<M>>, securityProviderRequest?: SecurityProviderRequest, additionalFinishStatuses?: string[], getCurrentChainId?: getCurrentChainId);
|
|
135
|
+
/**
|
|
136
|
+
* A getter for the number of 'unapproved' Messages in this.messages.
|
|
137
|
+
*
|
|
138
|
+
* @returns The number of 'unapproved' Messages in this.messages.
|
|
139
|
+
*/
|
|
140
|
+
getUnapprovedMessagesCount(): number;
|
|
141
|
+
/**
|
|
142
|
+
* A getter for the 'unapproved' Messages in state messages.
|
|
143
|
+
*
|
|
144
|
+
* @returns An index of Message ids to Messages, for all 'unapproved' Messages in this.messages.
|
|
145
|
+
*/
|
|
146
|
+
getUnapprovedMessages(): {
|
|
147
|
+
[key: string]: M;
|
|
148
|
+
};
|
|
149
|
+
/**
|
|
150
|
+
* Adds a passed Message to this.messages, and calls this.saveMessageList() to save
|
|
151
|
+
* the unapproved Messages from that list to this.messages.
|
|
152
|
+
*
|
|
153
|
+
* @param message - The Message to add to this.messages.
|
|
154
|
+
*/
|
|
155
|
+
addMessage(message: M): Promise<void>;
|
|
156
|
+
/**
|
|
157
|
+
* Returns a specified Message.
|
|
158
|
+
*
|
|
159
|
+
* @param messageId - The id of the Message to get.
|
|
160
|
+
* @returns The Message with the id that matches the passed messageId, or undefined
|
|
161
|
+
* if no Message has that id.
|
|
162
|
+
*/
|
|
163
|
+
getMessage(messageId: string): M | undefined;
|
|
164
|
+
/**
|
|
165
|
+
* Returns all the messages.
|
|
166
|
+
*
|
|
167
|
+
* @returns An array of messages.
|
|
168
|
+
*/
|
|
169
|
+
getAllMessages(): M[];
|
|
170
|
+
/**
|
|
171
|
+
* Approves a Message. Sets the message status via a call to this.setMessageStatusApproved,
|
|
172
|
+
* and returns a promise with any the message params modified for proper signing.
|
|
173
|
+
*
|
|
174
|
+
* @param messageParams - The messageParams to be used when signing method is called,
|
|
175
|
+
* plus data added by MetaMask.
|
|
176
|
+
* @returns Promise resolving to the messageParams with the metamaskId property removed.
|
|
177
|
+
*/
|
|
178
|
+
approveMessage(messageParams: PM): Promise<P>;
|
|
179
|
+
/**
|
|
180
|
+
* Sets a Message status to 'approved' via a call to this.setMessageStatus.
|
|
181
|
+
*
|
|
182
|
+
* @param messageId - The id of the Message to approve.
|
|
183
|
+
*/
|
|
184
|
+
setMessageStatusApproved(messageId: string): void;
|
|
185
|
+
/**
|
|
186
|
+
* Sets message status to inProgress in order to allow users to use extension
|
|
187
|
+
* while waiting for a custodian signature.
|
|
188
|
+
*
|
|
189
|
+
* @param messageId - The id of the message to set to inProgress
|
|
190
|
+
*/
|
|
191
|
+
setMessageStatusInProgress(messageId: string): void;
|
|
192
|
+
/**
|
|
193
|
+
* Sets a Message status to 'signed' via a call to this.setMessageStatus and updates
|
|
194
|
+
* that Message in this.messages by adding the raw signature data of the signature
|
|
195
|
+
* request to the Message.
|
|
196
|
+
*
|
|
197
|
+
* @param messageId - The id of the Message to sign.
|
|
198
|
+
* @param rawSig - The raw data of the signature request.
|
|
199
|
+
*/
|
|
200
|
+
setMessageStatusSigned(messageId: string, rawSig: string): void;
|
|
201
|
+
/**
|
|
202
|
+
* Sets the message via a call to this.setResult and updates status of the message.
|
|
203
|
+
*
|
|
204
|
+
* @param messageId - The id of the Message to sign.
|
|
205
|
+
* @param rawSig - The data to update rawSig in the message.
|
|
206
|
+
* @param status - The new message status.
|
|
207
|
+
*/
|
|
208
|
+
setMessageStatusAndResult(messageId: string, rawSig: string, status: string): void;
|
|
209
|
+
/**
|
|
210
|
+
* Sets the message result.
|
|
211
|
+
*
|
|
212
|
+
* @param messageId - The id of the Message to sign.
|
|
213
|
+
* @param result - The data to update result in the message.
|
|
214
|
+
*/
|
|
215
|
+
setResult(messageId: string, result: string): void;
|
|
216
|
+
/**
|
|
217
|
+
* Sets the messsage metadata
|
|
218
|
+
*
|
|
219
|
+
* @param messageId - The id of the Message to update
|
|
220
|
+
* @param metadata - The data with which to replace the metadata property in the message
|
|
221
|
+
*/
|
|
222
|
+
setMetadata(messageId: string, metadata: Json): void;
|
|
223
|
+
/**
|
|
224
|
+
* Removes the metamaskId property from passed messageParams and returns a promise which
|
|
225
|
+
* resolves the updated messageParams
|
|
226
|
+
*
|
|
227
|
+
* @param messageParams - The messageParams to modify
|
|
228
|
+
* @returns Promise resolving to the messageParams with the metamaskId property removed
|
|
229
|
+
*/
|
|
230
|
+
abstract prepMessageForSigning(messageParams: PM): Promise<P>;
|
|
231
|
+
/**
|
|
232
|
+
* Creates a new Message with an 'unapproved' status using the passed messageParams.
|
|
233
|
+
* this.addMessage is called to add the new Message to this.messages, and to save the
|
|
234
|
+
* unapproved Messages.
|
|
235
|
+
*
|
|
236
|
+
* @param messageParams - Message parameters for the message to add
|
|
237
|
+
* @param req - The original request object possibly containing the origin.
|
|
238
|
+
* @param version? - The version of the JSON RPC protocol the request is using.
|
|
239
|
+
* @returns The id of the newly created message.
|
|
240
|
+
*/
|
|
241
|
+
abstract addUnapprovedMessage(messageParams: PM, request: OriginalRequest, version?: string): Promise<string>;
|
|
242
|
+
/**
|
|
243
|
+
* Sets a Message status to 'rejected' via a call to this.setMessageStatus.
|
|
244
|
+
*
|
|
245
|
+
* @param messageId - The id of the Message to reject.
|
|
246
|
+
*/
|
|
247
|
+
rejectMessage(messageId: string): void;
|
|
248
|
+
/**
|
|
249
|
+
* Creates a promise which will resolve or reject when the message process is finished.
|
|
250
|
+
*
|
|
251
|
+
* @param messageParamsWithId - The params for the personal_sign call to be made after the message is approved.
|
|
252
|
+
* @param messageName - The name of the message
|
|
253
|
+
* @returns Promise resolving to the raw data of the signature request.
|
|
254
|
+
*/
|
|
255
|
+
waitForFinishStatus(messageParamsWithId: AbstractMessageParamsMetamask, messageName: string): Promise<string>;
|
|
256
|
+
}
|
|
257
|
+
export default AbstractMessageManager;
|
|
258
|
+
//# sourceMappingURL=AbstractMessageManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AbstractMessageManager.d.ts","sourceRoot":"","sources":["../src/AbstractMessageManager.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,qBAAqB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;CAC9C;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,wBAAwB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAChD,qBAAqB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC7C,QAAQ,CAAC,EAAE,IAAI,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,qBAAqB;IACpC,IAAI,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