···6767### client-side (browser)
68686969```ts
7070-import { createCABFetcher } from '@atcute/oauth-cab/client';
7070+import { createCabFetcher } from '@atcute/oauth-cab/client';
7171import { configureOAuth } from '@atcute/oauth-browser-client';
72727373configureOAuth({
7474 // ... other options
7575- fetchClientAssertion: createCABFetcher(), // defaults to location.origin
7575+ fetchClientAssertion: createCabFetcher(), // defaults to location.origin
7676});
7777```
+6-17
packages/oauth/cab/lib/client/index.ts
···11import { Client, simpleFetchHandler } from '@atcute/client';
22-33-// import lexicon types to augment XRPCProcedures
44-import '../lexicons/index.js';
55-66-import type {
77- ClientAssertionCredentials,
88- ClientAssertionFetcher,
99- FetchClientAssertionParams,
1010-} from './types.js';
22+import type { ClientAssertionFetcher } from '@atcute/oauth-browser-client';
1131212-const CLIENT_ASSERTION_TYPE_JWT_BEARER = 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer';
44+import type {} from '../lexicons/index.js';
135146/**
157 * options for creating a CAB fetcher
168 */
1717-export interface CreateCABFetcherOptions {
99+export interface CreateCabFetcherOptions {
1810 /** URL of CAB backend (defaults to location.origin) */
1911 service?: string | URL;
2012 /** optional custom fetch implementation */
···2921 * @param options fetcher configuration
3022 * @returns client assertion fetcher for use with oauth-browser-client
3123 */
3232-export const createCABFetcher = (options: CreateCABFetcherOptions = {}): ClientAssertionFetcher => {
2424+export const createCabFetcher = (options: CreateCabFetcherOptions = {}): ClientAssertionFetcher => {
3325 const serviceUrl = new URL(options.service ?? location.origin);
34263527 const client = new Client({
···3931 }),
4032 });
41334242- return async (params: FetchClientAssertionParams): Promise<ClientAssertionCredentials> => {
3434+ return async (params) => {
4335 const { aud, createDpopProof } = params;
44364537 // build the endpoint URL for DPoP proof (htu is origin + pathname only)
···7668 const { client_assertion } = response.data;
77697870 return {
7171+ client_assertion_type: 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer',
7972 client_assertion,
8080- client_assertion_type: CLIENT_ASSERTION_TYPE_JWT_BEARER,
8173 };
8274 };
8375};
8484-8585-// re-export types for convenience
8686-export type { ClientAssertionCredentials, ClientAssertionFetcher, FetchClientAssertionParams };
-35
packages/oauth/cab/lib/client/types.ts
···11-/**
22- * client assertion credentials returned from a CAB backend.
33- */
44-export interface ClientAssertionCredentials {
55- /** the signed JWT assertion */
66- client_assertion: string;
77- /** the assertion type (always jwt-bearer) */
88- client_assertion_type: 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer';
99-}
1010-1111-/**
1212- * parameters for fetching a client assertion.
1313- */
1414-export interface FetchClientAssertionParams {
1515- /** JWK thumbprint of the DPoP key to bind the assertion to */
1616- jkt: string;
1717- /** authorization server issuer (audience for the assertion) */
1818- aud: string;
1919-2020- /**
2121- * create a DPoP proof to prove you possess the key for the claimed jkt.
2222- *
2323- * @param htu origin and pathname to the CAB backend
2424- * @param nonce optional DPoP nonce from the server
2525- * @returns DPoP proof that can be included in the request
2626- */
2727- createDpopProof: (htu: string, nonce?: string) => Promise<string>;
2828-}
2929-3030-/**
3131- * function that fetches a client assertion from a CAB backend.
3232- */
3333-export type ClientAssertionFetcher = (
3434- params: FetchClientAssertionParams,
3535-) => Promise<ClientAssertionCredentials>;