@getpara/core-sdk 3.1.0 → 3.2.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 +11 -3
- package/dist/cjs/constants.js +1 -1
- package/dist/cjs/external/userManagementClient.js +27 -2
- package/dist/cjs/services/PollingService.js +2 -0
- package/dist/cjs/telemetry/init.js +2 -2
- package/dist/esm/ParaCore.js +12 -4
- package/dist/esm/constants.js +1 -1
- package/dist/esm/external/userManagementClient.js +25 -1
- package/dist/esm/services/PollingService.js +2 -0
- package/dist/esm/telemetry/init.js +2 -2
- package/dist/types/ParaCore.d.ts +1 -0
- package/dist/types/external/userManagementClient.d.ts +11 -1
- package/dist/types/telemetry/init.d.ts +1 -0
- package/dist/types/types/config.d.ts +8 -0
- package/package.json +3 -3
package/dist/cjs/ParaCore.js
CHANGED
|
@@ -265,10 +265,11 @@ const _ParaCore = class _ParaCore {
|
|
|
265
265
|
if (typeof original === "function") {
|
|
266
266
|
this[methodName] = (...args) => {
|
|
267
267
|
var _a;
|
|
268
|
-
const attrs = __spreadValues({
|
|
269
|
-
"para.platform": this.platformUtils.sdkType
|
|
268
|
+
const attrs = __spreadValues(__spreadProps(__spreadValues({
|
|
269
|
+
"para.platform": this.platformUtils.sdkType
|
|
270
|
+
}, this.clientType ? { "para.client_type": this.clientType } : {}), {
|
|
270
271
|
"para.sdk_version": _ParaCore.version
|
|
271
|
-
}, ((_a = this.partner) == null ? void 0 : _a.id) ? { "para.partner_id": this.partner.id } : {});
|
|
272
|
+
}), ((_a = this.partner) == null ? void 0 : _a.id) ? { "para.partner_id": this.partner.id } : {});
|
|
272
273
|
return (0, import_tracer.wrapWithSpan)(
|
|
273
274
|
methodName,
|
|
274
275
|
(span) => __async(this, null, function* () {
|
|
@@ -430,6 +431,7 @@ const _ParaCore = class _ParaCore {
|
|
|
430
431
|
this.addCredential = (params) => __async(this, null, function* () {
|
|
431
432
|
return yield __privateGet(this, _authService).addCredential(params);
|
|
432
433
|
});
|
|
434
|
+
var _a;
|
|
433
435
|
let env, apiKey;
|
|
434
436
|
const actualArgs = Array.from(arguments).filter((arg) => arg !== void 0);
|
|
435
437
|
const actualArgumentCount = actualArgs.length;
|
|
@@ -514,11 +516,16 @@ const _ParaCore = class _ParaCore {
|
|
|
514
516
|
refreshJwt
|
|
515
517
|
);
|
|
516
518
|
};
|
|
519
|
+
const rawPlatform = (_a = opts.hostPlatform) != null ? _a : this.platformUtils.sdkType;
|
|
520
|
+
this.clientType = (0, import_userManagementClient.normalizePlatform)(rawPlatform);
|
|
517
521
|
const client = (0, import_userManagementClient.initClient)({
|
|
518
522
|
env,
|
|
519
523
|
version: _ParaCore.version,
|
|
520
524
|
apiKey,
|
|
521
525
|
partnerId: this.isPortal(env) ? opts.portalPartnerId : void 0,
|
|
526
|
+
// Native shells (Swift/Flutter) set opts.hostPlatform via bridge-v2; web and
|
|
527
|
+
// React Native fall back to the in-process sdkType. Normalized in initClient.
|
|
528
|
+
platform: rawPlatform,
|
|
522
529
|
useFetchAdapter: !!opts.disableWorkers,
|
|
523
530
|
retrieveSessionCookie: this.retrieveSessionCookie,
|
|
524
531
|
persistSessionCookie: this.persistSessionCookie
|
|
@@ -1570,6 +1577,7 @@ const _ParaCore = class _ParaCore {
|
|
|
1570
1577
|
tunnelUrl: `${(0, import_userManagementClient.getBaseUrl)(this.ctx.env)}telemetry`,
|
|
1571
1578
|
sampleRate: telemetry.sample_rate,
|
|
1572
1579
|
sdkType: this.platformUtils.sdkType,
|
|
1580
|
+
clientType: this.clientType,
|
|
1573
1581
|
sdkVersion: _ParaCore.version,
|
|
1574
1582
|
partnerId: this.partner.id,
|
|
1575
1583
|
// Only true in DEV — adds localhost to the trace-propagation allow-list
|
package/dist/cjs/constants.js
CHANGED
|
@@ -46,7 +46,7 @@ __export(constants_exports, {
|
|
|
46
46
|
TRANSACTION_REVIEW_TIMEOUT_MS: () => TRANSACTION_REVIEW_TIMEOUT_MS
|
|
47
47
|
});
|
|
48
48
|
module.exports = __toCommonJS(constants_exports);
|
|
49
|
-
const PARA_CORE_VERSION = "3.
|
|
49
|
+
const PARA_CORE_VERSION = "3.2.0";
|
|
50
50
|
const PREFIX = "@CAPSULE/";
|
|
51
51
|
const PARA_PREFIX = "@PARA/";
|
|
52
52
|
const LOCAL_STORAGE_AUTH_INFO = `${PREFIX}authInfo`;
|
|
@@ -30,7 +30,8 @@ __export(userManagementClient_exports, {
|
|
|
30
30
|
getBaseMPCNetworkUrl: () => getBaseMPCNetworkUrl,
|
|
31
31
|
getBaseOAuthUrl: () => getBaseOAuthUrl,
|
|
32
32
|
getBaseUrl: () => getBaseUrl,
|
|
33
|
-
initClient: () => initClient
|
|
33
|
+
initClient: () => initClient,
|
|
34
|
+
normalizePlatform: () => normalizePlatform
|
|
34
35
|
});
|
|
35
36
|
module.exports = __toCommonJS(userManagementClient_exports);
|
|
36
37
|
var import_user_management_client = __toESM(require("@getpara/user-management-client"));
|
|
@@ -93,11 +94,33 @@ function getBaseMPCNetworkUrl(env, useWebsocket) {
|
|
|
93
94
|
throw new Error(`unsupported env: ${env}`);
|
|
94
95
|
}
|
|
95
96
|
}
|
|
97
|
+
function normalizePlatform(platform) {
|
|
98
|
+
switch (platform) {
|
|
99
|
+
case "iOS":
|
|
100
|
+
case "ios":
|
|
101
|
+
case "swift":
|
|
102
|
+
return "swift";
|
|
103
|
+
case "flutter":
|
|
104
|
+
return "flutter";
|
|
105
|
+
case "REACT_NATIVE":
|
|
106
|
+
case "react-native":
|
|
107
|
+
return "react-native";
|
|
108
|
+
case "WEB":
|
|
109
|
+
case "web":
|
|
110
|
+
return "web";
|
|
111
|
+
case "SERVER":
|
|
112
|
+
case "server":
|
|
113
|
+
return "server";
|
|
114
|
+
default:
|
|
115
|
+
return void 0;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
96
118
|
function initClient({
|
|
97
119
|
env,
|
|
98
120
|
version,
|
|
99
121
|
apiKey,
|
|
100
122
|
partnerId,
|
|
123
|
+
platform,
|
|
101
124
|
useFetchAdapter = false,
|
|
102
125
|
retrieveSessionCookie,
|
|
103
126
|
persistSessionCookie,
|
|
@@ -108,6 +131,7 @@ function initClient({
|
|
|
108
131
|
version: [import_types.Environment.DEV, import_types.Environment.SANDBOX].includes(env) ? "dev" : version,
|
|
109
132
|
apiKey,
|
|
110
133
|
partnerId,
|
|
134
|
+
clientType: normalizePlatform(platform),
|
|
111
135
|
opts: { useFetchAdapter },
|
|
112
136
|
retrieveSessionCookie,
|
|
113
137
|
persistSessionCookie,
|
|
@@ -119,5 +143,6 @@ function initClient({
|
|
|
119
143
|
getBaseMPCNetworkUrl,
|
|
120
144
|
getBaseOAuthUrl,
|
|
121
145
|
getBaseUrl,
|
|
122
|
-
initClient
|
|
146
|
+
initClient,
|
|
147
|
+
normalizePlatform
|
|
123
148
|
});
|
|
@@ -412,6 +412,8 @@ class PollingService {
|
|
|
412
412
|
if (__privateGet(this, _walletService).currentWalletIdsArray.length === 0) {
|
|
413
413
|
return { finished: false };
|
|
414
414
|
}
|
|
415
|
+
} else if (__privateGet(this, _walletService).currentWalletIdsArray.length === 0) {
|
|
416
|
+
return { finished: true };
|
|
415
417
|
}
|
|
416
418
|
const sessionLookupId = session.sessionLookupId;
|
|
417
419
|
const temporaryShares = (yield __privateGet(this, _paraCoreInterface).ctx.client.getTransmissionKeyshares(__privateGet(this, _authService).userId, sessionLookupId)).data.temporaryShares;
|
|
@@ -99,11 +99,11 @@ function initTelemetry(opts) {
|
|
|
99
99
|
} catch (e) {
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
|
-
const resource = (0, import_resources.resourceFromAttributes)(__spreadValues(__spreadValues({
|
|
102
|
+
const resource = (0, import_resources.resourceFromAttributes)(__spreadValues(__spreadValues(__spreadValues({
|
|
103
103
|
[import_semantic_conventions.ATTR_SERVICE_NAME]: opts.isPortal ? "para-portal" : "para-sdk",
|
|
104
104
|
[import_semantic_conventions.ATTR_SERVICE_VERSION]: opts.sdkVersion,
|
|
105
105
|
"para.platform": opts.sdkType
|
|
106
|
-
}, opts.partnerId ? { "para.partner_id": opts.partnerId } : {}), opts.resourceAttributes));
|
|
106
|
+
}, opts.clientType ? { "para.client_type": opts.clientType } : {}), opts.partnerId ? { "para.partner_id": opts.partnerId } : {}), opts.resourceAttributes));
|
|
107
107
|
const exporter = new import_exporter_trace_otlp_http.OTLPTraceExporter({
|
|
108
108
|
url: opts.tunnelUrl
|
|
109
109
|
// No auth header — the tunnel is a dumb proxy. Per-IP rate limit + body cap on the
|
package/dist/esm/ParaCore.js
CHANGED
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
import forge from "node-forge";
|
|
30
30
|
const { pki, jsbn } = forge;
|
|
31
31
|
import { decryptWithPrivateKey, getAsymmetricKeyPair } from "./cryptography/utils.js";
|
|
32
|
-
import { getBaseUrl, initClient } from "./external/userManagementClient.js";
|
|
32
|
+
import { getBaseUrl, initClient, normalizePlatform } from "./external/userManagementClient.js";
|
|
33
33
|
import * as mpcComputationClient from "./external/mpcComputationClient.js";
|
|
34
34
|
import {
|
|
35
35
|
Environment,
|
|
@@ -210,10 +210,11 @@ const _ParaCore = class _ParaCore {
|
|
|
210
210
|
if (typeof original === "function") {
|
|
211
211
|
this[methodName] = (...args) => {
|
|
212
212
|
var _a;
|
|
213
|
-
const attrs = __spreadValues({
|
|
214
|
-
"para.platform": this.platformUtils.sdkType
|
|
213
|
+
const attrs = __spreadValues(__spreadProps(__spreadValues({
|
|
214
|
+
"para.platform": this.platformUtils.sdkType
|
|
215
|
+
}, this.clientType ? { "para.client_type": this.clientType } : {}), {
|
|
215
216
|
"para.sdk_version": _ParaCore.version
|
|
216
|
-
}, ((_a = this.partner) == null ? void 0 : _a.id) ? { "para.partner_id": this.partner.id } : {});
|
|
217
|
+
}), ((_a = this.partner) == null ? void 0 : _a.id) ? { "para.partner_id": this.partner.id } : {});
|
|
217
218
|
return wrapWithSpan(
|
|
218
219
|
methodName,
|
|
219
220
|
(span) => __async(this, null, function* () {
|
|
@@ -375,6 +376,7 @@ const _ParaCore = class _ParaCore {
|
|
|
375
376
|
this.addCredential = (params) => __async(this, null, function* () {
|
|
376
377
|
return yield __privateGet(this, _authService).addCredential(params);
|
|
377
378
|
});
|
|
379
|
+
var _a;
|
|
378
380
|
let env, apiKey;
|
|
379
381
|
const actualArgs = Array.from(arguments).filter((arg) => arg !== void 0);
|
|
380
382
|
const actualArgumentCount = actualArgs.length;
|
|
@@ -459,11 +461,16 @@ const _ParaCore = class _ParaCore {
|
|
|
459
461
|
refreshJwt
|
|
460
462
|
);
|
|
461
463
|
};
|
|
464
|
+
const rawPlatform = (_a = opts.hostPlatform) != null ? _a : this.platformUtils.sdkType;
|
|
465
|
+
this.clientType = normalizePlatform(rawPlatform);
|
|
462
466
|
const client = initClient({
|
|
463
467
|
env,
|
|
464
468
|
version: _ParaCore.version,
|
|
465
469
|
apiKey,
|
|
466
470
|
partnerId: this.isPortal(env) ? opts.portalPartnerId : void 0,
|
|
471
|
+
// Native shells (Swift/Flutter) set opts.hostPlatform via bridge-v2; web and
|
|
472
|
+
// React Native fall back to the in-process sdkType. Normalized in initClient.
|
|
473
|
+
platform: rawPlatform,
|
|
467
474
|
useFetchAdapter: !!opts.disableWorkers,
|
|
468
475
|
retrieveSessionCookie: this.retrieveSessionCookie,
|
|
469
476
|
persistSessionCookie: this.persistSessionCookie
|
|
@@ -1515,6 +1522,7 @@ const _ParaCore = class _ParaCore {
|
|
|
1515
1522
|
tunnelUrl: `${getBaseUrl(this.ctx.env)}telemetry`,
|
|
1516
1523
|
sampleRate: telemetry.sample_rate,
|
|
1517
1524
|
sdkType: this.platformUtils.sdkType,
|
|
1525
|
+
clientType: this.clientType,
|
|
1518
1526
|
sdkVersion: _ParaCore.version,
|
|
1519
1527
|
partnerId: this.partner.id,
|
|
1520
1528
|
// Only true in DEV — adds localhost to the trace-propagation allow-list
|
package/dist/esm/constants.js
CHANGED
|
@@ -59,11 +59,33 @@ function getBaseMPCNetworkUrl(env, useWebsocket) {
|
|
|
59
59
|
throw new Error(`unsupported env: ${env}`);
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
+
function normalizePlatform(platform) {
|
|
63
|
+
switch (platform) {
|
|
64
|
+
case "iOS":
|
|
65
|
+
case "ios":
|
|
66
|
+
case "swift":
|
|
67
|
+
return "swift";
|
|
68
|
+
case "flutter":
|
|
69
|
+
return "flutter";
|
|
70
|
+
case "REACT_NATIVE":
|
|
71
|
+
case "react-native":
|
|
72
|
+
return "react-native";
|
|
73
|
+
case "WEB":
|
|
74
|
+
case "web":
|
|
75
|
+
return "web";
|
|
76
|
+
case "SERVER":
|
|
77
|
+
case "server":
|
|
78
|
+
return "server";
|
|
79
|
+
default:
|
|
80
|
+
return void 0;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
62
83
|
function initClient({
|
|
63
84
|
env,
|
|
64
85
|
version,
|
|
65
86
|
apiKey,
|
|
66
87
|
partnerId,
|
|
88
|
+
platform,
|
|
67
89
|
useFetchAdapter = false,
|
|
68
90
|
retrieveSessionCookie,
|
|
69
91
|
persistSessionCookie,
|
|
@@ -74,6 +96,7 @@ function initClient({
|
|
|
74
96
|
version: [Environment.DEV, Environment.SANDBOX].includes(env) ? "dev" : version,
|
|
75
97
|
apiKey,
|
|
76
98
|
partnerId,
|
|
99
|
+
clientType: normalizePlatform(platform),
|
|
77
100
|
opts: { useFetchAdapter },
|
|
78
101
|
retrieveSessionCookie,
|
|
79
102
|
persistSessionCookie,
|
|
@@ -84,5 +107,6 @@ export {
|
|
|
84
107
|
getBaseMPCNetworkUrl,
|
|
85
108
|
getBaseOAuthUrl,
|
|
86
109
|
getBaseUrl,
|
|
87
|
-
initClient
|
|
110
|
+
initClient,
|
|
111
|
+
normalizePlatform
|
|
88
112
|
};
|
|
@@ -354,6 +354,8 @@ class PollingService {
|
|
|
354
354
|
if (__privateGet(this, _walletService).currentWalletIdsArray.length === 0) {
|
|
355
355
|
return { finished: false };
|
|
356
356
|
}
|
|
357
|
+
} else if (__privateGet(this, _walletService).currentWalletIdsArray.length === 0) {
|
|
358
|
+
return { finished: true };
|
|
357
359
|
}
|
|
358
360
|
const sessionLookupId = session.sessionLookupId;
|
|
359
361
|
const temporaryShares = (yield __privateGet(this, _paraCoreInterface).ctx.client.getTransmissionKeyshares(__privateGet(this, _authService).userId, sessionLookupId)).data.temporaryShares;
|
|
@@ -37,11 +37,11 @@ function initTelemetry(opts) {
|
|
|
37
37
|
} catch (e) {
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
const resource = resourceFromAttributes(__spreadValues(__spreadValues({
|
|
40
|
+
const resource = resourceFromAttributes(__spreadValues(__spreadValues(__spreadValues({
|
|
41
41
|
[ATTR_SERVICE_NAME]: opts.isPortal ? "para-portal" : "para-sdk",
|
|
42
42
|
[ATTR_SERVICE_VERSION]: opts.sdkVersion,
|
|
43
43
|
"para.platform": opts.sdkType
|
|
44
|
-
}, opts.partnerId ? { "para.partner_id": opts.partnerId } : {}), opts.resourceAttributes));
|
|
44
|
+
}, opts.clientType ? { "para.client_type": opts.clientType } : {}), opts.partnerId ? { "para.partner_id": opts.partnerId } : {}), opts.resourceAttributes));
|
|
45
45
|
const exporter = new OTLPTraceExporter({
|
|
46
46
|
url: opts.tunnelUrl
|
|
47
47
|
// No auth header — the tunnel is a dumb proxy. Per-IP rate limit + body cap on the
|
package/dist/types/ParaCore.d.ts
CHANGED
|
@@ -295,6 +295,7 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
295
295
|
onRampPurchase: OnRampPurchase;
|
|
296
296
|
} | undefined;
|
|
297
297
|
protected platformUtils: PlatformUtils;
|
|
298
|
+
private clientType?;
|
|
298
299
|
protected nonPersistedStorageKeys: string[];
|
|
299
300
|
private localStorageGetItem;
|
|
300
301
|
private localStorageSetItem;
|
|
@@ -3,11 +3,21 @@ import { Environment } from '../types/index.js';
|
|
|
3
3
|
export declare function getBaseOAuthUrl(env: Environment): string;
|
|
4
4
|
export declare function getBaseUrl(env: Environment, scheme?: 'http' | 'ws'): string;
|
|
5
5
|
export declare function getBaseMPCNetworkUrl(env: Environment, useWebsocket?: boolean): string;
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Maps a raw host-platform / sdkType value onto the normalized `client_type`
|
|
8
|
+
* dimension used by backend analytics + Sentry. Unknown values (e.g. BRIDGE
|
|
9
|
+
* without a resolved host) return undefined so the backend omits the property
|
|
10
|
+
* rather than emitting a meaningless bucket. CLI sets `client_type` directly
|
|
11
|
+
* outside this core SDK path.
|
|
12
|
+
*/
|
|
13
|
+
export declare function normalizePlatform(platform?: string): string | undefined;
|
|
14
|
+
export declare function initClient({ env, version, apiKey, partnerId, platform, useFetchAdapter, retrieveSessionCookie, persistSessionCookie, staticTraceContext, }: {
|
|
7
15
|
env: Environment;
|
|
8
16
|
version?: string;
|
|
9
17
|
apiKey: string;
|
|
10
18
|
partnerId?: string;
|
|
19
|
+
/** Raw host platform (e.g. 'iOS', 'flutter') or sdkType; normalized to client_type. */
|
|
20
|
+
platform?: string;
|
|
11
21
|
useFetchAdapter?: boolean;
|
|
12
22
|
retrieveSessionCookie?: () => string;
|
|
13
23
|
persistSessionCookie?: (cookie: string) => void;
|
|
@@ -59,6 +59,14 @@ export type SupportedWalletTypeConfig = {
|
|
|
59
59
|
optional?: boolean;
|
|
60
60
|
};
|
|
61
61
|
export interface ConstructorOpts {
|
|
62
|
+
/**
|
|
63
|
+
* Host platform of the native shell hosting this SDK instance (e.g. 'iOS',
|
|
64
|
+
* 'flutter'). Set by bridge-v2 from the native Para#init metadata so the
|
|
65
|
+
* backend can attribute analytics/errors to the originating SDK. Normalized
|
|
66
|
+
* to client_type (swift | flutter | react-native | web). React Native and
|
|
67
|
+
* web derive their platform from platformUtils.sdkType and leave this unset.
|
|
68
|
+
*/
|
|
69
|
+
hostPlatform?: string;
|
|
62
70
|
externalWalletConnectionOnly?: boolean;
|
|
63
71
|
useStorageOverrides?: boolean;
|
|
64
72
|
disableWorkers?: boolean;
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/core-sdk",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@celo/utils": "^8.0.2",
|
|
6
6
|
"@cosmjs/encoding": "^0.32.4",
|
|
7
7
|
"@ethereumjs/util": "^9.1.0",
|
|
8
|
-
"@getpara/user-management-client": "3.
|
|
8
|
+
"@getpara/user-management-client": "3.2.0",
|
|
9
9
|
"@noble/hashes": "^1.5.0",
|
|
10
10
|
"@opentelemetry/api": "^1.9.1",
|
|
11
11
|
"@opentelemetry/context-zone": "^2.7.1",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"dist",
|
|
42
42
|
"package.json"
|
|
43
43
|
],
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "096152f48e9d9a64fdb192588315c64d33d15a1b",
|
|
45
45
|
"main": "dist/cjs/index.js",
|
|
46
46
|
"module": "dist/esm/index.js",
|
|
47
47
|
"scripts": {
|