@logto/client 3.0.4 → 3.1.1
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/lib/client.d.ts +4 -0
- package/lib/client.js +5 -4
- package/package.json +2 -2
package/lib/client.d.ts
CHANGED
|
@@ -17,6 +17,10 @@ export type SignInOptions = {
|
|
|
17
17
|
* Note: If specified, it will override the prompt value in Logto configs.
|
|
18
18
|
*/
|
|
19
19
|
prompt?: SignInUriParameters['prompt'];
|
|
20
|
+
/**
|
|
21
|
+
* Clear cached tokens from storage before sign-in. Defaults to: `true`
|
|
22
|
+
*/
|
|
23
|
+
clearTokens?: boolean;
|
|
20
24
|
} & Pick<SignInUriParameters, 'interactionMode' | 'firstScreen' | 'identifiers' | 'loginHint' | 'directSignIn' | 'extraParams'>;
|
|
21
25
|
/**
|
|
22
26
|
* The Logto base client class that provides the essential methods for
|
package/lib/client.js
CHANGED
|
@@ -115,7 +115,7 @@ class StandardLogtoClient {
|
|
|
115
115
|
async getIdTokenClaims() {
|
|
116
116
|
const idToken = await this.getIdToken();
|
|
117
117
|
if (!idToken) {
|
|
118
|
-
throw new LogtoClientError('not_authenticated');
|
|
118
|
+
throw new LogtoClientError('not_authenticated', 'ID token not found');
|
|
119
119
|
}
|
|
120
120
|
return decodeIdToken(idToken);
|
|
121
121
|
}
|
|
@@ -158,7 +158,7 @@ class StandardLogtoClient {
|
|
|
158
158
|
return fetchUserInfo(userinfoEndpoint, accessToken, this.adapter.requester);
|
|
159
159
|
}
|
|
160
160
|
async signIn(options, mode, hint) {
|
|
161
|
-
const { redirectUri: redirectUriUrl, postRedirectUri: postRedirectUriUrl, firstScreen, identifiers, interactionMode, loginHint, directSignIn, extraParams, prompt, } = typeof options === 'string' || options instanceof URL
|
|
161
|
+
const { redirectUri: redirectUriUrl, postRedirectUri: postRedirectUriUrl, firstScreen, identifiers, interactionMode, loginHint, directSignIn, extraParams, prompt, clearTokens, } = typeof options === 'string' || options instanceof URL
|
|
162
162
|
? {
|
|
163
163
|
redirectUri: options,
|
|
164
164
|
postRedirectUri: undefined,
|
|
@@ -169,6 +169,7 @@ class StandardLogtoClient {
|
|
|
169
169
|
directSignIn: undefined,
|
|
170
170
|
extraParams: undefined,
|
|
171
171
|
prompt: undefined,
|
|
172
|
+
clearTokens: true,
|
|
172
173
|
}
|
|
173
174
|
: options;
|
|
174
175
|
const redirectUri = redirectUriUrl.toString();
|
|
@@ -198,7 +199,7 @@ class StandardLogtoClient {
|
|
|
198
199
|
});
|
|
199
200
|
await Promise.all([
|
|
200
201
|
this.setSignInSession({ redirectUri, postRedirectUri, codeVerifier, state }),
|
|
201
|
-
this.clearAllTokens(),
|
|
202
|
+
clearTokens === false ? undefined : this.clearAllTokens(),
|
|
202
203
|
]);
|
|
203
204
|
await this.adapter.navigate(signInUri, { redirectUri, for: 'sign-in' });
|
|
204
205
|
}
|
|
@@ -272,7 +273,7 @@ class StandardLogtoClient {
|
|
|
272
273
|
async getAccessTokenByRefreshToken(resource, organizationId) {
|
|
273
274
|
const currentRefreshToken = await this.getRefreshToken();
|
|
274
275
|
if (!currentRefreshToken) {
|
|
275
|
-
throw new LogtoClientError('not_authenticated');
|
|
276
|
+
throw new LogtoClientError('not_authenticated', 'Refresh token not found');
|
|
276
277
|
}
|
|
277
278
|
const accessTokenKey = buildAccessTokenKey(resource, organizationId);
|
|
278
279
|
const { appId: clientId } = this.logtoConfig;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logto/client",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"module": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"@silverhand/essentials": "^2.9.2",
|
|
25
25
|
"camelcase-keys": "^9.1.3",
|
|
26
26
|
"jose": "^5.2.2",
|
|
27
|
-
"@logto/js": "^5.0
|
|
27
|
+
"@logto/js": "^5.1.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@silverhand/eslint-config": "^6.0.1",
|