@getpara/core-sdk 2.0.0-dev.0 → 2.0.0-dev.2
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/ParaCore.js +3378 -0
- package/dist/cjs/PlatformUtils.js +15 -0
- package/dist/cjs/StorageUtils.js +15 -0
- package/dist/cjs/constants.js +87 -0
- package/dist/cjs/cryptography/utils.js +350 -0
- package/dist/cjs/errors.js +51 -0
- package/dist/cjs/external/mpcComputationClient.js +62 -0
- package/dist/cjs/external/userManagementClient.js +106 -0
- package/dist/cjs/index.js +102 -4080
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/shares/KeyContainer.js +89 -0
- package/dist/cjs/shares/recovery.js +127 -0
- package/dist/cjs/shares/shareDistribution.js +104 -0
- package/dist/cjs/transmission/transmissionUtils.js +93 -0
- package/dist/cjs/types/auth.js +33 -0
- package/dist/cjs/types/config.js +43 -0
- package/dist/cjs/types/coreApi.js +89 -0
- package/dist/cjs/types/events.js +41 -0
- package/dist/cjs/types/index.js +54 -0
- package/dist/cjs/types/methods.js +15 -0
- package/dist/cjs/types/onRamps.js +33 -0
- package/dist/cjs/types/popup.js +35 -0
- package/dist/cjs/types/recovery.js +34 -0
- package/dist/cjs/types/theme.js +15 -0
- package/dist/cjs/types/wallet.js +31 -0
- package/dist/cjs/utils/autobind.js +41 -0
- package/dist/cjs/utils/events.js +45 -0
- package/dist/cjs/utils/formatting.js +116 -0
- package/dist/cjs/utils/index.js +41 -0
- package/dist/cjs/utils/json.js +37 -0
- package/dist/cjs/utils/listeners.js +71 -0
- package/dist/cjs/utils/onRamps.js +92 -0
- package/dist/cjs/utils/phone.js +73 -0
- package/dist/cjs/utils/polling.js +58 -0
- package/dist/cjs/utils/types.js +29 -0
- package/dist/cjs/utils/url.js +135 -0
- package/dist/cjs/utils/wallet.js +159 -0
- package/dist/esm/ParaCore.js +3343 -0
- package/dist/esm/PlatformUtils.js +0 -0
- package/dist/esm/StorageUtils.js +0 -0
- package/dist/esm/chunk-7B52C2XE.js +70 -0
- package/dist/esm/constants.js +45 -0
- package/dist/esm/cryptography/utils.js +282 -0
- package/dist/esm/errors.js +27 -0
- package/dist/esm/external/mpcComputationClient.js +30 -0
- package/dist/esm/external/userManagementClient.js +71 -0
- package/dist/esm/index.js +78 -4049
- package/dist/esm/package.json +4 -0
- package/dist/esm/shares/KeyContainer.js +57 -0
- package/dist/esm/shares/recovery.js +74 -0
- package/dist/esm/shares/shareDistribution.js +64 -0
- package/dist/esm/transmission/transmissionUtils.js +42 -0
- package/dist/esm/types/auth.js +11 -0
- package/dist/esm/types/config.js +20 -0
- package/dist/esm/types/coreApi.js +66 -0
- package/dist/esm/types/events.js +19 -0
- package/dist/esm/types/index.js +23 -0
- package/dist/esm/types/methods.js +0 -0
- package/dist/esm/types/onRamps.js +11 -0
- package/dist/esm/types/popup.js +13 -0
- package/dist/esm/types/recovery.js +12 -0
- package/dist/esm/types/theme.js +0 -0
- package/dist/esm/types/wallet.js +9 -0
- package/dist/esm/utils/autobind.js +19 -0
- package/dist/esm/utils/events.js +11 -0
- package/dist/esm/utils/formatting.js +76 -0
- package/dist/esm/utils/index.js +11 -0
- package/dist/esm/utils/json.js +15 -0
- package/dist/esm/utils/listeners.js +38 -0
- package/dist/esm/utils/onRamps.js +66 -0
- package/dist/esm/utils/phone.js +39 -0
- package/dist/esm/utils/polling.js +18 -0
- package/dist/esm/utils/types.js +7 -0
- package/dist/esm/utils/url.js +90 -0
- package/dist/esm/utils/wallet.js +103 -0
- package/dist/types/ParaCore.d.ts +140 -367
- package/dist/types/PlatformUtils.d.ts +4 -5
- package/dist/types/constants.d.ts +17 -13
- package/dist/types/index.d.ts +5 -4
- package/dist/types/shares/KeyContainer.d.ts +0 -2
- package/dist/types/types/auth.d.ts +16 -0
- package/dist/types/types/config.d.ts +12 -5
- package/dist/types/types/coreApi.d.ts +531 -0
- package/dist/types/types/events.d.ts +4 -1
- package/dist/types/types/index.d.ts +2 -0
- package/dist/types/types/methods.d.ts +145 -42
- package/dist/types/types/onRamps.d.ts +3 -3
- package/dist/types/types/wallet.d.ts +8 -4
- package/dist/types/utils/formatting.d.ts +5 -2
- package/dist/types/utils/index.d.ts +1 -0
- package/dist/types/utils/onRamps.d.ts +12 -5
- package/dist/types/utils/phone.d.ts +6 -2
- package/dist/types/utils/types.d.ts +2 -0
- package/dist/types/utils/url.d.ts +2 -1
- package/dist/types/utils/wallet.d.ts +9 -7
- package/package.json +27 -26
- package/dist/cjs/index.js.br +0 -0
- package/dist/cjs/index.js.gz +0 -0
- package/dist/esm/index.js.br +0 -0
- package/dist/esm/index.js.gz +0 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var KeyContainer_exports = {};
|
|
29
|
+
__export(KeyContainer_exports, {
|
|
30
|
+
KeyContainer: () => KeyContainer
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(KeyContainer_exports);
|
|
33
|
+
var import_ecies = require("@celo/utils/lib/ecies.js");
|
|
34
|
+
var eutil = __toESM(require("@ethereumjs/util"));
|
|
35
|
+
var forge = __toESM(require("node-forge"));
|
|
36
|
+
class KeyContainer {
|
|
37
|
+
constructor(walletId, keyshare, address) {
|
|
38
|
+
this.walletId = walletId;
|
|
39
|
+
this.keyshare = keyshare;
|
|
40
|
+
this.address = address;
|
|
41
|
+
this.backupDecryptionKey = Buffer.from(forge.random.getBytesSync(32), "binary").toString("hex");
|
|
42
|
+
}
|
|
43
|
+
static buildFrom(serializedContainer) {
|
|
44
|
+
try {
|
|
45
|
+
const parsedObject = JSON.parse(serializedContainer);
|
|
46
|
+
return Object.assign(new KeyContainer("", "", ""), parsedObject);
|
|
47
|
+
} catch (e) {
|
|
48
|
+
const container = new KeyContainer("", "", "");
|
|
49
|
+
container.backupDecryptionKey = serializedContainer.split("|")[0];
|
|
50
|
+
return container;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
getPublicEncryptionKey() {
|
|
54
|
+
return Buffer.from(eutil.privateToPublic(Buffer.from(this.backupDecryptionKey, "hex")));
|
|
55
|
+
}
|
|
56
|
+
getPublicEncryptionKeyHex() {
|
|
57
|
+
return this.getPublicEncryptionKey().toString("hex");
|
|
58
|
+
}
|
|
59
|
+
encryptForSelf(backup) {
|
|
60
|
+
try {
|
|
61
|
+
const pubkey = this.getPublicEncryptionKey();
|
|
62
|
+
const data = (0, import_ecies.Encrypt)(pubkey, Buffer.from(backup, "ucs2")).toString("base64");
|
|
63
|
+
return data;
|
|
64
|
+
} catch (error) {
|
|
65
|
+
throw Error("Error encrypting backup");
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
static encryptWithPublicKey(publicKey, backup) {
|
|
69
|
+
try {
|
|
70
|
+
const data = (0, import_ecies.Encrypt)(publicKey, Buffer.from(backup, "ucs2")).toString("base64");
|
|
71
|
+
return data;
|
|
72
|
+
} catch (error) {
|
|
73
|
+
throw Error("Error encrypting backup");
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
decrypt(encryptedBackup) {
|
|
77
|
+
try {
|
|
78
|
+
const buf = Buffer.from(encryptedBackup, "base64");
|
|
79
|
+
const data = (0, import_ecies.Decrypt)(Buffer.from(this.backupDecryptionKey, "hex"), buf);
|
|
80
|
+
return Buffer.from(data.buffer).toString("ucs2");
|
|
81
|
+
} catch (error) {
|
|
82
|
+
throw Error("Error decrypting backup");
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
87
|
+
0 && (module.exports = {
|
|
88
|
+
KeyContainer
|
|
89
|
+
});
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __export = (target, all) => {
|
|
20
|
+
for (var name in all)
|
|
21
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
22
|
+
};
|
|
23
|
+
var __copyProps = (to, from, except, desc) => {
|
|
24
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
25
|
+
for (let key of __getOwnPropNames(from))
|
|
26
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
27
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
28
|
+
}
|
|
29
|
+
return to;
|
|
30
|
+
};
|
|
31
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
|
+
var __async = (__this, __arguments, generator) => {
|
|
33
|
+
return new Promise((resolve, reject) => {
|
|
34
|
+
var fulfilled = (value) => {
|
|
35
|
+
try {
|
|
36
|
+
step(generator.next(value));
|
|
37
|
+
} catch (e) {
|
|
38
|
+
reject(e);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
var rejected = (value) => {
|
|
42
|
+
try {
|
|
43
|
+
step(generator.throw(value));
|
|
44
|
+
} catch (e) {
|
|
45
|
+
reject(e);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
49
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
var recovery_exports = {};
|
|
53
|
+
__export(recovery_exports, {
|
|
54
|
+
sendRecoveryForShare: () => sendRecoveryForShare
|
|
55
|
+
});
|
|
56
|
+
module.exports = __toCommonJS(recovery_exports);
|
|
57
|
+
var import_user_management_client = require("@getpara/user-management-client");
|
|
58
|
+
var import_KeyContainer = require("./KeyContainer.js");
|
|
59
|
+
function sendRecoveryForShare(_0) {
|
|
60
|
+
return __async(this, arguments, function* ({
|
|
61
|
+
ctx,
|
|
62
|
+
userId,
|
|
63
|
+
walletId,
|
|
64
|
+
otherEncryptedShares = [],
|
|
65
|
+
userSigner,
|
|
66
|
+
ignoreRedistributingBackupEncryptedShare = false,
|
|
67
|
+
emailProps = {},
|
|
68
|
+
forceRefresh = false
|
|
69
|
+
}) {
|
|
70
|
+
if (ignoreRedistributingBackupEncryptedShare) {
|
|
71
|
+
yield ctx.client.uploadUserKeyShares(
|
|
72
|
+
userId,
|
|
73
|
+
otherEncryptedShares.map((share) => __spreadValues({
|
|
74
|
+
walletId
|
|
75
|
+
}, share))
|
|
76
|
+
);
|
|
77
|
+
return "";
|
|
78
|
+
}
|
|
79
|
+
let userBackupKeyShareOptsArr;
|
|
80
|
+
let recoveryPrivateKeyContainer;
|
|
81
|
+
const { recoveryPublicKeys } = yield ctx.client.getRecoveryPublicKeys(userId);
|
|
82
|
+
if (forceRefresh || !(recoveryPublicKeys == null ? void 0 : recoveryPublicKeys.length)) {
|
|
83
|
+
recoveryPrivateKeyContainer = new import_KeyContainer.KeyContainer(walletId, "", "");
|
|
84
|
+
const { recoveryPublicKeys: recoveryPublicKeys2 } = yield ctx.client.persistRecoveryPublicKeys(userId, [
|
|
85
|
+
recoveryPrivateKeyContainer.getPublicEncryptionKeyHex()
|
|
86
|
+
]);
|
|
87
|
+
const encryptedUserBackup = recoveryPrivateKeyContainer.encryptForSelf(userSigner);
|
|
88
|
+
userBackupKeyShareOptsArr = [
|
|
89
|
+
{
|
|
90
|
+
walletId,
|
|
91
|
+
encryptedShare: encryptedUserBackup,
|
|
92
|
+
type: import_user_management_client.KeyShareType.USER,
|
|
93
|
+
encryptor: import_user_management_client.EncryptorType.RECOVERY,
|
|
94
|
+
recoveryPublicKeyId: recoveryPublicKeys2[0].id
|
|
95
|
+
}
|
|
96
|
+
];
|
|
97
|
+
} else {
|
|
98
|
+
userBackupKeyShareOptsArr = recoveryPublicKeys.map((recoveryPublicKey) => {
|
|
99
|
+
const { id: recoveryPublicKeyId, publicKey } = recoveryPublicKey;
|
|
100
|
+
const encryptedUserBackup = import_KeyContainer.KeyContainer.encryptWithPublicKey(Buffer.from(publicKey, "hex"), userSigner);
|
|
101
|
+
return {
|
|
102
|
+
walletId,
|
|
103
|
+
encryptedShare: encryptedUserBackup,
|
|
104
|
+
type: import_user_management_client.KeyShareType.USER,
|
|
105
|
+
encryptor: import_user_management_client.EncryptorType.RECOVERY,
|
|
106
|
+
recoveryPublicKeyId
|
|
107
|
+
};
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
yield ctx.client.uploadUserKeyShares(userId, [
|
|
111
|
+
...otherEncryptedShares.map((share) => __spreadValues({
|
|
112
|
+
walletId
|
|
113
|
+
}, share)),
|
|
114
|
+
...ignoreRedistributingBackupEncryptedShare ? [] : userBackupKeyShareOptsArr
|
|
115
|
+
]);
|
|
116
|
+
yield ctx.client.distributeParaShare(__spreadValues({
|
|
117
|
+
userId,
|
|
118
|
+
walletId,
|
|
119
|
+
useDKLS: ctx.useDKLS
|
|
120
|
+
}, emailProps));
|
|
121
|
+
return recoveryPrivateKeyContainer ? JSON.stringify(recoveryPrivateKeyContainer) : "";
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
125
|
+
0 && (module.exports = {
|
|
126
|
+
sendRecoveryForShare
|
|
127
|
+
});
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var __async = (__this, __arguments, generator) => {
|
|
19
|
+
return new Promise((resolve, reject) => {
|
|
20
|
+
var fulfilled = (value) => {
|
|
21
|
+
try {
|
|
22
|
+
step(generator.next(value));
|
|
23
|
+
} catch (e) {
|
|
24
|
+
reject(e);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
var rejected = (value) => {
|
|
28
|
+
try {
|
|
29
|
+
step(generator.throw(value));
|
|
30
|
+
} catch (e) {
|
|
31
|
+
reject(e);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
35
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
var shareDistribution_exports = {};
|
|
39
|
+
__export(shareDistribution_exports, {
|
|
40
|
+
distributeNewShare: () => distributeNewShare
|
|
41
|
+
});
|
|
42
|
+
module.exports = __toCommonJS(shareDistribution_exports);
|
|
43
|
+
var import_user_management_client = require("@getpara/user-management-client");
|
|
44
|
+
var import_utils = require("../cryptography/utils.js");
|
|
45
|
+
var import_recovery = require("./recovery.js");
|
|
46
|
+
function distributeNewShare(_0) {
|
|
47
|
+
return __async(this, arguments, function* ({
|
|
48
|
+
ctx,
|
|
49
|
+
userId,
|
|
50
|
+
walletId,
|
|
51
|
+
userShare,
|
|
52
|
+
ignoreRedistributingBackupEncryptedShare = false,
|
|
53
|
+
emailProps = {},
|
|
54
|
+
partnerId,
|
|
55
|
+
protocolId
|
|
56
|
+
}) {
|
|
57
|
+
const publicKeysRes = yield ctx.client.getSessionPublicKeys(userId);
|
|
58
|
+
const biometricEncryptedShares = publicKeysRes.data.keys.map((key) => {
|
|
59
|
+
if (!key.publicKey) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const { encryptedMessageHex, encryptedKeyHex } = (0, import_utils.encryptWithDerivedPublicKey)(key.sigDerivedPublicKey, userShare);
|
|
63
|
+
return {
|
|
64
|
+
encryptedShare: encryptedMessageHex,
|
|
65
|
+
encryptedKey: encryptedKeyHex,
|
|
66
|
+
type: import_user_management_client.KeyShareType.USER,
|
|
67
|
+
encryptor: import_user_management_client.EncryptorType.BIOMETRICS,
|
|
68
|
+
biometricPublicKey: key.sigDerivedPublicKey,
|
|
69
|
+
partnerId,
|
|
70
|
+
protocolId
|
|
71
|
+
};
|
|
72
|
+
}).filter(Boolean);
|
|
73
|
+
const passwords = yield ctx.client.getPasswords({ userId });
|
|
74
|
+
const passwordEncryptedShares = passwords.map((password) => {
|
|
75
|
+
if (password.status === "PENDING") {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const { encryptedMessageHex, encryptedKeyHex } = (0, import_utils.encryptWithDerivedPublicKey)(password.sigDerivedPublicKey, userShare);
|
|
79
|
+
return {
|
|
80
|
+
encryptedShare: encryptedMessageHex,
|
|
81
|
+
encryptedKey: encryptedKeyHex,
|
|
82
|
+
type: import_user_management_client.KeyShareType.USER,
|
|
83
|
+
encryptor: import_user_management_client.EncryptorType.PASSWORD,
|
|
84
|
+
passwordId: password.id,
|
|
85
|
+
partnerId,
|
|
86
|
+
protocolId
|
|
87
|
+
};
|
|
88
|
+
}).filter(Boolean);
|
|
89
|
+
const allEncryptedShares = [...biometricEncryptedShares, ...passwordEncryptedShares];
|
|
90
|
+
return yield (0, import_recovery.sendRecoveryForShare)({
|
|
91
|
+
ctx,
|
|
92
|
+
userId,
|
|
93
|
+
walletId,
|
|
94
|
+
otherEncryptedShares: allEncryptedShares,
|
|
95
|
+
userSigner: userShare,
|
|
96
|
+
ignoreRedistributingBackupEncryptedShare,
|
|
97
|
+
emailProps
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
102
|
+
0 && (module.exports = {
|
|
103
|
+
distributeNewShare
|
|
104
|
+
});
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var __async = (__this, __arguments, generator) => {
|
|
29
|
+
return new Promise((resolve, reject) => {
|
|
30
|
+
var fulfilled = (value) => {
|
|
31
|
+
try {
|
|
32
|
+
step(generator.next(value));
|
|
33
|
+
} catch (e) {
|
|
34
|
+
reject(e);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
var rejected = (value) => {
|
|
38
|
+
try {
|
|
39
|
+
step(generator.throw(value));
|
|
40
|
+
} catch (e) {
|
|
41
|
+
reject(e);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
45
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
var transmissionUtils_exports = {};
|
|
49
|
+
__export(transmissionUtils_exports, {
|
|
50
|
+
retrieve: () => retrieve,
|
|
51
|
+
upload: () => upload
|
|
52
|
+
});
|
|
53
|
+
module.exports = __toCommonJS(transmissionUtils_exports);
|
|
54
|
+
var import_ecies = require("@celo/utils/lib/ecies.js");
|
|
55
|
+
var import_buffer = require("buffer");
|
|
56
|
+
var eutil = __toESM(require("@ethereumjs/util"));
|
|
57
|
+
var import_crypto = require("crypto");
|
|
58
|
+
function upload(message, userManagementClient) {
|
|
59
|
+
return __async(this, null, function* () {
|
|
60
|
+
let secret;
|
|
61
|
+
let publicKeyUint8Array;
|
|
62
|
+
while (true) {
|
|
63
|
+
try {
|
|
64
|
+
secret = (0, import_crypto.randomBytes)(32).toString("hex");
|
|
65
|
+
publicKeyUint8Array = eutil.privateToPublic(import_buffer.Buffer.from(secret, "hex"));
|
|
66
|
+
break;
|
|
67
|
+
} catch (e) {
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const pubkey = import_buffer.Buffer.from(publicKeyUint8Array);
|
|
72
|
+
const data = (0, import_ecies.Encrypt)(pubkey, import_buffer.Buffer.from(message, "ucs2")).toString("base64");
|
|
73
|
+
const {
|
|
74
|
+
data: { id }
|
|
75
|
+
} = yield userManagementClient.tempTrasmissionInit(data);
|
|
76
|
+
return encodeURIComponent(id + "|" + secret);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
function retrieve(uriEncodedMessage, userManagementClient) {
|
|
80
|
+
return __async(this, null, function* () {
|
|
81
|
+
const [id, secret] = decodeURIComponent(uriEncodedMessage).split("|");
|
|
82
|
+
const response = yield userManagementClient.tempTrasmission(id);
|
|
83
|
+
const data = response.data.message;
|
|
84
|
+
const buf = import_buffer.Buffer.from(data, "base64");
|
|
85
|
+
const res = import_buffer.Buffer.from((0, import_ecies.Decrypt)(import_buffer.Buffer.from(secret, "hex"), buf).buffer).toString("ucs2");
|
|
86
|
+
return res;
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
90
|
+
0 && (module.exports = {
|
|
91
|
+
retrieve,
|
|
92
|
+
upload
|
|
93
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var auth_exports = {};
|
|
19
|
+
__export(auth_exports, {
|
|
20
|
+
AccountLinkError: () => AccountLinkError
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(auth_exports);
|
|
23
|
+
var AccountLinkError = /* @__PURE__ */ ((AccountLinkError2) => {
|
|
24
|
+
AccountLinkError2["NotAuthenticated"] = "No user is currently authenticated";
|
|
25
|
+
AccountLinkError2["Conflict"] = "Account already linked";
|
|
26
|
+
AccountLinkError2["Canceled"] = "Account linking was canceled";
|
|
27
|
+
AccountLinkError2["Unknown"] = "An unknown error occurred";
|
|
28
|
+
return AccountLinkError2;
|
|
29
|
+
})(AccountLinkError || {});
|
|
30
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
31
|
+
0 && (module.exports = {
|
|
32
|
+
AccountLinkError
|
|
33
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var config_exports = {};
|
|
19
|
+
__export(config_exports, {
|
|
20
|
+
EnabledFlow: () => EnabledFlow,
|
|
21
|
+
Environment: () => Environment
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(config_exports);
|
|
24
|
+
var Environment = /* @__PURE__ */ ((Environment2) => {
|
|
25
|
+
Environment2["DEV"] = "DEV";
|
|
26
|
+
Environment2["SANDBOX"] = "SANDBOX";
|
|
27
|
+
Environment2["BETA"] = "BETA";
|
|
28
|
+
Environment2["PROD"] = "PROD";
|
|
29
|
+
Environment2["DEVELOPMENT"] = "BETA";
|
|
30
|
+
Environment2["PRODUCTION"] = "PROD";
|
|
31
|
+
return Environment2;
|
|
32
|
+
})(Environment || {});
|
|
33
|
+
var EnabledFlow = /* @__PURE__ */ ((EnabledFlow2) => {
|
|
34
|
+
EnabledFlow2["BUY"] = "BUY";
|
|
35
|
+
EnabledFlow2["RECEIVE"] = "RECEIVE";
|
|
36
|
+
EnabledFlow2["WITHDRAW"] = "WITHDRAW";
|
|
37
|
+
return EnabledFlow2;
|
|
38
|
+
})(EnabledFlow || {});
|
|
39
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
40
|
+
0 && (module.exports = {
|
|
41
|
+
EnabledFlow,
|
|
42
|
+
Environment
|
|
43
|
+
});
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var coreApi_exports = {};
|
|
19
|
+
__export(coreApi_exports, {
|
|
20
|
+
PARA_CORE_METHODS: () => PARA_CORE_METHODS,
|
|
21
|
+
PARA_INTERNAL_METHODS: () => PARA_INTERNAL_METHODS
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(coreApi_exports);
|
|
24
|
+
const PARA_CORE_METHODS = [
|
|
25
|
+
"getAuthInfo",
|
|
26
|
+
"signUpOrLogIn",
|
|
27
|
+
"verifyNewAccount",
|
|
28
|
+
"waitForLogin",
|
|
29
|
+
"waitForSignup",
|
|
30
|
+
"waitForWalletCreation",
|
|
31
|
+
"getOAuthUrl",
|
|
32
|
+
"verifyOAuth",
|
|
33
|
+
"getFarcasterConnectUri",
|
|
34
|
+
"verifyFarcaster",
|
|
35
|
+
"verifyTelegram",
|
|
36
|
+
"resendVerificationCode",
|
|
37
|
+
"loginExternalWallet",
|
|
38
|
+
"verifyExternalWallet",
|
|
39
|
+
"setup2fa",
|
|
40
|
+
"enable2fa",
|
|
41
|
+
"verify2fa",
|
|
42
|
+
"logout",
|
|
43
|
+
"clearStorage",
|
|
44
|
+
"isSessionActive",
|
|
45
|
+
"isFullyLoggedIn",
|
|
46
|
+
"refreshSession",
|
|
47
|
+
"keepSessionAlive",
|
|
48
|
+
"exportSession",
|
|
49
|
+
"importSession",
|
|
50
|
+
"getVerificationToken",
|
|
51
|
+
"getWallets",
|
|
52
|
+
"getWalletsByType",
|
|
53
|
+
"fetchWallets",
|
|
54
|
+
"createWallet",
|
|
55
|
+
"createWalletPerType",
|
|
56
|
+
"getPregenWallets",
|
|
57
|
+
"hasPregenWallet",
|
|
58
|
+
"updatePregenWalletIdentifier",
|
|
59
|
+
"createPregenWallet",
|
|
60
|
+
"createPregenWalletPerType",
|
|
61
|
+
"claimPregenWallets",
|
|
62
|
+
"createGuestWallets",
|
|
63
|
+
"distributeNewWalletShare",
|
|
64
|
+
"getUserShare",
|
|
65
|
+
"setUserShare",
|
|
66
|
+
"refreshShare",
|
|
67
|
+
"signMessage",
|
|
68
|
+
"signTransaction",
|
|
69
|
+
"initiateOnRampTransaction",
|
|
70
|
+
"getWalletBalance",
|
|
71
|
+
"issueJwt",
|
|
72
|
+
"getLinkedAccounts",
|
|
73
|
+
"accountLinkInProgress"
|
|
74
|
+
];
|
|
75
|
+
const PARA_INTERNAL_METHODS = [
|
|
76
|
+
"linkAccount",
|
|
77
|
+
"unlinkAccount",
|
|
78
|
+
"verifyEmailOrPhoneLink",
|
|
79
|
+
"verifyOAuthLink",
|
|
80
|
+
"verifyFarcasterLink",
|
|
81
|
+
"verifyTelegramLink",
|
|
82
|
+
"verifyExternalWalletLink",
|
|
83
|
+
"accountLinkInProgress"
|
|
84
|
+
];
|
|
85
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
86
|
+
0 && (module.exports = {
|
|
87
|
+
PARA_CORE_METHODS,
|
|
88
|
+
PARA_INTERNAL_METHODS
|
|
89
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var events_exports = {};
|
|
19
|
+
__export(events_exports, {
|
|
20
|
+
ParaEvent: () => ParaEvent
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(events_exports);
|
|
23
|
+
const EVENT_PREFIX = "para";
|
|
24
|
+
var ParaEvent = ((ParaEvent2) => {
|
|
25
|
+
ParaEvent2["LOGIN_EVENT"] = `${EVENT_PREFIX}Login`;
|
|
26
|
+
ParaEvent2["ACCOUNT_CREATION_EVENT"] = `${EVENT_PREFIX}AccountCreation`;
|
|
27
|
+
ParaEvent2["ACCOUNT_SETUP_EVENT"] = `${EVENT_PREFIX}AccountSetup`;
|
|
28
|
+
ParaEvent2["LOGOUT_EVENT"] = `${EVENT_PREFIX}Logout`;
|
|
29
|
+
ParaEvent2["SIGN_MESSAGE_EVENT"] = `${EVENT_PREFIX}SignMessage`;
|
|
30
|
+
ParaEvent2["SIGN_TRANSACTION_EVENT"] = `${EVENT_PREFIX}SignTransaction`;
|
|
31
|
+
ParaEvent2["EXTERNAL_WALLET_CHANGE_EVENT"] = `${EVENT_PREFIX}ExternalWalletChange`;
|
|
32
|
+
ParaEvent2["WALLETS_CHANGE_EVENT"] = `${EVENT_PREFIX}WalletsChange`;
|
|
33
|
+
ParaEvent2["WALLET_CREATED"] = `${EVENT_PREFIX}WalletCreated`;
|
|
34
|
+
ParaEvent2["PREGEN_WALLET_CLAIMED"] = `${EVENT_PREFIX}PregenWalletClaimed`;
|
|
35
|
+
ParaEvent2["GUEST_WALLETS_CREATED"] = `${EVENT_PREFIX}GuestWalletsCreated`;
|
|
36
|
+
return ParaEvent2;
|
|
37
|
+
})(ParaEvent || {});
|
|
38
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
39
|
+
0 && (module.exports = {
|
|
40
|
+
ParaEvent
|
|
41
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var types_exports = {};
|
|
20
|
+
__export(types_exports, {
|
|
21
|
+
Network: () => import_user_management_client.Network,
|
|
22
|
+
OnRampAsset: () => import_user_management_client.OnRampAsset,
|
|
23
|
+
OnRampProvider: () => import_user_management_client.OnRampProvider,
|
|
24
|
+
OnRampPurchaseStatus: () => import_user_management_client.OnRampPurchaseStatus
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(types_exports);
|
|
27
|
+
__reExport(types_exports, require("./auth.js"), module.exports);
|
|
28
|
+
__reExport(types_exports, require("./config.js"), module.exports);
|
|
29
|
+
__reExport(types_exports, require("./coreApi.js"), module.exports);
|
|
30
|
+
__reExport(types_exports, require("./wallet.js"), module.exports);
|
|
31
|
+
__reExport(types_exports, require("./methods.js"), module.exports);
|
|
32
|
+
__reExport(types_exports, require("./theme.js"), module.exports);
|
|
33
|
+
__reExport(types_exports, require("./onRamps.js"), module.exports);
|
|
34
|
+
__reExport(types_exports, require("./popup.js"), module.exports);
|
|
35
|
+
__reExport(types_exports, require("./recovery.js"), module.exports);
|
|
36
|
+
__reExport(types_exports, require("./events.js"), module.exports);
|
|
37
|
+
var import_user_management_client = require("@getpara/user-management-client");
|
|
38
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
39
|
+
0 && (module.exports = {
|
|
40
|
+
Network,
|
|
41
|
+
OnRampAsset,
|
|
42
|
+
OnRampProvider,
|
|
43
|
+
OnRampPurchaseStatus,
|
|
44
|
+
...require("./auth.js"),
|
|
45
|
+
...require("./config.js"),
|
|
46
|
+
...require("./coreApi.js"),
|
|
47
|
+
...require("./wallet.js"),
|
|
48
|
+
...require("./methods.js"),
|
|
49
|
+
...require("./theme.js"),
|
|
50
|
+
...require("./onRamps.js"),
|
|
51
|
+
...require("./popup.js"),
|
|
52
|
+
...require("./recovery.js"),
|
|
53
|
+
...require("./events.js")
|
|
54
|
+
});
|