@getpara/core-sdk 1.11.0 → 1.12.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/ParaCore.js +52 -0
- package/dist/cjs/constants.js +4 -1
- package/dist/esm/ParaCore.js +52 -0
- package/dist/esm/constants.js +3 -1
- package/dist/types/ParaCore.d.ts +6 -0
- package/dist/types/PlatformUtils.d.ts +2 -1
- package/dist/types/constants.d.ts +1 -0
- package/dist/types/types/config.d.ts +1 -0
- package/package.json +5 -5
package/dist/cjs/ParaCore.js
CHANGED
|
@@ -162,6 +162,37 @@ const _ParaCore = class _ParaCore {
|
|
|
162
162
|
this.platformUtils.secureStorage.clear(constants.PREFIX);
|
|
163
163
|
}
|
|
164
164
|
});
|
|
165
|
+
this.trackError = (methodName, err) => __async(this, null, function* () {
|
|
166
|
+
try {
|
|
167
|
+
yield this.ctx.client.trackError({
|
|
168
|
+
methodName,
|
|
169
|
+
sdkType: this.platformUtils.sdkType,
|
|
170
|
+
userId: this.userId,
|
|
171
|
+
error: {
|
|
172
|
+
name: err.name,
|
|
173
|
+
message: err.message
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
} catch (e) {
|
|
177
|
+
console.error("error tracking error:", e);
|
|
178
|
+
}
|
|
179
|
+
throw err;
|
|
180
|
+
});
|
|
181
|
+
this.wrapMethodsWithErrorTracking = (methodNames) => {
|
|
182
|
+
for (const methodName of methodNames) {
|
|
183
|
+
const original = this[methodName];
|
|
184
|
+
if (typeof original === "function") {
|
|
185
|
+
this[methodName] = (...args) => {
|
|
186
|
+
try {
|
|
187
|
+
const result = original.apply(this, args);
|
|
188
|
+
return result instanceof Promise ? result.catch((err) => this.trackError(methodName, err)) : result;
|
|
189
|
+
} catch (err) {
|
|
190
|
+
return this.trackError(methodName, err);
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
};
|
|
165
196
|
this.initializeFromStorage = () => {
|
|
166
197
|
this.updateEmailFromStorage();
|
|
167
198
|
this.updateCountryCodeFromStorage();
|
|
@@ -267,6 +298,7 @@ const _ParaCore = class _ParaCore {
|
|
|
267
298
|
isE2E = true;
|
|
268
299
|
env = import_types.Environment.SANDBOX;
|
|
269
300
|
}
|
|
301
|
+
this.externalWalletConnectionOnly = opts.externalWalletConnectionOnly;
|
|
270
302
|
this.emailPrimaryColor = opts.emailPrimaryColor;
|
|
271
303
|
this.emailTheme = opts.emailTheme;
|
|
272
304
|
this.homepageUrl = opts.homepageUrl;
|
|
@@ -354,6 +386,19 @@ const _ParaCore = class _ParaCore {
|
|
|
354
386
|
}
|
|
355
387
|
this.initializeFromStorage();
|
|
356
388
|
import_listeners.setupListeners.bind(this)();
|
|
389
|
+
if (env !== import_types.Environment.PROD) {
|
|
390
|
+
this.wrapMethodsWithErrorTracking([
|
|
391
|
+
"createUser",
|
|
392
|
+
"initiateUserLoginV2",
|
|
393
|
+
"waitForPasskeyAndCreateWallet",
|
|
394
|
+
"waitForOAuth",
|
|
395
|
+
"waitForLoginAndSetup",
|
|
396
|
+
"createPregenWallet",
|
|
397
|
+
"claimPregenWallets",
|
|
398
|
+
"signMessage",
|
|
399
|
+
"signTransaction"
|
|
400
|
+
]);
|
|
401
|
+
}
|
|
357
402
|
}
|
|
358
403
|
get isEmail() {
|
|
359
404
|
return !!this.email && !this.phone && !this.countryCode && !this.farcasterUsername && !this.telegramUserId && !this.externalWalletWithParaAuth;
|
|
@@ -1266,6 +1311,13 @@ const _ParaCore = class _ParaCore {
|
|
|
1266
1311
|
*/
|
|
1267
1312
|
externalWalletLogin(wallet) {
|
|
1268
1313
|
return __async(this, null, function* () {
|
|
1314
|
+
if (this.externalWalletConnectionOnly) {
|
|
1315
|
+
wallet.withFullParaAuth = false;
|
|
1316
|
+
yield this.setExternalWallet(wallet);
|
|
1317
|
+
return Promise.resolve({
|
|
1318
|
+
userId: constants.EXTERNAL_WALLET_CONNECTION_ONLY_USER_ID
|
|
1319
|
+
});
|
|
1320
|
+
}
|
|
1269
1321
|
this.requireApiKey();
|
|
1270
1322
|
const res = yield this.ctx.client.externalWalletLogin({
|
|
1271
1323
|
externalAddress: wallet.address,
|
package/dist/cjs/constants.js
CHANGED
|
@@ -17,6 +17,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
var constants_exports = {};
|
|
19
19
|
__export(constants_exports, {
|
|
20
|
+
EXTERNAL_WALLET_CONNECTION_ONLY_USER_ID: () => EXTERNAL_WALLET_CONNECTION_ONLY_USER_ID,
|
|
20
21
|
LOCAL_STORAGE_COUNTRY_CODE: () => LOCAL_STORAGE_COUNTRY_CODE,
|
|
21
22
|
LOCAL_STORAGE_CURRENT_WALLET_IDS: () => LOCAL_STORAGE_CURRENT_WALLET_IDS,
|
|
22
23
|
LOCAL_STORAGE_ED25519_WALLETS: () => LOCAL_STORAGE_ED25519_WALLETS,
|
|
@@ -36,7 +37,7 @@ __export(constants_exports, {
|
|
|
36
37
|
SHORT_POLLING_INTERVAL_MS: () => SHORT_POLLING_INTERVAL_MS
|
|
37
38
|
});
|
|
38
39
|
module.exports = __toCommonJS(constants_exports);
|
|
39
|
-
const PARA_CORE_VERSION =
|
|
40
|
+
const PARA_CORE_VERSION = "1.12.0";
|
|
40
41
|
const PREFIX = "@CAPSULE/";
|
|
41
42
|
const LOCAL_STORAGE_EMAIL = `${PREFIX}e-mail`;
|
|
42
43
|
const LOCAL_STORAGE_PHONE = `${PREFIX}phone`;
|
|
@@ -53,8 +54,10 @@ const LOCAL_STORAGE_SESSION_COOKIE = `${PREFIX}sessionCookie`;
|
|
|
53
54
|
const SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR = `${PREFIX}loginEncryptionKeyPair`;
|
|
54
55
|
const POLLING_INTERVAL_MS = 2e3;
|
|
55
56
|
const SHORT_POLLING_INTERVAL_MS = 1e3;
|
|
57
|
+
const EXTERNAL_WALLET_CONNECTION_ONLY_USER_ID = "EXTERNAL_WALLET_CONNECTION_ONLY";
|
|
56
58
|
// Annotate the CommonJS export names for ESM import in node:
|
|
57
59
|
0 && (module.exports = {
|
|
60
|
+
EXTERNAL_WALLET_CONNECTION_ONLY_USER_ID,
|
|
58
61
|
LOCAL_STORAGE_COUNTRY_CODE,
|
|
59
62
|
LOCAL_STORAGE_CURRENT_WALLET_IDS,
|
|
60
63
|
LOCAL_STORAGE_ED25519_WALLETS,
|
package/dist/esm/ParaCore.js
CHANGED
|
@@ -113,6 +113,37 @@ const _ParaCore = class _ParaCore {
|
|
|
113
113
|
this.platformUtils.secureStorage.clear(constants.PREFIX);
|
|
114
114
|
}
|
|
115
115
|
});
|
|
116
|
+
this.trackError = (methodName, err) => __async(this, null, function* () {
|
|
117
|
+
try {
|
|
118
|
+
yield this.ctx.client.trackError({
|
|
119
|
+
methodName,
|
|
120
|
+
sdkType: this.platformUtils.sdkType,
|
|
121
|
+
userId: this.userId,
|
|
122
|
+
error: {
|
|
123
|
+
name: err.name,
|
|
124
|
+
message: err.message
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
} catch (e) {
|
|
128
|
+
console.error("error tracking error:", e);
|
|
129
|
+
}
|
|
130
|
+
throw err;
|
|
131
|
+
});
|
|
132
|
+
this.wrapMethodsWithErrorTracking = (methodNames) => {
|
|
133
|
+
for (const methodName of methodNames) {
|
|
134
|
+
const original = this[methodName];
|
|
135
|
+
if (typeof original === "function") {
|
|
136
|
+
this[methodName] = (...args) => {
|
|
137
|
+
try {
|
|
138
|
+
const result = original.apply(this, args);
|
|
139
|
+
return result instanceof Promise ? result.catch((err) => this.trackError(methodName, err)) : result;
|
|
140
|
+
} catch (err) {
|
|
141
|
+
return this.trackError(methodName, err);
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
};
|
|
116
147
|
this.initializeFromStorage = () => {
|
|
117
148
|
this.updateEmailFromStorage();
|
|
118
149
|
this.updateCountryCodeFromStorage();
|
|
@@ -218,6 +249,7 @@ const _ParaCore = class _ParaCore {
|
|
|
218
249
|
isE2E = true;
|
|
219
250
|
env = Environment.SANDBOX;
|
|
220
251
|
}
|
|
252
|
+
this.externalWalletConnectionOnly = opts.externalWalletConnectionOnly;
|
|
221
253
|
this.emailPrimaryColor = opts.emailPrimaryColor;
|
|
222
254
|
this.emailTheme = opts.emailTheme;
|
|
223
255
|
this.homepageUrl = opts.homepageUrl;
|
|
@@ -305,6 +337,19 @@ const _ParaCore = class _ParaCore {
|
|
|
305
337
|
}
|
|
306
338
|
this.initializeFromStorage();
|
|
307
339
|
setupListeners.bind(this)();
|
|
340
|
+
if (env !== Environment.PROD) {
|
|
341
|
+
this.wrapMethodsWithErrorTracking([
|
|
342
|
+
"createUser",
|
|
343
|
+
"initiateUserLoginV2",
|
|
344
|
+
"waitForPasskeyAndCreateWallet",
|
|
345
|
+
"waitForOAuth",
|
|
346
|
+
"waitForLoginAndSetup",
|
|
347
|
+
"createPregenWallet",
|
|
348
|
+
"claimPregenWallets",
|
|
349
|
+
"signMessage",
|
|
350
|
+
"signTransaction"
|
|
351
|
+
]);
|
|
352
|
+
}
|
|
308
353
|
}
|
|
309
354
|
get isEmail() {
|
|
310
355
|
return !!this.email && !this.phone && !this.countryCode && !this.farcasterUsername && !this.telegramUserId && !this.externalWalletWithParaAuth;
|
|
@@ -1217,6 +1262,13 @@ const _ParaCore = class _ParaCore {
|
|
|
1217
1262
|
*/
|
|
1218
1263
|
externalWalletLogin(wallet) {
|
|
1219
1264
|
return __async(this, null, function* () {
|
|
1265
|
+
if (this.externalWalletConnectionOnly) {
|
|
1266
|
+
wallet.withFullParaAuth = false;
|
|
1267
|
+
yield this.setExternalWallet(wallet);
|
|
1268
|
+
return Promise.resolve({
|
|
1269
|
+
userId: constants.EXTERNAL_WALLET_CONNECTION_ONLY_USER_ID
|
|
1270
|
+
});
|
|
1271
|
+
}
|
|
1220
1272
|
this.requireApiKey();
|
|
1221
1273
|
const res = yield this.ctx.client.externalWalletLogin({
|
|
1222
1274
|
externalAddress: wallet.address,
|
package/dist/esm/constants.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "./chunk-7B52C2XE.js";
|
|
2
|
-
const PARA_CORE_VERSION =
|
|
2
|
+
const PARA_CORE_VERSION = "1.12.0";
|
|
3
3
|
const PREFIX = "@CAPSULE/";
|
|
4
4
|
const LOCAL_STORAGE_EMAIL = `${PREFIX}e-mail`;
|
|
5
5
|
const LOCAL_STORAGE_PHONE = `${PREFIX}phone`;
|
|
@@ -16,7 +16,9 @@ const LOCAL_STORAGE_SESSION_COOKIE = `${PREFIX}sessionCookie`;
|
|
|
16
16
|
const SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR = `${PREFIX}loginEncryptionKeyPair`;
|
|
17
17
|
const POLLING_INTERVAL_MS = 2e3;
|
|
18
18
|
const SHORT_POLLING_INTERVAL_MS = 1e3;
|
|
19
|
+
const EXTERNAL_WALLET_CONNECTION_ONLY_USER_ID = "EXTERNAL_WALLET_CONNECTION_ONLY";
|
|
19
20
|
export {
|
|
21
|
+
EXTERNAL_WALLET_CONNECTION_ONLY_USER_ID,
|
|
20
22
|
LOCAL_STORAGE_COUNTRY_CODE,
|
|
21
23
|
LOCAL_STORAGE_CURRENT_WALLET_IDS,
|
|
22
24
|
LOCAL_STORAGE_ED25519_WALLETS,
|
package/dist/types/ParaCore.d.ts
CHANGED
|
@@ -112,6 +112,10 @@ export declare abstract class ParaCore {
|
|
|
112
112
|
* @deprecated configure theming through the developer portal
|
|
113
113
|
*/
|
|
114
114
|
portalTheme?: Theme;
|
|
115
|
+
/**
|
|
116
|
+
* Whether or not to treat external wallets as connections only, skipping all Para functionality.
|
|
117
|
+
*/
|
|
118
|
+
externalWalletConnectionOnly?: boolean;
|
|
115
119
|
private disableProviderModal?;
|
|
116
120
|
get isNoWalletConfig(): boolean;
|
|
117
121
|
get supportedWalletTypes(): SupportedWalletTypes;
|
|
@@ -172,6 +176,8 @@ export declare abstract class ParaCore {
|
|
|
172
176
|
* @returns - A new ParaCore instance.
|
|
173
177
|
*/
|
|
174
178
|
constructor(env: Environment, apiKey?: string, opts?: ConstructorOpts);
|
|
179
|
+
private trackError;
|
|
180
|
+
private wrapMethodsWithErrorTracking;
|
|
175
181
|
private initializeFromStorage;
|
|
176
182
|
private updateTelegramUserIdFromStorage;
|
|
177
183
|
private updateUserIdFromStorage;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
-
import { BackupKitEmailProps, TPregenIdentifierType, WalletType } from '@getpara/user-management-client';
|
|
3
|
+
import { BackupKitEmailProps, TPregenIdentifierType, WalletType, SDKType } from '@getpara/user-management-client';
|
|
4
4
|
import { Ctx, PopupType, SignatureRes } from './types/index.js';
|
|
5
5
|
import { StorageUtils } from './StorageUtils.js';
|
|
6
6
|
export interface PlatformUtils {
|
|
7
|
+
sdkType: SDKType;
|
|
7
8
|
getPrivateKey(ctx: Ctx, userId: string, walletId: string, share: string, sessionCookie: string): Promise<string>;
|
|
8
9
|
keygen(ctx: Ctx, userId: string, type: Exclude<WalletType, WalletType.SOLANA>, secretKey: string | null, // should be acceptable as null in RN as we don't pre-gen them
|
|
9
10
|
sessionCookie: string, emailProps?: BackupKitEmailProps): Promise<{
|
|
@@ -15,3 +15,4 @@ export declare const LOCAL_STORAGE_SESSION_COOKIE: string;
|
|
|
15
15
|
export declare const SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR: string;
|
|
16
16
|
export declare const POLLING_INTERVAL_MS = 2000;
|
|
17
17
|
export declare const SHORT_POLLING_INTERVAL_MS = 1000;
|
|
18
|
+
export declare const EXTERNAL_WALLET_CONNECTION_ONLY_USER_ID = "EXTERNAL_WALLET_CONNECTION_ONLY";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/core-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.0",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -10,15 +10,15 @@
|
|
|
10
10
|
"@celo/utils": "^8.0.2",
|
|
11
11
|
"@cosmjs/encoding": "^0.32.4",
|
|
12
12
|
"@ethereumjs/util": "^9.1.0",
|
|
13
|
-
"@getpara/user-management-client": "1.
|
|
13
|
+
"@getpara/user-management-client": "1.12.0",
|
|
14
14
|
"@noble/hashes": "^1.5.0",
|
|
15
15
|
"base64url": "^3.0.1",
|
|
16
16
|
"libphonenumber-js": "1.11.2",
|
|
17
17
|
"node-forge": "^1.3.1",
|
|
18
|
-
"
|
|
18
|
+
"uuid": "^11.1.0"
|
|
19
19
|
},
|
|
20
20
|
"scripts": {
|
|
21
|
-
"build": "rm -rf dist && node ./scripts/build.mjs && yarn build:types
|
|
21
|
+
"build": "rm -rf dist && node ./scripts/build.mjs && yarn build:types",
|
|
22
22
|
"old-build": "yarn build:cjs && yarn build:esm && yarn build:types; yarn post-build",
|
|
23
23
|
"post-build": "./scripts/set-version.sh",
|
|
24
24
|
"build:cjs": "rm -rf dist/cjs && tsc --module commonjs --outDir dist/cjs && printf '{\"type\":\"commonjs\"}' > dist/cjs/package.json",
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"require": "./dist/cjs/index.js"
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "748afcf08c9d307a2d3eaf0716f73132f3eb8529"
|
|
44
44
|
}
|