@owlmeans/web-oauth 0.1.18-rc.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.
Files changed (109) hide show
  1. package/README.md +15 -0
  2. package/agent-meta/manifest.json +16 -0
  3. package/agent-meta/skills/web-oauth/SKILL.md +131 -0
  4. package/build/@/components/ui/button.d.ts +11 -0
  5. package/build/@/components/ui/button.d.ts.map +1 -0
  6. package/build/@/components/ui/button.js +32 -0
  7. package/build/@/components/ui/button.js.map +1 -0
  8. package/build/@/components/ui/card.d.ts +10 -0
  9. package/build/@/components/ui/card.d.ts.map +1 -0
  10. package/build/@/components/ui/card.js +25 -0
  11. package/build/@/components/ui/card.js.map +1 -0
  12. package/build/@/components/ui/input.d.ts +4 -0
  13. package/build/@/components/ui/input.d.ts.map +1 -0
  14. package/build/@/components/ui/input.js +7 -0
  15. package/build/@/components/ui/input.js.map +1 -0
  16. package/build/@/components/ui/label.d.ts +5 -0
  17. package/build/@/components/ui/label.d.ts.map +1 -0
  18. package/build/@/components/ui/label.js +8 -0
  19. package/build/@/components/ui/label.js.map +1 -0
  20. package/build/@/lib/utils.d.ts +3 -0
  21. package/build/@/lib/utils.d.ts.map +1 -0
  22. package/build/@/lib/utils.js +6 -0
  23. package/build/@/lib/utils.js.map +1 -0
  24. package/build/append.d.ts +14 -0
  25. package/build/append.d.ts.map +1 -0
  26. package/build/append.js +19 -0
  27. package/build/append.js.map +1 -0
  28. package/build/components/consent-screen.d.ts +12 -0
  29. package/build/components/consent-screen.d.ts.map +1 -0
  30. package/build/components/consent-screen.js +30 -0
  31. package/build/components/consent-screen.js.map +1 -0
  32. package/build/components/device-screen.d.ts +10 -0
  33. package/build/components/device-screen.d.ts.map +1 -0
  34. package/build/components/device-screen.js +48 -0
  35. package/build/components/device-screen.js.map +1 -0
  36. package/build/components/done-screen.d.ts +8 -0
  37. package/build/components/done-screen.d.ts.map +1 -0
  38. package/build/components/done-screen.js +18 -0
  39. package/build/components/done-screen.js.map +1 -0
  40. package/build/components/index.d.ts +4 -0
  41. package/build/components/index.d.ts.map +1 -0
  42. package/build/components/index.js +4 -0
  43. package/build/components/index.js.map +1 -0
  44. package/build/consts.d.ts +6 -0
  45. package/build/consts.d.ts.map +1 -0
  46. package/build/consts.js +6 -0
  47. package/build/consts.js.map +1 -0
  48. package/build/entrypoints.d.ts +8 -0
  49. package/build/entrypoints.d.ts.map +1 -0
  50. package/build/entrypoints.js +20 -0
  51. package/build/entrypoints.js.map +1 -0
  52. package/build/hooks/use-oauth-consent.d.ts +27 -0
  53. package/build/hooks/use-oauth-consent.d.ts.map +1 -0
  54. package/build/hooks/use-oauth-consent.js +128 -0
  55. package/build/hooks/use-oauth-consent.js.map +1 -0
  56. package/build/i18n/be.json +35 -0
  57. package/build/i18n/de.json +35 -0
  58. package/build/i18n/en.json +35 -0
  59. package/build/i18n/es.json +35 -0
  60. package/build/i18n/pl.json +35 -0
  61. package/build/i18n/ru.json +35 -0
  62. package/build/i18n/uk.json +35 -0
  63. package/build/i18n.d.ts +2 -0
  64. package/build/i18n.d.ts.map +1 -0
  65. package/build/i18n.js +17 -0
  66. package/build/i18n.js.map +1 -0
  67. package/build/index.d.ts +7 -0
  68. package/build/index.d.ts.map +1 -0
  69. package/build/index.js +7 -0
  70. package/build/index.js.map +1 -0
  71. package/components.json +21 -0
  72. package/package.json +77 -0
  73. package/src/@/components/ui/button.tsx +60 -0
  74. package/src/@/components/ui/card.tsx +93 -0
  75. package/src/@/components/ui/input.tsx +22 -0
  76. package/src/@/components/ui/label.tsx +23 -0
  77. package/src/@/globals.css +57 -0
  78. package/src/@/lib/utils.ts +6 -0
  79. package/src/append.ts +24 -0
  80. package/src/components/consent-screen.tsx +95 -0
  81. package/src/components/device-screen.tsx +81 -0
  82. package/src/components/done-screen.tsx +30 -0
  83. package/src/components/index.ts +3 -0
  84. package/src/consts.ts +6 -0
  85. package/src/entrypoints.ts +22 -0
  86. package/src/hooks/use-oauth-consent.ts +163 -0
  87. package/src/i18n/be.json +35 -0
  88. package/src/i18n/de.json +35 -0
  89. package/src/i18n/en.json +35 -0
  90. package/src/i18n/es.json +35 -0
  91. package/src/i18n/pl.json +35 -0
  92. package/src/i18n/ru.json +35 -0
  93. package/src/i18n/uk.json +35 -0
  94. package/src/i18n.ts +18 -0
  95. package/src/index.ts +6 -0
  96. package/tests/consent.spec.ts +260 -0
  97. package/tests/context.ts +48 -0
  98. package/tests/device.spec.ts +64 -0
  99. package/tests/done.spec.ts +41 -0
  100. package/tests/harness/css.d.ts +1 -0
  101. package/tests/harness/frame.html +15 -0
  102. package/tests/harness/index.html +11 -0
  103. package/tests/harness/mount.tsx +89 -0
  104. package/tests/helpers.ts +97 -0
  105. package/tests/i18n.spec.ts +41 -0
  106. package/tests/languages.spec.ts +38 -0
  107. package/tests/package-boundary.spec.ts +19 -0
  108. package/tests/tsconfig.json +12 -0
  109. package/tsconfig.json +14 -0
@@ -0,0 +1,41 @@
1
+ import { describe, expect, test } from 'bun:test'
2
+ import en from '../src/i18n/en.json' with { type: 'json' }
3
+ import pl from '../src/i18n/pl.json' with { type: 'json' }
4
+ import ru from '../src/i18n/ru.json' with { type: 'json' }
5
+ import be from '../src/i18n/be.json' with { type: 'json' }
6
+ import uk from '../src/i18n/uk.json' with { type: 'json' }
7
+ import es from '../src/i18n/es.json' with { type: 'json' }
8
+ import de from '../src/i18n/de.json' with { type: 'json' }
9
+
10
+ const LANGUAGES: Record<string, unknown> = { pl, ru, be, uk, es, de }
11
+
12
+ /** Every leaf key path in a nested translation object, e.g. `consent.title`. */
13
+ const leafKeys = (value: unknown, prefix = ''): string[] => {
14
+ if (typeof value !== 'object' || value == null) return [prefix]
15
+
16
+ return Object.entries(value as Record<string, unknown>)
17
+ .flatMap(([key, child]) => leafKeys(child, prefix === '' ? key : `${prefix}.${key}`))
18
+ }
19
+
20
+ describe('@owlmeans/web-oauth — translations', () => {
21
+ const englishKeys = leafKeys(en).sort()
22
+
23
+ test('English covers the three screens', () => {
24
+ expect(englishKeys).toContain('consent.approve')
25
+ expect(englishKeys).toContain('device.continue')
26
+ expect(englishKeys).toContain('done.message')
27
+ })
28
+
29
+ for (const [lang, resource] of Object.entries(LANGUAGES)) {
30
+ test(`${lang} has exactly the same keys as English`, () => {
31
+ expect(leafKeys(resource).sort()).toEqual(englishKeys)
32
+ })
33
+
34
+ test(`${lang} has no empty translation`, () => {
35
+ for (const key of leafKeys(resource)) {
36
+ const value = key.split('.').reduce((node: any, part) => node[part], resource)
37
+ expect(typeof value === 'string' && value.trim() !== '').toBe(true)
38
+ }
39
+ })
40
+ }
41
+ })
@@ -0,0 +1,38 @@
1
+ import { afterAll, describe, expect, test } from 'bun:test'
2
+ import { closeBrowser } from '@owlmeans/test-ui'
3
+ import { OAUTH_CONSENT_PATH } from '@owlmeans/oauth'
4
+ import en from '../src/i18n/en.json' with { type: 'json' }
5
+ import pl from '../src/i18n/pl.json' with { type: 'json' }
6
+ import ru from '../src/i18n/ru.json' with { type: 'json' }
7
+ import be from '../src/i18n/be.json' with { type: 'json' }
8
+ import uk from '../src/i18n/uk.json' with { type: 'json' }
9
+ import es from '../src/i18n/es.json' with { type: 'json' }
10
+ import de from '../src/i18n/de.json' with { type: 'json' }
11
+ import { deviceView, open, TIMEOUT } from './helpers.js'
12
+
13
+ afterAll(async () => { await closeBrowser() })
14
+
15
+ const LANGUAGES = { en, pl, ru, be, uk, es, de }
16
+
17
+ describe('consent screen — all seven languages render', () => {
18
+ for (const [lng, strings] of Object.entries(LANGUAGES)) {
19
+ test(`${lng}: the buttons and the switch link carry the translation, never a key path`, async () => {
20
+ const { page, close } = await open(`${OAUTH_CONSENT_PATH}?ref=ABCD-EFGH`, {
21
+ signedIn: true, lng, stubs: { load: { json: deviceView() } },
22
+ })
23
+ try {
24
+ await page.getByTestId('oauth-consent-approve').waitFor({ state: 'visible', timeout: 45_000 })
25
+
26
+ expect(await page.getByTestId('oauth-consent-approve').textContent()).toBe(strings.consent.approve)
27
+ expect(await page.getByTestId('oauth-consent-deny').textContent()).toBe(strings.consent.deny)
28
+ expect(await page.getByTestId('oauth-consent-switch').textContent()).toBe(strings.consent['switch-account'])
29
+ expect(await page.getByTestId('oauth-consent-code').textContent())
30
+ .toBe(strings.consent['device-code'].replace('{{code}}', 'ABCD-EFGH'))
31
+ // A missing key would print its own path.
32
+ expect(await page.getByTestId('oauth-consent-card').textContent()).not.toMatch(/consent\.[a-z-]+/)
33
+ } finally {
34
+ await close()
35
+ }
36
+ }, TIMEOUT)
37
+ }
38
+ })
@@ -0,0 +1,19 @@
1
+ import { describe, expect, test } from 'bun:test'
2
+ import { readdirSync, readFileSync } from 'node:fs'
3
+ import { join } from 'node:path'
4
+
5
+ const source = join(import.meta.dir, '../src')
6
+
7
+ const sourceFiles = (dir: string): string[] => readdirSync(dir, { withFileTypes: true }).flatMap(entry => {
8
+ const path = join(dir, entry.name)
9
+
10
+ return entry.isDirectory() ? sourceFiles(path) : [path]
11
+ })
12
+
13
+ describe('@owlmeans/web-oauth — package boundary', () => {
14
+ test('does not use consumer-project UI aliases in package source', () => {
15
+ for (const file of sourceFiles(source).filter(file => /\.tsx?$/.test(file))) {
16
+ expect(readFileSync(file, 'utf8')).not.toMatch(/from\s+['"]@\//)
17
+ }
18
+ })
19
+ })
@@ -0,0 +1,12 @@
1
+ {
2
+ "extends": [
3
+ "@owlmeans/dep-config/tsconfig.base.json",
4
+ "@owlmeans/dep-config/tsconfig.react.json"
5
+ ],
6
+ "compilerOptions": {
7
+ "types": ["bun"],
8
+ "rootDir": "../",
9
+ "noEmit": true
10
+ },
11
+ "include": ["./**/*", "../src/**/*"]
12
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "extends": [
3
+ "@owlmeans/dep-config/tsconfig.base.json",
4
+ "@owlmeans/dep-config/tsconfig.react.json"
5
+ ],
6
+ "compilerOptions": {
7
+ "paths": {
8
+ "@/*": ["./src/@/*"]
9
+ },
10
+ "rootDir": "./src/",
11
+ "outDir": "./build/"
12
+ },
13
+ "exclude": ["./dist/**/*", "./build/**/*", "./tests/**/*", "./*.ts"]
14
+ }