@owlmeans/web-client 0.1.18-rc.8 → 0.1.18
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/README.md +247 -43
- package/agent-meta/manifest.json +3 -3
- package/agent-meta/skills/web-client/SKILL.md +67 -56
- package/build/components/dispatcher/component.d.ts.map +1 -1
- package/build/components/dispatcher/component.js +55 -9
- package/build/components/dispatcher/component.js.map +1 -1
- package/build/components/dispatcher/parametrise.d.ts.map +1 -1
- package/build/components/dispatcher/parametrise.js +0 -3
- package/build/components/dispatcher/parametrise.js.map +1 -1
- package/build/components/dispatcher/types.d.ts +2 -2
- package/build/components/dispatcher/types.d.ts.map +1 -1
- package/build/context.d.ts.map +1 -1
- package/build/context.js +0 -1
- package/build/context.js.map +1 -1
- package/build/entrypoints.d.ts +16 -0
- package/build/entrypoints.d.ts.map +1 -0
- package/build/entrypoints.js +20 -0
- package/build/entrypoints.js.map +1 -0
- package/build/errors.d.ts.map +1 -1
- package/build/errors.js.map +1 -1
- package/build/exports.d.ts +3 -2
- package/build/exports.d.ts.map +1 -1
- package/build/exports.js +2 -2
- package/build/exports.js.map +1 -1
- package/build/helper.d.ts.map +1 -1
- package/build/i18n/auth-be.json +32 -0
- package/build/i18n/auth-de.json +32 -0
- package/build/i18n/auth-en.json +32 -0
- package/build/i18n/auth-es.json +32 -0
- package/build/i18n/auth-fr.json +38 -0
- package/build/i18n/auth-pl.json +32 -0
- package/build/i18n/auth-ru.json +32 -0
- package/build/i18n/auth-uk.json +32 -0
- package/build/i18n.js +10 -8
- package/build/i18n.js.map +1 -1
- package/build/index.d.ts +1 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1 -1
- package/build/index.js.map +1 -1
- package/build/login/consts.d.ts +36 -0
- package/build/login/consts.d.ts.map +1 -1
- package/build/login/consts.js +38 -0
- package/build/login/consts.js.map +1 -1
- package/build/login/consts.local.d.ts +22 -0
- package/build/login/consts.local.d.ts.map +1 -0
- package/build/login/consts.local.js +48 -0
- package/build/login/consts.local.js.map +1 -0
- package/build/login/index.d.ts +4 -0
- package/build/login/index.d.ts.map +1 -1
- package/build/login/index.js +3 -0
- package/build/login/index.js.map +1 -1
- package/build/login/pump.d.ts +20 -0
- package/build/login/pump.d.ts.map +1 -0
- package/build/login/pump.js +46 -0
- package/build/login/pump.js.map +1 -0
- package/build/login/redirect.d.ts.map +1 -1
- package/build/login/redirect.js +17 -1
- package/build/login/redirect.js.map +1 -1
- package/build/login/screen.d.ts +19 -0
- package/build/login/screen.d.ts.map +1 -0
- package/build/login/screen.js +119 -0
- package/build/login/screen.js.map +1 -0
- package/build/login/service.d.ts.map +1 -1
- package/build/login/surrogate.d.ts +16 -0
- package/build/login/surrogate.d.ts.map +1 -1
- package/build/login/surrogate.js +139 -71
- package/build/login/surrogate.js.map +1 -1
- package/build/login/types.d.ts +10 -0
- package/build/login/types.d.ts.map +1 -0
- package/build/login/types.js +2 -0
- package/build/login/types.js.map +1 -0
- package/build/login/view.d.ts +4 -0
- package/build/login/view.d.ts.map +1 -0
- package/build/login/view.js +12 -0
- package/build/login/view.js.map +1 -0
- package/build/main.d.ts +9 -1
- package/build/main.d.ts.map +1 -1
- package/build/main.js +18 -5
- package/build/main.js.map +1 -1
- package/build/middleware.d.ts +1 -1
- package/build/middleware.d.ts.map +1 -1
- package/build/middleware.js +7 -6
- package/build/middleware.js.map +1 -1
- package/build/service.d.ts.map +1 -1
- package/build/service.js +1 -1
- package/build/service.js.map +1 -1
- package/build/types.local.d.ts +5 -0
- package/build/types.local.d.ts.map +1 -0
- package/build/types.local.js +2 -0
- package/build/types.local.js.map +1 -0
- package/package.json +22 -21
- package/src/components/dispatcher/component.tsx +71 -8
- package/src/components/dispatcher/parametrise.tsx +0 -3
- package/src/components/dispatcher/types.ts +2 -2
- package/src/context.ts +0 -2
- package/src/entrypoints.ts +20 -0
- package/src/exports.ts +7 -2
- package/src/i18n/auth-be.json +32 -0
- package/src/i18n/auth-de.json +32 -0
- package/src/i18n/auth-en.json +32 -0
- package/src/i18n/auth-es.json +32 -0
- package/src/i18n/auth-fr.json +38 -0
- package/src/i18n/auth-pl.json +32 -0
- package/src/i18n/auth-ru.json +32 -0
- package/src/i18n/auth-uk.json +32 -0
- package/src/i18n.ts +10 -8
- package/src/index.ts +1 -1
- package/src/login/consts.local.ts +52 -0
- package/src/login/consts.ts +38 -0
- package/src/login/index.ts +4 -0
- package/src/login/pump.ts +53 -0
- package/src/login/redirect.ts +23 -2
- package/src/login/screen.tsx +141 -0
- package/src/login/surrogate.ts +170 -86
- package/src/login/types.ts +10 -0
- package/src/login/view.tsx +22 -0
- package/src/main.tsx +19 -6
- package/src/middleware.ts +9 -12
- package/src/service.ts +1 -1
- package/src/types.local.ts +5 -0
- package/tests/surrogate.spec.ts +74 -0
- package/tsconfig.json +1 -1
- package/src/modules.ts +0 -9
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { describe, test, expect, afterEach } from 'bun:test'
|
|
2
|
+
import { centeredPopupFeatures } from '../src/login/surrogate.js'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A hand-written `window`, not jsdom: the function under test reads exactly four geometry
|
|
6
|
+
* properties, and a real DOM would prove a fixture behaves rather than that the math does.
|
|
7
|
+
*/
|
|
8
|
+
const stubWindow = (over: Record<string, unknown>): void => {
|
|
9
|
+
(globalThis as unknown as { window: unknown }).window = {
|
|
10
|
+
screenLeft: 0, screenTop: 0, screenX: 0, screenY: 0,
|
|
11
|
+
outerWidth: 1920, outerHeight: 1080,
|
|
12
|
+
screen: { width: 1920, height: 1080 },
|
|
13
|
+
...over,
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
afterEach(() => {
|
|
18
|
+
delete (globalThis as { window?: unknown }).window
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
describe('centeredPopupFeatures', () => {
|
|
22
|
+
test('centers on the browser window, at its current screen position', () => {
|
|
23
|
+
stubWindow({ screenLeft: 100, screenTop: 50, outerWidth: 1200, outerHeight: 800 })
|
|
24
|
+
|
|
25
|
+
expect(centeredPopupFeatures(520, 760)).toBe('popup=yes,width=520,height=760,left=440,top=70')
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
// A cross-origin iframe: `window.top.innerWidth` would throw, which is exactly why this reads
|
|
29
|
+
// `outerWidth`/`outerHeight` instead — they describe the browser's own chrome, not this
|
|
30
|
+
// document's viewport, and stay readable across the origin boundary.
|
|
31
|
+
test('falls back to screenX/screenY when the legacy aliases are unavailable', () => {
|
|
32
|
+
stubWindow({
|
|
33
|
+
screenLeft: undefined, screenTop: undefined, screenX: 20, screenY: 10,
|
|
34
|
+
outerWidth: 1200, outerHeight: 800,
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
expect(centeredPopupFeatures(520, 760)).toBe('popup=yes,width=520,height=760,left=360,top=30')
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
test('falls back to window.screen when outerWidth/outerHeight report zero', () => {
|
|
41
|
+
// A headless runner: no chrome geometry to report at all.
|
|
42
|
+
stubWindow({ outerWidth: 0, outerHeight: 0, screen: { width: 1600, height: 900 } })
|
|
43
|
+
|
|
44
|
+
expect(centeredPopupFeatures(520, 760)).toBe('popup=yes,width=520,height=760,left=540,top=70')
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
test('never places the popup off-screen when it is larger than the window', () => {
|
|
48
|
+
stubWindow({ outerWidth: 400, outerHeight: 400 })
|
|
49
|
+
|
|
50
|
+
expect(centeredPopupFeatures(520, 760)).toBe('popup=yes,width=520,height=760,left=0,top=0')
|
|
51
|
+
})
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
describe('surrogateLoginStep', () => {
|
|
55
|
+
test('a stored session is forgotten when there is a dispatcher to authenticate through', async () => {
|
|
56
|
+
const { surrogateLoginStep } = await import('../src/login/screen.js')
|
|
57
|
+
const { SurrogateLoginStep } = await import('../src/login/consts.js')
|
|
58
|
+
expect(surrogateLoginStep('OIDC-WRAPPED-TOKEN abc', '/dispatcher?x=1')).toBe(SurrogateLoginStep.Forget)
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
test('a stored session is handed back only when there is no dispatcher address', async () => {
|
|
62
|
+
const { surrogateLoginStep } = await import('../src/login/screen.js')
|
|
63
|
+
const { SurrogateLoginStep } = await import('../src/login/consts.js')
|
|
64
|
+
expect(surrogateLoginStep('OIDC-WRAPPED-TOKEN abc', null)).toBe(SurrogateLoginStep.Resume)
|
|
65
|
+
expect(surrogateLoginStep('OIDC-WRAPPED-TOKEN abc', '')).toBe(SurrogateLoginStep.Resume)
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
test('nothing stored authenticates, with or without a dispatcher address', async () => {
|
|
69
|
+
const { surrogateLoginStep } = await import('../src/login/screen.js')
|
|
70
|
+
const { SurrogateLoginStep } = await import('../src/login/consts.js')
|
|
71
|
+
expect(surrogateLoginStep(null, '/dispatcher')).toBe(SurrogateLoginStep.Authenticate)
|
|
72
|
+
expect(surrogateLoginStep('', null)).toBe(SurrogateLoginStep.Authenticate)
|
|
73
|
+
})
|
|
74
|
+
})
|
package/tsconfig.json
CHANGED
package/src/modules.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { DISPATCHER } from '@owlmeans/auth'
|
|
2
|
-
import { modules as list } from '@owlmeans/client-auth'
|
|
3
|
-
import { elevate } from '@owlmeans/client-entrypoint'
|
|
4
|
-
import { handler } from '@owlmeans/client'
|
|
5
|
-
import { Dispatcher } from './components/dispatcher/component.js'
|
|
6
|
-
|
|
7
|
-
elevate(list, DISPATCHER, handler(Dispatcher), { force: true })
|
|
8
|
-
|
|
9
|
-
export const modules = list
|