@logto/client 2.6.2 → 2.6.4
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.cjs +10 -9
- package/lib/client.d.ts +6 -0
- package/lib/client.js +10 -9
- package/package.json +1 -1
package/lib/client.cjs
CHANGED
|
@@ -141,7 +141,7 @@ class StandardLogtoClient {
|
|
|
141
141
|
return js.fetchUserInfo(userinfoEndpoint, accessToken, this.adapter.requester);
|
|
142
142
|
}
|
|
143
143
|
async signIn(options, mode, hint) {
|
|
144
|
-
const { redirectUri: redirectUriUrl, postRedirectUri: postRedirectUriUrl, firstScreen, interactionMode, loginHint, directSignIn, extraParams, } = typeof options === 'string' || options instanceof URL
|
|
144
|
+
const { redirectUri: redirectUriUrl, postRedirectUri: postRedirectUriUrl, firstScreen, interactionMode, loginHint, directSignIn, extraParams, prompt, } = typeof options === 'string' || options instanceof URL
|
|
145
145
|
? {
|
|
146
146
|
redirectUri: options,
|
|
147
147
|
postRedirectUri: undefined,
|
|
@@ -150,11 +150,12 @@ class StandardLogtoClient {
|
|
|
150
150
|
loginHint: hint,
|
|
151
151
|
directSignIn: undefined,
|
|
152
152
|
extraParams: undefined,
|
|
153
|
+
prompt: undefined,
|
|
153
154
|
}
|
|
154
155
|
: options;
|
|
155
156
|
const redirectUri = redirectUriUrl.toString();
|
|
156
157
|
const postRedirectUri = postRedirectUriUrl?.toString();
|
|
157
|
-
const { appId: clientId, prompt, resources, scopes } = this.logtoConfig;
|
|
158
|
+
const { appId: clientId, prompt: promptViaConfig, resources, scopes } = this.logtoConfig;
|
|
158
159
|
const { authorizationEndpoint } = await this.getOidcConfig();
|
|
159
160
|
const [codeVerifier, state] = await Promise.all([
|
|
160
161
|
this.adapter.generateCodeVerifier(),
|
|
@@ -169,7 +170,7 @@ class StandardLogtoClient {
|
|
|
169
170
|
state,
|
|
170
171
|
scopes,
|
|
171
172
|
resources,
|
|
172
|
-
prompt,
|
|
173
|
+
prompt: prompt ?? promptViaConfig,
|
|
173
174
|
firstScreen,
|
|
174
175
|
interactionMode,
|
|
175
176
|
loginHint,
|
|
@@ -180,6 +181,7 @@ class StandardLogtoClient {
|
|
|
180
181
|
this.setSignInSession({ redirectUri, postRedirectUri, codeVerifier, state }),
|
|
181
182
|
this.setRefreshToken(null),
|
|
182
183
|
this.setIdToken(null),
|
|
184
|
+
this.clearAccessToken(),
|
|
183
185
|
]);
|
|
184
186
|
await this.adapter.navigate(signInUri, { redirectUri, for: 'sign-in' });
|
|
185
187
|
}
|
|
@@ -227,12 +229,7 @@ class StandardLogtoClient {
|
|
|
227
229
|
postLogoutRedirectUri,
|
|
228
230
|
clientId,
|
|
229
231
|
});
|
|
230
|
-
this.
|
|
231
|
-
await Promise.all([
|
|
232
|
-
this.setRefreshToken(null),
|
|
233
|
-
this.setIdToken(null),
|
|
234
|
-
this.adapter.storage.removeItem('accessToken'),
|
|
235
|
-
]);
|
|
232
|
+
await Promise.all([this.setRefreshToken(null), this.setIdToken(null), this.clearAccessToken()]);
|
|
236
233
|
await this.adapter.navigate(url, { redirectUri: postLogoutRedirectUri, for: 'sign-out' });
|
|
237
234
|
}
|
|
238
235
|
async getSignInSession() {
|
|
@@ -255,6 +252,10 @@ class StandardLogtoClient {
|
|
|
255
252
|
async setRefreshToken(value) {
|
|
256
253
|
return this.adapter.setStorageItem(types.PersistKey.RefreshToken, value);
|
|
257
254
|
}
|
|
255
|
+
async clearAccessToken() {
|
|
256
|
+
this.accessTokenMap.clear();
|
|
257
|
+
await this.adapter.storage.removeItem('accessToken');
|
|
258
|
+
}
|
|
258
259
|
async getAccessTokenByRefreshToken(resource, organizationId) {
|
|
259
260
|
const currentRefreshToken = await this.getRefreshToken();
|
|
260
261
|
if (!currentRefreshToken) {
|
package/lib/client.d.ts
CHANGED
|
@@ -12,6 +12,11 @@ export type SignInOptions = {
|
|
|
12
12
|
* sign-in callback. If not specified, the user will stay on the `redirectUri` page.
|
|
13
13
|
*/
|
|
14
14
|
postRedirectUri?: string | URL;
|
|
15
|
+
/**
|
|
16
|
+
* The prompt parameter to be used for the authorization request.
|
|
17
|
+
* Note: If specified, it will override the prompt value in Logto configs.
|
|
18
|
+
*/
|
|
19
|
+
prompt?: SignInUriParameters['prompt'];
|
|
15
20
|
} & Pick<SignInUriParameters, 'interactionMode' | 'firstScreen' | 'loginHint' | 'directSignIn' | 'extraParams'>;
|
|
16
21
|
/**
|
|
17
22
|
* The Logto base client class that provides the essential methods for
|
|
@@ -183,6 +188,7 @@ export declare class StandardLogtoClient {
|
|
|
183
188
|
protected setSignInSession(value: Nullable<LogtoSignInSessionItem>): Promise<void>;
|
|
184
189
|
private setIdToken;
|
|
185
190
|
private setRefreshToken;
|
|
191
|
+
private clearAccessToken;
|
|
186
192
|
private getAccessTokenByRefreshToken;
|
|
187
193
|
private saveAccessTokenMap;
|
|
188
194
|
private loadAccessTokenMap;
|
package/lib/client.js
CHANGED
|
@@ -139,7 +139,7 @@ class StandardLogtoClient {
|
|
|
139
139
|
return fetchUserInfo(userinfoEndpoint, accessToken, this.adapter.requester);
|
|
140
140
|
}
|
|
141
141
|
async signIn(options, mode, hint) {
|
|
142
|
-
const { redirectUri: redirectUriUrl, postRedirectUri: postRedirectUriUrl, firstScreen, interactionMode, loginHint, directSignIn, extraParams, } = typeof options === 'string' || options instanceof URL
|
|
142
|
+
const { redirectUri: redirectUriUrl, postRedirectUri: postRedirectUriUrl, firstScreen, interactionMode, loginHint, directSignIn, extraParams, prompt, } = typeof options === 'string' || options instanceof URL
|
|
143
143
|
? {
|
|
144
144
|
redirectUri: options,
|
|
145
145
|
postRedirectUri: undefined,
|
|
@@ -148,11 +148,12 @@ class StandardLogtoClient {
|
|
|
148
148
|
loginHint: hint,
|
|
149
149
|
directSignIn: undefined,
|
|
150
150
|
extraParams: undefined,
|
|
151
|
+
prompt: undefined,
|
|
151
152
|
}
|
|
152
153
|
: options;
|
|
153
154
|
const redirectUri = redirectUriUrl.toString();
|
|
154
155
|
const postRedirectUri = postRedirectUriUrl?.toString();
|
|
155
|
-
const { appId: clientId, prompt, resources, scopes } = this.logtoConfig;
|
|
156
|
+
const { appId: clientId, prompt: promptViaConfig, resources, scopes } = this.logtoConfig;
|
|
156
157
|
const { authorizationEndpoint } = await this.getOidcConfig();
|
|
157
158
|
const [codeVerifier, state] = await Promise.all([
|
|
158
159
|
this.adapter.generateCodeVerifier(),
|
|
@@ -167,7 +168,7 @@ class StandardLogtoClient {
|
|
|
167
168
|
state,
|
|
168
169
|
scopes,
|
|
169
170
|
resources,
|
|
170
|
-
prompt,
|
|
171
|
+
prompt: prompt ?? promptViaConfig,
|
|
171
172
|
firstScreen,
|
|
172
173
|
interactionMode,
|
|
173
174
|
loginHint,
|
|
@@ -178,6 +179,7 @@ class StandardLogtoClient {
|
|
|
178
179
|
this.setSignInSession({ redirectUri, postRedirectUri, codeVerifier, state }),
|
|
179
180
|
this.setRefreshToken(null),
|
|
180
181
|
this.setIdToken(null),
|
|
182
|
+
this.clearAccessToken(),
|
|
181
183
|
]);
|
|
182
184
|
await this.adapter.navigate(signInUri, { redirectUri, for: 'sign-in' });
|
|
183
185
|
}
|
|
@@ -225,12 +227,7 @@ class StandardLogtoClient {
|
|
|
225
227
|
postLogoutRedirectUri,
|
|
226
228
|
clientId,
|
|
227
229
|
});
|
|
228
|
-
this.
|
|
229
|
-
await Promise.all([
|
|
230
|
-
this.setRefreshToken(null),
|
|
231
|
-
this.setIdToken(null),
|
|
232
|
-
this.adapter.storage.removeItem('accessToken'),
|
|
233
|
-
]);
|
|
230
|
+
await Promise.all([this.setRefreshToken(null), this.setIdToken(null), this.clearAccessToken()]);
|
|
234
231
|
await this.adapter.navigate(url, { redirectUri: postLogoutRedirectUri, for: 'sign-out' });
|
|
235
232
|
}
|
|
236
233
|
async getSignInSession() {
|
|
@@ -253,6 +250,10 @@ class StandardLogtoClient {
|
|
|
253
250
|
async setRefreshToken(value) {
|
|
254
251
|
return this.adapter.setStorageItem(PersistKey.RefreshToken, value);
|
|
255
252
|
}
|
|
253
|
+
async clearAccessToken() {
|
|
254
|
+
this.accessTokenMap.clear();
|
|
255
|
+
await this.adapter.storage.removeItem('accessToken');
|
|
256
|
+
}
|
|
256
257
|
async getAccessTokenByRefreshToken(resource, organizationId) {
|
|
257
258
|
const currentRefreshToken = await this.getRefreshToken();
|
|
258
259
|
if (!currentRefreshToken) {
|