@metamask/snaps-jest 6.0.2 → 7.0.1
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/README.md +100 -7
- package/dist/{chunk-6RXFM4YC.js → chunk-2JAGD4N6.js} +3 -3
- package/dist/{chunk-7YD4IW43.mjs → chunk-3M4GRUMH.mjs} +3 -6
- package/dist/chunk-3M4GRUMH.mjs.map +1 -0
- package/dist/{chunk-WIFOID2P.mjs → chunk-3OEADJAL.mjs} +20 -10
- package/dist/chunk-3OEADJAL.mjs.map +1 -0
- package/dist/{chunk-7BFTEFLS.mjs → chunk-5U5WB3SM.mjs} +5 -3
- package/dist/chunk-5U5WB3SM.mjs.map +1 -0
- package/dist/chunk-7L5S3PID.js +127 -0
- package/dist/chunk-7L5S3PID.js.map +1 -0
- package/dist/{chunk-7VILST6M.mjs → chunk-BVGI3E45.mjs} +2 -2
- package/dist/chunk-CKRORVDW.js +1 -0
- package/dist/{chunk-6HW5NGCB.js → chunk-DTDYOBCI.js} +3 -3
- package/dist/{chunk-B4QZXXQY.js → chunk-FIZAYEHV.js} +4 -4
- package/dist/{chunk-T2BE4O5H.js → chunk-IDGD7TZ7.js} +33 -23
- package/dist/chunk-IDGD7TZ7.js.map +1 -0
- package/dist/chunk-KR7CYXCR.js +213 -0
- package/dist/chunk-KR7CYXCR.js.map +1 -0
- package/dist/{chunk-BS24WMRW.mjs → chunk-LG3VKXGH.mjs} +2 -2
- package/dist/{chunk-5PLDD7ZC.js → chunk-LMCG5RIX.js} +24 -14
- package/dist/chunk-LMCG5RIX.js.map +1 -0
- package/dist/{chunk-C2ONPIIB.js → chunk-MCYTJUDG.js} +10 -15
- package/dist/chunk-MCYTJUDG.js.map +1 -0
- package/dist/chunk-QPC6UJH7.mjs +213 -0
- package/dist/chunk-QPC6UJH7.mjs.map +1 -0
- package/dist/chunk-S2HLITUN.js +1 -0
- package/dist/{chunk-ISWZ7XZ5.js → chunk-SB5EPHE3.js} +5 -3
- package/dist/chunk-SB5EPHE3.js.map +1 -0
- package/dist/{chunk-HBLJOACO.mjs → chunk-TAIJXTLU.mjs} +2 -10
- package/dist/chunk-TAIJXTLU.mjs.map +1 -0
- package/dist/chunk-TGZ7WOTJ.mjs +1 -0
- package/dist/chunk-UDOXICJK.mjs +1 -0
- package/dist/{chunk-3HU56QS3.mjs → chunk-VSUNWJMQ.mjs} +8 -13
- package/dist/chunk-VSUNWJMQ.mjs.map +1 -0
- package/dist/{chunk-TO46ICOZ.js → chunk-WMLSD6B5.js} +3 -6
- package/dist/chunk-WMLSD6B5.js.map +1 -0
- package/dist/{chunk-3SNZ4SPY.mjs → chunk-X5IPMTHO.mjs} +2 -2
- package/dist/{chunk-7J34R6YW.mjs → chunk-YEVKBYKO.mjs} +35 -25
- package/dist/chunk-YEVKBYKO.mjs.map +1 -0
- package/dist/chunk-ZJVA3AOC.mjs +127 -0
- package/dist/chunk-ZJVA3AOC.mjs.map +1 -0
- package/dist/{chunk-LXSNRZV4.js → chunk-ZWN4SO2V.js} +5 -13
- package/dist/chunk-ZWN4SO2V.js.map +1 -0
- package/dist/environment.js +13 -14
- package/dist/environment.mjs +12 -13
- package/dist/global.js +2 -0
- package/dist/global.js.map +1 -0
- package/dist/global.mjs +2 -0
- package/dist/global.mjs.map +1 -0
- package/dist/helpers.js +13 -14
- package/dist/helpers.mjs +12 -13
- package/dist/index.js +16 -16
- package/dist/index.mjs +15 -15
- package/dist/internals/index.js +27 -14
- package/dist/internals/index.mjs +30 -17
- package/dist/internals/request.js +12 -11
- package/dist/internals/request.mjs +13 -12
- package/dist/internals/simulation/controllers.js +6 -7
- package/dist/internals/simulation/controllers.mjs +5 -6
- package/dist/internals/simulation/index.js +17 -10
- package/dist/internals/simulation/index.mjs +17 -10
- package/dist/internals/simulation/interface.js +11 -3
- package/dist/internals/simulation/interface.mjs +12 -4
- package/dist/internals/simulation/methods/hooks/index.js +4 -10
- package/dist/internals/simulation/methods/hooks/index.mjs +3 -9
- package/dist/internals/simulation/methods/hooks/notifications.js +1 -1
- package/dist/internals/simulation/methods/hooks/notifications.mjs +1 -1
- package/dist/internals/simulation/methods/hooks/show-dialog.js +1 -1
- package/dist/internals/simulation/methods/hooks/show-dialog.mjs +1 -1
- package/dist/internals/simulation/methods/hooks/state.js +3 -3
- package/dist/internals/simulation/methods/hooks/state.mjs +2 -2
- package/dist/internals/simulation/methods/index.js +5 -6
- package/dist/internals/simulation/methods/index.mjs +4 -5
- package/dist/internals/simulation/methods/specifications.js +5 -6
- package/dist/internals/simulation/methods/specifications.mjs +4 -5
- package/dist/internals/simulation/simulation.js +8 -9
- package/dist/internals/simulation/simulation.mjs +7 -8
- package/dist/internals/simulation/store/index.js +2 -2
- package/dist/internals/simulation/store/index.mjs +1 -1
- package/dist/internals/simulation/store/store.js +2 -2
- package/dist/internals/simulation/store/store.mjs +1 -1
- package/dist/internals/structs.js +6 -2
- package/dist/internals/structs.mjs +5 -1
- package/dist/matchers.js +13 -14
- package/dist/matchers.mjs +12 -13
- package/dist/setup.js +12 -13
- package/dist/setup.mjs +12 -13
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/global.d.ts +69 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/internals/request.d.ts +13 -4
- package/dist/types/internals/simulation/interface.d.ts +47 -4
- package/dist/types/internals/simulation/methods/hooks/index.d.ts +0 -1
- package/dist/types/internals/simulation/methods/hooks/state.d.ts +2 -1
- package/dist/types/internals/simulation/store/store.d.ts +1 -2
- package/dist/types/internals/structs.d.ts +79 -156
- package/dist/types/types.d.ts +42 -21
- package/package.json +6 -6
- package/dist/chunk-2X23DUDP.mjs +0 -22
- package/dist/chunk-2X23DUDP.mjs.map +0 -1
- package/dist/chunk-3HU56QS3.mjs.map +0 -1
- package/dist/chunk-5PLDD7ZC.js.map +0 -1
- package/dist/chunk-6MVV44M5.mjs +0 -76
- package/dist/chunk-6MVV44M5.mjs.map +0 -1
- package/dist/chunk-7BFTEFLS.mjs.map +0 -1
- package/dist/chunk-7J34R6YW.mjs.map +0 -1
- package/dist/chunk-7YD4IW43.mjs.map +0 -1
- package/dist/chunk-C2ONPIIB.js.map +0 -1
- package/dist/chunk-HBLJOACO.mjs.map +0 -1
- package/dist/chunk-HNH5UAKZ.js +0 -80
- package/dist/chunk-HNH5UAKZ.js.map +0 -1
- package/dist/chunk-ISWZ7XZ5.js.map +0 -1
- package/dist/chunk-LXSNRZV4.js.map +0 -1
- package/dist/chunk-LYK6EGZU.mjs +0 -80
- package/dist/chunk-LYK6EGZU.mjs.map +0 -1
- package/dist/chunk-RD7GQCPL.js +0 -22
- package/dist/chunk-RD7GQCPL.js.map +0 -1
- package/dist/chunk-T2BE4O5H.js.map +0 -1
- package/dist/chunk-TO46ICOZ.js.map +0 -1
- package/dist/chunk-U5BLLHIU.js +0 -1
- package/dist/chunk-V6LFAN3U.mjs +0 -1
- package/dist/chunk-WIFOID2P.mjs.map +0 -1
- package/dist/chunk-ZAQZRYPW.js +0 -76
- package/dist/chunk-ZAQZRYPW.js.map +0 -1
- package/dist/internals/simulation/methods/hooks/encryption.js +0 -10
- package/dist/internals/simulation/methods/hooks/encryption.mjs +0 -10
- package/dist/types/internals/simulation/methods/hooks/encryption.d.ts +0 -29
- /package/dist/{chunk-6RXFM4YC.js.map → chunk-2JAGD4N6.js.map} +0 -0
- /package/dist/{chunk-7VILST6M.mjs.map → chunk-BVGI3E45.mjs.map} +0 -0
- /package/dist/{chunk-U5BLLHIU.js.map → chunk-CKRORVDW.js.map} +0 -0
- /package/dist/{chunk-6HW5NGCB.js.map → chunk-DTDYOBCI.js.map} +0 -0
- /package/dist/{chunk-B4QZXXQY.js.map → chunk-FIZAYEHV.js.map} +0 -0
- /package/dist/{chunk-BS24WMRW.mjs.map → chunk-LG3VKXGH.mjs.map} +0 -0
- /package/dist/{internals/simulation/methods/hooks/encryption.js.map → chunk-S2HLITUN.js.map} +0 -0
- /package/dist/{chunk-V6LFAN3U.mjs.map → chunk-TGZ7WOTJ.mjs.map} +0 -0
- /package/dist/{internals/simulation/methods/hooks/encryption.mjs.map → chunk-UDOXICJK.mjs.map} +0 -0
- /package/dist/{chunk-3SNZ4SPY.mjs.map → chunk-X5IPMTHO.mjs.map} +0 -0
package/dist/chunk-ZAQZRYPW.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var _chunkPZDTZGSIjs = require('./chunk-PZDTZGSI.js');
|
|
6
|
-
|
|
7
|
-
// src/internals/simulation/interface.ts
|
|
8
|
-
var _snapssdk = require('@metamask/snaps-sdk');
|
|
9
|
-
var _effects = require('redux-saga/effects');
|
|
10
|
-
function getInterfaceResponse(runSaga, type, content) {
|
|
11
|
-
switch (type) {
|
|
12
|
-
case _snapssdk.DialogType.Alert:
|
|
13
|
-
return {
|
|
14
|
-
type,
|
|
15
|
-
content,
|
|
16
|
-
ok: resolveWith(runSaga, null)
|
|
17
|
-
};
|
|
18
|
-
case _snapssdk.DialogType.Confirmation:
|
|
19
|
-
return {
|
|
20
|
-
type,
|
|
21
|
-
content,
|
|
22
|
-
ok: resolveWith(runSaga, true),
|
|
23
|
-
cancel: resolveWith(runSaga, false)
|
|
24
|
-
};
|
|
25
|
-
case _snapssdk.DialogType.Prompt:
|
|
26
|
-
return {
|
|
27
|
-
type,
|
|
28
|
-
content,
|
|
29
|
-
ok: resolveWithInput(runSaga),
|
|
30
|
-
cancel: resolveWith(runSaga, null)
|
|
31
|
-
};
|
|
32
|
-
default:
|
|
33
|
-
throw new Error(`Unknown or unsupported dialog type: "${String(type)}".`);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
function resolveWith(runSaga, value) {
|
|
37
|
-
function* resolveWithSaga() {
|
|
38
|
-
yield _effects.put.call(void 0, _chunkPZDTZGSIjs.resolveInterface.call(void 0, value));
|
|
39
|
-
}
|
|
40
|
-
return async () => {
|
|
41
|
-
await runSaga(resolveWithSaga).toPromise();
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
function resolveWithInput(runSaga) {
|
|
45
|
-
function* resolveWithSaga(value) {
|
|
46
|
-
yield _effects.put.call(void 0, _chunkPZDTZGSIjs.resolveInterface.call(void 0, value));
|
|
47
|
-
}
|
|
48
|
-
return async (value = "") => {
|
|
49
|
-
await runSaga(resolveWithSaga, value).toPromise();
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
function* getInterface(runSaga, snapId, controllerMessenger) {
|
|
53
|
-
const currentInterface = yield _effects.select.call(void 0, _chunkPZDTZGSIjs.getCurrentInterface);
|
|
54
|
-
if (currentInterface) {
|
|
55
|
-
const { content: content2 } = controllerMessenger.call(
|
|
56
|
-
"SnapInterfaceController:getInterface",
|
|
57
|
-
snapId,
|
|
58
|
-
currentInterface.id
|
|
59
|
-
);
|
|
60
|
-
return getInterfaceResponse(runSaga, currentInterface.type, content2);
|
|
61
|
-
}
|
|
62
|
-
const { payload } = yield _effects.take.call(void 0, _chunkPZDTZGSIjs.setInterface.type);
|
|
63
|
-
const { type, id } = payload;
|
|
64
|
-
const { content } = controllerMessenger.call(
|
|
65
|
-
"SnapInterfaceController:getInterface",
|
|
66
|
-
snapId,
|
|
67
|
-
id
|
|
68
|
-
);
|
|
69
|
-
return getInterfaceResponse(runSaga, type, content);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
exports.getInterfaceResponse = getInterfaceResponse; exports.getInterface = getInterface;
|
|
76
|
-
//# sourceMappingURL=chunk-ZAQZRYPW.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/internals/simulation/interface.ts"],"names":["content"],"mappings":";;;;;;;AACA,SAAS,kBAAkB;AAG3B,SAAS,KAAK,QAAQ,YAAY;AAe3B,SAAS,qBACd,SACA,MACA,SACe;AACf,UAAQ,MAAM;A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I,oBAAoB;AAAA,IACtC;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,SAAO,qBAAqB,SAAS,MAAM,OAAO;AACpD","sourcesContent":["import type { Component, SnapId } from '@metamask/snaps-sdk';\nimport { DialogType } from '@metamask/snaps-sdk';\nimport type { PayloadAction } from '@reduxjs/toolkit';\nimport type { SagaIterator } from 'redux-saga';\nimport { put, select, take } from 'redux-saga/effects';\n\nimport type { SnapInterface } from '../../types';\nimport type { RootControllerMessenger } from './controllers';\nimport type { Interface, RunSagaFunction } from './store';\nimport { getCurrentInterface, resolveInterface, setInterface } from './store';\n\n/**\n * Get a user interface object from a type and content object.\n *\n * @param runSaga - A function to run a saga outside the usual Redux flow.\n * @param type - The type of the interface.\n * @param content - The content to show in the interface.\n * @returns The user interface object.\n */\nexport function getInterfaceResponse(\n runSaga: RunSagaFunction,\n type: DialogType,\n content: Component,\n): SnapInterface {\n switch (type) {\n case DialogType.Alert:\n return {\n type,\n content,\n ok: resolveWith(runSaga, null),\n };\n\n case DialogType.Confirmation:\n return {\n type,\n content,\n\n ok: resolveWith(runSaga, true),\n cancel: resolveWith(runSaga, false),\n };\n\n case DialogType.Prompt:\n return {\n type,\n content,\n\n ok: resolveWithInput(runSaga),\n cancel: resolveWith(runSaga, null),\n };\n\n default:\n throw new Error(`Unknown or unsupported dialog type: \"${String(type)}\".`);\n }\n}\n\n/**\n * Resolve the current user interface with the given value. This returns a\n * function that can be used to resolve the user interface.\n *\n * @param runSaga - A function to run a saga outside the usual Redux flow.\n * @param value - The value to resolve the user interface with.\n * @returns A function that can be used to resolve the user interface.\n */\nfunction resolveWith(runSaga: RunSagaFunction, value: unknown) {\n /**\n * Resolve the current user interface with the given value.\n *\n * @yields Puts the resolve user interface action.\n */\n function* resolveWithSaga(): SagaIterator {\n yield put(resolveInterface(value));\n }\n\n return async () => {\n await runSaga(resolveWithSaga).toPromise();\n };\n}\n\n/**\n * Resolve the current user interface with the provided input. This returns a\n * function that can be used to resolve the user interface.\n *\n * @param runSaga - A function to run a saga outside the usual Redux flow.\n * @returns A function that can be used to resolve the user interface.\n */\nfunction resolveWithInput(runSaga: RunSagaFunction) {\n /**\n * Resolve the current user interface with the given value.\n *\n * @param value - The value to resolve the user interface with.\n * @yields Puts the resolve user interface action.\n */\n function* resolveWithSaga(value: string): SagaIterator {\n yield put(resolveInterface(value));\n }\n\n return async (value = '') => {\n await runSaga(resolveWithSaga, value).toPromise();\n };\n}\n\n/**\n * Get a user interface object from a Snap.\n *\n * @param runSaga - A function to run a saga outside the usual Redux flow.\n * @param snapId - The Snap ID.\n * @param controllerMessenger - The controller messenger used to call actions.\n * @yields Takes the set interface action.\n * @returns The user interface object.\n */\nexport function* getInterface(\n runSaga: RunSagaFunction,\n snapId: SnapId,\n controllerMessenger: RootControllerMessenger,\n): SagaIterator<SnapInterface> {\n const currentInterface: Interface | null = yield select(getCurrentInterface);\n if (currentInterface) {\n const { content } = controllerMessenger.call(\n 'SnapInterfaceController:getInterface',\n snapId,\n currentInterface.id,\n );\n return getInterfaceResponse(runSaga, currentInterface.type, content);\n }\n\n const { payload }: PayloadAction<Interface> = yield take(setInterface.type);\n const { type, id } = payload;\n\n const { content } = controllerMessenger.call(\n 'SnapInterfaceController:getInterface',\n snapId,\n id,\n );\n\n return getInterfaceResponse(runSaga, type, content);\n}\n"]}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var _chunkRD7GQCPLjs = require('../../../../chunk-RD7GQCPL.js');
|
|
5
|
-
require('../../../../chunk-PHUTP7NB.js');
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
exports.decryptImplementation = _chunkRD7GQCPLjs.decryptImplementation; exports.encryptImplementation = _chunkRD7GQCPLjs.encryptImplementation;
|
|
10
|
-
//# sourceMappingURL=encryption.js.map
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { Json } from '@metamask/utils';
|
|
2
|
-
/**
|
|
3
|
-
* Mocks encrypting a value using a password. This is not a real encryption
|
|
4
|
-
* method, but rather is used to simulate encryption in the tests.
|
|
5
|
-
*
|
|
6
|
-
* Ideally we would use a real encryption method, such as
|
|
7
|
-
* `@metamask/browser-passworder`, but it doesn't seem to work with Node.js 18
|
|
8
|
-
* without some mocking. We can switch to a real encryption method once we
|
|
9
|
-
* drop support for Node.js 18.
|
|
10
|
-
*
|
|
11
|
-
* @param password - The password to use.
|
|
12
|
-
* @param value - The value to encrypt.
|
|
13
|
-
* @returns The "encrypted" value.
|
|
14
|
-
*/
|
|
15
|
-
export declare function encryptImplementation(password: string, value: Json): string;
|
|
16
|
-
/**
|
|
17
|
-
* Mocks decrypting a value using a password. This is not a real encryption
|
|
18
|
-
* method, but rather is used to simulate encryption in the tests.
|
|
19
|
-
*
|
|
20
|
-
* Ideally we would use a real decryption method, such as
|
|
21
|
-
* `@metamask/browser-passworder`, but it doesn't seem to work with Node.js 18
|
|
22
|
-
* without some mocking. We can switch to a real encryption method once we
|
|
23
|
-
* drop support for Node.js 18.
|
|
24
|
-
*
|
|
25
|
-
* @param password - The password to use.
|
|
26
|
-
* @param value - The value to decrypt.
|
|
27
|
-
* @returns The "decrypted" value.
|
|
28
|
-
*/
|
|
29
|
-
export declare function decryptImplementation(password: string, value: string): any;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/{internals/simulation/methods/hooks/encryption.js.map → chunk-S2HLITUN.js.map}
RENAMED
|
File without changes
|
|
File without changes
|
/package/dist/{internals/simulation/methods/hooks/encryption.mjs.map → chunk-UDOXICJK.mjs.map}
RENAMED
|
File without changes
|
|
File without changes
|