@ledgerhq/vault-cli 1.73.2 → 2.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/.turbo/turbo-build.log +16 -2
- package/CHANGELOG.md +64 -0
- package/__mocks__/@ledgerhq/vault-common.ts +1 -0
- package/bin/index.js +5615 -15
- package/bin/index.js.map +1 -1
- package/bin/index.mjs +5621 -0
- package/bin/index.mjs.map +1 -0
- package/package.json +6 -7
- package/tsup.config.ts +10 -0
- package/bin/__patchGateOptionsWithEnvVariables.d.ts +0 -4
- package/bin/__patchGateOptionsWithEnvVariables.d.ts.map +0 -1
- package/bin/__patchGateOptionsWithEnvVariables.js +0 -38
- package/bin/__patchGateOptionsWithEnvVariables.js.map +0 -1
- package/bin/__tests__/apdu.test.d.ts +0 -2
- package/bin/__tests__/apdu.test.d.ts.map +0 -1
- package/bin/__tests__/apdu.test.js +0 -33
- package/bin/__tests__/apdu.test.js.map +0 -1
- package/bin/__tests__/approve.test.d.ts +0 -2
- package/bin/__tests__/approve.test.d.ts.map +0 -1
- package/bin/__tests__/approve.test.js +0 -159
- package/bin/__tests__/approve.test.js.map +0 -1
- package/bin/__tests__/backupCompartment.test.d.ts +0 -2
- package/bin/__tests__/backupCompartment.test.d.ts.map +0 -1
- package/bin/__tests__/backupCompartment.test.js +0 -88
- package/bin/__tests__/backupCompartment.test.js.map +0 -1
- package/bin/__tests__/bake.test.d.ts +0 -2
- package/bin/__tests__/bake.test.d.ts.map +0 -1
- package/bin/__tests__/bake.test.js +0 -175
- package/bin/__tests__/bake.test.js.map +0 -1
- package/bin/__tests__/cli.test.d.ts +0 -2
- package/bin/__tests__/cli.test.d.ts.map +0 -1
- package/bin/__tests__/cli.test.js +0 -222
- package/bin/__tests__/cli.test.js.map +0 -1
- package/bin/__tests__/configcat.test.d.ts +0 -2
- package/bin/__tests__/configcat.test.d.ts.map +0 -1
- package/bin/__tests__/configcat.test.js +0 -100
- package/bin/__tests__/configcat.test.js.map +0 -1
- package/bin/__tests__/create.test.d.ts +0 -2
- package/bin/__tests__/create.test.d.ts.map +0 -1
- package/bin/__tests__/create.test.js +0 -264
- package/bin/__tests__/create.test.js.map +0 -1
- package/bin/__tests__/deploy.test.d.ts +0 -2
- package/bin/__tests__/deploy.test.d.ts.map +0 -1
- package/bin/__tests__/deploy.test.js +0 -95
- package/bin/__tests__/deploy.test.js.map +0 -1
- package/bin/__tests__/destroy.test.d.ts +0 -2
- package/bin/__tests__/destroy.test.d.ts.map +0 -1
- package/bin/__tests__/destroy.test.js +0 -44
- package/bin/__tests__/destroy.test.js.map +0 -1
- package/bin/__tests__/drain.test.d.ts +0 -2
- package/bin/__tests__/drain.test.d.ts.map +0 -1
- package/bin/__tests__/drain.test.js +0 -35
- package/bin/__tests__/drain.test.js.map +0 -1
- package/bin/__tests__/faucet.test.d.ts +0 -2
- package/bin/__tests__/faucet.test.d.ts.map +0 -1
- package/bin/__tests__/faucet.test.js +0 -31
- package/bin/__tests__/faucet.test.js.map +0 -1
- package/bin/__tests__/fetch.test.d.ts +0 -2
- package/bin/__tests__/fetch.test.d.ts.map +0 -1
- package/bin/__tests__/fetch.test.js +0 -54
- package/bin/__tests__/fetch.test.js.map +0 -1
- package/bin/__tests__/genKeys.test.d.ts +0 -2
- package/bin/__tests__/genKeys.test.d.ts.map +0 -1
- package/bin/__tests__/genKeys.test.js +0 -17
- package/bin/__tests__/genKeys.test.js.map +0 -1
- package/bin/__tests__/get.test.d.ts +0 -2
- package/bin/__tests__/get.test.d.ts.map +0 -1
- package/bin/__tests__/get.test.js +0 -133
- package/bin/__tests__/get.test.js.map +0 -1
- package/bin/__tests__/getAPIUserTokens.test.d.ts +0 -2
- package/bin/__tests__/getAPIUserTokens.test.d.ts.map +0 -1
- package/bin/__tests__/getAPIUserTokens.test.js +0 -69
- package/bin/__tests__/getAPIUserTokens.test.js.map +0 -1
- package/bin/__tests__/getAuthToken.test.d.ts +0 -2
- package/bin/__tests__/getAuthToken.test.d.ts.map +0 -1
- package/bin/__tests__/getAuthToken.test.js +0 -31
- package/bin/__tests__/getAuthToken.test.js.map +0 -1
- package/bin/__tests__/getCertFromPFX.test.d.ts +0 -2
- package/bin/__tests__/getCertFromPFX.test.d.ts.map +0 -1
- package/bin/__tests__/getCertFromPFX.test.js +0 -54
- package/bin/__tests__/getCertFromPFX.test.js.map +0 -1
- package/bin/__tests__/getMVInstances.test.d.ts +0 -2
- package/bin/__tests__/getMVInstances.test.d.ts.map +0 -1
- package/bin/__tests__/getMVInstances.test.js +0 -72
- package/bin/__tests__/getMVInstances.test.js.map +0 -1
- package/bin/__tests__/getSeeds.test.d.ts +0 -2
- package/bin/__tests__/getSeeds.test.d.ts.map +0 -1
- package/bin/__tests__/getSeeds.test.js +0 -20
- package/bin/__tests__/getSeeds.test.js.map +0 -1
- package/bin/__tests__/getUserID.test.d.ts +0 -2
- package/bin/__tests__/getUserID.test.d.ts.map +0 -1
- package/bin/__tests__/getUserID.test.js +0 -31
- package/bin/__tests__/getUserID.test.js.map +0 -1
- package/bin/__tests__/initCompartment.test.d.ts +0 -2
- package/bin/__tests__/initCompartment.test.d.ts.map +0 -1
- package/bin/__tests__/initCompartment.test.js +0 -86
- package/bin/__tests__/initCompartment.test.js.map +0 -1
- package/bin/__tests__/onboard.test.d.ts +0 -2
- package/bin/__tests__/onboard.test.d.ts.map +0 -1
- package/bin/__tests__/onboard.test.js +0 -63
- package/bin/__tests__/onboard.test.js.map +0 -1
- package/bin/__tests__/pathGateOptionsWithEnvVariables.test.d.ts +0 -2
- package/bin/__tests__/pathGateOptionsWithEnvVariables.test.d.ts.map +0 -1
- package/bin/__tests__/pathGateOptionsWithEnvVariables.test.js +0 -34
- package/bin/__tests__/pathGateOptionsWithEnvVariables.test.js.map +0 -1
- package/bin/__tests__/pledge.test.d.ts +0 -2
- package/bin/__tests__/pledge.test.d.ts.map +0 -1
- package/bin/__tests__/pledge.test.js +0 -110
- package/bin/__tests__/pledge.test.js.map +0 -1
- package/bin/__tests__/proxy.test.d.ts +0 -2
- package/bin/__tests__/proxy.test.d.ts.map +0 -1
- package/bin/__tests__/proxy.test.js +0 -22
- package/bin/__tests__/proxy.test.js.map +0 -1
- package/bin/__tests__/receive.test.d.ts +0 -2
- package/bin/__tests__/receive.test.d.ts.map +0 -1
- package/bin/__tests__/receive.test.js +0 -85
- package/bin/__tests__/receive.test.js.map +0 -1
- package/bin/__tests__/recipe.test.d.ts +0 -2
- package/bin/__tests__/recipe.test.d.ts.map +0 -1
- package/bin/__tests__/recipe.test.js +0 -41
- package/bin/__tests__/recipe.test.js.map +0 -1
- package/bin/__tests__/reject.test.d.ts +0 -2
- package/bin/__tests__/reject.test.d.ts.map +0 -1
- package/bin/__tests__/reject.test.js +0 -214
- package/bin/__tests__/reject.test.js.map +0 -1
- package/bin/__tests__/resetCompartment.test.d.ts +0 -2
- package/bin/__tests__/resetCompartment.test.d.ts.map +0 -1
- package/bin/__tests__/resetCompartment.test.js +0 -88
- package/bin/__tests__/resetCompartment.test.js.map +0 -1
- package/bin/__tests__/restoreCompartment.test.d.ts +0 -2
- package/bin/__tests__/restoreCompartment.test.d.ts.map +0 -1
- package/bin/__tests__/restoreCompartment.test.js +0 -95
- package/bin/__tests__/restoreCompartment.test.js.map +0 -1
- package/bin/__tests__/revoke.test.d.ts +0 -2
- package/bin/__tests__/revoke.test.d.ts.map +0 -1
- package/bin/__tests__/revoke.test.js +0 -62
- package/bin/__tests__/revoke.test.js.map +0 -1
- package/bin/__tests__/send.test.d.ts +0 -2
- package/bin/__tests__/send.test.d.ts.map +0 -1
- package/bin/__tests__/send.test.js +0 -216
- package/bin/__tests__/send.test.js.map +0 -1
- package/bin/__tests__/setQuorum.test.d.ts +0 -2
- package/bin/__tests__/setQuorum.test.d.ts.map +0 -1
- package/bin/__tests__/setQuorum.test.js +0 -32
- package/bin/__tests__/setQuorum.test.js.map +0 -1
- package/bin/__tests__/settle.test.d.ts +0 -2
- package/bin/__tests__/settle.test.d.ts.map +0 -1
- package/bin/__tests__/settle.test.js +0 -123
- package/bin/__tests__/settle.test.js.map +0 -1
- package/bin/__tests__/test-utils.d.ts +0 -19
- package/bin/__tests__/test-utils.d.ts.map +0 -1
- package/bin/__tests__/test-utils.js +0 -39
- package/bin/__tests__/test-utils.js.map +0 -1
- package/bin/__tests__/upgrade.test.d.ts +0 -2
- package/bin/__tests__/upgrade.test.d.ts.map +0 -1
- package/bin/__tests__/upgrade.test.js +0 -57
- package/bin/__tests__/upgrade.test.js.map +0 -1
- package/bin/__tests__/utils.test.d.ts +0 -2
- package/bin/__tests__/utils.test.d.ts.map +0 -1
- package/bin/__tests__/utils.test.js +0 -40
- package/bin/__tests__/utils.test.js.map +0 -1
- package/bin/__tests__/wipe.test.d.ts +0 -2
- package/bin/__tests__/wipe.test.d.ts.map +0 -1
- package/bin/__tests__/wipe.test.js +0 -92
- package/bin/__tests__/wipe.test.js.map +0 -1
- package/bin/cli.d.ts +0 -4
- package/bin/cli.d.ts.map +0 -1
- package/bin/cli.js +0 -152
- package/bin/cli.js.map +0 -1
- package/bin/cliOptions.d.ts +0 -8
- package/bin/cliOptions.d.ts.map +0 -1
- package/bin/cliOptions.js +0 -11
- package/bin/cliOptions.js.map +0 -1
- package/bin/commands/apdu.d.ts +0 -14
- package/bin/commands/apdu.d.ts.map +0 -1
- package/bin/commands/apdu.js +0 -35
- package/bin/commands/apdu.js.map +0 -1
- package/bin/commands/approve.d.ts +0 -34
- package/bin/commands/approve.d.ts.map +0 -1
- package/bin/commands/approve.js +0 -150
- package/bin/commands/approve.js.map +0 -1
- package/bin/commands/backupCompartment.d.ts +0 -31
- package/bin/commands/backupCompartment.d.ts.map +0 -1
- package/bin/commands/backupCompartment.js +0 -70
- package/bin/commands/backupCompartment.js.map +0 -1
- package/bin/commands/bake.d.ts +0 -73
- package/bin/commands/bake.d.ts.map +0 -1
- package/bin/commands/bake.js +0 -232
- package/bin/commands/bake.js.map +0 -1
- package/bin/commands/bridge.d.ts +0 -22
- package/bin/commands/bridge.d.ts.map +0 -1
- package/bin/commands/bridge.js +0 -137
- package/bin/commands/bridge.js.map +0 -1
- package/bin/commands/configcat.d.ts +0 -78
- package/bin/commands/configcat.d.ts.map +0 -1
- package/bin/commands/configcat.js +0 -208
- package/bin/commands/configcat.js.map +0 -1
- package/bin/commands/create.d.ts +0 -207
- package/bin/commands/create.d.ts.map +0 -1
- package/bin/commands/create.js +0 -554
- package/bin/commands/create.js.map +0 -1
- package/bin/commands/deploy.d.ts +0 -60
- package/bin/commands/deploy.d.ts.map +0 -1
- package/bin/commands/deploy.js +0 -106
- package/bin/commands/deploy.js.map +0 -1
- package/bin/commands/destroy.d.ts +0 -36
- package/bin/commands/destroy.d.ts.map +0 -1
- package/bin/commands/destroy.js +0 -58
- package/bin/commands/destroy.js.map +0 -1
- package/bin/commands/drain.d.ts +0 -26
- package/bin/commands/drain.d.ts.map +0 -1
- package/bin/commands/drain.js +0 -64
- package/bin/commands/drain.js.map +0 -1
- package/bin/commands/faucet.d.ts +0 -31
- package/bin/commands/faucet.d.ts.map +0 -1
- package/bin/commands/faucet.js +0 -68
- package/bin/commands/faucet.js.map +0 -1
- package/bin/commands/fetch.d.ts +0 -35
- package/bin/commands/fetch.d.ts.map +0 -1
- package/bin/commands/fetch.js +0 -83
- package/bin/commands/fetch.js.map +0 -1
- package/bin/commands/genKeys.d.ts +0 -14
- package/bin/commands/genKeys.d.ts.map +0 -1
- package/bin/commands/genKeys.js +0 -19
- package/bin/commands/genKeys.js.map +0 -1
- package/bin/commands/get.d.ts +0 -56
- package/bin/commands/get.d.ts.map +0 -1
- package/bin/commands/get.js +0 -211
- package/bin/commands/get.js.map +0 -1
- package/bin/commands/getAPIUserTokens.d.ts +0 -39
- package/bin/commands/getAPIUserTokens.d.ts.map +0 -1
- package/bin/commands/getAPIUserTokens.js +0 -63
- package/bin/commands/getAPIUserTokens.js.map +0 -1
- package/bin/commands/getAuthToken.d.ts +0 -26
- package/bin/commands/getAuthToken.d.ts.map +0 -1
- package/bin/commands/getAuthToken.js +0 -42
- package/bin/commands/getAuthToken.js.map +0 -1
- package/bin/commands/getMVInstances.d.ts +0 -33
- package/bin/commands/getMVInstances.d.ts.map +0 -1
- package/bin/commands/getMVInstances.js +0 -71
- package/bin/commands/getMVInstances.js.map +0 -1
- package/bin/commands/getSeeds.d.ts +0 -19
- package/bin/commands/getSeeds.d.ts.map +0 -1
- package/bin/commands/getSeeds.js +0 -95
- package/bin/commands/getSeeds.js.map +0 -1
- package/bin/commands/getUserID.d.ts +0 -27
- package/bin/commands/getUserID.d.ts.map +0 -1
- package/bin/commands/getUserID.js +0 -32
- package/bin/commands/getUserID.js.map +0 -1
- package/bin/commands/index.d.ts +0 -892
- package/bin/commands/index.d.ts.map +0 -1
- package/bin/commands/index.js +0 -111
- package/bin/commands/index.js.map +0 -1
- package/bin/commands/initCompartment.d.ts +0 -22
- package/bin/commands/initCompartment.d.ts.map +0 -1
- package/bin/commands/initCompartment.js +0 -62
- package/bin/commands/initCompartment.js.map +0 -1
- package/bin/commands/listen.d.ts +0 -31
- package/bin/commands/listen.d.ts.map +0 -1
- package/bin/commands/listen.js +0 -56
- package/bin/commands/listen.js.map +0 -1
- package/bin/commands/onboard.d.ts +0 -30
- package/bin/commands/onboard.d.ts.map +0 -1
- package/bin/commands/onboard.js +0 -68
- package/bin/commands/onboard.js.map +0 -1
- package/bin/commands/pledge.d.ts +0 -38
- package/bin/commands/pledge.d.ts.map +0 -1
- package/bin/commands/pledge.js +0 -89
- package/bin/commands/pledge.js.map +0 -1
- package/bin/commands/proxy.d.ts +0 -17
- package/bin/commands/proxy.d.ts.map +0 -1
- package/bin/commands/proxy.js +0 -227
- package/bin/commands/proxy.js.map +0 -1
- package/bin/commands/receive.d.ts +0 -40
- package/bin/commands/receive.d.ts.map +0 -1
- package/bin/commands/receive.js +0 -60
- package/bin/commands/receive.js.map +0 -1
- package/bin/commands/recipe.d.ts +0 -29
- package/bin/commands/recipe.d.ts.map +0 -1
- package/bin/commands/recipe.js +0 -62
- package/bin/commands/recipe.js.map +0 -1
- package/bin/commands/reject.d.ts +0 -49
- package/bin/commands/reject.d.ts.map +0 -1
- package/bin/commands/reject.js +0 -176
- package/bin/commands/reject.js.map +0 -1
- package/bin/commands/resetCompartment.d.ts +0 -31
- package/bin/commands/resetCompartment.d.ts.map +0 -1
- package/bin/commands/resetCompartment.js +0 -71
- package/bin/commands/resetCompartment.js.map +0 -1
- package/bin/commands/restoreCompartment.d.ts +0 -39
- package/bin/commands/restoreCompartment.d.ts.map +0 -1
- package/bin/commands/restoreCompartment.js +0 -80
- package/bin/commands/restoreCompartment.js.map +0 -1
- package/bin/commands/revoke.d.ts +0 -40
- package/bin/commands/revoke.d.ts.map +0 -1
- package/bin/commands/revoke.js +0 -80
- package/bin/commands/revoke.js.map +0 -1
- package/bin/commands/send.d.ts +0 -54
- package/bin/commands/send.d.ts.map +0 -1
- package/bin/commands/send.js +0 -170
- package/bin/commands/send.js.map +0 -1
- package/bin/commands/setQuorum.d.ts +0 -30
- package/bin/commands/setQuorum.d.ts.map +0 -1
- package/bin/commands/setQuorum.js +0 -44
- package/bin/commands/setQuorum.js.map +0 -1
- package/bin/commands/settle.d.ts +0 -43
- package/bin/commands/settle.d.ts.map +0 -1
- package/bin/commands/settle.js +0 -92
- package/bin/commands/settle.js.map +0 -1
- package/bin/commands/upgrade.d.ts +0 -44
- package/bin/commands/upgrade.d.ts.map +0 -1
- package/bin/commands/upgrade.js +0 -68
- package/bin/commands/upgrade.js.map +0 -1
- package/bin/commands/wipe.d.ts +0 -77
- package/bin/commands/wipe.d.ts.map +0 -1
- package/bin/commands/wipe.js +0 -86
- package/bin/commands/wipe.js.map +0 -1
- package/bin/deviceOption.d.ts +0 -9
- package/bin/deviceOption.d.ts.map +0 -1
- package/bin/deviceOption.js +0 -10
- package/bin/deviceOption.js.map +0 -1
- package/bin/gateOptions.d.ts +0 -39
- package/bin/gateOptions.d.ts.map +0 -1
- package/bin/gateOptions.js +0 -73
- package/bin/gateOptions.js.map +0 -1
- package/bin/getCertFromPFX.d.ts +0 -7
- package/bin/getCertFromPFX.d.ts.map +0 -1
- package/bin/getCertFromPFX.js +0 -43
- package/bin/getCertFromPFX.js.map +0 -1
- package/bin/index.d.ts +0 -3
- package/bin/index.d.ts.map +0 -1
- package/bin/lamOptions.d.ts +0 -15
- package/bin/lamOptions.d.ts.map +0 -1
- package/bin/lamOptions.js +0 -17
- package/bin/lamOptions.js.map +0 -1
- package/bin/logger.d.ts +0 -3
- package/bin/logger.d.ts.map +0 -1
- package/bin/logger.js +0 -5
- package/bin/logger.js.map +0 -1
- package/bin/manifests/beatles.json +0 -46
- package/bin/manifests/empty.json +0 -1
- package/bin/manifests/erc20.json +0 -32
- package/bin/manifests/message-signing.json +0 -36
- package/bin/manifests/mobile.json +0 -43
- package/bin/manifests/polkadot-staking.json +0 -152
- package/bin/manifests/polkadot.json +0 -37
- package/bin/manifests/rawsigning.json +0 -39
- package/bin/manifests/ripple.json +0 -37
- package/bin/manifests/sci.json +0 -146
- package/bin/manifests/solana-dev.json +0 -99
- package/bin/manifests/solana-staking.json +0 -44
- package/bin/manifests/solana.json +0 -30
- package/bin/manifests/stellar.json +0 -37
- package/bin/manifests/tezos.json +0 -51
- package/bin/manifests/tradelink-hsm.json +0 -429
- package/bin/manifests/tradelink.json +0 -361
- package/bin/miscOptions.d.ts +0 -20
- package/bin/miscOptions.d.ts.map +0 -1
- package/bin/miscOptions.js +0 -17
- package/bin/miscOptions.js.map +0 -1
- package/bin/registerTransports.d.ts +0 -2
- package/bin/registerTransports.d.ts.map +0 -1
- package/bin/registerTransports.js +0 -18
- package/bin/registerTransports.js.map +0 -1
- package/bin/types.d.ts +0 -23
- package/bin/types.d.ts.map +0 -1
- package/bin/types.js +0 -3
- package/bin/types.js.map +0 -1
- package/bin/utils.d.ts +0 -22
- package/bin/utils.d.ts.map +0 -1
- package/bin/utils.js +0 -156
- package/bin/utils.js.map +0 -1
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const vault_common_1 = require("@ledgerhq/vault-common");
|
|
16
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
17
|
-
const command_line_usage_1 = __importDefault(require("command-line-usage"));
|
|
18
|
-
const cli_1 = __importDefault(require("../cli"));
|
|
19
|
-
const logger_1 = __importDefault(require("../logger"));
|
|
20
|
-
const test_utils_1 = require("./test-utils");
|
|
21
|
-
jest.mock("../commands/get");
|
|
22
|
-
const buildCommand = (str) => {
|
|
23
|
-
const els = str.match(/(".*?"|[^"\s]+)+(?=\s*|\s*$)/g);
|
|
24
|
-
return (els || []).map((el) => el.replace(/^"/g, "").replace(/"$/g, ""));
|
|
25
|
-
};
|
|
26
|
-
afterEach(() => {
|
|
27
|
-
jest.clearAllMocks();
|
|
28
|
-
});
|
|
29
|
-
describe("Create commands", () => {
|
|
30
|
-
const pool = (0, test_utils_1.createTestDevicesPool)();
|
|
31
|
-
const testCreateCommand = (desc, command, manifest) => {
|
|
32
|
-
it(desc, () => __awaiter(void 0, void 0, void 0, function* () {
|
|
33
|
-
const argv = buildCommand(command);
|
|
34
|
-
yield (0, cli_1.default)(argv);
|
|
35
|
-
expect(vault_common_1.bakeManifest).toHaveBeenCalledWith(manifest, pool, {
|
|
36
|
-
noApproval: undefined,
|
|
37
|
-
logger: logger_1.default,
|
|
38
|
-
});
|
|
39
|
-
}));
|
|
40
|
-
};
|
|
41
|
-
const testErrorCommand = (desc, command, errorMsg) => {
|
|
42
|
-
it(desc, () => __awaiter(void 0, void 0, void 0, function* () {
|
|
43
|
-
const argv = buildCommand(command);
|
|
44
|
-
let err;
|
|
45
|
-
try {
|
|
46
|
-
yield (0, cli_1.default)(argv);
|
|
47
|
-
}
|
|
48
|
-
catch (e) {
|
|
49
|
-
err = e;
|
|
50
|
-
}
|
|
51
|
-
expect(err).toEqual(new Error(errorMsg));
|
|
52
|
-
}));
|
|
53
|
-
};
|
|
54
|
-
it("should display CLI version", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
55
|
-
const spyConsole = jest.spyOn(console, "log").mockImplementation();
|
|
56
|
-
const argv = buildCommand("--version");
|
|
57
|
-
yield (0, cli_1.default)(argv);
|
|
58
|
-
const { version } = require("../../package.json");
|
|
59
|
-
expect(spyConsole).toHaveBeenCalledWith(version);
|
|
60
|
-
spyConsole.mockRestore();
|
|
61
|
-
}));
|
|
62
|
-
it('should set process.env.DEBUG = "1" if debug option is specified', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
63
|
-
const argv = buildCommand("create user --name Ringo --device lam --debug");
|
|
64
|
-
yield (0, cli_1.default)(argv);
|
|
65
|
-
expect(process.env.DEBUG).toBe("1");
|
|
66
|
-
}));
|
|
67
|
-
it("should process.exit(1) if a required option is not specified", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
68
|
-
const spyConsole = jest.spyOn(console, "log").mockImplementation();
|
|
69
|
-
const spyProcess = jest.spyOn(process, "exit").mockImplementation();
|
|
70
|
-
const argv = buildCommand("create user --role operator --device lam");
|
|
71
|
-
yield (0, cli_1.default)(argv);
|
|
72
|
-
expect(spyProcess).toHaveBeenCalledWith(1);
|
|
73
|
-
expect(spyConsole).toHaveBeenCalledWith((0, chalk_1.default) `{red.bold ERROR} {red missing required option --name}`);
|
|
74
|
-
jest.restoreAllMocks();
|
|
75
|
-
}));
|
|
76
|
-
describe("help", () => {
|
|
77
|
-
it("should display help for unknown subcommand", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
78
|
-
const spyConsole = jest.spyOn(console, "log").mockImplementation();
|
|
79
|
-
const argv = buildCommand("create manager");
|
|
80
|
-
yield (0, cli_1.default)(argv);
|
|
81
|
-
expect(spyConsole).toHaveBeenCalledWith("helper text");
|
|
82
|
-
expect(command_line_usage_1.default).toHaveBeenCalledTimes(1);
|
|
83
|
-
spyConsole.mockRestore();
|
|
84
|
-
}));
|
|
85
|
-
});
|
|
86
|
-
describe("user creation", () => {
|
|
87
|
-
testCreateCommand("should create properly an operator", "create user --role operator --name Ringo --device 10", {
|
|
88
|
-
customUsernames: {
|
|
89
|
-
10: "Ringo",
|
|
90
|
-
},
|
|
91
|
-
users: {
|
|
92
|
-
operators: [10],
|
|
93
|
-
},
|
|
94
|
-
});
|
|
95
|
-
testCreateCommand("should create properly an LAM api operator", "create user --name Ringo --device lam", {
|
|
96
|
-
users: {
|
|
97
|
-
api: ["Ringo"],
|
|
98
|
-
},
|
|
99
|
-
});
|
|
100
|
-
testCreateCommand("should create properly an API v2 operator", "create user --name Ringo --device api --publicKey 04a7629e22eaeeccddf13349a0a88fd401d31e2275c53e4acb526f56510f80a5db82dd52d10c5720779c3d065eaca87c75e0cabbfd2cf9eddd3202d1563db97177", {
|
|
101
|
-
users: {
|
|
102
|
-
apiV2: [
|
|
103
|
-
{
|
|
104
|
-
name: "Ringo",
|
|
105
|
-
publicKey: "04a7629e22eaeeccddf13349a0a88fd401d31e2275c53e4acb526f56510f80a5db82dd52d10c5720779c3d065eaca87c75e0cabbfd2cf9eddd3202d1563db97177",
|
|
106
|
-
role: "operator",
|
|
107
|
-
},
|
|
108
|
-
],
|
|
109
|
-
},
|
|
110
|
-
});
|
|
111
|
-
testCreateCommand("should create properly an API v2 admin", "create user --name Ringo --device api --publicKey 04a7629e22eaeeccddf13349a0a88fd401d31e2275c53e4acb526f56510f80a5db82dd52d10c5720779c3d065eaca87c75e0cabbfd2cf9eddd3202d1563db97177 --role admin", {
|
|
112
|
-
users: {
|
|
113
|
-
apiV2: [
|
|
114
|
-
{
|
|
115
|
-
name: "Ringo",
|
|
116
|
-
publicKey: "04a7629e22eaeeccddf13349a0a88fd401d31e2275c53e4acb526f56510f80a5db82dd52d10c5720779c3d065eaca87c75e0cabbfd2cf9eddd3202d1563db97177",
|
|
117
|
-
role: "admin",
|
|
118
|
-
},
|
|
119
|
-
],
|
|
120
|
-
},
|
|
121
|
-
});
|
|
122
|
-
testCreateCommand("should create properly an admin", "create user --role admin --name Ringo --device 10", {
|
|
123
|
-
customUsernames: {
|
|
124
|
-
10: "Ringo",
|
|
125
|
-
},
|
|
126
|
-
users: {
|
|
127
|
-
admins: [10],
|
|
128
|
-
},
|
|
129
|
-
});
|
|
130
|
-
testErrorCommand("should throw if no role given to regular user", "create user --name foo --device 12", "`role` option is required when creating regular (non-API) user");
|
|
131
|
-
testErrorCommand("should throw if invalid device", "create user --name foo --device croquignolesque", `Invalid value "croquignolesque" for device, must be either "lam", "api" or a number`);
|
|
132
|
-
testErrorCommand("should throw if invalid role", "create user --name b --device 12 --role cook", "invalid role `cook`");
|
|
133
|
-
});
|
|
134
|
-
describe("whitelist creation", () => {
|
|
135
|
-
testCreateCommand("should create properly a whitelist", "create whitelist --name White --addresses bitcoin|name|mmizX66rU546AD6A5BBd7qKoyBKBwJWD4h", {
|
|
136
|
-
whitelists: [
|
|
137
|
-
{
|
|
138
|
-
name: "White",
|
|
139
|
-
addresses: [
|
|
140
|
-
{
|
|
141
|
-
address: "mmizX66rU546AD6A5BBd7qKoyBKBwJWD4h",
|
|
142
|
-
name: "name",
|
|
143
|
-
currency: "bitcoin",
|
|
144
|
-
},
|
|
145
|
-
],
|
|
146
|
-
},
|
|
147
|
-
],
|
|
148
|
-
});
|
|
149
|
-
testCreateCommand("should handle XRP dest tags in whitelist creation", `create whitelist --name "my wl" --addresses "ripple|super name|r4GBuaRNykmkg5kZkVxnsERBVcJjYNb7Hx|[123,456,789]"`, {
|
|
150
|
-
whitelists: [
|
|
151
|
-
{
|
|
152
|
-
name: "my wl",
|
|
153
|
-
addresses: [
|
|
154
|
-
{
|
|
155
|
-
address: "r4GBuaRNykmkg5kZkVxnsERBVcJjYNb7Hx",
|
|
156
|
-
name: "super name",
|
|
157
|
-
currency: "ripple",
|
|
158
|
-
destination_tags: [123, 456, 789],
|
|
159
|
-
},
|
|
160
|
-
],
|
|
161
|
-
},
|
|
162
|
-
],
|
|
163
|
-
});
|
|
164
|
-
});
|
|
165
|
-
describe("group creation", () => {
|
|
166
|
-
testCreateCommand("should create properly a group", "create group --name test --users 13,14", {
|
|
167
|
-
groups: [
|
|
168
|
-
{
|
|
169
|
-
name: "test",
|
|
170
|
-
users: [13, 14],
|
|
171
|
-
},
|
|
172
|
-
],
|
|
173
|
-
});
|
|
174
|
-
testCreateCommand("should create properly a group with LAM or API v2 users", "create group --name test --users 13,yass", {
|
|
175
|
-
groups: [
|
|
176
|
-
{
|
|
177
|
-
name: "test",
|
|
178
|
-
users: [13, "yass"],
|
|
179
|
-
},
|
|
180
|
-
],
|
|
181
|
-
});
|
|
182
|
-
});
|
|
183
|
-
describe("account creation", () => {
|
|
184
|
-
const rules = [
|
|
185
|
-
[
|
|
186
|
-
{
|
|
187
|
-
type: "MULTI_AUTHORIZATIONS",
|
|
188
|
-
steps: [{ quorum: 1, group: "Beatles" }],
|
|
189
|
-
},
|
|
190
|
-
],
|
|
191
|
-
];
|
|
192
|
-
testCreateCommand("should create properly a account with no rules", "create account --name btc --currency bitcoin_testnet --derivationMode native_segwit", {
|
|
193
|
-
accounts: [
|
|
194
|
-
{
|
|
195
|
-
name: "btc",
|
|
196
|
-
currency: "bitcoin_testnet",
|
|
197
|
-
derivationMode: "native_segwit",
|
|
198
|
-
},
|
|
199
|
-
],
|
|
200
|
-
});
|
|
201
|
-
testCreateCommand("should create an account with 1 rule", `create account --name btc --currency bitcoin_testnet --rules ${JSON.stringify(rules)}`, {
|
|
202
|
-
accounts: [
|
|
203
|
-
{
|
|
204
|
-
name: "btc",
|
|
205
|
-
currency: "bitcoin_testnet",
|
|
206
|
-
rules,
|
|
207
|
-
},
|
|
208
|
-
],
|
|
209
|
-
});
|
|
210
|
-
});
|
|
211
|
-
describe("entity creation", () => {
|
|
212
|
-
testCreateCommand("should create properly an entity", "create entity --name foo --accounts bar,baz", {
|
|
213
|
-
entities: [
|
|
214
|
-
{
|
|
215
|
-
name: "foo",
|
|
216
|
-
accounts: ["bar", "baz"],
|
|
217
|
-
},
|
|
218
|
-
],
|
|
219
|
-
});
|
|
220
|
-
});
|
|
221
|
-
});
|
|
222
|
-
//# sourceMappingURL=cli.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cli.test.js","sourceRoot":"","sources":["../../src/__tests__/cli.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,yDAAsD;AAEtD,kDAA0B;AAC1B,4EAAkD;AAElD,iDAAyB;AACzB,uDAA+B;AAC/B,6CAAqD;AAErD,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;AAE7B,MAAM,YAAY,GAAG,CAAC,GAAW,EAAE,EAAE;IAEnC,MAAM,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;IACvD,OAAO,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC;AAC3E,CAAC,CAAC;AAEF,SAAS,CAAC,GAAG,EAAE;IACb,IAAI,CAAC,aAAa,EAAE,CAAC;AACvB,CAA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;SACF,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAChC,MAAM,KAAK,GAA4B;YACrC;gBACE;oBACE,IAAI,EAAE,sBAAsB;oBAC5B,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;iBACzC;aACF;SACF,CAAC;QACF,iBAAiB,CACf,gDAAgD,EAChD,qFAAqF,EACrF;YACE,QAAQ,EAAE;gBACR;oBACE,IAAI,EAAE,KAAK;oBACX,QAAQ,EAAE,iBAAiB;oBAC3B,cAAc,EAAE,eAAe;iBAChC;aACF;SACF,CACF,CAAC;QAEF,iBAAiB,CACf,sCAAsC,EACtC,gEAAgE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,EACvF;YACE,QAAQ,EAAE;gBACR;oBACE,IAAI,EAAE,KAAK;oBACX,QAAQ,EAAE,iBAAiB;oBAC3B,KAAK;iBACN;aACF;SACF,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;QAC/B,iBAAiB,CACf,kCAAkC,EAClC,6CAA6C,EAC7C;YACE,QAAQ,EAAE;gBACR;oBACE,IAAI,EAAE,KAAK;oBACX,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC;iBACzB;aACF;SACF,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"configcat.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/configcat.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const configcat_1 = require("../commands/configcat");
|
|
13
|
-
describe("configcat", () => {
|
|
14
|
-
const OLD_ENV = process.env;
|
|
15
|
-
beforeAll(() => {
|
|
16
|
-
process.env = Object.assign(Object.assign({}, OLD_ENV), { CONFIGCAT_SBX_PRODUCT_ID: "123", CONFIGCAT_SBX_CONFIG_ID: "123", CONFIGCAT_STG_PRODUCT_ID: "123", CONFIGCAT_STG_CONFIG_ID: "123", CONFIGCAT_PPR_PRODUCT_ID: "123", CONFIGCAT_PPR_CONFIG_ID: "123" });
|
|
17
|
-
});
|
|
18
|
-
afterAll(() => {
|
|
19
|
-
process.env = OLD_ENV;
|
|
20
|
-
});
|
|
21
|
-
const missingConfig = {
|
|
22
|
-
env: "foo",
|
|
23
|
-
sbx: false,
|
|
24
|
-
stg: false,
|
|
25
|
-
ppr: false,
|
|
26
|
-
data: null,
|
|
27
|
-
apiKey: null,
|
|
28
|
-
productId: null,
|
|
29
|
-
configId: null,
|
|
30
|
-
};
|
|
31
|
-
const badApiKeyOnPpr = {
|
|
32
|
-
env: "foo",
|
|
33
|
-
sbx: false,
|
|
34
|
-
stg: false,
|
|
35
|
-
ppr: true,
|
|
36
|
-
data: '{"bar": true}',
|
|
37
|
-
apiKey: "bad api key",
|
|
38
|
-
productId: null,
|
|
39
|
-
configId: null,
|
|
40
|
-
};
|
|
41
|
-
const badApiKeyOnStg = {
|
|
42
|
-
env: "foo",
|
|
43
|
-
sbx: false,
|
|
44
|
-
stg: true,
|
|
45
|
-
ppr: false,
|
|
46
|
-
data: '{"bar": true}',
|
|
47
|
-
apiKey: "bad api key",
|
|
48
|
-
productId: null,
|
|
49
|
-
configId: null,
|
|
50
|
-
};
|
|
51
|
-
const badApiKeyOnSbx = {
|
|
52
|
-
env: "foo",
|
|
53
|
-
sbx: true,
|
|
54
|
-
stg: false,
|
|
55
|
-
ppr: false,
|
|
56
|
-
data: '{"bar": true}',
|
|
57
|
-
apiKey: "bad api key",
|
|
58
|
-
productId: null,
|
|
59
|
-
configId: null,
|
|
60
|
-
};
|
|
61
|
-
const badApiKey = {
|
|
62
|
-
env: "foo",
|
|
63
|
-
sbx: false,
|
|
64
|
-
stg: false,
|
|
65
|
-
ppr: false,
|
|
66
|
-
data: '{"bar": true}',
|
|
67
|
-
apiKey: "bad api key",
|
|
68
|
-
productId: "123",
|
|
69
|
-
configId: "123",
|
|
70
|
-
};
|
|
71
|
-
const missingConfigMessage = "One of ConfigCat data (apiKey, productId or configId) is missing. Please use --help to know about relevant env variables or CLI options.";
|
|
72
|
-
const badApiKeyMessage = "";
|
|
73
|
-
const params = [
|
|
74
|
-
{ config: missingConfig, errorMessage: missingConfigMessage },
|
|
75
|
-
{ config: badApiKeyOnPpr, errorMessage: badApiKeyMessage },
|
|
76
|
-
{ config: badApiKeyOnStg, errorMessage: badApiKeyMessage },
|
|
77
|
-
{ config: badApiKeyOnSbx, errorMessage: badApiKeyMessage },
|
|
78
|
-
{ config: badApiKey, errorMessage: badApiKeyMessage },
|
|
79
|
-
];
|
|
80
|
-
describe("create", () => {
|
|
81
|
-
it.each(params)("should throw an error because of bad config", ({ config, errorMessage }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
82
|
-
yield expect((0, configcat_1.configCatCreate)(config)).rejects.toThrowError(errorMessage);
|
|
83
|
-
}));
|
|
84
|
-
});
|
|
85
|
-
describe("setFlags", () => {
|
|
86
|
-
it.each(params)("should throw an error because of bad config", ({ config, errorMessage }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
87
|
-
yield expect((0, configcat_1.configCatSetFlags)(config)).rejects.toThrowError(errorMessage);
|
|
88
|
-
}));
|
|
89
|
-
it("should throw an error because of bad data", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
90
|
-
const config = Object.assign(Object.assign({}, badApiKey), { data: "bad JSON {} data" });
|
|
91
|
-
yield expect((0, configcat_1.configCatSetFlags)(config)).rejects.toThrowError("Invalid JSON input for feature flags data");
|
|
92
|
-
}));
|
|
93
|
-
});
|
|
94
|
-
describe("delete", () => {
|
|
95
|
-
it.each(params)("should throw an error because of bad config", ({ config, errorMessage }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
96
|
-
yield expect((0, configcat_1.configCatDelete)(config)).rejects.toThrowError(errorMessage);
|
|
97
|
-
}));
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
//# sourceMappingURL=configcat.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"configcat.test.js","sourceRoot":"","sources":["../../src/__tests__/configcat.test.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,qDAK+B;AAE/B,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACzB,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC;IAE5B,SAAS,CAAC,GAAG,EAAE;QACb,OAAO,CAAC,GAAG,mCACN,OAAO,KACV,wBAAwB,EAAE,KAAK,EAC/B,uBAAuB,EAAE,KAAK,EAC9B,wBAAwB,EAAE,KAAK,EAC/B,uBAAuB,EAAE,KAAK,EAC9B,wBAAwB,EAAE,KAAK,EAC/B,uBAAuB,EAAE,KAAK,GAC/B,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,GAAG,EAAE;QACZ,OAAO,CAAC,GAAG,GAAG,OAAO,CAAC;IACxB,CAAC,CAAC,CAAC;IAEH,MAAM,aAAa,GAAqB;QACtC,GAAG,EAAE,KAAK;QACV,GAAG,EAAE,KAAK;QACV,GAAG,EAA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7C,CAAO,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE,EAAE;YACjC,MAAM,MAAM,CAAC,IAAA,2BAAe,EAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;QAC3E,CAAC,CAAA,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/create.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,264 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const vault_common_1 = require("@ledgerhq/vault-common");
|
|
16
|
-
const create_1 = require("../commands/create");
|
|
17
|
-
const logger_1 = __importDefault(require("../logger"));
|
|
18
|
-
const test_utils_1 = require("./test-utils");
|
|
19
|
-
const opts = {
|
|
20
|
-
name: "<accountName>",
|
|
21
|
-
command: "account",
|
|
22
|
-
salt: "",
|
|
23
|
-
gate: "<gate>",
|
|
24
|
-
apiGateway: "<apigw>",
|
|
25
|
-
device: 4,
|
|
26
|
-
noApproval: true,
|
|
27
|
-
format: "table",
|
|
28
|
-
};
|
|
29
|
-
describe("create", () => {
|
|
30
|
-
it("should create a whitelist with destination tags", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
31
|
-
const pool = (0, test_utils_1.createTestDevicesPool)();
|
|
32
|
-
const spyConsole = jest.spyOn(console, "log").mockImplementation();
|
|
33
|
-
yield (0, create_1.createEntity)(Object.assign(Object.assign({}, opts), { command: "whitelist", addresses: ["ripple|ripple-account|addr|[1234]"] }));
|
|
34
|
-
expect(vault_common_1.bakeManifest).toHaveBeenCalledWith({
|
|
35
|
-
whitelists: [
|
|
36
|
-
{
|
|
37
|
-
addresses: [
|
|
38
|
-
{
|
|
39
|
-
address: "addr",
|
|
40
|
-
currency: "ripple",
|
|
41
|
-
destination_tags: [1234],
|
|
42
|
-
name: "ripple-account",
|
|
43
|
-
},
|
|
44
|
-
],
|
|
45
|
-
name: "<accountName>",
|
|
46
|
-
status: "PENDING",
|
|
47
|
-
},
|
|
48
|
-
],
|
|
49
|
-
}, pool, { noApproval: true, logger: logger_1.default });
|
|
50
|
-
spyConsole.mockRestore();
|
|
51
|
-
}));
|
|
52
|
-
it("should create an account with accountType", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
53
|
-
const pool = (0, test_utils_1.createTestDevicesPool)();
|
|
54
|
-
const spyConsole = jest.spyOn(console, "log").mockImplementation();
|
|
55
|
-
yield (0, create_1.createEntity)(Object.assign(Object.assign({}, opts), { command: "account", currency: "cosmos", accountType: "Cosmos" }));
|
|
56
|
-
expect(vault_common_1.bakeManifest).toHaveBeenCalledWith({
|
|
57
|
-
accounts: [
|
|
58
|
-
{
|
|
59
|
-
name: "<accountName>",
|
|
60
|
-
currency: "cosmos",
|
|
61
|
-
accountType: "Cosmos",
|
|
62
|
-
status: "PENDING",
|
|
63
|
-
},
|
|
64
|
-
],
|
|
65
|
-
}, pool, { noApproval: true, logger: logger_1.default });
|
|
66
|
-
spyConsole.mockRestore();
|
|
67
|
-
}));
|
|
68
|
-
it("should create an account with NFT gallery enabled", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
69
|
-
const pool = (0, test_utils_1.createTestDevicesPool)();
|
|
70
|
-
const spyConsole = jest.spyOn(console, "log").mockImplementation();
|
|
71
|
-
yield (0, create_1.createEntity)(Object.assign(Object.assign({}, opts), { command: "account", currency: "ethereum", enableNFTGallery: true }));
|
|
72
|
-
expect(vault_common_1.bakeManifest).toHaveBeenCalledWith({
|
|
73
|
-
accounts: [
|
|
74
|
-
{
|
|
75
|
-
name: "<accountName>",
|
|
76
|
-
currency: "ethereum",
|
|
77
|
-
status: "PENDING",
|
|
78
|
-
config: {
|
|
79
|
-
nftGallery: true,
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
],
|
|
83
|
-
}, pool, { noApproval: true, logger: logger_1.default });
|
|
84
|
-
spyConsole.mockRestore();
|
|
85
|
-
}));
|
|
86
|
-
it("should create an account with specified index", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
87
|
-
const pool = (0, test_utils_1.createTestDevicesPool)();
|
|
88
|
-
const spyConsole = jest.spyOn(console, "log").mockImplementation();
|
|
89
|
-
yield (0, create_1.createEntity)(Object.assign(Object.assign({}, opts), { command: "account", currency: "ethereum", index: 10 }));
|
|
90
|
-
expect(vault_common_1.bakeManifest).toHaveBeenCalledWith({
|
|
91
|
-
accounts: [
|
|
92
|
-
{
|
|
93
|
-
name: "<accountName>",
|
|
94
|
-
currency: "ethereum",
|
|
95
|
-
index: 10,
|
|
96
|
-
status: "PENDING",
|
|
97
|
-
},
|
|
98
|
-
],
|
|
99
|
-
}, pool, { noApproval: true, logger: logger_1.default });
|
|
100
|
-
spyConsole.mockRestore();
|
|
101
|
-
}));
|
|
102
|
-
it("should create an read-only account (with xPub)", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
103
|
-
const pool = (0, test_utils_1.createTestDevicesPool)();
|
|
104
|
-
const spyConsole = jest.spyOn(console, "log").mockImplementation();
|
|
105
|
-
yield (0, create_1.createEntity)(Object.assign(Object.assign({}, opts), { command: "account", currency: "bitcoin", xpub: "xpub", chainCode: "chainCode", publicKey: "publicKey" }));
|
|
106
|
-
expect(vault_common_1.bakeManifest).toHaveBeenCalledWith({
|
|
107
|
-
accounts: [
|
|
108
|
-
{
|
|
109
|
-
name: "<accountName>",
|
|
110
|
-
currency: "bitcoin",
|
|
111
|
-
status: "PENDING",
|
|
112
|
-
readOnly: {
|
|
113
|
-
xpub: "xpub",
|
|
114
|
-
chainCode: "chainCode",
|
|
115
|
-
publicKey: "publicKey",
|
|
116
|
-
},
|
|
117
|
-
},
|
|
118
|
-
],
|
|
119
|
-
}, pool, { noApproval: true, logger: logger_1.default });
|
|
120
|
-
spyConsole.mockRestore();
|
|
121
|
-
}));
|
|
122
|
-
it("should create an account and wait for it to be active", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
123
|
-
const pool = (0, test_utils_1.createTestDevicesPool)();
|
|
124
|
-
const spyConsole = jest.spyOn(console, "log").mockImplementation();
|
|
125
|
-
yield (0, create_1.createEntity)(Object.assign(Object.assign({}, opts), { command: "account", currency: "bitcoin", waitForActive: true }));
|
|
126
|
-
expect(vault_common_1.bakeManifest).toHaveBeenCalledWith({
|
|
127
|
-
accounts: [
|
|
128
|
-
{
|
|
129
|
-
name: "<accountName>",
|
|
130
|
-
currency: "bitcoin",
|
|
131
|
-
status: "PENDING",
|
|
132
|
-
},
|
|
133
|
-
],
|
|
134
|
-
}, pool, { noApproval: true, waitForActive: true, logger: logger_1.default });
|
|
135
|
-
spyConsole.mockRestore();
|
|
136
|
-
}));
|
|
137
|
-
it("should create an exchange (without rules)", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
138
|
-
const pool = (0, test_utils_1.createTestDevicesPool)();
|
|
139
|
-
const spyConsole = jest.spyOn(console, "log").mockImplementation();
|
|
140
|
-
yield (0, create_1.createEntity)(Object.assign(Object.assign({}, opts), { noApproval: false, command: "exchange", name: "foo", platform: "binance", apiKey: "bim bam boum", apiSecret: "fooooooo" }));
|
|
141
|
-
expect(vault_common_1.bakeManifest).toHaveBeenCalledWith({
|
|
142
|
-
exchanges: [
|
|
143
|
-
{
|
|
144
|
-
name: "foo",
|
|
145
|
-
platform: "binance",
|
|
146
|
-
configuration: {
|
|
147
|
-
apiKey: "bim bam boum",
|
|
148
|
-
apiSecret: "fooooooo",
|
|
149
|
-
},
|
|
150
|
-
},
|
|
151
|
-
],
|
|
152
|
-
}, pool, { noApproval: false, logger: logger_1.default });
|
|
153
|
-
spyConsole.mockRestore();
|
|
154
|
-
}));
|
|
155
|
-
it("should create an exchange (with rules)", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
156
|
-
const pool = (0, test_utils_1.createTestDevicesPool)();
|
|
157
|
-
const spyConsole = jest.spyOn(console, "log").mockImplementation();
|
|
158
|
-
yield (0, create_1.createEntity)(Object.assign(Object.assign({}, opts), { noApproval: false, command: "exchange", name: "foo", platform: "binance", apiKey: "bim bam boum", apiSecret: "fooooooo", rules: '{ "toto": true }' }));
|
|
159
|
-
expect(vault_common_1.bakeManifest).toHaveBeenCalledWith({
|
|
160
|
-
exchanges: [
|
|
161
|
-
{
|
|
162
|
-
name: "foo",
|
|
163
|
-
platform: "binance",
|
|
164
|
-
configuration: {
|
|
165
|
-
apiKey: "bim bam boum",
|
|
166
|
-
apiSecret: "fooooooo",
|
|
167
|
-
},
|
|
168
|
-
rules: {
|
|
169
|
-
toto: true,
|
|
170
|
-
},
|
|
171
|
-
},
|
|
172
|
-
],
|
|
173
|
-
}, pool, { noApproval: false, logger: logger_1.default });
|
|
174
|
-
spyConsole.mockRestore();
|
|
175
|
-
}));
|
|
176
|
-
(0, test_utils_1.testErrorCommand)({
|
|
177
|
-
description: "should throw when trying to create read-only account without the required arguments",
|
|
178
|
-
task: create_1.createEntity,
|
|
179
|
-
options: Object.assign(Object.assign({}, opts), { command: "account", currency: "bitcoin", xpub: "bcde" }),
|
|
180
|
-
errorMessage: "xpub / publicKey / chainCode must be defined together in order to work",
|
|
181
|
-
});
|
|
182
|
-
(0, test_utils_1.testErrorCommand)({
|
|
183
|
-
description: "should throw when trying to whitelist addresses with not the right format",
|
|
184
|
-
task: create_1.createEntity,
|
|
185
|
-
options: Object.assign(Object.assign({}, opts), { command: "whitelist", addresses: ["a", "bc", "defg"] }),
|
|
186
|
-
errorMessage: "invalid address format, should be currency|name|address",
|
|
187
|
-
});
|
|
188
|
-
(0, test_utils_1.testErrorCommand)({
|
|
189
|
-
description: "should throw when trying to create an account with invalid rules format",
|
|
190
|
-
task: create_1.createEntity,
|
|
191
|
-
options: Object.assign(Object.assign({}, opts), { command: "account", rules: "rules" }),
|
|
192
|
-
errorMessage: "Invalid rules given",
|
|
193
|
-
});
|
|
194
|
-
(0, test_utils_1.testErrorCommand)({
|
|
195
|
-
description: "should throw when trying to create an account with no currency specified",
|
|
196
|
-
task: create_1.createEntity,
|
|
197
|
-
options: Object.assign(Object.assign({}, opts), { command: "account" }),
|
|
198
|
-
errorMessage: "No currency or contractAddress in account",
|
|
199
|
-
});
|
|
200
|
-
(0, test_utils_1.testErrorCommand)({
|
|
201
|
-
description: "should throw when manifest is undefined",
|
|
202
|
-
task: create_1.createEntity,
|
|
203
|
-
options: Object.assign(Object.assign({}, opts), { command: "unknown_command" }),
|
|
204
|
-
errorMessage: "Nothing to bake",
|
|
205
|
-
});
|
|
206
|
-
it("should handle json format", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
207
|
-
const pool = (0, test_utils_1.createTestDevicesPool)();
|
|
208
|
-
const spyConsole = jest.spyOn(console, "log").mockImplementation();
|
|
209
|
-
yield (0, create_1.createEntity)(Object.assign(Object.assign({}, opts), { noApproval: false, command: "exchange", name: "foo", platform: "binance", apiKey: "bim bam boum", apiSecret: "fooooooo", rules: '{ "toto": true }', format: "json" }));
|
|
210
|
-
expect(vault_common_1.bakeManifest).toHaveBeenCalledWith({
|
|
211
|
-
exchanges: [
|
|
212
|
-
{
|
|
213
|
-
name: "foo",
|
|
214
|
-
platform: "binance",
|
|
215
|
-
configuration: {
|
|
216
|
-
apiKey: "bim bam boum",
|
|
217
|
-
apiSecret: "fooooooo",
|
|
218
|
-
},
|
|
219
|
-
rules: {
|
|
220
|
-
toto: true,
|
|
221
|
-
},
|
|
222
|
-
},
|
|
223
|
-
],
|
|
224
|
-
}, pool, { noApproval: false });
|
|
225
|
-
expect(spyConsole).toHaveBeenCalledWith('{"edges":[{"node":{"id":1,"name":"Bob","username":"Bob le bricoleur","role":"Admin","user_id":"BobLeBricoleur","currency":"westend","balance":10,"status":"status","description":"description","notes":[],"type":"type","members":[]}},{"node":{"id":2,"name":"Alice","username":"Alice In Wonderland","role":"Admin","user_id":"Wonderland","currency":"westend","balance":10,"status":"status","description":"description","notes":[],"type":"CREATE_TRANSACTION","created_by":{"id":2},"members":[],"approvals_steps":[{"group":{"id":0,"name":"group","entityType":"GROUP","created_on":"created_on","created_by":{"id":0,"entityType":"USER","pub_key":"pub_key","username":"user","user_id":"id","created_on":"created_on","status":"status","role":"OPERATOR"},"status":"PENDING","is_internal":false,"members":[{"id":2}],"is_under_edit":false},"quorum":1}]}},{"node":{"id":3,"name":"Alice","username":"Alice In Wonderland","role":"Admin","user_id":"Wonderland","currency":"westend","balance":10,"status":"status","description":"description","notes":[],"type":"CREATE_TRANSACTION","created_by":{"id":2},"members":[],"approvals":[{"created_by":{"id":4,"entityType":"USER","pub_key":"pub_key","username":"user","user_id":"id","created_on":"created_on","status":"status","role":"OPERATOR"},"created_on":"created_on","type":"APPROVE","step":1}],"approvals_steps":[{"group":{"id":0,"name":"group","entityType":"GROUP","created_on":"created_on","created_by":{"id":0,"entityType":"USER","pub_key":"pub_key","username":"user","user_id":"id","created_on":"created_on","status":"status","role":"OPERATOR"},"status":"PENDING","is_internal":false,"members":[{"username":"drakoAPI"},{"id":2}],"is_under_edit":false},"quorum":2}]}},{"node":{"id":5,"name":"Alice","username":"Alice In Wonderland","role":"Admin","user_id":"Wonderland","currency":"westend","balance":10,"status":"status","description":"description","notes":[],"type":"CREATE_TRANSACTION","created_by":{"id":4,"is_api":true,"username":"drakoAPI"},"members":[],"approvals":[],"approvals_steps":[{"group":{"id":0,"name":"group","entityType":"GROUP","created_on":"created_on","created_by":{"id":0,"entityType":"USER","pub_key":"pub_key","username":"user","user_id":"id","created_on":"created_on","status":"status","role":"OPERATOR"},"status":"PENDING","is_internal":false,"members":[{"username":"drakoAPI","device_type":"API"}],"is_under_edit":false},"quorum":1}]}},{"node":{"id":6,"name":"Alice","username":"Alice In Wonderland","role":"Admin","user_id":"Wonderland","currency":"westend","balance":10,"status":"status","description":"description","notes":[],"type":"CREATE_PLEDGE_INCREMENT","created_by":{"id":4,"is_api":true,"username":"drakoAPI"},"members":[],"approvals":[],"approvals_steps":[{"group":{"id":0,"name":"group","entityType":"GROUP","created_on":"created_on","created_by":{"id":0,"entityType":"USER","pub_key":"pub_key","username":"user","user_id":"id","created_on":"created_on","status":"status","role":"OPERATOR"},"status":"PENDING","is_internal":false,"members":[{"username":"drakoAPI","device_type":"API"}],"is_under_edit":false},"quorum":1}]}},{"node":{"id":7,"name":"Alice","username":"Alice In Wonderland","role":"Admin","user_id":"Wonderland","currency":"westend","balance":10,"status":"status","description":"description","notes":[],"type":"CREATE_TRANSACTION","created_by":{"username":"drakoLAM"},"members":[],"approvals":[],"approvals_steps":[{"group":{"id":0,"name":"group","entityType":"GROUP","created_on":"created_on","created_by":{"id":0,"entityType":"USER","pub_key":"pub_key","username":"user","user_id":"id","created_on":"created_on","status":"status","role":"OPERATOR"},"status":"PENDING","is_internal":false,"members":[{"username":"drakoLAM","device_type":"SOFT_PSD"},{"id":2}],"is_under_edit":false},"quorum":1}]}},{"node":{"id":8,"name":"Alice","username":"Alice In Wonderland","role":"Admin","user_id":"Wonderland","currency":"westend","balance":10,"status":"status","description":"description","notes":[],"type":"MESSAGE_SIGNING","created_by":{"username":"drakoLAM"},"members":[],"approvals":[],"approvals_steps":[{"group":{"id":0,"name":"group","entityType":"GROUP","created_on":"created_on","created_by":{"id":0,"entityType":"USER","pub_key":"pub_key","username":"user","user_id":"id","created_on":"created_on","status":"status","role":"OPERATOR"},"status":"PENDING","is_internal":false,"members":[{"username":"drakoAPI","device_type":"API"},{"id":2}],"is_under_edit":false},"quorum":1}]}}]}');
|
|
226
|
-
spyConsole.mockRestore();
|
|
227
|
-
}));
|
|
228
|
-
it("should create a viewAll API operator", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
229
|
-
const pool = (0, test_utils_1.createTestDevicesPool)();
|
|
230
|
-
const spyConsole = jest.spyOn(console, "log").mockImplementation();
|
|
231
|
-
yield (0, create_1.createEntity)(Object.assign(Object.assign({}, opts), { command: "user", name: "foo", device: "api", viewAll: true, role: "operator" }));
|
|
232
|
-
expect(vault_common_1.bakeManifest).toHaveBeenCalledWith({
|
|
233
|
-
users: {
|
|
234
|
-
apiV2: [
|
|
235
|
-
{
|
|
236
|
-
name: "foo",
|
|
237
|
-
publicKey: undefined,
|
|
238
|
-
role: "operator",
|
|
239
|
-
viewAll: true,
|
|
240
|
-
},
|
|
241
|
-
],
|
|
242
|
-
},
|
|
243
|
-
}, pool, { noApproval: true, logger: logger_1.default });
|
|
244
|
-
spyConsole.mockRestore();
|
|
245
|
-
}));
|
|
246
|
-
it("should create a policy", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
247
|
-
const pool = (0, test_utils_1.createTestDevicesPool)();
|
|
248
|
-
const spyConsole = jest.spyOn(console, "log").mockImplementation();
|
|
249
|
-
yield (0, create_1.createEntity)(Object.assign(Object.assign({}, opts), { command: "policy", name: "My policy", currency: "bitcoin", rules: '{ "toto": true }' }));
|
|
250
|
-
expect(vault_common_1.bakeManifest).toHaveBeenCalledWith({
|
|
251
|
-
policies: [
|
|
252
|
-
{
|
|
253
|
-
name: "My policy",
|
|
254
|
-
currency: "bitcoin",
|
|
255
|
-
rules: {
|
|
256
|
-
toto: true,
|
|
257
|
-
},
|
|
258
|
-
},
|
|
259
|
-
],
|
|
260
|
-
}, pool, { noApproval: true, logger: logger_1.default });
|
|
261
|
-
spyConsole.mockRestore();
|
|
262
|
-
}));
|
|
263
|
-
});
|
|
264
|
-
//# sourceMappingURL=create.test.js.map
|