@prosopo/account 1.0.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/dist/cjs/common/dist/error.cjs +20 -16
- package/dist/cjs/common/dist/hash.cjs +1 -1
- package/dist/cjs/common/dist/i18n.cjs +3 -3
- package/dist/cjs/common/dist/locales/en.json.cjs +2 -1
- package/dist/cjs/common/dist/logger.cjs +23 -11
- package/dist/cjs/common/dist/node/UrlConverter.cjs +15 -7
- package/dist/cjs/common/dist/utils.cjs +4 -2
- package/dist/cjs/detector/src/index.cjs +4586 -0
- package/dist/cjs/extension/ExtensionWeb2.cjs +30 -30
- package/dist/cjs/extension/ExtensionWeb3.cjs +5 -3
- package/dist/cjs/util/dist/at.cjs +3 -0
- package/dist/cjs/util/dist/canvas.cjs +15 -9
- package/dist/cjs/util/dist/hex.cjs +37 -2
- package/dist/cjs/util/dist/index.cjs +1 -0
- package/dist/cjs/util/dist/ofLen.cjs +1 -1
- package/dist/cjs/util/dist/table.cjs +2 -2
- package/dist/cjs/util/dist/util.cjs +1 -1
- package/dist/extension/Extension.d.ts +1 -1
- package/dist/extension/Extension.d.ts.map +1 -1
- package/dist/extension/Extension.js.map +1 -1
- package/dist/extension/ExtensionWeb2.d.ts +4 -5
- package/dist/extension/ExtensionWeb2.d.ts.map +1 -1
- package/dist/extension/ExtensionWeb2.js +27 -36
- package/dist/extension/ExtensionWeb2.js.map +1 -1
- package/dist/extension/ExtensionWeb3.d.ts +2 -2
- package/dist/extension/ExtensionWeb3.d.ts.map +1 -1
- package/dist/extension/ExtensionWeb3.js +8 -6
- package/dist/extension/ExtensionWeb3.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/package.json +53 -58
- package/vite.cjs.config.ts +3 -3
|
@@ -34,58 +34,62 @@ class ProsopoBaseError extends Error {
|
|
|
34
34
|
class ProsopoError extends ProsopoBaseError {
|
|
35
35
|
constructor(error, options) {
|
|
36
36
|
const errorName = options?.name || "ProsopoError";
|
|
37
|
-
|
|
38
|
-
super(error,
|
|
37
|
+
const optionsAll = { ...options, name: errorName };
|
|
38
|
+
super(error, optionsAll);
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
class ProsopoEnvError extends ProsopoBaseError {
|
|
42
42
|
constructor(error, options) {
|
|
43
43
|
const errorName = options?.name || "ProsopoEnvError";
|
|
44
|
-
|
|
45
|
-
super(error,
|
|
44
|
+
const optionsAll = { ...options, name: errorName };
|
|
45
|
+
super(error, optionsAll);
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
class ProsopoContractError extends ProsopoBaseError {
|
|
49
49
|
constructor(error, options) {
|
|
50
50
|
const errorName = options?.name || "ProsopoContractError";
|
|
51
|
-
|
|
52
|
-
super(error,
|
|
51
|
+
const optionsAll = { ...options, name: errorName };
|
|
52
|
+
super(error, optionsAll);
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
class ProsopoTxQueueError extends ProsopoBaseError {
|
|
56
56
|
constructor(error, options) {
|
|
57
57
|
const errorName = options?.name || "ProsopoTxQueueError";
|
|
58
|
-
|
|
59
|
-
super(error,
|
|
58
|
+
const optionsAll = { ...options, name: errorName };
|
|
59
|
+
super(error, optionsAll);
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
class ProsopoDBError extends ProsopoBaseError {
|
|
63
63
|
constructor(error, options) {
|
|
64
64
|
const errorName = options?.name || "ProsopoDBError";
|
|
65
|
-
|
|
66
|
-
super(error,
|
|
65
|
+
const optionsAll = { ...options, name: errorName };
|
|
66
|
+
super(error, optionsAll);
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
class ProsopoCliError extends ProsopoBaseError {
|
|
70
70
|
constructor(error, options) {
|
|
71
71
|
const errorName = options?.name || "ProsopoCliError";
|
|
72
|
-
|
|
73
|
-
super(error,
|
|
72
|
+
const optionsAll = { ...options, name: errorName };
|
|
73
|
+
super(error, optionsAll);
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
class ProsopoDatasetError extends ProsopoBaseError {
|
|
77
77
|
constructor(error, options) {
|
|
78
78
|
const errorName = options?.name || "ProsopoDatasetError";
|
|
79
|
-
|
|
80
|
-
super(error,
|
|
79
|
+
const optionsAll = { ...options, name: errorName };
|
|
80
|
+
super(error, optionsAll);
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
class ProsopoApiError extends ProsopoBaseError {
|
|
84
84
|
constructor(error, options) {
|
|
85
85
|
const errorName = options?.name || "ProsopoApiError";
|
|
86
86
|
const code = options?.context?.code || 500;
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
const optionsAll = {
|
|
88
|
+
...options,
|
|
89
|
+
name: errorName,
|
|
90
|
+
context: { ...options?.context, code }
|
|
91
|
+
};
|
|
92
|
+
super(error, optionsAll);
|
|
89
93
|
this.code = code;
|
|
90
94
|
}
|
|
91
95
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const array = require("./array.cjs");
|
|
4
3
|
const blake2 = require("@polkadot/util-crypto/blake2");
|
|
4
|
+
const array = require("./array.cjs");
|
|
5
5
|
const HEX_HASH_BIT_LENGTH = 256;
|
|
6
6
|
function hexHash(data, bitLength) {
|
|
7
7
|
return blake2.blake2AsHex(data, bitLength);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
const i18n = require("i18next");
|
|
2
3
|
const LanguageDetector = require("i18next-browser-languagedetector");
|
|
4
|
+
const Backend = require("i18next-http-backend");
|
|
3
5
|
const i18nextHttpMiddleware = require("i18next-http-middleware");
|
|
4
6
|
const reactI18next = require("react-i18next");
|
|
5
|
-
const utils = require("./utils.cjs");
|
|
6
|
-
const Backend = require("i18next-http-backend");
|
|
7
|
-
const i18n = require("i18next");
|
|
8
7
|
const en = require("./locales/en.json.cjs");
|
|
8
|
+
const utils = require("./utils.cjs");
|
|
9
9
|
const commonOptions = {
|
|
10
10
|
debug: false,
|
|
11
11
|
fallbackLng: "en",
|
|
@@ -4,7 +4,8 @@ const ACCOUNT = {
|
|
|
4
4
|
NO_POLKADOT_EXTENSION: "Polkadot extension not found"
|
|
5
5
|
};
|
|
6
6
|
const WIDGET = {
|
|
7
|
-
SELECT_ALL: "Select all
|
|
7
|
+
SELECT_ALL: "Select all containing the following",
|
|
8
|
+
IF_NONE_CLICK_NEXT: "If there are none, click Next",
|
|
8
9
|
NEXT: "Next",
|
|
9
10
|
SUBMIT: "Submit",
|
|
10
11
|
CANCEL: "Cancel",
|
|
@@ -2,10 +2,18 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const tslib = require("tslib");
|
|
4
4
|
const browser = require("consola/browser");
|
|
5
|
-
const error = require("./error.cjs");
|
|
6
5
|
const zod = require("zod");
|
|
6
|
+
const error = require("./error.cjs");
|
|
7
7
|
var _Loggable_logger;
|
|
8
|
-
const LogLevel = zod.enum([
|
|
8
|
+
const LogLevel = zod.enum([
|
|
9
|
+
"trace",
|
|
10
|
+
"debug",
|
|
11
|
+
"info",
|
|
12
|
+
"warn",
|
|
13
|
+
"error",
|
|
14
|
+
"fatal",
|
|
15
|
+
"log"
|
|
16
|
+
]);
|
|
9
17
|
function getLogger(logLevel, scope) {
|
|
10
18
|
return getLoggerAdapterConsola(getLogLevel(logLevel), scope);
|
|
11
19
|
}
|
|
@@ -13,7 +21,9 @@ function getLoggerDefault() {
|
|
|
13
21
|
return defaultLogger;
|
|
14
22
|
}
|
|
15
23
|
const getLoggerAdapterConsola = (logLevel, scope) => {
|
|
16
|
-
const logger = browser.createConsola({
|
|
24
|
+
const logger = browser.createConsola({
|
|
25
|
+
formatOptions: { colors: true, date: true }
|
|
26
|
+
}).withTag(scope);
|
|
17
27
|
let currentLevel = logLevel;
|
|
18
28
|
const result = {
|
|
19
29
|
log: logger.log,
|
|
@@ -24,9 +34,9 @@ const getLoggerAdapterConsola = (logLevel, scope) => {
|
|
|
24
34
|
error: logger.error,
|
|
25
35
|
fatal: logger.fatal,
|
|
26
36
|
setLogLevel: (level) => {
|
|
27
|
-
let logLevel2 = NaN;
|
|
28
|
-
|
|
29
|
-
switch (
|
|
37
|
+
let logLevel2 = Number.NaN;
|
|
38
|
+
const levelSafe = getLogLevel(level);
|
|
39
|
+
switch (levelSafe) {
|
|
30
40
|
case LogLevel.enum.trace:
|
|
31
41
|
logLevel2 = browser.LogLevels.trace;
|
|
32
42
|
break;
|
|
@@ -52,7 +62,7 @@ const getLoggerAdapterConsola = (logLevel, scope) => {
|
|
|
52
62
|
throw new Error(`Invalid log level translation to consola's log level: ${level}`);
|
|
53
63
|
}
|
|
54
64
|
logger.level = logLevel2;
|
|
55
|
-
currentLevel =
|
|
65
|
+
currentLevel = levelSafe;
|
|
56
66
|
},
|
|
57
67
|
getLogLevel: () => {
|
|
58
68
|
return currentLevel;
|
|
@@ -62,12 +72,14 @@ const getLoggerAdapterConsola = (logLevel, scope) => {
|
|
|
62
72
|
return result;
|
|
63
73
|
};
|
|
64
74
|
function getLogLevel(logLevel) {
|
|
65
|
-
|
|
66
|
-
|
|
75
|
+
const logLevelLocal = logLevel || process.env.PROSOPO_LOG_LEVEL || "Info";
|
|
76
|
+
const logLevelStr = logLevelLocal.toString().toLowerCase();
|
|
67
77
|
try {
|
|
68
|
-
return LogLevel.parse(
|
|
78
|
+
return LogLevel.parse(logLevelStr);
|
|
69
79
|
} catch (e) {
|
|
70
|
-
throw new error.ProsopoEnvError("CONFIG.INVALID_LOG_LEVEL", {
|
|
80
|
+
throw new error.ProsopoEnvError("CONFIG.INVALID_LOG_LEVEL", {
|
|
81
|
+
context: { logLevel }
|
|
82
|
+
});
|
|
71
83
|
}
|
|
72
84
|
}
|
|
73
85
|
const defaultLogger = getLoggerAdapterConsola(LogLevel.enum.info, "global");
|
|
@@ -70,7 +70,7 @@ class UrlConverter {
|
|
|
70
70
|
this.longestSymbolLength = this.symbols.reduce((longest, symb) => {
|
|
71
71
|
return Math.max(longest, symb.length);
|
|
72
72
|
}, 0);
|
|
73
|
-
const maxSymbols =
|
|
73
|
+
const maxSymbols = 2 ** this.symbolNBits;
|
|
74
74
|
if (this.symbols.length > maxSymbols) {
|
|
75
75
|
throw new error.ProsopoError("DEVELOPER.GENERAL", {
|
|
76
76
|
context: {
|
|
@@ -81,7 +81,9 @@ class UrlConverter {
|
|
|
81
81
|
}
|
|
82
82
|
const symbols = this.getSymbols();
|
|
83
83
|
if (symbols.length !== new Set(symbols).size) {
|
|
84
|
-
throw new error.ProsopoError("DEVELOPER.GENERAL", {
|
|
84
|
+
throw new error.ProsopoError("DEVELOPER.GENERAL", {
|
|
85
|
+
context: { error: "Symbols must be unique" }
|
|
86
|
+
});
|
|
85
87
|
}
|
|
86
88
|
}
|
|
87
89
|
symbolToNum(symb) {
|
|
@@ -127,7 +129,9 @@ class UrlConverter {
|
|
|
127
129
|
}
|
|
128
130
|
if (num === void 0) {
|
|
129
131
|
throw new error.ProsopoError("DEVELOPER.GENERAL", {
|
|
130
|
-
context: {
|
|
132
|
+
context: {
|
|
133
|
+
error: `Could not find symbol at '${url}' of '${origUrl}'`
|
|
134
|
+
}
|
|
131
135
|
});
|
|
132
136
|
}
|
|
133
137
|
nums.push(num);
|
|
@@ -141,7 +145,9 @@ class UrlConverter {
|
|
|
141
145
|
const num = nums[numIndex];
|
|
142
146
|
if (num === void 0) {
|
|
143
147
|
throw new error.ProsopoError("DEVELOPER.GENERAL", {
|
|
144
|
-
context: {
|
|
148
|
+
context: {
|
|
149
|
+
error: `Could not find number at index ${numIndex} of '${nums}'`
|
|
150
|
+
}
|
|
145
151
|
});
|
|
146
152
|
}
|
|
147
153
|
const byteIndex = bitCount / this.byteNBits | 0;
|
|
@@ -151,7 +157,7 @@ class UrlConverter {
|
|
|
151
157
|
if (shift < 0) {
|
|
152
158
|
const usedBitsInSymbol = bitCount % this.symbolNBits;
|
|
153
159
|
const unusedBitsInSymbol = this.symbolNBits - usedBitsInSymbol;
|
|
154
|
-
const max =
|
|
160
|
+
const max = 2 ** unusedBitsInSymbol;
|
|
155
161
|
const remNum = num % max;
|
|
156
162
|
const shift2 = this.byteNBits - unusedBitsInSymbol;
|
|
157
163
|
const shiftedNum = remNum << shift2;
|
|
@@ -174,7 +180,9 @@ class UrlConverter {
|
|
|
174
180
|
const byte = bytes[byteIndex];
|
|
175
181
|
if (byte === void 0) {
|
|
176
182
|
throw new error.ProsopoError("DEVELOPER.GENERAL", {
|
|
177
|
-
context: {
|
|
183
|
+
context: {
|
|
184
|
+
error: `Could not find byte at index ${byteIndex} of '${bytes}'`
|
|
185
|
+
}
|
|
178
186
|
});
|
|
179
187
|
}
|
|
180
188
|
const usedBitsInByte = bitCount % this.byteNBits;
|
|
@@ -204,7 +212,7 @@ class UrlConverter {
|
|
|
204
212
|
}
|
|
205
213
|
bitTruncLeft(num, nBits) {
|
|
206
214
|
const threshNBits = this.byteNBits - nBits;
|
|
207
|
-
const thresh =
|
|
215
|
+
const thresh = 2 ** threshNBits;
|
|
208
216
|
return thresh <= 0 ? 0 : num % thresh;
|
|
209
217
|
}
|
|
210
218
|
getSymbols() {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const error = require("./error.cjs");
|
|
4
3
|
const hex = require("@polkadot/util/hex");
|
|
4
|
+
const error = require("./error.cjs");
|
|
5
5
|
const en = require("./locales/en.json.cjs");
|
|
6
6
|
function isClientSide() {
|
|
7
7
|
return !!(typeof window !== "undefined" && window.document && window.document.createElement);
|
|
@@ -13,7 +13,9 @@ function getLeafFieldPath(obj) {
|
|
|
13
13
|
return Object.keys(obj).reduce((arr, key) => {
|
|
14
14
|
const value = obj[key];
|
|
15
15
|
if (value === void 0) {
|
|
16
|
-
throw new error.ProsopoError("DEVELOPER.KEY_ERROR", {
|
|
16
|
+
throw new error.ProsopoError("DEVELOPER.KEY_ERROR", {
|
|
17
|
+
context: { error: `Undefined value for key ${key}` }
|
|
18
|
+
});
|
|
17
19
|
}
|
|
18
20
|
const children = getLeafFieldPath(value);
|
|
19
21
|
return arr.concat(children.map((child) => {
|