···6767 })
68686969 const currentSession = serverSession.data
7070- if (!currentSession) return { oauthSession: undefined, serverSession }
7070+ // TODO (jg): why can a session be `{}`?
7171+ if (!currentSession || !currentSession.public?.did) {
7272+ return { oauthSession: undefined, serverSession }
7373+ }
71747275 const oauthSession = await client.restore(currentSession.public.did)
7376 return { oauthSession, serverSession }
+9-7
server/utils/docs/client.ts
···991010import { doc, type DocNode } from '@deno/doc'
1111import type { DenoDocNode, DenoDocResult } from '#shared/types/deno-doc'
1212+import { isBuiltin } from 'node:module'
12131314// =============================================================================
1415// Configuration
···8182 _cacheSetting?: string,
8283 _checksum?: string,
8384 ) => {
8484- let url: URL
8585- try {
8686- url = new URL(specifier)
8787- } catch (e) {
8888- // eslint-disable-next-line no-console
8989- console.error(e)
8585+ const url = URL.parse(specifier)
8686+8787+ if (url === null) {
9088 return undefined
9189 }
9290···139137 }
140138141139 // Handle bare specifiers - resolve through esm.sh
142142- if (!specifier.startsWith('http://') && !specifier.startsWith('https://')) {
140140+ if (
141141+ !specifier.startsWith('http://') &&
142142+ !specifier.startsWith('https://') &&
143143+ !isBuiltin(specifier)
144144+ ) {
143145 // Try to resolve bare specifier relative to esm.sh base
144146 const baseUrl = new URL(referrer)
145147 if (baseUrl.hostname === 'esm.sh') {
+10-8
shared/types/userSession.ts
···11import type { NodeSavedSession, NodeSavedState } from '@atproto/oauth-client-node'
2233export interface UserServerSession {
44- public: {
55- did: string
66- handle: string
77- pds: string
88- avatar?: string
99- }
44+ public?:
55+ | {
66+ did: string
77+ handle: string
88+ pds: string
99+ avatar?: string
1010+ }
1111+ | undefined
1012 // Only to be used in the atproto session and state stores
1113 // Will need to change to Record<string, T> and add a current logged in user if we ever want to support
1214 // multiple did logins per server session
1313- oauthSession: NodeSavedSession | undefined
1414- oauthState: NodeSavedState | undefined
1515+ oauthSession?: NodeSavedSession | undefined
1616+ oauthState?: NodeSavedState | undefined
1517}