@logto/js 4.1.4 → 4.2.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/consts/index.cjs +1 -0
- package/lib/consts/index.d.ts +1 -0
- package/lib/consts/index.js +1 -0
- package/lib/core/sign-in.cjs +5 -1
- package/lib/core/sign-in.d.ts +20 -2
- package/lib/core/sign-in.js +5 -1
- package/lib/core/user-info.d.ts +7 -0
- package/lib/types/index.d.ts +5 -1
- package/package.json +2 -2
package/lib/consts/index.cjs
CHANGED
|
@@ -37,6 +37,7 @@ exports.QueryKey = void 0;
|
|
|
37
37
|
/** The query key for specifying the organization ID. */
|
|
38
38
|
QueryKey["OrganizationId"] = "organization_id";
|
|
39
39
|
QueryKey["FirstScreen"] = "first_screen";
|
|
40
|
+
QueryKey["Identifier"] = "identifier";
|
|
40
41
|
QueryKey["DirectSignIn"] = "direct_sign_in";
|
|
41
42
|
})(exports.QueryKey || (exports.QueryKey = {}));
|
|
42
43
|
/** The prompt parameter to be used for the authorization request. */
|
package/lib/consts/index.d.ts
CHANGED
|
@@ -33,6 +33,7 @@ export declare enum QueryKey {
|
|
|
33
33
|
/** The query key for specifying the organization ID. */
|
|
34
34
|
OrganizationId = "organization_id",
|
|
35
35
|
FirstScreen = "first_screen",
|
|
36
|
+
Identifier = "identifier",
|
|
36
37
|
DirectSignIn = "direct_sign_in"
|
|
37
38
|
}
|
|
38
39
|
/** The prompt parameter to be used for the authorization request. */
|
package/lib/consts/index.js
CHANGED
|
@@ -35,6 +35,7 @@ var QueryKey;
|
|
|
35
35
|
/** The query key for specifying the organization ID. */
|
|
36
36
|
QueryKey["OrganizationId"] = "organization_id";
|
|
37
37
|
QueryKey["FirstScreen"] = "first_screen";
|
|
38
|
+
QueryKey["Identifier"] = "identifier";
|
|
38
39
|
QueryKey["DirectSignIn"] = "direct_sign_in";
|
|
39
40
|
})(QueryKey || (QueryKey = {}));
|
|
40
41
|
/** The prompt parameter to be used for the authorization request. */
|
package/lib/core/sign-in.cjs
CHANGED
|
@@ -11,7 +11,8 @@ const buildPrompt = (prompt) => {
|
|
|
11
11
|
}
|
|
12
12
|
return prompt ?? index.Prompt.Consent;
|
|
13
13
|
};
|
|
14
|
-
|
|
14
|
+
// eslint-disable-next-line complexity
|
|
15
|
+
const generateSignInUri = ({ authorizationEndpoint, clientId, redirectUri, codeChallenge, state, scopes: scopes$1, resources, prompt, firstScreen, identifiers: identifier, interactionMode, loginHint, directSignIn, extraParams, includeReservedScopes = true, }) => {
|
|
15
16
|
const urlSearchParameters = new URLSearchParams({
|
|
16
17
|
[index.QueryKey.ClientId]: clientId,
|
|
17
18
|
[index.QueryKey.RedirectUri]: redirectUri,
|
|
@@ -41,6 +42,9 @@ const generateSignInUri = ({ authorizationEndpoint, clientId, redirectUri, codeC
|
|
|
41
42
|
else if (interactionMode) {
|
|
42
43
|
urlSearchParameters.append(index.QueryKey.InteractionMode, interactionMode);
|
|
43
44
|
}
|
|
45
|
+
if (identifier && identifier.length > 0) {
|
|
46
|
+
urlSearchParameters.append(index.QueryKey.Identifier, identifier.join(' '));
|
|
47
|
+
}
|
|
44
48
|
if (extraParams) {
|
|
45
49
|
for (const [key, value] of Object.entries(extraParams)) {
|
|
46
50
|
urlSearchParameters.append(key, value);
|
package/lib/core/sign-in.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export type DirectSignInOptions = {
|
|
|
12
12
|
*/
|
|
13
13
|
target: string;
|
|
14
14
|
};
|
|
15
|
+
type Identifier = 'email' | 'phone' | 'username';
|
|
15
16
|
export type SignInUriParameters = {
|
|
16
17
|
authorizationEndpoint: string;
|
|
17
18
|
clientId: string;
|
|
@@ -25,7 +26,23 @@ export type SignInUriParameters = {
|
|
|
25
26
|
* The first screen to be shown in the sign-in experience.
|
|
26
27
|
*/
|
|
27
28
|
firstScreen?: FirstScreen;
|
|
28
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* Specifies identifiers used in the identifier sign-in or identifier register page.
|
|
31
|
+
*
|
|
32
|
+
* Available values: `email`, `phone`, `username`.
|
|
33
|
+
*
|
|
34
|
+
* This parameter is applicable only when the `firstScreen` is set to either `identifierSignIn` or `identifierRegister`.
|
|
35
|
+
*
|
|
36
|
+
* If the provided identifier is not supported in the Logto sign-in experience configuration, it will be ignored,
|
|
37
|
+
* and if no one of them is supported, it will fallback to the sign-in / sign-up method value set in the sign-in experience configuration.
|
|
38
|
+
*
|
|
39
|
+
*/
|
|
40
|
+
identifiers?: Identifier[];
|
|
41
|
+
/**
|
|
42
|
+
* The first screen to be shown in the sign-in experience.
|
|
43
|
+
*
|
|
44
|
+
* @deprecated Use `firstScreen` instead.
|
|
45
|
+
*/
|
|
29
46
|
interactionMode?: InteractionMode;
|
|
30
47
|
/**
|
|
31
48
|
* Login hint indicates the current user (usually an email address or a phone number).
|
|
@@ -51,4 +68,5 @@ export type SignInUriParameters = {
|
|
|
51
68
|
*/
|
|
52
69
|
includeReservedScopes?: boolean;
|
|
53
70
|
};
|
|
54
|
-
export declare const generateSignInUri: ({ authorizationEndpoint, clientId, redirectUri, codeChallenge, state, scopes, resources, prompt, firstScreen, interactionMode, loginHint, directSignIn, extraParams, includeReservedScopes, }: SignInUriParameters) => string;
|
|
71
|
+
export declare const generateSignInUri: ({ authorizationEndpoint, clientId, redirectUri, codeChallenge, state, scopes, resources, prompt, firstScreen, identifiers: identifier, interactionMode, loginHint, directSignIn, extraParams, includeReservedScopes, }: SignInUriParameters) => string;
|
|
72
|
+
export {};
|
package/lib/core/sign-in.js
CHANGED
|
@@ -9,7 +9,8 @@ const buildPrompt = (prompt) => {
|
|
|
9
9
|
}
|
|
10
10
|
return prompt ?? Prompt.Consent;
|
|
11
11
|
};
|
|
12
|
-
|
|
12
|
+
// eslint-disable-next-line complexity
|
|
13
|
+
const generateSignInUri = ({ authorizationEndpoint, clientId, redirectUri, codeChallenge, state, scopes, resources, prompt, firstScreen, identifiers: identifier, interactionMode, loginHint, directSignIn, extraParams, includeReservedScopes = true, }) => {
|
|
13
14
|
const urlSearchParameters = new URLSearchParams({
|
|
14
15
|
[QueryKey.ClientId]: clientId,
|
|
15
16
|
[QueryKey.RedirectUri]: redirectUri,
|
|
@@ -39,6 +40,9 @@ const generateSignInUri = ({ authorizationEndpoint, clientId, redirectUri, codeC
|
|
|
39
40
|
else if (interactionMode) {
|
|
40
41
|
urlSearchParameters.append(QueryKey.InteractionMode, interactionMode);
|
|
41
42
|
}
|
|
43
|
+
if (identifier && identifier.length > 0) {
|
|
44
|
+
urlSearchParameters.append(QueryKey.Identifier, identifier.join(' '));
|
|
45
|
+
}
|
|
42
46
|
if (extraParams) {
|
|
43
47
|
for (const [key, value] of Object.entries(extraParams)) {
|
|
44
48
|
urlSearchParameters.append(key, value);
|
package/lib/core/user-info.d.ts
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
|
+
import { type Nullable } from '@silverhand/essentials';
|
|
1
2
|
import { type IdTokenClaims } from '../index.js';
|
|
2
3
|
import type { Requester } from '../types/index.js';
|
|
3
4
|
type Identity = {
|
|
4
5
|
userId: string;
|
|
5
6
|
details?: Record<string, unknown>;
|
|
6
7
|
};
|
|
8
|
+
type OrganizationData = {
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
description: Nullable<string>;
|
|
12
|
+
};
|
|
7
13
|
export type UserInfoResponse = IdTokenClaims & {
|
|
8
14
|
custom_data?: unknown;
|
|
9
15
|
identities?: Record<string, Identity>;
|
|
16
|
+
organization_data?: OrganizationData[];
|
|
10
17
|
};
|
|
11
18
|
export declare const fetchUserInfo: (userInfoEndpoint: string, accessToken: string, requester: Requester) => Promise<UserInfoResponse>;
|
|
12
19
|
export {};
|
package/lib/types/index.d.ts
CHANGED
|
@@ -13,12 +13,16 @@ export type Requester = <T>(...args: Parameters<typeof fetch>) => Promise<T>;
|
|
|
13
13
|
*
|
|
14
14
|
* - `signIn`: The authorization request will be initiated with a sign-in page.
|
|
15
15
|
* - `signUp`: The authorization request will be initiated with a sign-up page.
|
|
16
|
+
*
|
|
17
|
+
* @deprecated Use `FirstScreen` instead.
|
|
16
18
|
*/
|
|
17
19
|
export type InteractionMode = 'signIn' | 'signUp';
|
|
18
20
|
/**
|
|
19
21
|
* The first screen to be shown in the sign-in experience. Note it's not a part of the OIDC
|
|
20
22
|
* standard, but a Logto-specific extension.
|
|
21
23
|
*
|
|
24
|
+
* Note: `signIn` is deprecated, use `sign_in` instead
|
|
25
|
+
*
|
|
22
26
|
* @experimental Don't use this type as it's under development.
|
|
23
27
|
*/
|
|
24
|
-
export type FirstScreen = 'signIn' | 'register';
|
|
28
|
+
export type FirstScreen = 'signIn' | 'sign_in' | 'register' | 'reset_password' | 'identifier:sign_in' | 'identifier:register' | 'single_sign_on';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logto/js",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./lib/index.cjs",
|
|
6
6
|
"module": "./lib/index.js",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@silverhand/ts-config": "^6.0.0",
|
|
29
29
|
"@types/node": "^20.11.19",
|
|
30
30
|
"@vitest/coverage-v8": "^1.6.0",
|
|
31
|
-
"angular-auth-oidc-client": "^
|
|
31
|
+
"angular-auth-oidc-client": "^18.0.0",
|
|
32
32
|
"eslint": "^8.57.0",
|
|
33
33
|
"happy-dom": "^14.0.0",
|
|
34
34
|
"jose": "^5.2.2",
|