@logto/core-kit 2.2.0 → 2.2.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/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/openid.d.ts +112 -0
- package/lib/openid.js +143 -0
- package/package.json +4 -4
- package/scss/_console-themes.scss +12 -0
- package/lib/scope.d.ts +0 -55
- package/lib/scope.js +0 -76
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
package/lib/openid.d.ts
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/** Scopes that reserved by Logto, which will be added to the auth request automatically. */
|
|
2
|
+
export declare enum ReservedScope {
|
|
3
|
+
OpenId = "openid",
|
|
4
|
+
OfflineAccess = "offline_access"
|
|
5
|
+
}
|
|
6
|
+
/** Resources that reserved by Logto, which cannot be defined by users. */
|
|
7
|
+
export declare enum ReservedResource {
|
|
8
|
+
/**
|
|
9
|
+
* The resource for organization template per RFC 0001.
|
|
10
|
+
*
|
|
11
|
+
* @see {@link https://github.com/logto-io/rfcs | RFC 0001} for more details.
|
|
12
|
+
*/
|
|
13
|
+
Organization = "urn:logto:resource:organizations"
|
|
14
|
+
}
|
|
15
|
+
export type UserClaim = 'name' | 'picture' | 'username' | 'email' | 'email_verified' | 'phone_number' | 'phone_number_verified' | 'roles' | 'organizations' | 'organization_data' | 'organization_roles' | 'custom_data' | 'identities';
|
|
16
|
+
/**
|
|
17
|
+
* Scopes for ID Token and Userinfo Endpoint.
|
|
18
|
+
*/
|
|
19
|
+
export declare enum UserScope {
|
|
20
|
+
/**
|
|
21
|
+
* Scope for basic user info.
|
|
22
|
+
*
|
|
23
|
+
* See {@link idTokenClaims} for mapped claims in ID Token and {@link userinfoClaims} for additional claims in Userinfo Endpoint.
|
|
24
|
+
*/
|
|
25
|
+
Profile = "profile",
|
|
26
|
+
/**
|
|
27
|
+
* Scope for user email address.
|
|
28
|
+
*
|
|
29
|
+
* See {@link idTokenClaims} for mapped claims in ID Token and {@link userinfoClaims} for additional claims in Userinfo Endpoint.
|
|
30
|
+
*/
|
|
31
|
+
Email = "email",
|
|
32
|
+
/**
|
|
33
|
+
* Scope for user phone number.
|
|
34
|
+
*
|
|
35
|
+
* See {@link idTokenClaims} for mapped claims in ID Token and {@link userinfoClaims} for additional claims in Userinfo Endpoint.
|
|
36
|
+
*/
|
|
37
|
+
Phone = "phone",
|
|
38
|
+
/**
|
|
39
|
+
* Scope for user's custom data.
|
|
40
|
+
*
|
|
41
|
+
* See {@link idTokenClaims} for mapped claims in ID Token and {@link userinfoClaims} for additional claims in Userinfo Endpoint.
|
|
42
|
+
*/
|
|
43
|
+
CustomData = "custom_data",
|
|
44
|
+
/**
|
|
45
|
+
* Scope for user's social identity details.
|
|
46
|
+
*
|
|
47
|
+
* See {@link idTokenClaims} for mapped claims in ID Token and {@link userinfoClaims} for additional claims in Userinfo Endpoint.
|
|
48
|
+
*/
|
|
49
|
+
Identities = "identities",
|
|
50
|
+
/**
|
|
51
|
+
* Scope for user's roles.
|
|
52
|
+
*
|
|
53
|
+
* See {@link idTokenClaims} for mapped claims in ID Token and {@link userinfoClaims} for additional claims in Userinfo Endpoint.
|
|
54
|
+
*/
|
|
55
|
+
Roles = "roles",
|
|
56
|
+
/**
|
|
57
|
+
* Scope for user's organization IDs and perform organization token grant per [RFC 0001](https://github.com/logto-io/rfcs).
|
|
58
|
+
*
|
|
59
|
+
* See {@link idTokenClaims} for mapped claims in ID Token and {@link userinfoClaims} for additional claims in Userinfo Endpoint.
|
|
60
|
+
*/
|
|
61
|
+
Organizations = "urn:logto:scope:organizations",
|
|
62
|
+
/**
|
|
63
|
+
* Scope for user's organization roles per [RFC 0001](https://github.com/logto-io/rfcs).
|
|
64
|
+
*
|
|
65
|
+
* See {@link idTokenClaims} for mapped claims in ID Token and {@link userinfoClaims} for additional claims in Userinfo Endpoint.
|
|
66
|
+
*/
|
|
67
|
+
OrganizationRoles = "urn:logto:scope:organization_roles"
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Mapped claims that ID Token includes.
|
|
71
|
+
*/
|
|
72
|
+
export declare const idTokenClaims: Readonly<Record<UserScope, UserClaim[]>>;
|
|
73
|
+
/**
|
|
74
|
+
* Additional claims that Userinfo Endpoint returns.
|
|
75
|
+
*/
|
|
76
|
+
export declare const userinfoClaims: Readonly<Record<UserScope, UserClaim[]>>;
|
|
77
|
+
export declare const userClaims: Readonly<Record<UserScope, UserClaim[]>>;
|
|
78
|
+
/**
|
|
79
|
+
* The prefix of the URN (Uniform Resource Name) for the organization in Logto.
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```
|
|
83
|
+
* urn:logto:organization:123 // organization with ID 123
|
|
84
|
+
* ```
|
|
85
|
+
* @see {@link https://en.wikipedia.org/wiki/Uniform_Resource_Name | Uniform Resource Name}
|
|
86
|
+
*/
|
|
87
|
+
export declare const organizationUrnPrefix = "urn:logto:organization:";
|
|
88
|
+
/**
|
|
89
|
+
* Build the URN (Uniform Resource Name) for the organization in Logto.
|
|
90
|
+
*
|
|
91
|
+
* @param organizationId The ID of the organization.
|
|
92
|
+
* @returns The URN for the organization.
|
|
93
|
+
* @see {@link organizationUrnPrefix} for the prefix of the URN.
|
|
94
|
+
* @example
|
|
95
|
+
* ```ts
|
|
96
|
+
* buildOrganizationUrn('1') // returns 'urn:logto:organization:1'
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
export declare const buildOrganizationUrn: (organizationId: string) => string;
|
|
100
|
+
/**
|
|
101
|
+
* Get the organization ID from the URN (Uniform Resource Name) for the organization in Logto.
|
|
102
|
+
*
|
|
103
|
+
* @param urn The URN for the organization. Must start with {@link organizationUrnPrefix}.
|
|
104
|
+
* @returns The ID of the organization.
|
|
105
|
+
* @throws {TypeError} If the URN is invalid.
|
|
106
|
+
* @example
|
|
107
|
+
* ```ts
|
|
108
|
+
* getOrganizationIdFromUrn('1') // throws TypeError
|
|
109
|
+
* getOrganizationIdFromUrn('urn:logto:organization:1') // returns '1'
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
export declare const getOrganizationIdFromUrn: (urn: string) => string;
|
package/lib/openid.js
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/** Scopes that reserved by Logto, which will be added to the auth request automatically. */
|
|
2
|
+
export var ReservedScope;
|
|
3
|
+
(function (ReservedScope) {
|
|
4
|
+
ReservedScope["OpenId"] = "openid";
|
|
5
|
+
ReservedScope["OfflineAccess"] = "offline_access";
|
|
6
|
+
})(ReservedScope || (ReservedScope = {}));
|
|
7
|
+
/** Resources that reserved by Logto, which cannot be defined by users. */
|
|
8
|
+
export var ReservedResource;
|
|
9
|
+
(function (ReservedResource) {
|
|
10
|
+
/**
|
|
11
|
+
* The resource for organization template per RFC 0001.
|
|
12
|
+
*
|
|
13
|
+
* @see {@link https://github.com/logto-io/rfcs | RFC 0001} for more details.
|
|
14
|
+
*/
|
|
15
|
+
ReservedResource["Organization"] = "urn:logto:resource:organizations";
|
|
16
|
+
})(ReservedResource || (ReservedResource = {}));
|
|
17
|
+
/**
|
|
18
|
+
* Scopes for ID Token and Userinfo Endpoint.
|
|
19
|
+
*/
|
|
20
|
+
export var UserScope;
|
|
21
|
+
(function (UserScope) {
|
|
22
|
+
/**
|
|
23
|
+
* Scope for basic user info.
|
|
24
|
+
*
|
|
25
|
+
* See {@link idTokenClaims} for mapped claims in ID Token and {@link userinfoClaims} for additional claims in Userinfo Endpoint.
|
|
26
|
+
*/
|
|
27
|
+
UserScope["Profile"] = "profile";
|
|
28
|
+
/**
|
|
29
|
+
* Scope for user email address.
|
|
30
|
+
*
|
|
31
|
+
* See {@link idTokenClaims} for mapped claims in ID Token and {@link userinfoClaims} for additional claims in Userinfo Endpoint.
|
|
32
|
+
*/
|
|
33
|
+
UserScope["Email"] = "email";
|
|
34
|
+
/**
|
|
35
|
+
* Scope for user phone number.
|
|
36
|
+
*
|
|
37
|
+
* See {@link idTokenClaims} for mapped claims in ID Token and {@link userinfoClaims} for additional claims in Userinfo Endpoint.
|
|
38
|
+
*/
|
|
39
|
+
UserScope["Phone"] = "phone";
|
|
40
|
+
/**
|
|
41
|
+
* Scope for user's custom data.
|
|
42
|
+
*
|
|
43
|
+
* See {@link idTokenClaims} for mapped claims in ID Token and {@link userinfoClaims} for additional claims in Userinfo Endpoint.
|
|
44
|
+
*/
|
|
45
|
+
UserScope["CustomData"] = "custom_data";
|
|
46
|
+
/**
|
|
47
|
+
* Scope for user's social identity details.
|
|
48
|
+
*
|
|
49
|
+
* See {@link idTokenClaims} for mapped claims in ID Token and {@link userinfoClaims} for additional claims in Userinfo Endpoint.
|
|
50
|
+
*/
|
|
51
|
+
UserScope["Identities"] = "identities";
|
|
52
|
+
/**
|
|
53
|
+
* Scope for user's roles.
|
|
54
|
+
*
|
|
55
|
+
* See {@link idTokenClaims} for mapped claims in ID Token and {@link userinfoClaims} for additional claims in Userinfo Endpoint.
|
|
56
|
+
*/
|
|
57
|
+
UserScope["Roles"] = "roles";
|
|
58
|
+
/**
|
|
59
|
+
* Scope for user's organization IDs and perform organization token grant per [RFC 0001](https://github.com/logto-io/rfcs).
|
|
60
|
+
*
|
|
61
|
+
* See {@link idTokenClaims} for mapped claims in ID Token and {@link userinfoClaims} for additional claims in Userinfo Endpoint.
|
|
62
|
+
*/
|
|
63
|
+
UserScope["Organizations"] = "urn:logto:scope:organizations";
|
|
64
|
+
/**
|
|
65
|
+
* Scope for user's organization roles per [RFC 0001](https://github.com/logto-io/rfcs).
|
|
66
|
+
*
|
|
67
|
+
* See {@link idTokenClaims} for mapped claims in ID Token and {@link userinfoClaims} for additional claims in Userinfo Endpoint.
|
|
68
|
+
*/
|
|
69
|
+
UserScope["OrganizationRoles"] = "urn:logto:scope:organization_roles";
|
|
70
|
+
})(UserScope || (UserScope = {}));
|
|
71
|
+
/**
|
|
72
|
+
* Mapped claims that ID Token includes.
|
|
73
|
+
*/
|
|
74
|
+
export const idTokenClaims = Object.freeze({
|
|
75
|
+
[UserScope.Profile]: ['name', 'picture', 'username'],
|
|
76
|
+
[UserScope.Email]: ['email', 'email_verified'],
|
|
77
|
+
[UserScope.Phone]: ['phone_number', 'phone_number_verified'],
|
|
78
|
+
[UserScope.Roles]: ['roles'],
|
|
79
|
+
[UserScope.Organizations]: ['organizations'],
|
|
80
|
+
[UserScope.OrganizationRoles]: ['organization_roles'],
|
|
81
|
+
[UserScope.CustomData]: [],
|
|
82
|
+
[UserScope.Identities]: [],
|
|
83
|
+
});
|
|
84
|
+
/**
|
|
85
|
+
* Additional claims that Userinfo Endpoint returns.
|
|
86
|
+
*/
|
|
87
|
+
export const userinfoClaims = Object.freeze({
|
|
88
|
+
[UserScope.Profile]: [],
|
|
89
|
+
[UserScope.Email]: [],
|
|
90
|
+
[UserScope.Phone]: [],
|
|
91
|
+
[UserScope.Roles]: [],
|
|
92
|
+
[UserScope.Organizations]: ['organization_data'],
|
|
93
|
+
[UserScope.OrganizationRoles]: [],
|
|
94
|
+
[UserScope.CustomData]: ['custom_data'],
|
|
95
|
+
[UserScope.Identities]: ['identities'],
|
|
96
|
+
});
|
|
97
|
+
export const userClaims = Object.freeze(
|
|
98
|
+
// Hard to infer type directly, use `as` for a workaround.
|
|
99
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
100
|
+
Object.fromEntries(Object.values(UserScope).map((current) => [
|
|
101
|
+
current,
|
|
102
|
+
[...idTokenClaims[current], ...userinfoClaims[current]],
|
|
103
|
+
])));
|
|
104
|
+
/**
|
|
105
|
+
* The prefix of the URN (Uniform Resource Name) for the organization in Logto.
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* ```
|
|
109
|
+
* urn:logto:organization:123 // organization with ID 123
|
|
110
|
+
* ```
|
|
111
|
+
* @see {@link https://en.wikipedia.org/wiki/Uniform_Resource_Name | Uniform Resource Name}
|
|
112
|
+
*/
|
|
113
|
+
export const organizationUrnPrefix = 'urn:logto:organization:';
|
|
114
|
+
/**
|
|
115
|
+
* Build the URN (Uniform Resource Name) for the organization in Logto.
|
|
116
|
+
*
|
|
117
|
+
* @param organizationId The ID of the organization.
|
|
118
|
+
* @returns The URN for the organization.
|
|
119
|
+
* @see {@link organizationUrnPrefix} for the prefix of the URN.
|
|
120
|
+
* @example
|
|
121
|
+
* ```ts
|
|
122
|
+
* buildOrganizationUrn('1') // returns 'urn:logto:organization:1'
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
export const buildOrganizationUrn = (organizationId) => `${organizationUrnPrefix}${organizationId}`;
|
|
126
|
+
/**
|
|
127
|
+
* Get the organization ID from the URN (Uniform Resource Name) for the organization in Logto.
|
|
128
|
+
*
|
|
129
|
+
* @param urn The URN for the organization. Must start with {@link organizationUrnPrefix}.
|
|
130
|
+
* @returns The ID of the organization.
|
|
131
|
+
* @throws {TypeError} If the URN is invalid.
|
|
132
|
+
* @example
|
|
133
|
+
* ```ts
|
|
134
|
+
* getOrganizationIdFromUrn('1') // throws TypeError
|
|
135
|
+
* getOrganizationIdFromUrn('urn:logto:organization:1') // returns '1'
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
138
|
+
export const getOrganizationIdFromUrn = (urn) => {
|
|
139
|
+
if (!urn.startsWith(organizationUrnPrefix)) {
|
|
140
|
+
throw new TypeError('Invalid organization URN.');
|
|
141
|
+
}
|
|
142
|
+
return urn.slice(organizationUrnPrefix.length);
|
|
143
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logto/core-kit",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"author": "Silverhand Inc. <contact@silverhand.io>",
|
|
5
5
|
"homepage": "https://github.com/logto-io/toolkit#readme",
|
|
6
6
|
"repository": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"color": "^4.2.3"
|
|
35
35
|
},
|
|
36
36
|
"optionalDependencies": {
|
|
37
|
-
"zod": "^3.
|
|
37
|
+
"zod": "^3.22.4"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@jest/types": "^29.0.3",
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
"@types/react": "^18.0.31",
|
|
49
49
|
"eslint": "^8.44.0",
|
|
50
50
|
"jest": "^29.5.0",
|
|
51
|
-
"lint-staged": "^
|
|
52
|
-
"postcss": "^8.4.
|
|
51
|
+
"lint-staged": "^15.0.0",
|
|
52
|
+
"postcss": "^8.4.31",
|
|
53
53
|
"prettier": "^3.0.0",
|
|
54
54
|
"stylelint": "^15.0.0",
|
|
55
55
|
"tslib": "^2.4.1",
|
|
@@ -158,6 +158,8 @@
|
|
|
158
158
|
--color-env-tag-development: rgba(93, 52, 242, 15%);
|
|
159
159
|
--color-env-tag-staging: rgba(255, 185, 90, 35%);
|
|
160
160
|
--color-env-tag-production: rgba(131, 218, 133, 35%);
|
|
161
|
+
--color-specific-icon-bg: #f3effa;
|
|
162
|
+
--color-specific-toggle-off-enable: var(--color-neutral-90);
|
|
161
163
|
|
|
162
164
|
// Shadows
|
|
163
165
|
--shadow-1: 0 4px 8px rgba(0, 0, 0, 8%);
|
|
@@ -173,11 +175,14 @@
|
|
|
173
175
|
--color-tooltip-background: #34353f; // dark theme Surface-4
|
|
174
176
|
--color-tooltip-text: var(--color-neutral-99);
|
|
175
177
|
--color-overlay: rgba(0, 0, 0, 30%);
|
|
178
|
+
--color-overlay-default-focused: rgba(25, 28, 29, 16%);
|
|
176
179
|
--color-drawer-overlay: rgba(0, 0, 0, 40%);
|
|
177
180
|
--color-guide-dropdown-background: var(--color-white);
|
|
178
181
|
--color-guide-dropdown-border: var(--color-border);
|
|
179
182
|
--color-skeleton-shimmer-rgb: 255, 255, 255; // rgb of Layer-1
|
|
180
183
|
--color-specific-tag-upsell: var(--color-primary-50);
|
|
184
|
+
--color-specific-tag-test: var(--color-tertiary-50);
|
|
185
|
+
--color-specific-toggle-thumb-disabled: #ffffffb3;
|
|
181
186
|
|
|
182
187
|
// Background
|
|
183
188
|
--color-bg-body-base: var(--color-neutral-95);
|
|
@@ -192,6 +197,7 @@
|
|
|
192
197
|
--color-bg-toast: var(--color-neutral-20);
|
|
193
198
|
--color-bg-state-unselected: var(--color-neutral-90);
|
|
194
199
|
--color-bg-state-disabled: rgba(25, 28, 29, 8%); // 8% --color-neutral-10
|
|
200
|
+
--color-bg-info-tag: rgba(229, 225, 236, 80%); // 80% --color-neutral-variant-90
|
|
195
201
|
}
|
|
196
202
|
|
|
197
203
|
@mixin dark {
|
|
@@ -354,6 +360,8 @@
|
|
|
354
360
|
--color-env-tag-development: rgba(202, 190, 255, 32%);
|
|
355
361
|
--color-env-tag-staging: rgba(235, 153, 24, 36%);
|
|
356
362
|
--color-env-tag-production: rgba(104, 190, 108, 36%);
|
|
363
|
+
--color-specific-icon-bg: rgba(247, 248, 248, 12%);
|
|
364
|
+
--color-specific-toggle-off-enable: var(--color-neutral-90);
|
|
357
365
|
|
|
358
366
|
// Shadows
|
|
359
367
|
--shadow-1: 0 4px 8px rgba(0, 0, 0, 8%);
|
|
@@ -369,11 +377,14 @@
|
|
|
369
377
|
--color-tooltip-background: var(--color-surface-4);
|
|
370
378
|
--color-tooltip-text: var(--color-neutral-10);
|
|
371
379
|
--color-overlay: rgba(0, 0, 0, 70%); // 70% Neutral-100
|
|
380
|
+
--color-overlay-default-focused: rgba(247, 248, 248, 16%);
|
|
372
381
|
--color-drawer-overlay: rgba(0, 0, 0, 60%);
|
|
373
382
|
--color-guide-dropdown-background: var(--color-neutral-variant-80);
|
|
374
383
|
--color-guide-dropdown-border: var(--color-neutral-variant-70);
|
|
375
384
|
--color-skeleton-shimmer-rgb: 42, 44, 50; // rgb of Layer-1
|
|
376
385
|
--color-specific-tag-upsell: var(--color-primary-70);
|
|
386
|
+
--color-specific-tag-test: var(--color-tertiary-80);
|
|
387
|
+
--color-specific-toggle-thumb-disabled: #ffffff4d;
|
|
377
388
|
|
|
378
389
|
// Background
|
|
379
390
|
--color-bg-body-base: var(--color-neutral-100);
|
|
@@ -391,4 +402,5 @@
|
|
|
391
402
|
--color-bg-toast: var(--color-neutral-80);
|
|
392
403
|
--color-bg-state-unselected: var(--color-neutral-90);
|
|
393
404
|
--color-bg-state-disabled: rgba(247, 248, 248, 8%); // 8% --color-neutral-10
|
|
405
|
+
--color-bg-info-tag: var(--color-neutral-variant-90);
|
|
394
406
|
}
|
package/lib/scope.d.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
export declare enum ReservedScope {
|
|
2
|
-
OpenId = "openid",
|
|
3
|
-
OfflineAccess = "offline_access"
|
|
4
|
-
}
|
|
5
|
-
export type UserClaim = 'name' | 'picture' | 'username' | 'email' | 'email_verified' | 'phone_number' | 'phone_number_verified' | 'roles' | 'custom_data' | 'identities';
|
|
6
|
-
/**
|
|
7
|
-
* Scopes for ID Token and Userinfo Endpoint.
|
|
8
|
-
*/
|
|
9
|
-
export declare enum UserScope {
|
|
10
|
-
/**
|
|
11
|
-
* Scope for basic user info.
|
|
12
|
-
*
|
|
13
|
-
* See {@link idTokenClaims} for mapped claims in ID Token and {@link userinfoClaims} for additional claims in Userinfo Endpoint.
|
|
14
|
-
*/
|
|
15
|
-
Profile = "profile",
|
|
16
|
-
/**
|
|
17
|
-
* Scope for user email address.
|
|
18
|
-
*
|
|
19
|
-
* See {@link idTokenClaims} for mapped claims in ID Token and {@link userinfoClaims} for additional claims in Userinfo Endpoint.
|
|
20
|
-
*/
|
|
21
|
-
Email = "email",
|
|
22
|
-
/**
|
|
23
|
-
* Scope for user phone number.
|
|
24
|
-
*
|
|
25
|
-
* See {@link idTokenClaims} for mapped claims in ID Token and {@link userinfoClaims} for additional claims in Userinfo Endpoint.
|
|
26
|
-
*/
|
|
27
|
-
Phone = "phone",
|
|
28
|
-
/**
|
|
29
|
-
* Scope for user's custom data.
|
|
30
|
-
*
|
|
31
|
-
* See {@link idTokenClaims} for mapped claims in ID Token and {@link userinfoClaims} for additional claims in Userinfo Endpoint.
|
|
32
|
-
*/
|
|
33
|
-
CustomData = "custom_data",
|
|
34
|
-
/**
|
|
35
|
-
* Scope for user's social identity details.
|
|
36
|
-
*
|
|
37
|
-
* See {@link idTokenClaims} for mapped claims in ID Token and {@link userinfoClaims} for additional claims in Userinfo Endpoint.
|
|
38
|
-
*/
|
|
39
|
-
Identities = "identities",
|
|
40
|
-
/**
|
|
41
|
-
* Scope for user's roles.
|
|
42
|
-
*
|
|
43
|
-
* See {@link idTokenClaims} for mapped claims in ID Token and {@link userinfoClaims} for additional claims in Userinfo Endpoint.
|
|
44
|
-
*/
|
|
45
|
-
Roles = "roles"
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Mapped claims that ID Token includes.
|
|
49
|
-
*/
|
|
50
|
-
export declare const idTokenClaims: Readonly<Record<UserScope, UserClaim[]>>;
|
|
51
|
-
/**
|
|
52
|
-
* Additional claims that Userinfo Endpoint returns.
|
|
53
|
-
*/
|
|
54
|
-
export declare const userinfoClaims: Readonly<Record<UserScope, UserClaim[]>>;
|
|
55
|
-
export declare const userClaims: Readonly<Record<UserScope, UserClaim[]>>;
|
package/lib/scope.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
export var ReservedScope;
|
|
2
|
-
(function (ReservedScope) {
|
|
3
|
-
ReservedScope["OpenId"] = "openid";
|
|
4
|
-
ReservedScope["OfflineAccess"] = "offline_access";
|
|
5
|
-
})(ReservedScope || (ReservedScope = {}));
|
|
6
|
-
/**
|
|
7
|
-
* Scopes for ID Token and Userinfo Endpoint.
|
|
8
|
-
*/
|
|
9
|
-
export var UserScope;
|
|
10
|
-
(function (UserScope) {
|
|
11
|
-
/**
|
|
12
|
-
* Scope for basic user info.
|
|
13
|
-
*
|
|
14
|
-
* See {@link idTokenClaims} for mapped claims in ID Token and {@link userinfoClaims} for additional claims in Userinfo Endpoint.
|
|
15
|
-
*/
|
|
16
|
-
UserScope["Profile"] = "profile";
|
|
17
|
-
/**
|
|
18
|
-
* Scope for user email address.
|
|
19
|
-
*
|
|
20
|
-
* See {@link idTokenClaims} for mapped claims in ID Token and {@link userinfoClaims} for additional claims in Userinfo Endpoint.
|
|
21
|
-
*/
|
|
22
|
-
UserScope["Email"] = "email";
|
|
23
|
-
/**
|
|
24
|
-
* Scope for user phone number.
|
|
25
|
-
*
|
|
26
|
-
* See {@link idTokenClaims} for mapped claims in ID Token and {@link userinfoClaims} for additional claims in Userinfo Endpoint.
|
|
27
|
-
*/
|
|
28
|
-
UserScope["Phone"] = "phone";
|
|
29
|
-
/**
|
|
30
|
-
* Scope for user's custom data.
|
|
31
|
-
*
|
|
32
|
-
* See {@link idTokenClaims} for mapped claims in ID Token and {@link userinfoClaims} for additional claims in Userinfo Endpoint.
|
|
33
|
-
*/
|
|
34
|
-
UserScope["CustomData"] = "custom_data";
|
|
35
|
-
/**
|
|
36
|
-
* Scope for user's social identity details.
|
|
37
|
-
*
|
|
38
|
-
* See {@link idTokenClaims} for mapped claims in ID Token and {@link userinfoClaims} for additional claims in Userinfo Endpoint.
|
|
39
|
-
*/
|
|
40
|
-
UserScope["Identities"] = "identities";
|
|
41
|
-
/**
|
|
42
|
-
* Scope for user's roles.
|
|
43
|
-
*
|
|
44
|
-
* See {@link idTokenClaims} for mapped claims in ID Token and {@link userinfoClaims} for additional claims in Userinfo Endpoint.
|
|
45
|
-
*/
|
|
46
|
-
UserScope["Roles"] = "roles";
|
|
47
|
-
})(UserScope || (UserScope = {}));
|
|
48
|
-
/**
|
|
49
|
-
* Mapped claims that ID Token includes.
|
|
50
|
-
*/
|
|
51
|
-
export const idTokenClaims = Object.freeze({
|
|
52
|
-
[UserScope.Profile]: ['name', 'picture', 'username'],
|
|
53
|
-
[UserScope.Email]: ['email', 'email_verified'],
|
|
54
|
-
[UserScope.Phone]: ['phone_number', 'phone_number_verified'],
|
|
55
|
-
[UserScope.Roles]: ['roles'],
|
|
56
|
-
[UserScope.CustomData]: [],
|
|
57
|
-
[UserScope.Identities]: [],
|
|
58
|
-
});
|
|
59
|
-
/**
|
|
60
|
-
* Additional claims that Userinfo Endpoint returns.
|
|
61
|
-
*/
|
|
62
|
-
export const userinfoClaims = Object.freeze({
|
|
63
|
-
[UserScope.Profile]: [],
|
|
64
|
-
[UserScope.Email]: [],
|
|
65
|
-
[UserScope.Phone]: [],
|
|
66
|
-
[UserScope.Roles]: [],
|
|
67
|
-
[UserScope.CustomData]: ['custom_data'],
|
|
68
|
-
[UserScope.Identities]: ['identities'],
|
|
69
|
-
});
|
|
70
|
-
export const userClaims = Object.freeze(
|
|
71
|
-
// Hard to infer type directly, use `as` for a workaround.
|
|
72
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
73
|
-
Object.fromEntries(Object.values(UserScope).map((current) => [
|
|
74
|
-
current,
|
|
75
|
-
[...idTokenClaims[current], ...userinfoClaims[current]],
|
|
76
|
-
])));
|