Skip to content

Commit 77cd3a6

Browse files
committed
chore: fix config client-id issue
1 parent 83c52d4 commit 77cd3a6

7 files changed

Lines changed: 3236 additions & 1809 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@ lib/*
77
package-lock.json
88
.idea
99
.history
10+
.env
11+
.env.*
12+
.pnpm-store

__test__/executeIframe.test.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/**
2+
* @jest-environment jsdom
3+
*/
4+
5+
import { executeIframe } from '../src/utils';
6+
7+
describe('executeIframe', () => {
8+
const authorizerOrigin = 'https://auth.example.com';
9+
const authorizeUrl = `${authorizerOrigin}/authorize?x=1`;
10+
11+
beforeEach(() => {
12+
document.body.innerHTML = '';
13+
});
14+
15+
it('ignores postMessage from a different origin', async () => {
16+
const p = executeIframe(authorizeUrl, authorizerOrigin, 0.2);
17+
await new Promise(r => setTimeout(r, 0));
18+
window.dispatchEvent(
19+
new MessageEvent('message', {
20+
origin: 'https://evil.example',
21+
data: { response: { access_token: 'stolen' } },
22+
source: window as unknown as MessageEventSource,
23+
}),
24+
);
25+
await expect(p).rejects.toThrow('Authorization timeout');
26+
});
27+
28+
it('resolves when postMessage origin matches authorizer URL', async () => {
29+
const p = executeIframe(authorizeUrl, authorizerOrigin, 0.05);
30+
await new Promise(r => setTimeout(r, 0));
31+
window.dispatchEvent(
32+
new MessageEvent('message', {
33+
origin: authorizerOrigin,
34+
data: { response: { code: 'auth-code' } },
35+
source: null,
36+
}),
37+
);
38+
await expect(p).resolves.toEqual({ code: 'auth-code' });
39+
});
40+
});

package.json

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,29 +45,37 @@
4545
"path": "path-browserify"
4646
},
4747
"dependencies": {
48-
"cross-fetch": "^3.1.5"
48+
"cross-fetch": "^4.1.0"
4949
},
5050
"lint-staged": {
5151
"**/*.{js,jsx,ts,tsx}": [
5252
"npm run lint:fix"
5353
]
5454
},
5555
"devDependencies": {
56-
"@antfu/eslint-config": "^2.1.0",
57-
"@swc/core": "^1.3.99",
58-
"@types/jest": "^29.5.12",
59-
"@types/node": "^20.9.4",
60-
"@typescript-eslint/eslint-plugin": "^7.8.0",
61-
"@typescript-eslint/parser": "^7.8.0",
62-
"bumpp": "^9.2.0",
63-
"eslint": "^8.54.0",
64-
"husky": "^8.0.0",
56+
"@antfu/eslint-config": "^2.27.3",
57+
"@swc/core": "^1.15.24",
58+
"@types/jest": "^29.5.14",
59+
"@types/node": "^20.19.39",
60+
"@typescript-eslint/eslint-plugin": "^7.18.0",
61+
"@typescript-eslint/parser": "^7.18.0",
62+
"bumpp": "^9.11.1",
63+
"eslint": "^8.57.1",
64+
"husky": "^8.0.3",
6565
"jest": "^29.7.0",
66-
"lint-staged": "^15.2.0",
67-
"testcontainers": "^10.3.2",
68-
"ts-jest": "^29.1.1",
69-
"tslib": "^2.6.2",
70-
"tsup": "^8.0.1",
71-
"typescript": "^5.4.5"
66+
"jest-environment-jsdom": "^29.7.0",
67+
"lint-staged": "^15.5.2",
68+
"testcontainers": "^10.28.0",
69+
"ts-jest": "^29.4.9",
70+
"tslib": "^2.8.1",
71+
"tsup": "^8.5.1",
72+
"typescript": "^5.9.3"
73+
},
74+
"pnpm": {
75+
"overrides": {
76+
"undici": ">=6.24.0",
77+
"tar": ">=7.5.11",
78+
"@tootallnate/once": ">=3.0.1"
79+
}
7280
}
7381
}

0 commit comments

Comments
 (0)