add polyfills
This commit is contained in:
@@ -119,6 +119,7 @@
|
|||||||
"@types/lodash.throttle": "^4.1.9",
|
"@types/lodash.throttle": "^4.1.9",
|
||||||
"@types/node": "^20.14.3",
|
"@types/node": "^20.14.3",
|
||||||
"@zxing/text-encoding": "^0.9.0",
|
"@zxing/text-encoding": "^0.9.0",
|
||||||
|
"abortcontroller-polyfill": "^1.7.8",
|
||||||
"array.prototype.findlast": "^1.2.3",
|
"array.prototype.findlast": "^1.2.3",
|
||||||
"await-lock": "^2.2.2",
|
"await-lock": "^2.2.2",
|
||||||
"babel-plugin-transform-remove-console": "^6.9.4",
|
"babel-plugin-transform-remove-console": "^6.9.4",
|
||||||
@@ -130,6 +131,7 @@
|
|||||||
"email-validator": "^2.0.4",
|
"email-validator": "^2.0.4",
|
||||||
"emoji-mart": "^5.5.2",
|
"emoji-mart": "^5.5.2",
|
||||||
"emoji-regex": "^10.4.0",
|
"emoji-regex": "^10.4.0",
|
||||||
|
"event-target-polyfill": "^0.0.4",
|
||||||
"eventemitter3": "^5.0.1",
|
"eventemitter3": "^5.0.1",
|
||||||
"expo": "53.0.11",
|
"expo": "53.0.11",
|
||||||
"expo-application": "~6.1.4",
|
"expo-application": "~6.1.4",
|
||||||
|
|||||||
+7
-3
@@ -93,7 +93,7 @@ beginResolveGeolocation()
|
|||||||
function InnerApp() {
|
function InnerApp() {
|
||||||
const [isReady, setIsReady] = React.useState(false)
|
const [isReady, setIsReady] = React.useState(false)
|
||||||
const {currentAccount} = useSession()
|
const {currentAccount} = useSession()
|
||||||
const {resumeSession} = useSessionApi()
|
const {resumeSession, resumeSessionOauth} = useSessionApi()
|
||||||
const theme = useColorModeTheme()
|
const theme = useColorModeTheme()
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const hasCheckedReferrer = useStarterPackEntry()
|
const hasCheckedReferrer = useStarterPackEntry()
|
||||||
@@ -103,7 +103,11 @@ function InnerApp() {
|
|||||||
async function onLaunch(account?: SessionAccount) {
|
async function onLaunch(account?: SessionAccount) {
|
||||||
try {
|
try {
|
||||||
if (account) {
|
if (account) {
|
||||||
await resumeSession(account)
|
if (true) {
|
||||||
|
await resumeSessionOauth(account)
|
||||||
|
} else {
|
||||||
|
await resumeSession(account)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
await tryFetchGates(undefined, 'prefer-fresh-gates')
|
await tryFetchGates(undefined, 'prefer-fresh-gates')
|
||||||
}
|
}
|
||||||
@@ -115,7 +119,7 @@ function InnerApp() {
|
|||||||
}
|
}
|
||||||
const account = readLastActiveAccount()
|
const account = readLastActiveAccount()
|
||||||
onLaunch(account)
|
onLaunch(account)
|
||||||
}, [resumeSession])
|
}, [resumeSession, resumeSessionOauth])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
return listenSessionDropped(() => {
|
return listenSessionDropped(() => {
|
||||||
|
|||||||
+7
-3
@@ -72,7 +72,7 @@ beginResolveGeolocation()
|
|||||||
function InnerApp() {
|
function InnerApp() {
|
||||||
const [isReady, setIsReady] = React.useState(false)
|
const [isReady, setIsReady] = React.useState(false)
|
||||||
const {currentAccount} = useSession()
|
const {currentAccount} = useSession()
|
||||||
const {resumeSession} = useSessionApi()
|
const {resumeSession, resumeSessionOauth} = useSessionApi()
|
||||||
const theme = useColorModeTheme()
|
const theme = useColorModeTheme()
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const hasCheckedReferrer = useStarterPackEntry()
|
const hasCheckedReferrer = useStarterPackEntry()
|
||||||
@@ -82,7 +82,11 @@ function InnerApp() {
|
|||||||
async function onLaunch(account?: SessionAccount) {
|
async function onLaunch(account?: SessionAccount) {
|
||||||
try {
|
try {
|
||||||
if (account) {
|
if (account) {
|
||||||
await resumeSession(account)
|
if (true) {
|
||||||
|
await resumeSessionOauth(account)
|
||||||
|
} else {
|
||||||
|
await resumeSession(account)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.error(`session: resumeSession failed`, {message: e})
|
logger.error(`session: resumeSession failed`, {message: e})
|
||||||
@@ -92,7 +96,7 @@ function InnerApp() {
|
|||||||
}
|
}
|
||||||
const account = readLastActiveAccount()
|
const account = readLastActiveAccount()
|
||||||
onLaunch(account)
|
onLaunch(account)
|
||||||
}, [resumeSession])
|
}, [resumeSession, resumeSessionOauth])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
return listenSessionDropped(() => {
|
return listenSessionDropped(() => {
|
||||||
|
|||||||
@@ -4,16 +4,16 @@ import {useLingui} from '@lingui/react'
|
|||||||
|
|
||||||
import {logger} from '#/logger'
|
import {logger} from '#/logger'
|
||||||
import {isWeb} from '#/platform/detection'
|
import {isWeb} from '#/platform/detection'
|
||||||
import {SessionAccount, useSessionApi} from '#/state/session'
|
import {type SessionAccount, useSessionApi} from '#/state/session'
|
||||||
import {useLoggedOutViewControls} from '#/state/shell/logged-out'
|
import {useLoggedOutViewControls} from '#/state/shell/logged-out'
|
||||||
import * as Toast from '#/view/com/util/Toast'
|
import * as Toast from '#/view/com/util/Toast'
|
||||||
import {logEvent} from '../statsig/statsig'
|
import {logEvent} from '../statsig/statsig'
|
||||||
import {LogEvents} from '../statsig/statsig'
|
import {type LogEvents} from '../statsig/statsig'
|
||||||
|
|
||||||
export function useAccountSwitcher() {
|
export function useAccountSwitcher() {
|
||||||
const [pendingDid, setPendingDid] = useState<string | null>(null)
|
const [pendingDid, setPendingDid] = useState<string | null>(null)
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const {resumeSession} = useSessionApi()
|
const {resumeSession, resumeSessionOauth} = useSessionApi()
|
||||||
const {requestSwitchToAccount} = useLoggedOutViewControls()
|
const {requestSwitchToAccount} = useLoggedOutViewControls()
|
||||||
|
|
||||||
const onPressSwitchAccount = useCallback(
|
const onPressSwitchAccount = useCallback(
|
||||||
@@ -36,7 +36,11 @@ export function useAccountSwitcher() {
|
|||||||
// So we change the URL ourselves. The navigator will pick it up on remount.
|
// So we change the URL ourselves. The navigator will pick it up on remount.
|
||||||
history.pushState(null, '', '/')
|
history.pushState(null, '', '/')
|
||||||
}
|
}
|
||||||
await resumeSession(account)
|
if (true) {
|
||||||
|
await resumeSessionOauth(account)
|
||||||
|
} else {
|
||||||
|
await resumeSession(account)
|
||||||
|
}
|
||||||
logEvent('account:loggedIn', {logContext, withPassword: false})
|
logEvent('account:loggedIn', {logContext, withPassword: false})
|
||||||
Toast.show(_(msg`Signed in as @${account.handle}`))
|
Toast.show(_(msg`Signed in as @${account.handle}`))
|
||||||
} else {
|
} else {
|
||||||
@@ -59,7 +63,7 @@ export function useAccountSwitcher() {
|
|||||||
setPendingDid(null)
|
setPendingDid(null)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[_, resumeSession, requestSwitchToAccount, pendingDid],
|
[_, resumeSession, resumeSessionOauth, requestSwitchToAccount, pendingDid],
|
||||||
)
|
)
|
||||||
|
|
||||||
return {onPressSwitchAccount, pendingDid}
|
return {onPressSwitchAccount, pendingDid}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import 'react-native-url-polyfill/auto'
|
import 'react-native-url-polyfill/auto'
|
||||||
import 'fast-text-encoding'
|
import 'fast-text-encoding'
|
||||||
|
import 'abortcontroller-polyfill/dist/polyfill-patch-fetch'
|
||||||
|
import 'event-target-polyfill'
|
||||||
export {}
|
export {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import {useLingui} from '@lingui/react'
|
|||||||
|
|
||||||
import {logEvent} from '#/lib/statsig/statsig'
|
import {logEvent} from '#/lib/statsig/statsig'
|
||||||
import {logger} from '#/logger'
|
import {logger} from '#/logger'
|
||||||
import {SessionAccount, useSession, useSessionApi} from '#/state/session'
|
import {type SessionAccount, useSession, useSessionApi} from '#/state/session'
|
||||||
import {useLoggedOutViewControls} from '#/state/shell/logged-out'
|
import {useLoggedOutViewControls} from '#/state/shell/logged-out'
|
||||||
import * as Toast from '#/view/com/util/Toast'
|
import * as Toast from '#/view/com/util/Toast'
|
||||||
import {atoms as a} from '#/alf'
|
import {atoms as a} from '#/alf'
|
||||||
@@ -24,7 +24,7 @@ export const ChooseAccountForm = ({
|
|||||||
const [pendingDid, setPendingDid] = React.useState<string | null>(null)
|
const [pendingDid, setPendingDid] = React.useState<string | null>(null)
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const {currentAccount} = useSession()
|
const {currentAccount} = useSession()
|
||||||
const {resumeSession} = useSessionApi()
|
const {resumeSession, resumeSessionOauth} = useSessionApi()
|
||||||
const {setShowLoggedOut} = useLoggedOutViewControls()
|
const {setShowLoggedOut} = useLoggedOutViewControls()
|
||||||
|
|
||||||
const onSelect = React.useCallback(
|
const onSelect = React.useCallback(
|
||||||
@@ -45,7 +45,11 @@ export const ChooseAccountForm = ({
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
setPendingDid(account.did)
|
setPendingDid(account.did)
|
||||||
await resumeSession(account)
|
if (true) {
|
||||||
|
resumeSessionOauth(account)
|
||||||
|
} else {
|
||||||
|
await resumeSession(account)
|
||||||
|
}
|
||||||
logEvent('account:loggedIn', {
|
logEvent('account:loggedIn', {
|
||||||
logContext: 'ChooseAccountForm',
|
logContext: 'ChooseAccountForm',
|
||||||
withPassword: false,
|
withPassword: false,
|
||||||
@@ -64,6 +68,7 @@ export const ChooseAccountForm = ({
|
|||||||
[
|
[
|
||||||
currentAccount,
|
currentAccount,
|
||||||
resumeSession,
|
resumeSession,
|
||||||
|
resumeSessionOauth,
|
||||||
pendingDid,
|
pendingDid,
|
||||||
onSelectAccount,
|
onSelectAccount,
|
||||||
setShowLoggedOut,
|
setShowLoggedOut,
|
||||||
|
|||||||
@@ -272,7 +272,11 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
|||||||
)
|
)
|
||||||
if (syncedAccount && syncedAccount.refreshJwt) {
|
if (syncedAccount && syncedAccount.refreshJwt) {
|
||||||
if (syncedAccount.did !== state.currentAgentState.did) {
|
if (syncedAccount.did !== state.currentAgentState.did) {
|
||||||
resumeSession(syncedAccount)
|
if (true) {
|
||||||
|
resumeSessionOauth(syncedAccount)
|
||||||
|
} else {
|
||||||
|
resumeSession(syncedAccount)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
const agent = state.currentAgentState.agent as BskyAgent
|
const agent = state.currentAgentState.agent as BskyAgent
|
||||||
const prevSession = agent.session
|
const prevSession = agent.session
|
||||||
@@ -286,7 +290,7 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}, [state, resumeSession])
|
}, [state, resumeSession, resumeSessionOauth])
|
||||||
|
|
||||||
const stateContext = React.useMemo(
|
const stateContext = React.useMemo(
|
||||||
() => ({
|
() => ({
|
||||||
@@ -335,7 +339,8 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
|||||||
addSessionDebugLog({type: 'agent:switch', prevAgent, nextAgent: agent})
|
addSessionDebugLog({type: 'agent:switch', prevAgent, nextAgent: agent})
|
||||||
// We never reuse agents so let's fully neutralize the previous one.
|
// We never reuse agents so let's fully neutralize the previous one.
|
||||||
// This ensures it won't try to consume any refresh tokens.
|
// This ensures it won't try to consume any refresh tokens.
|
||||||
prevAgent.dispose()
|
// TODO: this is a hack!
|
||||||
|
prevAgent.dispose?.()
|
||||||
}
|
}
|
||||||
}, [agent])
|
}, [agent])
|
||||||
|
|
||||||
|
|||||||
@@ -8070,6 +8070,11 @@ abort-controller@^3.0.0:
|
|||||||
dependencies:
|
dependencies:
|
||||||
event-target-shim "^5.0.0"
|
event-target-shim "^5.0.0"
|
||||||
|
|
||||||
|
abortcontroller-polyfill@^1.7.8:
|
||||||
|
version "1.7.8"
|
||||||
|
resolved "https://registry.yarnpkg.com/abortcontroller-polyfill/-/abortcontroller-polyfill-1.7.8.tgz#fe8d4370403f02e2aa37e3d2b0b178bae9d83f49"
|
||||||
|
integrity sha512-9f1iZ2uWh92VcrU9Y8x+LdM4DLj75VE0MJB8zuF1iUnroEptStw+DQ8EQPMUdfe5k+PkB1uUfDQfWbhstH8LrQ==
|
||||||
|
|
||||||
accepts@^1.3.7, accepts@^1.3.8, accepts@~1.3.4, accepts@~1.3.5, accepts@~1.3.8:
|
accepts@^1.3.7, accepts@^1.3.8, accepts@~1.3.4, accepts@~1.3.5, accepts@~1.3.8:
|
||||||
version "1.3.8"
|
version "1.3.8"
|
||||||
resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.8.tgz#0bf0be125b67014adcb0b0921e62db7bffe16b2e"
|
resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.8.tgz#0bf0be125b67014adcb0b0921e62db7bffe16b2e"
|
||||||
@@ -11153,6 +11158,11 @@ etcd3@^1.1.2:
|
|||||||
bignumber.js "^9.1.1"
|
bignumber.js "^9.1.1"
|
||||||
cockatiel "^3.1.1"
|
cockatiel "^3.1.1"
|
||||||
|
|
||||||
|
event-target-polyfill@^0.0.4:
|
||||||
|
version "0.0.4"
|
||||||
|
resolved "https://registry.yarnpkg.com/event-target-polyfill/-/event-target-polyfill-0.0.4.tgz#060ee66e85aaedc76b6fa66079782dcc11cba496"
|
||||||
|
integrity sha512-Gs6RLjzlLRdT8X9ZipJdIZI/Y6/HhRLyq9RdDlCsnpxr/+Nn6bU2EFGuC94GjxqhM+Nmij2Vcq98yoHrU8uNFQ==
|
||||||
|
|
||||||
event-target-shim@^5.0.0, event-target-shim@^5.0.1:
|
event-target-shim@^5.0.0, event-target-shim@^5.0.1:
|
||||||
version "5.0.1"
|
version "5.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/event-target-shim/-/event-target-shim-5.0.1.tgz#5d4d3ebdf9583d63a5333ce2deb7480ab2b05789"
|
resolved "https://registry.yarnpkg.com/event-target-shim/-/event-target-shim-5.0.1.tgz#5d4d3ebdf9583d63a5333ce2deb7480ab2b05789"
|
||||||
|
|||||||
Reference in New Issue
Block a user