@prosopo/account 0.3.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/dist/cjs/common/dist/array.cjs +8 -0
- package/dist/cjs/common/dist/asyncFactory.cjs +13 -0
- package/dist/cjs/common/dist/custom.cjs +1 -0
- package/dist/cjs/common/dist/error.cjs +92 -0
- package/dist/cjs/common/dist/hash.cjs +14 -0
- package/dist/cjs/common/dist/i18n.cjs +29 -0
- package/dist/cjs/common/dist/index.cjs +40 -0
- package/dist/cjs/common/dist/locales/en.json.cjs +191 -0
- package/dist/cjs/common/dist/logger.cjs +91 -0
- package/dist/cjs/common/dist/node/UrlConverter.cjs +215 -0
- package/dist/cjs/common/dist/node/i18nMiddleware.cjs +8 -0
- package/dist/cjs/common/dist/node/index.cjs +4 -0
- package/dist/cjs/common/dist/react/index.cjs +4 -0
- package/dist/cjs/common/dist/react/useTranslation.cjs +8 -0
- package/dist/cjs/common/dist/string.cjs +6 -0
- package/dist/cjs/common/dist/utils.cjs +38 -0
- package/dist/cjs/extension/Extension.cjs +5 -0
- package/dist/cjs/extension/ExtensionWeb2.cjs +104 -0
- package/dist/cjs/index.cjs +6 -0
- package/dist/cjs/util/dist/canvas.cjs +326 -0
- package/dist/cjs/util/dist/index.cjs +26 -0
- package/dist/cjs/util/dist/isMain.cjs +13 -0
- package/dist/cjs/util/dist/lodash.cjs +35 -0
- package/dist/cjs/util/dist/ofLen.cjs +526 -0
- package/dist/cjs/util/dist/url.cjs +9 -0
- package/dist/cjs/util/dist/util.cjs +153 -0
- package/dist/extension/Extension.d.ts +5 -0
- package/dist/extension/Extension.d.ts.map +1 -0
- package/dist/extension/Extension.js +3 -0
- package/dist/extension/Extension.js.map +1 -0
- package/dist/extension/ExtensionWeb2.d.ts +18 -0
- package/dist/extension/ExtensionWeb2.d.ts.map +1 -0
- package/dist/extension/ExtensionWeb2.js +100 -0
- package/dist/extension/ExtensionWeb2.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/package.json +58 -0
- package/vite.cjs.config.ts +6 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const ARRAY_JOINER = "";
|
|
4
|
+
function arrayJoin(arr, joiner) {
|
|
5
|
+
return arr.join(joiner ? joiner : ARRAY_JOINER);
|
|
6
|
+
}
|
|
7
|
+
exports.ARRAY_JOINER = ARRAY_JOINER;
|
|
8
|
+
exports.arrayJoin = arrayJoin;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const error = require("./error.cjs");
|
|
4
|
+
class AsyncFactory {
|
|
5
|
+
constructor() {
|
|
6
|
+
throw new error.ProsopoEnvError("GENERAL.ASYNC_FACTORY_CREATE");
|
|
7
|
+
}
|
|
8
|
+
static async create(...args) {
|
|
9
|
+
return await Object.create(this.prototype).init(...args);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.AsyncFactory = AsyncFactory;
|
|
13
|
+
exports.default = AsyncFactory;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
require("./index.cjs");
|
|
4
|
+
const logger = require("./logger.cjs");
|
|
5
|
+
const i18n = require("i18next");
|
|
6
|
+
class ProsopoBaseError extends Error {
|
|
7
|
+
constructor(error, options) {
|
|
8
|
+
const logger$1 = options?.logger || logger.getLoggerDefault();
|
|
9
|
+
const logLevel = options?.logLevel || "error";
|
|
10
|
+
if (error instanceof Error) {
|
|
11
|
+
super(error.message);
|
|
12
|
+
this.translationKey = options?.translationKey;
|
|
13
|
+
this.context = {
|
|
14
|
+
...options?.context,
|
|
15
|
+
...options?.translationKey ? { translationMessage: i18n.t(options.translationKey) } : {}
|
|
16
|
+
};
|
|
17
|
+
} else {
|
|
18
|
+
super(i18n.t(error));
|
|
19
|
+
this.translationKey = error;
|
|
20
|
+
this.context = options?.context;
|
|
21
|
+
}
|
|
22
|
+
if (options?.silent)
|
|
23
|
+
this.logError(logger$1, logLevel);
|
|
24
|
+
}
|
|
25
|
+
logError(logger2, logLevel) {
|
|
26
|
+
const errorFormatter = "\n*************** ERROR ***************\n";
|
|
27
|
+
const errorName = `Error Type: ${this.name}
|
|
28
|
+
`;
|
|
29
|
+
const errorParams = JSON.stringify({ error: this.message, context: this.context });
|
|
30
|
+
const errorMessage = `${errorFormatter}${errorName}${errorParams}`;
|
|
31
|
+
logger2[logLevel](errorMessage);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
class ProsopoError extends ProsopoBaseError {
|
|
35
|
+
constructor(error, options) {
|
|
36
|
+
const errorName = options?.name || "ProsopoError";
|
|
37
|
+
options = { ...options, name: errorName };
|
|
38
|
+
super(error, options);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
class ProsopoEnvError extends ProsopoBaseError {
|
|
42
|
+
constructor(error, options) {
|
|
43
|
+
const errorName = options?.name || "ProsopoEnvError";
|
|
44
|
+
options = { ...options, name: errorName };
|
|
45
|
+
super(error, options);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
class ProsopoContractError extends ProsopoBaseError {
|
|
49
|
+
constructor(error, options) {
|
|
50
|
+
const errorName = options?.name || "ProsopoContractError";
|
|
51
|
+
options = { ...options, name: errorName };
|
|
52
|
+
super(error, options);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
class ProsopoDBError extends ProsopoBaseError {
|
|
56
|
+
constructor(error, options) {
|
|
57
|
+
const errorName = options?.name || "ProsopoDBError";
|
|
58
|
+
options = { ...options, name: errorName };
|
|
59
|
+
super(error, options);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
class ProsopoCliError extends ProsopoBaseError {
|
|
63
|
+
constructor(error, options) {
|
|
64
|
+
const errorName = options?.name || "ProsopoCliError";
|
|
65
|
+
options = { ...options, name: errorName };
|
|
66
|
+
super(error, options);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
class ProsopoDatasetError extends ProsopoBaseError {
|
|
70
|
+
constructor(error, options) {
|
|
71
|
+
const errorName = options?.name || "ProsopoDatasetError";
|
|
72
|
+
options = { ...options, name: errorName };
|
|
73
|
+
super(error, options);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
class ProsopoApiError extends ProsopoBaseError {
|
|
77
|
+
constructor(error, options) {
|
|
78
|
+
const errorName = options?.name || "ProsopoApiError";
|
|
79
|
+
const errorCode = options?.context?.code || 500;
|
|
80
|
+
options = { ...options, name: errorName, context: { ...options?.context, errorCode } };
|
|
81
|
+
super(error, options);
|
|
82
|
+
this.code = errorCode;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
exports.ProsopoApiError = ProsopoApiError;
|
|
86
|
+
exports.ProsopoBaseError = ProsopoBaseError;
|
|
87
|
+
exports.ProsopoCliError = ProsopoCliError;
|
|
88
|
+
exports.ProsopoContractError = ProsopoContractError;
|
|
89
|
+
exports.ProsopoDBError = ProsopoDBError;
|
|
90
|
+
exports.ProsopoDatasetError = ProsopoDatasetError;
|
|
91
|
+
exports.ProsopoEnvError = ProsopoEnvError;
|
|
92
|
+
exports.ProsopoError = ProsopoError;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const array = require("./array.cjs");
|
|
4
|
+
const blake2 = require("@polkadot/util-crypto/blake2");
|
|
5
|
+
const HEX_HASH_BIT_LENGTH = 256;
|
|
6
|
+
function hexHash(data, bitLength) {
|
|
7
|
+
return blake2.blake2AsHex(data, bitLength);
|
|
8
|
+
}
|
|
9
|
+
function hexHashArray(arr) {
|
|
10
|
+
return hexHash(array.arrayJoin(arr));
|
|
11
|
+
}
|
|
12
|
+
exports.HEX_HASH_BIT_LENGTH = HEX_HASH_BIT_LENGTH;
|
|
13
|
+
exports.hexHash = hexHash;
|
|
14
|
+
exports.hexHashArray = hexHashArray;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const i18nextHttpMiddleware = require("i18next-http-middleware");
|
|
3
|
+
const reactI18next = require("react-i18next");
|
|
4
|
+
const utils = require("./utils.cjs");
|
|
5
|
+
const Backend = require("i18next-http-backend");
|
|
6
|
+
const LanguageDetector = require("i18next-browser-languagedetector");
|
|
7
|
+
const i18n = require("i18next");
|
|
8
|
+
const en = require("./locales/en.json.cjs");
|
|
9
|
+
const commonOptions = {
|
|
10
|
+
debug: false,
|
|
11
|
+
fallbackLng: "en",
|
|
12
|
+
resources: {
|
|
13
|
+
en: {
|
|
14
|
+
translation: en.default
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
const reactOptions = {
|
|
19
|
+
react: {
|
|
20
|
+
useSuspense: false
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const nodeOptions = {};
|
|
24
|
+
if (utils.isClientSide()) {
|
|
25
|
+
i18n.use(LanguageDetector).use(reactI18next.initReactI18next).init({ ...commonOptions, ...reactOptions });
|
|
26
|
+
} else {
|
|
27
|
+
i18n.use(new Backend(void 0, { reloadInterval: false })).use(i18nextHttpMiddleware.LanguageDetector).init({ ...commonOptions, ...nodeOptions });
|
|
28
|
+
}
|
|
29
|
+
module.exports = i18n;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
require("./i18n.cjs");
|
|
4
|
+
require("./react/index.cjs");
|
|
5
|
+
require("./node/index.cjs");
|
|
6
|
+
const utils = require("./utils.cjs");
|
|
7
|
+
require("./custom.cjs");
|
|
8
|
+
const error = require("./error.cjs");
|
|
9
|
+
const logger = require("./logger.cjs");
|
|
10
|
+
const array = require("./array.cjs");
|
|
11
|
+
const hash = require("./hash.cjs");
|
|
12
|
+
const asyncFactory = require("./asyncFactory.cjs");
|
|
13
|
+
const string = require("./string.cjs");
|
|
14
|
+
const UrlConverter = require("./node/UrlConverter.cjs");
|
|
15
|
+
exports.isClientSide = utils.isClientSide;
|
|
16
|
+
exports.reverseHexString = utils.reverseHexString;
|
|
17
|
+
exports.snakeToCamelCase = utils.snakeToCamelCase;
|
|
18
|
+
exports.translationKeys = utils.translationKeys;
|
|
19
|
+
exports.trimProviderUrl = utils.trimProviderUrl;
|
|
20
|
+
exports.ProsopoApiError = error.ProsopoApiError;
|
|
21
|
+
exports.ProsopoBaseError = error.ProsopoBaseError;
|
|
22
|
+
exports.ProsopoCliError = error.ProsopoCliError;
|
|
23
|
+
exports.ProsopoContractError = error.ProsopoContractError;
|
|
24
|
+
exports.ProsopoDBError = error.ProsopoDBError;
|
|
25
|
+
exports.ProsopoDatasetError = error.ProsopoDatasetError;
|
|
26
|
+
exports.ProsopoEnvError = error.ProsopoEnvError;
|
|
27
|
+
exports.ProsopoError = error.ProsopoError;
|
|
28
|
+
exports.LogLevel = logger.LogLevel;
|
|
29
|
+
exports.Loggable = logger.Loggable;
|
|
30
|
+
exports.getLogLevel = logger.getLogLevel;
|
|
31
|
+
exports.getLogger = logger.getLogger;
|
|
32
|
+
exports.getLoggerDefault = logger.getLoggerDefault;
|
|
33
|
+
exports.ARRAY_JOINER = array.ARRAY_JOINER;
|
|
34
|
+
exports.arrayJoin = array.arrayJoin;
|
|
35
|
+
exports.HEX_HASH_BIT_LENGTH = hash.HEX_HASH_BIT_LENGTH;
|
|
36
|
+
exports.hexHash = hash.hexHash;
|
|
37
|
+
exports.hexHashArray = hash.hexHashArray;
|
|
38
|
+
exports.AsyncFactory = asyncFactory.AsyncFactory;
|
|
39
|
+
exports.capitaliseFirstLetter = string.capitaliseFirstLetter;
|
|
40
|
+
exports.UrlConverter = UrlConverter.UrlConverter;
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const WIDGET = {
|
|
4
|
+
SELECT_ALL: "Select all images containing a",
|
|
5
|
+
NEXT: "Next",
|
|
6
|
+
SUBMIT: "Submit",
|
|
7
|
+
CANCEL: "Cancel",
|
|
8
|
+
SELECT_ACCOUNT: "Select account",
|
|
9
|
+
NO_ACCOUNTS_FOUND: "No accounts found",
|
|
10
|
+
ACCOUNT_NOT_FOUND: "Account not found",
|
|
11
|
+
NO_EXTENSION_FOUND: "No extension found",
|
|
12
|
+
EXTENSION_NOT_FOUND: "Extension not found",
|
|
13
|
+
CANVAS: "Error with Captcha canvas"
|
|
14
|
+
};
|
|
15
|
+
const GENERAL = {
|
|
16
|
+
BAD_SURI: "Bad SURI",
|
|
17
|
+
CANNOT_FIND_CONFIG_FILE: "prosopo.config.js / prosopo.config.ts cannot be found.",
|
|
18
|
+
JSON_LOAD_FAILED: "Failed to load JSON file",
|
|
19
|
+
CREATE_JSON_FILE_FAILED: "Failed to create JSON file",
|
|
20
|
+
ASSERT_ERROR: "AssertionError",
|
|
21
|
+
GENERATE_CAPTCHAS_JSON_FAILED: "Something went wrong while creating captchas json file",
|
|
22
|
+
CALCULATE_CAPTCHA_SOLUTION: "Something went wrong while calculating captcha solutions",
|
|
23
|
+
MNEMONIC_UNDEFINED: "Mnemonic Undefined. Please set the mnemonic in environment variables",
|
|
24
|
+
NO_MNEMONIC_OR_SEED: "No mnemonic or seed provided",
|
|
25
|
+
ASYNC_FACTORY_CREATE: "Use `create` factory method",
|
|
26
|
+
CANT_FIND_KEYRINGPAIR: "Can't find the keyringpair for {{address}}",
|
|
27
|
+
ENVIRONMENT_NOT_READY: "Environment not ready",
|
|
28
|
+
INVALID_SIGNATURE: "Invalid signature",
|
|
29
|
+
PAIR_TYPE_UNDEFINED: "Pair type undefined",
|
|
30
|
+
NOT_IMPLEMENTED: "Not implemented",
|
|
31
|
+
NO_PAIR_TYPE_OR_SS58_FORMAT: "No pair type or ss58 format provided",
|
|
32
|
+
SITE_KEY_MISSING: "SITE KEY missing",
|
|
33
|
+
ACCOUNT_NOT_FOUND: "Account not found"
|
|
34
|
+
};
|
|
35
|
+
const CONTRACT = {
|
|
36
|
+
INVALID_METHOD: "Invalid contract method",
|
|
37
|
+
TX_ERROR: "Error making tx",
|
|
38
|
+
QUERY_ERROR: "Error making query",
|
|
39
|
+
INVALID_ADDRESS: "Failed to encode invalid address",
|
|
40
|
+
INVALID_STORAGE_NAME: "Failed to find given storage name",
|
|
41
|
+
CAPTCHA_SOLUTION_COMMITMENT_DOES_NOT_EXIST: "Captcha solution commitment does not exist",
|
|
42
|
+
DAPP_NOT_ACTIVE: "Dapp is not active",
|
|
43
|
+
CONTRACT_UNDEFINED: "Contract undefined",
|
|
44
|
+
SIGNER_UNDEFINED: "Signer undefined",
|
|
45
|
+
SIGNER_NOT_SUPPORTED: "Signer is not supported. Use connect instead, e.g. contract.connect(signer)",
|
|
46
|
+
CANNOT_FIND_KEYPAIR: "Cannot find keypair",
|
|
47
|
+
INVALID_TYPE: "Invalid type",
|
|
48
|
+
INVALID_ABI: "Invalid ABI",
|
|
49
|
+
NOT_HANDLED: "Not handled",
|
|
50
|
+
INVALID_STORAGE_TYPE: "Invalid storage type",
|
|
51
|
+
INTERRUPTED_EVENT: "Event interrupted",
|
|
52
|
+
TOO_MANY_CALLS: "Too many calls",
|
|
53
|
+
UNKNOWN_ERROR: "Unknown error",
|
|
54
|
+
CHAIN_DECIMALS_UNDEFINED: "Chain decimals are not defined",
|
|
55
|
+
INVALID_DATA_FORMAT: "Invalid data format",
|
|
56
|
+
INVALID_BLOCKHASH: "Invalid blockhash"
|
|
57
|
+
};
|
|
58
|
+
const CONFIG = {
|
|
59
|
+
UNKNOWN_ENVIRONMENT: "Unknown environment requested",
|
|
60
|
+
INVALID_CAPTCHA_NUMBER: "Please configure captchas configurations correctly",
|
|
61
|
+
CONFIGURATIONS_LOAD_FAILED: "Prosopo configurations load failed",
|
|
62
|
+
INVALID_LOG_LEVEL: "Invalid log level",
|
|
63
|
+
INVALID_PACKAGE_DIR: "Invalid package directory"
|
|
64
|
+
};
|
|
65
|
+
const DATASET = {
|
|
66
|
+
DATASET_PARSE_ERROR: "Error parsing dataset",
|
|
67
|
+
SOLUTION_PARSE_ERROR: "Error parsing dataset",
|
|
68
|
+
HASH_ERROR: "Error hashing dataset",
|
|
69
|
+
INVALID_DATASET_ID: "Invalid dataset id",
|
|
70
|
+
DATASET_ID_UNDEFINED: "Dataset id undefined",
|
|
71
|
+
NOT_ENOUGH_LABELS: "Not enough labels",
|
|
72
|
+
NOT_ENOUGH_IMAGES: "Not enough images",
|
|
73
|
+
CAPTCHAS_COUNT_LESS_THAN_CONFIGURED: "Number of captchas in dataset is less than configured number of captchas",
|
|
74
|
+
SOLUTIONS_COUNT_LESS_THAN_CONFIGURED: "Number of solutions in dataset is less than configured number of solutions",
|
|
75
|
+
DUPLICATE_IMAGE: "duplicate image detected",
|
|
76
|
+
MERKLE_ERROR: "Error creating merkle tree"
|
|
77
|
+
};
|
|
78
|
+
const DATABASE = {
|
|
79
|
+
CONNECT_ERROR: "Failed to connect",
|
|
80
|
+
DATABASE_IMPORT_FAILED: "Failed to import database engine",
|
|
81
|
+
DATABASE_UNDEFINED: "Database client is not connected",
|
|
82
|
+
DATABASE_HOST_UNDEFINED: "Database host address is not defined",
|
|
83
|
+
COLLECTION_UNDEFINED: "Database collection is not available",
|
|
84
|
+
DATASET_LOAD_FAILED: "Data set load failed",
|
|
85
|
+
DATASET_GET_FAILED: "Failed to get dataset",
|
|
86
|
+
CAPTCHA_GET_FAILED: "Failed to get captcha",
|
|
87
|
+
CAPTCHA_UPDATE_FAILED: "Failed to update captcha",
|
|
88
|
+
IMAGE_GET_FAILED: "Failed to get image",
|
|
89
|
+
NO_CAPTCHAS_FOUND: "No captcha matching datasetId",
|
|
90
|
+
PENDING_RECORD_NOT_FOUND: "No pending record found",
|
|
91
|
+
INVALID_HASH: "Invalid hash",
|
|
92
|
+
SOLUTION_GET_FAILED: "Failed to get solution",
|
|
93
|
+
DATASET_WITH_SOLUTIONS_GET_FAILED: "No datasets found with required number of solutions",
|
|
94
|
+
SOLUTION_APPROVE_FAILED: "Failed to approve solution",
|
|
95
|
+
SOLUTION_FLAG_FAILED: "Failed to flag solution as processed",
|
|
96
|
+
TABLES_UNDEFINED: "Tables undefined",
|
|
97
|
+
CONNECTION_UNDEFINED: "Connection undefined",
|
|
98
|
+
COMMITMENT_FLAG_FAILED: "Failed to flag commitment as processed"
|
|
99
|
+
};
|
|
100
|
+
const CAPTCHA = {
|
|
101
|
+
PARSE_ERROR: "Error parsing captcha",
|
|
102
|
+
INVALID_CAPTCHA_ID: "Invalid captcha id",
|
|
103
|
+
SOLUTION_HASH_ERROR: "Error hashing solution",
|
|
104
|
+
INVALID_ITEM_FORMAT: "Only image and text item types allowed",
|
|
105
|
+
INVALID_SOLUTION_TYPE: "Invalid solution type",
|
|
106
|
+
INVALID_ITEM_HASH: "Invalid item hash",
|
|
107
|
+
DIFFERENT_DATASET_IDS: "Dataset ids do not match",
|
|
108
|
+
INVALID_BLOCK_NO: "Invalid block number",
|
|
109
|
+
ID_MISMATCH: "captcha id mismatch",
|
|
110
|
+
MISSING_ITEM_HASH: "missing item hash",
|
|
111
|
+
INVALID_LEAF_HASH: "Invalid leaf hash",
|
|
112
|
+
INVALID_CAPTCHA_CHALLENGE: "Invalid captcha challenge",
|
|
113
|
+
INVALID_DATASET_CONTENT_ID: "Invalid dataset content id",
|
|
114
|
+
DAPP_USER_SOLUTION_NOT_FOUND: "Dapp user solution not found",
|
|
115
|
+
INVALID_PROVIDER_URL: "Invalid provider url",
|
|
116
|
+
NO_CAPTCHA: "No captcha found"
|
|
117
|
+
};
|
|
118
|
+
const API = {
|
|
119
|
+
BODY_UNDEFINED: "Body must be defined in API POST call",
|
|
120
|
+
PARAMETER_UNDEFINED: "Parameters must be defined in API POST call",
|
|
121
|
+
CAPTCHA_FAILED: "You answered one or more captchas incorrectly. Please try again",
|
|
122
|
+
CAPTCHA_PENDING: "Captcha solutions submitted and awaiting approval",
|
|
123
|
+
CAPTCHA_PASSED: "You correctly answered the captchas",
|
|
124
|
+
BAD_REQUEST: "BadRequest",
|
|
125
|
+
PAYMENT_INFO_NOT_FOUND: "Payment info not found for given block and transaction hashes",
|
|
126
|
+
USER_VERIFIED: "User verified",
|
|
127
|
+
USER_NOT_VERIFIED: "User not verified",
|
|
128
|
+
UNKNOWN: "Unknown API error"
|
|
129
|
+
};
|
|
130
|
+
const CLI = {
|
|
131
|
+
PARAMETER_ERROR: "Invalid parameter"
|
|
132
|
+
};
|
|
133
|
+
const DEVELOPER = {
|
|
134
|
+
PROSOPO_SITE_KEY_MISSING: "PROSOPO_SITE_KEY is not set in .env file.",
|
|
135
|
+
BALANCE_TOO_LOW: "{{mnemonic}} balance too low: {{balance}}",
|
|
136
|
+
CAPTCHA_ID_MISSING: "Cannot find captcha data id",
|
|
137
|
+
COMMITMENT_ID_MISSING: "Commitment id missing",
|
|
138
|
+
PROVIDER_NOT_FOUND: "Provider not found",
|
|
139
|
+
PROVIDER_NO_CAPTCHA: "No captchas returned from provider",
|
|
140
|
+
CREATE_ACCOUNT_FAILED: "Could not create an account!",
|
|
141
|
+
CREATE_ACCOUNT_FAILED_OUT_OF_FUNDS: "Could not create an account as there are no funds. Restart the substrate node.",
|
|
142
|
+
NO_MOCK_ENV: "MockEnvironment not set up",
|
|
143
|
+
ACCOUNT_TYPE_MISSING: "{{accountType}} not created by databasePopulator",
|
|
144
|
+
FUNDING_FAILED: "Funding failed",
|
|
145
|
+
MISSING_PROVIDER_PAIR: "Missing provider pair",
|
|
146
|
+
NETWORK_NOT_FOUND: "Network not found",
|
|
147
|
+
MISSING_ENV_VARIABLE: "Missing environment variable",
|
|
148
|
+
GENERAL: "General Dev Error, see context",
|
|
149
|
+
MISSING_SECRET_KEY: "Missing secret key",
|
|
150
|
+
KEY_ERROR: "Key error",
|
|
151
|
+
METHOD_NOT_IMPLEMENTED: "Method not implemented"
|
|
152
|
+
};
|
|
153
|
+
const FS = {
|
|
154
|
+
DIRECTORY_NOT_FOUND: "Directory not found",
|
|
155
|
+
FILE_NOT_FOUND: "File not found",
|
|
156
|
+
FILE_ALREADY_EXISTS: "File already exists",
|
|
157
|
+
DIRECTORY_ALREADY_EXISTS: "Directory already exists",
|
|
158
|
+
SAME_FILE: "Same file",
|
|
159
|
+
INVALID_DIR_FORMAT: "Invalid directory format"
|
|
160
|
+
};
|
|
161
|
+
const PROGUI = {
|
|
162
|
+
NO_STATE_PROVIDER: "useGlobalState must be used within a GlobalStateProvider",
|
|
163
|
+
NO_POLKADOT_EXTENSION: "Polkadot extension not found"
|
|
164
|
+
};
|
|
165
|
+
const translationEn = {
|
|
166
|
+
WIDGET,
|
|
167
|
+
GENERAL,
|
|
168
|
+
CONTRACT,
|
|
169
|
+
CONFIG,
|
|
170
|
+
DATASET,
|
|
171
|
+
DATABASE,
|
|
172
|
+
CAPTCHA,
|
|
173
|
+
API,
|
|
174
|
+
CLI,
|
|
175
|
+
DEVELOPER,
|
|
176
|
+
FS,
|
|
177
|
+
PROGUI
|
|
178
|
+
};
|
|
179
|
+
exports.API = API;
|
|
180
|
+
exports.CAPTCHA = CAPTCHA;
|
|
181
|
+
exports.CLI = CLI;
|
|
182
|
+
exports.CONFIG = CONFIG;
|
|
183
|
+
exports.CONTRACT = CONTRACT;
|
|
184
|
+
exports.DATABASE = DATABASE;
|
|
185
|
+
exports.DATASET = DATASET;
|
|
186
|
+
exports.DEVELOPER = DEVELOPER;
|
|
187
|
+
exports.FS = FS;
|
|
188
|
+
exports.GENERAL = GENERAL;
|
|
189
|
+
exports.PROGUI = PROGUI;
|
|
190
|
+
exports.WIDGET = WIDGET;
|
|
191
|
+
exports.default = translationEn;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const tslib = require("tslib");
|
|
4
|
+
const consola = require("consola");
|
|
5
|
+
const error = require("./error.cjs");
|
|
6
|
+
const zod = require("zod");
|
|
7
|
+
var _Loggable_logger;
|
|
8
|
+
const LogLevel = zod.enum(["trace", "debug", "info", "warn", "error", "fatal", "log"]);
|
|
9
|
+
function getLogger(logLevel, scope) {
|
|
10
|
+
return getLoggerAdapterConsola(getLogLevel(logLevel), scope);
|
|
11
|
+
}
|
|
12
|
+
function getLoggerDefault() {
|
|
13
|
+
return defaultLogger;
|
|
14
|
+
}
|
|
15
|
+
const getLoggerAdapterConsola = (logLevel, scope) => {
|
|
16
|
+
const logger = consola.createConsola({ formatOptions: { colors: true, date: true } }).withTag(scope);
|
|
17
|
+
let currentLevel = logLevel;
|
|
18
|
+
const result = {
|
|
19
|
+
log: logger.log,
|
|
20
|
+
info: logger.info,
|
|
21
|
+
debug: logger.debug,
|
|
22
|
+
trace: logger.trace,
|
|
23
|
+
warn: logger.warn,
|
|
24
|
+
error: logger.error,
|
|
25
|
+
fatal: logger.fatal,
|
|
26
|
+
setLogLevel: (level) => {
|
|
27
|
+
let logLevel2 = NaN;
|
|
28
|
+
level = getLogLevel(level);
|
|
29
|
+
switch (level) {
|
|
30
|
+
case LogLevel.enum.trace:
|
|
31
|
+
logLevel2 = consola.LogLevels.trace;
|
|
32
|
+
break;
|
|
33
|
+
case LogLevel.enum.debug:
|
|
34
|
+
logLevel2 = consola.LogLevels.debug;
|
|
35
|
+
break;
|
|
36
|
+
case LogLevel.enum.info:
|
|
37
|
+
logLevel2 = consola.LogLevels.info;
|
|
38
|
+
break;
|
|
39
|
+
case LogLevel.enum.warn:
|
|
40
|
+
logLevel2 = consola.LogLevels.warn;
|
|
41
|
+
break;
|
|
42
|
+
case LogLevel.enum.error:
|
|
43
|
+
logLevel2 = consola.LogLevels.error;
|
|
44
|
+
break;
|
|
45
|
+
case LogLevel.enum.fatal:
|
|
46
|
+
logLevel2 = consola.LogLevels.fatal;
|
|
47
|
+
break;
|
|
48
|
+
case LogLevel.enum.log:
|
|
49
|
+
logLevel2 = consola.LogLevels.log;
|
|
50
|
+
break;
|
|
51
|
+
default:
|
|
52
|
+
throw new Error(`Invalid log level translation to consola's log level: ${level}`);
|
|
53
|
+
}
|
|
54
|
+
logger.level = logLevel2;
|
|
55
|
+
currentLevel = level;
|
|
56
|
+
},
|
|
57
|
+
getLogLevel: () => {
|
|
58
|
+
return currentLevel;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
result.setLogLevel(logLevel);
|
|
62
|
+
return result;
|
|
63
|
+
};
|
|
64
|
+
function getLogLevel(logLevel) {
|
|
65
|
+
logLevel = logLevel || process.env.PROSOPO_LOG_LEVEL || "Info";
|
|
66
|
+
logLevel = logLevel.toString().toLowerCase();
|
|
67
|
+
try {
|
|
68
|
+
return LogLevel.parse(logLevel);
|
|
69
|
+
} catch (e) {
|
|
70
|
+
throw new error.ProsopoEnvError("CONFIG.INVALID_LOG_LEVEL", { context: { logLevel } });
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
const defaultLogger = getLoggerAdapterConsola(LogLevel.enum.info, "global");
|
|
74
|
+
class Loggable {
|
|
75
|
+
constructor() {
|
|
76
|
+
_Loggable_logger.set(this, void 0);
|
|
77
|
+
tslib.__classPrivateFieldSet(this, _Loggable_logger, getLoggerDefault(), "f");
|
|
78
|
+
}
|
|
79
|
+
get logger() {
|
|
80
|
+
return tslib.__classPrivateFieldGet(this, _Loggable_logger, "f");
|
|
81
|
+
}
|
|
82
|
+
set logger(logger) {
|
|
83
|
+
tslib.__classPrivateFieldSet(this, _Loggable_logger, logger, "f");
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
_Loggable_logger = /* @__PURE__ */ new WeakMap();
|
|
87
|
+
exports.LogLevel = LogLevel;
|
|
88
|
+
exports.Loggable = Loggable;
|
|
89
|
+
exports.getLogLevel = getLogLevel;
|
|
90
|
+
exports.getLogger = getLogger;
|
|
91
|
+
exports.getLoggerDefault = getLoggerDefault;
|