@logto/core-kit 2.4.0 → 2.5.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/declaration/index.ts +0 -1
- package/lib/models/tenant.d.ts +2 -2
- package/lib/models/tenant.js +1 -1
- package/lib/openid.d.ts +2 -2
- package/lib/openid.js +2 -2
- package/lib/password-policy.d.ts +0 -1
- package/lib/utils/url.d.ts +28 -1
- package/lib/utils/url.js +39 -0
- package/package.json +17 -12
- package/declaration/react-app.d.ts +0 -65
package/declaration/index.ts
CHANGED
package/lib/models/tenant.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export type
|
|
1
|
+
export type TenantDatabaseMetadata = {
|
|
2
2
|
id: string;
|
|
3
3
|
parentRole: string;
|
|
4
4
|
role: string;
|
|
5
5
|
password: string;
|
|
6
6
|
};
|
|
7
|
-
export declare const
|
|
7
|
+
export declare const createTenantDatabaseMetadata: (databaseName: string, tenantId?: string) => TenantDatabaseMetadata;
|
package/lib/models/tenant.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { generateStandardId } from '@logto/shared/universal';
|
|
2
2
|
// Use lowercase letters for tenant IDs to improve compatibility
|
|
3
3
|
const generateTenantId = () => generateStandardId(6);
|
|
4
|
-
export const
|
|
4
|
+
export const createTenantDatabaseMetadata = (databaseName, tenantId = generateTenantId()) => {
|
|
5
5
|
const parentRole = `logto_tenant_${databaseName}`;
|
|
6
6
|
const role = `logto_tenant_${databaseName}_${tenantId}`;
|
|
7
7
|
const password = generateStandardId(32);
|
package/lib/openid.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export declare enum ReservedResource {
|
|
|
12
12
|
*/
|
|
13
13
|
Organization = "urn:logto:resource:organizations"
|
|
14
14
|
}
|
|
15
|
-
export type UserClaim = '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' | 'created_at';
|
|
15
|
+
export type UserClaim = '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';
|
|
16
16
|
/**
|
|
17
17
|
* Scopes for ID Token and Userinfo Endpoint.
|
|
18
18
|
*/
|
|
@@ -48,7 +48,7 @@ export declare enum UserScope {
|
|
|
48
48
|
*/
|
|
49
49
|
CustomData = "custom_data",
|
|
50
50
|
/**
|
|
51
|
-
* Scope for user's social identity details.
|
|
51
|
+
* Scope for user's social and SSO identity details.
|
|
52
52
|
*
|
|
53
53
|
* See {@link idTokenClaims} for mapped claims in ID Token and {@link userinfoClaims} for additional claims in Userinfo Endpoint.
|
|
54
54
|
*/
|
package/lib/openid.js
CHANGED
|
@@ -50,7 +50,7 @@ export var UserScope;
|
|
|
50
50
|
*/
|
|
51
51
|
UserScope["CustomData"] = "custom_data";
|
|
52
52
|
/**
|
|
53
|
-
* Scope for user's social identity details.
|
|
53
|
+
* Scope for user's social and SSO identity details.
|
|
54
54
|
*
|
|
55
55
|
* See {@link idTokenClaims} for mapped claims in ID Token and {@link userinfoClaims} for additional claims in Userinfo Endpoint.
|
|
56
56
|
*/
|
|
@@ -121,7 +121,7 @@ export const userinfoClaims = Object.freeze({
|
|
|
121
121
|
[UserScope.Organizations]: ['organization_data'],
|
|
122
122
|
[UserScope.OrganizationRoles]: [],
|
|
123
123
|
[UserScope.CustomData]: ['custom_data'],
|
|
124
|
-
[UserScope.Identities]: ['identities'],
|
|
124
|
+
[UserScope.Identities]: ['identities', 'sso_identities'],
|
|
125
125
|
});
|
|
126
126
|
export const userClaims = Object.freeze(
|
|
127
127
|
// Hard to infer type directly, use `as` for a workaround.
|
package/lib/password-policy.d.ts
CHANGED
package/lib/utils/url.d.ts
CHANGED
|
@@ -1,7 +1,34 @@
|
|
|
1
|
-
export declare const validateRedirectUrl: (url: string, type:
|
|
1
|
+
export declare const validateRedirectUrl: (url: string, type: "web" | "mobile") => boolean;
|
|
2
2
|
export declare const validateUriOrigin: (url: string) => boolean;
|
|
3
3
|
export declare const isValidUrl: (url?: string) => boolean;
|
|
4
4
|
/**
|
|
5
5
|
* Check if the given URL is localhost
|
|
6
6
|
*/
|
|
7
7
|
export declare const isLocalhost: (url: string) => boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Check if the request URL is a file asset path.
|
|
10
|
+
* The check is based on the last segment of the URL path containing a dot, ignoring query params.
|
|
11
|
+
* Example:
|
|
12
|
+
* - `path/scripts.js` -> true
|
|
13
|
+
* - `path/index.html?query=param` -> true
|
|
14
|
+
* - `path` -> false
|
|
15
|
+
* - `path?email=abc@test.com` -> false
|
|
16
|
+
* @param url Request URL
|
|
17
|
+
* @returns Boolean value indicating if the request URL is a file asset path
|
|
18
|
+
*/
|
|
19
|
+
export declare const isFileAssetPath: (url: string) => boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Parse the "range" request header value to get the start, end, and count values.
|
|
22
|
+
* Example:
|
|
23
|
+
* - `range: bytes=0-499` -> { start: 0, end: 499, count: 500 }
|
|
24
|
+
* - `range: bytes=0-` -> { start: 0, end: undefined, count: undefined }
|
|
25
|
+
* - `range: invalid` -> Error: Range not satisfiable
|
|
26
|
+
* - Without range header -> { start: undefined, end: undefined, count: undefined }
|
|
27
|
+
* @param range Range request header value
|
|
28
|
+
* @returns Object containing start, end, and count values
|
|
29
|
+
*/
|
|
30
|
+
export declare const parseRange: (range: string) => {
|
|
31
|
+
start: number | undefined;
|
|
32
|
+
end: number | undefined;
|
|
33
|
+
count: number | undefined;
|
|
34
|
+
};
|
package/lib/utils/url.js
CHANGED
|
@@ -32,3 +32,42 @@ export const isLocalhost = (url) => {
|
|
|
32
32
|
const parsedUrl = new URL(url);
|
|
33
33
|
return ['localhost', '127.0.0.1', '::1'].includes(parsedUrl.hostname);
|
|
34
34
|
};
|
|
35
|
+
/**
|
|
36
|
+
* Check if the request URL is a file asset path.
|
|
37
|
+
* The check is based on the last segment of the URL path containing a dot, ignoring query params.
|
|
38
|
+
* Example:
|
|
39
|
+
* - `path/scripts.js` -> true
|
|
40
|
+
* - `path/index.html?query=param` -> true
|
|
41
|
+
* - `path` -> false
|
|
42
|
+
* - `path?email=abc@test.com` -> false
|
|
43
|
+
* @param url Request URL
|
|
44
|
+
* @returns Boolean value indicating if the request URL is a file asset path
|
|
45
|
+
*/
|
|
46
|
+
export const isFileAssetPath = (url) => {
|
|
47
|
+
const pathWithoutQuery = url.split('?')[0];
|
|
48
|
+
return Boolean(pathWithoutQuery?.split('/').at(-1)?.includes('.'));
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Parse the "range" request header value to get the start, end, and count values.
|
|
52
|
+
* Example:
|
|
53
|
+
* - `range: bytes=0-499` -> { start: 0, end: 499, count: 500 }
|
|
54
|
+
* - `range: bytes=0-` -> { start: 0, end: undefined, count: undefined }
|
|
55
|
+
* - `range: invalid` -> Error: Range not satisfiable
|
|
56
|
+
* - Without range header -> { start: undefined, end: undefined, count: undefined }
|
|
57
|
+
* @param range Range request header value
|
|
58
|
+
* @returns Object containing start, end, and count values
|
|
59
|
+
*/
|
|
60
|
+
export const parseRange = (range) => {
|
|
61
|
+
const rangeMatch = /bytes=(\d+)-(\d+)?/.exec(range);
|
|
62
|
+
if (range && !rangeMatch) {
|
|
63
|
+
throw new Error('Range not satisfiable.');
|
|
64
|
+
}
|
|
65
|
+
const start = rangeMatch?.[1] === undefined ? undefined : Number.parseInt(rangeMatch[1], 10);
|
|
66
|
+
const end = rangeMatch?.[2] === undefined ? undefined : Number.parseInt(rangeMatch[2], 10);
|
|
67
|
+
const count = end === undefined ? undefined : end - (start ?? 0) + 1;
|
|
68
|
+
return {
|
|
69
|
+
start,
|
|
70
|
+
end,
|
|
71
|
+
count,
|
|
72
|
+
};
|
|
73
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logto/core-kit",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.1",
|
|
4
4
|
"author": "Silverhand Inc. <contact@silverhand.io>",
|
|
5
5
|
"homepage": "https://github.com/logto-io/toolkit#readme",
|
|
6
6
|
"repository": {
|
|
@@ -17,7 +17,11 @@
|
|
|
17
17
|
"import": "./lib/index.js"
|
|
18
18
|
},
|
|
19
19
|
"./declaration": "./declaration/index.ts",
|
|
20
|
-
"./scss/*": "./scss/*.scss"
|
|
20
|
+
"./scss/*": "./scss/*.scss",
|
|
21
|
+
"./custom-jwt": {
|
|
22
|
+
"node": "./lib/custom-jwt/index.js",
|
|
23
|
+
"types": "./lib/custom-jwt/index.d.ts"
|
|
24
|
+
}
|
|
21
25
|
},
|
|
22
26
|
"types": "./lib/index.d.ts",
|
|
23
27
|
"files": [
|
|
@@ -31,27 +35,28 @@
|
|
|
31
35
|
"dependencies": {
|
|
32
36
|
"@logto/language-kit": "^1.1.0",
|
|
33
37
|
"@logto/shared": "^3.1.0",
|
|
34
|
-
"@silverhand/essentials": "^2.9.
|
|
38
|
+
"@silverhand/essentials": "^2.9.1",
|
|
35
39
|
"color": "^4.2.3"
|
|
36
40
|
},
|
|
37
41
|
"optionalDependencies": {
|
|
38
|
-
"zod": "^3.
|
|
42
|
+
"zod": "^3.23.8"
|
|
39
43
|
},
|
|
40
44
|
"devDependencies": {
|
|
41
|
-
"@silverhand/eslint-config": "
|
|
42
|
-
"@silverhand/
|
|
43
|
-
"@silverhand/ts-config
|
|
45
|
+
"@silverhand/eslint-config": "6.0.1",
|
|
46
|
+
"@silverhand/eslint-config-react": "6.0.2",
|
|
47
|
+
"@silverhand/ts-config": "6.0.0",
|
|
48
|
+
"@silverhand/ts-config-react": "6.0.0",
|
|
44
49
|
"@types/color": "^3.0.3",
|
|
45
50
|
"@types/node": "^20.9.5",
|
|
46
|
-
"@types/react": "^18.
|
|
47
|
-
"@vitest/coverage-v8": "^
|
|
48
|
-
"eslint": "^8.
|
|
51
|
+
"@types/react": "^18.3.3",
|
|
52
|
+
"@vitest/coverage-v8": "^2.0.0",
|
|
53
|
+
"eslint": "^8.56.0",
|
|
49
54
|
"lint-staged": "^15.0.0",
|
|
50
55
|
"postcss": "^8.4.31",
|
|
51
56
|
"prettier": "^3.0.0",
|
|
52
57
|
"stylelint": "^15.0.0",
|
|
53
|
-
"typescript": "^5.
|
|
54
|
-
"vitest": "^
|
|
58
|
+
"typescript": "^5.5.3",
|
|
59
|
+
"vitest": "^2.0.0"
|
|
55
60
|
},
|
|
56
61
|
"eslintConfig": {
|
|
57
62
|
"extends": "@silverhand"
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
// Copied from react-scripts/lib/react-app.d.ts
|
|
2
|
-
|
|
3
|
-
declare module '*.avif' {
|
|
4
|
-
const source: string;
|
|
5
|
-
export default source;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
declare module '*.bmp' {
|
|
9
|
-
const source: string;
|
|
10
|
-
export default source;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
declare module '*.gif' {
|
|
14
|
-
const source: string;
|
|
15
|
-
export default source;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
declare module '*.jpg' {
|
|
19
|
-
const source: string;
|
|
20
|
-
export default source;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
declare module '*.jpeg' {
|
|
24
|
-
const source: string;
|
|
25
|
-
export default source;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
declare module '*.png' {
|
|
29
|
-
const source: string;
|
|
30
|
-
export default source;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
declare module '*.webp' {
|
|
34
|
-
const source: string;
|
|
35
|
-
export default source;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
declare module '*.svg' {
|
|
39
|
-
import * as React from 'react';
|
|
40
|
-
|
|
41
|
-
export const ReactComponent: React.FunctionComponent<
|
|
42
|
-
React.SVGProps<SVGSVGElement> & { title?: string }
|
|
43
|
-
>;
|
|
44
|
-
|
|
45
|
-
const source: string;
|
|
46
|
-
export default source;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
declare module '*.module.css' {
|
|
50
|
-
const classes: Readonly<Record<string, string>>;
|
|
51
|
-
export default classes;
|
|
52
|
-
export = classes;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
declare module '*.module.scss' {
|
|
56
|
-
const classes: Readonly<Record<string, string>>;
|
|
57
|
-
export default classes;
|
|
58
|
-
export = classes;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
declare module '*.module.sass' {
|
|
62
|
-
const classes: Readonly<Record<string, string>>;
|
|
63
|
-
export default classes;
|
|
64
|
-
export = classes;
|
|
65
|
-
}
|