@lightdash/common 1.252.0 → 1.252.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/dist/cjs/.tsbuildinfo +1 -1
- package/dist/cjs/utils/oauth.d.ts +2 -1
- package/dist/cjs/utils/oauth.d.ts.map +1 -1
- package/dist/cjs/utils/oauth.js +57 -33
- package/dist/cjs/utils/oauth.js.map +1 -1
- package/dist/cjs/utils/oauth.test.js +40 -1
- package/dist/cjs/utils/oauth.test.js.map +1 -1
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/utils/oauth.d.ts +2 -1
- package/dist/esm/utils/oauth.d.ts.map +1 -1
- package/dist/esm/utils/oauth.js +55 -32
- package/dist/esm/utils/oauth.js.map +1 -1
- package/dist/esm/utils/oauth.test.js +41 -2
- package/dist/esm/utils/oauth.test.js.map +1 -1
- package/dist/types/.tsbuildinfo +1 -1
- package/dist/types/utils/oauth.d.ts +2 -1
- package/dist/types/utils/oauth.d.ts.map +1 -1
- package/dist/types/utils/oauth.js +55 -32
- package/dist/types/utils/oauth.js.map +1 -1
- package/dist/types/utils/oauth.test.js +41 -2
- package/dist/types/utils/oauth.test.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const oauthPageStyles = "\n body {\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Fira Sans', 'Droid Sans', 'Open Sans', 'Helvetica Neue', sans-serif;\n background-color: #f8fafc;\n margin: 0;\n padding: 20px;\n box-sizing: border-box;\n min-height: 100vh;\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: 14px;\n line-height: 1.4;\n }\n .container {\n background: white;\n border-radius: 8px;\n border: 1px solid #e9ecef;\n box-shadow: 0px 1px 2px 0px rgba(10, 13, 18, 0.05);\n padding: 24px;\n margin: 0;\n box-sizing: border-box;\n max-width: 450px;\n width: 100%;\n text-align: center;\n }\n .logo {\n width: 130px;\n height: auto;\n margin: 0 auto 24px auto;\n display: block;\n }\n h1 {\n color: #111418;\n margin: 0 0 16px 0;\n font-size: 18px;\n font-weight: 600;\n text-align: center;\n }\n p {\n color: #6c757d;\n margin: 0 0 12px 0;\n line-height: 1.4;\n font-size: 14px;\n }\n .icon {\n width: 32px;\n height: 32px;\n margin: 0 auto 16px auto;\n display: block;\n }\n .success .icon {\n color: #111418;\n }\n .error .icon {\n color: #6c757d;\n }\n .stack {\n display: flex;\n flex-direction: column;\n gap: 16px;\n }\n";
|
|
1
|
+
export declare const oauthPageStyles = "\n body {\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Fira Sans', 'Droid Sans', 'Open Sans', 'Helvetica Neue', sans-serif;\n background-color: #f8fafc;\n margin: 0;\n padding: 20px;\n box-sizing: border-box;\n min-height: 100vh;\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: 14px;\n line-height: 1.4;\n }\n .container {\n background: white;\n border-radius: 8px;\n border: 1px solid #e9ecef;\n box-shadow: 0px 1px 2px 0px rgba(10, 13, 18, 0.05);\n padding: 24px;\n margin: 0;\n box-sizing: border-box;\n max-width: 450px;\n width: 100%;\n text-align: center;\n }\n .logo {\n width: 130px;\n height: auto;\n margin: 0 auto 24px auto;\n display: block;\n }\n h1 {\n color: #111418;\n margin: 0 0 16px 0;\n font-size: 18px;\n font-weight: 600;\n text-align: center;\n }\n p {\n color: #6c757d;\n margin: 0 0 12px 0;\n line-height: 1.4;\n font-size: 14px;\n }\n .icon {\n width: 32px;\n height: 32px;\n margin: 0 auto 16px auto;\n display: block;\n }\n .success .icon {\n color: #111418;\n }\n .error .icon {\n color: #6c757d;\n }\n .stack {\n display: flex;\n flex-direction: column;\n gap: 16px;\n }\n .oauth-btn,\n .button {\n display: inline-block;\n padding: 8px 24px;\n border: 1px solid #e9ecef;\n border-radius: 8px;\n font-weight: 500;\n font-size: 14px;\n cursor: pointer;\n text-decoration: none;\n transition: background 0.15s, border-color 0.15s;\n }\n .oauth-btn.approve,\n .button {\n background: #111418;\n color: #fff;\n border-color: #111418;\n }\n .oauth-btn.approve:hover,\n .button:hover {\n background: #2c2e33;\n border-color: #2c2e33;\n }\n .oauth-btn.deny {\n background: transparent;\n color: #111418;\n border-color: #e9ecef;\n }\n .oauth-btn.deny:hover {\n background: #f8fafc;\n border-color: #dee2e6;\n }\n";
|
|
2
2
|
declare const OAUTH_ICONS: {
|
|
3
3
|
readonly success: '<circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2"/><path d="M9 12l2 2 4-4" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>';
|
|
4
4
|
readonly error: '<circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2"/><path d="M15 9l-6 6M9 9l6 6" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>';
|
|
@@ -35,6 +35,7 @@ export interface OAuthRedirectParams {
|
|
|
35
35
|
redirectUrl: string;
|
|
36
36
|
message: string;
|
|
37
37
|
}
|
|
38
|
+
export declare const isSafeRedirectScheme: (uri: string) => boolean;
|
|
38
39
|
/**
|
|
39
40
|
* Parses a scope string (e.g. "read write") and returns an array of scope objects with descriptions
|
|
40
41
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../../../src/utils/oauth.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../../../src/utils/oauth.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe,gzEA8F3B,CAAC;AAoTF,QAAA,MAAM,WAAW;aACb,OAAO,EACH,wLAAwL;aAC5L,KAAK,EAAE,6LAA6L;aACpM,cAAc,EACV,sLAAsL;CACpL,CAAC;AAOX,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,OAAO,CAAC;AACtD,MAAM,MAA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5B,MAAM,YACH,MAAM,EAAE,aACR,aAAa,KACxB,MAME,CAAC;AAEN;;GAEG;AACH,eAAO,MAAM,yBAAyB,WAC1B,mBAAmB,KAC5B,MAYF,CAAC;AAQF;;;GAGG;AACH,eAAO,MAAM,0BAA0B,WAC3B,oBAAoB,KAC7B,MASG,CAAC"}
|
|
@@ -61,6 +61,38 @@ export const oauthPageStyles = `
|
|
|
61
61
|
flex-direction: column;
|
|
62
62
|
gap: 16px;
|
|
63
63
|
}
|
|
64
|
+
.oauth-btn,
|
|
65
|
+
.button {
|
|
66
|
+
display: inline-block;
|
|
67
|
+
padding: 8px 24px;
|
|
68
|
+
border: 1px solid #e9ecef;
|
|
69
|
+
border-radius: 8px;
|
|
70
|
+
font-weight: 500;
|
|
71
|
+
font-size: 14px;
|
|
72
|
+
cursor: pointer;
|
|
73
|
+
text-decoration: none;
|
|
74
|
+
transition: background 0.15s, border-color 0.15s;
|
|
75
|
+
}
|
|
76
|
+
.oauth-btn.approve,
|
|
77
|
+
.button {
|
|
78
|
+
background: #111418;
|
|
79
|
+
color: #fff;
|
|
80
|
+
border-color: #111418;
|
|
81
|
+
}
|
|
82
|
+
.oauth-btn.approve:hover,
|
|
83
|
+
.button:hover {
|
|
84
|
+
background: #2c2e33;
|
|
85
|
+
border-color: #2c2e33;
|
|
86
|
+
}
|
|
87
|
+
.oauth-btn.deny {
|
|
88
|
+
background: transparent;
|
|
89
|
+
color: #111418;
|
|
90
|
+
border-color: #e9ecef;
|
|
91
|
+
}
|
|
92
|
+
.oauth-btn.deny:hover {
|
|
93
|
+
background: #f8fafc;
|
|
94
|
+
border-color: #dee2e6;
|
|
95
|
+
}
|
|
64
96
|
`;
|
|
65
97
|
// Lightdash logo SVG
|
|
66
98
|
const LIGHTDASH_LOGO_SVG = `
|
|
@@ -119,6 +151,7 @@ const OAUTH_REDIRECT_TEMPLATE = `
|
|
|
119
151
|
{{{logo}}}
|
|
120
152
|
<h1>Redirecting...</h1>
|
|
121
153
|
<p>{{message}}</p>
|
|
154
|
+
<a class="button" href="{{redirectUrl}}">Continue</a>
|
|
122
155
|
</div>
|
|
123
156
|
</div>
|
|
124
157
|
</body>
|
|
@@ -278,33 +311,6 @@ const OAUTH_AUTHORIZE_TEMPLATE = `
|
|
|
278
311
|
padding-top: 16px;
|
|
279
312
|
border-top: 1px solid #e9ecef;
|
|
280
313
|
}
|
|
281
|
-
.oauth-btn {
|
|
282
|
-
padding: 8px 24px;
|
|
283
|
-
border: 1px solid #e9ecef;
|
|
284
|
-
border-radius: 8px;
|
|
285
|
-
font-weight: 500;
|
|
286
|
-
font-size: 14px;
|
|
287
|
-
cursor: pointer;
|
|
288
|
-
transition: background 0.15s, border-color 0.15s;
|
|
289
|
-
}
|
|
290
|
-
.oauth-btn.approve {
|
|
291
|
-
background: #111418;
|
|
292
|
-
color: #fff;
|
|
293
|
-
border-color: #111418;
|
|
294
|
-
}
|
|
295
|
-
.oauth-btn.approve:hover {
|
|
296
|
-
background: #2c2e33;
|
|
297
|
-
border-color: #2c2e33;
|
|
298
|
-
}
|
|
299
|
-
.oauth-btn.deny {
|
|
300
|
-
background: transparent;
|
|
301
|
-
color: #111418;
|
|
302
|
-
border-color: #e9ecef;
|
|
303
|
-
}
|
|
304
|
-
.oauth-btn.deny:hover {
|
|
305
|
-
background: #f8fafc;
|
|
306
|
-
border-color: #dee2e6;
|
|
307
|
-
}
|
|
308
314
|
</style>
|
|
309
315
|
</head>
|
|
310
316
|
<body>
|
|
@@ -399,6 +405,16 @@ const OAUTH_ICONS = {
|
|
|
399
405
|
const compiledResponseTemplate = compile(OAUTH_RESPONSE_TEMPLATE);
|
|
400
406
|
const compiledRedirectTemplate = compile(OAUTH_REDIRECT_TEMPLATE);
|
|
401
407
|
const compiledAuthorizeTemplate = compile(OAUTH_AUTHORIZE_TEMPLATE);
|
|
408
|
+
const UNSAFE_REDIRECT_PROTOCOLS = new Set(['javascript', 'data', 'vbscript', 'file', 'blob'].map((scheme) => `${scheme}:`));
|
|
409
|
+
export const isSafeRedirectScheme = (uri) => {
|
|
410
|
+
try {
|
|
411
|
+
const { protocol } = new URL(uri);
|
|
412
|
+
return !UNSAFE_REDIRECT_PROTOCOLS.has(protocol.toLowerCase());
|
|
413
|
+
}
|
|
414
|
+
catch {
|
|
415
|
+
return false;
|
|
416
|
+
}
|
|
417
|
+
};
|
|
402
418
|
// Scope descriptions mapping
|
|
403
419
|
const SCOPE_DESCRIPTIONS = {
|
|
404
420
|
read: {
|
|
@@ -465,11 +481,18 @@ export const generateOAuthErrorResponse = (title, messages, iconType = 'error')
|
|
|
465
481
|
/**
|
|
466
482
|
* Generates a script-free redirect page for a previously validated OAuth URI.
|
|
467
483
|
*/
|
|
468
|
-
export const generateOAuthRedirectPage = (params) =>
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
484
|
+
export const generateOAuthRedirectPage = (params) => {
|
|
485
|
+
if (!isSafeRedirectScheme(params.redirectUrl)) {
|
|
486
|
+
return generateOAuthErrorResponse('Unsupported redirect', [
|
|
487
|
+
'This application uses an unsupported redirect and cannot continue.',
|
|
488
|
+
]);
|
|
489
|
+
}
|
|
490
|
+
return compiledRedirectTemplate({
|
|
491
|
+
styles: oauthPageStyles,
|
|
492
|
+
logo: LIGHTDASH_LOGO_SVG,
|
|
493
|
+
...params,
|
|
494
|
+
});
|
|
495
|
+
};
|
|
473
496
|
const getUserInitials = (user) => {
|
|
474
497
|
const initials = `${user.firstName.charAt(0)}${user.lastName.charAt(0)}`.trim();
|
|
475
498
|
return initials || user.email?.charAt(0) || '?';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth.js","sourceRoot":"","sources":["../../../src/utils/oauth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,MAAM,CAAC,MAAM,eAAe,GAAG
|
|
1
|
+
{"version":3,"file":"oauth.js","sourceRoot":"","sources":["../../../src/utils/oauth.ts"],"names":[],"mapp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P,CAAC;IAED,OAAO,wBAAwB,CAAC;QAC5B,MAAM,EAAE,eAAe;QACvB,IAAI,EAAE,kBAAkB;QACxB,GAAG,MAAM;KACZ,CAAC,CAAC;AACP,CAAC,CAAC;AAEF,MAAM,eAAe,GAAG,CAAC,IAAe,EAAU,EAAE;IAChD,MAAM,QAAQ,GACV,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC;IACnE,OAAO,QAAQ,IAAI,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC;AACpD,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CACtC,MAA4B,EACtB,EAAE,CACR,yBAAyB,CAAC;IACtB,MAAM,EAAE,eAAe;IACvB,IAAI,EAAE,kBAAkB;IACxB,GAAG,MAAM;IACT,IAAI,EAAE;QACF,GAAG,MAAM,CAAC,IAAI;QACd,QAAQ,EAAE,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC;KACzC;CACJ,CAAC,CAAC"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { generateOAuthAuthorizePage, generateOAuthRedirectPage, generateOAuthSuccessResponse, parseScopeString, } from './oauth';
|
|
1
|
+
import { generateOAuthAuthorizePage, generateOAuthRedirectPage, generateOAuthSuccessResponse, isSafeRedirectScheme, parseScopeString, } from './oauth';
|
|
2
2
|
const VIEWPORT_META = '<meta name="viewport" content="width=device-width, initial-scale=1" />';
|
|
3
|
+
const JAVASCRIPT_SCHEME = ['javascript', ''].join(':');
|
|
4
|
+
const JAVASCRIPT_REDIRECT_URI = `${JAVASCRIPT_SCHEME}alert(1)`;
|
|
3
5
|
const authorizePage = () => generateOAuthAuthorizePage({
|
|
4
6
|
action: '/api/v1/oauth/authorize',
|
|
5
7
|
client_id: 'test-client',
|
|
@@ -15,6 +17,27 @@ const authorizePage = () => generateOAuthAuthorizePage({
|
|
|
15
17
|
loginUrl: '/login',
|
|
16
18
|
hiddenInputs: [],
|
|
17
19
|
});
|
|
20
|
+
describe('isSafeRedirectScheme', () => {
|
|
21
|
+
it.each([
|
|
22
|
+
'https://example.com/callback',
|
|
23
|
+
'http://localhost:9000/callback',
|
|
24
|
+
'com.lightdash.mobile://oauth/callback',
|
|
25
|
+
])('accepts supported redirect URI %s', (redirectUri) => {
|
|
26
|
+
expect(isSafeRedirectScheme(redirectUri)).toBe(true);
|
|
27
|
+
});
|
|
28
|
+
it.each([
|
|
29
|
+
JAVASCRIPT_REDIRECT_URI,
|
|
30
|
+
'data:text/html,x',
|
|
31
|
+
'vbscript:x',
|
|
32
|
+
'file:///etc/passwd',
|
|
33
|
+
'blob:https://x',
|
|
34
|
+
[' JAVASCRIPT', 'alert(1)'].join(':'),
|
|
35
|
+
'\tDaTa:text/html,x ',
|
|
36
|
+
'not a URL',
|
|
37
|
+
])('rejects unsafe redirect URI %s', (redirectUri) => {
|
|
38
|
+
expect(isSafeRedirectScheme(redirectUri)).toBe(false);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
18
41
|
describe('OAuth page templates', () => {
|
|
19
42
|
it('declares the viewport on the authorize page so it renders at 1:1 on mobile', () => {
|
|
20
43
|
expect(authorizePage()).toContain(VIEWPORT_META);
|
|
@@ -38,8 +61,24 @@ describe('OAuth page templates', () => {
|
|
|
38
61
|
expect(redirectPage).not.toContain('</script>');
|
|
39
62
|
expect(redirectPage).not.toContain('<img src=x');
|
|
40
63
|
expect(redirectPage).not.toContain('onerror=');
|
|
41
|
-
expect(redirectPage).
|
|
64
|
+
expect(redirectPage).toContain('<a class="button" href="https://example.com/callback?</script><img src=x onerror=alert(document.domain)>">Continue</a>');
|
|
42
65
|
expect(redirectPage).toContain('</script>');
|
|
43
66
|
});
|
|
67
|
+
it('escapes quotes in OAuth redirect link URLs', () => {
|
|
68
|
+
const redirectPage = generateOAuthRedirectPage({
|
|
69
|
+
redirectUrl: 'com.lightdash.mobile://oauth/callback?state="value"',
|
|
70
|
+
message: 'Redirecting',
|
|
71
|
+
});
|
|
72
|
+
expect(redirectPage).toContain('<a class="button" href="com.lightdash.mobile://oauth/callback?state="value"">Continue</a>');
|
|
73
|
+
expect(redirectPage).not.toContain('href="value"');
|
|
74
|
+
});
|
|
75
|
+
it('does not navigate to an unsafe OAuth redirect URL', () => {
|
|
76
|
+
const redirectPage = generateOAuthRedirectPage({
|
|
77
|
+
redirectUrl: JAVASCRIPT_REDIRECT_URI,
|
|
78
|
+
message: 'Redirecting',
|
|
79
|
+
});
|
|
80
|
+
expect(redirectPage).not.toContain(JAVASCRIPT_SCHEME);
|
|
81
|
+
expect(redirectPage).not.toContain('http-equiv="refresh"');
|
|
82
|
+
});
|
|
44
83
|
});
|
|
45
84
|
//# sourceMappingURL=oauth.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth.test.js","sourceRoot":"","sources":["../../../src/utils/oauth.test.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,0BAA0B,EAC1B,yBAAyB,EACzB,4BAA4B,EAC5B,gBAAgB,GACnB,MAAM,SAAS,CAAC;AAEjB,MAAM,aAAa,GACf,wEAAwE,CAAC;
|
|
1
|
+
{"version":3,"file":"oauth.test.js","sourceRoot":"","sources":["../../../src/utils/oauth.test.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,0BAA0B,EAC1B,yBAAyB,EACzB,4BAA4B,EAC5B,oBAAoB,EACpB,gBAAgB,GACnB,MAAM,SAAS,CAAC;AAEjB,MAAM,aAAa,GACf,wEAAwE,CAAC;AAC7E,MAAM,iBAAiB,GAAG,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACvD,MAAM,uBAAuB,GAAG,GAAG,iBAAiB,UAAU,CAAC;AAE/D,MAAM,aAAa,GAAG,GAAG,EAAE,CACvB,0BA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