@oxyhq/core 12.1.1 → 12.2.0

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 (66) hide show
  1. package/dist/cjs/.tsbuildinfo +1 -1
  2. package/dist/cjs/i18n/locales/ar-SA.json +2 -1
  3. package/dist/cjs/i18n/locales/ca-ES.json +2 -1
  4. package/dist/cjs/i18n/locales/de-DE.json +2 -1
  5. package/dist/cjs/i18n/locales/en-US.json +2 -1
  6. package/dist/cjs/i18n/locales/es-ES.json +2 -1
  7. package/dist/cjs/i18n/locales/fr-FR.json +2 -1
  8. package/dist/cjs/i18n/locales/it-IT.json +2 -1
  9. package/dist/cjs/i18n/locales/ja-JP.json +2 -1
  10. package/dist/cjs/i18n/locales/ko-KR.json +2 -1
  11. package/dist/cjs/i18n/locales/locales/ar-SA.json +2 -1
  12. package/dist/cjs/i18n/locales/locales/ca-ES.json +2 -1
  13. package/dist/cjs/i18n/locales/locales/de-DE.json +2 -1
  14. package/dist/cjs/i18n/locales/locales/en-US.json +2 -1
  15. package/dist/cjs/i18n/locales/locales/es-ES.json +2 -1
  16. package/dist/cjs/i18n/locales/locales/fr-FR.json +2 -1
  17. package/dist/cjs/i18n/locales/locales/it-IT.json +2 -1
  18. package/dist/cjs/i18n/locales/locales/ja-JP.json +2 -1
  19. package/dist/cjs/i18n/locales/locales/ko-KR.json +2 -1
  20. package/dist/cjs/i18n/locales/locales/pt-PT.json +2 -1
  21. package/dist/cjs/i18n/locales/locales/zh-CN.json +2 -1
  22. package/dist/cjs/i18n/locales/pt-PT.json +2 -1
  23. package/dist/cjs/i18n/locales/zh-CN.json +2 -1
  24. package/dist/cjs/session/accountDialogController.js +112 -2
  25. package/dist/esm/.tsbuildinfo +1 -1
  26. package/dist/esm/i18n/locales/ar-SA.json +2 -1
  27. package/dist/esm/i18n/locales/ca-ES.json +2 -1
  28. package/dist/esm/i18n/locales/de-DE.json +2 -1
  29. package/dist/esm/i18n/locales/en-US.json +2 -1
  30. package/dist/esm/i18n/locales/es-ES.json +2 -1
  31. package/dist/esm/i18n/locales/fr-FR.json +2 -1
  32. package/dist/esm/i18n/locales/it-IT.json +2 -1
  33. package/dist/esm/i18n/locales/ja-JP.json +2 -1
  34. package/dist/esm/i18n/locales/ko-KR.json +2 -1
  35. package/dist/esm/i18n/locales/locales/ar-SA.json +2 -1
  36. package/dist/esm/i18n/locales/locales/ca-ES.json +2 -1
  37. package/dist/esm/i18n/locales/locales/de-DE.json +2 -1
  38. package/dist/esm/i18n/locales/locales/en-US.json +2 -1
  39. package/dist/esm/i18n/locales/locales/es-ES.json +2 -1
  40. package/dist/esm/i18n/locales/locales/fr-FR.json +2 -1
  41. package/dist/esm/i18n/locales/locales/it-IT.json +2 -1
  42. package/dist/esm/i18n/locales/locales/ja-JP.json +2 -1
  43. package/dist/esm/i18n/locales/locales/ko-KR.json +2 -1
  44. package/dist/esm/i18n/locales/locales/pt-PT.json +2 -1
  45. package/dist/esm/i18n/locales/locales/zh-CN.json +2 -1
  46. package/dist/esm/i18n/locales/pt-PT.json +2 -1
  47. package/dist/esm/i18n/locales/zh-CN.json +2 -1
  48. package/dist/esm/session/accountDialogController.js +112 -2
  49. package/dist/types/.tsbuildinfo +1 -1
  50. package/dist/types/index.d.ts +1 -1
  51. package/dist/types/session/accountDialogController.d.ts +81 -1
  52. package/package.json +4 -4
  53. package/src/i18n/locales/ar-SA.json +2 -1
  54. package/src/i18n/locales/ca-ES.json +2 -1
  55. package/src/i18n/locales/de-DE.json +2 -1
  56. package/src/i18n/locales/en-US.json +2 -1
  57. package/src/i18n/locales/es-ES.json +2 -1
  58. package/src/i18n/locales/fr-FR.json +2 -1
  59. package/src/i18n/locales/it-IT.json +2 -1
  60. package/src/i18n/locales/ja-JP.json +2 -1
  61. package/src/i18n/locales/ko-KR.json +2 -1
  62. package/src/i18n/locales/pt-PT.json +2 -1
  63. package/src/i18n/locales/zh-CN.json +2 -1
  64. package/src/index.ts +1 -0
  65. package/src/session/__tests__/accountDialogController.test.ts +133 -1
  66. package/src/session/accountDialogController.ts +145 -2
@@ -61,7 +61,8 @@
61
61
  "usernameAvailable": "متاح",
62
62
  "usernameTaken": "اسم المستخدم هذا مستخدم بالفعل",
63
63
  "backToSignInLink": "لديك حساب بالفعل؟ سجّل الدخول",
64
- "notAvailableHere": "‏إنشاء الحساب غير متاح في هذا التطبيق بعد أنشئ هويتك باستخدام Commons، أو تفضّل بزيارة oxy.so للتسجيل باستخدام مفتاح مرور.",
64
+ "hubExplainer": "أنشئ هوية Oxy الخاصة بك في نافذة آمنة، ثم عد إلى هنا مباشرة.",
65
+ "continueInWindow": "المتابعة في نافذة جديدة",
65
66
  "welcome": {
66
67
  "title": "مرحبًا بك في Oxy!",
67
68
  "subtitle": "أنشئ حسابك في خطوات قليلة",
@@ -61,7 +61,8 @@
61
61
  "usernameAvailable": "Disponible",
62
62
  "usernameTaken": "Aquest nom d'usuari ja està en ús",
63
63
  "backToSignInLink": "Ja tens compte? Inicia sessió",
64
- "notAvailableHere": "La creació de comptes encara no està disponible en aquesta app: crea la teva identitat amb Commons o visita oxy.so per registrar-te amb una clau d'accés.",
64
+ "hubExplainer": "Crea la teva Oxy ID en una finestra segura i torna de seguida.",
65
+ "continueInWindow": "Continua en una finestra nova",
65
66
  "welcome": {
66
67
  "title": "Benvingut a Oxy!",
67
68
  "subtitle": "Crea el teu compte en pocs passos",
@@ -61,7 +61,8 @@
61
61
  "usernameAvailable": "Verfügbar",
62
62
  "usernameTaken": "Dieser Benutzername ist bereits vergeben",
63
63
  "backToSignInLink": "Sie haben bereits ein Konto? Anmelden",
64
- "notAvailableHere": "Die Kontoerstellung ist in dieser App noch nicht verfügbar – erstellen Sie Ihre Identität mit Commons oder besuchen Sie oxy.so, um sich mit einem Passkey zu registrieren.",
64
+ "hubExplainer": "Erstellen Sie Ihre Oxy-ID in einem sicheren Fenster und kehren Sie dann direkt zurück.",
65
+ "continueInWindow": "In einem neuen Fenster fortfahren",
65
66
  "welcome": {
66
67
  "title": "Willkommen bei Oxy!",
67
68
  "subtitle": "Erstellen Sie Ihr Konto in nur wenigen Schritten",
@@ -68,7 +68,8 @@
68
68
  "usernameAvailable": "Available",
69
69
  "usernameTaken": "This username is taken",
70
70
  "backToSignInLink": "Already have an account? Sign in",
71
- "notAvailableHere": "Account creation isn't available in this app yet — create your identity with Commons, or visit oxy.so to sign up with a passkey.",
71
+ "hubExplainer": "Create your Oxy ID in a secure window, then come right back.",
72
+ "continueInWindow": "Continue in a new window",
72
73
  "welcome": {
73
74
  "title": "Welcome to Oxy!",
74
75
  "subtitle": "Let's create your account in just a few steps",
@@ -68,7 +68,8 @@
68
68
  "usernameAvailable": "Disponible",
69
69
  "usernameTaken": "Este usuario ya está en uso",
70
70
  "backToSignInLink": "¿Ya tienes cuenta? Inicia sesión",
71
- "notAvailableHere": "La creación de cuentas aún no está disponible en esta app: crea tu identidad con Commons o visita oxy.so para registrarte con una clave de acceso.",
71
+ "hubExplainer": "Crea tu Oxy ID en una ventana segura y vuelve enseguida.",
72
+ "continueInWindow": "Continuar en una ventana nueva",
72
73
  "welcome": {
73
74
  "title": "¡Te damos la bienvenida a Oxy!",
74
75
  "subtitle": "Crea tu cuenta en pocos pasos",
@@ -61,7 +61,8 @@
61
61
  "usernameAvailable": "Disponible",
62
62
  "usernameTaken": "Ce nom d'utilisateur est déjà pris",
63
63
  "backToSignInLink": "Vous avez déjà un compte ? Connectez-vous",
64
- "notAvailableHere": "La création de compte n'est pas encore disponible dans cette app — créez votre identité avec Commons, ou rendez-vous sur oxy.so pour vous inscrire avec une clé d'accès.",
64
+ "hubExplainer": "Créez votre Oxy ID dans une fenêtre sécurisée, puis revenez directement.",
65
+ "continueInWindow": "Continuer dans une nouvelle fenêtre",
65
66
  "welcome": {
66
67
  "title": "Bienvenue sur Oxy !",
67
68
  "subtitle": "Créez votre compte en quelques étapes",
@@ -61,7 +61,8 @@
61
61
  "usernameAvailable": "Disponibile",
62
62
  "usernameTaken": "Questo nome utente è già in uso",
63
63
  "backToSignInLink": "Hai già un account? Accedi",
64
- "notAvailableHere": "La creazione dell'account non è ancora disponibile in questa app: crea la tua identità con Commons oppure visita oxy.so per registrarti con una passkey.",
64
+ "hubExplainer": "Crea il tuo Oxy ID in una finestra sicura, poi torna subito qui.",
65
+ "continueInWindow": "Continua in una nuova finestra",
65
66
  "welcome": {
66
67
  "title": "Benvenuto su Oxy!",
67
68
  "subtitle": "Crea il tuo account in pochi passaggi",
@@ -61,7 +61,8 @@
61
61
  "usernameAvailable": "利用可能",
62
62
  "usernameTaken": "このユーザー名は既に使用されています",
63
63
  "backToSignInLink": "すでにアカウントをお持ちですか?サインイン",
64
- "notAvailableHere": "このアプリではまだアカウントを作成できません。Commonsでアイデンティティを作成するか、oxy.soにアクセスしてパスキーで登録してください。",
64
+ "hubExplainer": "安全なウィンドウでOxy IDを作成し、すぐに戻ってきてください。",
65
+ "continueInWindow": "新しいウィンドウで続ける",
65
66
  "welcome": {
66
67
  "title": "Oxyへようこそ!",
67
68
  "subtitle": "数ステップでアカウントを作成",
@@ -61,7 +61,8 @@
61
61
  "usernameAvailable": "사용 가능",
62
62
  "usernameTaken": "이미 사용 중인 사용자 이름입니다",
63
63
  "backToSignInLink": "이미 계정이 있으신가요? 로그인",
64
- "notAvailableHere": " 앱에서는 아직 계정을 만들 없습니다. Commons로 아이덴티티를 만들거나 oxy.so에서 패스키로 가입하세요.",
64
+ "hubExplainer": "안전한 창에서 Oxy ID를 만든 바로 돌아오세요.",
65
+ "continueInWindow": "새 창에서 계속하기",
65
66
  "welcome": {
66
67
  "title": "Oxy에 오신 것을 환영합니다!",
67
68
  "subtitle": "몇 단계만으로 계정을 만드세요",
@@ -61,7 +61,8 @@
61
61
  "usernameAvailable": "متاح",
62
62
  "usernameTaken": "اسم المستخدم هذا مستخدم بالفعل",
63
63
  "backToSignInLink": "لديك حساب بالفعل؟ سجّل الدخول",
64
- "notAvailableHere": "‏إنشاء الحساب غير متاح في هذا التطبيق بعد أنشئ هويتك باستخدام Commons، أو تفضّل بزيارة oxy.so للتسجيل باستخدام مفتاح مرور.",
64
+ "hubExplainer": "أنشئ هوية Oxy الخاصة بك في نافذة آمنة، ثم عد إلى هنا مباشرة.",
65
+ "continueInWindow": "المتابعة في نافذة جديدة",
65
66
  "welcome": {
66
67
  "title": "مرحبًا بك في Oxy!",
67
68
  "subtitle": "أنشئ حسابك في خطوات قليلة",
@@ -61,7 +61,8 @@
61
61
  "usernameAvailable": "Disponible",
62
62
  "usernameTaken": "Aquest nom d'usuari ja està en ús",
63
63
  "backToSignInLink": "Ja tens compte? Inicia sessió",
64
- "notAvailableHere": "La creació de comptes encara no està disponible en aquesta app: crea la teva identitat amb Commons o visita oxy.so per registrar-te amb una clau d'accés.",
64
+ "hubExplainer": "Crea la teva Oxy ID en una finestra segura i torna de seguida.",
65
+ "continueInWindow": "Continua en una finestra nova",
65
66
  "welcome": {
66
67
  "title": "Benvingut a Oxy!",
67
68
  "subtitle": "Crea el teu compte en pocs passos",
@@ -61,7 +61,8 @@
61
61
  "usernameAvailable": "Verfügbar",
62
62
  "usernameTaken": "Dieser Benutzername ist bereits vergeben",
63
63
  "backToSignInLink": "Sie haben bereits ein Konto? Anmelden",
64
- "notAvailableHere": "Die Kontoerstellung ist in dieser App noch nicht verfügbar – erstellen Sie Ihre Identität mit Commons oder besuchen Sie oxy.so, um sich mit einem Passkey zu registrieren.",
64
+ "hubExplainer": "Erstellen Sie Ihre Oxy-ID in einem sicheren Fenster und kehren Sie dann direkt zurück.",
65
+ "continueInWindow": "In einem neuen Fenster fortfahren",
65
66
  "welcome": {
66
67
  "title": "Willkommen bei Oxy!",
67
68
  "subtitle": "Erstellen Sie Ihr Konto in nur wenigen Schritten",
@@ -68,7 +68,8 @@
68
68
  "usernameAvailable": "Available",
69
69
  "usernameTaken": "This username is taken",
70
70
  "backToSignInLink": "Already have an account? Sign in",
71
- "notAvailableHere": "Account creation isn't available in this app yet — create your identity with Commons, or visit oxy.so to sign up with a passkey.",
71
+ "hubExplainer": "Create your Oxy ID in a secure window, then come right back.",
72
+ "continueInWindow": "Continue in a new window",
72
73
  "welcome": {
73
74
  "title": "Welcome to Oxy!",
74
75
  "subtitle": "Let's create your account in just a few steps",
@@ -68,7 +68,8 @@
68
68
  "usernameAvailable": "Disponible",
69
69
  "usernameTaken": "Este usuario ya está en uso",
70
70
  "backToSignInLink": "¿Ya tienes cuenta? Inicia sesión",
71
- "notAvailableHere": "La creación de cuentas aún no está disponible en esta app: crea tu identidad con Commons o visita oxy.so para registrarte con una clave de acceso.",
71
+ "hubExplainer": "Crea tu Oxy ID en una ventana segura y vuelve enseguida.",
72
+ "continueInWindow": "Continuar en una ventana nueva",
72
73
  "welcome": {
73
74
  "title": "¡Te damos la bienvenida a Oxy!",
74
75
  "subtitle": "Crea tu cuenta en pocos pasos",
@@ -61,7 +61,8 @@
61
61
  "usernameAvailable": "Disponible",
62
62
  "usernameTaken": "Ce nom d'utilisateur est déjà pris",
63
63
  "backToSignInLink": "Vous avez déjà un compte ? Connectez-vous",
64
- "notAvailableHere": "La création de compte n'est pas encore disponible dans cette app — créez votre identité avec Commons, ou rendez-vous sur oxy.so pour vous inscrire avec une clé d'accès.",
64
+ "hubExplainer": "Créez votre Oxy ID dans une fenêtre sécurisée, puis revenez directement.",
65
+ "continueInWindow": "Continuer dans une nouvelle fenêtre",
65
66
  "welcome": {
66
67
  "title": "Bienvenue sur Oxy !",
67
68
  "subtitle": "Créez votre compte en quelques étapes",
@@ -61,7 +61,8 @@
61
61
  "usernameAvailable": "Disponibile",
62
62
  "usernameTaken": "Questo nome utente è già in uso",
63
63
  "backToSignInLink": "Hai già un account? Accedi",
64
- "notAvailableHere": "La creazione dell'account non è ancora disponibile in questa app: crea la tua identità con Commons oppure visita oxy.so per registrarti con una passkey.",
64
+ "hubExplainer": "Crea il tuo Oxy ID in una finestra sicura, poi torna subito qui.",
65
+ "continueInWindow": "Continua in una nuova finestra",
65
66
  "welcome": {
66
67
  "title": "Benvenuto su Oxy!",
67
68
  "subtitle": "Crea il tuo account in pochi passaggi",
@@ -61,7 +61,8 @@
61
61
  "usernameAvailable": "利用可能",
62
62
  "usernameTaken": "このユーザー名は既に使用されています",
63
63
  "backToSignInLink": "すでにアカウントをお持ちですか?サインイン",
64
- "notAvailableHere": "このアプリではまだアカウントを作成できません。Commonsでアイデンティティを作成するか、oxy.soにアクセスしてパスキーで登録してください。",
64
+ "hubExplainer": "安全なウィンドウでOxy IDを作成し、すぐに戻ってきてください。",
65
+ "continueInWindow": "新しいウィンドウで続ける",
65
66
  "welcome": {
66
67
  "title": "Oxyへようこそ!",
67
68
  "subtitle": "数ステップでアカウントを作成",
@@ -61,7 +61,8 @@
61
61
  "usernameAvailable": "사용 가능",
62
62
  "usernameTaken": "이미 사용 중인 사용자 이름입니다",
63
63
  "backToSignInLink": "이미 계정이 있으신가요? 로그인",
64
- "notAvailableHere": " 앱에서는 아직 계정을 만들 없습니다. Commons로 아이덴티티를 만들거나 oxy.so에서 패스키로 가입하세요.",
64
+ "hubExplainer": "안전한 창에서 Oxy ID를 만든 바로 돌아오세요.",
65
+ "continueInWindow": "새 창에서 계속하기",
65
66
  "welcome": {
66
67
  "title": "Oxy에 오신 것을 환영합니다!",
67
68
  "subtitle": "몇 단계만으로 계정을 만드세요",
@@ -61,7 +61,8 @@
61
61
  "usernameAvailable": "Disponível",
62
62
  "usernameTaken": "Este nome de utilizador já está em uso",
63
63
  "backToSignInLink": "Já tem uma conta? Inicie sessão",
64
- "notAvailableHere": "A criação de conta ainda não está disponível nesta app: crie a sua identidade com o Commons ou visite oxy.so para se registar com uma chave de acesso.",
64
+ "hubExplainer": "Crie a sua Oxy ID numa janela segura e volte de seguida.",
65
+ "continueInWindow": "Continuar numa nova janela",
65
66
  "welcome": {
66
67
  "title": "Bem-vindo ao Oxy!",
67
68
  "subtitle": "Crie a sua conta em poucos passos",
@@ -61,7 +61,8 @@
61
61
  "usernameAvailable": "可用",
62
62
  "usernameTaken": "该用户名已被占用",
63
63
  "backToSignInLink": "已有账户?登录",
64
- "notAvailableHere": "此应用暂不支持创建账户——请使用 Commons 创建您的身份,或访问 oxy.so 使用通行密钥注册。",
64
+ "hubExplainer": "在安全窗口中创建您的 Oxy ID,然后立即返回。",
65
+ "continueInWindow": "在新窗口中继续",
65
66
  "welcome": {
66
67
  "title": "欢迎使用Oxy!",
67
68
  "subtitle": "只需几步即可创建您的账户",
@@ -61,7 +61,8 @@
61
61
  "usernameAvailable": "Disponível",
62
62
  "usernameTaken": "Este nome de utilizador já está em uso",
63
63
  "backToSignInLink": "Já tem uma conta? Inicie sessão",
64
- "notAvailableHere": "A criação de conta ainda não está disponível nesta app: crie a sua identidade com o Commons ou visite oxy.so para se registar com uma chave de acesso.",
64
+ "hubExplainer": "Crie a sua Oxy ID numa janela segura e volte de seguida.",
65
+ "continueInWindow": "Continuar numa nova janela",
65
66
  "welcome": {
66
67
  "title": "Bem-vindo ao Oxy!",
67
68
  "subtitle": "Crie a sua conta em poucos passos",
@@ -61,7 +61,8 @@
61
61
  "usernameAvailable": "可用",
62
62
  "usernameTaken": "该用户名已被占用",
63
63
  "backToSignInLink": "已有账户?登录",
64
- "notAvailableHere": "此应用暂不支持创建账户——请使用 Commons 创建您的身份,或访问 oxy.so 使用通行密钥注册。",
64
+ "hubExplainer": "在安全窗口中创建您的 Oxy ID,然后立即返回。",
65
+ "continueInWindow": "在新窗口中继续",
65
66
  "welcome": {
66
67
  "title": "欢迎使用Oxy!",
67
68
  "subtitle": "只需几步即可创建您的账户",
@@ -24,6 +24,12 @@
24
24
  * - `commonsAvailability` — whether Commons is installed on this device
25
25
  * (native only, via the injected `canOpenApp` probe), so the QR view can
26
26
  * offer a "Get Commons" fallback instead of a same-device dead end.
27
+ * - `startPasskeyHubSignIn` — on a non-Oxy web origin (where a WebAuthn
28
+ * ceremony can't run locally, the RP-ID is bound to oxy.so), open a popup
29
+ * at the auth.oxy.so passkey hub instead, scoped to the SAME device-flow
30
+ * session `showQr` creates, and complete it via the SAME poll/socket/claim
31
+ * engine. Falls back to `showQr`'s plain QR rendering if the popup is
32
+ * blocked.
27
33
  *
28
34
  * Sign-in is passkey (WebAuthn) or the Commons QR / shared-keychain handoff —
29
35
  * password, social login, and 2FA were removed ecosystem-wide. Account
@@ -32,6 +38,7 @@
32
38
  */
33
39
  import { logger } from '../logger/index.js';
34
40
  import { extractErrorStatus } from '../utils/errorUtils.js';
41
+ import { CENTRAL_IDP_APEX } from '../utils/authWebUrl.js';
35
42
  import { projectSwitchableAccounts, switchableAccountIds, } from './accountProjection.js';
36
43
  /**
37
44
  * Slow FALLBACK poll cadence for the QR flow. The `/auth-session` socket delivers
@@ -86,6 +93,10 @@ export class AccountDialogController {
86
93
  * single-use token concurrently.
87
94
  */
88
95
  this.pollInFlight = false;
96
+ /** The popup opened by {@link startPasskeyHubSignIn}, or `null`. */
97
+ this.activePopup = null;
98
+ /** Watches {@link activePopup}'s `closed` state; see {@link watchPopup}. */
99
+ this.popupWatchTimer = null;
89
100
  // --- Store plumbing ---
90
101
  this.unsubscribeSession = null;
91
102
  this.unsubscribeTokens = null;
@@ -104,6 +115,8 @@ export class AccountDialogController {
104
115
  this.openUrl = options.openUrl;
105
116
  this.canOpenApp = options.canOpenApp;
106
117
  this.socketFactory = options.socketFactory;
118
+ this.openPopup = options.openPopup;
119
+ this.hubBaseUrl = options.hubBaseUrl ?? `https://auth.${CENTRAL_IDP_APEX}`;
107
120
  this.snapshot = this.computeSnapshot();
108
121
  }
109
122
  // =========================================================================
@@ -177,6 +190,7 @@ export class AccountDialogController {
177
190
  }
178
191
  this.clearPollTimer();
179
192
  this.closeAuthSessionSocket();
193
+ this.closeActivePopup();
180
194
  this.signInToken = null;
181
195
  this.listeners.clear();
182
196
  }
@@ -444,9 +458,62 @@ export class AccountDialogController {
444
458
  async showQr() {
445
459
  this.cancelSignIn();
446
460
  this.setView('qr');
461
+ await this.startDeviceFlowSession();
462
+ }
463
+ /**
464
+ * Web-only: "Sign in with a passkey" on a non-Oxy origin cannot run the
465
+ * WebAuthn ceremony locally — a credential minted with `WEBAUTHN_RP_ID=oxy.so`
466
+ * can only be asserted from `oxy.so`/a subdomain/loopback, a browser-enforced
467
+ * boundary `isOxyRpOrigin()` (consumer-side) already gates on. Instead, open
468
+ * a popup at the auth.oxy.so passkey hub, scoped to the SAME device-flow
469
+ * session {@link showQr} would create (same `authorizeCode`/`sessionToken`
470
+ * pair), and let the SAME poll/socket/claim engine complete it once the hub
471
+ * authorizes the session (`POST /auth/session/authorize-code/:authorizeCode`,
472
+ * bearer-authed, server-side — this method never sees or transmits the
473
+ * secret `sessionToken`).
474
+ *
475
+ * The popup MUST be opened synchronously, before any `await`, or the
476
+ * browser's popup blocker loses the click-gesture attribution and silently
477
+ * blocks it — so {@link openPopup} is invoked as the very first step, before
478
+ * the device-flow session (which needs an async call) even exists. If the
479
+ * popup is blocked (or no `openPopup` was injected), this falls back to
480
+ * `showQr`'s plain QR rendering — no dead end.
481
+ */
482
+ async startPasskeyHubSignIn() {
483
+ this.cancelSignIn();
484
+ this.setView('qr');
485
+ const popup = this.openPopup?.() ?? null;
486
+ if (!popup) {
487
+ await this.startDeviceFlowSession();
488
+ return;
489
+ }
490
+ const handle = await this.startDeviceFlowSession();
491
+ if (!handle) {
492
+ popup.close();
493
+ return;
494
+ }
495
+ // The user may have closed the popup during the async session creation
496
+ // above, before any watcher was attached to catch it — guard rather than
497
+ // navigate a dead window (browsers vary on whether that throws).
498
+ if (popup.closed) {
499
+ this.failSignIn('Sign-in was cancelled.');
500
+ return;
501
+ }
502
+ this.activePopup = popup;
503
+ popup.location.href = `${this.hubBaseUrl}/hub-passkey?code=${encodeURIComponent(handle.authorizeCode)}`;
504
+ this.watchPopup(popup);
505
+ }
506
+ /**
507
+ * Shared device-flow session creation for both {@link showQr} (renders the
508
+ * QR) and {@link startPasskeyHubSignIn} (also opens the hub popup) — the
509
+ * same `startCommonsSignIn` → poll/socket wiring either way. Returns the
510
+ * handle on success (already reflected in `signIn`), or `null` on failure
511
+ * (already set as `signIn.error`).
512
+ */
513
+ async startDeviceFlowSession() {
447
514
  if (!this.clientId) {
448
515
  this.setSignIn({ ...IDLE_SIGN_IN, phase: 'error', error: 'This app is not configured for sign-in (missing clientId).' });
449
- return;
516
+ return null;
450
517
  }
451
518
  this.setSignIn({ ...IDLE_SIGN_IN, phase: 'starting' });
452
519
  try {
@@ -471,9 +538,49 @@ export class AccountDialogController {
471
538
  // stay live as the fallback, so a user who dismisses the app-open still
472
539
  // completes the sign-in by scanning.
473
540
  void this.deepLinkIntoCommonsIfAvailable(handle.qrPayload);
541
+ return handle;
474
542
  }
475
543
  catch (error) {
476
544
  this.setSignIn({ ...IDLE_SIGN_IN, phase: 'error', error: errorMessage(error) });
545
+ return null;
546
+ }
547
+ }
548
+ /**
549
+ * Poll {@link PopupWindowHandle.closed} so a user who dismisses the hub
550
+ * popup without completing sign-in gets prompt feedback (there is no DOM
551
+ * event for a cross-origin popup closing — polling is the only mechanism).
552
+ * Cleared by {@link closeActivePopup}, which every sign-in exit path already
553
+ * calls.
554
+ */
555
+ watchPopup(popup) {
556
+ this.clearPopupWatchTimer();
557
+ this.popupWatchTimer = setInterval(() => {
558
+ if (!popup.closed)
559
+ return;
560
+ this.clearPopupWatchTimer();
561
+ if (this.signIn.phase === 'starting' || this.signIn.phase === 'waiting') {
562
+ this.failSignIn('Sign-in was cancelled.');
563
+ }
564
+ }, 1000);
565
+ }
566
+ clearPopupWatchTimer() {
567
+ if (this.popupWatchTimer !== null) {
568
+ clearInterval(this.popupWatchTimer);
569
+ this.popupWatchTimer = null;
570
+ }
571
+ }
572
+ /** Tear down the popup watch timer and close the popup, if any. Idempotent. */
573
+ closeActivePopup() {
574
+ this.clearPopupWatchTimer();
575
+ const popup = this.activePopup;
576
+ this.activePopup = null;
577
+ if (!popup || popup.closed)
578
+ return;
579
+ try {
580
+ popup.close();
581
+ }
582
+ catch (error) {
583
+ logger.debug('[AccountDialogController] popup close failed', { component: 'AccountDialogController' }, error);
477
584
  }
478
585
  }
479
586
  /**
@@ -523,10 +630,11 @@ export class AccountDialogController {
523
630
  this.openUrl(qrPayload);
524
631
  }
525
632
  }
526
- /** Tear down the active sign-in device flow (timers + socket + token) and reset to idle. */
633
+ /** Tear down the active sign-in device flow (timers + socket + popup + token) and reset to idle. */
527
634
  cancelSignIn() {
528
635
  this.clearPollTimer();
529
636
  this.closeAuthSessionSocket();
637
+ this.closeActivePopup();
530
638
  this.signInToken = null;
531
639
  if (this.signIn !== IDLE_SIGN_IN) {
532
640
  this.setSignIn(IDLE_SIGN_IN);
@@ -635,6 +743,7 @@ export class AccountDialogController {
635
743
  this.signInToken = null;
636
744
  this.clearPollTimer();
637
745
  this.closeAuthSessionSocket();
746
+ this.closeActivePopup();
638
747
  this.signIn = IDLE_SIGN_IN;
639
748
  this.view = 'accounts';
640
749
  this.emit();
@@ -666,6 +775,7 @@ export class AccountDialogController {
666
775
  failSignIn(message) {
667
776
  this.clearPollTimer();
668
777
  this.closeAuthSessionSocket();
778
+ this.closeActivePopup();
669
779
  this.signInToken = null;
670
780
  this.setSignIn({ ...IDLE_SIGN_IN, phase: 'error', error: message });
671
781
  }