@metamask-previews/eth-snap-keyring 4.3.2-672cc7b
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 +344 -0
- package/README.md +71 -0
- package/dist/CaseInsensitiveMap.d.ts +62 -0
- package/dist/CaseInsensitiveMap.js +82 -0
- package/dist/CaseInsensitiveMap.js.map +1 -0
- package/dist/DeferredPromise.d.ts +15 -0
- package/dist/DeferredPromise.js +30 -0
- package/dist/DeferredPromise.js.map +1 -0
- package/dist/SnapIdMap.d.ts +202 -0
- package/dist/SnapIdMap.js +242 -0
- package/dist/SnapIdMap.js.map +1 -0
- package/dist/SnapKeyring.d.ts +182 -0
- package/dist/SnapKeyring.js +599 -0
- package/dist/SnapKeyring.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/logger.d.ts +4 -0
- package/dist/logger.js +8 -0
- package/dist/logger.js.map +1 -0
- package/dist/types.d.ts +12 -0
- package/dist/types.js +10 -0
- package/dist/types.js.map +1 -0
- package/dist/util.d.ts +52 -0
- package/dist/util.js +76 -0
- package/dist/util.js.map +1 -0
- package/package.json +72 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [4.3.2]
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- Bump `@metamask/eth-sig-util` from `^7.0.1` to `^7.0.3` ([#311](https://github.com/MetaMask/eth-snap-keyring/pull/311))
|
|
15
|
+
- Bump `@metamask/keyring-api` from `^8.0.0` to `^8.0.1` ([#311](https://github.com/MetaMask/eth-snap-keyring/pull/311))
|
|
16
|
+
- Bump `@metamask/snaps-controllers` from `^8.1.1` to `^9.3.0` ([#311](https://github.com/MetaMask/eth-snap-keyring/pull/311), [#363](https://github.com/MetaMask/eth-snap-keyring/pull/363))
|
|
17
|
+
- Bump `@metamask/snaps-sdk` from `^4.2.0` to `^6.1.0` ([#311](https://github.com/MetaMask/eth-snap-keyring/pull/311), [#363](https://github.com/MetaMask/eth-snap-keyring/pull/363))
|
|
18
|
+
- Bump `@metamask/snaps-utils` from `^7.4.0` to `^7.8.0` ([#311](https://github.com/MetaMask/eth-snap-keyring/pull/311), [#363](https://github.com/MetaMask/eth-snap-keyring/pull/363))
|
|
19
|
+
- Bump `@metamask/utils` from `^8.4.0` to `^9.1.0` ([#311](https://github.com/MetaMask/eth-snap-keyring/pull/311))
|
|
20
|
+
- Set tsconfig options `module`, `moduleResolution` to `Node16` ([#311](https://github.com/MetaMask/eth-snap-keyring/pull/311))
|
|
21
|
+
|
|
22
|
+
### Fixed
|
|
23
|
+
|
|
24
|
+
- Replace `superstruct` with ESM-compatible `@metamask/superstruct` `^3.1.0` ([#311](https://github.com/MetaMask/eth-snap-keyring/pull/311))
|
|
25
|
+
- This fixes the issue of this package being unusable by any TypeScript project that uses `Node16` or `NodeNext` as its `moduleResolution` option.
|
|
26
|
+
|
|
27
|
+
## [4.3.1]
|
|
28
|
+
|
|
29
|
+
### Changed
|
|
30
|
+
|
|
31
|
+
- Bump @metamask/keyring-api from 6.3.1 to 8.0.0 ([#331](https://github.com/MetaMask/eth-snap-keyring/pull/331)).
|
|
32
|
+
|
|
33
|
+
## [4.3.0]
|
|
34
|
+
|
|
35
|
+
### Added
|
|
36
|
+
|
|
37
|
+
- Export `KeyringSnapControllerClient` ([#328](https://github.com/MetaMask/eth-snap-keyring/pull/328)).
|
|
38
|
+
|
|
39
|
+
### Changed
|
|
40
|
+
|
|
41
|
+
- Bump @metamask/snaps-utils from 7.4.1 to 7.5.0 ([#326](https://github.com/MetaMask/eth-snap-keyring/pull/326)).
|
|
42
|
+
- Bump @metamask/snaps-controllers from 8.3.1 to 8.4.0 ([#325](https://github.com/MetaMask/eth-snap-keyring/pull/325)).
|
|
43
|
+
- Bump @metamask/snaps-sdk from 4.4.1 to 4.4.2 ([#327](https://github.com/MetaMask/eth-snap-keyring/pull/327)).
|
|
44
|
+
- Bump @metamask/rpc-errors from 6.2.1 to 6.3.0 ([#322](https://github.com/MetaMask/eth-snap-keyring/pull/322)).
|
|
45
|
+
- Bump @metamask/snaps-controllers from 8.2.0 to 8.3.1 ([#321](https://github.com/MetaMask/eth-snap-keyring/pull/321)).
|
|
46
|
+
- Bump @metamask/snaps-sdk from 4.3.0 to 4.4.1 ([#314](https://github.com/MetaMask/eth-snap-keyring/pull/314)).
|
|
47
|
+
- Bump @metamask/permission-controller from 9.1.0 to 9.1.1 ([#316](https://github.com/MetaMask/eth-snap-keyring/pull/316)).
|
|
48
|
+
- Bump @metamask/snaps-utils from 7.4.0 to 7.4.1 ([#319](https://github.com/MetaMask/eth-snap-keyring/pull/319)).
|
|
49
|
+
- Bump @metamask/keyring-api from 6.3.1 to 6.4.0 ([#315](https://github.com/MetaMask/eth-snap-keyring/pull/315)).
|
|
50
|
+
- Bump @metamask/json-rpc-middleware-stream from 7.0.1 to 7.0.2 ([#317](https://github.com/MetaMask/eth-snap-keyring/pull/317)).
|
|
51
|
+
- Bump @metamask/phishing-controller from 9.0.3 to 9.0.4 ([#318](https://github.com/MetaMask/eth-snap-keyring/pull/318)).
|
|
52
|
+
- Bump @metamask/snaps-rpc-methods from 9.1.0 to 9.1.2 ([#320](https://github.com/MetaMask/eth-snap-keyring/pull/320)).
|
|
53
|
+
- Bump @lavamoat/allow-scripts@^2.3.1->^3.0.4 ([#296](https://github.com/MetaMask/eth-snap-keyring/pull/296)).
|
|
54
|
+
- Bump @metamask/key-tree from 9.1.0 to 9.1.1 ([#298](https://github.com/MetaMask/eth-snap-keyring/pull/298)).
|
|
55
|
+
- Bump @metamask/phishing-controller from 9.0.2 to 9.0.3 ([#302](https://github.com/MetaMask/eth-snap-keyring/pull/302)).
|
|
56
|
+
- Bump @metamask/json-rpc-engine from 8.0.1 to 8.0.2 ([#291](https://github.com/MetaMask/eth-snap-keyring/pull/291)).
|
|
57
|
+
- Bump @metamask/snaps-controllers from 8.1.1 to 8.2.0 ([#307](https://github.com/MetaMask/eth-snap-keyring/pull/307)).
|
|
58
|
+
|
|
59
|
+
## [4.2.1]
|
|
60
|
+
|
|
61
|
+
### Changed
|
|
62
|
+
|
|
63
|
+
- Fixed 4337 methods enum ([#312](https://github.com/MetaMask/eth-snap-keyring/pull/312))
|
|
64
|
+
- Bump @metamask/post-message-stream from 8.0.0 to 8.1.0 ([#297](https://github.com/MetaMask/eth-snap-keyring/pull/297))
|
|
65
|
+
- Bump @metamask/permission-controller from 9.0.2 to 9.1.0 ([#306](https://github.com/MetaMask/eth-snap-keyring/pull/306))
|
|
66
|
+
- Bump @metamask/snaps-sdk from 4.2.0 to 4.3.0 ([#308](https://github.com/MetaMask/eth-snap-keyring/pull/308))
|
|
67
|
+
|
|
68
|
+
## [4.2.0]
|
|
69
|
+
|
|
70
|
+
### Added
|
|
71
|
+
|
|
72
|
+
- Add `accountNameSuggestion` and `displayConfirmation` options handling for `"notify:accountCreated"` ([#300](https://github.com/MetaMask/eth-snap-keyring/pull/300))
|
|
73
|
+
- Bump @metamask/keyring-api from 6.1.1 to 6.2.1 ([#304](https://github.com/MetaMask/eth-snap-keyring/pull/304))
|
|
74
|
+
|
|
75
|
+
## [4.1.1]
|
|
76
|
+
|
|
77
|
+
### Changed
|
|
78
|
+
|
|
79
|
+
- Bump @metamask/snaps-\* and @metamask/keyring-api ([#294](https://github.com/MetaMask/eth-snap-keyring/pull/294))
|
|
80
|
+
- Bump @metamask/key-tree from 9.0.0 to 9.1.0 ([#293](https://github.com/MetaMask/eth-snap-keyring/pull/293))
|
|
81
|
+
|
|
82
|
+
## [4.1.0]
|
|
83
|
+
|
|
84
|
+
### Changed
|
|
85
|
+
|
|
86
|
+
- Bump @metamask/keyring-api to version 6.1.0 and introduce btc account types ([#285](https://github.com/MetaMask/eth-snap-keyring/pull/285))
|
|
87
|
+
- Bump @metamask/phishing-controller from 9.0.1 to 9.0.2 ([#279](https://github.com/MetaMask/eth-snap-keyring/pull/279))
|
|
88
|
+
- Bump @metamask/base-controller from 5.0.1 to 5.0.2 ([#280](https://github.com/MetaMask/eth-snap-keyring/pull/280))
|
|
89
|
+
- Bump @metamask/eth-sig-util from 7.0.1 to 7.0.2 ([#281](https://github.com/MetaMask/eth-snap-keyring/pull/281))
|
|
90
|
+
- Bump @metamask/approval-controller from 6.0.1 to 6.0.2 ([#282](https://github.com/MetaMask/eth-snap-keyring/pull/282))
|
|
91
|
+
- Bump @metamask/providers from 16.0.0 to 16.1.0 ([#283](https://github.com/MetaMask/eth-snap-keyring/pull/283))
|
|
92
|
+
- Bump @metamask/snaps-controllers from 7.0.1 to 8.0.0 ([#278](https://github.com/MetaMask/eth-snap-keyring/pull/278))
|
|
93
|
+
- Bump @metamask/snaps-utils from 7.1.0 to 7.2.0 ([#277](https://github.com/MetaMask/eth-snap-keyring/pull/277))
|
|
94
|
+
|
|
95
|
+
## [4.0.0]
|
|
96
|
+
|
|
97
|
+
### Changed
|
|
98
|
+
|
|
99
|
+
- **BREAKING**: Bump @metamask/keyring-api to version 6.0.0 ([#275](https://github.com/MetaMask/eth-snap-keyring/pull/275))
|
|
100
|
+
- Bump @metamask/snaps-controllers from 6.0.3 to 7.0.1 and @metamask/snaps-sdk 3.1.1 to 4.0.1 ([#272](https://github.com/MetaMask/eth-snap-keyring/pull/272))
|
|
101
|
+
- Bump @metamask/snaps-utils from 7.0.4 to 7.1.0 ([#268](https://github.com/MetaMask/eth-snap-keyring/pull/268))
|
|
102
|
+
- Bump @metamask/controller-utils from 9.0.2 to 9.1.0 ([#270](https://github.com/MetaMask/eth-snap-keyring/pull/270))
|
|
103
|
+
- Bump @metamask/snaps-controllers from 6.0.3 to 6.0.4 ([#266](https://github.com/MetaMask/eth-snap-keyring/pull/266))
|
|
104
|
+
- Bump @metamask/snaps-registry from 3.0.1 to 3.1.0 ([#265](https://github.com/MetaMask/eth-snap-keyring/pull/265))
|
|
105
|
+
- Bump @metamask/snaps-rpc-methods from 7.0.1 to 7.0.2 ([#264](https://github.com/MetaMask/eth-snap-keyring/pull/264))
|
|
106
|
+
- Bump @metamask/snaps-utils from 7.0.3 to 7.0.4 ([#263](https://github.com/MetaMask/eth-snap-keyring/pull/263))
|
|
107
|
+
- Bump @metamask/snaps-sdk from 3.1.1 to 3.2.0 ([#262](https://github.com/MetaMask/eth-snap-keyring/pull/262))
|
|
108
|
+
|
|
109
|
+
## [3.0.0]
|
|
110
|
+
|
|
111
|
+
### Added
|
|
112
|
+
|
|
113
|
+
- Add logger and now log Snap requests ([#254](https://github.com/MetaMask/eth-snap-keyring/pull/254))
|
|
114
|
+
|
|
115
|
+
### Changed
|
|
116
|
+
|
|
117
|
+
- **BREAKING**: Add KeyringExecutionContext to user ops methods ([#253](https://github.com/MetaMask/eth-snap-keyring/pull/253))
|
|
118
|
+
- Bump @metamask/utils from 8.3.0 to 8.4.0
|
|
119
|
+
([#260](https://github.com/MetaMask/eth-snap-keyring/pull/260))
|
|
120
|
+
([#256](https://github.com/MetaMask/eth-snap-keyring/pull/256))
|
|
121
|
+
- Bump @metamask/keyring-api from 5.0.0 to 5.1.0 ([#259](https://github.com/MetaMask/eth-snap-keyring/pull/259))
|
|
122
|
+
- Bump @metamask/keyring-api from 4.0.2 to 5.0.0 ([#255](https://github.com/MetaMask/eth-snap-keyring/pull/255))
|
|
123
|
+
|
|
124
|
+
## [2.2.2]
|
|
125
|
+
|
|
126
|
+
### Changed
|
|
127
|
+
|
|
128
|
+
- Bump @metamask/safe-event-emitter from 3.1.0 to 3.1.1 ([#251](https://github.com/MetaMask/eth-snap-keyring/pull/251))
|
|
129
|
+
- Bump dependencies ([#246](https://github.com/MetaMask/eth-snap-keyring/pull/246))
|
|
130
|
+
- Bump @metamask/safe-event-emitter from 3.0.0 to 3.1.0 ([#245](https://github.com/MetaMask/eth-snap-keyring/pull/245))
|
|
131
|
+
- Fix enforcing responses of `prepareUserOperation` and `patchUserOperation` to be synchronous ([#243](https://github.com/MetaMask/eth-snap-keyring/pull/243))
|
|
132
|
+
- Bump @metamask/snaps-registry from 3.0.0 to 3.0.1 ([#244](https://github.com/MetaMask/eth-snap-keyring/pull/244))
|
|
133
|
+
|
|
134
|
+
## [2.2.1]
|
|
135
|
+
|
|
136
|
+
### Changed
|
|
137
|
+
|
|
138
|
+
- Bump @metamask dependencies ([#236](https://github.com/MetaMask/eth-snap-keyring/pull/236))
|
|
139
|
+
- Extract logic in 'submitRequest' ([#232](https://github.com/MetaMask/eth-snap-keyring/pull/232))
|
|
140
|
+
- Bump @metamask/controller-utils from 8.0.3 to 8.0.4 ([#233](https://github.com/MetaMask/eth-snap-keyring/pull/233))
|
|
141
|
+
- Bump @metamask/json-rpc-engine from 7.3.2 to 7.3.3 ([#234](https://github.com/MetaMask/eth-snap-keyring/pull/234))
|
|
142
|
+
- Bump @metamask/approval-controller from 5.1.2 to 5.1.3 ([#235](https://github.com/MetaMask/eth-snap-keyring/pull/235))
|
|
143
|
+
- Bump update Snap and dev dependencies ([#230](https://github.com/MetaMask/eth-snap-keyring/pull/230))
|
|
144
|
+
- Bump @metamask/rpc-errors from 6.2.0 to 6.2.1 ([#223](https://github.com/MetaMask/eth-snap-keyring/pull/223))
|
|
145
|
+
- Bump @metamask/snaps-utils from 6.1.0 to 7.0.0 ([#224](https://github.com/MetaMask/eth-snap-keyring/pull/224))
|
|
146
|
+
- Bump @metamask/rpc-errors from 6.1.0 to 6.2.0 ([#219](https://github.com/MetaMask/eth-snap-keyring/pull/219))
|
|
147
|
+
- Bump ip from 2.0.0 to 2.0.1 ([#218](https://github.com/MetaMask/eth-snap-keyring/pull/218))
|
|
148
|
+
|
|
149
|
+
### Fixed
|
|
150
|
+
|
|
151
|
+
- Add `chainId` to Keyring API requests (transaction/typed message) ([#231](https://github.com/MetaMask/eth-snap-keyring/pull/231))
|
|
152
|
+
- Enforce async request redirect URL is in the snaps 'allowedOrigins' ([#228](https://github.com/MetaMask/eth-snap-keyring/pull/228))
|
|
153
|
+
|
|
154
|
+
## [2.2.0]
|
|
155
|
+
|
|
156
|
+
### Changed
|
|
157
|
+
|
|
158
|
+
- Bump dependencies ([#220](https://github.com/MetaMask/eth-snap-keyring/pull/220))
|
|
159
|
+
- @metamask/snaps-controllers from ^4.1.0 to ^5.0.1
|
|
160
|
+
- @metamask/snaps-sdk from ^1.4.0 to ^2.1.0
|
|
161
|
+
- @metamask/snaps-utils from ^5.2.0 to ^6.1.0
|
|
162
|
+
- @metamask/utils from ^8.1.0 to ^8.3.0
|
|
163
|
+
- @metamask/keyring-api from ^2.0.0 to ^4.0.0
|
|
164
|
+
|
|
165
|
+
## [2.1.2]
|
|
166
|
+
|
|
167
|
+
### Fixed
|
|
168
|
+
|
|
169
|
+
- Fixed inconsistent signature signing ([#200](https://github.com/MetaMask/eth-snap-keyring/pull/200))
|
|
170
|
+
|
|
171
|
+
## [2.1.1]
|
|
172
|
+
|
|
173
|
+
### Fixed
|
|
174
|
+
|
|
175
|
+
- Reject unsupported account methods ([#190](https://github.com/MetaMask/eth-snap-keyring/pull/190))
|
|
176
|
+
|
|
177
|
+
## [2.1.0]
|
|
178
|
+
|
|
179
|
+
### Added
|
|
180
|
+
|
|
181
|
+
- Add methods to support ERC-4337 accounts ([#180](https://github.com/MetaMask/eth-snap-keyring/pull/180)).
|
|
182
|
+
|
|
183
|
+
### Changed
|
|
184
|
+
|
|
185
|
+
- Use a `snapId`-indexed map ([#172](https://github.com/MetaMask/eth-snap-keyring/pull/172)).
|
|
186
|
+
- Update CODEOWNERS and run CI on merge queues ([#165](https://github.com/MetaMask/eth-snap-keyring/pull/165)).
|
|
187
|
+
- Bump min Node version to 18.18 and use LTS for dev ([#183](https://github.com/MetaMask/eth-snap-keyring/pull/183)).
|
|
188
|
+
|
|
189
|
+
## [2.0.0]
|
|
190
|
+
|
|
191
|
+
### Changed
|
|
192
|
+
|
|
193
|
+
- **BREAKING**: Remove async from `listAccounts` and `getAccountByAddress` ([#148](https://github.com/MetaMask/eth-snap-keyring/pull/148)).
|
|
194
|
+
|
|
195
|
+
## [1.0.0]
|
|
196
|
+
|
|
197
|
+
### Changed
|
|
198
|
+
|
|
199
|
+
- Bump `@metamask/keyring-api` to 1.0.0 ([#145](https://github.com/MetaMask/eth-snap-keyring/pull/145)).
|
|
200
|
+
- Bump `semver` and `word-wrap` dependencies ([#144](https://github.com/MetaMask/eth-snap-keyring/pull/144)).
|
|
201
|
+
- Bump @metamask/rpc-errors from 6.0.0 to 6.1.0 ([#143](https://github.com/MetaMask/eth-snap-keyring/pull/143)).
|
|
202
|
+
|
|
203
|
+
## [1.0.0-rc.2]
|
|
204
|
+
|
|
205
|
+
### Added
|
|
206
|
+
|
|
207
|
+
- Add `redirectUser` callback ([#136](https://github.com/MetaMask/eth-snap-keyring/pull/136)).
|
|
208
|
+
|
|
209
|
+
## [1.0.0-rc.1]
|
|
210
|
+
|
|
211
|
+
### Added
|
|
212
|
+
|
|
213
|
+
- Add `getAccountByAddress` method ([#134](https://github.com/MetaMask/eth-snap-keyring/pull/134)).
|
|
214
|
+
|
|
215
|
+
### Changed
|
|
216
|
+
|
|
217
|
+
- Bump `word-wrap` and `semver` ([#140](https://github.com/MetaMask/eth-snap-keyring/pull/140)).
|
|
218
|
+
- Bump `@metamask/scure-bip39` from 2.1.0 to 2.1.1 ([#133](https://github.com/MetaMask/eth-snap-keyring/pull/133)).
|
|
219
|
+
- Bump `postcss` from 8.4.20 to 8.4.31 ([#137](https://github.com/MetaMask/eth-snap-keyring/pull/137)).
|
|
220
|
+
- Bump `@metamask` dependencies ([#139](https://github.com/MetaMask/eth-snap-keyring/pull/139)).
|
|
221
|
+
|
|
222
|
+
## [0.3.1]
|
|
223
|
+
|
|
224
|
+
### Added
|
|
225
|
+
|
|
226
|
+
- Add the `getAccountsBySnapId` method ([#122](https://github.com/MetaMask/eth-snap-keyring/pull/122)).
|
|
227
|
+
|
|
228
|
+
### Fixed
|
|
229
|
+
|
|
230
|
+
- Remove the `removeAccountsBySnapId` method ([#121](https://github.com/MetaMask/eth-snap-keyring/pull/121)).
|
|
231
|
+
- Call external function with lowercase address ([#120](https://github.com/MetaMask/eth-snap-keyring/pull/120)).
|
|
232
|
+
|
|
233
|
+
## [0.3.0]
|
|
234
|
+
|
|
235
|
+
### Changed
|
|
236
|
+
|
|
237
|
+
- Handle approval when adding/removing account with `handleUserInput` callback ([#99](https://github.com/MetaMask/eth-snap-keyring/pull/99)).
|
|
238
|
+
|
|
239
|
+
## [0.2.3]
|
|
240
|
+
|
|
241
|
+
### Added
|
|
242
|
+
|
|
243
|
+
- Add method to remove all accounts given a snap ID ([#116](https://github.com/MetaMask/eth-snap-keyring/pull/116)).
|
|
244
|
+
|
|
245
|
+
### Fixed
|
|
246
|
+
|
|
247
|
+
- Don't allow duplicate accounts to be added ([#115](https://github.com/MetaMask/eth-snap-keyring/pull/115)).
|
|
248
|
+
- Ignore event if account was already removed ([#101](https://github.com/MetaMask/eth-snap-keyring/pull/101)).
|
|
249
|
+
|
|
250
|
+
## [0.2.2]
|
|
251
|
+
|
|
252
|
+
### Changed
|
|
253
|
+
|
|
254
|
+
- Add `removeAccount` callback to constructor ([#96](https://github.com/MetaMask/eth-snap-keyring/pull/96)).
|
|
255
|
+
|
|
256
|
+
## [0.2.1]
|
|
257
|
+
|
|
258
|
+
### Changed
|
|
259
|
+
|
|
260
|
+
- Add `callbacks` argument to constructor ([#82](https://github.com/MetaMask/eth-snap-keyring/pull/82)).
|
|
261
|
+
- Increase minimum Node.js version to 16 (default to 18) ([#83](https://github.com/MetaMask/eth-snap-keyring/pull/83)).
|
|
262
|
+
- Migrate to the new `keyring-api` ([#78](https://github.com/MetaMask/eth-snap-keyring/pull/78)).
|
|
263
|
+
- Upgrade dependencies.
|
|
264
|
+
|
|
265
|
+
## [0.2.0]
|
|
266
|
+
|
|
267
|
+
### Changed
|
|
268
|
+
|
|
269
|
+
- Add account and snap metadata ([#75](https://github.com/MetaMask/eth-snap-keyring/pull/75)).
|
|
270
|
+
- Rename files to be more idiomatic ([#42](https://github.com/MetaMask/eth-snap-keyring/pull/42)).
|
|
271
|
+
- Move internal state from objects to maps ([#41](https://github.com/MetaMask/eth-snap-keyring/pull/41)).
|
|
272
|
+
|
|
273
|
+
### Fixed
|
|
274
|
+
|
|
275
|
+
- Remove promise if `submitRequest()` throws ([#43](https://github.com/MetaMask/eth-snap-keyring/pull/43)).
|
|
276
|
+
|
|
277
|
+
## [0.1.4]
|
|
278
|
+
|
|
279
|
+
### Changed
|
|
280
|
+
|
|
281
|
+
- **BREAKING**: Add `callbacks` that will be used to inject dependencies ([#79](https://github.com/MetaMask/eth-snap-keyring/pull/79), [MetaMask/snaps#1725](https://github.com/MetaMask/snaps/pull/1725), [MetaMask/metamask-extension#20786](https://github.com/MetaMask/metamask-extension/pull/20786)).
|
|
282
|
+
|
|
283
|
+
## [0.1.3]
|
|
284
|
+
|
|
285
|
+
### Fixed
|
|
286
|
+
|
|
287
|
+
- Remove account from maps before calling the snap ([#39](https://github.com/MetaMask/eth-snap-keyring/pull/39)).
|
|
288
|
+
|
|
289
|
+
## [0.1.2]
|
|
290
|
+
|
|
291
|
+
### Changed
|
|
292
|
+
|
|
293
|
+
- Remove unused `#listAccounts()` method ([#35](https://github.com/MetaMask/eth-snap-keyring/pull/35)).
|
|
294
|
+
|
|
295
|
+
### Fixed
|
|
296
|
+
|
|
297
|
+
- Sync all accounts on snap notificaiton ([#36](https://github.com/MetaMask/eth-snap-keyring/pull/36)).
|
|
298
|
+
- Don't sync accounts twice on deletion ([#32](https://github.com/MetaMask/eth-snap-keyring/pull/32)).
|
|
299
|
+
|
|
300
|
+
## [0.1.1]
|
|
301
|
+
|
|
302
|
+
### Changed
|
|
303
|
+
|
|
304
|
+
- Use objects in snap -> controller methods ([#28](https://github.com/MetaMask/eth-snap-keyring/pull/28)).
|
|
305
|
+
- Fix circular call when handling `'read'` requests ([#27](https://github.com/MetaMask/eth-snap-keyring/pull/27)).
|
|
306
|
+
- Remove `saveSnapKeyring` argument from `handleKeyringSnapMessage` ([#26](https://github.com/MetaMask/eth-snap-keyring/pull/26)).
|
|
307
|
+
|
|
308
|
+
## [0.1.0]
|
|
309
|
+
|
|
310
|
+
### Added
|
|
311
|
+
|
|
312
|
+
- Initial release.
|
|
313
|
+
|
|
314
|
+
[Unreleased]: https://github.com/MetaMask/accounts/compare/@metamask/eth-snap-keyring@4.3.2...HEAD
|
|
315
|
+
[4.3.2]: https://github.com/MetaMask/accounts/compare/@metamask/eth-snap-keyring@4.3.1...@metamask/eth-snap-keyring@4.3.2
|
|
316
|
+
[4.3.1]: https://github.com/MetaMask/accounts/compare/@metamask/eth-snap-keyring@4.3.0...@metamask/eth-snap-keyring@4.3.1
|
|
317
|
+
[4.3.0]: https://github.com/MetaMask/accounts/compare/@metamask/eth-snap-keyring@4.2.1...@metamask/eth-snap-keyring@4.3.0
|
|
318
|
+
[4.2.1]: https://github.com/MetaMask/accounts/compare/@metamask/eth-snap-keyring@4.2.0...@metamask/eth-snap-keyring@4.2.1
|
|
319
|
+
[4.2.0]: https://github.com/MetaMask/accounts/compare/@metamask/eth-snap-keyring@4.1.1...@metamask/eth-snap-keyring@4.2.0
|
|
320
|
+
[4.1.1]: https://github.com/MetaMask/accounts/compare/@metamask/eth-snap-keyring@4.1.0...@metamask/eth-snap-keyring@4.1.1
|
|
321
|
+
[4.1.0]: https://github.com/MetaMask/accounts/compare/@metamask/eth-snap-keyring@4.0.0...@metamask/eth-snap-keyring@4.1.0
|
|
322
|
+
[4.0.0]: https://github.com/MetaMask/accounts/compare/@metamask/eth-snap-keyring@3.0.0...@metamask/eth-snap-keyring@4.0.0
|
|
323
|
+
[3.0.0]: https://github.com/MetaMask/accounts/compare/@metamask/eth-snap-keyring@2.2.2...@metamask/eth-snap-keyring@3.0.0
|
|
324
|
+
[2.2.2]: https://github.com/MetaMask/accounts/compare/@metamask/eth-snap-keyring@2.2.1...@metamask/eth-snap-keyring@2.2.2
|
|
325
|
+
[2.2.1]: https://github.com/MetaMask/accounts/compare/@metamask/eth-snap-keyring@2.2.0...@metamask/eth-snap-keyring@2.2.1
|
|
326
|
+
[2.2.0]: https://github.com/MetaMask/accounts/compare/@metamask/eth-snap-keyring@2.1.2...@metamask/eth-snap-keyring@2.2.0
|
|
327
|
+
[2.1.2]: https://github.com/MetaMask/accounts/compare/@metamask/eth-snap-keyring@2.1.1...@metamask/eth-snap-keyring@2.1.2
|
|
328
|
+
[2.1.1]: https://github.com/MetaMask/accounts/compare/@metamask/eth-snap-keyring@2.1.0...@metamask/eth-snap-keyring@2.1.1
|
|
329
|
+
[2.1.0]: https://github.com/MetaMask/accounts/compare/@metamask/eth-snap-keyring@2.0.0...@metamask/eth-snap-keyring@2.1.0
|
|
330
|
+
[2.0.0]: https://github.com/MetaMask/accounts/compare/@metamask/eth-snap-keyring@1.0.0...@metamask/eth-snap-keyring@2.0.0
|
|
331
|
+
[1.0.0]: https://github.com/MetaMask/accounts/compare/@metamask/eth-snap-keyring@1.0.0-rc.2...@metamask/eth-snap-keyring@1.0.0
|
|
332
|
+
[1.0.0-rc.2]: https://github.com/MetaMask/accounts/compare/@metamask/eth-snap-keyring@1.0.0-rc.1...@metamask/eth-snap-keyring@1.0.0-rc.2
|
|
333
|
+
[1.0.0-rc.1]: https://github.com/MetaMask/accounts/compare/@metamask/eth-snap-keyring@0.3.1...@metamask/eth-snap-keyring@1.0.0-rc.1
|
|
334
|
+
[0.3.1]: https://github.com/MetaMask/accounts/compare/@metamask/eth-snap-keyring@0.3.0...@metamask/eth-snap-keyring@0.3.1
|
|
335
|
+
[0.3.0]: https://github.com/MetaMask/accounts/compare/@metamask/eth-snap-keyring@0.2.3...@metamask/eth-snap-keyring@0.3.0
|
|
336
|
+
[0.2.3]: https://github.com/MetaMask/accounts/compare/@metamask/eth-snap-keyring@0.2.2...@metamask/eth-snap-keyring@0.2.3
|
|
337
|
+
[0.2.2]: https://github.com/MetaMask/accounts/compare/@metamask/eth-snap-keyring@0.2.1...@metamask/eth-snap-keyring@0.2.2
|
|
338
|
+
[0.2.1]: https://github.com/MetaMask/accounts/compare/@metamask/eth-snap-keyring@0.2.0...@metamask/eth-snap-keyring@0.2.1
|
|
339
|
+
[0.2.0]: https://github.com/MetaMask/accounts/compare/@metamask/eth-snap-keyring@0.1.4...@metamask/eth-snap-keyring@0.2.0
|
|
340
|
+
[0.1.4]: https://github.com/MetaMask/accounts/compare/@metamask/eth-snap-keyring@0.1.3...@metamask/eth-snap-keyring@0.1.4
|
|
341
|
+
[0.1.3]: https://github.com/MetaMask/accounts/compare/@metamask/eth-snap-keyring@0.1.2...@metamask/eth-snap-keyring@0.1.3
|
|
342
|
+
[0.1.2]: https://github.com/MetaMask/accounts/compare/@metamask/eth-snap-keyring@0.1.1...@metamask/eth-snap-keyring@0.1.2
|
|
343
|
+
[0.1.1]: https://github.com/MetaMask/accounts/compare/@metamask/eth-snap-keyring@0.1.0...@metamask/eth-snap-keyring@0.1.1
|
|
344
|
+
[0.1.0]: https://github.com/MetaMask/accounts/releases/tag/@metamask/eth-snap-keyring@0.1.0
|
package/README.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Snap Keyring
|
|
2
|
+
|
|
3
|
+
This keyring acts as a bridge between the `KeyringController` and a snap.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
`yarn add @metamask/eth-snap-keyring`
|
|
8
|
+
|
|
9
|
+
or
|
|
10
|
+
|
|
11
|
+
`npm install @metamask/eth-snap-keyring`
|
|
12
|
+
|
|
13
|
+
## API
|
|
14
|
+
|
|
15
|
+
See our documentation:
|
|
16
|
+
|
|
17
|
+
- [Latest published API documentation](https://metamask.github.io/eth-snap-keyring/latest/)
|
|
18
|
+
- [Latest development API documentation](https://metamask.github.io/eth-snap-keyring/staging/)
|
|
19
|
+
|
|
20
|
+
## Contributing
|
|
21
|
+
|
|
22
|
+
### Setup
|
|
23
|
+
|
|
24
|
+
- Install [Node.js](https://nodejs.org) version 18
|
|
25
|
+
- If you are using [nvm](https://github.com/creationix/nvm#installation) (recommended) running `nvm use` will automatically choose the right node version for you.
|
|
26
|
+
- Install [Yarn v3](https://yarnpkg.com/getting-started/install)
|
|
27
|
+
- Run `yarn install` to install dependencies and run any required post-install scripts
|
|
28
|
+
|
|
29
|
+
### Testing and Linting
|
|
30
|
+
|
|
31
|
+
Run `yarn test` to run the tests once. To run tests on file changes, run `yarn test:watch`.
|
|
32
|
+
|
|
33
|
+
Run `yarn lint` to run the linter, or run `yarn lint:fix` to run the linter and fix any automatically fixable issues.
|
|
34
|
+
|
|
35
|
+
### Release & Publishing
|
|
36
|
+
|
|
37
|
+
The project follows the same release process as the other libraries in the MetaMask organization. The GitHub Actions [`action-create-release-pr`](https://github.com/MetaMask/action-create-release-pr) and [`action-publish-release`](https://github.com/MetaMask/action-publish-release) are used to automate the release process; see those repositories for more information about how they work.
|
|
38
|
+
|
|
39
|
+
1. Choose a release version.
|
|
40
|
+
|
|
41
|
+
- The release version should be chosen according to SemVer. Analyze the changes to see whether they include any breaking changes, new features, or deprecations, then choose the appropriate SemVer version. See [the SemVer specification](https://semver.org/) for more information.
|
|
42
|
+
|
|
43
|
+
2. If this release is backporting changes onto a previous release, then ensure there is a major version branch for that version (e.g. `1.x` for a `v1` backport release).
|
|
44
|
+
|
|
45
|
+
- The major version branch should be set to the most recent release with that major version. For example, when backporting a `v1.0.2` release, you'd want to ensure there was a `1.x` branch that was set to the `v1.0.1` tag.
|
|
46
|
+
|
|
47
|
+
3. Trigger the [`workflow_dispatch`](https://docs.github.com/en/actions/reference/events-that-trigger-workflows#workflow_dispatch) event [manually](https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow) for the `Create Release Pull Request` action to create the release PR.
|
|
48
|
+
|
|
49
|
+
- For a backport release, the base branch should be the major version branch that you ensured existed in step 2. For a normal release, the base branch should be the main branch for that repository (which should be the default value).
|
|
50
|
+
- This should trigger the [`action-create-release-pr`](https://github.com/MetaMask/action-create-release-pr) workflow to create the release PR.
|
|
51
|
+
|
|
52
|
+
4. Update the changelog to move each change entry into the appropriate change category ([See here](https://keepachangelog.com/en/1.0.0/#types) for the full list of change categories, and the correct ordering), and edit them to be more easily understood by users of the package.
|
|
53
|
+
|
|
54
|
+
- Generally any changes that don't affect consumers of the package (e.g. lockfile changes or development environment changes) are omitted. Exceptions may be made for changes that might be of interest despite not having an effect upon the published package (e.g. major test improvements, security improvements, improved documentation, etc.).
|
|
55
|
+
- Try to explain each change in terms that users of the package would understand (e.g. avoid referencing internal variables/concepts).
|
|
56
|
+
- Consolidate related changes into one change entry if it makes it easier to explain.
|
|
57
|
+
- Run `yarn auto-changelog validate --rc` to check that the changelog is correctly formatted.
|
|
58
|
+
|
|
59
|
+
5. Review and QA the release.
|
|
60
|
+
|
|
61
|
+
- If changes are made to the base branch, the release branch will need to be updated with these changes and review/QA will need to restart again. As such, it's probably best to avoid merging other PRs into the base branch while review is underway.
|
|
62
|
+
|
|
63
|
+
6. Squash & Merge the release.
|
|
64
|
+
|
|
65
|
+
- This should trigger the [`action-publish-release`](https://github.com/MetaMask/action-publish-release) workflow to tag the final release commit and publish the release on GitHub.
|
|
66
|
+
|
|
67
|
+
7. Publish the release on npm.
|
|
68
|
+
|
|
69
|
+
- Wait for the `publish-release` GitHub Action workflow to finish. This should trigger a second job (`publish-npm`), which will wait for a run approval by the [`npm publishers`](https://github.com/orgs/MetaMask/teams/npm-publishers) team.
|
|
70
|
+
- Approve the `publish-npm` job (or ask somebody on the npm publishers team to approve it for you).
|
|
71
|
+
- Once the `publish-npm` job has finished, check npm to verify that it has been published.
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A case-insensitive map that stores key-value pairs.
|
|
3
|
+
*/
|
|
4
|
+
export declare class CaseInsensitiveMap<Value> extends Map<string, Value> {
|
|
5
|
+
/**
|
|
6
|
+
* Create a new case-insensitive map from a plain object.
|
|
7
|
+
*
|
|
8
|
+
* @param obj - An object with entries to initialize the map with.
|
|
9
|
+
* @returns A new case-insensitive map with all entries from `obj`.
|
|
10
|
+
*/
|
|
11
|
+
static fromObject<Value>(obj: Record<string, Value>): CaseInsensitiveMap<Value>;
|
|
12
|
+
/**
|
|
13
|
+
* Return a plain object with all entries from this map.
|
|
14
|
+
*
|
|
15
|
+
* @returns A plain object with all entries from this map.
|
|
16
|
+
*/
|
|
17
|
+
toObject(): Record<string, Value>;
|
|
18
|
+
/**
|
|
19
|
+
* Return the value associated to the given key, or `undefined` if the key is
|
|
20
|
+
* not found.
|
|
21
|
+
*
|
|
22
|
+
* @param key - The key to get the value for.
|
|
23
|
+
* @returns The value associated to the given key, or `undefined` if the key
|
|
24
|
+
* is not found.
|
|
25
|
+
*/
|
|
26
|
+
get(key: string): Value | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Return the value associated with the given key, or throw an error if the
|
|
29
|
+
* key is not found.
|
|
30
|
+
*
|
|
31
|
+
* @param key - The key to look up in the map.
|
|
32
|
+
* @param name - Optional name of the key to include in the error message.
|
|
33
|
+
* @returns The value associated with the given key.
|
|
34
|
+
*/
|
|
35
|
+
getOrThrow(key: string, name?: string): Value;
|
|
36
|
+
/**
|
|
37
|
+
* Check whether the given key is present in the map.
|
|
38
|
+
*
|
|
39
|
+
* @param key - The key to check for.
|
|
40
|
+
* @returns `true` if the key is present in the map, `false` otherwise.
|
|
41
|
+
*/
|
|
42
|
+
has(key: string): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Set the value for the given key. If the key already exists in the map, its
|
|
45
|
+
* value will be updated.
|
|
46
|
+
*
|
|
47
|
+
* The key is converted to lowercase before being stored in the map to ensure
|
|
48
|
+
* case-insensitivity.
|
|
49
|
+
*
|
|
50
|
+
* @param key - The key to set the value for.
|
|
51
|
+
* @param value - The value to set.
|
|
52
|
+
* @returns The map instance.
|
|
53
|
+
*/
|
|
54
|
+
set(key: string, value: Value): this;
|
|
55
|
+
/**
|
|
56
|
+
* Delete the entry for the given key.
|
|
57
|
+
*
|
|
58
|
+
* @param key - The key to delete the entry for.
|
|
59
|
+
* @returns `true` if the entry was present in the map, `false` otherwise.
|
|
60
|
+
*/
|
|
61
|
+
delete(key: string): boolean;
|
|
62
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CaseInsensitiveMap = void 0;
|
|
4
|
+
const util_1 = require("./util");
|
|
5
|
+
/**
|
|
6
|
+
* A case-insensitive map that stores key-value pairs.
|
|
7
|
+
*/
|
|
8
|
+
class CaseInsensitiveMap extends Map {
|
|
9
|
+
/**
|
|
10
|
+
* Create a new case-insensitive map from a plain object.
|
|
11
|
+
*
|
|
12
|
+
* @param obj - An object with entries to initialize the map with.
|
|
13
|
+
* @returns A new case-insensitive map with all entries from `obj`.
|
|
14
|
+
*/
|
|
15
|
+
static fromObject(obj) {
|
|
16
|
+
return new CaseInsensitiveMap(Object.entries(obj));
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Return a plain object with all entries from this map.
|
|
20
|
+
*
|
|
21
|
+
* @returns A plain object with all entries from this map.
|
|
22
|
+
*/
|
|
23
|
+
toObject() {
|
|
24
|
+
return Object.fromEntries(this.entries());
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Return the value associated to the given key, or `undefined` if the key is
|
|
28
|
+
* not found.
|
|
29
|
+
*
|
|
30
|
+
* @param key - The key to get the value for.
|
|
31
|
+
* @returns The value associated to the given key, or `undefined` if the key
|
|
32
|
+
* is not found.
|
|
33
|
+
*/
|
|
34
|
+
get(key) {
|
|
35
|
+
return super.get(key.toLowerCase());
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Return the value associated with the given key, or throw an error if the
|
|
39
|
+
* key is not found.
|
|
40
|
+
*
|
|
41
|
+
* @param key - The key to look up in the map.
|
|
42
|
+
* @param name - Optional name of the key to include in the error message.
|
|
43
|
+
* @returns The value associated with the given key.
|
|
44
|
+
*/
|
|
45
|
+
getOrThrow(key, name = 'Key') {
|
|
46
|
+
return this.get(key) ?? (0, util_1.throwError)(`${name} '${key}' not found`);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Check whether the given key is present in the map.
|
|
50
|
+
*
|
|
51
|
+
* @param key - The key to check for.
|
|
52
|
+
* @returns `true` if the key is present in the map, `false` otherwise.
|
|
53
|
+
*/
|
|
54
|
+
has(key) {
|
|
55
|
+
return super.has(key.toLowerCase());
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Set the value for the given key. If the key already exists in the map, its
|
|
59
|
+
* value will be updated.
|
|
60
|
+
*
|
|
61
|
+
* The key is converted to lowercase before being stored in the map to ensure
|
|
62
|
+
* case-insensitivity.
|
|
63
|
+
*
|
|
64
|
+
* @param key - The key to set the value for.
|
|
65
|
+
* @param value - The value to set.
|
|
66
|
+
* @returns The map instance.
|
|
67
|
+
*/
|
|
68
|
+
set(key, value) {
|
|
69
|
+
return super.set(key.toLowerCase(), value);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Delete the entry for the given key.
|
|
73
|
+
*
|
|
74
|
+
* @param key - The key to delete the entry for.
|
|
75
|
+
* @returns `true` if the entry was present in the map, `false` otherwise.
|
|
76
|
+
*/
|
|
77
|
+
delete(key) {
|
|
78
|
+
return super.delete(key.toLowerCase());
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
exports.CaseInsensitiveMap = CaseInsensitiveMap;
|
|
82
|
+
//# sourceMappingURL=CaseInsensitiveMap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CaseInsensitiveMap.js","sourceRoot":"","sources":["../src/CaseInsensitiveMap.ts"],"names":[],"mappings":";;;AAAA,iCAAoC;AAEpC;;GAEG;AACH,MAAa,kBAA0B,SAAQ,GAAkB;IAC/D;;;;;OAKG;IACH,MAAM,CAAC,UAAU,CACf,GAA0B;QAE1B,OAAO,IAAI,kBAAkB,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;IACrD,CAAC;IAED;;;;OAIG;IACH,QAAQ;QACN,OAAO,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;IAC5C,CAAC;IAED;;;;;;;OAOG;IACH,GAAG,CAAC,GAAW;QACb,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC;IACtC,CAAC;IAED;;;;;;;OAOG;IACH,UAAU,CAAC,GAAW,EAAE,IAAI,GAAG,KAAK;QAClC,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,IAAA,iBAAU,EAAC,GAAG,IAAI,KAAK,GAAG,aAAa,CAAC,CAAC;IACnE,CAAC;IAED;;;;;OAKG;IACH,GAAG,CAAC,GAAW;QACb,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC;IACtC,CAAC;IAED;;;;;;;;;;OAUG;IACH,GAAG,CAAC,GAAW,EAAE,KAAY;QAC3B,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,KAAK,CAAC,CAAC;IAC7C,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,GAAW;QAChB,OAAO,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC;IACzC,CAAC;CACF;AAhFD,gDAgFC","sourcesContent":["import { throwError } from './util';\n\n/**\n * A case-insensitive map that stores key-value pairs.\n */\nexport class CaseInsensitiveMap<Value> extends Map<string, Value> {\n /**\n * Create a new case-insensitive map from a plain object.\n *\n * @param obj - An object with entries to initialize the map with.\n * @returns A new case-insensitive map with all entries from `obj`.\n */\n static fromObject<Value>(\n obj: Record<string, Value>,\n ): CaseInsensitiveMap<Value> {\n return new CaseInsensitiveMap(Object.entries(obj));\n }\n\n /**\n * Return a plain object with all entries from this map.\n *\n * @returns A plain object with all entries from this map.\n */\n toObject(): Record<string, Value> {\n return Object.fromEntries(this.entries());\n }\n\n /**\n * Return the value associated to the given key, or `undefined` if the key is\n * not found.\n *\n * @param key - The key to get the value for.\n * @returns The value associated to the given key, or `undefined` if the key\n * is not found.\n */\n get(key: string): Value | undefined {\n return super.get(key.toLowerCase());\n }\n\n /**\n * Return the value associated with the given key, or throw an error if the\n * key is not found.\n *\n * @param key - The key to look up in the map.\n * @param name - Optional name of the key to include in the error message.\n * @returns The value associated with the given key.\n */\n getOrThrow(key: string, name = 'Key'): Value {\n return this.get(key) ?? throwError(`${name} '${key}' not found`);\n }\n\n /**\n * Check whether the given key is present in the map.\n *\n * @param key - The key to check for.\n * @returns `true` if the key is present in the map, `false` otherwise.\n */\n has(key: string): boolean {\n return super.has(key.toLowerCase());\n }\n\n /**\n * Set the value for the given key. If the key already exists in the map, its\n * value will be updated.\n *\n * The key is converted to lowercase before being stored in the map to ensure\n * case-insensitivity.\n *\n * @param key - The key to set the value for.\n * @param value - The value to set.\n * @returns The map instance.\n */\n set(key: string, value: Value): this {\n return super.set(key.toLowerCase(), value);\n }\n\n /**\n * Delete the entry for the given key.\n *\n * @param key - The key to delete the entry for.\n * @returns `true` if the entry was present in the map, `false` otherwise.\n */\n delete(key: string): boolean {\n return super.delete(key.toLowerCase());\n }\n}\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A deferred promise can be resolved by a caller different from the one who
|
|
3
|
+
* created it.
|
|
4
|
+
*
|
|
5
|
+
* Example:
|
|
6
|
+
* - "A" creates a deferred promise "P", adds it to a list, and awaits it
|
|
7
|
+
* - "B" gets "P" from the list and resolves it
|
|
8
|
+
* - "A" gets the resolved value
|
|
9
|
+
*/
|
|
10
|
+
export declare class DeferredPromise<Type> {
|
|
11
|
+
promise: Promise<Type>;
|
|
12
|
+
resolve: (value: Type | PromiseLike<Type>) => void;
|
|
13
|
+
reject: (reason?: any) => void;
|
|
14
|
+
constructor();
|
|
15
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DeferredPromise = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* A deferred promise can be resolved by a caller different from the one who
|
|
6
|
+
* created it.
|
|
7
|
+
*
|
|
8
|
+
* Example:
|
|
9
|
+
* - "A" creates a deferred promise "P", adds it to a list, and awaits it
|
|
10
|
+
* - "B" gets "P" from the list and resolves it
|
|
11
|
+
* - "A" gets the resolved value
|
|
12
|
+
*/
|
|
13
|
+
class DeferredPromise {
|
|
14
|
+
constructor() {
|
|
15
|
+
this.resolve = undefined;
|
|
16
|
+
this.reject = undefined;
|
|
17
|
+
this.promise = new Promise((resolve, reject) => {
|
|
18
|
+
this.resolve = resolve;
|
|
19
|
+
this.reject = reject;
|
|
20
|
+
});
|
|
21
|
+
// This is a sanity check to make sure that the promise constructor
|
|
22
|
+
// actually set the `resolve` and `reject` functions.
|
|
23
|
+
/* istanbul ignore next */
|
|
24
|
+
if (!this.resolve || !this.reject) {
|
|
25
|
+
throw new Error('Promise constructor failed');
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.DeferredPromise = DeferredPromise;
|
|
30
|
+
//# sourceMappingURL=DeferredPromise.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DeferredPromise.js","sourceRoot":"","sources":["../src/DeferredPromise.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;GAQG;AACH,MAAa,eAAe;IAO1B;QAJA,YAAO,GAA8C,SAAgB,CAAC;QAEtE,WAAM,GAA2B,SAAgB,CAAC;QAGhD,IAAI,CAAC,OAAO,GAAG,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAC7C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;YACvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACvB,CAAC,CAAC,CAAC;QAEH,mEAAmE;QACnE,qDAAqD;QACrD,0BAA0B;QAC1B,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YACjC,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;SAC/C;IACH,CAAC;CACF;AApBD,0CAoBC","sourcesContent":["/**\n * A deferred promise can be resolved by a caller different from the one who\n * created it.\n *\n * Example:\n * - \"A\" creates a deferred promise \"P\", adds it to a list, and awaits it\n * - \"B\" gets \"P\" from the list and resolves it\n * - \"A\" gets the resolved value\n */\nexport class DeferredPromise<Type> {\n promise: Promise<Type>;\n\n resolve: (value: Type | PromiseLike<Type>) => void = undefined as any;\n\n reject: (reason?: any) => void = undefined as any;\n\n constructor() {\n this.promise = new Promise((resolve, reject) => {\n this.resolve = resolve;\n this.reject = reject;\n });\n\n // This is a sanity check to make sure that the promise constructor\n // actually set the `resolve` and `reject` functions.\n /* istanbul ignore next */\n if (!this.resolve || !this.reject) {\n throw new Error('Promise constructor failed');\n }\n }\n}\n"]}
|