@logto/client 2.5.1 → 2.6.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.cjs +7 -1
- package/lib/client.d.ts +30 -16
- package/lib/client.js +7 -1
- package/package.json +3 -3
package/lib/client.cjs
CHANGED
|
@@ -141,12 +141,15 @@ 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, interactionMode, loginHint, } = typeof options === 'string' || options instanceof URL
|
|
144
|
+
const { redirectUri: redirectUriUrl, postRedirectUri: postRedirectUriUrl, firstScreen, interactionMode, loginHint, directSignIn, extraParams, } = typeof options === 'string' || options instanceof URL
|
|
145
145
|
? {
|
|
146
146
|
redirectUri: options,
|
|
147
147
|
postRedirectUri: undefined,
|
|
148
|
+
firstScreen: undefined,
|
|
148
149
|
interactionMode: mode,
|
|
149
150
|
loginHint: hint,
|
|
151
|
+
directSignIn: undefined,
|
|
152
|
+
extraParams: undefined,
|
|
150
153
|
}
|
|
151
154
|
: options;
|
|
152
155
|
const redirectUri = redirectUriUrl.toString();
|
|
@@ -167,8 +170,11 @@ class StandardLogtoClient {
|
|
|
167
170
|
scopes,
|
|
168
171
|
resources,
|
|
169
172
|
prompt,
|
|
173
|
+
firstScreen,
|
|
170
174
|
interactionMode,
|
|
171
175
|
loginHint,
|
|
176
|
+
directSignIn,
|
|
177
|
+
extraParams,
|
|
172
178
|
});
|
|
173
179
|
await Promise.all([
|
|
174
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,21 +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
|
-
/**
|
|
26
|
-
* Login hint indicates the current user (usually an email address).
|
|
27
|
-
*/
|
|
28
|
-
loginHint?: string;
|
|
29
|
-
};
|
|
15
|
+
} & Pick<SignInUriParameters, 'interactionMode' | 'firstScreen' | 'loginHint' | 'directSignIn' | 'extraParams'>;
|
|
30
16
|
/**
|
|
31
17
|
* The Logto base client class that provides the essential methods for
|
|
32
18
|
* interacting with the Logto server.
|
|
@@ -131,8 +117,34 @@ export declare class StandardLogtoClient {
|
|
|
131
117
|
* @throws LogtoClientError if the user is not authenticated.
|
|
132
118
|
*/
|
|
133
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
|
+
*/
|
|
134
132
|
signIn(options: SignInOptions): Promise<void>;
|
|
135
133
|
/**
|
|
134
|
+
* Start the sign-in flow with the specified options.
|
|
135
|
+
*
|
|
136
|
+
* The redirect URI is required and it must be registered in the Logto Console.
|
|
137
|
+
*
|
|
138
|
+
* The user will be redirected to that URI after the sign-in flow is completed,
|
|
139
|
+
* and the client will be able to get the authorization code from the URI.
|
|
140
|
+
* To fetch the tokens from the authorization code, use {@link handleSignInCallback}
|
|
141
|
+
* after the user is redirected in the callback URI.
|
|
142
|
+
*
|
|
143
|
+
* @param redirectUri See {@link SignInOptions.redirectUri}.
|
|
144
|
+
*/
|
|
145
|
+
signIn(redirectUri: SignInOptions['redirectUri']): Promise<void>;
|
|
146
|
+
/**
|
|
147
|
+
*
|
|
136
148
|
* Start the sign-in flow with the specified redirect URI. The URI must be
|
|
137
149
|
* registered in the Logto Console.
|
|
138
150
|
*
|
|
@@ -141,8 +153,10 @@ export declare class StandardLogtoClient {
|
|
|
141
153
|
* To fetch the tokens from the authorization code, use {@link handleSignInCallback}
|
|
142
154
|
* after the user is redirected in the callback URI.
|
|
143
155
|
*
|
|
156
|
+
* @deprecated Use the object parameter instead.
|
|
144
157
|
* @param redirectUri See {@link SignInOptions.redirectUri}.
|
|
145
158
|
* @param interactionMode See {@link SignInOptions.interactionMode}.
|
|
159
|
+
* @param loginHint See {@link SignInOptions.loginHint}.
|
|
146
160
|
*/
|
|
147
161
|
signIn(redirectUri: SignInOptions['redirectUri'], interactionMode?: SignInOptions['interactionMode'], loginHint?: SignInOptions['loginHint']): Promise<void>;
|
|
148
162
|
/**
|
package/lib/client.js
CHANGED
|
@@ -139,12 +139,15 @@ 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, interactionMode, loginHint, } = typeof options === 'string' || options instanceof URL
|
|
142
|
+
const { redirectUri: redirectUriUrl, postRedirectUri: postRedirectUriUrl, firstScreen, interactionMode, loginHint, directSignIn, extraParams, } = typeof options === 'string' || options instanceof URL
|
|
143
143
|
? {
|
|
144
144
|
redirectUri: options,
|
|
145
145
|
postRedirectUri: undefined,
|
|
146
|
+
firstScreen: undefined,
|
|
146
147
|
interactionMode: mode,
|
|
147
148
|
loginHint: hint,
|
|
149
|
+
directSignIn: undefined,
|
|
150
|
+
extraParams: undefined,
|
|
148
151
|
}
|
|
149
152
|
: options;
|
|
150
153
|
const redirectUri = redirectUriUrl.toString();
|
|
@@ -165,8 +168,11 @@ class StandardLogtoClient {
|
|
|
165
168
|
scopes,
|
|
166
169
|
resources,
|
|
167
170
|
prompt,
|
|
171
|
+
firstScreen,
|
|
168
172
|
interactionMode,
|
|
169
173
|
loginHint,
|
|
174
|
+
directSignIn,
|
|
175
|
+
extraParams,
|
|
170
176
|
});
|
|
171
177
|
await Promise.all([
|
|
172
178
|
this.setSignInSession({ redirectUri, postRedirectUri, codeVerifier, state }),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logto/client",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.1",
|
|
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.1",
|
|
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.1"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@peculiar/webcrypto": "^1.4.5",
|