@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,142 @@
|
|
|
1
|
+
import type { OxyServices } from '@oxyhq/core';
|
|
2
|
+
import { completeOAuthCode } from '../completeOAuthCode';
|
|
3
|
+
import type { OAuthSessionCommitInput } from '../types';
|
|
4
|
+
|
|
5
|
+
const HANDSHAKE = { state: 'state-abc', codeVerifier: 'verifier-xyz' };
|
|
6
|
+
const REDIRECT_URI = 'https://mention.earth';
|
|
7
|
+
|
|
8
|
+
const SESSION = {
|
|
9
|
+
sessionId: 'sess-1',
|
|
10
|
+
deviceId: 'dev-1',
|
|
11
|
+
deviceSecret: 'secret-1',
|
|
12
|
+
accessToken: 'token-1',
|
|
13
|
+
expiresAt: '2099-01-01T00:00:00.000Z',
|
|
14
|
+
user: { id: 'user-1', username: 'nate', avatar: 'a1' },
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
function makeOxyServices(exchange: jest.Mock): OxyServices {
|
|
18
|
+
return { exchangeOAuthCode: exchange } as unknown as OxyServices;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
describe('completeOAuthCode', () => {
|
|
22
|
+
it('exchanges the code and commits the session it returns', async () => {
|
|
23
|
+
const exchange = jest.fn().mockResolvedValue(SESSION);
|
|
24
|
+
const committed: OAuthSessionCommitInput[] = [];
|
|
25
|
+
|
|
26
|
+
const result = await completeOAuthCode({
|
|
27
|
+
oxyServices: makeOxyServices(exchange),
|
|
28
|
+
clientId: 'oxy_dk_test',
|
|
29
|
+
code: 'code-1',
|
|
30
|
+
returnedState: HANDSHAKE.state,
|
|
31
|
+
handshake: HANDSHAKE,
|
|
32
|
+
redirectUri: REDIRECT_URI,
|
|
33
|
+
commitSession: async (input) => {
|
|
34
|
+
committed.push(input);
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
expect(result).toEqual({ ok: true });
|
|
39
|
+
expect(exchange).toHaveBeenCalledWith({
|
|
40
|
+
code: 'code-1',
|
|
41
|
+
clientId: 'oxy_dk_test',
|
|
42
|
+
redirectUri: REDIRECT_URI,
|
|
43
|
+
codeVerifier: HANDSHAKE.codeVerifier,
|
|
44
|
+
});
|
|
45
|
+
expect(committed).toEqual([
|
|
46
|
+
{
|
|
47
|
+
sessionId: 'sess-1',
|
|
48
|
+
accessToken: 'token-1',
|
|
49
|
+
deviceId: 'dev-1',
|
|
50
|
+
deviceSecret: 'secret-1',
|
|
51
|
+
userId: 'user-1',
|
|
52
|
+
expiresAt: '2099-01-01T00:00:00.000Z',
|
|
53
|
+
user: SESSION.user,
|
|
54
|
+
},
|
|
55
|
+
]);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('cleans up BEFORE committing, so a stale code cannot re-enter the exchange', async () => {
|
|
59
|
+
const order: string[] = [];
|
|
60
|
+
const result = await completeOAuthCode({
|
|
61
|
+
oxyServices: makeOxyServices(jest.fn().mockResolvedValue(SESSION)),
|
|
62
|
+
clientId: 'oxy_dk_test',
|
|
63
|
+
code: 'code-1',
|
|
64
|
+
returnedState: HANDSHAKE.state,
|
|
65
|
+
handshake: HANDSHAKE,
|
|
66
|
+
redirectUri: REDIRECT_URI,
|
|
67
|
+
commitSession: async () => {
|
|
68
|
+
order.push('commit');
|
|
69
|
+
},
|
|
70
|
+
cleanup: () => {
|
|
71
|
+
order.push('cleanup');
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
expect(result).toEqual({ ok: true });
|
|
76
|
+
expect(order).toEqual(['cleanup', 'commit']);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it.each([
|
|
80
|
+
['a mismatched state', 'someone-elses-state', HANDSHAKE],
|
|
81
|
+
['no returned state', null, HANDSHAKE],
|
|
82
|
+
['no stored handshake', HANDSHAKE.state, null],
|
|
83
|
+
])('refuses to exchange the code with %s', async (_label, returnedState, handshake) => {
|
|
84
|
+
const exchange = jest.fn();
|
|
85
|
+
const commitSession = jest.fn();
|
|
86
|
+
const cleanup = jest.fn();
|
|
87
|
+
|
|
88
|
+
const result = await completeOAuthCode({
|
|
89
|
+
oxyServices: makeOxyServices(exchange),
|
|
90
|
+
clientId: 'oxy_dk_test',
|
|
91
|
+
code: 'code-1',
|
|
92
|
+
returnedState,
|
|
93
|
+
handshake,
|
|
94
|
+
redirectUri: REDIRECT_URI,
|
|
95
|
+
commitSession,
|
|
96
|
+
cleanup,
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
expect(result).toEqual({ ok: false, reason: 'state-mismatch' });
|
|
100
|
+
expect(exchange).not.toHaveBeenCalled();
|
|
101
|
+
expect(commitSession).not.toHaveBeenCalled();
|
|
102
|
+
expect(cleanup).toHaveBeenCalledTimes(1);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it('reports a failed exchange without throwing, and still cleans up', async () => {
|
|
106
|
+
const cleanup = jest.fn();
|
|
107
|
+
const commitSession = jest.fn();
|
|
108
|
+
|
|
109
|
+
const result = await completeOAuthCode({
|
|
110
|
+
oxyServices: makeOxyServices(jest.fn().mockRejectedValue(new Error('invalid_grant'))),
|
|
111
|
+
clientId: 'oxy_dk_test',
|
|
112
|
+
code: 'code-1',
|
|
113
|
+
returnedState: HANDSHAKE.state,
|
|
114
|
+
handshake: HANDSHAKE,
|
|
115
|
+
redirectUri: REDIRECT_URI,
|
|
116
|
+
commitSession,
|
|
117
|
+
cleanup,
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
expect(result).toEqual({ ok: false, reason: 'exchange-failed' });
|
|
121
|
+
expect(commitSession).not.toHaveBeenCalled();
|
|
122
|
+
expect(cleanup).toHaveBeenCalledTimes(1);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
it('reports a failed commit without throwing, and cleans up exactly once', async () => {
|
|
126
|
+
const cleanup = jest.fn();
|
|
127
|
+
|
|
128
|
+
const result = await completeOAuthCode({
|
|
129
|
+
oxyServices: makeOxyServices(jest.fn().mockResolvedValue(SESSION)),
|
|
130
|
+
clientId: 'oxy_dk_test',
|
|
131
|
+
code: 'code-1',
|
|
132
|
+
returnedState: HANDSHAKE.state,
|
|
133
|
+
handshake: HANDSHAKE,
|
|
134
|
+
redirectUri: REDIRECT_URI,
|
|
135
|
+
commitSession: jest.fn().mockRejectedValue(new Error('commit blew up')),
|
|
136
|
+
cleanup,
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
expect(result).toEqual({ ok: false, reason: 'exchange-failed' });
|
|
140
|
+
expect(cleanup).toHaveBeenCalledTimes(1);
|
|
141
|
+
});
|
|
142
|
+
});
|
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
import {
|
|
2
|
+
awaitOAuthPopupResult,
|
|
3
|
+
closeOAuthPopup,
|
|
4
|
+
navigateOAuthPopup,
|
|
5
|
+
openOAuthPopup,
|
|
6
|
+
OXY_OAUTH_POPUP_WINDOW_NAME,
|
|
7
|
+
} from '../oauthPopup';
|
|
8
|
+
import { OXY_OAUTH_CODE_MESSAGE_TYPE, OXY_OAUTH_ERROR_MESSAGE_TYPE } from '../oauthPopupMessages';
|
|
9
|
+
import type { OAuthPopupHandle, OAuthPopupOutcome } from '../types';
|
|
10
|
+
|
|
11
|
+
const IDP_ORIGIN = 'https://auth.oxy.so';
|
|
12
|
+
const REDIRECT_URI = 'https://mention.earth';
|
|
13
|
+
const STATE = 'state-abc';
|
|
14
|
+
|
|
15
|
+
interface ControllablePopup extends OAuthPopupHandle {
|
|
16
|
+
close: jest.Mock;
|
|
17
|
+
setClosed: () => void;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function fakePopup(): ControllablePopup {
|
|
21
|
+
let closed = false;
|
|
22
|
+
return {
|
|
23
|
+
get closed() {
|
|
24
|
+
return closed;
|
|
25
|
+
},
|
|
26
|
+
close: jest.fn(() => {
|
|
27
|
+
closed = true;
|
|
28
|
+
}),
|
|
29
|
+
location: { href: '' },
|
|
30
|
+
setClosed: () => {
|
|
31
|
+
closed = true;
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function dispatchMessage(init: { data: unknown; origin: string; source: unknown }): void {
|
|
37
|
+
const event = new Event('message');
|
|
38
|
+
Object.assign(event, init);
|
|
39
|
+
window.dispatchEvent(event);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function codeMessage(source: unknown, state = STATE, origin = IDP_ORIGIN) {
|
|
43
|
+
return {
|
|
44
|
+
data: { type: OXY_OAUTH_CODE_MESSAGE_TYPE, code: 'code-1', state },
|
|
45
|
+
origin,
|
|
46
|
+
source,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Resolve the outcome, or `'pending'` when the promise has not settled yet. */
|
|
51
|
+
async function outcomeOrPending(
|
|
52
|
+
promise: Promise<OAuthPopupOutcome>,
|
|
53
|
+
): Promise<OAuthPopupOutcome | 'pending'> {
|
|
54
|
+
return Promise.race([
|
|
55
|
+
promise,
|
|
56
|
+
Promise.resolve().then(() => 'pending' as const),
|
|
57
|
+
]);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
describe('openOAuthPopup', () => {
|
|
61
|
+
afterEach(() => {
|
|
62
|
+
jest.restoreAllMocks();
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('opens an empty, named window so a second press reuses it', () => {
|
|
66
|
+
const handle = fakePopup();
|
|
67
|
+
const openSpy = jest
|
|
68
|
+
.spyOn(window, 'open')
|
|
69
|
+
.mockReturnValue(handle as unknown as Window);
|
|
70
|
+
|
|
71
|
+
expect(openOAuthPopup()).toBe(handle);
|
|
72
|
+
expect(openSpy).toHaveBeenCalledWith('', OXY_OAUTH_POPUP_WINDOW_NAME, expect.any(String));
|
|
73
|
+
// The window is navigated later, once the authorize URL exists.
|
|
74
|
+
expect(openSpy.mock.calls[0][0]).toBe('');
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('returns null when the browser blocks the popup', () => {
|
|
78
|
+
jest.spyOn(window, 'open').mockReturnValue(null);
|
|
79
|
+
expect(openOAuthPopup()).toBeNull();
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('returns null instead of throwing when window.open throws', () => {
|
|
83
|
+
jest.spyOn(window, 'open').mockImplementation(() => {
|
|
84
|
+
throw new Error('blocked');
|
|
85
|
+
});
|
|
86
|
+
expect(openOAuthPopup()).toBeNull();
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
describe('navigateOAuthPopup', () => {
|
|
91
|
+
it('points the popup at the authorize URL', () => {
|
|
92
|
+
const popup = fakePopup();
|
|
93
|
+
expect(navigateOAuthPopup(popup, `${IDP_ORIGIN}/authorize?x=1`)).toBe(true);
|
|
94
|
+
expect(popup.location.href).toBe(`${IDP_ORIGIN}/authorize?x=1`);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('reports failure instead of throwing when the window is gone', () => {
|
|
98
|
+
const popup: OAuthPopupHandle = {
|
|
99
|
+
closed: true,
|
|
100
|
+
close: () => undefined,
|
|
101
|
+
get location(): { href: string } {
|
|
102
|
+
throw new Error('window closed');
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
expect(navigateOAuthPopup(popup, `${IDP_ORIGIN}/authorize`)).toBe(false);
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
describe('closeOAuthPopup', () => {
|
|
110
|
+
it('is a no-op for null and for an already-closed window', () => {
|
|
111
|
+
expect(() => closeOAuthPopup(null)).not.toThrow();
|
|
112
|
+
const popup = fakePopup();
|
|
113
|
+
popup.setClosed();
|
|
114
|
+
closeOAuthPopup(popup);
|
|
115
|
+
expect(popup.close).not.toHaveBeenCalled();
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it('closes an open window and swallows a close that throws', () => {
|
|
119
|
+
const popup = fakePopup();
|
|
120
|
+
closeOAuthPopup(popup);
|
|
121
|
+
expect(popup.close).toHaveBeenCalledTimes(1);
|
|
122
|
+
|
|
123
|
+
const hostile: OAuthPopupHandle = {
|
|
124
|
+
closed: false,
|
|
125
|
+
close: () => {
|
|
126
|
+
throw new Error('denied');
|
|
127
|
+
},
|
|
128
|
+
location: { href: '' },
|
|
129
|
+
};
|
|
130
|
+
expect(() => closeOAuthPopup(hostile)).not.toThrow();
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
describe('awaitOAuthPopupResult', () => {
|
|
135
|
+
let addSpy: jest.SpyInstance;
|
|
136
|
+
let removeSpy: jest.SpyInstance;
|
|
137
|
+
|
|
138
|
+
beforeEach(() => {
|
|
139
|
+
jest.useFakeTimers();
|
|
140
|
+
addSpy = jest.spyOn(window, 'addEventListener');
|
|
141
|
+
removeSpy = jest.spyOn(window, 'removeEventListener');
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
afterEach(() => {
|
|
145
|
+
jest.useRealTimers();
|
|
146
|
+
jest.restoreAllMocks();
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
/** Every exit path must leave zero listeners and zero timers behind. */
|
|
150
|
+
function expectFullCleanup(): void {
|
|
151
|
+
const registered = addSpy.mock.calls.filter(([type]) => type === 'message');
|
|
152
|
+
const removed = removeSpy.mock.calls.filter(([type]) => type === 'message');
|
|
153
|
+
expect(registered).toHaveLength(1);
|
|
154
|
+
expect(removed).toHaveLength(1);
|
|
155
|
+
expect(removed[0][1]).toBe(registered[0][1]);
|
|
156
|
+
expect(jest.getTimerCount()).toBe(0);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
it('resolves with the authorization code on a valid message', async () => {
|
|
160
|
+
const popup = fakePopup();
|
|
161
|
+
const promise = awaitOAuthPopupResult({
|
|
162
|
+
popup,
|
|
163
|
+
expectedOrigin: IDP_ORIGIN,
|
|
164
|
+
expectedState: STATE,
|
|
165
|
+
redirectUri: REDIRECT_URI,
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
dispatchMessage(codeMessage(popup));
|
|
169
|
+
|
|
170
|
+
await expect(promise).resolves.toEqual({ kind: 'code', code: 'code-1', state: STATE });
|
|
171
|
+
expectFullCleanup();
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
it('resolves with a typed IdP error', async () => {
|
|
175
|
+
const popup = fakePopup();
|
|
176
|
+
const promise = awaitOAuthPopupResult({
|
|
177
|
+
popup,
|
|
178
|
+
expectedOrigin: IDP_ORIGIN,
|
|
179
|
+
expectedState: STATE,
|
|
180
|
+
redirectUri: REDIRECT_URI,
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
dispatchMessage({
|
|
184
|
+
data: {
|
|
185
|
+
type: OXY_OAUTH_ERROR_MESSAGE_TYPE,
|
|
186
|
+
error: 'access_denied',
|
|
187
|
+
errorDescription: 'user declined',
|
|
188
|
+
state: STATE,
|
|
189
|
+
},
|
|
190
|
+
origin: IDP_ORIGIN,
|
|
191
|
+
source: popup,
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
await expect(promise).resolves.toEqual({
|
|
195
|
+
kind: 'oauth-error',
|
|
196
|
+
error: 'access_denied',
|
|
197
|
+
errorDescription: 'user declined',
|
|
198
|
+
});
|
|
199
|
+
expectFullCleanup();
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
it('resolves with a state mismatch when our popup answers another request', async () => {
|
|
203
|
+
const popup = fakePopup();
|
|
204
|
+
const promise = awaitOAuthPopupResult({
|
|
205
|
+
popup,
|
|
206
|
+
expectedOrigin: IDP_ORIGIN,
|
|
207
|
+
expectedState: STATE,
|
|
208
|
+
redirectUri: REDIRECT_URI,
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
dispatchMessage(codeMessage(popup, 'a-different-state'));
|
|
212
|
+
|
|
213
|
+
await expect(promise).resolves.toEqual({ kind: 'state-mismatch' });
|
|
214
|
+
expectFullCleanup();
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
it.each([
|
|
218
|
+
['a foreign origin', () => codeMessage(fakePopup(), STATE, 'https://evil.example')],
|
|
219
|
+
['a foreign window', () => codeMessage(fakePopup())],
|
|
220
|
+
])('keeps waiting after a message from %s', async (_label, build) => {
|
|
221
|
+
const popup = fakePopup();
|
|
222
|
+
const promise = awaitOAuthPopupResult({
|
|
223
|
+
popup,
|
|
224
|
+
expectedOrigin: IDP_ORIGIN,
|
|
225
|
+
expectedState: STATE,
|
|
226
|
+
redirectUri: REDIRECT_URI,
|
|
227
|
+
timeoutMs: 60_000,
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
dispatchMessage(build());
|
|
231
|
+
expect(await outcomeOrPending(promise)).toBe('pending');
|
|
232
|
+
|
|
233
|
+
// The real popup can still complete the flow afterwards.
|
|
234
|
+
dispatchMessage(codeMessage(popup));
|
|
235
|
+
await expect(promise).resolves.toEqual({ kind: 'code', code: 'code-1', state: STATE });
|
|
236
|
+
expectFullCleanup();
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
it('keeps waiting after a malformed payload from the real popup', async () => {
|
|
240
|
+
const popup = fakePopup();
|
|
241
|
+
const promise = awaitOAuthPopupResult({
|
|
242
|
+
popup,
|
|
243
|
+
expectedOrigin: IDP_ORIGIN,
|
|
244
|
+
expectedState: STATE,
|
|
245
|
+
redirectUri: REDIRECT_URI,
|
|
246
|
+
timeoutMs: 60_000,
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
dispatchMessage({ data: { type: 'oxy:oauth:code' }, origin: IDP_ORIGIN, source: popup });
|
|
250
|
+
expect(await outcomeOrPending(promise)).toBe('pending');
|
|
251
|
+
|
|
252
|
+
dispatchMessage(codeMessage(popup));
|
|
253
|
+
await expect(promise).resolves.toEqual({ kind: 'code', code: 'code-1', state: STATE });
|
|
254
|
+
expectFullCleanup();
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
it('ignores a duplicate result: the first message wins and the listener is gone', async () => {
|
|
258
|
+
const popup = fakePopup();
|
|
259
|
+
const promise = awaitOAuthPopupResult({
|
|
260
|
+
popup,
|
|
261
|
+
expectedOrigin: IDP_ORIGIN,
|
|
262
|
+
expectedState: STATE,
|
|
263
|
+
redirectUri: REDIRECT_URI,
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
dispatchMessage(codeMessage(popup));
|
|
267
|
+
await expect(promise).resolves.toEqual({ kind: 'code', code: 'code-1', state: STATE });
|
|
268
|
+
|
|
269
|
+
// A late redelivery (or a second, contradicting message) reaches nothing.
|
|
270
|
+
expect(() =>
|
|
271
|
+
dispatchMessage({
|
|
272
|
+
data: { type: OXY_OAUTH_ERROR_MESSAGE_TYPE, error: 'access_denied', state: STATE },
|
|
273
|
+
origin: IDP_ORIGIN,
|
|
274
|
+
source: popup,
|
|
275
|
+
}),
|
|
276
|
+
).not.toThrow();
|
|
277
|
+
await expect(promise).resolves.toEqual({ kind: 'code', code: 'code-1', state: STATE });
|
|
278
|
+
expectFullCleanup();
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
it('reports cancellation once the user closes the window', async () => {
|
|
282
|
+
const popup = fakePopup();
|
|
283
|
+
const promise = awaitOAuthPopupResult({
|
|
284
|
+
popup,
|
|
285
|
+
expectedOrigin: IDP_ORIGIN,
|
|
286
|
+
expectedState: STATE,
|
|
287
|
+
redirectUri: REDIRECT_URI,
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
popup.setClosed();
|
|
291
|
+
jest.advanceTimersByTime(1000);
|
|
292
|
+
// The close is not reported instantly: an already-queued message may still win.
|
|
293
|
+
expect(await outcomeOrPending(promise)).toBe('pending');
|
|
294
|
+
|
|
295
|
+
jest.advanceTimersByTime(400);
|
|
296
|
+
await expect(promise).resolves.toEqual({ kind: 'closed' });
|
|
297
|
+
expectFullCleanup();
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
it('lets a result that arrived just before the close win the race', async () => {
|
|
301
|
+
const popup = fakePopup();
|
|
302
|
+
const promise = awaitOAuthPopupResult({
|
|
303
|
+
popup,
|
|
304
|
+
expectedOrigin: IDP_ORIGIN,
|
|
305
|
+
expectedState: STATE,
|
|
306
|
+
redirectUri: REDIRECT_URI,
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
// The IdP posts its result and immediately closes itself.
|
|
310
|
+
popup.setClosed();
|
|
311
|
+
jest.advanceTimersByTime(1000);
|
|
312
|
+
dispatchMessage(codeMessage(popup));
|
|
313
|
+
jest.advanceTimersByTime(1000);
|
|
314
|
+
|
|
315
|
+
await expect(promise).resolves.toEqual({ kind: 'code', code: 'code-1', state: STATE });
|
|
316
|
+
expectFullCleanup();
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
it('times out when nothing ever answers', async () => {
|
|
320
|
+
const popup = fakePopup();
|
|
321
|
+
const promise = awaitOAuthPopupResult({
|
|
322
|
+
popup,
|
|
323
|
+
expectedOrigin: IDP_ORIGIN,
|
|
324
|
+
expectedState: STATE,
|
|
325
|
+
redirectUri: REDIRECT_URI,
|
|
326
|
+
timeoutMs: 30_000,
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
jest.advanceTimersByTime(29_999);
|
|
330
|
+
expect(await outcomeOrPending(promise)).toBe('pending');
|
|
331
|
+
|
|
332
|
+
jest.advanceTimersByTime(1);
|
|
333
|
+
await expect(promise).resolves.toEqual({ kind: 'timed-out' });
|
|
334
|
+
expectFullCleanup();
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
it('reads a same-origin redirect fallback from the popup URL when postMessage is unavailable', async () => {
|
|
338
|
+
const popup = fakePopup();
|
|
339
|
+
popup.location.href = `${REDIRECT_URI}?code=auth-code&state=${STATE}`;
|
|
340
|
+
const promise = awaitOAuthPopupResult({
|
|
341
|
+
popup,
|
|
342
|
+
expectedOrigin: IDP_ORIGIN,
|
|
343
|
+
expectedState: STATE,
|
|
344
|
+
redirectUri: REDIRECT_URI,
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
jest.advanceTimersByTime(1000);
|
|
348
|
+
|
|
349
|
+
await expect(promise).resolves.toEqual({ kind: 'code', code: 'auth-code', state: STATE });
|
|
350
|
+
expectFullCleanup();
|
|
351
|
+
});
|
|
352
|
+
});
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import {
|
|
2
|
+
OXY_OAUTH_CODE_MESSAGE_TYPE,
|
|
3
|
+
OXY_OAUTH_ERROR_MESSAGE_TYPE,
|
|
4
|
+
parseOAuthPopupMessage,
|
|
5
|
+
readOAuthPopupMessage,
|
|
6
|
+
} from '../oauthPopupMessages';
|
|
7
|
+
import type { OAuthPopupHandle } from '../types';
|
|
8
|
+
|
|
9
|
+
const IDP_ORIGIN = 'https://auth.oxy.so';
|
|
10
|
+
const STATE = 'state-abc';
|
|
11
|
+
|
|
12
|
+
/** A stand-in for the popup `Window`; identity is all the validator compares. */
|
|
13
|
+
function fakePopup(): OAuthPopupHandle {
|
|
14
|
+
return { closed: false, close: () => undefined, location: { href: '' } };
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Build a `message` event with attacker-controllable fields. jsdom's
|
|
19
|
+
* `MessageEvent` constructor refuses a non-`Window` `source`, so the event is
|
|
20
|
+
* assembled the way the browser hands it to the listener instead.
|
|
21
|
+
*/
|
|
22
|
+
function makeMessageEvent(init: {
|
|
23
|
+
data: unknown;
|
|
24
|
+
origin: string;
|
|
25
|
+
source: unknown;
|
|
26
|
+
}): MessageEvent {
|
|
27
|
+
const event = new Event('message');
|
|
28
|
+
Object.assign(event, init);
|
|
29
|
+
return event as MessageEvent;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
describe('parseOAuthPopupMessage', () => {
|
|
33
|
+
it('accepts a well-formed code message', () => {
|
|
34
|
+
expect(
|
|
35
|
+
parseOAuthPopupMessage({ type: OXY_OAUTH_CODE_MESSAGE_TYPE, code: 'c1', state: STATE }),
|
|
36
|
+
).toEqual({ type: OXY_OAUTH_CODE_MESSAGE_TYPE, code: 'c1', state: STATE });
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('accepts a well-formed error message and its optional fields', () => {
|
|
40
|
+
expect(
|
|
41
|
+
parseOAuthPopupMessage({
|
|
42
|
+
type: OXY_OAUTH_ERROR_MESSAGE_TYPE,
|
|
43
|
+
error: 'access_denied',
|
|
44
|
+
errorDescription: 'user said no',
|
|
45
|
+
state: STATE,
|
|
46
|
+
}),
|
|
47
|
+
).toEqual({
|
|
48
|
+
type: OXY_OAUTH_ERROR_MESSAGE_TYPE,
|
|
49
|
+
error: 'access_denied',
|
|
50
|
+
errorDescription: 'user said no',
|
|
51
|
+
state: STATE,
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('drops optional error fields that are not non-empty strings', () => {
|
|
56
|
+
expect(
|
|
57
|
+
parseOAuthPopupMessage({
|
|
58
|
+
type: OXY_OAUTH_ERROR_MESSAGE_TYPE,
|
|
59
|
+
error: 'server_error',
|
|
60
|
+
errorDescription: 42,
|
|
61
|
+
state: '',
|
|
62
|
+
}),
|
|
63
|
+
).toEqual({ type: OXY_OAUTH_ERROR_MESSAGE_TYPE, error: 'server_error' });
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('never surfaces extra properties a sender smuggled in', () => {
|
|
67
|
+
const parsed = parseOAuthPopupMessage({
|
|
68
|
+
type: OXY_OAUTH_CODE_MESSAGE_TYPE,
|
|
69
|
+
code: 'c1',
|
|
70
|
+
state: STATE,
|
|
71
|
+
accessToken: 'leaked',
|
|
72
|
+
deviceSecret: 'leaked',
|
|
73
|
+
});
|
|
74
|
+
expect(parsed).toEqual({ type: OXY_OAUTH_CODE_MESSAGE_TYPE, code: 'c1', state: STATE });
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it.each([
|
|
78
|
+
['null', null],
|
|
79
|
+
['undefined', undefined],
|
|
80
|
+
['a string', 'oxy:oauth:code'],
|
|
81
|
+
['a number', 7],
|
|
82
|
+
['an array', [{ type: OXY_OAUTH_CODE_MESSAGE_TYPE, code: 'c', state: STATE }]],
|
|
83
|
+
['an unknown type', { type: 'oxy:oauth:token', code: 'c', state: STATE }],
|
|
84
|
+
['a code message with no code', { type: OXY_OAUTH_CODE_MESSAGE_TYPE, state: STATE }],
|
|
85
|
+
['a code message with an empty code', { type: OXY_OAUTH_CODE_MESSAGE_TYPE, code: '', state: STATE }],
|
|
86
|
+
['a code message with no state', { type: OXY_OAUTH_CODE_MESSAGE_TYPE, code: 'c' }],
|
|
87
|
+
['a code message with a non-string code', { type: OXY_OAUTH_CODE_MESSAGE_TYPE, code: 1, state: STATE }],
|
|
88
|
+
['an error message with no error', { type: OXY_OAUTH_ERROR_MESSAGE_TYPE, state: STATE }],
|
|
89
|
+
])('rejects %s', (_label, data) => {
|
|
90
|
+
expect(parseOAuthPopupMessage(data)).toBeNull();
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
describe('readOAuthPopupMessage', () => {
|
|
95
|
+
const popup = fakePopup();
|
|
96
|
+
const context = { expectedOrigin: IDP_ORIGIN, expectedState: STATE, popup };
|
|
97
|
+
|
|
98
|
+
it('returns the code when origin, source, shape and state all match', () => {
|
|
99
|
+
const verdict = readOAuthPopupMessage(
|
|
100
|
+
makeMessageEvent({
|
|
101
|
+
data: { type: OXY_OAUTH_CODE_MESSAGE_TYPE, code: 'c1', state: STATE },
|
|
102
|
+
origin: IDP_ORIGIN,
|
|
103
|
+
source: popup,
|
|
104
|
+
}),
|
|
105
|
+
context,
|
|
106
|
+
);
|
|
107
|
+
expect(verdict).toEqual({ kind: 'code', code: 'c1', state: STATE });
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it('ignores a message from another origin, even with a valid payload', () => {
|
|
111
|
+
const verdict = readOAuthPopupMessage(
|
|
112
|
+
makeMessageEvent({
|
|
113
|
+
data: { type: OXY_OAUTH_CODE_MESSAGE_TYPE, code: 'evil', state: STATE },
|
|
114
|
+
origin: 'https://evil.example',
|
|
115
|
+
source: popup,
|
|
116
|
+
}),
|
|
117
|
+
context,
|
|
118
|
+
);
|
|
119
|
+
expect(verdict).toEqual({ kind: 'ignore' });
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it('ignores a message from a window that is not the popup we opened', () => {
|
|
123
|
+
const verdict = readOAuthPopupMessage(
|
|
124
|
+
makeMessageEvent({
|
|
125
|
+
data: { type: OXY_OAUTH_CODE_MESSAGE_TYPE, code: 'evil', state: STATE },
|
|
126
|
+
origin: IDP_ORIGIN,
|
|
127
|
+
source: fakePopup(),
|
|
128
|
+
}),
|
|
129
|
+
context,
|
|
130
|
+
);
|
|
131
|
+
expect(verdict).toEqual({ kind: 'ignore' });
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it('ignores a message with no source at all', () => {
|
|
135
|
+
const verdict = readOAuthPopupMessage(
|
|
136
|
+
makeMessageEvent({
|
|
137
|
+
data: { type: OXY_OAUTH_CODE_MESSAGE_TYPE, code: 'c1', state: STATE },
|
|
138
|
+
origin: IDP_ORIGIN,
|
|
139
|
+
source: null,
|
|
140
|
+
}),
|
|
141
|
+
context,
|
|
142
|
+
);
|
|
143
|
+
expect(verdict).toEqual({ kind: 'ignore' });
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
it('ignores a malformed payload from the real popup', () => {
|
|
147
|
+
const verdict = readOAuthPopupMessage(
|
|
148
|
+
makeMessageEvent({ data: { hello: 'world' }, origin: IDP_ORIGIN, source: popup }),
|
|
149
|
+
context,
|
|
150
|
+
);
|
|
151
|
+
expect(verdict).toEqual({ kind: 'ignore' });
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
it('reports a state mismatch on a code message bound to another request', () => {
|
|
155
|
+
const verdict = readOAuthPopupMessage(
|
|
156
|
+
makeMessageEvent({
|
|
157
|
+
data: { type: OXY_OAUTH_CODE_MESSAGE_TYPE, code: 'c1', state: 'other-state' },
|
|
158
|
+
origin: IDP_ORIGIN,
|
|
159
|
+
source: popup,
|
|
160
|
+
}),
|
|
161
|
+
context,
|
|
162
|
+
);
|
|
163
|
+
expect(verdict).toEqual({ kind: 'state-mismatch' });
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
it('accepts an error message that carries no state', () => {
|
|
167
|
+
const verdict = readOAuthPopupMessage(
|
|
168
|
+
makeMessageEvent({
|
|
169
|
+
data: { type: OXY_OAUTH_ERROR_MESSAGE_TYPE, error: 'access_denied' },
|
|
170
|
+
origin: IDP_ORIGIN,
|
|
171
|
+
source: popup,
|
|
172
|
+
}),
|
|
173
|
+
context,
|
|
174
|
+
);
|
|
175
|
+
expect(verdict).toEqual({ kind: 'oauth-error', error: 'access_denied' });
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
it('reports a state mismatch on an error message bound to another request', () => {
|
|
179
|
+
const verdict = readOAuthPopupMessage(
|
|
180
|
+
makeMessageEvent({
|
|
181
|
+
data: { type: OXY_OAUTH_ERROR_MESSAGE_TYPE, error: 'access_denied', state: 'other' },
|
|
182
|
+
origin: IDP_ORIGIN,
|
|
183
|
+
source: popup,
|
|
184
|
+
}),
|
|
185
|
+
context,
|
|
186
|
+
);
|
|
187
|
+
expect(verdict).toEqual({ kind: 'state-mismatch' });
|
|
188
|
+
});
|
|
189
|
+
});
|