@prosopo/account 2.0.2 → 2.1.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/extension/ExtensionWeb2.cjs +7 -10
- package/dist/cjs/extension/ExtensionWeb3.cjs +4 -5
- package/dist/extension/ExtensionWeb2.d.ts.map +1 -1
- package/dist/extension/ExtensionWeb2.js.map +1 -1
- package/dist/extension/ExtensionWeb3.js.map +1 -1
- package/package.json +57 -53
- package/dist/cjs/common/dist/array.cjs +0 -8
- package/dist/cjs/common/dist/asyncFactory.cjs +0 -13
- package/dist/cjs/common/dist/custom.cjs +0 -1
- package/dist/cjs/common/dist/error.cjs +0 -104
- package/dist/cjs/common/dist/hash.cjs +0 -14
- package/dist/cjs/common/dist/i18n.cjs +0 -29
- package/dist/cjs/common/dist/index.cjs +0 -39
- package/dist/cjs/common/dist/locales/en.json.cjs +0 -205
- package/dist/cjs/common/dist/logger.cjs +0 -103
- package/dist/cjs/common/dist/node/UrlConverter.cjs +0 -223
- package/dist/cjs/common/dist/node/i18nMiddleware.cjs +0 -8
- package/dist/cjs/common/dist/node/index.cjs +0 -4
- package/dist/cjs/common/dist/react/index.cjs +0 -4
- package/dist/cjs/common/dist/react/useTranslation.cjs +0 -8
- package/dist/cjs/common/dist/string.cjs +0 -6
- package/dist/cjs/common/dist/utils.cjs +0 -33
- package/dist/cjs/detector/src/index.cjs +0 -4586
- package/dist/cjs/util/dist/at.cjs +0 -25
- package/dist/cjs/util/dist/canvas.cjs +0 -332
- package/dist/cjs/util/dist/checks.cjs +0 -10
- package/dist/cjs/util/dist/choice.cjs +0 -19
- package/dist/cjs/util/dist/get.cjs +0 -10
- package/dist/cjs/util/dist/hex.cjs +0 -46
- package/dist/cjs/util/dist/index.cjs +0 -44
- package/dist/cjs/util/dist/isMain.cjs +0 -13
- package/dist/cjs/util/dist/lodash.cjs +0 -35
- package/dist/cjs/util/dist/merge.cjs +0 -58
- package/dist/cjs/util/dist/ofLen.cjs +0 -526
- package/dist/cjs/util/dist/permutations.cjs +0 -26
- package/dist/cjs/util/dist/solverService.cjs +0 -17
- package/dist/cjs/util/dist/table.cjs +0 -24
- package/dist/cjs/util/dist/url.cjs +0 -9
- package/dist/cjs/util/dist/util.cjs +0 -22
- package/dist/cjs/util/dist/verifyRecency.cjs +0 -12
- package/dist/cjs/util/dist/version.cjs +0 -4
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const tslib = require("tslib");
|
|
4
|
-
const browser = require("consola/browser");
|
|
5
|
-
const zod = require("zod");
|
|
6
|
-
const error = require("./error.cjs");
|
|
7
|
-
var _Loggable_logger;
|
|
8
|
-
const LogLevel = zod.enum([
|
|
9
|
-
"trace",
|
|
10
|
-
"debug",
|
|
11
|
-
"info",
|
|
12
|
-
"warn",
|
|
13
|
-
"error",
|
|
14
|
-
"fatal",
|
|
15
|
-
"log"
|
|
16
|
-
]);
|
|
17
|
-
function getLogger(logLevel, scope) {
|
|
18
|
-
return getLoggerAdapterConsola(getLogLevel(logLevel), scope);
|
|
19
|
-
}
|
|
20
|
-
function getLoggerDefault() {
|
|
21
|
-
return defaultLogger;
|
|
22
|
-
}
|
|
23
|
-
const getLoggerAdapterConsola = (logLevel, scope) => {
|
|
24
|
-
const logger = browser.createConsola({
|
|
25
|
-
formatOptions: { colors: true, date: true }
|
|
26
|
-
}).withTag(scope);
|
|
27
|
-
let currentLevel = logLevel;
|
|
28
|
-
const result = {
|
|
29
|
-
log: logger.log,
|
|
30
|
-
info: logger.info,
|
|
31
|
-
debug: logger.debug,
|
|
32
|
-
trace: logger.trace,
|
|
33
|
-
warn: logger.warn,
|
|
34
|
-
error: logger.error,
|
|
35
|
-
fatal: logger.fatal,
|
|
36
|
-
setLogLevel: (level) => {
|
|
37
|
-
let logLevel2 = Number.NaN;
|
|
38
|
-
const levelSafe = getLogLevel(level);
|
|
39
|
-
switch (levelSafe) {
|
|
40
|
-
case LogLevel.enum.trace:
|
|
41
|
-
logLevel2 = browser.LogLevels.trace;
|
|
42
|
-
break;
|
|
43
|
-
case LogLevel.enum.debug:
|
|
44
|
-
logLevel2 = browser.LogLevels.debug;
|
|
45
|
-
break;
|
|
46
|
-
case LogLevel.enum.info:
|
|
47
|
-
logLevel2 = browser.LogLevels.info;
|
|
48
|
-
break;
|
|
49
|
-
case LogLevel.enum.warn:
|
|
50
|
-
logLevel2 = browser.LogLevels.warn;
|
|
51
|
-
break;
|
|
52
|
-
case LogLevel.enum.error:
|
|
53
|
-
logLevel2 = browser.LogLevels.error;
|
|
54
|
-
break;
|
|
55
|
-
case LogLevel.enum.fatal:
|
|
56
|
-
logLevel2 = browser.LogLevels.fatal;
|
|
57
|
-
break;
|
|
58
|
-
case LogLevel.enum.log:
|
|
59
|
-
logLevel2 = browser.LogLevels.log;
|
|
60
|
-
break;
|
|
61
|
-
default:
|
|
62
|
-
throw new Error(`Invalid log level translation to consola's log level: ${level}`);
|
|
63
|
-
}
|
|
64
|
-
logger.level = logLevel2;
|
|
65
|
-
currentLevel = levelSafe;
|
|
66
|
-
},
|
|
67
|
-
getLogLevel: () => {
|
|
68
|
-
return currentLevel;
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
result.setLogLevel(logLevel);
|
|
72
|
-
return result;
|
|
73
|
-
};
|
|
74
|
-
function getLogLevel(logLevel) {
|
|
75
|
-
const logLevelLocal = logLevel || process.env.PROSOPO_LOG_LEVEL || "Info";
|
|
76
|
-
const logLevelStr = logLevelLocal.toString().toLowerCase();
|
|
77
|
-
try {
|
|
78
|
-
return LogLevel.parse(logLevelStr);
|
|
79
|
-
} catch (e) {
|
|
80
|
-
throw new error.ProsopoEnvError("CONFIG.INVALID_LOG_LEVEL", {
|
|
81
|
-
context: { logLevel }
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
const defaultLogger = getLoggerAdapterConsola(LogLevel.enum.info, "global");
|
|
86
|
-
class Loggable {
|
|
87
|
-
constructor() {
|
|
88
|
-
_Loggable_logger.set(this, void 0);
|
|
89
|
-
tslib.__classPrivateFieldSet(this, _Loggable_logger, getLoggerDefault(), "f");
|
|
90
|
-
}
|
|
91
|
-
get logger() {
|
|
92
|
-
return tslib.__classPrivateFieldGet(this, _Loggable_logger, "f");
|
|
93
|
-
}
|
|
94
|
-
set logger(logger) {
|
|
95
|
-
tslib.__classPrivateFieldSet(this, _Loggable_logger, logger, "f");
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
_Loggable_logger = /* @__PURE__ */ new WeakMap();
|
|
99
|
-
exports.LogLevel = LogLevel;
|
|
100
|
-
exports.Loggable = Loggable;
|
|
101
|
-
exports.getLogLevel = getLogLevel;
|
|
102
|
-
exports.getLogger = getLogger;
|
|
103
|
-
exports.getLoggerDefault = getLoggerDefault;
|
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
-
require("../index.cjs");
|
|
4
|
-
const error = require("../error.cjs");
|
|
5
|
-
class UrlConverter {
|
|
6
|
-
constructor() {
|
|
7
|
-
this.symbols = [
|
|
8
|
-
"",
|
|
9
|
-
"0",
|
|
10
|
-
"1",
|
|
11
|
-
"2",
|
|
12
|
-
"3",
|
|
13
|
-
"4",
|
|
14
|
-
"5",
|
|
15
|
-
"6",
|
|
16
|
-
"7",
|
|
17
|
-
"8",
|
|
18
|
-
"9",
|
|
19
|
-
"a",
|
|
20
|
-
"b",
|
|
21
|
-
"c",
|
|
22
|
-
"d",
|
|
23
|
-
"e",
|
|
24
|
-
"f",
|
|
25
|
-
"g",
|
|
26
|
-
"h",
|
|
27
|
-
"i",
|
|
28
|
-
"j",
|
|
29
|
-
"k",
|
|
30
|
-
"l",
|
|
31
|
-
"m",
|
|
32
|
-
"n",
|
|
33
|
-
"o",
|
|
34
|
-
"p",
|
|
35
|
-
"q",
|
|
36
|
-
"r",
|
|
37
|
-
"s",
|
|
38
|
-
"t",
|
|
39
|
-
"u",
|
|
40
|
-
"v",
|
|
41
|
-
"w",
|
|
42
|
-
"x",
|
|
43
|
-
"y",
|
|
44
|
-
"z",
|
|
45
|
-
"/",
|
|
46
|
-
".",
|
|
47
|
-
"-",
|
|
48
|
-
"_",
|
|
49
|
-
"%",
|
|
50
|
-
":",
|
|
51
|
-
"http://",
|
|
52
|
-
"https://",
|
|
53
|
-
"www.",
|
|
54
|
-
".com",
|
|
55
|
-
".net",
|
|
56
|
-
".org",
|
|
57
|
-
".co.uk",
|
|
58
|
-
".io"
|
|
59
|
-
];
|
|
60
|
-
this.symbolNBits = 6;
|
|
61
|
-
this.byteNBits = 8;
|
|
62
|
-
this.symbolToNumMap = this.symbols.reduce((obj, symb, i, arr) => {
|
|
63
|
-
obj[symb] = i;
|
|
64
|
-
return obj;
|
|
65
|
-
}, {});
|
|
66
|
-
this.numToSymbolMap = this.symbols.reduce((obj, symb, i, arr) => {
|
|
67
|
-
obj[i] = symb;
|
|
68
|
-
return obj;
|
|
69
|
-
}, {});
|
|
70
|
-
this.longestSymbolLength = this.symbols.reduce((longest, symb) => {
|
|
71
|
-
return Math.max(longest, symb.length);
|
|
72
|
-
}, 0);
|
|
73
|
-
const maxSymbols = 2 ** this.symbolNBits;
|
|
74
|
-
if (this.symbols.length > maxSymbols) {
|
|
75
|
-
throw new error.ProsopoError("DEVELOPER.GENERAL", {
|
|
76
|
-
context: {
|
|
77
|
-
error: `Cannot encode more than ${maxSymbols} symbols`,
|
|
78
|
-
context: "only built to encode 64 symbols. Need to adjust the encoding and decoding scheme for more symbols"
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
const symbols = this.getSymbols();
|
|
83
|
-
if (symbols.length !== new Set(symbols).size) {
|
|
84
|
-
throw new error.ProsopoError("DEVELOPER.GENERAL", {
|
|
85
|
-
context: { error: "Symbols must be unique" }
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
symbolToNum(symb) {
|
|
90
|
-
const num = this.symbolToNumNull(symb);
|
|
91
|
-
if (num === void 0) {
|
|
92
|
-
throw new error.ProsopoError("DEVELOPER.GENERAL", {
|
|
93
|
-
context: { error: `Could not find number for symbol '${symb}'` }
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
return num;
|
|
97
|
-
}
|
|
98
|
-
symbolToNumNull(symb) {
|
|
99
|
-
symb = symb.toLowerCase();
|
|
100
|
-
const num = this.symbolToNumMap[symb];
|
|
101
|
-
return num;
|
|
102
|
-
}
|
|
103
|
-
numToSymbol(num) {
|
|
104
|
-
const symb = this.numToSymbolNull(num);
|
|
105
|
-
if (symb === void 0) {
|
|
106
|
-
throw new error.ProsopoError("DEVELOPER.GENERAL", {
|
|
107
|
-
context: { error: `Could not find symbol for number ${num}` }
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
return symb;
|
|
111
|
-
}
|
|
112
|
-
numToSymbolNull(num) {
|
|
113
|
-
const symb = this.numToSymbolMap[num];
|
|
114
|
-
return symb;
|
|
115
|
-
}
|
|
116
|
-
encode(url) {
|
|
117
|
-
url = url.toLowerCase();
|
|
118
|
-
const nums = [];
|
|
119
|
-
const origUrl = url;
|
|
120
|
-
while (url.length > 0) {
|
|
121
|
-
let len = Math.min(url.length, this.longestSymbolLength);
|
|
122
|
-
let num = void 0;
|
|
123
|
-
while (num === void 0 && len > 0) {
|
|
124
|
-
const str = url.slice(0, len);
|
|
125
|
-
num = this.symbolToNumNull(str);
|
|
126
|
-
if (num === void 0) {
|
|
127
|
-
len--;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
if (num === void 0) {
|
|
131
|
-
throw new error.ProsopoError("DEVELOPER.GENERAL", {
|
|
132
|
-
context: {
|
|
133
|
-
error: `Could not find symbol at '${url}' of '${origUrl}'`
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
nums.push(num);
|
|
138
|
-
url = url.slice(len);
|
|
139
|
-
}
|
|
140
|
-
const nBits = nums.length * this.symbolNBits;
|
|
141
|
-
const nBytes = Math.ceil(nBits / this.byteNBits);
|
|
142
|
-
const bytes = new Uint8Array(nBytes);
|
|
143
|
-
for (let bitCount = 0; bitCount < nBits; ) {
|
|
144
|
-
const numIndex = bitCount / this.symbolNBits | 0;
|
|
145
|
-
const num = nums[numIndex];
|
|
146
|
-
if (num === void 0) {
|
|
147
|
-
throw new error.ProsopoError("DEVELOPER.GENERAL", {
|
|
148
|
-
context: {
|
|
149
|
-
error: `Could not find number at index ${numIndex} of '${nums}'`
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
const byteIndex = bitCount / this.byteNBits | 0;
|
|
154
|
-
const usedBitsInByte = bitCount % this.byteNBits;
|
|
155
|
-
const unusedBitsInByte = this.byteNBits - usedBitsInByte;
|
|
156
|
-
const shift = this.symbolNBits - unusedBitsInByte;
|
|
157
|
-
if (shift < 0) {
|
|
158
|
-
const usedBitsInSymbol = bitCount % this.symbolNBits;
|
|
159
|
-
const unusedBitsInSymbol = this.symbolNBits - usedBitsInSymbol;
|
|
160
|
-
const max = 2 ** unusedBitsInSymbol;
|
|
161
|
-
const remNum = num % max;
|
|
162
|
-
const shift2 = this.byteNBits - unusedBitsInSymbol;
|
|
163
|
-
const shiftedNum = remNum << shift2;
|
|
164
|
-
bytes[byteIndex] |= shiftedNum;
|
|
165
|
-
bitCount += unusedBitsInSymbol;
|
|
166
|
-
} else {
|
|
167
|
-
bytes[byteIndex] |= num >> shift;
|
|
168
|
-
bitCount += unusedBitsInByte;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
return bytes;
|
|
172
|
-
}
|
|
173
|
-
decode(bytes) {
|
|
174
|
-
const arr = [];
|
|
175
|
-
const nBits = bytes.length * this.byteNBits;
|
|
176
|
-
let num = 0;
|
|
177
|
-
let nBitsNum = 0;
|
|
178
|
-
for (let bitCount = 0; bitCount < nBits; ) {
|
|
179
|
-
const byteIndex = bitCount / this.byteNBits | 0;
|
|
180
|
-
const byte = bytes[byteIndex];
|
|
181
|
-
if (byte === void 0) {
|
|
182
|
-
throw new error.ProsopoError("DEVELOPER.GENERAL", {
|
|
183
|
-
context: {
|
|
184
|
-
error: `Could not find byte at index ${byteIndex} of '${bytes}'`
|
|
185
|
-
}
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
const usedBitsInByte = bitCount % this.byteNBits;
|
|
189
|
-
const unusedBitsInByte = this.byteNBits - usedBitsInByte;
|
|
190
|
-
const unusedBitsInSymbol = this.symbolNBits - nBitsNum;
|
|
191
|
-
const consumeNBits = Math.min(unusedBitsInByte, unusedBitsInSymbol);
|
|
192
|
-
const slice = this.bitSlice(byte, usedBitsInByte, consumeNBits);
|
|
193
|
-
num = num << consumeNBits | slice;
|
|
194
|
-
nBitsNum += consumeNBits;
|
|
195
|
-
if (nBitsNum >= this.symbolNBits) {
|
|
196
|
-
const symbol = this.numToSymbol(num);
|
|
197
|
-
arr.push(symbol);
|
|
198
|
-
num = 0;
|
|
199
|
-
nBitsNum = 0;
|
|
200
|
-
}
|
|
201
|
-
bitCount += consumeNBits;
|
|
202
|
-
}
|
|
203
|
-
return arr.join("");
|
|
204
|
-
}
|
|
205
|
-
bitSlice(num, startBit, lenBit) {
|
|
206
|
-
const truncedLeft = this.bitTruncLeft(num, startBit);
|
|
207
|
-
const truncedLen = this.bitTruncRight(truncedLeft, Math.max(0, this.byteNBits - lenBit - startBit));
|
|
208
|
-
return truncedLen;
|
|
209
|
-
}
|
|
210
|
-
bitTruncRight(num, nBits) {
|
|
211
|
-
return num >> nBits;
|
|
212
|
-
}
|
|
213
|
-
bitTruncLeft(num, nBits) {
|
|
214
|
-
const threshNBits = this.byteNBits - nBits;
|
|
215
|
-
const thresh = 2 ** threshNBits;
|
|
216
|
-
return thresh <= 0 ? 0 : num % thresh;
|
|
217
|
-
}
|
|
218
|
-
getSymbols() {
|
|
219
|
-
return this.symbols;
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
exports.UrlConverter = UrlConverter;
|
|
223
|
-
exports.default = UrlConverter;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const i18nextHttpMiddleware = require("i18next-http-middleware");
|
|
3
|
-
require("../i18n.cjs");
|
|
4
|
-
const i18n = require("i18next");
|
|
5
|
-
function i18nMiddleware(options) {
|
|
6
|
-
return i18nextHttpMiddleware.handle(i18n, { ...options });
|
|
7
|
-
}
|
|
8
|
-
module.exports = i18nMiddleware;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const reactI18next = require("react-i18next");
|
|
3
|
-
require("../i18n.cjs");
|
|
4
|
-
const i18n = require("i18next");
|
|
5
|
-
function useTranslation(options) {
|
|
6
|
-
return reactI18next.useTranslation("translation", { i18n, ...options });
|
|
7
|
-
}
|
|
8
|
-
module.exports = useTranslation;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const error = require("./error.cjs");
|
|
4
|
-
const en = require("./locales/en.json.cjs");
|
|
5
|
-
const zod = require("zod");
|
|
6
|
-
function isClientSide() {
|
|
7
|
-
return !!(typeof window !== "undefined" && window.document && window.document.createElement);
|
|
8
|
-
}
|
|
9
|
-
function getLeafFieldPath(obj) {
|
|
10
|
-
if (typeof obj === "string") {
|
|
11
|
-
return [];
|
|
12
|
-
}
|
|
13
|
-
return Object.keys(obj).reduce((arr, key) => {
|
|
14
|
-
const value = obj[key];
|
|
15
|
-
if (value === void 0) {
|
|
16
|
-
throw new error.ProsopoError("DEVELOPER.KEY_ERROR", {
|
|
17
|
-
context: { error: `Undefined value for key ${key}` }
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
const children = getLeafFieldPath(value);
|
|
21
|
-
return arr.concat(children.map((child) => {
|
|
22
|
-
return `${key}.${child}`;
|
|
23
|
-
}));
|
|
24
|
-
}, []);
|
|
25
|
-
}
|
|
26
|
-
const TranslationKeysSchema = zod.z.enum(getLeafFieldPath(en.default));
|
|
27
|
-
const TranslationFileSchema = zod.z.record(TranslationKeysSchema, zod.z.record(TranslationKeysSchema, zod.z.string()));
|
|
28
|
-
function reverseHexString(str) {
|
|
29
|
-
return `0x${str.match(/.{1,2}/g)?.reverse().join("") || ""}`;
|
|
30
|
-
}
|
|
31
|
-
exports.TranslationKeysSchema = TranslationKeysSchema;
|
|
32
|
-
exports.isClientSide = isClientSide;
|
|
33
|
-
exports.reverseHexString = reverseHexString;
|