@logto/core-kit 2.5.1 → 2.5.3
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/openid.d.ts +20 -1
- package/lib/openid.js +50 -0
- package/lib/regex.js +1 -1
- package/package.json +5 -5
package/lib/openid.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
1
2
|
/** Scopes that reserved by Logto, which will be added to the auth request automatically. */
|
|
2
3
|
export declare enum ReservedScope {
|
|
3
4
|
OpenId = "openid",
|
|
@@ -12,7 +13,25 @@ export declare enum ReservedResource {
|
|
|
12
13
|
*/
|
|
13
14
|
Organization = "urn:logto:resource:organizations"
|
|
14
15
|
}
|
|
15
|
-
|
|
16
|
+
/**
|
|
17
|
+
* A comprehensive list of all available user claims that can be used in SAML applications.
|
|
18
|
+
* This array serves two purposes:
|
|
19
|
+
* 1. Acts as a single source of truth for all possible `UserClaim` values
|
|
20
|
+
* 2. Provides a runtime accessible list of all available claims
|
|
21
|
+
*
|
|
22
|
+
* Previously, `UserClaim` type was defined directly as a union type. Now, we define this array first
|
|
23
|
+
* and derive the `UserClaim` type from it using Zod. This approach maintains type safety while also
|
|
24
|
+
* making the complete list of claims available at runtime.
|
|
25
|
+
*
|
|
26
|
+
* Note: This array must include ALL possible values from `UserClaim` type.
|
|
27
|
+
* TypeScript will throw error if any value is missing.
|
|
28
|
+
*/
|
|
29
|
+
export declare const userClaimsList: readonly ["name", "given_name", "family_name", "middle_name", "nickname", "preferred_username", "profile", "picture", "website", "email", "email_verified", "gender", "birthdate", "zoneinfo", "locale", "phone_number", "phone_number_verified", "address", "updated_at", "username", "roles", "organizations", "organization_data", "organization_roles", "custom_data", "identities", "sso_identities", "created_at"];
|
|
30
|
+
/**
|
|
31
|
+
* Zod guard for `UserClaim` type, using `userClaimsList` as the single source of truth
|
|
32
|
+
*/
|
|
33
|
+
export declare const userClaimGuard: z.ZodEnum<["name", "given_name", "family_name", "middle_name", "nickname", "preferred_username", "profile", "picture", "website", "email", "email_verified", "gender", "birthdate", "zoneinfo", "locale", "phone_number", "phone_number_verified", "address", "updated_at", "username", "roles", "organizations", "organization_data", "organization_roles", "custom_data", "identities", "sso_identities", "created_at"]>;
|
|
34
|
+
export type UserClaim = z.infer<typeof userClaimGuard>;
|
|
16
35
|
/**
|
|
17
36
|
* Scopes for ID Token and Userinfo Endpoint.
|
|
18
37
|
*/
|
package/lib/openid.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
1
2
|
/** Scopes that reserved by Logto, which will be added to the auth request automatically. */
|
|
2
3
|
export var ReservedScope;
|
|
3
4
|
(function (ReservedScope) {
|
|
@@ -14,6 +15,55 @@ export var ReservedResource;
|
|
|
14
15
|
*/
|
|
15
16
|
ReservedResource["Organization"] = "urn:logto:resource:organizations";
|
|
16
17
|
})(ReservedResource || (ReservedResource = {}));
|
|
18
|
+
/**
|
|
19
|
+
* A comprehensive list of all available user claims that can be used in SAML applications.
|
|
20
|
+
* This array serves two purposes:
|
|
21
|
+
* 1. Acts as a single source of truth for all possible `UserClaim` values
|
|
22
|
+
* 2. Provides a runtime accessible list of all available claims
|
|
23
|
+
*
|
|
24
|
+
* Previously, `UserClaim` type was defined directly as a union type. Now, we define this array first
|
|
25
|
+
* and derive the `UserClaim` type from it using Zod. This approach maintains type safety while also
|
|
26
|
+
* making the complete list of claims available at runtime.
|
|
27
|
+
*
|
|
28
|
+
* Note: This array must include ALL possible values from `UserClaim` type.
|
|
29
|
+
* TypeScript will throw error if any value is missing.
|
|
30
|
+
*/
|
|
31
|
+
export const userClaimsList = [
|
|
32
|
+
// OIDC standard claims
|
|
33
|
+
'name',
|
|
34
|
+
'given_name',
|
|
35
|
+
'family_name',
|
|
36
|
+
'middle_name',
|
|
37
|
+
'nickname',
|
|
38
|
+
'preferred_username',
|
|
39
|
+
'profile',
|
|
40
|
+
'picture',
|
|
41
|
+
'website',
|
|
42
|
+
'email',
|
|
43
|
+
'email_verified',
|
|
44
|
+
'gender',
|
|
45
|
+
'birthdate',
|
|
46
|
+
'zoneinfo',
|
|
47
|
+
'locale',
|
|
48
|
+
'phone_number',
|
|
49
|
+
'phone_number_verified',
|
|
50
|
+
'address',
|
|
51
|
+
'updated_at',
|
|
52
|
+
// Custom claims
|
|
53
|
+
'username',
|
|
54
|
+
'roles',
|
|
55
|
+
'organizations',
|
|
56
|
+
'organization_data',
|
|
57
|
+
'organization_roles',
|
|
58
|
+
'custom_data',
|
|
59
|
+
'identities',
|
|
60
|
+
'sso_identities',
|
|
61
|
+
'created_at',
|
|
62
|
+
];
|
|
63
|
+
/**
|
|
64
|
+
* Zod guard for `UserClaim` type, using `userClaimsList` as the single source of truth
|
|
65
|
+
*/
|
|
66
|
+
export const userClaimGuard = z.enum(userClaimsList);
|
|
17
67
|
/**
|
|
18
68
|
* Scopes for ID Token and Userinfo Endpoint.
|
|
19
69
|
*/
|
package/lib/regex.js
CHANGED
|
@@ -3,7 +3,7 @@ export const phoneRegEx = /^\d+$/;
|
|
|
3
3
|
export const phoneInputRegEx = /^\+?[\d-( )]+$/;
|
|
4
4
|
export const usernameRegEx = /^[A-Z_a-z]\w*$/;
|
|
5
5
|
export const webRedirectUriProtocolRegEx = /^https?:$/;
|
|
6
|
-
export const mobileUriSchemeProtocolRegEx = /^[a-z][\d+_a-z-]*(\.[\d+_a-z-]+)
|
|
6
|
+
export const mobileUriSchemeProtocolRegEx = /^(?!http(s)?:)[a-z][\d+_a-z-]*(\.[\d+_a-z-]+)*:$/;
|
|
7
7
|
export const hexColorRegEx = /^#[\da-f]{3}([\da-f]{3})?$/i;
|
|
8
8
|
export const dateRegex = /^\d{4}(-\d{2}){2}/;
|
|
9
9
|
export const noSpaceRegEx = /^\S+$/;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logto/core-kit",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.3",
|
|
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
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@logto/language-kit": "^1.1.0",
|
|
37
|
-
"@logto/shared": "^3.1.
|
|
37
|
+
"@logto/shared": "^3.1.3",
|
|
38
38
|
"@silverhand/essentials": "^2.9.1",
|
|
39
39
|
"color": "^4.2.3"
|
|
40
40
|
},
|
|
@@ -46,17 +46,17 @@
|
|
|
46
46
|
"@silverhand/eslint-config-react": "6.0.2",
|
|
47
47
|
"@silverhand/ts-config": "6.0.0",
|
|
48
48
|
"@silverhand/ts-config-react": "6.0.0",
|
|
49
|
-
"@types/color": "^
|
|
49
|
+
"@types/color": "^4.0.0",
|
|
50
50
|
"@types/node": "^20.9.5",
|
|
51
51
|
"@types/react": "^18.3.3",
|
|
52
|
-
"@vitest/coverage-v8": "^2.
|
|
52
|
+
"@vitest/coverage-v8": "^2.1.8",
|
|
53
53
|
"eslint": "^8.56.0",
|
|
54
54
|
"lint-staged": "^15.0.0",
|
|
55
55
|
"postcss": "^8.4.31",
|
|
56
56
|
"prettier": "^3.0.0",
|
|
57
57
|
"stylelint": "^15.0.0",
|
|
58
58
|
"typescript": "^5.5.3",
|
|
59
|
-
"vitest": "^2.
|
|
59
|
+
"vitest": "^2.1.8"
|
|
60
60
|
},
|
|
61
61
|
"eslintConfig": {
|
|
62
62
|
"extends": "@silverhand"
|