All files / realm/blong-access/adapter/db google.ts

100% Statements 49/49
66.66% Branches 2/3
100% Functions 1/1
100% Lines 49/49

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 501x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 10x 10x 10x 10x 4x 4x 10x 10x  
import {library} from '@feasibleone/blong';
 
/** Identity-flow selector for the Google exchange (`oidc` default, `oauth` option). */
export type GoogleFlow = 'oidc' | 'oauth';
 
/** Google OAuth client configuration consumed by `accessIdentityCheck`. */
export type GoogleConfig = {
    /** Provider base URL — local mock in dev, `https://accounts.google.com` in production. */
    baseUrl?: string;
    clientId?: string;
    clientSecret?: string;
    redirectUri?: string;
    /**
     * Full authorization endpoint (e.g. Google's
     * `https://accounts.google.com/o/oauth2/v2/auth`).  When unset it is
     * resolved from OIDC discovery (`authorization_endpoint`), falling back to
     * `${baseUrl}/authorize` (the local mock's path).
     */
    authorizationEndpoint?: string;
    /**
     * OIDC discovery document URL (OIDC flow).  Defaults to
     * `${baseUrl}/.well-known/openid-configuration`; when unset/unreachable the
     * flow falls back to `${baseUrl}/token` + `${baseUrl}/certs`.
     */
    discoveryUrl?: string;
};
 
/**
 * Google OAuth client configuration.
 *
 * Read from the realm's `db` config slice (`config.<intent>.db.google` declared in
 * `server.ts`), so every suite that includes the access realm reuses the same defaults —
 * the local mock in `dev`, real Google endpoints (or an override) elsewhere.
 */
/** The Google helpers as a handler sees them, destructured from `lib`. */
export type GoogleLib = {
    /** Return the effective Google OAuth client config from the realm `db.google` slice. */
    googleConfig(): GoogleConfig;
};
 
export default library(({config}): GoogleLib => {
    const google = (config?.google ?? {}) as GoogleConfig;
    return {
        /** Return the effective Google OAuth client config from the realm `db.google` slice. */
        googleConfig(): GoogleConfig {
            return google;
        },
    };
});