@logto/client 2.5.0 → 2.6.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/lib/client.cjs +15 -3
- package/lib/client.d.ts +18 -13
- package/lib/client.js +15 -3
- package/lib/mock.d.ts +2 -0
- package/package.json +3 -3
package/lib/client.cjs
CHANGED
|
@@ -140,9 +140,17 @@ class StandardLogtoClient {
|
|
|
140
140
|
}
|
|
141
141
|
return js.fetchUserInfo(userinfoEndpoint, accessToken, this.adapter.requester);
|
|
142
142
|
}
|
|
143
|
-
async signIn(options, mode) {
|
|
144
|
-
const { redirectUri: redirectUriUrl, postRedirectUri: postRedirectUriUrl, interactionMode, } = typeof options === 'string' || options instanceof URL
|
|
145
|
-
? {
|
|
143
|
+
async signIn(options, mode, hint) {
|
|
144
|
+
const { redirectUri: redirectUriUrl, postRedirectUri: postRedirectUriUrl, firstScreen, interactionMode, loginHint, directSignIn, extraParams, } = typeof options === 'string' || options instanceof URL
|
|
145
|
+
? {
|
|
146
|
+
redirectUri: options,
|
|
147
|
+
postRedirectUri: undefined,
|
|
148
|
+
firstScreen: undefined,
|
|
149
|
+
interactionMode: mode,
|
|
150
|
+
loginHint: hint,
|
|
151
|
+
directSignIn: undefined,
|
|
152
|
+
extraParams: undefined,
|
|
153
|
+
}
|
|
146
154
|
: options;
|
|
147
155
|
const redirectUri = redirectUriUrl.toString();
|
|
148
156
|
const postRedirectUri = postRedirectUriUrl?.toString();
|
|
@@ -162,7 +170,11 @@ class StandardLogtoClient {
|
|
|
162
170
|
scopes,
|
|
163
171
|
resources,
|
|
164
172
|
prompt,
|
|
173
|
+
firstScreen,
|
|
165
174
|
interactionMode,
|
|
175
|
+
loginHint,
|
|
176
|
+
directSignIn,
|
|
177
|
+
extraParams,
|
|
166
178
|
});
|
|
167
179
|
await Promise.all([
|
|
168
180
|
this.setSignInSession({ redirectUri, postRedirectUri, codeVerifier, state }),
|
package/lib/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type IdTokenClaims, type UserInfoResponse, type
|
|
1
|
+
import { type IdTokenClaims, type UserInfoResponse, type AccessTokenClaims, type OidcConfigResponse, type SignInUriParameters } from '@logto/js';
|
|
2
2
|
import { type Nullable } from '@silverhand/essentials';
|
|
3
3
|
import { ClientAdapterInstance, type ClientAdapter, type JwtVerifier } from './adapter/index.js';
|
|
4
4
|
import type { AccessToken, LogtoConfig, LogtoSignInSessionItem } from './types/index.js';
|
|
@@ -12,17 +12,7 @@ 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 interaction mode to be used for the authorization request. It determines the first page
|
|
17
|
-
* that the user will see in the sign-in flow.
|
|
18
|
-
*
|
|
19
|
-
* Note it's not a part of the OIDC standard, but a Logto-specific extension.
|
|
20
|
-
*
|
|
21
|
-
* @default InteractionMode.SignIn
|
|
22
|
-
* @see {@link InteractionMode}
|
|
23
|
-
*/
|
|
24
|
-
interactionMode?: InteractionMode;
|
|
25
|
-
};
|
|
15
|
+
} & Pick<SignInUriParameters, 'interactionMode' | 'firstScreen' | 'loginHint' | 'directSignIn' | 'extraParams'>;
|
|
26
16
|
/**
|
|
27
17
|
* The Logto base client class that provides the essential methods for
|
|
28
18
|
* interacting with the Logto server.
|
|
@@ -127,8 +117,21 @@ export declare class StandardLogtoClient {
|
|
|
127
117
|
* @throws LogtoClientError if the user is not authenticated.
|
|
128
118
|
*/
|
|
129
119
|
fetchUserInfo(): Promise<UserInfoResponse>;
|
|
120
|
+
/**
|
|
121
|
+
* Start the sign-in flow with the specified options.
|
|
122
|
+
*
|
|
123
|
+
* The redirect URI is required and it must be registered in the Logto Console.
|
|
124
|
+
*
|
|
125
|
+
* The user will be redirected to that URI after the sign-in flow is completed,
|
|
126
|
+
* and the client will be able to get the authorization code from the URI.
|
|
127
|
+
* To fetch the tokens from the authorization code, use {@link handleSignInCallback}
|
|
128
|
+
* after the user is redirected in the callback URI.
|
|
129
|
+
*
|
|
130
|
+
* @param options The options for the sign-in flow.
|
|
131
|
+
*/
|
|
130
132
|
signIn(options: SignInOptions): Promise<void>;
|
|
131
133
|
/**
|
|
134
|
+
*
|
|
132
135
|
* Start the sign-in flow with the specified redirect URI. The URI must be
|
|
133
136
|
* registered in the Logto Console.
|
|
134
137
|
*
|
|
@@ -137,10 +140,12 @@ export declare class StandardLogtoClient {
|
|
|
137
140
|
* To fetch the tokens from the authorization code, use {@link handleSignInCallback}
|
|
138
141
|
* after the user is redirected in the callback URI.
|
|
139
142
|
*
|
|
143
|
+
* @deprecated Use the object parameter instead.
|
|
140
144
|
* @param redirectUri See {@link SignInOptions.redirectUri}.
|
|
141
145
|
* @param interactionMode See {@link SignInOptions.interactionMode}.
|
|
146
|
+
* @param loginHint See {@link SignInOptions.loginHint}.
|
|
142
147
|
*/
|
|
143
|
-
signIn(redirectUri: SignInOptions['redirectUri'], interactionMode?: SignInOptions['interactionMode']): Promise<void>;
|
|
148
|
+
signIn(redirectUri: SignInOptions['redirectUri'], interactionMode?: SignInOptions['interactionMode'], loginHint?: SignInOptions['loginHint']): Promise<void>;
|
|
144
149
|
/**
|
|
145
150
|
* Check if the user is redirected from the sign-in page by checking if the
|
|
146
151
|
* current URL matches the redirect URI in the sign-in session.
|
package/lib/client.js
CHANGED
|
@@ -138,9 +138,17 @@ class StandardLogtoClient {
|
|
|
138
138
|
}
|
|
139
139
|
return fetchUserInfo(userinfoEndpoint, accessToken, this.adapter.requester);
|
|
140
140
|
}
|
|
141
|
-
async signIn(options, mode) {
|
|
142
|
-
const { redirectUri: redirectUriUrl, postRedirectUri: postRedirectUriUrl, interactionMode, } = typeof options === 'string' || options instanceof URL
|
|
143
|
-
? {
|
|
141
|
+
async signIn(options, mode, hint) {
|
|
142
|
+
const { redirectUri: redirectUriUrl, postRedirectUri: postRedirectUriUrl, firstScreen, interactionMode, loginHint, directSignIn, extraParams, } = typeof options === 'string' || options instanceof URL
|
|
143
|
+
? {
|
|
144
|
+
redirectUri: options,
|
|
145
|
+
postRedirectUri: undefined,
|
|
146
|
+
firstScreen: undefined,
|
|
147
|
+
interactionMode: mode,
|
|
148
|
+
loginHint: hint,
|
|
149
|
+
directSignIn: undefined,
|
|
150
|
+
extraParams: undefined,
|
|
151
|
+
}
|
|
144
152
|
: options;
|
|
145
153
|
const redirectUri = redirectUriUrl.toString();
|
|
146
154
|
const postRedirectUri = postRedirectUriUrl?.toString();
|
|
@@ -160,7 +168,11 @@ class StandardLogtoClient {
|
|
|
160
168
|
scopes,
|
|
161
169
|
resources,
|
|
162
170
|
prompt,
|
|
171
|
+
firstScreen,
|
|
163
172
|
interactionMode,
|
|
173
|
+
loginHint,
|
|
174
|
+
directSignIn,
|
|
175
|
+
extraParams,
|
|
164
176
|
});
|
|
165
177
|
await Promise.all([
|
|
166
178
|
this.setSignInSession({ redirectUri, postRedirectUri, codeVerifier, state }),
|
package/lib/mock.d.ts
CHANGED
|
@@ -26,9 +26,11 @@ export declare const postSignOutRedirectUri = "http://localhost:3000";
|
|
|
26
26
|
export declare const mockCodeChallenge = "code_challenge_value";
|
|
27
27
|
export declare const mockedCodeVerifier = "code_verifier_value";
|
|
28
28
|
export declare const mockedState = "state_value";
|
|
29
|
+
export declare const mockedUserHint = "johndoe@example.com";
|
|
29
30
|
export declare const mockedSignInUri: string;
|
|
30
31
|
export declare const mockedSignInUriWithLoginPrompt: string;
|
|
31
32
|
export declare const mockedSignUpUri: string;
|
|
33
|
+
export declare const mockedSignInUriWithLoginHint: string;
|
|
32
34
|
export declare const accessToken = "access_token_value";
|
|
33
35
|
export declare const refreshToken = "new_refresh_token_value";
|
|
34
36
|
export declare const idToken = "id_token_value";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logto/client",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./lib/index.cjs",
|
|
6
6
|
"module": "./lib/index.js",
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"directory": "packages/client"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@logto/js": "^4.0.0",
|
|
33
32
|
"@silverhand/essentials": "^2.8.7",
|
|
34
33
|
"camelcase-keys": "^7.0.1",
|
|
35
|
-
"jose": "^5.2.2"
|
|
34
|
+
"jose": "^5.2.2",
|
|
35
|
+
"@logto/js": "^4.1.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@peculiar/webcrypto": "^1.4.5",
|