@getpara/core-sdk 3.2.0 → 3.4.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 +6 -2
- package/dist/cjs/constants.js +1 -1
- package/dist/cjs/external/userManagementClient.js +6 -2
- package/dist/cjs/services/AuthService.js +3 -1
- package/dist/cjs/services/SessionManagementService.js +14 -0
- package/dist/esm/ParaCore.js +6 -2
- package/dist/esm/constants.js +1 -1
- package/dist/esm/external/userManagementClient.js +6 -2
- package/dist/esm/services/AuthService.js +3 -1
- package/dist/esm/services/SessionManagementService.js +14 -0
- package/dist/types/PlatformUtils.d.ts +11 -0
- package/dist/types/external/userManagementClient.d.ts +3 -1
- package/dist/types/services/SessionManagementService.d.ts +1 -0
- package/package.json +3 -3
package/dist/cjs/ParaCore.js
CHANGED
|
@@ -431,7 +431,7 @@ const _ParaCore = class _ParaCore {
|
|
|
431
431
|
this.addCredential = (params) => __async(this, null, function* () {
|
|
432
432
|
return yield __privateGet(this, _authService).addCredential(params);
|
|
433
433
|
});
|
|
434
|
-
var _a;
|
|
434
|
+
var _a, _b, _c;
|
|
435
435
|
let env, apiKey;
|
|
436
436
|
const actualArgs = Array.from(arguments).filter((arg) => arg !== void 0);
|
|
437
437
|
const actualArgumentCount = actualArgs.length;
|
|
@@ -518,6 +518,7 @@ const _ParaCore = class _ParaCore {
|
|
|
518
518
|
};
|
|
519
519
|
const rawPlatform = (_a = opts.hostPlatform) != null ? _a : this.platformUtils.sdkType;
|
|
520
520
|
this.clientType = (0, import_userManagementClient.normalizePlatform)(rawPlatform);
|
|
521
|
+
const requestAgents = (_c = (_b = this.platformUtils).getRequestAgents) == null ? void 0 : _c.call(_b);
|
|
521
522
|
const client = (0, import_userManagementClient.initClient)({
|
|
522
523
|
env,
|
|
523
524
|
version: _ParaCore.version,
|
|
@@ -528,7 +529,9 @@ const _ParaCore = class _ParaCore {
|
|
|
528
529
|
platform: rawPlatform,
|
|
529
530
|
useFetchAdapter: !!opts.disableWorkers,
|
|
530
531
|
retrieveSessionCookie: this.retrieveSessionCookie,
|
|
531
|
-
persistSessionCookie: this.persistSessionCookie
|
|
532
|
+
persistSessionCookie: this.persistSessionCookie,
|
|
533
|
+
httpAgent: requestAgents == null ? void 0 : requestAgents.httpAgent,
|
|
534
|
+
httpsAgent: requestAgents == null ? void 0 : requestAgents.httpsAgent
|
|
532
535
|
});
|
|
533
536
|
const enclaveClient = new import_enclave.EnclaveClient({
|
|
534
537
|
userManagementClient: client,
|
|
@@ -3489,6 +3492,7 @@ logout_fn = function() {
|
|
|
3489
3492
|
this.accountLinkInProgress = void 0;
|
|
3490
3493
|
__privateGet(this, _authService).userId = void 0;
|
|
3491
3494
|
__privateGet(this, _sessionManagementService).sessionCookie = void 0;
|
|
3495
|
+
__privateGet(this, _sessionManagementService).invalidateTouchSessionCache();
|
|
3492
3496
|
this.isEnclaveUser = false;
|
|
3493
3497
|
(0, import_uxStateSpanProcessor.setCurrentUserId)(void 0);
|
|
3494
3498
|
if (isSessionActive) {
|
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.4.0";
|
|
50
50
|
const PREFIX = "@CAPSULE/";
|
|
51
51
|
const PARA_PREFIX = "@PARA/";
|
|
52
52
|
const LOCAL_STORAGE_AUTH_INFO = `${PREFIX}authInfo`;
|
|
@@ -124,7 +124,9 @@ function initClient({
|
|
|
124
124
|
useFetchAdapter = false,
|
|
125
125
|
retrieveSessionCookie,
|
|
126
126
|
persistSessionCookie,
|
|
127
|
-
staticTraceContext
|
|
127
|
+
staticTraceContext,
|
|
128
|
+
httpAgent,
|
|
129
|
+
httpsAgent
|
|
128
130
|
}) {
|
|
129
131
|
return new import_user_management_client.default({
|
|
130
132
|
userManagementHost: getBaseUrl(env),
|
|
@@ -135,7 +137,9 @@ function initClient({
|
|
|
135
137
|
opts: { useFetchAdapter },
|
|
136
138
|
retrieveSessionCookie,
|
|
137
139
|
persistSessionCookie,
|
|
138
|
-
staticTraceContext
|
|
140
|
+
staticTraceContext,
|
|
141
|
+
httpAgent,
|
|
142
|
+
httpsAgent
|
|
139
143
|
});
|
|
140
144
|
}
|
|
141
145
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -686,6 +686,7 @@ class AuthService {
|
|
|
686
686
|
}
|
|
687
687
|
}
|
|
688
688
|
const { sessionId } = yield __privateGet(this, _sessionManagementService).touchSession();
|
|
689
|
+
const hasExistingPasskey = userAuthMethods.has(import_user_management_client.AuthMethod.PASSKEY);
|
|
689
690
|
const result = (isForNewDevice || urlType) && (yield __privateGet(this, _portalUrlService).constructPortalUrl(isForNewDevice ? "addNewCredential" : urlType, {
|
|
690
691
|
isForNewDevice,
|
|
691
692
|
pathId: credentialId,
|
|
@@ -694,7 +695,8 @@ class AuthService {
|
|
|
694
695
|
sessionId: isForNewDevice ? sessionId : void 0,
|
|
695
696
|
addNewCredentialType: optsAuthMethod,
|
|
696
697
|
addNewCredentialPasskeyId: passkeyId,
|
|
697
|
-
addNewCredentialPasswordId: passwordId
|
|
698
|
+
addNewCredentialPasswordId: passwordId,
|
|
699
|
+
useLegacyUrl: hasExistingPasskey
|
|
698
700
|
}));
|
|
699
701
|
return __spreadValues({ credentialId }, result ? { url: result.url, fullUrl: result.fullUrl } : {});
|
|
700
702
|
});
|
|
@@ -218,6 +218,20 @@ const _SessionManagementService = class _SessionManagementService {
|
|
|
218
218
|
}
|
|
219
219
|
return session;
|
|
220
220
|
}));
|
|
221
|
+
// Drop the dedupe cache so the next touchSession() round-trips to the server
|
|
222
|
+
// instead of replaying the pre-logout snapshot. Without this, the core state
|
|
223
|
+
// machine's post-logout `checkUserState` (auth machine) hits the cache within
|
|
224
|
+
// the 1s TTL, sees `isAuthenticated: true` and `currentWalletIds` from before
|
|
225
|
+
// logout, re-applies the wallet IDs via #doTouchSession line 235-237, and
|
|
226
|
+
// reports `isFullyLoggedIn=true` — sending the state machine back to
|
|
227
|
+
// `authenticated` instead of `unauthenticated`. Called from ParaCore.#logout
|
|
228
|
+
// after the session cookie + in-memory auth state are cleared, so the next
|
|
229
|
+
// touchSession sees a fresh "no session" response.
|
|
230
|
+
this.invalidateTouchSessionCache = () => {
|
|
231
|
+
__privateSet(this, _touchCached, void 0);
|
|
232
|
+
__privateSet(this, _touchCachedAt, void 0);
|
|
233
|
+
__privateSet(this, _touchPromise, void 0);
|
|
234
|
+
};
|
|
221
235
|
this.isSessionActive = () => __async(this, null, function* () {
|
|
222
236
|
if (__privateGet(this, _externalWalletService).externalWalletConnectionType === "CONNECTION_ONLY") {
|
|
223
237
|
return true;
|
package/dist/esm/ParaCore.js
CHANGED
|
@@ -376,7 +376,7 @@ const _ParaCore = class _ParaCore {
|
|
|
376
376
|
this.addCredential = (params) => __async(this, null, function* () {
|
|
377
377
|
return yield __privateGet(this, _authService).addCredential(params);
|
|
378
378
|
});
|
|
379
|
-
var _a;
|
|
379
|
+
var _a, _b, _c;
|
|
380
380
|
let env, apiKey;
|
|
381
381
|
const actualArgs = Array.from(arguments).filter((arg) => arg !== void 0);
|
|
382
382
|
const actualArgumentCount = actualArgs.length;
|
|
@@ -463,6 +463,7 @@ const _ParaCore = class _ParaCore {
|
|
|
463
463
|
};
|
|
464
464
|
const rawPlatform = (_a = opts.hostPlatform) != null ? _a : this.platformUtils.sdkType;
|
|
465
465
|
this.clientType = normalizePlatform(rawPlatform);
|
|
466
|
+
const requestAgents = (_c = (_b = this.platformUtils).getRequestAgents) == null ? void 0 : _c.call(_b);
|
|
466
467
|
const client = initClient({
|
|
467
468
|
env,
|
|
468
469
|
version: _ParaCore.version,
|
|
@@ -473,7 +474,9 @@ const _ParaCore = class _ParaCore {
|
|
|
473
474
|
platform: rawPlatform,
|
|
474
475
|
useFetchAdapter: !!opts.disableWorkers,
|
|
475
476
|
retrieveSessionCookie: this.retrieveSessionCookie,
|
|
476
|
-
persistSessionCookie: this.persistSessionCookie
|
|
477
|
+
persistSessionCookie: this.persistSessionCookie,
|
|
478
|
+
httpAgent: requestAgents == null ? void 0 : requestAgents.httpAgent,
|
|
479
|
+
httpsAgent: requestAgents == null ? void 0 : requestAgents.httpsAgent
|
|
477
480
|
});
|
|
478
481
|
const enclaveClient = new EnclaveClient({
|
|
479
482
|
userManagementClient: client,
|
|
@@ -3434,6 +3437,7 @@ logout_fn = function() {
|
|
|
3434
3437
|
this.accountLinkInProgress = void 0;
|
|
3435
3438
|
__privateGet(this, _authService).userId = void 0;
|
|
3436
3439
|
__privateGet(this, _sessionManagementService).sessionCookie = void 0;
|
|
3440
|
+
__privateGet(this, _sessionManagementService).invalidateTouchSessionCache();
|
|
3437
3441
|
this.isEnclaveUser = false;
|
|
3438
3442
|
setCurrentUserId(void 0);
|
|
3439
3443
|
if (isSessionActive) {
|
package/dist/esm/constants.js
CHANGED
|
@@ -89,7 +89,9 @@ function initClient({
|
|
|
89
89
|
useFetchAdapter = false,
|
|
90
90
|
retrieveSessionCookie,
|
|
91
91
|
persistSessionCookie,
|
|
92
|
-
staticTraceContext
|
|
92
|
+
staticTraceContext,
|
|
93
|
+
httpAgent,
|
|
94
|
+
httpsAgent
|
|
93
95
|
}) {
|
|
94
96
|
return new Client({
|
|
95
97
|
userManagementHost: getBaseUrl(env),
|
|
@@ -100,7 +102,9 @@ function initClient({
|
|
|
100
102
|
opts: { useFetchAdapter },
|
|
101
103
|
retrieveSessionCookie,
|
|
102
104
|
persistSessionCookie,
|
|
103
|
-
staticTraceContext
|
|
105
|
+
staticTraceContext,
|
|
106
|
+
httpAgent,
|
|
107
|
+
httpsAgent
|
|
104
108
|
});
|
|
105
109
|
}
|
|
106
110
|
export {
|
|
@@ -617,6 +617,7 @@ class AuthService {
|
|
|
617
617
|
}
|
|
618
618
|
}
|
|
619
619
|
const { sessionId } = yield __privateGet(this, _sessionManagementService).touchSession();
|
|
620
|
+
const hasExistingPasskey = userAuthMethods.has(AuthMethod.PASSKEY);
|
|
620
621
|
const result = (isForNewDevice || urlType) && (yield __privateGet(this, _portalUrlService).constructPortalUrl(isForNewDevice ? "addNewCredential" : urlType, {
|
|
621
622
|
isForNewDevice,
|
|
622
623
|
pathId: credentialId,
|
|
@@ -625,7 +626,8 @@ class AuthService {
|
|
|
625
626
|
sessionId: isForNewDevice ? sessionId : void 0,
|
|
626
627
|
addNewCredentialType: optsAuthMethod,
|
|
627
628
|
addNewCredentialPasskeyId: passkeyId,
|
|
628
|
-
addNewCredentialPasswordId: passwordId
|
|
629
|
+
addNewCredentialPasswordId: passwordId,
|
|
630
|
+
useLegacyUrl: hasExistingPasskey
|
|
629
631
|
}));
|
|
630
632
|
return __spreadValues({ credentialId }, result ? { url: result.url, fullUrl: result.fullUrl } : {});
|
|
631
633
|
});
|
|
@@ -162,6 +162,20 @@ const _SessionManagementService = class _SessionManagementService {
|
|
|
162
162
|
}
|
|
163
163
|
return session;
|
|
164
164
|
}));
|
|
165
|
+
// Drop the dedupe cache so the next touchSession() round-trips to the server
|
|
166
|
+
// instead of replaying the pre-logout snapshot. Without this, the core state
|
|
167
|
+
// machine's post-logout `checkUserState` (auth machine) hits the cache within
|
|
168
|
+
// the 1s TTL, sees `isAuthenticated: true` and `currentWalletIds` from before
|
|
169
|
+
// logout, re-applies the wallet IDs via #doTouchSession line 235-237, and
|
|
170
|
+
// reports `isFullyLoggedIn=true` — sending the state machine back to
|
|
171
|
+
// `authenticated` instead of `unauthenticated`. Called from ParaCore.#logout
|
|
172
|
+
// after the session cookie + in-memory auth state are cleared, so the next
|
|
173
|
+
// touchSession sees a fresh "no session" response.
|
|
174
|
+
this.invalidateTouchSessionCache = () => {
|
|
175
|
+
__privateSet(this, _touchCached, void 0);
|
|
176
|
+
__privateSet(this, _touchCachedAt, void 0);
|
|
177
|
+
__privateSet(this, _touchPromise, void 0);
|
|
178
|
+
};
|
|
165
179
|
this.isSessionActive = () => __async(this, null, function* () {
|
|
166
180
|
if (__privateGet(this, _externalWalletService).externalWalletConnectionType === "CONNECTION_ONLY") {
|
|
167
181
|
return true;
|
|
@@ -9,6 +9,17 @@ export interface EventData<T = any> {
|
|
|
9
9
|
export type EventHandler<T = any> = (data: T) => void;
|
|
10
10
|
export interface PlatformUtils {
|
|
11
11
|
sdkType: SDKType;
|
|
12
|
+
/**
|
|
13
|
+
* Node-only: keep-alive HTTP(S) agents for the user-management client so
|
|
14
|
+
* server-to-server callers reuse connections instead of re-handshaking
|
|
15
|
+
* TCP+TLS per request. Browser/RN platforms omit this (the runtime pools
|
|
16
|
+
* sockets itself). Returned as `unknown` to keep node:http types out of
|
|
17
|
+
* browser-bundled core-sdk.
|
|
18
|
+
*/
|
|
19
|
+
getRequestAgents?(): {
|
|
20
|
+
httpAgent?: unknown;
|
|
21
|
+
httpsAgent?: unknown;
|
|
22
|
+
} | undefined;
|
|
12
23
|
getPrivateKey(ctx: Ctx, userId: string, walletId: string, share: string, sessionCookie: string): Promise<string>;
|
|
13
24
|
getED25519PrivateKey(ctx: Ctx, userId: string, walletId: string, share: string, sessionCookie: string): Promise<string>;
|
|
14
25
|
keygen(ctx: Ctx, userId: string, type: Exclude<TWalletType, 'SOLANA'>, secretKey: string | null, // should be acceptable as null in RN as we don't pre-gen them
|
|
@@ -11,7 +11,7 @@ export declare function getBaseMPCNetworkUrl(env: Environment, useWebsocket?: bo
|
|
|
11
11
|
* outside this core SDK path.
|
|
12
12
|
*/
|
|
13
13
|
export declare function normalizePlatform(platform?: string): string | undefined;
|
|
14
|
-
export declare function initClient({ env, version, apiKey, partnerId, platform, useFetchAdapter, retrieveSessionCookie, persistSessionCookie, staticTraceContext, }: {
|
|
14
|
+
export declare function initClient({ env, version, apiKey, partnerId, platform, useFetchAdapter, retrieveSessionCookie, persistSessionCookie, staticTraceContext, httpAgent, httpsAgent, }: {
|
|
15
15
|
env: Environment;
|
|
16
16
|
version?: string;
|
|
17
17
|
apiKey: string;
|
|
@@ -22,4 +22,6 @@ export declare function initClient({ env, version, apiKey, partnerId, platform,
|
|
|
22
22
|
retrieveSessionCookie?: () => string;
|
|
23
23
|
persistSessionCookie?: (cookie: string) => void;
|
|
24
24
|
staticTraceContext?: Record<string, string>;
|
|
25
|
+
httpAgent?: unknown;
|
|
26
|
+
httpsAgent?: unknown;
|
|
25
27
|
}): Client;
|
|
@@ -19,6 +19,7 @@ export declare class SessionManagementService {
|
|
|
19
19
|
pregenWalletService: PregenWalletService;
|
|
20
20
|
}) => void;
|
|
21
21
|
touchSession: TouchSessionMethod;
|
|
22
|
+
invalidateTouchSessionCache: () => void;
|
|
22
23
|
isSessionActive: IsSessionActiveMethod;
|
|
23
24
|
isFullyLoggedIn: IsFullyLoggedInMethod;
|
|
24
25
|
refreshSession: RefreshSessionMethod;
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/core-sdk",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.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.4.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": "795829c50bb71817a84bdbf5e6561ca4df3a827d",
|
|
45
45
|
"main": "dist/cjs/index.js",
|
|
46
46
|
"module": "dist/esm/index.js",
|
|
47
47
|
"scripts": {
|