@metamask/snaps-controllers 16.1.0 → 17.0.0
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 +18 -1
- package/dist/snaps/SnapController.cjs +15 -9
- package/dist/snaps/SnapController.cjs.map +1 -1
- package/dist/snaps/SnapController.d.cts +7 -1
- package/dist/snaps/SnapController.d.cts.map +1 -1
- package/dist/snaps/SnapController.d.mts +7 -1
- package/dist/snaps/SnapController.d.mts.map +1 -1
- package/dist/snaps/SnapController.mjs +15 -9
- package/dist/snaps/SnapController.mjs.map +1 -1
- package/dist/snaps/registry/json.cjs +16 -3
- package/dist/snaps/registry/json.cjs.map +1 -1
- package/dist/snaps/registry/json.d.cts +7 -2
- package/dist/snaps/registry/json.d.cts.map +1 -1
- package/dist/snaps/registry/json.d.mts +7 -2
- package/dist/snaps/registry/json.d.mts.map +1 -1
- package/dist/snaps/registry/json.mjs +16 -3
- package/dist/snaps/registry/json.mjs.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [17.0.0]
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- **BREAKING:** Ensure user has onboarded before allowing usage of SnapController ([#3731](https://github.com/MetaMask/snaps/pull/3731))
|
|
15
|
+
- This is breaking as it adds a new required constructor argument to `SnapController` called `ensureOnboardingComplete`.
|
|
16
|
+
- **BREAKING:** Support specified `clientVersions` in the registry ([#3737](https://github.com/MetaMask/snaps/pull/3737))
|
|
17
|
+
- This is breaking as it adds a new required constructor argument to `JsonSnapsRegistry` called `clientConfig`.
|
|
18
|
+
|
|
19
|
+
## [16.1.1]
|
|
20
|
+
|
|
21
|
+
### Fixed
|
|
22
|
+
|
|
23
|
+
- Override `disableSnapInstallation` feature flag when using automatic updates ([#3735](https://github.com/MetaMask/snaps/pull/3735))
|
|
24
|
+
|
|
10
25
|
## [16.1.0]
|
|
11
26
|
|
|
12
27
|
### Added
|
|
@@ -954,7 +969,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
954
969
|
- The version of the package no longer needs to match the version of all other
|
|
955
970
|
MetaMask Snaps packages.
|
|
956
971
|
|
|
957
|
-
[Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-controllers@
|
|
972
|
+
[Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-controllers@17.0.0...HEAD
|
|
973
|
+
[17.0.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-controllers@16.1.1...@metamask/snaps-controllers@17.0.0
|
|
974
|
+
[16.1.1]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-controllers@16.1.0...@metamask/snaps-controllers@16.1.1
|
|
958
975
|
[16.1.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-controllers@16.0.0...@metamask/snaps-controllers@16.1.0
|
|
959
976
|
[16.0.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-controllers@15.0.2...@metamask/snaps-controllers@16.0.0
|
|
960
977
|
[15.0.2]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-controllers@15.0.1...@metamask/snaps-controllers@15.0.2
|
|
@@ -83,7 +83,8 @@ class SnapController extends base_controller_1.BaseController {
|
|
|
83
83
|
#preinstalledSnaps;
|
|
84
84
|
#trackEvent;
|
|
85
85
|
#trackSnapExport;
|
|
86
|
-
|
|
86
|
+
#ensureOnboardingComplete;
|
|
87
|
+
constructor({ closeAllConnections, messenger, state, dynamicPermissions = ['endowment:caip25', 'wallet_snap'], environmentEndowmentPermissions = [], excludedPermissions = {}, idleTimeCheckInterval = (0, utils_1.inMilliseconds)(5, utils_1.Duration.Second), maxIdleTime = (0, utils_1.inMilliseconds)(30, utils_1.Duration.Second), maxRequestTime = (0, utils_1.inMilliseconds)(60, utils_1.Duration.Second), fetchFunction = globalThis.fetch.bind(undefined), featureFlags = {}, detectSnapLocation: detectSnapLocationFunction = location_1.detectSnapLocation, preinstalledSnaps = null, encryptor, getMnemonicSeed, getFeatureFlags = () => ({}), clientCryptography, trackEvent, ensureOnboardingComplete, }) {
|
|
87
88
|
super({
|
|
88
89
|
messenger,
|
|
89
90
|
metadata: {
|
|
@@ -160,6 +161,7 @@ class SnapController extends base_controller_1.BaseController {
|
|
|
160
161
|
this.#rollbackSnapshots = new Map();
|
|
161
162
|
this.#snapsRuntimeData = new Map();
|
|
162
163
|
this.#trackEvent = trackEvent;
|
|
164
|
+
this.#ensureOnboardingComplete = ensureOnboardingComplete;
|
|
163
165
|
this.#pollForLastRequestStatus();
|
|
164
166
|
/* eslint-disable @typescript-eslint/unbound-method */
|
|
165
167
|
this.messenger.subscribe('ExecutionService:unhandledError', this._onUnhandledSnapError);
|
|
@@ -383,7 +385,7 @@ class SnapController extends base_controller_1.BaseController {
|
|
|
383
385
|
* Also updates any preinstalled Snaps to the latest allowlisted version.
|
|
384
386
|
*/
|
|
385
387
|
async updateRegistry() {
|
|
386
|
-
this.#assertCanUsePlatform();
|
|
388
|
+
await this.#assertCanUsePlatform();
|
|
387
389
|
await this.messenger.call('SnapsRegistry:update');
|
|
388
390
|
const blockedSnaps = await this.messenger.call('SnapsRegistry:get', Object.values(this.state.snaps).reduce((blockListArg, snap) => {
|
|
389
391
|
blockListArg[snap.id] = {
|
|
@@ -489,9 +491,11 @@ class SnapController extends base_controller_1.BaseController {
|
|
|
489
491
|
(0, utils_1.assert)(this.#featureFlags.disableSnapInstallation !== true, 'Installing Snaps is currently disabled in this version of MetaMask.');
|
|
490
492
|
}
|
|
491
493
|
/**
|
|
492
|
-
*
|
|
494
|
+
* Waits for onboarding and then asserts whether the Snaps platform is allowed to run.
|
|
493
495
|
*/
|
|
494
|
-
#assertCanUsePlatform() {
|
|
496
|
+
async #assertCanUsePlatform() {
|
|
497
|
+
// Ensure the user has onboarded before allowing access to Snaps.
|
|
498
|
+
await this.#ensureOnboardingComplete();
|
|
495
499
|
const flags = this.#getFeatureFlags();
|
|
496
500
|
(0, utils_1.assert)(flags.disableSnaps !== true, 'The Snaps platform requires basic functionality to be used. Enable basic functionality in the settings to use the Snaps platform.');
|
|
497
501
|
}
|
|
@@ -558,7 +562,7 @@ class SnapController extends base_controller_1.BaseController {
|
|
|
558
562
|
* @param snapId - The id of the Snap to start.
|
|
559
563
|
*/
|
|
560
564
|
async startSnap(snapId) {
|
|
561
|
-
this.#assertCanUsePlatform();
|
|
565
|
+
await this.#assertCanUsePlatform();
|
|
562
566
|
const snap = this.state.snaps[snapId];
|
|
563
567
|
if (!snap.enabled) {
|
|
564
568
|
throw new Error(`Snap "${snapId}" is disabled.`);
|
|
@@ -1226,7 +1230,7 @@ class SnapController extends base_controller_1.BaseController {
|
|
|
1226
1230
|
* snap couldn't be installed.
|
|
1227
1231
|
*/
|
|
1228
1232
|
async installSnaps(origin, requestedSnaps) {
|
|
1229
|
-
this.#assertCanUsePlatform();
|
|
1233
|
+
await this.#assertCanUsePlatform();
|
|
1230
1234
|
const result = {};
|
|
1231
1235
|
const snapIds = Object.keys(requestedSnaps);
|
|
1232
1236
|
const pendingUpdates = [];
|
|
@@ -1408,8 +1412,10 @@ class SnapController extends base_controller_1.BaseController {
|
|
|
1408
1412
|
* @returns The snap metadata if updated, `null` otherwise.
|
|
1409
1413
|
*/
|
|
1410
1414
|
async #updateSnap({ origin, snapId, location, versionRange, automaticUpdate = false, }) {
|
|
1411
|
-
|
|
1412
|
-
|
|
1415
|
+
if (!automaticUpdate) {
|
|
1416
|
+
this.#assertCanInstallSnaps();
|
|
1417
|
+
}
|
|
1418
|
+
await this.#assertCanUsePlatform();
|
|
1413
1419
|
const snap = this.getExpect(snapId);
|
|
1414
1420
|
const { preinstalled, removable, hidden, hideSnapBranding } = snap;
|
|
1415
1421
|
if (preinstalled && !automaticUpdate) {
|
|
@@ -1832,7 +1838,7 @@ class SnapController extends base_controller_1.BaseController {
|
|
|
1832
1838
|
* @returns The result of the JSON-RPC request.
|
|
1833
1839
|
*/
|
|
1834
1840
|
async handleRequest({ snapId, origin, handler: handlerType, request: rawRequest, }) {
|
|
1835
|
-
this.#assertCanUsePlatform();
|
|
1841
|
+
await this.#assertCanUsePlatform();
|
|
1836
1842
|
const snap = this.get(snapId);
|
|
1837
1843
|
(0, utils_1.assert)(snap, `The Snap "${snapId}" is not installed. Please install it before invoking it.`);
|
|
1838
1844
|
(0, utils_1.assert)(origin === constants_1.METAMASK_ORIGIN || (0, snaps_utils_1.isValidUrl)(origin), "'origin' must be a valid URL or 'metamask'.");
|