@logto/client 2.6.7 → 2.6.8
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/types/index.cjs +6 -3
- package/lib/types/index.d.ts +10 -2
- package/lib/types/index.js +7 -4
- package/package.json +2 -2
package/lib/types/index.cjs
CHANGED
|
@@ -6,18 +6,21 @@ var essentials = require('@silverhand/essentials');
|
|
|
6
6
|
/**
|
|
7
7
|
* Normalize the Logto client configuration per the following rules:
|
|
8
8
|
*
|
|
9
|
-
* - Add default scopes (`openid`, `offline_access` and `profile`) if not provided
|
|
10
|
-
*
|
|
9
|
+
* - Add default scopes (`openid`, `offline_access` and `profile`) if not provided and
|
|
10
|
+
* `includeReservedScopes` is `true`.
|
|
11
|
+
* - Add {@link ReservedResource.Organization} to resources if {@link UserScope.Organizations} is
|
|
12
|
+
* included in scopes.
|
|
11
13
|
*
|
|
12
14
|
* @param config The Logto client configuration to be normalized.
|
|
13
15
|
* @returns The normalized Logto client configuration.
|
|
14
16
|
*/
|
|
15
17
|
const normalizeLogtoConfig = (config) => {
|
|
16
18
|
const { prompt = js.Prompt.Consent, scopes = [], resources, ...rest } = config;
|
|
19
|
+
const includeReservedScopes = config.includeReservedScopes ?? true;
|
|
17
20
|
return {
|
|
18
21
|
...rest,
|
|
19
22
|
prompt,
|
|
20
|
-
scopes: js.
|
|
23
|
+
scopes: includeReservedScopes ? js.withReservedScopes(scopes).split(' ') : scopes,
|
|
21
24
|
resources: scopes.includes(js.UserScope.Organizations)
|
|
22
25
|
? essentials.deduplicate([...(resources ?? []), js.ReservedResource.Organization])
|
|
23
26
|
: resources,
|
package/lib/types/index.d.ts
CHANGED
|
@@ -39,12 +39,20 @@ export type LogtoConfig = {
|
|
|
39
39
|
* The prompt parameter to be used for the authorization request.
|
|
40
40
|
*/
|
|
41
41
|
prompt?: Prompt | Prompt[];
|
|
42
|
+
/**
|
|
43
|
+
* Whether to include reserved scopes (`openid`, `offline_access` and `profile`) in the scopes.
|
|
44
|
+
*
|
|
45
|
+
* @default true
|
|
46
|
+
*/
|
|
47
|
+
includeReservedScopes?: boolean;
|
|
42
48
|
};
|
|
43
49
|
/**
|
|
44
50
|
* Normalize the Logto client configuration per the following rules:
|
|
45
51
|
*
|
|
46
|
-
* - Add default scopes (`openid`, `offline_access` and `profile`) if not provided
|
|
47
|
-
*
|
|
52
|
+
* - Add default scopes (`openid`, `offline_access` and `profile`) if not provided and
|
|
53
|
+
* `includeReservedScopes` is `true`.
|
|
54
|
+
* - Add {@link ReservedResource.Organization} to resources if {@link UserScope.Organizations} is
|
|
55
|
+
* included in scopes.
|
|
48
56
|
*
|
|
49
57
|
* @param config The Logto client configuration to be normalized.
|
|
50
58
|
* @returns The normalized Logto client configuration.
|
package/lib/types/index.js
CHANGED
|
@@ -1,21 +1,24 @@
|
|
|
1
|
-
import { Prompt,
|
|
1
|
+
import { Prompt, withReservedScopes, UserScope, ReservedResource, isArbitraryObject } from '@logto/js';
|
|
2
2
|
import { deduplicate } from '@silverhand/essentials';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Normalize the Logto client configuration per the following rules:
|
|
6
6
|
*
|
|
7
|
-
* - Add default scopes (`openid`, `offline_access` and `profile`) if not provided
|
|
8
|
-
*
|
|
7
|
+
* - Add default scopes (`openid`, `offline_access` and `profile`) if not provided and
|
|
8
|
+
* `includeReservedScopes` is `true`.
|
|
9
|
+
* - Add {@link ReservedResource.Organization} to resources if {@link UserScope.Organizations} is
|
|
10
|
+
* included in scopes.
|
|
9
11
|
*
|
|
10
12
|
* @param config The Logto client configuration to be normalized.
|
|
11
13
|
* @returns The normalized Logto client configuration.
|
|
12
14
|
*/
|
|
13
15
|
const normalizeLogtoConfig = (config) => {
|
|
14
16
|
const { prompt = Prompt.Consent, scopes = [], resources, ...rest } = config;
|
|
17
|
+
const includeReservedScopes = config.includeReservedScopes ?? true;
|
|
15
18
|
return {
|
|
16
19
|
...rest,
|
|
17
20
|
prompt,
|
|
18
|
-
scopes:
|
|
21
|
+
scopes: includeReservedScopes ? withReservedScopes(scopes).split(' ') : scopes,
|
|
19
22
|
resources: scopes.includes(UserScope.Organizations)
|
|
20
23
|
? deduplicate([...(resources ?? []), ReservedResource.Organization])
|
|
21
24
|
: resources,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logto/client",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./lib/index.cjs",
|
|
6
6
|
"module": "./lib/index.js",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@silverhand/essentials": "^2.8.7",
|
|
33
33
|
"camelcase-keys": "^7.0.1",
|
|
34
34
|
"jose": "^5.2.2",
|
|
35
|
-
"@logto/js": "^4.1.
|
|
35
|
+
"@logto/js": "^4.1.2"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@silverhand/eslint-config": "^6.0.1",
|