@oxyhq/services 22.12.4 → 22.13.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.
- package/README.md +16 -46
- package/lib/commonjs/index.js +18 -12
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/ui/boot/runProviderColdBoot.js +51 -9
- package/lib/commonjs/ui/boot/runProviderColdBoot.js.map +1 -1
- package/lib/commonjs/ui/client.js +0 -13
- package/lib/commonjs/ui/client.js.map +1 -1
- package/lib/commonjs/ui/components/OxyAccountDialogScreen.js +27 -4
- package/lib/commonjs/ui/components/OxyAccountDialogScreen.js.map +1 -1
- package/lib/commonjs/ui/components/OxyAuthChooser.js +72 -1123
- package/lib/commonjs/ui/components/OxyAuthChooser.js.map +1 -1
- package/lib/commonjs/ui/components/OxyConsentScreen.js +50 -12
- package/lib/commonjs/ui/components/OxyConsentScreen.js.map +1 -1
- package/lib/commonjs/ui/components/OxyProvider.js +4 -4
- package/lib/commonjs/ui/components/OxyProvider.js.map +1 -1
- package/lib/commonjs/ui/components/OxySignInButton.js +74 -40
- package/lib/commonjs/ui/components/OxySignInButton.js.map +1 -1
- package/lib/commonjs/ui/components/authChooser/AccountsMenuView.js +527 -0
- package/lib/commonjs/ui/components/authChooser/AccountsMenuView.js.map +1 -0
- package/lib/commonjs/ui/components/authChooser/SignInEntryView.js +90 -0
- package/lib/commonjs/ui/components/authChooser/SignInEntryView.js.map +1 -0
- package/lib/commonjs/ui/components/authChooser/SignInRequestView.js +144 -0
- package/lib/commonjs/ui/components/authChooser/SignInRequestView.js.map +1 -0
- package/lib/commonjs/ui/components/authChooser/SignUpView.js +188 -0
- package/lib/commonjs/ui/components/authChooser/SignUpView.js.map +1 -0
- package/lib/commonjs/ui/components/authChooser/TroubleDisclosure.js +63 -0
- package/lib/commonjs/ui/components/authChooser/TroubleDisclosure.js.map +1 -0
- package/lib/commonjs/ui/components/authChooser/primitives.js +169 -0
- package/lib/commonjs/ui/components/authChooser/primitives.js.map +1 -0
- package/lib/commonjs/ui/components/authChooser/requestSurfaces.js +149 -0
- package/lib/commonjs/ui/components/authChooser/requestSurfaces.js.map +1 -0
- package/lib/commonjs/ui/components/authChooser/signInProgress.js +54 -0
- package/lib/commonjs/ui/components/authChooser/signInProgress.js.map +1 -0
- package/lib/commonjs/ui/components/{oxyAuthChooserStyles.js → authChooser/styles.js} +19 -1
- package/lib/commonjs/ui/components/authChooser/styles.js.map +1 -0
- package/lib/commonjs/ui/components/authChooser/types.js +59 -0
- package/lib/commonjs/ui/components/authChooser/types.js.map +1 -0
- package/lib/commonjs/ui/components/authChooser/useUsernameAvailability.js +50 -0
- package/lib/commonjs/ui/components/authChooser/useUsernameAvailability.js.map +1 -0
- package/lib/commonjs/ui/context/OxyContext.js +205 -30
- package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
- package/lib/commonjs/ui/context/commitSessionFlow.js +46 -0
- package/lib/commonjs/ui/context/commitSessionFlow.js.map +1 -1
- package/lib/commonjs/ui/context/hooks/useAuthOperations.js +15 -2
- package/lib/commonjs/ui/context/hooks/useAuthOperations.js.map +1 -1
- package/lib/commonjs/ui/context/useOxyAccountGraph.js +13 -5
- package/lib/commonjs/ui/context/useOxyAccountGraph.js.map +1 -1
- package/lib/commonjs/ui/hooks/useSwitchableAccounts.js +6 -1
- package/lib/commonjs/ui/hooks/useSwitchableAccounts.js.map +1 -1
- package/lib/commonjs/ui/index.js +0 -13
- package/lib/commonjs/ui/index.js.map +1 -1
- package/lib/commonjs/ui/oauth/browserAuthTransport.js +170 -0
- package/lib/commonjs/ui/oauth/browserAuthTransport.js.map +1 -0
- package/lib/commonjs/ui/oauth/completeOAuthCode.js +78 -0
- package/lib/commonjs/ui/oauth/completeOAuthCode.js.map +1 -0
- package/lib/commonjs/ui/oauth/legacyRedirectLanes.js +48 -0
- package/lib/commonjs/ui/oauth/legacyRedirectLanes.js.map +1 -0
- package/lib/commonjs/ui/oauth/oauthHandshake.js +53 -0
- package/lib/commonjs/ui/oauth/oauthHandshake.js.map +1 -0
- package/lib/commonjs/ui/oauth/oauthPopup.js +276 -0
- package/lib/commonjs/ui/oauth/oauthPopup.js.map +1 -0
- package/lib/commonjs/ui/oauth/oauthPopupMessages.js +141 -0
- package/lib/commonjs/ui/oauth/oauthPopupMessages.js.map +1 -0
- package/lib/commonjs/ui/oauth/types.js +2 -0
- package/lib/commonjs/ui/oauth/types.js.map +1 -0
- package/lib/commonjs/ui/server.js +2 -5
- package/lib/commonjs/ui/server.js.map +1 -1
- package/lib/commonjs/ui/session/authStore.js +6 -75
- package/lib/commonjs/ui/session/authStore.js.map +1 -1
- package/lib/commonjs/ui/session/createSessionClient.js +11 -3
- package/lib/commonjs/ui/session/createSessionClient.js.map +1 -1
- package/lib/commonjs/ui/session/identityBinding.js +95 -0
- package/lib/commonjs/ui/session/identityBinding.js.map +1 -0
- package/lib/commonjs/ui/session/index.js +13 -0
- package/lib/commonjs/ui/session/index.js.map +1 -1
- package/lib/commonjs/ui/session/nativeSecureStorage.js +90 -0
- package/lib/commonjs/ui/session/nativeSecureStorage.js.map +1 -0
- package/lib/commonjs/ui/session/tokenTransport.js +11 -1
- package/lib/commonjs/ui/session/tokenTransport.js.map +1 -1
- package/lib/commonjs/ui/utils/crossOriginRestore.js +5 -4
- package/lib/commonjs/ui/utils/crossOriginRestore.js.map +1 -1
- package/lib/commonjs/ui/utils/deliveryPlatform.js +58 -0
- package/lib/commonjs/ui/utils/deliveryPlatform.js.map +1 -0
- package/lib/commonjs/ui/utils/oauthReturn.js +72 -46
- package/lib/commonjs/ui/utils/oauthReturn.js.map +1 -1
- package/lib/module/index.js +9 -4
- package/lib/module/index.js.map +1 -1
- package/lib/module/ui/boot/runProviderColdBoot.js +51 -9
- package/lib/module/ui/boot/runProviderColdBoot.js.map +1 -1
- package/lib/module/ui/client.js +0 -1
- package/lib/module/ui/client.js.map +1 -1
- package/lib/module/ui/components/OxyAccountDialogScreen.js +27 -4
- package/lib/module/ui/components/OxyAccountDialogScreen.js.map +1 -1
- package/lib/module/ui/components/OxyAuthChooser.js +76 -1128
- package/lib/module/ui/components/OxyAuthChooser.js.map +1 -1
- package/lib/module/ui/components/OxyConsentScreen.js +50 -12
- package/lib/module/ui/components/OxyConsentScreen.js.map +1 -1
- package/lib/module/ui/components/OxyProvider.js +4 -4
- package/lib/module/ui/components/OxyProvider.js.map +1 -1
- package/lib/module/ui/components/OxySignInButton.js +76 -42
- package/lib/module/ui/components/OxySignInButton.js.map +1 -1
- package/lib/module/ui/components/authChooser/AccountsMenuView.js +523 -0
- package/lib/module/ui/components/authChooser/AccountsMenuView.js.map +1 -0
- package/lib/module/ui/components/authChooser/SignInEntryView.js +85 -0
- package/lib/module/ui/components/authChooser/SignInEntryView.js.map +1 -0
- package/lib/module/ui/components/authChooser/SignInRequestView.js +139 -0
- package/lib/module/ui/components/authChooser/SignInRequestView.js.map +1 -0
- package/lib/module/ui/components/authChooser/SignUpView.js +184 -0
- package/lib/module/ui/components/authChooser/SignUpView.js.map +1 -0
- package/lib/module/ui/components/authChooser/TroubleDisclosure.js +59 -0
- package/lib/module/ui/components/authChooser/TroubleDisclosure.js.map +1 -0
- package/lib/module/ui/components/authChooser/primitives.js +163 -0
- package/lib/module/ui/components/authChooser/primitives.js.map +1 -0
- package/lib/module/ui/components/authChooser/requestSurfaces.js +139 -0
- package/lib/module/ui/components/authChooser/requestSurfaces.js.map +1 -0
- package/lib/module/ui/components/authChooser/signInProgress.js +50 -0
- package/lib/module/ui/components/authChooser/signInProgress.js.map +1 -0
- package/lib/module/ui/components/{oxyAuthChooserStyles.js → authChooser/styles.js} +19 -1
- package/lib/module/ui/components/authChooser/styles.js.map +1 -0
- package/lib/module/ui/components/authChooser/types.js +55 -0
- package/lib/module/ui/components/authChooser/types.js.map +1 -0
- package/lib/module/ui/components/authChooser/useUsernameAvailability.js +46 -0
- package/lib/module/ui/components/authChooser/useUsernameAvailability.js.map +1 -0
- package/lib/module/ui/context/OxyContext.js +208 -33
- package/lib/module/ui/context/OxyContext.js.map +1 -1
- package/lib/module/ui/context/commitSessionFlow.js +45 -0
- package/lib/module/ui/context/commitSessionFlow.js.map +1 -1
- package/lib/module/ui/context/hooks/useAuthOperations.js +15 -2
- package/lib/module/ui/context/hooks/useAuthOperations.js.map +1 -1
- package/lib/module/ui/context/useOxyAccountGraph.js +13 -5
- package/lib/module/ui/context/useOxyAccountGraph.js.map +1 -1
- package/lib/module/ui/hooks/useSwitchableAccounts.js +6 -1
- package/lib/module/ui/hooks/useSwitchableAccounts.js.map +1 -1
- package/lib/module/ui/index.js +0 -1
- package/lib/module/ui/index.js.map +1 -1
- package/lib/module/ui/oauth/browserAuthTransport.js +167 -0
- package/lib/module/ui/oauth/browserAuthTransport.js.map +1 -0
- package/lib/module/ui/oauth/completeOAuthCode.js +75 -0
- package/lib/module/ui/oauth/completeOAuthCode.js.map +1 -0
- package/lib/module/ui/oauth/legacyRedirectLanes.js +44 -0
- package/lib/module/ui/oauth/legacyRedirectLanes.js.map +1 -0
- package/lib/module/ui/oauth/oauthHandshake.js +50 -0
- package/lib/module/ui/oauth/oauthHandshake.js.map +1 -0
- package/lib/module/ui/oauth/oauthPopup.js +268 -0
- package/lib/module/ui/oauth/oauthPopup.js.map +1 -0
- package/lib/module/ui/oauth/oauthPopupMessages.js +135 -0
- package/lib/module/ui/oauth/oauthPopupMessages.js.map +1 -0
- package/lib/module/ui/oauth/types.js +2 -0
- package/lib/module/ui/oauth/types.js.map +1 -0
- package/lib/module/ui/server.js +0 -2
- package/lib/module/ui/server.js.map +1 -1
- package/lib/module/ui/session/authStore.js +5 -75
- package/lib/module/ui/session/authStore.js.map +1 -1
- package/lib/module/ui/session/createSessionClient.js +11 -3
- package/lib/module/ui/session/createSessionClient.js.map +1 -1
- package/lib/module/ui/session/identityBinding.js +89 -0
- package/lib/module/ui/session/identityBinding.js.map +1 -0
- package/lib/module/ui/session/index.js +5 -2
- package/lib/module/ui/session/index.js.map +1 -1
- package/lib/module/ui/session/nativeSecureStorage.js +88 -0
- package/lib/module/ui/session/nativeSecureStorage.js.map +1 -0
- package/lib/module/ui/session/tokenTransport.js +11 -1
- package/lib/module/ui/session/tokenTransport.js.map +1 -1
- package/lib/module/ui/utils/crossOriginRestore.js +6 -5
- package/lib/module/ui/utils/crossOriginRestore.js.map +1 -1
- package/lib/module/ui/utils/deliveryPlatform.js +55 -0
- package/lib/module/ui/utils/deliveryPlatform.js.map +1 -0
- package/lib/module/ui/utils/oauthReturn.js +73 -47
- package/lib/module/ui/utils/oauthReturn.js.map +1 -1
- package/lib/typescript/commonjs/index.d.ts +4 -1
- package/lib/typescript/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/boot/runProviderColdBoot.d.ts +34 -2
- package/lib/typescript/commonjs/ui/boot/runProviderColdBoot.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/client.d.ts +0 -1
- package/lib/typescript/commonjs/ui/client.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/OxyAccountDialogScreen.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/OxyAuthChooser.d.ts +21 -29
- package/lib/typescript/commonjs/ui/components/OxyAuthChooser.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/OxyConsentScreen.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/OxyProvider.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/OxySignInButton.d.ts +17 -12
- package/lib/typescript/commonjs/ui/components/OxySignInButton.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/authChooser/AccountsMenuView.d.ts +38 -0
- package/lib/typescript/commonjs/ui/components/authChooser/AccountsMenuView.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/components/authChooser/SignInEntryView.d.ts +32 -0
- package/lib/typescript/commonjs/ui/components/authChooser/SignInEntryView.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/components/authChooser/SignInRequestView.d.ts +34 -0
- package/lib/typescript/commonjs/ui/components/authChooser/SignInRequestView.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/components/authChooser/SignUpView.d.ts +34 -0
- package/lib/typescript/commonjs/ui/components/authChooser/SignUpView.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/components/authChooser/TroubleDisclosure.d.ts +43 -0
- package/lib/typescript/commonjs/ui/components/authChooser/TroubleDisclosure.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/components/authChooser/primitives.d.ts +55 -0
- package/lib/typescript/commonjs/ui/components/authChooser/primitives.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/components/authChooser/requestSurfaces.d.ts +54 -0
- package/lib/typescript/commonjs/ui/components/authChooser/requestSurfaces.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/components/authChooser/signInProgress.d.ts +26 -0
- package/lib/typescript/commonjs/ui/components/authChooser/signInProgress.d.ts.map +1 -0
- package/lib/typescript/{module/ui/components/oxyAuthChooserStyles.d.ts → commonjs/ui/components/authChooser/styles.d.ts} +19 -1
- package/lib/typescript/commonjs/ui/components/authChooser/styles.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/components/authChooser/types.d.ts +85 -0
- package/lib/typescript/commonjs/ui/components/authChooser/types.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/components/authChooser/useUsernameAvailability.d.ts +16 -0
- package/lib/typescript/commonjs/ui/components/authChooser/useUsernameAvailability.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/context/OxyContext.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/context/commitSessionFlow.d.ts +40 -0
- package/lib/typescript/commonjs/ui/context/commitSessionFlow.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/context/hooks/useAuthOperations.d.ts +11 -2
- package/lib/typescript/commonjs/ui/context/hooks/useAuthOperations.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/context/oxyContextTypes.d.ts +44 -1
- package/lib/typescript/commonjs/ui/context/oxyContextTypes.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/context/useOxyAccountGraph.d.ts +7 -1
- package/lib/typescript/commonjs/ui/context/useOxyAccountGraph.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/useSwitchableAccounts.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/index.d.ts +0 -1
- package/lib/typescript/commonjs/ui/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/oauth/browserAuthTransport.d.ts +56 -0
- package/lib/typescript/commonjs/ui/oauth/browserAuthTransport.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/oauth/completeOAuthCode.d.ts +49 -0
- package/lib/typescript/commonjs/ui/oauth/completeOAuthCode.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/oauth/legacyRedirectLanes.d.ts +40 -0
- package/lib/typescript/commonjs/ui/oauth/legacyRedirectLanes.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/oauth/oauthHandshake.d.ts +50 -0
- package/lib/typescript/commonjs/ui/oauth/oauthHandshake.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/oauth/oauthPopup.d.ts +83 -0
- package/lib/typescript/commonjs/ui/oauth/oauthPopup.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/oauth/oauthPopupMessages.d.ts +67 -0
- package/lib/typescript/commonjs/ui/oauth/oauthPopupMessages.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/oauth/types.d.ts +176 -0
- package/lib/typescript/commonjs/ui/oauth/types.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/server.d.ts +0 -2
- package/lib/typescript/commonjs/ui/server.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/session/authStore.d.ts +3 -7
- package/lib/typescript/commonjs/ui/session/authStore.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/session/createSessionClient.d.ts +8 -1
- package/lib/typescript/commonjs/ui/session/createSessionClient.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/session/identityBinding.d.ts +66 -0
- package/lib/typescript/commonjs/ui/session/identityBinding.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/session/index.d.ts +6 -2
- package/lib/typescript/commonjs/ui/session/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/session/nativeSecureStorage.d.ts +25 -0
- package/lib/typescript/commonjs/ui/session/nativeSecureStorage.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/session/tokenTransport.d.ts +8 -1
- package/lib/typescript/commonjs/ui/session/tokenTransport.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/types/navigation.d.ts +44 -0
- package/lib/typescript/commonjs/ui/types/navigation.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/utils/crossOriginRestore.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/utils/deliveryPlatform.d.ts +33 -0
- package/lib/typescript/commonjs/ui/utils/deliveryPlatform.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/utils/oauthReturn.d.ts +30 -16
- package/lib/typescript/commonjs/ui/utils/oauthReturn.d.ts.map +1 -1
- package/lib/typescript/module/index.d.ts +4 -1
- package/lib/typescript/module/index.d.ts.map +1 -1
- package/lib/typescript/module/ui/boot/runProviderColdBoot.d.ts +34 -2
- package/lib/typescript/module/ui/boot/runProviderColdBoot.d.ts.map +1 -1
- package/lib/typescript/module/ui/client.d.ts +0 -1
- package/lib/typescript/module/ui/client.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/OxyAccountDialogScreen.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/OxyAuthChooser.d.ts +21 -29
- package/lib/typescript/module/ui/components/OxyAuthChooser.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/OxyConsentScreen.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/OxyProvider.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/OxySignInButton.d.ts +17 -12
- package/lib/typescript/module/ui/components/OxySignInButton.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/authChooser/AccountsMenuView.d.ts +38 -0
- package/lib/typescript/module/ui/components/authChooser/AccountsMenuView.d.ts.map +1 -0
- package/lib/typescript/module/ui/components/authChooser/SignInEntryView.d.ts +32 -0
- package/lib/typescript/module/ui/components/authChooser/SignInEntryView.d.ts.map +1 -0
- package/lib/typescript/module/ui/components/authChooser/SignInRequestView.d.ts +34 -0
- package/lib/typescript/module/ui/components/authChooser/SignInRequestView.d.ts.map +1 -0
- package/lib/typescript/module/ui/components/authChooser/SignUpView.d.ts +34 -0
- package/lib/typescript/module/ui/components/authChooser/SignUpView.d.ts.map +1 -0
- package/lib/typescript/module/ui/components/authChooser/TroubleDisclosure.d.ts +43 -0
- package/lib/typescript/module/ui/components/authChooser/TroubleDisclosure.d.ts.map +1 -0
- package/lib/typescript/module/ui/components/authChooser/primitives.d.ts +55 -0
- package/lib/typescript/module/ui/components/authChooser/primitives.d.ts.map +1 -0
- package/lib/typescript/module/ui/components/authChooser/requestSurfaces.d.ts +54 -0
- package/lib/typescript/module/ui/components/authChooser/requestSurfaces.d.ts.map +1 -0
- package/lib/typescript/module/ui/components/authChooser/signInProgress.d.ts +26 -0
- package/lib/typescript/module/ui/components/authChooser/signInProgress.d.ts.map +1 -0
- package/lib/typescript/{commonjs/ui/components/oxyAuthChooserStyles.d.ts → module/ui/components/authChooser/styles.d.ts} +19 -1
- package/lib/typescript/module/ui/components/authChooser/styles.d.ts.map +1 -0
- package/lib/typescript/module/ui/components/authChooser/types.d.ts +85 -0
- package/lib/typescript/module/ui/components/authChooser/types.d.ts.map +1 -0
- package/lib/typescript/module/ui/components/authChooser/useUsernameAvailability.d.ts +16 -0
- package/lib/typescript/module/ui/components/authChooser/useUsernameAvailability.d.ts.map +1 -0
- package/lib/typescript/module/ui/context/OxyContext.d.ts.map +1 -1
- package/lib/typescript/module/ui/context/commitSessionFlow.d.ts +40 -0
- package/lib/typescript/module/ui/context/commitSessionFlow.d.ts.map +1 -1
- package/lib/typescript/module/ui/context/hooks/useAuthOperations.d.ts +11 -2
- package/lib/typescript/module/ui/context/hooks/useAuthOperations.d.ts.map +1 -1
- package/lib/typescript/module/ui/context/oxyContextTypes.d.ts +44 -1
- package/lib/typescript/module/ui/context/oxyContextTypes.d.ts.map +1 -1
- package/lib/typescript/module/ui/context/useOxyAccountGraph.d.ts +7 -1
- package/lib/typescript/module/ui/context/useOxyAccountGraph.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/useSwitchableAccounts.d.ts.map +1 -1
- package/lib/typescript/module/ui/index.d.ts +0 -1
- package/lib/typescript/module/ui/index.d.ts.map +1 -1
- package/lib/typescript/module/ui/oauth/browserAuthTransport.d.ts +56 -0
- package/lib/typescript/module/ui/oauth/browserAuthTransport.d.ts.map +1 -0
- package/lib/typescript/module/ui/oauth/completeOAuthCode.d.ts +49 -0
- package/lib/typescript/module/ui/oauth/completeOAuthCode.d.ts.map +1 -0
- package/lib/typescript/module/ui/oauth/legacyRedirectLanes.d.ts +40 -0
- package/lib/typescript/module/ui/oauth/legacyRedirectLanes.d.ts.map +1 -0
- package/lib/typescript/module/ui/oauth/oauthHandshake.d.ts +50 -0
- package/lib/typescript/module/ui/oauth/oauthHandshake.d.ts.map +1 -0
- package/lib/typescript/module/ui/oauth/oauthPopup.d.ts +83 -0
- package/lib/typescript/module/ui/oauth/oauthPopup.d.ts.map +1 -0
- package/lib/typescript/module/ui/oauth/oauthPopupMessages.d.ts +67 -0
- package/lib/typescript/module/ui/oauth/oauthPopupMessages.d.ts.map +1 -0
- package/lib/typescript/module/ui/oauth/types.d.ts +176 -0
- package/lib/typescript/module/ui/oauth/types.d.ts.map +1 -0
- package/lib/typescript/module/ui/server.d.ts +0 -2
- package/lib/typescript/module/ui/server.d.ts.map +1 -1
- package/lib/typescript/module/ui/session/authStore.d.ts +3 -7
- package/lib/typescript/module/ui/session/authStore.d.ts.map +1 -1
- package/lib/typescript/module/ui/session/createSessionClient.d.ts +8 -1
- package/lib/typescript/module/ui/session/createSessionClient.d.ts.map +1 -1
- package/lib/typescript/module/ui/session/identityBinding.d.ts +66 -0
- package/lib/typescript/module/ui/session/identityBinding.d.ts.map +1 -0
- package/lib/typescript/module/ui/session/index.d.ts +6 -2
- package/lib/typescript/module/ui/session/index.d.ts.map +1 -1
- package/lib/typescript/module/ui/session/nativeSecureStorage.d.ts +25 -0
- package/lib/typescript/module/ui/session/nativeSecureStorage.d.ts.map +1 -0
- package/lib/typescript/module/ui/session/tokenTransport.d.ts +8 -1
- package/lib/typescript/module/ui/session/tokenTransport.d.ts.map +1 -1
- package/lib/typescript/module/ui/types/navigation.d.ts +44 -0
- package/lib/typescript/module/ui/types/navigation.d.ts.map +1 -1
- package/lib/typescript/module/ui/utils/crossOriginRestore.d.ts.map +1 -1
- package/lib/typescript/module/ui/utils/deliveryPlatform.d.ts +33 -0
- package/lib/typescript/module/ui/utils/deliveryPlatform.d.ts.map +1 -0
- package/lib/typescript/module/ui/utils/oauthReturn.d.ts +30 -16
- package/lib/typescript/module/ui/utils/oauthReturn.d.ts.map +1 -1
- package/package.json +6 -8
- package/src/index.ts +19 -5
- package/src/ui/boot/__tests__/coldBootWebAuthMode.test.ts +281 -0
- package/src/ui/boot/runProviderColdBoot.ts +83 -13
- package/src/ui/client.ts +0 -1
- package/src/ui/components/OxyAccountDialogScreen.tsx +33 -4
- package/src/ui/components/OxyAuthChooser.tsx +100 -1230
- package/src/ui/components/OxyConsentScreen.tsx +56 -13
- package/src/ui/components/OxyProvider.tsx +4 -4
- package/src/ui/components/OxySignInButton.tsx +119 -78
- package/src/ui/components/__tests__/OxyConsentScreen.test.tsx +27 -0
- package/src/ui/components/authChooser/AccountsMenuView.tsx +569 -0
- package/src/ui/components/authChooser/SignInEntryView.tsx +115 -0
- package/src/ui/components/authChooser/SignInRequestView.tsx +163 -0
- package/src/ui/components/authChooser/SignUpView.tsx +174 -0
- package/src/ui/components/authChooser/TroubleDisclosure.tsx +81 -0
- package/src/ui/components/authChooser/primitives.tsx +144 -0
- package/src/ui/components/authChooser/requestSurfaces.tsx +116 -0
- package/src/ui/components/authChooser/signInProgress.ts +54 -0
- package/src/ui/components/{oxyAuthChooserStyles.ts → authChooser/styles.ts} +18 -0
- package/src/ui/components/authChooser/types.ts +101 -0
- package/src/ui/components/authChooser/useUsernameAvailability.ts +60 -0
- package/src/ui/context/OxyContext.tsx +226 -24
- package/src/ui/context/__tests__/commitSessionFlow.test.ts +102 -0
- package/src/ui/context/commitSessionFlow.ts +64 -0
- package/src/ui/context/hooks/useAuthOperations.ts +26 -1
- package/src/ui/context/oxyContextTypes.ts +45 -1
- package/src/ui/context/useOxyAccountGraph.ts +19 -5
- package/src/ui/hooks/useSwitchableAccounts.ts +12 -1
- package/src/ui/index.ts +0 -1
- package/src/ui/oauth/__tests__/browserAuthTransport.test.ts +335 -0
- package/src/ui/oauth/__tests__/completeOAuthCode.test.ts +142 -0
- package/src/ui/oauth/__tests__/oauthPopup.test.ts +352 -0
- package/src/ui/oauth/__tests__/oauthPopupMessages.test.ts +189 -0
- package/src/ui/oauth/__tests__/sharedCompletionPath.test.ts +174 -0
- package/src/ui/oauth/browserAuthTransport.ts +193 -0
- package/src/ui/oauth/completeOAuthCode.ts +93 -0
- package/src/ui/oauth/legacyRedirectLanes.ts +43 -0
- package/src/ui/oauth/oauthHandshake.ts +74 -0
- package/src/ui/oauth/oauthPopup.ts +277 -0
- package/src/ui/oauth/oauthPopupMessages.ts +136 -0
- package/src/ui/oauth/types.ts +150 -0
- package/src/ui/server.ts +0 -2
- package/src/ui/session/__tests__/createSessionClient.test.ts +26 -0
- package/src/ui/session/__tests__/tokenTransport.test.ts +34 -0
- package/src/ui/session/authStore.ts +5 -89
- package/src/ui/session/createSessionClient.ts +15 -2
- package/src/ui/session/identityBinding.ts +116 -0
- package/src/ui/session/index.ts +6 -2
- package/src/ui/session/nativeSecureStorage.ts +98 -0
- package/src/ui/session/tokenTransport.ts +14 -1
- package/src/ui/types/navigation.ts +44 -1
- package/src/ui/utils/__tests__/crossOriginRestore.test.ts +17 -0
- package/src/ui/utils/crossOriginRestore.ts +9 -13
- package/src/ui/utils/deliveryPlatform.ts +65 -0
- package/src/ui/utils/oauthReturn.ts +79 -65
- package/lib/commonjs/assets/assets/fonts/Inter/Inter_18pt-Black.ttf +0 -0
- package/lib/commonjs/assets/assets/fonts/Inter/Inter_18pt-Bold.ttf +0 -0
- package/lib/commonjs/assets/assets/fonts/Inter/Inter_18pt-ExtraBold.ttf +0 -0
- package/lib/commonjs/assets/assets/fonts/Inter/Inter_18pt-Light.ttf +0 -0
- package/lib/commonjs/assets/assets/fonts/Inter/Inter_18pt-Medium.ttf +0 -0
- package/lib/commonjs/assets/assets/fonts/Inter/Inter_18pt-Regular.ttf +0 -0
- package/lib/commonjs/assets/assets/fonts/Inter/Inter_18pt-SemiBold.ttf +0 -0
- package/lib/commonjs/assets/fonts/Inter/Inter_18pt-Black.ttf +0 -0
- package/lib/commonjs/assets/fonts/Inter/Inter_18pt-Bold.ttf +0 -0
- package/lib/commonjs/assets/fonts/Inter/Inter_18pt-ExtraBold.ttf +0 -0
- package/lib/commonjs/assets/fonts/Inter/Inter_18pt-Light.ttf +0 -0
- package/lib/commonjs/assets/fonts/Inter/Inter_18pt-Medium.ttf +0 -0
- package/lib/commonjs/assets/fonts/Inter/Inter_18pt-Regular.ttf +0 -0
- package/lib/commonjs/assets/fonts/Inter/Inter_18pt-SemiBold.ttf +0 -0
- package/lib/commonjs/ui/components/FontLoader.js +0 -35
- package/lib/commonjs/ui/components/FontLoader.js.map +0 -1
- package/lib/commonjs/ui/components/FontLoader.native.js +0 -88
- package/lib/commonjs/ui/components/FontLoader.native.js.map +0 -1
- package/lib/commonjs/ui/components/oxyAuthChooserStyles.js.map +0 -1
- package/lib/module/assets/assets/fonts/Inter/Inter_18pt-Black.ttf +0 -0
- package/lib/module/assets/assets/fonts/Inter/Inter_18pt-Bold.ttf +0 -0
- package/lib/module/assets/assets/fonts/Inter/Inter_18pt-ExtraBold.ttf +0 -0
- package/lib/module/assets/assets/fonts/Inter/Inter_18pt-Light.ttf +0 -0
- package/lib/module/assets/assets/fonts/Inter/Inter_18pt-Medium.ttf +0 -0
- package/lib/module/assets/assets/fonts/Inter/Inter_18pt-Regular.ttf +0 -0
- package/lib/module/assets/assets/fonts/Inter/Inter_18pt-SemiBold.ttf +0 -0
- package/lib/module/assets/fonts/Inter/Inter_18pt-Black.ttf +0 -0
- package/lib/module/assets/fonts/Inter/Inter_18pt-Bold.ttf +0 -0
- package/lib/module/assets/fonts/Inter/Inter_18pt-ExtraBold.ttf +0 -0
- package/lib/module/assets/fonts/Inter/Inter_18pt-Light.ttf +0 -0
- package/lib/module/assets/fonts/Inter/Inter_18pt-Medium.ttf +0 -0
- package/lib/module/assets/fonts/Inter/Inter_18pt-Regular.ttf +0 -0
- package/lib/module/assets/fonts/Inter/Inter_18pt-SemiBold.ttf +0 -0
- package/lib/module/ui/components/FontLoader.js +0 -29
- package/lib/module/ui/components/FontLoader.js.map +0 -1
- package/lib/module/ui/components/FontLoader.native.js +0 -83
- package/lib/module/ui/components/FontLoader.native.js.map +0 -1
- package/lib/module/ui/components/oxyAuthChooserStyles.js.map +0 -1
- package/lib/typescript/commonjs/ui/components/FontLoader.d.ts +0 -24
- package/lib/typescript/commonjs/ui/components/FontLoader.d.ts.map +0 -1
- package/lib/typescript/commonjs/ui/components/FontLoader.native.d.ts +0 -13
- package/lib/typescript/commonjs/ui/components/FontLoader.native.d.ts.map +0 -1
- package/lib/typescript/commonjs/ui/components/oxyAuthChooserStyles.d.ts.map +0 -1
- package/lib/typescript/module/ui/components/FontLoader.d.ts +0 -24
- package/lib/typescript/module/ui/components/FontLoader.d.ts.map +0 -1
- package/lib/typescript/module/ui/components/FontLoader.native.d.ts +0 -13
- package/lib/typescript/module/ui/components/FontLoader.native.d.ts.map +0 -1
- package/lib/typescript/module/ui/components/oxyAuthChooserStyles.d.ts.map +0 -1
- package/src/assets/fonts/Inter/Inter_18pt-Black.ttf +0 -0
- package/src/assets/fonts/Inter/Inter_18pt-Bold.ttf +0 -0
- package/src/assets/fonts/Inter/Inter_18pt-ExtraBold.ttf +0 -0
- package/src/assets/fonts/Inter/Inter_18pt-Light.ttf +0 -0
- package/src/assets/fonts/Inter/Inter_18pt-Medium.ttf +0 -0
- package/src/assets/fonts/Inter/Inter_18pt-Regular.ttf +0 -0
- package/src/assets/fonts/Inter/Inter_18pt-SemiBold.ttf +0 -0
- package/src/ui/components/FontLoader.native.tsx +0 -88
- package/src/ui/components/FontLoader.tsx +0 -27
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Both web transports MUST finish through the same completion function.
|
|
3
|
+
*
|
|
4
|
+
* A duplicated exchange/commit implementation is how the popup and redirect
|
|
5
|
+
* lanes would silently drift apart on `state` validation, PKCE replay, or the
|
|
6
|
+
* session commit — so this suite mocks `completeOAuthCode` and proves each lane
|
|
7
|
+
* routes through it and performs no exchange of its own.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
jest.mock('../completeOAuthCode', () => ({
|
|
11
|
+
completeOAuthCode: jest.fn(),
|
|
12
|
+
}));
|
|
13
|
+
jest.mock('../../components/oauthNavigation', () => ({
|
|
14
|
+
redirectToAuthorize: jest.fn(),
|
|
15
|
+
}));
|
|
16
|
+
|
|
17
|
+
import type { OxyServices } from '@oxyhq/core';
|
|
18
|
+
import {
|
|
19
|
+
OXY_OAUTH_CODE_VERIFIER_STORAGE_KEY,
|
|
20
|
+
OXY_OAUTH_STATE_STORAGE_KEY,
|
|
21
|
+
} from '@oxyhq/core';
|
|
22
|
+
import { tryCompleteOAuthReturn } from '../../utils/oauthReturn';
|
|
23
|
+
import { startWebOAuthSignIn, type WebOAuthTransportContext } from '../browserAuthTransport';
|
|
24
|
+
import { completeOAuthCode } from '../completeOAuthCode';
|
|
25
|
+
import { OXY_OAUTH_CODE_MESSAGE_TYPE } from '../oauthPopupMessages';
|
|
26
|
+
import type { CompleteOAuthCodeInput } from '../completeOAuthCode';
|
|
27
|
+
import type { OAuthPopupHandle } from '../types';
|
|
28
|
+
|
|
29
|
+
const mockCompleteOAuthCode = completeOAuthCode as jest.Mock;
|
|
30
|
+
|
|
31
|
+
const CLIENT_ID = 'oxy_dk_test';
|
|
32
|
+
const REDIRECT_URI = 'https://mention.earth';
|
|
33
|
+
const IDP_ORIGIN = 'https://auth.oxy.so';
|
|
34
|
+
|
|
35
|
+
function fakePopup(): OAuthPopupHandle {
|
|
36
|
+
return { closed: false, close: jest.fn(), location: { href: '' } };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function makeContext(mode: 'popup' | 'redirect'): WebOAuthTransportContext & {
|
|
40
|
+
exchangeOAuthCode: jest.Mock;
|
|
41
|
+
} {
|
|
42
|
+
const exchangeOAuthCode = jest.fn();
|
|
43
|
+
return {
|
|
44
|
+
mode,
|
|
45
|
+
oxyServices: { exchangeOAuthCode } as unknown as OxyServices,
|
|
46
|
+
clientId: CLIENT_ID,
|
|
47
|
+
authorizeBaseUrl: `${IDP_ORIGIN}/authorize`,
|
|
48
|
+
identityBound: false,
|
|
49
|
+
commitSession: jest.fn().mockResolvedValue(undefined),
|
|
50
|
+
exchangeOAuthCode,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async function waitForAuthorizeUrl(popup: OAuthPopupHandle): Promise<URL> {
|
|
55
|
+
for (let attempt = 0; attempt < 100; attempt += 1) {
|
|
56
|
+
if (popup.location.href) return new URL(popup.location.href);
|
|
57
|
+
await new Promise((resolve) => {
|
|
58
|
+
setTimeout(resolve, 5);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
throw new Error('the popup was never navigated to the authorize URL');
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
describe('shared OAuth completion path', () => {
|
|
65
|
+
beforeEach(() => {
|
|
66
|
+
mockCompleteOAuthCode.mockReset();
|
|
67
|
+
mockCompleteOAuthCode.mockResolvedValue({ ok: true });
|
|
68
|
+
globalThis.sessionStorage?.clear();
|
|
69
|
+
window.history.replaceState({}, '', '/');
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('the popup transport completes through completeOAuthCode with its in-memory handshake', async () => {
|
|
73
|
+
const context = makeContext('popup');
|
|
74
|
+
const popup = fakePopup();
|
|
75
|
+
|
|
76
|
+
const pending = startWebOAuthSignIn(context, { redirectUri: REDIRECT_URI, popup });
|
|
77
|
+
const authorizeUrl = await waitForAuthorizeUrl(popup);
|
|
78
|
+
const state = authorizeUrl.searchParams.get('state');
|
|
79
|
+
const event = new Event('message');
|
|
80
|
+
Object.assign(event, {
|
|
81
|
+
data: { type: OXY_OAUTH_CODE_MESSAGE_TYPE, code: 'code-1', state },
|
|
82
|
+
origin: IDP_ORIGIN,
|
|
83
|
+
source: popup,
|
|
84
|
+
});
|
|
85
|
+
window.dispatchEvent(event);
|
|
86
|
+
|
|
87
|
+
await expect(pending).resolves.toEqual({ status: 'signed-in' });
|
|
88
|
+
|
|
89
|
+
expect(mockCompleteOAuthCode).toHaveBeenCalledTimes(1);
|
|
90
|
+
const input = mockCompleteOAuthCode.mock.calls[0][0] as CompleteOAuthCodeInput;
|
|
91
|
+
expect(input.code).toBe('code-1');
|
|
92
|
+
expect(input.clientId).toBe(CLIENT_ID);
|
|
93
|
+
expect(input.redirectUri).toBe(REDIRECT_URI);
|
|
94
|
+
expect(input.returnedState).toBe(state);
|
|
95
|
+
expect(input.handshake?.state).toBe(state);
|
|
96
|
+
expect(input.handshake?.codeVerifier).toEqual(expect.any(String));
|
|
97
|
+
// Nothing was persisted, so there is nothing for this lane to clean up.
|
|
98
|
+
expect(input.cleanup).toBeUndefined();
|
|
99
|
+
// The transport never exchanges the code itself.
|
|
100
|
+
expect(context.exchangeOAuthCode).not.toHaveBeenCalled();
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('the redirect return leg completes through completeOAuthCode with the persisted handshake', async () => {
|
|
104
|
+
const exchangeOAuthCode = jest.fn();
|
|
105
|
+
const oxyServices = { exchangeOAuthCode } as unknown as OxyServices;
|
|
106
|
+
sessionStorage.setItem(OXY_OAUTH_STATE_STORAGE_KEY, 'state-from-storage');
|
|
107
|
+
sessionStorage.setItem(OXY_OAUTH_CODE_VERIFIER_STORAGE_KEY, 'verifier-from-storage');
|
|
108
|
+
window.history.replaceState({}, '', '/feed?code=code-2&state=state-from-storage');
|
|
109
|
+
|
|
110
|
+
await expect(
|
|
111
|
+
tryCompleteOAuthReturn({
|
|
112
|
+
oxyServices,
|
|
113
|
+
clientId: CLIENT_ID,
|
|
114
|
+
authRedirectUri: REDIRECT_URI,
|
|
115
|
+
commitSession: jest.fn().mockResolvedValue(undefined),
|
|
116
|
+
}),
|
|
117
|
+
).resolves.toBe(true);
|
|
118
|
+
|
|
119
|
+
expect(mockCompleteOAuthCode).toHaveBeenCalledTimes(1);
|
|
120
|
+
const input = mockCompleteOAuthCode.mock.calls[0][0] as CompleteOAuthCodeInput;
|
|
121
|
+
expect(input.code).toBe('code-2');
|
|
122
|
+
expect(input.returnedState).toBe('state-from-storage');
|
|
123
|
+
expect(input.handshake).toEqual({
|
|
124
|
+
state: 'state-from-storage',
|
|
125
|
+
codeVerifier: 'verifier-from-storage',
|
|
126
|
+
});
|
|
127
|
+
expect(input.redirectUri).toBe(REDIRECT_URI);
|
|
128
|
+
// This lane DOES have persisted state + a dirty URL to clear.
|
|
129
|
+
expect(typeof input.cleanup).toBe('function');
|
|
130
|
+
// The return leg never exchanges the code itself.
|
|
131
|
+
expect(exchangeOAuthCode).not.toHaveBeenCalled();
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it('reports the shared path failing rather than committing a session', async () => {
|
|
135
|
+
mockCompleteOAuthCode.mockResolvedValue({ ok: false, reason: 'state-mismatch' });
|
|
136
|
+
sessionStorage.setItem(OXY_OAUTH_STATE_STORAGE_KEY, 'state-from-storage');
|
|
137
|
+
sessionStorage.setItem(OXY_OAUTH_CODE_VERIFIER_STORAGE_KEY, 'verifier-from-storage');
|
|
138
|
+
window.history.replaceState({}, '', '/?code=code-3&state=state-from-storage');
|
|
139
|
+
|
|
140
|
+
await expect(
|
|
141
|
+
tryCompleteOAuthReturn({
|
|
142
|
+
oxyServices: { exchangeOAuthCode: jest.fn() } as unknown as OxyServices,
|
|
143
|
+
clientId: CLIENT_ID,
|
|
144
|
+
commitSession: jest.fn().mockResolvedValue(undefined),
|
|
145
|
+
}),
|
|
146
|
+
).resolves.toBe(false);
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it('never reaches the shared path without a clientId', async () => {
|
|
150
|
+
window.history.replaceState({}, '', '/?code=code-4&state=state-from-storage');
|
|
151
|
+
|
|
152
|
+
await expect(
|
|
153
|
+
tryCompleteOAuthReturn({
|
|
154
|
+
oxyServices: { exchangeOAuthCode: jest.fn() } as unknown as OxyServices,
|
|
155
|
+
clientId: null,
|
|
156
|
+
commitSession: jest.fn().mockResolvedValue(undefined),
|
|
157
|
+
}),
|
|
158
|
+
).resolves.toBe(false);
|
|
159
|
+
expect(mockCompleteOAuthCode).not.toHaveBeenCalled();
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
it('never reaches the shared path when the IdP returned an error instead of a code', async () => {
|
|
163
|
+
window.history.replaceState({}, '', '/?error=access_denied&state=state-from-storage');
|
|
164
|
+
|
|
165
|
+
await expect(
|
|
166
|
+
tryCompleteOAuthReturn({
|
|
167
|
+
oxyServices: { exchangeOAuthCode: jest.fn() } as unknown as OxyServices,
|
|
168
|
+
clientId: CLIENT_ID,
|
|
169
|
+
commitSession: jest.fn().mockResolvedValue(undefined),
|
|
170
|
+
}),
|
|
171
|
+
).resolves.toBe(false);
|
|
172
|
+
expect(mockCompleteOAuthCode).not.toHaveBeenCalled();
|
|
173
|
+
});
|
|
174
|
+
});
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The single web entry point for third-party "Sign in with Oxy".
|
|
3
|
+
*
|
|
4
|
+
* Picks the transport (`popup` or `redirect`), drives it, and returns ONE typed
|
|
5
|
+
* result — so callers (`OxySignInButton`, and any RP with its own button) never
|
|
6
|
+
* touch `window.open`, `postMessage`, or the token exchange themselves.
|
|
7
|
+
*
|
|
8
|
+
* Popup mode keeps the relying party mounted: its route, scroll position, and
|
|
9
|
+
* unsaved state survive because the tab never navigates. Redirect mode is the
|
|
10
|
+
* compatibility fallback, and is also where popup mode lands when the browser
|
|
11
|
+
* blocks the window — a blocked popup must still sign the user in, not dead-end.
|
|
12
|
+
*
|
|
13
|
+
* Native is NOT handled here: `openAuthorizeUrlNative` (an in-app auth session)
|
|
14
|
+
* remains the native lane and is untouched by this module.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { logger, persistOAuthHandshake } from '@oxyhq/core';
|
|
18
|
+
import type { OxyServices } from '@oxyhq/core';
|
|
19
|
+
import { redirectToAuthorize } from '../components/oauthNavigation';
|
|
20
|
+
import { isWebBrowser } from '../utils/isWebBrowser';
|
|
21
|
+
import { completeOAuthCode } from './completeOAuthCode';
|
|
22
|
+
import { prepareAuthorizeRequest } from './oauthHandshake';
|
|
23
|
+
import { awaitOAuthPopupResult, closeOAuthPopup, navigateOAuthPopup, openOAuthPopup } from './oauthPopup';
|
|
24
|
+
import type {
|
|
25
|
+
OAuthPopupHandle,
|
|
26
|
+
OAuthSessionCommitInput,
|
|
27
|
+
WebAuthMode,
|
|
28
|
+
WebOAuthRedirectReason,
|
|
29
|
+
WebOAuthSignInResult,
|
|
30
|
+
} from './types';
|
|
31
|
+
|
|
32
|
+
/** Provider-owned wiring for a web sign-in — everything that is not per-press. */
|
|
33
|
+
export interface WebOAuthTransportContext {
|
|
34
|
+
/** The provider's `webAuthMode`. */
|
|
35
|
+
mode: WebAuthMode;
|
|
36
|
+
oxyServices: OxyServices;
|
|
37
|
+
/** The app's registered client id; `null` disables third-party sign-in. */
|
|
38
|
+
clientId: string | null;
|
|
39
|
+
/** Authorize endpoint override (local/staging deployments). */
|
|
40
|
+
authorizeBaseUrl?: string;
|
|
41
|
+
/** `sessionMode: 'identity'` — no third-party OAuth lane exists by design. */
|
|
42
|
+
identityBound: boolean;
|
|
43
|
+
/** The provider's session commit funnel. */
|
|
44
|
+
commitSession: (input: OAuthSessionCommitInput) => Promise<void>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Per-press inputs for {@link startWebOAuthSignIn}. */
|
|
48
|
+
export interface StartWebOAuthSignInOptions {
|
|
49
|
+
/** EXACT registered redirect URI for this application. */
|
|
50
|
+
redirectUri: string;
|
|
51
|
+
/**
|
|
52
|
+
* The popup to drive, when the caller already opened one.
|
|
53
|
+
*
|
|
54
|
+
* - omitted — this call opens the window itself, which is only valid when it
|
|
55
|
+
* was invoked SYNCHRONOUSLY from the user's click (gesture attribution);
|
|
56
|
+
* - `null` — the caller tried and the browser blocked it: fall back to a
|
|
57
|
+
* full-page redirect;
|
|
58
|
+
* - a handle — use exactly this window.
|
|
59
|
+
*
|
|
60
|
+
* Callers that must `await` before signing in (resolving the application, for
|
|
61
|
+
* instance) have to open the window in their press handler and pass it here;
|
|
62
|
+
* a window opened after an `await` is silently blocked by every browser.
|
|
63
|
+
*/
|
|
64
|
+
popup?: OAuthPopupHandle | null;
|
|
65
|
+
/** Requested scope; defaults to the SDK's standard sign-in scope. */
|
|
66
|
+
scope?: string;
|
|
67
|
+
/** Popup timeout override (ms). */
|
|
68
|
+
timeoutMs?: number;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export async function startWebOAuthSignIn(
|
|
72
|
+
context: WebOAuthTransportContext,
|
|
73
|
+
options: StartWebOAuthSignInOptions,
|
|
74
|
+
): Promise<WebOAuthSignInResult> {
|
|
75
|
+
if (!isWebBrowser()) {
|
|
76
|
+
closeOAuthPopup(options.popup ?? null);
|
|
77
|
+
return { status: 'unsupported', reason: 'no-browser' };
|
|
78
|
+
}
|
|
79
|
+
if (context.identityBound) {
|
|
80
|
+
closeOAuthPopup(options.popup ?? null);
|
|
81
|
+
return { status: 'unsupported', reason: 'identity-bound' };
|
|
82
|
+
}
|
|
83
|
+
if (!context.clientId) {
|
|
84
|
+
closeOAuthPopup(options.popup ?? null);
|
|
85
|
+
return { status: 'unsupported', reason: 'missing-client-id' };
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Claim the window BEFORE the first `await` below, so a caller that invoked us
|
|
89
|
+
// straight from the click still has gesture attribution. An explicit `null`
|
|
90
|
+
// means the caller already tried and was blocked.
|
|
91
|
+
const popup =
|
|
92
|
+
context.mode === 'popup' && options.popup === undefined ? openOAuthPopup() : options.popup ?? null;
|
|
93
|
+
|
|
94
|
+
if (context.mode === 'redirect') {
|
|
95
|
+
closeOAuthPopup(popup);
|
|
96
|
+
return startRedirectSignIn(context, options, 'redirect-mode');
|
|
97
|
+
}
|
|
98
|
+
if (!popup) {
|
|
99
|
+
logger.warn('OAuth sign-in popup was blocked; falling back to a full-page redirect', {
|
|
100
|
+
component: 'browserAuthTransport',
|
|
101
|
+
});
|
|
102
|
+
return startRedirectSignIn(context, options, 'popup-blocked');
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
try {
|
|
106
|
+
const prepared = await prepareAuthorizeRequest({
|
|
107
|
+
clientId: context.clientId,
|
|
108
|
+
redirectUri: options.redirectUri,
|
|
109
|
+
authorizeBaseUrl: context.authorizeBaseUrl,
|
|
110
|
+
scope: options.scope,
|
|
111
|
+
responseMode: 'web_message',
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
if (!navigateOAuthPopup(popup, prepared.authorizeUrl)) {
|
|
115
|
+
return startRedirectSignIn(context, options, 'popup-navigation-failed');
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const outcome = await awaitOAuthPopupResult({
|
|
119
|
+
popup,
|
|
120
|
+
expectedOrigin: prepared.authorizeOrigin,
|
|
121
|
+
expectedState: prepared.handshake.state,
|
|
122
|
+
redirectUri: options.redirectUri,
|
|
123
|
+
...(options.timeoutMs !== undefined ? { timeoutMs: options.timeoutMs } : {}),
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
switch (outcome.kind) {
|
|
127
|
+
case 'code': {
|
|
128
|
+
const completion = await completeOAuthCode({
|
|
129
|
+
oxyServices: context.oxyServices,
|
|
130
|
+
clientId: context.clientId,
|
|
131
|
+
code: outcome.code,
|
|
132
|
+
returnedState: outcome.state,
|
|
133
|
+
handshake: prepared.handshake,
|
|
134
|
+
redirectUri: options.redirectUri,
|
|
135
|
+
commitSession: context.commitSession,
|
|
136
|
+
});
|
|
137
|
+
return completion.ok
|
|
138
|
+
? { status: 'signed-in' }
|
|
139
|
+
: { status: 'failed', reason: completion.reason };
|
|
140
|
+
}
|
|
141
|
+
case 'oauth-error':
|
|
142
|
+
return {
|
|
143
|
+
status: 'failed',
|
|
144
|
+
reason: 'idp-error',
|
|
145
|
+
description: outcome.errorDescription ?? outcome.error,
|
|
146
|
+
};
|
|
147
|
+
case 'state-mismatch':
|
|
148
|
+
return { status: 'failed', reason: 'state-mismatch' };
|
|
149
|
+
case 'closed':
|
|
150
|
+
return { status: 'cancelled' };
|
|
151
|
+
case 'timed-out':
|
|
152
|
+
return { status: 'timed-out' };
|
|
153
|
+
case 'unsupported':
|
|
154
|
+
return { status: 'unsupported', reason: 'no-browser' };
|
|
155
|
+
}
|
|
156
|
+
} finally {
|
|
157
|
+
// Covers throws after open (prepare/exchange/commit) and every settled outcome.
|
|
158
|
+
closeOAuthPopup(popup);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Full-page hand-off to the IdP. The document is destroyed by the navigation, so
|
|
164
|
+
* the handshake MUST reach `sessionStorage` first — without it the return trip
|
|
165
|
+
* cannot validate `state`, and starting the redirect anyway would strand the
|
|
166
|
+
* user at a callback that can only refuse them.
|
|
167
|
+
*/
|
|
168
|
+
async function startRedirectSignIn(
|
|
169
|
+
context: WebOAuthTransportContext,
|
|
170
|
+
options: StartWebOAuthSignInOptions,
|
|
171
|
+
via: WebOAuthRedirectReason,
|
|
172
|
+
): Promise<WebOAuthSignInResult> {
|
|
173
|
+
// Narrowed by the caller; repeated here so this helper is safe on its own.
|
|
174
|
+
if (!context.clientId) return { status: 'unsupported', reason: 'missing-client-id' };
|
|
175
|
+
|
|
176
|
+
const prepared = await prepareAuthorizeRequest({
|
|
177
|
+
clientId: context.clientId,
|
|
178
|
+
redirectUri: options.redirectUri,
|
|
179
|
+
authorizeBaseUrl: context.authorizeBaseUrl,
|
|
180
|
+
scope: options.scope,
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
if (!persistOAuthHandshake(
|
|
184
|
+
prepared.handshake.state,
|
|
185
|
+
prepared.handshake.codeVerifier,
|
|
186
|
+
options.redirectUri,
|
|
187
|
+
)) {
|
|
188
|
+
return { status: 'failed', reason: 'handshake-storage' };
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
redirectToAuthorize(prepared.authorizeUrl);
|
|
192
|
+
return { status: 'redirecting', via };
|
|
193
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The ONE path from an OAuth authorization code to a committed session.
|
|
3
|
+
*
|
|
4
|
+
* Both web transports end here — the popup with an in-memory handshake, the
|
|
5
|
+
* redirect lane with one read back from `sessionStorage` — so state validation,
|
|
6
|
+
* the PKCE exchange, the session commit, and handshake cleanup exist exactly
|
|
7
|
+
* once. Duplicating any of those per transport is how the two lanes would drift
|
|
8
|
+
* apart on the security-critical steps.
|
|
9
|
+
*
|
|
10
|
+
* Ordering is deliberate and load-bearing:
|
|
11
|
+
* 1. validate `state` BEFORE anything is sent to the token endpoint,
|
|
12
|
+
* 2. exchange the code for a session,
|
|
13
|
+
* 3. run `cleanup` (drop the persisted handshake / strip `?code=` from the
|
|
14
|
+
* URL) BEFORE the commit, so a stale code can never re-enter the exchange,
|
|
15
|
+
* 4. commit the session.
|
|
16
|
+
*
|
|
17
|
+
* `cleanup` runs exactly once on EVERY exit path, including a state mismatch
|
|
18
|
+
* and a failed exchange.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import type { OxyServices } from '@oxyhq/core';
|
|
22
|
+
import { logger } from '@oxyhq/core';
|
|
23
|
+
import type { OAuthCompletionResult, OAuthHandshake, OAuthSessionCommitInput } from './types';
|
|
24
|
+
|
|
25
|
+
/** Inputs for {@link completeOAuthCode}. */
|
|
26
|
+
export interface CompleteOAuthCodeInput {
|
|
27
|
+
oxyServices: OxyServices;
|
|
28
|
+
/** The registered `ApplicationCredential` public key (`oxy_dk_…`). */
|
|
29
|
+
clientId: string;
|
|
30
|
+
/** The single-use authorization code the IdP issued. */
|
|
31
|
+
code: string;
|
|
32
|
+
/** The `state` the IdP returned, or `null` when it sent none. */
|
|
33
|
+
returnedState: string | null;
|
|
34
|
+
/**
|
|
35
|
+
* The handshake this RP started the authorize request with, or `null` when it
|
|
36
|
+
* is gone (never stored, expired, or a different tab's). A missing handshake
|
|
37
|
+
* is treated exactly like a mismatched `state`: no exchange is attempted.
|
|
38
|
+
*/
|
|
39
|
+
handshake: OAuthHandshake | null;
|
|
40
|
+
/** EXACT redirect URI sent on the authorize request — OAuth requires a match. */
|
|
41
|
+
redirectUri: string;
|
|
42
|
+
/** The provider's session commit funnel. */
|
|
43
|
+
commitSession: (input: OAuthSessionCommitInput) => Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Transport-specific teardown, invoked once after the exchange settles and
|
|
46
|
+
* before the commit. The redirect lane strips `?code=` and clears the
|
|
47
|
+
* persisted handshake; the popup lane has nothing persisted and omits it.
|
|
48
|
+
*/
|
|
49
|
+
cleanup?: () => void;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export async function completeOAuthCode(
|
|
53
|
+
input: CompleteOAuthCodeInput,
|
|
54
|
+
): Promise<OAuthCompletionResult> {
|
|
55
|
+
let cleaned = false;
|
|
56
|
+
const runCleanup = (): void => {
|
|
57
|
+
if (cleaned) return;
|
|
58
|
+
cleaned = true;
|
|
59
|
+
input.cleanup?.();
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
if (!input.handshake || !input.returnedState || input.handshake.state !== input.returnedState) {
|
|
63
|
+
logger.warn('OAuth completion rejected: missing or mismatched state', {
|
|
64
|
+
component: 'completeOAuthCode',
|
|
65
|
+
});
|
|
66
|
+
runCleanup();
|
|
67
|
+
return { ok: false, reason: 'state-mismatch' };
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
try {
|
|
71
|
+
const result = await input.oxyServices.exchangeOAuthCode({
|
|
72
|
+
code: input.code,
|
|
73
|
+
clientId: input.clientId,
|
|
74
|
+
redirectUri: input.redirectUri,
|
|
75
|
+
codeVerifier: input.handshake.codeVerifier,
|
|
76
|
+
});
|
|
77
|
+
runCleanup();
|
|
78
|
+
await input.commitSession({
|
|
79
|
+
sessionId: result.sessionId,
|
|
80
|
+
accessToken: result.accessToken,
|
|
81
|
+
deviceId: result.deviceId,
|
|
82
|
+
deviceSecret: result.deviceSecret,
|
|
83
|
+
userId: result.user.id,
|
|
84
|
+
expiresAt: result.expiresAt,
|
|
85
|
+
user: result.user,
|
|
86
|
+
});
|
|
87
|
+
return { ok: true };
|
|
88
|
+
} catch (error) {
|
|
89
|
+
logger.warn('OAuth code exchange failed', { component: 'completeOAuthCode' }, error);
|
|
90
|
+
runCleanup();
|
|
91
|
+
return { ok: false, reason: 'exchange-failed' };
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The legacy, redirect-mode-only lanes that navigate the RP's TOP-LEVEL window
|
|
3
|
+
* to the IdP without a user gesture.
|
|
4
|
+
*
|
|
5
|
+
* `webAuthMode: 'popup'` exists to guarantee exactly one thing: the relying
|
|
6
|
+
* party never leaves its route. Two mechanics in this SDK break that guarantee,
|
|
7
|
+
* because each replaces the whole document on its own initiative:
|
|
8
|
+
*
|
|
9
|
+
* 1. **Cold-boot silent restore** — a full-page `prompt=none` authorize bounce
|
|
10
|
+
* to `auth.oxy.so` when the device-secret mint finds no local session
|
|
11
|
+
* (`maybeStartSilentOAuthRestore`, called from `runProviderColdBoot`).
|
|
12
|
+
* 2. **Post-sign-in hub sync** — a full-page hop to `auth.oxy.so/sync` that
|
|
13
|
+
* plants this device's credential on the IdP hub so OTHER origins can later
|
|
14
|
+
* run lane 1 (`syncHubAfterSignIn`, called from the `commitSession` funnel).
|
|
15
|
+
*
|
|
16
|
+
* Both belong to the redirect transport and are kept only for the migration
|
|
17
|
+
* window (issue #691, "Cold boot and cross-domain behavior"). In popup mode a
|
|
18
|
+
* domain with no local credential simply resolves SIGNED OUT, and the user's
|
|
19
|
+
* next explicit "Continue with Oxy" opens the popup — from a real user gesture,
|
|
20
|
+
* never automatically.
|
|
21
|
+
*
|
|
22
|
+
* NOT covered here, and correctly enabled in BOTH modes: navigations the user
|
|
23
|
+
* asked for. When the browser blocks the popup, `startWebOAuthSignIn` still
|
|
24
|
+
* falls back to a full-page redirect rather than dead-ending the sign-in, and
|
|
25
|
+
* `tryCompleteOAuthReturn` still consumes a `?code=` that is already on the URL.
|
|
26
|
+
*
|
|
27
|
+
* PHASE 7b: once the pilot flips the default transport to `'popup'`, this
|
|
28
|
+
* predicate and BOTH lanes above are deleted outright. Grepping this symbol
|
|
29
|
+
* finds every site that has to go.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
import type { WebAuthMode } from './types';
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Whether a provider running `webAuthMode` may perform an SDK-initiated,
|
|
36
|
+
* non-gesture, full-page navigation to the IdP.
|
|
37
|
+
*
|
|
38
|
+
* `true` only for `'redirect'` — still the default and the compatibility path,
|
|
39
|
+
* whose behaviour must stay byte-for-byte unchanged.
|
|
40
|
+
*/
|
|
41
|
+
export function allowsAutomaticIdpRedirect(webAuthMode: WebAuthMode): boolean {
|
|
42
|
+
return webAuthMode === 'redirect';
|
|
43
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The RP half of an OAuth authorize request: a fresh CSRF `state` + PKCE pair,
|
|
3
|
+
* and the authorize URL built from them.
|
|
4
|
+
*
|
|
5
|
+
* Both web transports start here, and the ONLY difference between them is one
|
|
6
|
+
* parameter: `popup` asks the IdP for `response_mode=web_message` so the result
|
|
7
|
+
* comes back to `window.opener` instead of navigating the RP's tab. Everything
|
|
8
|
+
* else — `S256` PKCE, exact registered `redirect_uri`, random `state` — is
|
|
9
|
+
* identical, which is what lets both lanes converge on one completion path.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { buildOAuthAuthorizeUrl, generateOAuthState, generatePkcePair } from '@oxyhq/core';
|
|
13
|
+
import type { OAuthHandshake } from './types';
|
|
14
|
+
|
|
15
|
+
/** Inputs for {@link prepareAuthorizeRequest}. */
|
|
16
|
+
export interface PrepareAuthorizeRequestParams {
|
|
17
|
+
/** The registered `ApplicationCredential` public key (`oxy_dk_…`). */
|
|
18
|
+
clientId: string;
|
|
19
|
+
/** EXACT registered redirect URI. The token exchange must replay this value. */
|
|
20
|
+
redirectUri: string;
|
|
21
|
+
/** Authorize endpoint override; defaults to the production Oxy IdP. */
|
|
22
|
+
authorizeBaseUrl?: string;
|
|
23
|
+
/** Requested scope; defaults to the SDK's standard sign-in scope. */
|
|
24
|
+
scope?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Ask the IdP to deliver the result to `window.opener` via `postMessage`
|
|
27
|
+
* instead of redirecting. Set ONLY by the popup transport. It is a request,
|
|
28
|
+
* not a guarantee — an IdP with no opener still redirects.
|
|
29
|
+
*/
|
|
30
|
+
responseMode?: 'web_message';
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** A ready-to-use authorize request plus the secrets that finish it. */
|
|
34
|
+
export interface PreparedAuthorizeRequest {
|
|
35
|
+
/** Fully-built `auth.oxy.so/authorize` URL. */
|
|
36
|
+
authorizeUrl: string;
|
|
37
|
+
/**
|
|
38
|
+
* Exact origin of {@link authorizeUrl}. The popup transport accepts
|
|
39
|
+
* `postMessage` from this origin and no other.
|
|
40
|
+
*/
|
|
41
|
+
authorizeOrigin: string;
|
|
42
|
+
/** The `state` + PKCE verifier this request is bound to. */
|
|
43
|
+
handshake: OAuthHandshake;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Generate a fresh handshake and build the authorize URL around it.
|
|
48
|
+
*
|
|
49
|
+
* The verifier is returned to the caller and never stored here: the popup
|
|
50
|
+
* transport keeps it in memory for the lifetime of the attempt, and the
|
|
51
|
+
* redirect transport persists it through `persistOAuthHandshake` because a
|
|
52
|
+
* full-page navigation destroys the running document.
|
|
53
|
+
*/
|
|
54
|
+
export async function prepareAuthorizeRequest(
|
|
55
|
+
params: PrepareAuthorizeRequestParams,
|
|
56
|
+
): Promise<PreparedAuthorizeRequest> {
|
|
57
|
+
const [pkce, state] = await Promise.all([generatePkcePair(), generateOAuthState()]);
|
|
58
|
+
|
|
59
|
+
const authorizeUrl = buildOAuthAuthorizeUrl({
|
|
60
|
+
authorizeBaseUrl: params.authorizeBaseUrl,
|
|
61
|
+
clientId: params.clientId,
|
|
62
|
+
redirectUri: params.redirectUri,
|
|
63
|
+
scope: params.scope,
|
|
64
|
+
state,
|
|
65
|
+
codeChallenge: pkce.codeChallenge,
|
|
66
|
+
...(params.responseMode ? { responseMode: params.responseMode } : {}),
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
return {
|
|
70
|
+
authorizeUrl,
|
|
71
|
+
authorizeOrigin: new URL(authorizeUrl).origin,
|
|
72
|
+
handshake: { state, codeVerifier: pkce.codeVerifier },
|
|
73
|
+
};
|
|
74
|
+
}
|