@logto/client 2.6.6 → 2.6.7
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/adapter/defaults.cjs +1 -3
- package/lib/adapter/defaults.js +1 -3
- package/lib/mock.d.ts +16 -30
- package/lib/utils/memoize.cjs +1 -1
- package/lib/utils/memoize.js +1 -1
- package/package.json +11 -15
package/lib/adapter/defaults.cjs
CHANGED
|
@@ -17,9 +17,7 @@ class DefaultJwtVerifier {
|
|
|
17
17
|
async verifyIdToken(idToken) {
|
|
18
18
|
const { appId } = this.client.logtoConfig;
|
|
19
19
|
const { issuer, jwksUri } = await this.client.getOidcConfig();
|
|
20
|
-
|
|
21
|
-
this.getJwtVerifyGetKey = jose.createRemoteJWKSet(new URL(jwksUri));
|
|
22
|
-
}
|
|
20
|
+
this.getJwtVerifyGetKey ||= jose.createRemoteJWKSet(new URL(jwksUri));
|
|
23
21
|
await verifyIdToken(idToken, appId, issuer, this.getJwtVerifyGetKey);
|
|
24
22
|
}
|
|
25
23
|
}
|
package/lib/adapter/defaults.js
CHANGED
|
@@ -15,9 +15,7 @@ class DefaultJwtVerifier {
|
|
|
15
15
|
async verifyIdToken(idToken) {
|
|
16
16
|
const { appId } = this.client.logtoConfig;
|
|
17
17
|
const { issuer, jwksUri } = await this.client.getOidcConfig();
|
|
18
|
-
|
|
19
|
-
this.getJwtVerifyGetKey = createRemoteJWKSet(new URL(jwksUri));
|
|
20
|
-
}
|
|
18
|
+
this.getJwtVerifyGetKey ||= createRemoteJWKSet(new URL(jwksUri));
|
|
21
19
|
await verifyIdToken(idToken, appId, issuer, this.getJwtVerifyGetKey);
|
|
22
20
|
}
|
|
23
21
|
}
|
package/lib/mock.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
/// <reference types="jest" />
|
|
2
1
|
import { type OidcConfigResponse, Prompt } from '@logto/js';
|
|
3
2
|
import { type Nullable } from '@silverhand/essentials';
|
|
3
|
+
import nock from 'nock';
|
|
4
|
+
import { type Mock } from 'vitest';
|
|
4
5
|
import type { Storage } from './adapter/index.js';
|
|
5
6
|
import type { AccessToken, LogtoConfig, LogtoSignInSessionItem } from './index.js';
|
|
6
7
|
import LogtoClient from './index.js';
|
|
@@ -35,38 +36,22 @@ export declare const accessToken = "access_token_value";
|
|
|
35
36
|
export declare const refreshToken = "new_refresh_token_value";
|
|
36
37
|
export declare const idToken = "id_token_value";
|
|
37
38
|
export declare const currentUnixTimeStamp: number;
|
|
38
|
-
export declare const mockFetchOidcConfig: (delay?: number) =>
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}>, [], any>;
|
|
47
|
-
export declare const fetchOidcConfig: jest.Mock<Promise<{
|
|
48
|
-
authorizationEndpoint: string;
|
|
49
|
-
tokenEndpoint: string;
|
|
50
|
-
userinfoEndpoint: string;
|
|
51
|
-
endSessionEndpoint: string;
|
|
52
|
-
revocationEndpoint: string;
|
|
53
|
-
jwksUri: string;
|
|
54
|
-
issuer: string;
|
|
55
|
-
}>, [], any>;
|
|
56
|
-
export declare const requester: jest.Mock<any, any, any>;
|
|
57
|
-
export declare const failingRequester: jest.Mock<any, any, any>;
|
|
58
|
-
export declare const navigate: jest.Mock<any, any, any>;
|
|
59
|
-
export declare const generateCodeChallenge: jest.Mock<Promise<string>, [], any>;
|
|
60
|
-
export declare const generateCodeVerifier: jest.Mock<string, [], any>;
|
|
61
|
-
export declare const generateState: jest.Mock<string, [], any>;
|
|
39
|
+
export declare const mockFetchOidcConfig: (delay?: number) => Mock<unknown[], Promise<OidcConfigResponse>>;
|
|
40
|
+
export declare const fetchOidcConfig: Mock<unknown[], Promise<OidcConfigResponse>>;
|
|
41
|
+
export declare const requester: Mock<any, any>;
|
|
42
|
+
export declare const failingRequester: Mock<any, any>;
|
|
43
|
+
export declare const navigate: Mock<any, any>;
|
|
44
|
+
export declare const generateCodeChallenge: Mock<[], Promise<string>>;
|
|
45
|
+
export declare const generateCodeVerifier: Mock<[], string>;
|
|
46
|
+
export declare const generateState: Mock<[], string>;
|
|
62
47
|
export declare const createAdapters: (withCache?: boolean) => {
|
|
63
|
-
requester:
|
|
48
|
+
requester: Mock<any, any>;
|
|
64
49
|
storage: MockedStorage;
|
|
65
50
|
unstable_cache: import("@silverhand/essentials").Optional<MockedStorage>;
|
|
66
|
-
navigate:
|
|
67
|
-
generateCodeChallenge:
|
|
68
|
-
generateCodeVerifier:
|
|
69
|
-
generateState:
|
|
51
|
+
navigate: Mock<any, any>;
|
|
52
|
+
generateCodeChallenge: Mock<[], Promise<string>>;
|
|
53
|
+
generateCodeVerifier: Mock<[], string>;
|
|
54
|
+
generateState: Mock<[], string>;
|
|
70
55
|
};
|
|
71
56
|
export declare const createClient: (prompt?: Prompt, storage?: MockedStorage, withCache?: boolean, scopes?: string[]) => LogtoClientWithAccessors;
|
|
72
57
|
/**
|
|
@@ -79,3 +64,4 @@ export declare class LogtoClientWithAccessors extends LogtoClient {
|
|
|
79
64
|
setSignInSessionItem(item: Nullable<LogtoSignInSessionItem>): Promise<void>;
|
|
80
65
|
getAccessTokenMap(): Map<string, AccessToken>;
|
|
81
66
|
}
|
|
67
|
+
export declare const nocked: nock.Scope;
|
package/lib/utils/memoize.cjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
function memoize(run) {
|
|
4
4
|
const promiseCache = new Map();
|
|
5
5
|
const memoized = async function (...args) {
|
|
6
|
-
const promiseKey = args
|
|
6
|
+
const promiseKey = JSON.stringify(args);
|
|
7
7
|
const cachedPromise = promiseCache.get(promiseKey);
|
|
8
8
|
if (cachedPromise) {
|
|
9
9
|
return cachedPromise;
|
package/lib/utils/memoize.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
function memoize(run) {
|
|
2
2
|
const promiseCache = new Map();
|
|
3
3
|
const memoized = async function (...args) {
|
|
4
|
-
const promiseKey = args
|
|
4
|
+
const promiseKey = JSON.stringify(args);
|
|
5
5
|
const cachedPromise = promiseCache.get(promiseKey);
|
|
6
6
|
if (cachedPromise) {
|
|
7
7
|
return cachedPromise;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logto/client",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./lib/index.cjs",
|
|
6
6
|
"module": "./lib/index.js",
|
|
@@ -35,22 +35,17 @@
|
|
|
35
35
|
"@logto/js": "^4.1.1"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@
|
|
39
|
-
"@silverhand/
|
|
40
|
-
"@silverhand/ts-config": "^5.0.0",
|
|
41
|
-
"@swc/core": "^1.3.50",
|
|
42
|
-
"@swc/jest": "^0.2.24",
|
|
43
|
-
"@types/jest": "^29.5.0",
|
|
38
|
+
"@silverhand/eslint-config": "^6.0.1",
|
|
39
|
+
"@silverhand/ts-config": "^6.0.0",
|
|
44
40
|
"@types/node": "^20.11.19",
|
|
41
|
+
"@vitest/coverage-v8": "^1.4.0",
|
|
45
42
|
"eslint": "^8.57.0",
|
|
46
|
-
"
|
|
47
|
-
"jest-matcher-specific-error": "^1.0.0",
|
|
43
|
+
"happy-dom": "^14.0.0",
|
|
48
44
|
"lint-staged": "^15.0.0",
|
|
49
|
-
"nock": "
|
|
45
|
+
"nock": "14.0.0-beta.5",
|
|
50
46
|
"prettier": "^3.0.0",
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"typescript": "^5.3.3"
|
|
47
|
+
"typescript": "^5.3.3",
|
|
48
|
+
"vitest": "^1.4.0"
|
|
54
49
|
},
|
|
55
50
|
"eslintConfig": {
|
|
56
51
|
"extends": "@silverhand"
|
|
@@ -65,7 +60,8 @@
|
|
|
65
60
|
"check": "tsc --noEmit",
|
|
66
61
|
"build": "rm -rf lib/ && tsc -p tsconfig.build.json --noEmit && rollup -c",
|
|
67
62
|
"lint": "eslint --ext .ts src",
|
|
68
|
-
"test": "
|
|
69
|
-
"test:
|
|
63
|
+
"test": "vitest",
|
|
64
|
+
"test:dom": "vitest --config=vitest.config.dom.ts",
|
|
65
|
+
"test:coverage": "pnpm test:dom --silent --no-watch && pnpm run test --no-watch --silent --coverage"
|
|
70
66
|
}
|
|
71
67
|
}
|