@atproto/oauth-provider 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +13 -0
- package/dist/account/account-manager.d.ts +2 -2
- package/dist/account/account-manager.d.ts.map +1 -1
- package/dist/account/account-manager.js.map +1 -1
- package/dist/account/account-store.d.ts +19 -6
- package/dist/account/account-store.d.ts.map +1 -1
- package/dist/account/account-store.js +16 -1
- package/dist/account/account-store.js.map +1 -1
- package/dist/assets/app/bundle-manifest.json +3 -3
- package/dist/assets/app/main.css +1 -1
- package/dist/assets/app/main.js +3 -3
- package/dist/assets/app/main.js.map +1 -1
- package/dist/client/client-auth.d.ts.map +1 -1
- package/dist/client/client-auth.js +2 -2
- package/dist/client/client-auth.js.map +1 -1
- package/dist/client/client-manager.d.ts.map +1 -1
- package/dist/client/client-manager.js +3 -1
- package/dist/client/client-manager.js.map +1 -1
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/client.js +3 -3
- package/dist/client/client.js.map +1 -1
- package/dist/dpop/dpop-manager.d.ts.map +1 -1
- package/dist/dpop/dpop-manager.js +3 -3
- package/dist/dpop/dpop-manager.js.map +1 -1
- package/dist/errors/invalid-token-error.d.ts.map +1 -1
- package/dist/errors/invalid-token-error.js +3 -2
- package/dist/errors/invalid-token-error.js.map +1 -1
- package/dist/errors/second-authentication-factor-required-error.d.ts +13 -0
- package/dist/errors/second-authentication-factor-required-error.d.ts.map +1 -0
- package/dist/errors/second-authentication-factor-required-error.js +23 -0
- package/dist/errors/second-authentication-factor-required-error.js.map +1 -0
- package/dist/lib/util/authorization-header.js +1 -1
- package/dist/lib/util/authorization-header.js.map +1 -1
- package/dist/metadata/build-metadata.d.ts.map +1 -1
- package/dist/metadata/build-metadata.js +2 -0
- package/dist/metadata/build-metadata.js.map +1 -1
- package/dist/oauth-errors.d.ts +1 -0
- package/dist/oauth-errors.d.ts.map +1 -1
- package/dist/oauth-errors.js +3 -1
- package/dist/oauth-errors.js.map +1 -1
- package/dist/oauth-provider.d.ts +101 -4
- package/dist/oauth-provider.d.ts.map +1 -1
- package/dist/oauth-provider.js +98 -110
- package/dist/oauth-provider.js.map +1 -1
- package/dist/output/{send-authorize-page.d.ts → build-authorize-data.d.ts} +2 -5
- package/dist/output/build-authorize-data.d.ts.map +1 -0
- package/dist/output/build-authorize-data.js +22 -0
- package/dist/output/build-authorize-data.js.map +1 -0
- package/dist/output/build-error-payload.d.ts.map +1 -1
- package/dist/output/build-error-payload.js +4 -3
- package/dist/output/build-error-payload.js.map +1 -1
- package/dist/output/customization.d.ts +2 -12
- package/dist/output/customization.d.ts.map +1 -1
- package/dist/output/customization.js +59 -32
- package/dist/output/customization.js.map +1 -1
- package/dist/output/output-manager.d.ts +16 -0
- package/dist/output/output-manager.d.ts.map +1 -0
- package/dist/output/output-manager.js +69 -0
- package/dist/output/output-manager.js.map +1 -0
- package/dist/output/send-web-page.d.ts +1 -1
- package/dist/output/send-web-page.d.ts.map +1 -1
- package/dist/output/send-web-page.js +3 -2
- package/dist/output/send-web-page.js.map +1 -1
- package/package.json +6 -6
- package/src/account/account-manager.ts +2 -2
- package/src/account/account-store.ts +12 -6
- package/src/assets/app/components/accept-form.tsx +86 -83
- package/src/assets/app/components/account-picker.tsx +98 -79
- package/src/assets/app/components/button.tsx +34 -0
- package/src/assets/app/components/client-identifier.tsx +12 -13
- package/src/assets/app/components/fieldset.tsx +26 -0
- package/src/assets/app/components/form-card.tsx +47 -0
- package/src/assets/app/components/help-card.tsx +1 -1
- package/src/assets/app/components/icons/alert-icon.tsx +5 -0
- package/src/assets/app/components/icons/at-symbol-icon.tsx +5 -0
- package/src/assets/app/components/icons/caret-right-icon.tsx +5 -0
- package/src/assets/app/components/icons/lock-icon.tsx +5 -0
- package/src/assets/app/components/icons/token-icon.tsx +5 -0
- package/src/assets/app/components/icons/util.tsx +17 -0
- package/src/assets/app/components/info-card.tsx +45 -0
- package/src/assets/app/components/input-checkbox.tsx +47 -0
- package/src/assets/app/components/input-container.tsx +37 -0
- package/src/assets/app/components/input-layout.tsx +47 -0
- package/src/assets/app/components/input-text.tsx +69 -0
- package/src/assets/app/components/layout-title-page.tsx +33 -16
- package/src/assets/app/components/layout-welcome.tsx +30 -14
- package/src/assets/app/components/sign-in-form.tsx +214 -196
- package/src/assets/app/components/sign-up-account-form.tsx +101 -117
- package/src/assets/app/components/sign-up-disclaimer.tsx +1 -1
- package/src/assets/app/hooks/use-api.ts +2 -0
- package/src/assets/app/lib/api.ts +49 -14
- package/src/assets/app/lib/clsx.ts +6 -1
- package/src/assets/app/lib/util.ts +3 -0
- package/src/assets/app/main.css +2 -1
- package/src/assets/app/views/accept-view.tsx +4 -3
- package/src/assets/app/views/authorize-view.tsx +8 -4
- package/src/assets/app/views/error-view.tsx +24 -15
- package/src/assets/app/views/sign-in-view.tsx +5 -15
- package/src/assets/app/views/sign-up-view.tsx +3 -10
- package/src/assets/app/views/welcome-view.tsx +11 -18
- package/src/client/client-auth.ts +3 -2
- package/src/client/client-manager.ts +2 -1
- package/src/client/client.ts +3 -1
- package/src/dpop/dpop-manager.ts +3 -2
- package/src/errors/invalid-token-error.ts +3 -1
- package/src/errors/second-authentication-factor-required-error.ts +25 -0
- package/src/lib/util/authorization-header.ts +1 -1
- package/src/metadata/build-metadata.ts +3 -0
- package/src/oauth-errors.ts +1 -0
- package/src/oauth-provider.ts +110 -99
- package/src/output/{send-authorize-page.ts → build-authorize-data.ts} +3 -43
- package/src/output/build-error-payload.ts +3 -1
- package/src/output/customization.ts +67 -45
- package/src/output/output-manager.ts +87 -0
- package/src/output/send-web-page.ts +4 -3
- package/tailwind.config.js +14 -1
- package/dist/output/send-authorize-page.d.ts.map +0 -1
- package/dist/output/send-authorize-page.js +0 -49
- package/dist/output/send-authorize-page.js.map +0 -1
- package/dist/output/send-error-page.d.ts +0 -5
- package/dist/output/send-error-page.d.ts.map +0 -1
- package/dist/output/send-error-page.js +0 -31
- package/dist/output/send-error-page.js.map +0 -1
- package/src/output/send-error-page.ts +0 -41
@@ -1,22 +1,9 @@
|
|
1
1
|
// Matches colors defined in tailwind.config.js
|
2
|
-
const colorNames = ['
|
2
|
+
const colorNames = ['brand', 'error', 'warning'] as const
|
3
3
|
type ColorName = (typeof colorNames)[number]
|
4
4
|
const isColorName = (name: string): name is ColorName =>
|
5
5
|
(colorNames as readonly string[]).includes(name)
|
6
6
|
|
7
|
-
export type FieldDefinition = {
|
8
|
-
label?: string
|
9
|
-
placeholder?: string
|
10
|
-
pattern?: string
|
11
|
-
title?: string
|
12
|
-
}
|
13
|
-
|
14
|
-
export type ExtraFieldDefinition = FieldDefinition & {
|
15
|
-
type: 'text' | 'password' | 'date' | 'captcha'
|
16
|
-
required?: boolean
|
17
|
-
[_: string]: unknown
|
18
|
-
}
|
19
|
-
|
20
7
|
export type Customization = {
|
21
8
|
name?: string
|
22
9
|
logo?: string
|
@@ -41,56 +28,91 @@ export function buildCustomizationData({
|
|
41
28
|
}
|
42
29
|
|
43
30
|
export function buildCustomizationCss(customization?: Customization) {
|
44
|
-
|
31
|
+
const vars = Array.from(buildCustomizationVars(customization))
|
32
|
+
if (vars.length) return `:root { ${vars.join(' ')} }`
|
33
|
+
|
34
|
+
return ''
|
35
|
+
}
|
36
|
+
|
37
|
+
export function* buildCustomizationVars(customization?: Customization) {
|
38
|
+
if (customization?.colors) {
|
39
|
+
for (const [name, value] of Object.entries(customization.colors)) {
|
40
|
+
if (!isColorName(name)) {
|
41
|
+
throw new TypeError(`Invalid color name: ${name}`)
|
42
|
+
}
|
43
|
+
|
44
|
+
// Skip undefined values
|
45
|
+
if (value === undefined) continue
|
45
46
|
|
46
|
-
|
47
|
-
.filter((e) => isColorName(e[0]) && e[1] != null)
|
48
|
-
.map(([name, value]) => [name, parseColor(value)] as const)
|
49
|
-
.filter((e): e is [ColorName, ParsedColor] => e[1] != null)
|
50
|
-
// alpha not supported by tailwind (it does not work that way)
|
51
|
-
.map(([name, { r, g, b }]) => `--color-${name}: ${r} ${g} ${b};`)
|
47
|
+
const { r, g, b, a } = parseColor(value)
|
52
48
|
|
53
|
-
|
49
|
+
// Tailwind does not apply alpha values to base colors
|
50
|
+
if (a !== undefined) throw new TypeError('Alpha not supported')
|
51
|
+
|
52
|
+
yield `--color-${name}: ${r} ${g} ${b};`
|
53
|
+
}
|
54
|
+
}
|
54
55
|
}
|
55
56
|
|
56
|
-
type
|
57
|
-
function parseColor(color:
|
57
|
+
type RgbaColor = { r: number; g: number; b: number; a?: number }
|
58
|
+
function parseColor(color: unknown): RgbaColor {
|
59
|
+
if (typeof color !== 'string') {
|
60
|
+
throw new TypeError(`Invalid color value: ${typeof color}`)
|
61
|
+
}
|
62
|
+
|
58
63
|
if (color.startsWith('#')) {
|
59
64
|
if (color.length === 4 || color.length === 5) {
|
60
|
-
const
|
61
|
-
|
62
|
-
|
63
|
-
|
65
|
+
const r = parseUi8Hex(color.slice(1, 2))
|
66
|
+
const g = parseUi8Hex(color.slice(2, 3))
|
67
|
+
const b = parseUi8Hex(color.slice(3, 4))
|
68
|
+
const a = color.length > 4 ? parseUi8Hex(color.slice(4, 5)) : undefined
|
64
69
|
return { r, g, b, a }
|
65
70
|
}
|
66
71
|
|
67
72
|
if (color.length === 7 || color.length === 9) {
|
68
|
-
const r =
|
69
|
-
const g =
|
70
|
-
const b =
|
71
|
-
const a = color.length > 8 ?
|
73
|
+
const r = parseUi8Hex(color.slice(1, 3))
|
74
|
+
const g = parseUi8Hex(color.slice(3, 5))
|
75
|
+
const b = parseUi8Hex(color.slice(5, 7))
|
76
|
+
const a = color.length > 8 ? parseUi8Hex(color.slice(7, 9)) : undefined
|
72
77
|
return { r, g, b, a }
|
73
78
|
}
|
74
79
|
|
75
|
-
|
80
|
+
throw new TypeError(`Invalid hex color: ${color}`)
|
76
81
|
}
|
77
82
|
|
78
|
-
const rgbMatch = color.match(
|
83
|
+
const rgbMatch = color.match(
|
84
|
+
/^\s*rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)\s*$/,
|
85
|
+
)
|
79
86
|
if (rgbMatch) {
|
80
|
-
const
|
81
|
-
|
87
|
+
const r = parseUi8Dec(rgbMatch[1])
|
88
|
+
const g = parseUi8Dec(rgbMatch[2])
|
89
|
+
const b = parseUi8Dec(rgbMatch[3])
|
90
|
+
return { r, g, b }
|
82
91
|
}
|
83
92
|
|
84
|
-
const rgbaMatch = color.match(
|
93
|
+
const rgbaMatch = color.match(
|
94
|
+
/^\s*rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)\s*$/,
|
95
|
+
)
|
85
96
|
if (rgbaMatch) {
|
86
|
-
const
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
a: parseInt(a, 10),
|
92
|
-
}
|
97
|
+
const r = parseUi8Dec(rgbaMatch[1])
|
98
|
+
const g = parseUi8Dec(rgbaMatch[2])
|
99
|
+
const b = parseUi8Dec(rgbaMatch[3])
|
100
|
+
const a = parseUi8Dec(rgbaMatch[4])
|
101
|
+
return { r, g, b, a }
|
93
102
|
}
|
94
103
|
|
95
|
-
|
104
|
+
throw new TypeError(`Unsupported color format: ${color}`)
|
105
|
+
}
|
106
|
+
|
107
|
+
function parseUi8Hex(v: string) {
|
108
|
+
return asUi8(parseInt(v, 16))
|
109
|
+
}
|
110
|
+
|
111
|
+
function parseUi8Dec(v: string) {
|
112
|
+
return asUi8(parseInt(v, 10))
|
113
|
+
}
|
114
|
+
|
115
|
+
function asUi8(v: number) {
|
116
|
+
if (v >= 0 && v <= 255 && v === (v | 0)) return v
|
117
|
+
throw new TypeError(`Invalid color component: ${v}`)
|
96
118
|
}
|
@@ -0,0 +1,87 @@
|
|
1
|
+
import { ServerResponse } from 'node:http'
|
2
|
+
|
3
|
+
import { Asset } from '../assets/asset.js'
|
4
|
+
import { getAsset } from '../assets/index.js'
|
5
|
+
import { cssCode, Html, html } from '../lib/html/index.js'
|
6
|
+
import {
|
7
|
+
AuthorizationResultAuthorize,
|
8
|
+
buildAuthorizeData,
|
9
|
+
} from './build-authorize-data.js'
|
10
|
+
import { buildErrorPayload, buildErrorStatus } from './build-error-payload.js'
|
11
|
+
import {
|
12
|
+
buildCustomizationCss,
|
13
|
+
buildCustomizationData,
|
14
|
+
Customization,
|
15
|
+
} from './customization.js'
|
16
|
+
import { declareBackendData, sendWebPage } from './send-web-page.js'
|
17
|
+
|
18
|
+
export class OutputManager {
|
19
|
+
readonly customizationScript: Html
|
20
|
+
readonly customizationStyle: Html
|
21
|
+
readonly customizationLinks?: Customization['links']
|
22
|
+
|
23
|
+
// Could technically cause an "UnhandledPromiseRejection", which might cause
|
24
|
+
// the process to exit. This is intentional, as it's a critical error. It
|
25
|
+
// should never happen in practice, as the built assets are bundled with the
|
26
|
+
// package.
|
27
|
+
readonly assetsPromise: Promise<[js: Asset, css: Asset]> = Promise.all([
|
28
|
+
getAsset('main.js'),
|
29
|
+
getAsset('main.css'),
|
30
|
+
] as const)
|
31
|
+
|
32
|
+
constructor(customization?: Customization) {
|
33
|
+
// Note: building this here for two reasons:
|
34
|
+
// 1. To avoid re-building it on every request
|
35
|
+
// 2. To throw during init if the customization is invalid
|
36
|
+
this.customizationScript = declareBackendData(
|
37
|
+
'__customizationData',
|
38
|
+
buildCustomizationData(customization),
|
39
|
+
)
|
40
|
+
this.customizationStyle = cssCode(buildCustomizationCss(customization))
|
41
|
+
this.customizationLinks = customization?.links
|
42
|
+
}
|
43
|
+
|
44
|
+
async sendAuthorizePage(
|
45
|
+
res: ServerResponse,
|
46
|
+
data: AuthorizationResultAuthorize,
|
47
|
+
): Promise<void> {
|
48
|
+
const [jsAsset, cssAsset] = await this.assetsPromise
|
49
|
+
|
50
|
+
return sendWebPage(res, {
|
51
|
+
scripts: [
|
52
|
+
declareBackendData('__authorizeData', buildAuthorizeData(data)),
|
53
|
+
this.customizationScript,
|
54
|
+
jsAsset, // Last (to be able to read the "backend data" variables)
|
55
|
+
],
|
56
|
+
styles: [
|
57
|
+
cssAsset, // First (to be overridden by customization)
|
58
|
+
this.customizationStyle,
|
59
|
+
],
|
60
|
+
links: this.customizationLinks,
|
61
|
+
htmlAttrs: { lang: 'en' },
|
62
|
+
title: 'Authorize',
|
63
|
+
body: html`<div id="root"></div>`,
|
64
|
+
})
|
65
|
+
}
|
66
|
+
|
67
|
+
async sendErrorPage(res: ServerResponse, err: unknown): Promise<void> {
|
68
|
+
const [jsAsset, cssAsset] = await this.assetsPromise
|
69
|
+
|
70
|
+
return sendWebPage(res, {
|
71
|
+
status: buildErrorStatus(err),
|
72
|
+
scripts: [
|
73
|
+
declareBackendData('__errorData', buildErrorPayload(err)),
|
74
|
+
this.customizationScript,
|
75
|
+
jsAsset, // Last (to be able to read the "backend data" variables)
|
76
|
+
],
|
77
|
+
styles: [
|
78
|
+
cssAsset, // First (to be overridden by customization)
|
79
|
+
this.customizationStyle,
|
80
|
+
],
|
81
|
+
links: this.customizationLinks,
|
82
|
+
htmlAttrs: { lang: 'en' },
|
83
|
+
title: 'Error',
|
84
|
+
body: html`<div id="root"></div>`,
|
85
|
+
})
|
86
|
+
}
|
87
|
+
}
|
@@ -18,11 +18,12 @@ export function declareBackendData(name: string, data: unknown) {
|
|
18
18
|
return js`window[${name}]=${data};document.currentScript.remove();`
|
19
19
|
}
|
20
20
|
|
21
|
-
export function sendWebPage(
|
21
|
+
export async function sendWebPage(
|
22
22
|
res: ServerResponse,
|
23
23
|
{ status = 200, ...options }: BuildDocumentOptions & { status?: number },
|
24
|
-
): void {
|
24
|
+
): Promise<void> {
|
25
25
|
// @TODO: make these headers configurable (?)
|
26
|
+
res.setHeader('Permissions-Policy', 'otp-credentials=*, document-domain=()')
|
26
27
|
res.setHeader('Cross-Origin-Embedder-Policy', 'credentialless')
|
27
28
|
res.setHeader('Cross-Origin-Resource-Policy', 'same-origin')
|
28
29
|
res.setHeader('Cross-Origin-Opener-Policy', 'same-origin')
|
@@ -52,7 +53,7 @@ export function sendWebPage(
|
|
52
53
|
|
53
54
|
const html = buildDocument(options)
|
54
55
|
|
55
|
-
writeHtml(res, html.toString(), status)
|
56
|
+
return writeHtml(res, html.toString(), status)
|
56
57
|
}
|
57
58
|
|
58
59
|
function assetToHash(asset: Html | AssetRef): string {
|
package/tailwind.config.js
CHANGED
@@ -2,10 +2,23 @@
|
|
2
2
|
export default {
|
3
3
|
content: ['src/assets/app/**/*.{js,ts,jsx,tsx}'],
|
4
4
|
theme: {
|
5
|
+
fontFamily: {
|
6
|
+
sans: [
|
7
|
+
'-apple-system',
|
8
|
+
'BlinkMacSystemFont',
|
9
|
+
'"Segoe UI"',
|
10
|
+
'Roboto',
|
11
|
+
'Helvetica',
|
12
|
+
'Arial',
|
13
|
+
'sans-serif',
|
14
|
+
],
|
15
|
+
mono: ['Monaco', 'mono'],
|
16
|
+
},
|
5
17
|
extend: {
|
6
18
|
colors: {
|
7
|
-
|
19
|
+
brand: 'rgb(var(--color-brand) / <alpha-value>)',
|
8
20
|
error: 'rgb(var(--color-error) / <alpha-value>)',
|
21
|
+
warning: 'rgb(var(--color-warning) / <alpha-value>)',
|
9
22
|
},
|
10
23
|
},
|
11
24
|
},
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"send-authorize-page.d.ts","sourceRoot":"","sources":["../../src/output/send-authorize-page.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,oCAAoC,EACpC,mBAAmB,EACpB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAE1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAA;AAC/D,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AAE/C,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAE5C,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AACtD,OAAO,EACL,aAAa,EAGd,MAAM,oBAAoB,CAAA;AAG3B,MAAM,MAAM,4BAA4B,GAAG;IACzC,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,oCAAoC,CAAA;IAChD,SAAS,EAAE;QACT,GAAG,EAAE,UAAU,CAAA;QACf,QAAQ,EAAE,SAAS;YACjB,OAAO,EAAE,OAAO,CAAA;YAChB,IAAI,EAAE,iBAAiB,CAAA;YAEvB,QAAQ,EAAE,OAAO,CAAA;YACjB,aAAa,EAAE,OAAO,CAAA;YACtB,eAAe,EAAE,OAAO,CAAA;SACzB,EAAE,CAAA;KACJ,CAAA;CACF,CAAA;AAKD,KAAK,OAAO,GAAG;IACb,OAAO,EAAE,OAAO,CAAA;IAChB,IAAI,CAAC,EAAE,KAAK,CAAA;IAEZ,QAAQ,EAAE,OAAO,CAAA;IACjB,aAAa,EAAE,OAAO,CAAA;IACtB,eAAe,EAAE,OAAO,CAAA;CACzB,CAAA;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,EAAE,MAAM,CAAA;IAChB,cAAc,EAAE,mBAAmB,CAAA;IACnC,aAAa,EAAE,OAAO,CAAA;IACtB,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,yBAAyB,EAAE,OAAO,CAAA;IAClC,QAAQ,EAAE,OAAO,EAAE,CAAA;CACpB,CAAA;AAsBD,wBAAsB,iBAAiB,CACrC,GAAG,EAAE,cAAc,EACnB,IAAI,EAAE,4BAA4B,EAClC,aAAa,CAAC,EAAE,aAAa,GAC5B,OAAO,CAAC,IAAI,CAAC,CA2Bf"}
|
@@ -1,49 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.sendAuthorizePage = void 0;
|
4
|
-
const index_js_1 = require("../assets/index.js");
|
5
|
-
const index_js_2 = require("../lib/html/index.js");
|
6
|
-
const customization_js_1 = require("./customization.js");
|
7
|
-
const send_web_page_js_1 = require("./send-web-page.js");
|
8
|
-
function buildAuthorizeData(data) {
|
9
|
-
return {
|
10
|
-
clientId: data.client.id,
|
11
|
-
clientMetadata: data.client.metadata,
|
12
|
-
clientTrusted: data.client.info.isTrusted,
|
13
|
-
requestUri: data.authorize.uri,
|
14
|
-
csrfCookie: `csrf-${data.authorize.uri}`,
|
15
|
-
loginHint: data.parameters.login_hint,
|
16
|
-
newSessionsRequireConsent: data.parameters.prompt === 'consent',
|
17
|
-
sessions: data.authorize.sessions.map((session) => ({
|
18
|
-
account: session.account,
|
19
|
-
selected: session.selected,
|
20
|
-
loginRequired: session.loginRequired,
|
21
|
-
consentRequired: session.consentRequired,
|
22
|
-
})),
|
23
|
-
};
|
24
|
-
}
|
25
|
-
async function sendAuthorizePage(res, data, customization) {
|
26
|
-
res.setHeader('Cache-Control', 'no-store');
|
27
|
-
res.setHeader('Permissions-Policy', 'otp-credentials=*, document-domain=()');
|
28
|
-
const [jsAsset, cssAsset] = await Promise.all([
|
29
|
-
(0, index_js_1.getAsset)('main.js'),
|
30
|
-
(0, index_js_1.getAsset)('main.css'),
|
31
|
-
]);
|
32
|
-
return (0, send_web_page_js_1.sendWebPage)(res, {
|
33
|
-
scripts: [
|
34
|
-
(0, send_web_page_js_1.declareBackendData)('__customizationData', (0, customization_js_1.buildCustomizationData)(customization)),
|
35
|
-
(0, send_web_page_js_1.declareBackendData)('__authorizeData', buildAuthorizeData(data)),
|
36
|
-
jsAsset, // Last (to be able to read the global variables)
|
37
|
-
],
|
38
|
-
styles: [
|
39
|
-
cssAsset, // First (to be overridden by customization)
|
40
|
-
(0, index_js_2.cssCode)((0, customization_js_1.buildCustomizationCss)(customization)),
|
41
|
-
],
|
42
|
-
links: customization?.links,
|
43
|
-
htmlAttrs: { lang: 'en' },
|
44
|
-
title: 'Authorize',
|
45
|
-
body: (0, index_js_2.html) `<div id="root"></div>`,
|
46
|
-
});
|
47
|
-
}
|
48
|
-
exports.sendAuthorizePage = sendAuthorizePage;
|
49
|
-
//# sourceMappingURL=send-authorize-page.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"send-authorize-page.js","sourceRoot":"","sources":["../../src/output/send-authorize-page.ts"],"names":[],"mappings":";;;AAQA,iDAA6C;AAE7C,mDAAoD;AAEpD,yDAI2B;AAC3B,yDAAoE;AA0CpE,SAAS,kBAAkB,CAAC,IAAkC;IAC5D,OAAO;QACL,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE;QACxB,cAAc,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ;QACpC,aAAa,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS;QACzC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG;QAC9B,UAAU,EAAE,QAAQ,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE;QACxC,SAAS,EAAE,IAAI,CAAC,UAAU,CAAC,UAAU;QACrC,yBAAyB,EAAE,IAAI,CAAC,UAAU,CAAC,MAAM,KAAK,SAAS;QAC/D,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,CACnC,CAAC,OAAO,EAAW,EAAE,CAAC,CAAC;YACrB,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,aAAa,EAAE,OAAO,CAAC,aAAa;YACpC,eAAe,EAAE,OAAO,CAAC,eAAe;SACzC,CAAC,CACH;KACF,CAAA;AACH,CAAC;AAEM,KAAK,UAAU,iBAAiB,CACrC,GAAmB,EACnB,IAAkC,EAClC,aAA6B;IAE7B,GAAG,CAAC,SAAS,CAAC,eAAe,EAAE,UAAU,CAAC,CAAA;IAC1C,GAAG,CAAC,SAAS,CAAC,oBAAoB,EAAE,uCAAuC,CAAC,CAAA;IAE5E,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QAC5C,IAAA,mBAAQ,EAAC,SAAS,CAAC;QACnB,IAAA,mBAAQ,EAAC,UAAU,CAAC;KACrB,CAAC,CAAA;IAEF,OAAO,IAAA,8BAAW,EAAC,GAAG,EAAE;QACtB,OAAO,EAAE;YACP,IAAA,qCAAkB,EAChB,qBAAqB,EACrB,IAAA,yCAAsB,EAAC,aAAa,CAAC,CACtC;YACD,IAAA,qCAAkB,EAAC,iBAAiB,EAAE,kBAAkB,CAAC,IAAI,CAAC,CAAC;YAC/D,OAAO,EAAE,iDAAiD;SAC3D;QACD,MAAM,EAAE;YACN,QAAQ,EAAE,4CAA4C;YACtD,IAAA,kBAAO,EAAC,IAAA,wCAAqB,EAAC,aAAa,CAAC,CAAC;SAC9C;QACD,KAAK,EAAE,aAAa,EAAE,KAAK;QAC3B,SAAS,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE;QACzB,KAAK,EAAE,WAAW;QAClB,IAAI,EAAE,IAAA,eAAI,EAAA,uBAAuB;KAClC,CAAC,CAAA;AACJ,CAAC;AA/BD,8CA+BC"}
|
@@ -1,5 +0,0 @@
|
|
1
|
-
/// <reference types="node" />
|
2
|
-
import { ServerResponse } from 'node:http';
|
3
|
-
import { Customization } from './customization.js';
|
4
|
-
export declare function sendErrorPage(res: ServerResponse, err: unknown, customization?: Customization): Promise<void>;
|
5
|
-
//# sourceMappingURL=send-error-page.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"send-error-page.d.ts","sourceRoot":"","sources":["../../src/output/send-error-page.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAK1C,OAAO,EACL,aAAa,EAGd,MAAM,oBAAoB,CAAA;AAG3B,wBAAsB,aAAa,CACjC,GAAG,EAAE,cAAc,EACnB,GAAG,EAAE,OAAO,EACZ,aAAa,CAAC,EAAE,aAAa,GAC5B,OAAO,CAAC,IAAI,CAAC,CAwBf"}
|
@@ -1,31 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.sendErrorPage = void 0;
|
4
|
-
const index_js_1 = require("../assets/index.js");
|
5
|
-
const index_js_2 = require("../lib/html/index.js");
|
6
|
-
const build_error_payload_js_1 = require("./build-error-payload.js");
|
7
|
-
const customization_js_1 = require("./customization.js");
|
8
|
-
const send_web_page_js_1 = require("./send-web-page.js");
|
9
|
-
async function sendErrorPage(res, err, customization) {
|
10
|
-
const [jsAsset, cssAsset] = await Promise.all([
|
11
|
-
(0, index_js_1.getAsset)('main.js'),
|
12
|
-
(0, index_js_1.getAsset)('main.css'),
|
13
|
-
]);
|
14
|
-
return (0, send_web_page_js_1.sendWebPage)(res, {
|
15
|
-
status: (0, build_error_payload_js_1.buildErrorStatus)(err),
|
16
|
-
scripts: [
|
17
|
-
(0, send_web_page_js_1.declareBackendData)('__customizationData', (0, customization_js_1.buildCustomizationData)(customization)),
|
18
|
-
(0, send_web_page_js_1.declareBackendData)('__errorData', (0, build_error_payload_js_1.buildErrorPayload)(err)),
|
19
|
-
jsAsset, // Last (to be able to read the global variables)
|
20
|
-
],
|
21
|
-
styles: [
|
22
|
-
cssAsset, // First (to be overridden by customization)
|
23
|
-
(0, index_js_2.cssCode)((0, customization_js_1.buildCustomizationCss)(customization)),
|
24
|
-
],
|
25
|
-
htmlAttrs: { lang: 'en' },
|
26
|
-
title: 'Error',
|
27
|
-
body: (0, index_js_2.html) `<div id="root"></div>`,
|
28
|
-
});
|
29
|
-
}
|
30
|
-
exports.sendErrorPage = sendErrorPage;
|
31
|
-
//# sourceMappingURL=send-error-page.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"send-error-page.js","sourceRoot":"","sources":["../../src/output/send-error-page.ts"],"names":[],"mappings":";;;AAEA,iDAA6C;AAC7C,mDAAoD;AACpD,qEAA8E;AAC9E,yDAI2B;AAC3B,yDAAoE;AAE7D,KAAK,UAAU,aAAa,CACjC,GAAmB,EACnB,GAAY,EACZ,aAA6B;IAE7B,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QAC5C,IAAA,mBAAQ,EAAC,SAAS,CAAC;QACnB,IAAA,mBAAQ,EAAC,UAAU,CAAC;KACrB,CAAC,CAAA;IAEF,OAAO,IAAA,8BAAW,EAAC,GAAG,EAAE;QACtB,MAAM,EAAE,IAAA,yCAAgB,EAAC,GAAG,CAAC;QAC7B,OAAO,EAAE;YACP,IAAA,qCAAkB,EAChB,qBAAqB,EACrB,IAAA,yCAAsB,EAAC,aAAa,CAAC,CACtC;YACD,IAAA,qCAAkB,EAAC,aAAa,EAAE,IAAA,0CAAiB,EAAC,GAAG,CAAC,CAAC;YACzD,OAAO,EAAE,iDAAiD;SAC3D;QACD,MAAM,EAAE;YACN,QAAQ,EAAE,4CAA4C;YACtD,IAAA,kBAAO,EAAC,IAAA,wCAAqB,EAAC,aAAa,CAAC,CAAC;SAC9C;QACD,SAAS,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE;QACzB,KAAK,EAAE,OAAO;QACd,IAAI,EAAE,IAAA,eAAI,EAAA,uBAAuB;KAClC,CAAC,CAAA;AACJ,CAAC;AA5BD,sCA4BC"}
|
@@ -1,41 +0,0 @@
|
|
1
|
-
import { ServerResponse } from 'node:http'
|
2
|
-
|
3
|
-
import { getAsset } from '../assets/index.js'
|
4
|
-
import { cssCode, html } from '../lib/html/index.js'
|
5
|
-
import { buildErrorPayload, buildErrorStatus } from './build-error-payload.js'
|
6
|
-
import {
|
7
|
-
Customization,
|
8
|
-
buildCustomizationCss,
|
9
|
-
buildCustomizationData,
|
10
|
-
} from './customization.js'
|
11
|
-
import { declareBackendData, sendWebPage } from './send-web-page.js'
|
12
|
-
|
13
|
-
export async function sendErrorPage(
|
14
|
-
res: ServerResponse,
|
15
|
-
err: unknown,
|
16
|
-
customization?: Customization,
|
17
|
-
): Promise<void> {
|
18
|
-
const [jsAsset, cssAsset] = await Promise.all([
|
19
|
-
getAsset('main.js'),
|
20
|
-
getAsset('main.css'),
|
21
|
-
])
|
22
|
-
|
23
|
-
return sendWebPage(res, {
|
24
|
-
status: buildErrorStatus(err),
|
25
|
-
scripts: [
|
26
|
-
declareBackendData(
|
27
|
-
'__customizationData',
|
28
|
-
buildCustomizationData(customization),
|
29
|
-
),
|
30
|
-
declareBackendData('__errorData', buildErrorPayload(err)),
|
31
|
-
jsAsset, // Last (to be able to read the global variables)
|
32
|
-
],
|
33
|
-
styles: [
|
34
|
-
cssAsset, // First (to be overridden by customization)
|
35
|
-
cssCode(buildCustomizationCss(customization)),
|
36
|
-
],
|
37
|
-
htmlAttrs: { lang: 'en' },
|
38
|
-
title: 'Error',
|
39
|
-
body: html`<div id="root"></div>`,
|
40
|
-
})
|
41
|
-
}
|