@logto/js 5.1.1 → 6.1.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.
@@ -38,6 +38,12 @@ export declare enum UserScope {
38
38
  * See {@link idTokenClaims} for mapped claims in ID Token and {@link userinfoClaims} for additional claims in Userinfo Endpoint.
39
39
  */
40
40
  Phone = "phone",
41
+ /**
42
+ * Scope for user address.
43
+ *
44
+ * See {@link idTokenClaims} for mapped claims in ID Token and {@link userinfoClaims} for additional claims in Userinfo Endpoint.
45
+ */
46
+ Address = "address",
41
47
  /**
42
48
  * Scope for user's custom data.
43
49
  *
@@ -40,6 +40,12 @@ var UserScope;
40
40
  * See {@link idTokenClaims} for mapped claims in ID Token and {@link userinfoClaims} for additional claims in Userinfo Endpoint.
41
41
  */
42
42
  UserScope["Phone"] = "phone";
43
+ /**
44
+ * Scope for user address.
45
+ *
46
+ * See {@link idTokenClaims} for mapped claims in ID Token and {@link userinfoClaims} for additional claims in Userinfo Endpoint.
47
+ */
48
+ UserScope["Address"] = "address";
43
49
  /**
44
50
  * Scope for user's custom data.
45
51
  *
@@ -78,6 +84,7 @@ const idTokenClaims = Object.freeze({
78
84
  [UserScope.Profile]: ['name', 'picture', 'username'],
79
85
  [UserScope.Email]: ['email', 'email_verified'],
80
86
  [UserScope.Phone]: ['phone_number', 'phone_number_verified'],
87
+ [UserScope.Address]: [],
81
88
  [UserScope.Roles]: ['roles'],
82
89
  [UserScope.Organizations]: ['organizations'],
83
90
  [UserScope.OrganizationRoles]: ['organization_roles'],
@@ -91,6 +98,7 @@ const userinfoClaims = Object.freeze({
91
98
  [UserScope.Profile]: [],
92
99
  [UserScope.Email]: [],
93
100
  [UserScope.Phone]: [],
101
+ [UserScope.Address]: [],
94
102
  [UserScope.Roles]: [],
95
103
  [UserScope.Organizations]: [],
96
104
  [UserScope.OrganizationRoles]: [],
package/lib/index.js CHANGED
@@ -10,6 +10,5 @@ export { decodeIdToken } from './utils/id-token.js';
10
10
  export { decodeAccessToken } from './utils/access-token.js';
11
11
  export { withDefaultScopes, withReservedScopes } from './utils/scopes.js';
12
12
  export { isArbitraryObject } from './utils/arbitrary-object.js';
13
- export { buildAngularAuthConfig } from './utils/angular.js';
14
13
  export { ContentType, Prompt, QueryKey, TokenGrantType } from './consts/index.js';
15
14
  export { ReservedResource, ReservedScope, UserScope, buildOrganizationUrn, getOrganizationIdFromUrn, idTokenClaims, organizationUrnPrefix, userClaims, userinfoClaims } from './consts/openid.js';
@@ -4,4 +4,3 @@ export * from './id-token.js';
4
4
  export * from './access-token.js';
5
5
  export * from './scopes.js';
6
6
  export * from './arbitrary-object.js';
7
- export * from './angular.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logto/js",
3
- "version": "5.1.1",
3
+ "version": "6.1.0",
4
4
  "type": "module",
5
5
  "module": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -28,7 +28,6 @@
28
28
  "@silverhand/ts-config": "^6.0.0",
29
29
  "@types/node": "^22.0.0",
30
30
  "@vitest/coverage-v8": "^2.1.9",
31
- "angular-auth-oidc-client": "^19.0.0",
32
31
  "eslint": "^8.57.0",
33
32
  "happy-dom": "^16.0.0",
34
33
  "jose": "^5.2.2",
@@ -1,112 +0,0 @@
1
- import { type OpenIdConfiguration } from 'angular-auth-oidc-client';
2
- import { Prompt } from '../consts/index.js';
3
- import { type SignInUriParameters } from '../index.js';
4
- /** The Logto configuration object for Angular apps. */
5
- export type LogtoAngularConfig = {
6
- /**
7
- * The endpoint for the Logto server, you can get it from the integration guide
8
- * or the team settings page of the Logto Console.
9
- *
10
- * @example https://foo.logto.app
11
- */
12
- endpoint: string;
13
- /**
14
- * The client ID of your application, you can get it from the integration guide
15
- * or the application details page of the Logto Console.
16
- */
17
- appId: string;
18
- /**
19
- * The scopes (permissions) that your application needs to access.
20
- * Scopes that will be added by default: `openid`, `offline_access` and `profile`.
21
- */
22
- scopes?: string[];
23
- /**
24
- * The API resource that your application needs to access.
25
- *
26
- * @see {@link https://docs.logto.io/docs/recipes/rbac/ | RBAC} to learn more about how to use
27
- * role-based access control (RBAC) to protect API resources.
28
- */
29
- resource?: string;
30
- /**
31
- * @param redirectUri The redirect URI that the user will be redirected to after the sign-in flow
32
- * is completed.
33
- */
34
- redirectUri: string;
35
- /**
36
- * @param postLogoutRedirectUri The URI that the user will be redirected to after the sign-out
37
- * flow is completed.
38
- */
39
- postLogoutRedirectUri?: string;
40
- /**
41
- * The prompt parameter to be used for the authorization request.
42
- *
43
- * @default Prompt.Consent
44
- */
45
- prompt?: Prompt | Prompt[];
46
- /**
47
- * Whether to include reserved scopes (`openid`, `offline_access` and `profile`) in the scopes.
48
- *
49
- * @default true
50
- */
51
- includeReservedScopes?: boolean;
52
- /**
53
- * Login hint indicates the current user (usually an email address or a phone number).
54
- *
55
- * @link SignInUriParameters.loginHint
56
- */
57
- loginHint?: SignInUriParameters['loginHint'];
58
- /**
59
- * The first screen to be shown in the sign-in experience.
60
- *
61
- * @link SignInUriParameters.firstScreen
62
- */
63
- firstScreen?: SignInUriParameters['firstScreen'];
64
- /**
65
- * Identifiers used in the identifier sign-in, identifier register or reset password pages.
66
- *
67
- * Note: This parameter is applicable only when the `firstScreen` is set to either`identifierSignIn`
68
- * or `identifierRegister`.
69
- *
70
- * @link SignInUriParameters.identifiers
71
- */
72
- identifiers?: SignInUriParameters['identifiers'];
73
- /**
74
- * Direct sign-in options.
75
- *
76
- * @link SignInUriParameters.directSignIn
77
- */
78
- directSignIn?: SignInUriParameters['directSignIn'];
79
- /**
80
- * Extra parameters to be appended to the sign-in URI.
81
- *
82
- * Note: The parameters should be supported by the authorization server.
83
- *
84
- * @link SignInUriParameters.extraParams
85
- */
86
- extraParams?: SignInUriParameters['extraParams'];
87
- };
88
- /**
89
- * A helper function to build the OpenID Connect configuration for `angular-auth-oidc-client`
90
- * using a Logto-friendly way.
91
- *
92
- * @example
93
- * ```ts
94
- * // A minimal example
95
- * import { buildAngularAuthConfig } from '@logto/js';
96
- * import { provideAuth } from 'angular-auth-oidc-client';
97
- *
98
- * provideAuth({
99
- * config: buildAngularAuthConfig({
100
- * endpoint: '<your-logto-endpoint>',
101
- * appId: '<your-app-id>',
102
- * redirectUri: '<your-app-redirect-uri>',
103
- * }),
104
- * });
105
- * ```
106
- *
107
- * @param logtoConfig The Logto configuration object for Angular apps.
108
- * @returns The OpenID Connect configuration for `angular-auth-oidc-client`.
109
- * @see {@link https://angular-auth-oidc-client.com/ | angular-auth-oidc-client} to learn more
110
- * about how to use the library.
111
- */
112
- export declare const buildAngularAuthConfig: (logtoConfig: LogtoAngularConfig) => OpenIdConfiguration;
@@ -1,64 +0,0 @@
1
- import { conditional } from '@silverhand/essentials';
2
- import { Prompt, QueryKey } from '../consts/index.js';
3
- import { withReservedScopes } from './scopes.js';
4
-
5
- /**
6
- * A helper function to build the OpenID Connect configuration for `angular-auth-oidc-client`
7
- * using a Logto-friendly way.
8
- *
9
- * @example
10
- * ```ts
11
- * // A minimal example
12
- * import { buildAngularAuthConfig } from '@logto/js';
13
- * import { provideAuth } from 'angular-auth-oidc-client';
14
- *
15
- * provideAuth({
16
- * config: buildAngularAuthConfig({
17
- * endpoint: '<your-logto-endpoint>',
18
- * appId: '<your-app-id>',
19
- * redirectUri: '<your-app-redirect-uri>',
20
- * }),
21
- * });
22
- * ```
23
- *
24
- * @param logtoConfig The Logto configuration object for Angular apps.
25
- * @returns The OpenID Connect configuration for `angular-auth-oidc-client`.
26
- * @see {@link https://angular-auth-oidc-client.com/ | angular-auth-oidc-client} to learn more
27
- * about how to use the library.
28
- */
29
- const buildAngularAuthConfig = (logtoConfig) => {
30
- const { endpoint, appId: clientId, scopes, resource, redirectUri: redirectUrl, postLogoutRedirectUri, prompt = Prompt.Consent, includeReservedScopes = true, loginHint, identifiers, firstScreen, directSignIn, extraParams, } = logtoConfig;
31
- const scope = includeReservedScopes ? withReservedScopes(scopes) : scopes?.join(' ');
32
- const customParameters = {
33
- ...conditional(resource && { [QueryKey.Resource]: resource }),
34
- ...conditional(loginHint && { [QueryKey.LoginHint]: loginHint }),
35
- ...conditional(firstScreen && { [QueryKey.FirstScreen]: firstScreen }),
36
- ...conditional(identifiers && { [QueryKey.Identifier]: identifiers.join(' ') }),
37
- ...conditional(directSignIn && { [QueryKey.DirectSignIn]: `${directSignIn.method}:${directSignIn.target}` }),
38
- ...extraParams,
39
- };
40
- return {
41
- authority: new URL('/oidc', endpoint).href,
42
- redirectUrl,
43
- postLogoutRedirectUri,
44
- clientId,
45
- scope,
46
- responseType: 'code',
47
- autoUserInfo: !resource,
48
- renewUserInfoAfterTokenRenew: !resource,
49
- silentRenew: true,
50
- useRefreshToken: true,
51
- customParamsAuthRequest: {
52
- prompt: Array.isArray(prompt) ? prompt.join(' ') : prompt,
53
- ...customParameters,
54
- },
55
- customParamsCodeRequest: {
56
- ...customParameters,
57
- },
58
- customParamsRefreshTokenRequest: {
59
- ...customParameters,
60
- },
61
- };
62
- };
63
-
64
- export { buildAngularAuthConfig };