@logto/node 2.4.7 → 2.5.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.
- package/lib/src/client.cjs +2 -2
- package/lib/src/client.d.ts +1 -1
- package/lib/src/client.js +2 -2
- package/lib/src/index.cjs +1 -3
- package/lib/src/index.js +1 -3
- package/lib/src/types.d.ts +2 -0
- package/lib/src/utils/promise-queue.cjs +1 -1
- package/lib/src/utils/promise-queue.js +1 -1
- package/package.json +9 -13
package/lib/src/client.cjs
CHANGED
|
@@ -12,7 +12,7 @@ var BaseClient__default = /*#__PURE__*/_interopDefault(BaseClient);
|
|
|
12
12
|
class LogtoNodeBaseClient extends BaseClient__default.default {
|
|
13
13
|
constructor() {
|
|
14
14
|
super(...arguments);
|
|
15
|
-
this.getContext = async ({ getAccessToken, resource, fetchUserInfo, getOrganizationToken, } = {}) => {
|
|
15
|
+
this.getContext = async ({ getAccessToken, resource, fetchUserInfo, getOrganizationToken, organizationId, } = {}) => {
|
|
16
16
|
const isAuthenticated = await this.isAuthenticated();
|
|
17
17
|
if (!isAuthenticated) {
|
|
18
18
|
return {
|
|
@@ -22,7 +22,7 @@ class LogtoNodeBaseClient extends BaseClient__default.default {
|
|
|
22
22
|
const claims = await this.getIdTokenClaims();
|
|
23
23
|
const { accessToken, accessTokenClaims } = getAccessToken
|
|
24
24
|
? {
|
|
25
|
-
accessToken: await essentials.trySafe(async () => this.getAccessToken(resource)),
|
|
25
|
+
accessToken: await essentials.trySafe(async () => this.getAccessToken(resource, organizationId)),
|
|
26
26
|
accessTokenClaims: await essentials.trySafe(async () => this.getAccessTokenClaims(resource)),
|
|
27
27
|
}
|
|
28
28
|
: { accessToken: undefined, accessTokenClaims: undefined };
|
package/lib/src/client.d.ts
CHANGED
|
@@ -4,5 +4,5 @@ export type { LogtoContext, GetContextParameters } from './types.js';
|
|
|
4
4
|
export type { IdTokenClaims, LogtoErrorCode, LogtoConfig, LogtoClientErrorCode, Storage, StorageKey, InteractionMode, } from '@logto/client';
|
|
5
5
|
export { LogtoError, LogtoRequestError, LogtoClientError, OidcError, Prompt, ReservedScope, UserScope, } from '@logto/client';
|
|
6
6
|
export default class LogtoNodeBaseClient extends BaseClient {
|
|
7
|
-
getContext: ({ getAccessToken, resource, fetchUserInfo, getOrganizationToken, }?: GetContextParameters) => Promise<LogtoContext>;
|
|
7
|
+
getContext: ({ getAccessToken, resource, fetchUserInfo, getOrganizationToken, organizationId, }?: GetContextParameters) => Promise<LogtoContext>;
|
|
8
8
|
}
|
package/lib/src/client.js
CHANGED
|
@@ -5,7 +5,7 @@ import { trySafe, conditional } from '@silverhand/essentials';
|
|
|
5
5
|
class LogtoNodeBaseClient extends BaseClient {
|
|
6
6
|
constructor() {
|
|
7
7
|
super(...arguments);
|
|
8
|
-
this.getContext = async ({ getAccessToken, resource, fetchUserInfo, getOrganizationToken, } = {}) => {
|
|
8
|
+
this.getContext = async ({ getAccessToken, resource, fetchUserInfo, getOrganizationToken, organizationId, } = {}) => {
|
|
9
9
|
const isAuthenticated = await this.isAuthenticated();
|
|
10
10
|
if (!isAuthenticated) {
|
|
11
11
|
return {
|
|
@@ -15,7 +15,7 @@ class LogtoNodeBaseClient extends BaseClient {
|
|
|
15
15
|
const claims = await this.getIdTokenClaims();
|
|
16
16
|
const { accessToken, accessTokenClaims } = getAccessToken
|
|
17
17
|
? {
|
|
18
|
-
accessToken: await trySafe(async () => this.getAccessToken(resource)),
|
|
18
|
+
accessToken: await trySafe(async () => this.getAccessToken(resource, organizationId)),
|
|
19
19
|
accessTokenClaims: await trySafe(async () => this.getAccessTokenClaims(resource)),
|
|
20
20
|
}
|
|
21
21
|
: { accessToken: undefined, accessTokenClaims: undefined };
|
package/lib/src/index.cjs
CHANGED
|
@@ -17,9 +17,7 @@ class LogtoClient extends client.default {
|
|
|
17
17
|
return fetch(input, {
|
|
18
18
|
...init,
|
|
19
19
|
headers: {
|
|
20
|
-
Authorization: `Basic ${Buffer.from(
|
|
21
|
-
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
22
|
-
`${config.appId}:${config.appSecret}`, 'utf8').toString('base64')}`,
|
|
20
|
+
Authorization: `Basic ${Buffer.from(`${config.appId}:${config.appSecret}`, 'utf8').toString('base64')}`,
|
|
23
21
|
...init?.headers,
|
|
24
22
|
},
|
|
25
23
|
});
|
package/lib/src/index.js
CHANGED
|
@@ -14,9 +14,7 @@ class LogtoClient extends LogtoNodeBaseClient {
|
|
|
14
14
|
return fetch(input, {
|
|
15
15
|
...init,
|
|
16
16
|
headers: {
|
|
17
|
-
Authorization: `Basic ${Buffer.from(
|
|
18
|
-
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
19
|
-
`${config.appId}:${config.appSecret}`, 'utf8').toString('base64')}`,
|
|
17
|
+
Authorization: `Basic ${Buffer.from(`${config.appId}:${config.appSecret}`, 'utf8').toString('base64')}`,
|
|
20
18
|
...init?.headers,
|
|
21
19
|
},
|
|
22
20
|
});
|
package/lib/src/types.d.ts
CHANGED
|
@@ -15,6 +15,8 @@ export type LogtoContext = {
|
|
|
15
15
|
export type GetContextParameters = {
|
|
16
16
|
fetchUserInfo?: boolean;
|
|
17
17
|
getAccessToken?: boolean;
|
|
18
|
+
/** The optional `organization_id` param for granting access token. */
|
|
19
|
+
organizationId?: string;
|
|
18
20
|
resource?: string;
|
|
19
21
|
getOrganizationToken?: boolean;
|
|
20
22
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logto/node",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./lib/src/index.cjs",
|
|
6
6
|
"module": "./lib/src/index.js",
|
|
@@ -34,23 +34,19 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@silverhand/essentials": "^2.8.7",
|
|
36
36
|
"js-base64": "^3.7.4",
|
|
37
|
-
"@logto/client": "^2.6.
|
|
37
|
+
"@logto/client": "^2.6.7"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@silverhand/eslint-config": "^
|
|
41
|
-
"@silverhand/ts-config": "^
|
|
42
|
-
"@swc/core": "^1.3.7",
|
|
43
|
-
"@swc/jest": "^0.2.24",
|
|
40
|
+
"@silverhand/eslint-config": "^6.0.1",
|
|
41
|
+
"@silverhand/ts-config": "^6.0.0",
|
|
44
42
|
"@types/cookie": "^0.6.0",
|
|
45
|
-
"@types/jest": "^29.5.0",
|
|
46
43
|
"@types/node": "^20.11.19",
|
|
44
|
+
"@vitest/coverage-v8": "^1.4.0",
|
|
47
45
|
"eslint": "^8.57.0",
|
|
48
|
-
"jest": "^29.5.0",
|
|
49
|
-
"jest-location-mock": "^2.0.0",
|
|
50
|
-
"jest-matcher-specific-error": "^1.0.0",
|
|
51
46
|
"lint-staged": "^15.0.0",
|
|
52
47
|
"prettier": "^3.0.0",
|
|
53
|
-
"typescript": "^5.3.3"
|
|
48
|
+
"typescript": "^5.3.3",
|
|
49
|
+
"vitest": "^1.4.0"
|
|
54
50
|
},
|
|
55
51
|
"eslintConfig": {
|
|
56
52
|
"extends": "@silverhand"
|
|
@@ -65,7 +61,7 @@
|
|
|
65
61
|
"check": "tsc --noEmit",
|
|
66
62
|
"build": "rm -rf lib/ && tsc -p tsconfig.build.json --noEmit && rollup -c",
|
|
67
63
|
"lint": "eslint --ext .ts src",
|
|
68
|
-
"test": "
|
|
69
|
-
"test:coverage": "node test.cjs &&
|
|
64
|
+
"test": "vitest",
|
|
65
|
+
"test:coverage": "node test.cjs && vitest --silent --coverage"
|
|
70
66
|
}
|
|
71
67
|
}
|