a collection of lightweight TypeScript packages for AT Protocol, the protocol powering Bluesky
atproto bluesky typescript npm
101
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix(oauth-browser-client): fix type errors

Mary aa37fc7a 45dd5fb7

+17 -17
+2 -2
packages/oauth/browser-client/lib/agents/server-agent.ts
··· 74 74 } 75 75 } 76 76 77 - async refresh({ sub, token }: { sub: At.DID; token: TokenInfo }): Promise<TokenInfo> { 77 + async refresh({ sub, token }: { sub: At.Did; token: TokenInfo }): Promise<TokenInfo> { 78 78 if (!token.refresh) { 79 79 throw new TokenRefreshError(sub, 'no refresh token available'); 80 80 } ··· 133 133 return { 134 134 token: token, 135 135 info: { 136 - sub: sub as At.DID, 136 + sub: sub as At.Did, 137 137 aud: resolved.identity.pds.href, 138 138 server: pick(resolved.metadata, [ 139 139 'issuer',
+6 -6
packages/oauth/browser-client/lib/agents/sessions.ts
··· 14 14 } 15 15 16 16 type PendingItem<V> = Promise<{ value: V; isFresh: boolean }>; 17 - const pending = new Map<At.DID, PendingItem<Session>>(); 17 + const pending = new Map<At.Did, PendingItem<Session>>(); 18 18 19 - export const getSession = async (sub: At.DID, options?: SessionGetOptions): Promise<Session> => { 19 + export const getSession = async (sub: At.Did, options?: SessionGetOptions): Promise<Session> => { 20 20 options?.signal?.throwIfAborted(); 21 21 22 22 let allowStored = isTokenUsable; ··· 89 89 return value; 90 90 }; 91 91 92 - export const storeSession = async (sub: At.DID, newSession: Session): Promise<void> => { 92 + export const storeSession = async (sub: At.Did, newSession: Session): Promise<void> => { 93 93 try { 94 94 database.sessions.set(sub, newSession); 95 95 } catch (err) { ··· 98 98 } 99 99 }; 100 100 101 - export const deleteStoredSession = (sub: At.DID): void => { 101 + export const deleteStoredSession = (sub: At.Did): void => { 102 102 database.sessions.delete(sub); 103 103 }; 104 104 105 - export const listStoredSessions = (): At.DID[] => { 105 + export const listStoredSessions = (): At.Did[] => { 106 106 return database.sessions.keys(); 107 107 }; 108 108 109 109 const returnTrue = () => true; 110 110 const returnFalse = () => false; 111 111 112 - const refreshToken = async (sub: At.DID, storedSession: Session | undefined): Promise<Session> => { 112 + const refreshToken = async (sub: At.Did, storedSession: Session | undefined): Promise<Session> => { 113 113 if (storedSession === undefined) { 114 114 throw new TokenRefreshError(sub, `session deleted by another tab`); 115 115 }
+1 -1
packages/oauth/browser-client/lib/agents/user-agent.ts
··· 16 16 this.#fetch = createDPoPFetch(CLIENT_ID, session.dpopKey, false); 17 17 } 18 18 19 - get sub(): At.DID { 19 + get sub(): At.Did { 20 20 return this.session.info.sub; 21 21 } 22 22
+1 -1
packages/oauth/browser-client/lib/errors.ts
··· 16 16 override name = 'TokenRefreshError'; 17 17 18 18 constructor( 19 - public readonly sub: At.DID, 19 + public readonly sub: At.Did, 20 20 message: string, 21 21 options?: ErrorOptions, 22 22 ) {
+3 -3
packages/oauth/browser-client/lib/resolvers.ts
··· 16 16 * @param handle Domain handle to resolve 17 17 * @returns DID identifier resolved from the domain handle 18 18 */ 19 - export const resolveHandle = async (handle: string): Promise<At.DID> => { 19 + export const resolveHandle = async (handle: string): Promise<At.Did> => { 20 20 const url = DEFAULT_APPVIEW_URL + `/xrpc/com.atproto.identity.resolveHandle` + `?handle=${handle}`; 21 21 22 22 const response = await fetch(url); ··· 35 35 * @param did DID identifier we're seeking DID doc from 36 36 * @returns Retrieved DID document 37 37 */ 38 - export const getDidDocument = async (did: At.DID): Promise<DidDocument> => { 38 + export const getDidDocument = async (did: At.Did): Promise<DidDocument> => { 39 39 const colon_index = did.indexOf(':', 4); 40 40 41 41 const type = did.slice(4, colon_index); ··· 151 151 export const resolveFromIdentity = async ( 152 152 ident: string, 153 153 ): Promise<{ identity: IdentityMetadata; metadata: AuthorizationServerMetadata }> => { 154 - let did: At.DID; 154 + let did: At.Did; 155 155 if (isDid(ident)) { 156 156 did = ident; 157 157 } else {
+1 -1
packages/oauth/browser-client/lib/store/db.ts
··· 18 18 19 19 interface Schema { 20 20 sessions: { 21 - key: At.DID; 21 + key: At.Did; 22 22 value: Session; 23 23 indexes: { 24 24 expiresAt: number;
+1 -1
packages/oauth/browser-client/lib/types/identity.ts
··· 1 1 import type { At } from '@atcute/client/lexicons'; 2 2 3 3 export interface IdentityMetadata { 4 - id: At.DID; 4 + id: At.Did; 5 5 raw: string; 6 6 pds: URL; 7 7 }
+1 -1
packages/oauth/browser-client/lib/types/token.ts
··· 34 34 } 35 35 36 36 export interface ExchangeInfo { 37 - sub: At.DID; 37 + sub: At.Did; 38 38 aud: string; 39 39 server: PersistedAuthorizationServerMetadata; 40 40 }
+1 -1
packages/oauth/browser-client/lib/utils/strings.ts
··· 2 2 3 3 const isUrlParseSupported = 'parse' in URL; 4 4 5 - export const isDid = (value: string): value is At.DID => { 5 + export const isDid = (value: string): value is At.Did => { 6 6 return value.startsWith('did:'); 7 7 }; 8 8