@buildbase/sdk 0.0.48 → 0.0.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +119 -0
- package/CHANGELOG.md +42 -0
- package/README.md +198 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +376 -2
- package/dist/index.mjs +1 -1
- package/dist/react/{index.js → index.cjs} +5 -5
- package/dist/react/index.d.ts +2 -0
- package/dist/react/index.mjs +5 -5
- package/package.json +11 -9
- package/dist/index.js +0 -1
- /package/dist/data/{index.js → index.cjs} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1112,6 +1112,8 @@ declare abstract class BaseApi {
|
|
|
1112
1112
|
protected url(path: string): string;
|
|
1113
1113
|
/** Merge auth + custom + per-request headers. */
|
|
1114
1114
|
private buildHeaders;
|
|
1115
|
+
/** Fire the onError callback exactly once per error, regardless of call path. */
|
|
1116
|
+
private reportError;
|
|
1115
1117
|
/** Execute fetch with timeout, retries, debug logging, and error callback. */
|
|
1116
1118
|
private executeFetch;
|
|
1117
1119
|
/** Internal: execute fetch against a resolved URL with timeout, retries, debug logging, and error callback. */
|
|
@@ -2285,6 +2287,378 @@ declare function parseWebhookEvent(options: {
|
|
|
2285
2287
|
data: Record<string, any>;
|
|
2286
2288
|
} | null;
|
|
2287
2289
|
|
|
2290
|
+
/**
|
|
2291
|
+
* Agent-readiness discovery toolkit (server-side, framework-agnostic).
|
|
2292
|
+
*
|
|
2293
|
+
* Makes a consuming app "agent ready" (see https://isitagentready.com) by
|
|
2294
|
+
* serving the standard machine-readable discovery documents an AI agent looks
|
|
2295
|
+
* for — with the BuildBase server as the source of truth.
|
|
2296
|
+
*
|
|
2297
|
+
* The heavy lifting already lives on the platform: an org admin configures
|
|
2298
|
+
* agent readiness once (protected resources, scopes, llms.txt) and the server
|
|
2299
|
+
* publishes the OAuth2 authorization-server metadata (RFC 8414) and the
|
|
2300
|
+
* per-resource protected-resource metadata (RFC 9728). This module lets an app
|
|
2301
|
+
* re-serve those documents from its own origin — where agents actually look —
|
|
2302
|
+
* plus generate the static discovery documents (Agent Card, Agent Skills,
|
|
2303
|
+
* security.txt) from local config. The result: an org admin adds full agent
|
|
2304
|
+
* support to their app in a couple of lines, and never hand-writes a
|
|
2305
|
+
* `.well-known` route.
|
|
2306
|
+
*
|
|
2307
|
+
* Zero React and no framework types — every function returns plain data. The
|
|
2308
|
+
* only runtime dependency is `fetch`; SHA-256 (for Agent Skills digests) is a
|
|
2309
|
+
* dependency-free pure-JS implementation, so there is no Web Crypto / Node
|
|
2310
|
+
* `crypto` requirement and output is identical on every runtime (browser, edge,
|
|
2311
|
+
* Node 18+). Wire the returned documents into your router yourself (Next.js,
|
|
2312
|
+
* Hono, Express, …).
|
|
2313
|
+
*
|
|
2314
|
+
* @example Next.js App Router — the entire integration:
|
|
2315
|
+
* ```ts
|
|
2316
|
+
* // lib/agent-ready.ts
|
|
2317
|
+
* import type { AgentReadyConfig } from "@buildbase/sdk";
|
|
2318
|
+
* export const agentConfig: AgentReadyConfig = {
|
|
2319
|
+
* serverUrl: process.env.BUILDBASE_URL!,
|
|
2320
|
+
* orgId: process.env.BUILDBASE_ORG_ID!,
|
|
2321
|
+
* siteUrl: "https://imejis.io",
|
|
2322
|
+
* site: { name: "Imejis", description: "Generate images from templates via API." },
|
|
2323
|
+
* };
|
|
2324
|
+
*
|
|
2325
|
+
* // app/.well-known/[...path]/route.ts
|
|
2326
|
+
* import { resolveWellKnown } from "@buildbase/sdk";
|
|
2327
|
+
* import { agentConfig } from "@/lib/agent-ready";
|
|
2328
|
+
* export async function GET(req: Request) {
|
|
2329
|
+
* const doc = await resolveWellKnown(new URL(req.url).pathname, agentConfig);
|
|
2330
|
+
* if (!doc) return new Response('{"error":"not_found"}', { status: 404 });
|
|
2331
|
+
* return new Response(doc.body, {
|
|
2332
|
+
* status: doc.status,
|
|
2333
|
+
* headers: { "Content-Type": doc.contentType, "Cache-Control": doc.cacheControl },
|
|
2334
|
+
* });
|
|
2335
|
+
* }
|
|
2336
|
+
*
|
|
2337
|
+
* // app/llms.txt/route.ts
|
|
2338
|
+
* import { buildLlmsTxt, fetchAgentReadiness } from "@buildbase/sdk";
|
|
2339
|
+
* import { agentConfig } from "@/lib/agent-ready";
|
|
2340
|
+
* export async function GET() {
|
|
2341
|
+
* const doc = buildLlmsTxt(agentConfig, await fetchAgentReadiness(agentConfig));
|
|
2342
|
+
* if (!doc) return new Response("Not found", { status: 404 });
|
|
2343
|
+
* return new Response(doc.body, { headers: { "Content-Type": doc.contentType } });
|
|
2344
|
+
* }
|
|
2345
|
+
* ```
|
|
2346
|
+
*/
|
|
2347
|
+
/**
|
|
2348
|
+
* The agent-readiness bundle the BuildBase server publishes for an org at
|
|
2349
|
+
* `GET /api/v1/public/:orgId/agent-readiness`. This is the single source of
|
|
2350
|
+
* truth an org admin edits; everything org-specific below is derived from it.
|
|
2351
|
+
*/
|
|
2352
|
+
interface AgentReadinessBundle {
|
|
2353
|
+
/** False when the org has not enabled agent readiness — everything else absent. */
|
|
2354
|
+
enabled: boolean;
|
|
2355
|
+
/** Pointer to the org's RFC 8414 authorization-server metadata. */
|
|
2356
|
+
authorizationServer?: {
|
|
2357
|
+
issuer: string;
|
|
2358
|
+
metadataUrl: string;
|
|
2359
|
+
};
|
|
2360
|
+
/**
|
|
2361
|
+
* RFC 9728 protected-resource metadata objects, ready to serve. Each `metadata`
|
|
2362
|
+
* is a complete document; `resource` is the canonical resource URI it describes.
|
|
2363
|
+
*/
|
|
2364
|
+
protectedResources?: Array<{
|
|
2365
|
+
resource: string;
|
|
2366
|
+
metadata: Record<string, unknown>;
|
|
2367
|
+
}>;
|
|
2368
|
+
/** Org-authored llms.txt content, or null when unset. */
|
|
2369
|
+
llmsTxt?: string | null;
|
|
2370
|
+
}
|
|
2371
|
+
/** An Agent Skill (Agent Skills Discovery RFC v0.2.0) published by this app. */
|
|
2372
|
+
interface AgentSkill {
|
|
2373
|
+
/** Stable slug, e.g. `imejis-api`. */
|
|
2374
|
+
name: string;
|
|
2375
|
+
/** One-line human/agent-readable summary. */
|
|
2376
|
+
description: string;
|
|
2377
|
+
/** Full markdown content of the SKILL.md served for this skill. */
|
|
2378
|
+
content: string;
|
|
2379
|
+
/**
|
|
2380
|
+
* Path the SKILL.md is served from. Defaults to
|
|
2381
|
+
* `/.well-known/agent-skills/<name>/SKILL.md`.
|
|
2382
|
+
*/
|
|
2383
|
+
path?: string;
|
|
2384
|
+
/** Skill artifact kind. Defaults to `skill-md`. */
|
|
2385
|
+
type?: 'skill-md' | 'archive';
|
|
2386
|
+
}
|
|
2387
|
+
/** Configuration for the agent-readiness discovery layer. */
|
|
2388
|
+
interface AgentReadyConfig {
|
|
2389
|
+
/** BuildBase server base URL, e.g. `https://api.buildbase.app` (no trailing slash needed). */
|
|
2390
|
+
serverUrl: string;
|
|
2391
|
+
/** The org id (24-hex) whose agent-readiness config to serve. */
|
|
2392
|
+
orgId: string;
|
|
2393
|
+
/**
|
|
2394
|
+
* This app's public origin, e.g. `https://imejis.io`. Used to build absolute
|
|
2395
|
+
* URLs in the Agent Card and to match RFC 9728 resource paths.
|
|
2396
|
+
*/
|
|
2397
|
+
siteUrl: string;
|
|
2398
|
+
/** Static metadata for the Agent Card (`/.well-known/agent.json`). */
|
|
2399
|
+
site: {
|
|
2400
|
+
name: string;
|
|
2401
|
+
description?: string;
|
|
2402
|
+
/** Absolute URL to human/agent documentation. */
|
|
2403
|
+
documentationUrl?: string;
|
|
2404
|
+
/** Support/contact email surfaced on the Agent Card. */
|
|
2405
|
+
contactEmail?: string;
|
|
2406
|
+
/** Provider block; defaults to `{ name: site.name, url: siteUrl }`. */
|
|
2407
|
+
provider?: {
|
|
2408
|
+
name: string;
|
|
2409
|
+
url: string;
|
|
2410
|
+
};
|
|
2411
|
+
};
|
|
2412
|
+
/** Agent Skills to publish. Omit to skip the Agent Skills documents. */
|
|
2413
|
+
skills?: AgentSkill[];
|
|
2414
|
+
/** security.txt fields (RFC 9116). Omit to skip serving security.txt. */
|
|
2415
|
+
security?: {
|
|
2416
|
+
/** Contact URI(s) — email (`mailto:`) or URL. */
|
|
2417
|
+
contact: string | string[];
|
|
2418
|
+
/** ISO-8601 expiry; strongly recommended by RFC 9116. */
|
|
2419
|
+
expires?: string;
|
|
2420
|
+
/** Security policy URL. */
|
|
2421
|
+
policy?: string;
|
|
2422
|
+
};
|
|
2423
|
+
/** TTL (seconds) for cached platform fetches. Default 300 (5 min). */
|
|
2424
|
+
cacheTtlSeconds?: number;
|
|
2425
|
+
/** Injectable fetch, mainly for testing. Defaults to the global `fetch`. */
|
|
2426
|
+
fetch?: typeof fetch;
|
|
2427
|
+
}
|
|
2428
|
+
/** A rendered discovery document ready to become an HTTP response. */
|
|
2429
|
+
interface DiscoveryDocument {
|
|
2430
|
+
status: number;
|
|
2431
|
+
contentType: string;
|
|
2432
|
+
body: string;
|
|
2433
|
+
cacheControl: string;
|
|
2434
|
+
}
|
|
2435
|
+
/**
|
|
2436
|
+
* SHA-256 of `content` as `sha256:<hex>`, via the shared pure-JS hash (no Web
|
|
2437
|
+
* Crypto / Node `crypto`), so output is identical on every runtime.
|
|
2438
|
+
*/
|
|
2439
|
+
declare function sha256Digest(content: string): string;
|
|
2440
|
+
/**
|
|
2441
|
+
* Fetch (and cache) an org's agent-readiness bundle from the BuildBase server.
|
|
2442
|
+
*
|
|
2443
|
+
* Fail-soft: any network/HTTP/parse error resolves to `{ enabled: false }` so a
|
|
2444
|
+
* discovery route never 500s and never leaks the platform being down — agents
|
|
2445
|
+
* simply see the app as not (yet) agent-ready.
|
|
2446
|
+
*/
|
|
2447
|
+
declare function fetchAgentReadiness(config: AgentReadyConfig): Promise<AgentReadinessBundle>;
|
|
2448
|
+
/** Clear the in-memory agent-readiness cache (mainly for tests). */
|
|
2449
|
+
declare function clearAgentReadinessCache(): void;
|
|
2450
|
+
/**
|
|
2451
|
+
* The Agent Card served at `/.well-known/agent.json`. A stable, machine-readable
|
|
2452
|
+
* entry point advertising who this app is and where agents can discover more.
|
|
2453
|
+
*/
|
|
2454
|
+
declare function buildAgentCard(config: AgentReadyConfig, bundle: AgentReadinessBundle): DiscoveryDocument;
|
|
2455
|
+
/**
|
|
2456
|
+
* Resolve the RFC 9728 protected-resource metadata for a request path, or null
|
|
2457
|
+
* if no configured resource maps to it.
|
|
2458
|
+
*/
|
|
2459
|
+
declare function buildProtectedResourceMetadata(requestPath: string, config: AgentReadyConfig, bundle: AgentReadinessBundle): DiscoveryDocument | null;
|
|
2460
|
+
/** Agent Skills discovery index (Agent Skills Discovery RFC v0.2.0). */
|
|
2461
|
+
declare function buildAgentSkillsIndex(config: AgentReadyConfig): DiscoveryDocument | null;
|
|
2462
|
+
/** Serve a single skill's SKILL.md by request path, or null if none matches. */
|
|
2463
|
+
declare function buildSkillMd(requestPath: string, config: AgentReadyConfig): DiscoveryDocument | null;
|
|
2464
|
+
/** security.txt (RFC 9116), or null when not configured. */
|
|
2465
|
+
declare function buildSecurityTxt(config: AgentReadyConfig): DiscoveryDocument | null;
|
|
2466
|
+
/** The org-authored llms.txt, or null when the org hasn't set one. */
|
|
2467
|
+
declare function buildLlmsTxt(config: AgentReadyConfig, bundle: AgentReadinessBundle): DiscoveryDocument | null;
|
|
2468
|
+
/**
|
|
2469
|
+
* Resolve any `.well-known` request path to its discovery document, or null if
|
|
2470
|
+
* this app serves nothing there (caller should 404).
|
|
2471
|
+
*
|
|
2472
|
+
* Handles: agent.json, oauth-protected-resource (+ per-resource paths),
|
|
2473
|
+
* oauth-authorization-server (pointer), agent-skills index + SKILL.md,
|
|
2474
|
+
* security.txt.
|
|
2475
|
+
*/
|
|
2476
|
+
declare function resolveWellKnown(requestPath: string, config: AgentReadyConfig): Promise<DiscoveryDocument | null>;
|
|
2477
|
+
|
|
2478
|
+
/**
|
|
2479
|
+
* OAuth2 app-bridge toolkit (server-side).
|
|
2480
|
+
*
|
|
2481
|
+
* BuildBase runs the OAuth2 authorization flow (login, consent, code, PKCE,
|
|
2482
|
+
* refresh rotation) but it never mints the access token itself — on the token
|
|
2483
|
+
* grant it calls the org's own backend to mint the token the agent will carry.
|
|
2484
|
+
* Concretely, the platform makes signed webhook-style calls to two endpoints an
|
|
2485
|
+
* OAuth2 client registers:
|
|
2486
|
+
*
|
|
2487
|
+
* • applicationTokenUrl — mint an access token for a user (required)
|
|
2488
|
+
* • applicationRevokeUrl — invalidate a user's token on revocation (optional)
|
|
2489
|
+
*
|
|
2490
|
+
* Both requests carry an `Authorization: Bearer <JWT>` where the JWT is HS256,
|
|
2491
|
+
* signed with the client's secret (so possession of the secret authenticates
|
|
2492
|
+
* the platform). This module verifies those requests and shapes the responses,
|
|
2493
|
+
* so an implementor writes only the part that is theirs: minting/invalidating a
|
|
2494
|
+
* token in their own format.
|
|
2495
|
+
*
|
|
2496
|
+
* HMAC verification uses the SDK's dependency-free pure-JS HMAC-SHA256 (no Web
|
|
2497
|
+
* Crypto, no Node `crypto`, no `require`), so it behaves identically whether the
|
|
2498
|
+
* bundle is loaded as ESM or CJS, under a bundler or on bare Node.
|
|
2499
|
+
*
|
|
2500
|
+
* @example applicationTokenUrl handler (Next.js Pages Router):
|
|
2501
|
+
* ```ts
|
|
2502
|
+
* import { handleAppTokenRequest } from "@buildbase/sdk";
|
|
2503
|
+
* export default async function handler(req, res) {
|
|
2504
|
+
* const { status, body } = await handleAppTokenRequest({
|
|
2505
|
+
* authorization: req.headers.authorization,
|
|
2506
|
+
* clientSecret: process.env.BUILDBASE_CLIENT_SECRET!,
|
|
2507
|
+
* mintToken: (user) => ({
|
|
2508
|
+
* token: signMyAccessToken(user, { aud: user.resource }), // your token, your format
|
|
2509
|
+
* expiresIn: 3600,
|
|
2510
|
+
* }),
|
|
2511
|
+
* });
|
|
2512
|
+
* res.status(status).json(body);
|
|
2513
|
+
* }
|
|
2514
|
+
* ```
|
|
2515
|
+
*/
|
|
2516
|
+
/** Thrown when an incoming platform request fails verification. */
|
|
2517
|
+
declare class AppBridgeError extends Error {
|
|
2518
|
+
/** Machine-readable reason, e.g. `invalid_signature`, `token_expired`. */
|
|
2519
|
+
readonly code: string;
|
|
2520
|
+
constructor(code: string, message: string);
|
|
2521
|
+
}
|
|
2522
|
+
/**
|
|
2523
|
+
* The user + grant context BuildBase sends to `applicationTokenUrl`. The app
|
|
2524
|
+
* mints a token for this user; `resource` is the RFC 8707 audience(s) the token
|
|
2525
|
+
* should be bound to (stamp them as `aud`), and `scope` is what the user granted.
|
|
2526
|
+
* Unknown claims are preserved for forward-compatibility.
|
|
2527
|
+
*/
|
|
2528
|
+
interface AppTokenRequestClaims {
|
|
2529
|
+
/** The user's id in the org. */
|
|
2530
|
+
id: string;
|
|
2531
|
+
email: string;
|
|
2532
|
+
name?: string;
|
|
2533
|
+
role?: string;
|
|
2534
|
+
emailVerified?: boolean;
|
|
2535
|
+
image?: string;
|
|
2536
|
+
blocked?: boolean;
|
|
2537
|
+
blockedReason?: string;
|
|
2538
|
+
blockedAt?: string;
|
|
2539
|
+
/** Which grant triggered this mint. */
|
|
2540
|
+
grantType?: 'authorization_code' | 'refresh_token';
|
|
2541
|
+
/** Scopes granted at authorization time. */
|
|
2542
|
+
scope?: string[];
|
|
2543
|
+
/** RFC 8707 resource indicator(s) — bind the minted token's `aud` to these. */
|
|
2544
|
+
resource?: string[];
|
|
2545
|
+
/** The OAuth2 client's display title. */
|
|
2546
|
+
clientTitle?: string;
|
|
2547
|
+
[claim: string]: unknown;
|
|
2548
|
+
}
|
|
2549
|
+
/** The payload BuildBase sends to `applicationRevokeUrl`. */
|
|
2550
|
+
interface AppRevokeRequestClaims {
|
|
2551
|
+
userId: string;
|
|
2552
|
+
clientId: string;
|
|
2553
|
+
reason: string;
|
|
2554
|
+
[claim: string]: unknown;
|
|
2555
|
+
}
|
|
2556
|
+
/**
|
|
2557
|
+
* Verify a BuildBase-issued HS256 JWT (signed with the client secret) and return
|
|
2558
|
+
* its payload. Checks the signature (timing-safe), the algorithm, and `exp`/`nbf`.
|
|
2559
|
+
* Throws {@link AppBridgeError} on any failure.
|
|
2560
|
+
*/
|
|
2561
|
+
declare function verifyClientJwt(token: string, clientSecret: string, clockToleranceSec?: number): Record<string, any>;
|
|
2562
|
+
/** Extract the token from an `Authorization: Bearer <token>` header. */
|
|
2563
|
+
declare function extractBearerToken(authorization: string | null | undefined): string | null;
|
|
2564
|
+
interface VerifyOptions {
|
|
2565
|
+
/** The `Authorization` header value from the incoming request. */
|
|
2566
|
+
authorization: string | null | undefined;
|
|
2567
|
+
/** Your OAuth2 client's secret (the signing key). */
|
|
2568
|
+
clientSecret: string;
|
|
2569
|
+
/** Allowed clock skew in seconds for exp/nbf. Default 60. */
|
|
2570
|
+
clockToleranceSec?: number;
|
|
2571
|
+
}
|
|
2572
|
+
/** Verify an `applicationTokenUrl` request and return the user + grant context. */
|
|
2573
|
+
declare function verifyAppTokenRequest(options: VerifyOptions): AppTokenRequestClaims;
|
|
2574
|
+
/** Verify an `applicationRevokeUrl` request and return the revocation context. */
|
|
2575
|
+
declare function verifyAppRevokeRequest(options: VerifyOptions): AppRevokeRequestClaims;
|
|
2576
|
+
/** What your `mintToken` returns: an access token and, ideally, its lifetime. */
|
|
2577
|
+
interface AppTokenResult {
|
|
2578
|
+
/** The access token your app minted (its own format). */
|
|
2579
|
+
token: string;
|
|
2580
|
+
/** Token lifetime in seconds; the platform surfaces it as `expires_in`. */
|
|
2581
|
+
expiresIn?: number;
|
|
2582
|
+
/** Optional human-readable message. */
|
|
2583
|
+
message?: string;
|
|
2584
|
+
}
|
|
2585
|
+
/**
|
|
2586
|
+
* The exact body shape the platform expects from `applicationTokenUrl`
|
|
2587
|
+
* (`{ success, token, message }`, plus optional `expiresIn`; no other keys).
|
|
2588
|
+
*/
|
|
2589
|
+
interface AppTokenResponseBody {
|
|
2590
|
+
success: boolean;
|
|
2591
|
+
token: string;
|
|
2592
|
+
message: string;
|
|
2593
|
+
expiresIn?: number;
|
|
2594
|
+
}
|
|
2595
|
+
/** Build a success body for `applicationTokenUrl`. */
|
|
2596
|
+
declare function appTokenSuccess(result: AppTokenResult): AppTokenResponseBody;
|
|
2597
|
+
/** Build a failure body for `applicationTokenUrl`. */
|
|
2598
|
+
declare function appTokenFailure(message: string): AppTokenResponseBody;
|
|
2599
|
+
/** The `{ status, body }` a framework-agnostic handler returns. */
|
|
2600
|
+
interface HandlerResult<T> {
|
|
2601
|
+
status: number;
|
|
2602
|
+
body: T;
|
|
2603
|
+
}
|
|
2604
|
+
/**
|
|
2605
|
+
* Verify an `applicationTokenUrl` request, mint via your callback, and return
|
|
2606
|
+
* the exact response the platform expects. Returns 401 with a failure body when
|
|
2607
|
+
* verification fails; errors thrown by `mintToken` propagate to you.
|
|
2608
|
+
*
|
|
2609
|
+
* @example
|
|
2610
|
+
* ```ts
|
|
2611
|
+
* const { status, body } = await handleAppTokenRequest({
|
|
2612
|
+
* authorization: req.headers.authorization,
|
|
2613
|
+
* clientSecret: process.env.BUILDBASE_CLIENT_SECRET!,
|
|
2614
|
+
* mintToken: (user) => ({ token: signMyJwt(user, { aud: user.resource }), expiresIn: 3600 }),
|
|
2615
|
+
* });
|
|
2616
|
+
* res.status(status).json(body);
|
|
2617
|
+
* ```
|
|
2618
|
+
*/
|
|
2619
|
+
declare function handleAppTokenRequest(options: {
|
|
2620
|
+
authorization: string | null | undefined;
|
|
2621
|
+
clientSecret: string;
|
|
2622
|
+
mintToken: (claims: AppTokenRequestClaims) => AppTokenResult | Promise<AppTokenResult>;
|
|
2623
|
+
clockToleranceSec?: number;
|
|
2624
|
+
}): Promise<HandlerResult<AppTokenResponseBody>>;
|
|
2625
|
+
/**
|
|
2626
|
+
* Verify an `applicationRevokeUrl` request and run your invalidation callback.
|
|
2627
|
+
* Returns 401 on verification failure; errors thrown by `onRevoke` propagate.
|
|
2628
|
+
*/
|
|
2629
|
+
declare function handleAppRevokeRequest(options: {
|
|
2630
|
+
authorization: string | null | undefined;
|
|
2631
|
+
clientSecret: string;
|
|
2632
|
+
onRevoke: (claims: AppRevokeRequestClaims) => void | Promise<void>;
|
|
2633
|
+
clockToleranceSec?: number;
|
|
2634
|
+
}): Promise<HandlerResult<{
|
|
2635
|
+
success: boolean;
|
|
2636
|
+
message?: string;
|
|
2637
|
+
}>>;
|
|
2638
|
+
/**
|
|
2639
|
+
* Build the 401 an agent should receive when it calls your protected API without
|
|
2640
|
+
* a valid token. The `WWW-Authenticate: Bearer resource_metadata=...` header
|
|
2641
|
+
* points the agent at your `/.well-known/oauth-protected-resource` document,
|
|
2642
|
+
* bootstrapping the OAuth discovery flow (RFC 9728 §5.1, RFC 6750 §3).
|
|
2643
|
+
*
|
|
2644
|
+
* @example
|
|
2645
|
+
* ```ts
|
|
2646
|
+
* if (!isValid(token)) {
|
|
2647
|
+
* const c = bearerChallenge({ resourceMetadataUrl: "https://imejis.io/.well-known/oauth-protected-resource" });
|
|
2648
|
+
* res.writeHead(c.status, c.headers).end(c.body);
|
|
2649
|
+
* }
|
|
2650
|
+
* ```
|
|
2651
|
+
*/
|
|
2652
|
+
declare function bearerChallenge(options: {
|
|
2653
|
+
resourceMetadataUrl: string;
|
|
2654
|
+
error?: 'invalid_token' | 'insufficient_scope' | string;
|
|
2655
|
+
errorDescription?: string;
|
|
2656
|
+
}): {
|
|
2657
|
+
status: number;
|
|
2658
|
+
headers: Record<string, string>;
|
|
2659
|
+
body: string;
|
|
2660
|
+
};
|
|
2661
|
+
|
|
2288
2662
|
interface BuildBaseConfig {
|
|
2289
2663
|
/** Base URL of the BuildBase API server */
|
|
2290
2664
|
serverUrl: string;
|
|
@@ -2569,5 +2943,5 @@ interface BuildBaseResult extends ScopedActions {
|
|
|
2569
2943
|
}
|
|
2570
2944
|
declare function BuildBase(config: BuildBaseConfig): BuildBaseResult;
|
|
2571
2945
|
|
|
2572
|
-
export { ApiVersion, AuthApi, AuthStatus, BBAction, BBScreen, BBStatus, BB_PARAM, BaseApi, BetaForm, BillingIntervals, BuildBase, CURRENCY_DISPLAY, CURRENCY_FLAG, CreditBucketSource, CreditBucketStatus, CreditTransactionType, DEFAULT_ROLE_PERMISSIONS, DunningState, EventEmitter, InvoiceStatuses, PLAN_CURRENCY_CODES, PLAN_CURRENCY_OPTIONS, PUSH_SERVICE_WORKER_SCRIPT, Permission, PushApi, SDKEvent, SettingsApi, SubscriptionItemType, SubscriptionStatus, UserApi, WorkspaceApi, calculateBillableSeats, calculateSeatOverageCents, calculateTotalSubscriptionCents, cleanBBParams, clearAuthIntent, consumeAuthIntent, createBBUrl, createCheckoutRedirectUrls, createCreditPurchaseRedirectUrls, BuildBase as default, eventEmitter, formatCents, formatOverageRate, formatOverageRateWithLabel, formatQuotaIncludedOverage, formatQuotaWithPrice, getAvailableCurrenciesFromPlans, getBasePriceCents, getBillingIntervalAndCurrencyFromPriceId, getCurrencyFlag, getCurrencySymbol, getDisplayCurrency, getPerSeatPriceCents, getPricingVariant, getQuotaDisplayValue, getQuotaDisplayWithVariant, getQuotaOverageCents, getQuotaUnitLabelFromName, getSeatPricing, getStripePriceIdForInterval, hasPermission, invalidateCreditBalance, invalidateQuotaUsage, invalidateSubscription, parseWebhookEvent, readBBParams, resolveMaxUsers, resolvePermissions, safeRedirect, saveAuthIntent, validateInvite, validateRedirectUrl, verifyWebhookSignature };
|
|
2573
|
-
export type { BBActionType, BBScreenType, BBStatusType, BetaFormData, BetaFormResponse, BillingInterval, BuildBaseConfig, BuildBaseResult, BuildBaseSession, CheckoutResult, CreditActions, CreditBucketSourceType, CreditBucketStatusType, CreditTransactionTypeValue, DunningStateType, EventData, EventType, FeatureActions, FormatQuotaWithPriceOptions, GetCheckoutStripeParams, IAllQuotaUsageResponse, IBaseApiConfig, IBasePricing, IBetaConfig, ICheckoutSessionRequest, ICheckoutSessionResponse, ICheckoutStripeOptions, IConsumeCreditsRequest, IConsumeCreditsResponse, ICreditBalance, ICreditBucket, ICreditBucketsQuery, ICreditBucketsResponse, ICreditPackage, ICreditPackagePricingVariant, ICreditPurchaseRequest, ICreditPurchaseResponse, ICreditTransaction, ICreditTransactionsQuery, ICreditTransactionsResponse, IEventCallbacks, IExpiringCreditsResponse, IInvoice, IInvoiceListResponse, IInvoiceResponse, IOsConfig, IOsState, IPlan, IPlanGroup, IPlanGroupInfo, IPlanGroupLatestVersion, IPlanGroupResponse, IPlanGroupVersion, IPlanGroupVersionWithPlans, IPlanGroupVersionsResponse, IPlanVersion, IPlanVersionSummary, IPlanVersionWithPlan, IPricingVariant, IPublicCreditPackage, IPublicCreditPackagesResponse, IPublicPlanItem, IPublicPlanItemCategory, IPublicPlanVersion, IPublicPlansResponse, IQuotaByInterval, IQuotaIntervalValue, IQuotaOveragePriceIdsByInterval, IQuotaOveragesByInterval, IQuotaUsageStatus, IQuotaUsageStatusResponse, IRecordUsageRequest, IRecordUsageResponse, IStripePricesByInterval, ISubscription, ISubscriptionItem, ISubscriptionResponse, ISubscriptionUpdateRequest, ISubscriptionUpdateResponse, IUsageLogEntry, IUsageLogsQuery, IUsageLogsResponse, InviteBlockReason, InviteValidation, InvoiceActions, InvoiceStatus, InvoiceStatusType, MaxUsersConfig, NotificationData, NotificationEvent, NotificationResult, OnWorkspaceChangeParams, PermissionActions, PermissionContext, PermissionKey, PlanActions, PlanVersionWithPricingVariants, QuotaDisplayValue, QuotaDisplayWithOverage, RolePermissionMap, ScopedActions, SettingsActions, SubscriptionActions, SubscriptionItemTypeValue, SubscriptionStatusType, UsageActions, UserActions, UserCreatedEventData, UserUpdatedEventData, WorkspaceActions, WorkspaceChangedEventData, WorkspaceCreatedEventData, WorkspaceDeletedEventData, WorkspaceUpdatedEventData, WorkspaceUserAddedEventData, WorkspaceUserRemovedEventData, WorkspaceUserRoleChangedEventData };
|
|
2946
|
+
export { ApiVersion, AppBridgeError, AuthApi, AuthStatus, BBAction, BBScreen, BBStatus, BB_PARAM, BaseApi, BetaForm, BillingIntervals, BuildBase, CURRENCY_DISPLAY, CURRENCY_FLAG, CreditBucketSource, CreditBucketStatus, CreditTransactionType, DEFAULT_ROLE_PERMISSIONS, DunningState, EventEmitter, InvoiceStatuses, PLAN_CURRENCY_CODES, PLAN_CURRENCY_OPTIONS, PUSH_SERVICE_WORKER_SCRIPT, Permission, PushApi, SDKEvent, SettingsApi, SubscriptionItemType, SubscriptionStatus, UserApi, WorkspaceApi, appTokenFailure, appTokenSuccess, bearerChallenge, buildAgentCard, buildAgentSkillsIndex, buildLlmsTxt, buildProtectedResourceMetadata, buildSecurityTxt, buildSkillMd, calculateBillableSeats, calculateSeatOverageCents, calculateTotalSubscriptionCents, cleanBBParams, clearAgentReadinessCache, clearAuthIntent, consumeAuthIntent, createBBUrl, createCheckoutRedirectUrls, createCreditPurchaseRedirectUrls, BuildBase as default, eventEmitter, extractBearerToken, fetchAgentReadiness, formatCents, formatOverageRate, formatOverageRateWithLabel, formatQuotaIncludedOverage, formatQuotaWithPrice, getAvailableCurrenciesFromPlans, getBasePriceCents, getBillingIntervalAndCurrencyFromPriceId, getCurrencyFlag, getCurrencySymbol, getDisplayCurrency, getPerSeatPriceCents, getPricingVariant, getQuotaDisplayValue, getQuotaDisplayWithVariant, getQuotaOverageCents, getQuotaUnitLabelFromName, getSeatPricing, getStripePriceIdForInterval, handleAppRevokeRequest, handleAppTokenRequest, hasPermission, invalidateCreditBalance, invalidateQuotaUsage, invalidateSubscription, parseWebhookEvent, readBBParams, resolveMaxUsers, resolvePermissions, resolveWellKnown, safeRedirect, saveAuthIntent, sha256Digest, validateInvite, validateRedirectUrl, verifyAppRevokeRequest, verifyAppTokenRequest, verifyClientJwt, verifyWebhookSignature };
|
|
2947
|
+
export type { AgentReadinessBundle, AgentReadyConfig, AgentSkill, AppRevokeRequestClaims, AppTokenRequestClaims, AppTokenResponseBody, AppTokenResult, BBActionType, BBScreenType, BBStatusType, BetaFormData, BetaFormResponse, BillingInterval, BuildBaseConfig, BuildBaseResult, BuildBaseSession, CheckoutResult, CreditActions, CreditBucketSourceType, CreditBucketStatusType, CreditTransactionTypeValue, DiscoveryDocument, DunningStateType, EventData, EventType, FeatureActions, FormatQuotaWithPriceOptions, GetCheckoutStripeParams, HandlerResult, IAllQuotaUsageResponse, IBaseApiConfig, IBasePricing, IBetaConfig, ICheckoutSessionRequest, ICheckoutSessionResponse, ICheckoutStripeOptions, IConsumeCreditsRequest, IConsumeCreditsResponse, ICreditBalance, ICreditBucket, ICreditBucketsQuery, ICreditBucketsResponse, ICreditPackage, ICreditPackagePricingVariant, ICreditPurchaseRequest, ICreditPurchaseResponse, ICreditTransaction, ICreditTransactionsQuery, ICreditTransactionsResponse, IEventCallbacks, IExpiringCreditsResponse, IInvoice, IInvoiceListResponse, IInvoiceResponse, IOsConfig, IOsState, IPlan, IPlanGroup, IPlanGroupInfo, IPlanGroupLatestVersion, IPlanGroupResponse, IPlanGroupVersion, IPlanGroupVersionWithPlans, IPlanGroupVersionsResponse, IPlanVersion, IPlanVersionSummary, IPlanVersionWithPlan, IPricingVariant, IPublicCreditPackage, IPublicCreditPackagesResponse, IPublicPlanItem, IPublicPlanItemCategory, IPublicPlanVersion, IPublicPlansResponse, IQuotaByInterval, IQuotaIntervalValue, IQuotaOveragePriceIdsByInterval, IQuotaOveragesByInterval, IQuotaUsageStatus, IQuotaUsageStatusResponse, IRecordUsageRequest, IRecordUsageResponse, IStripePricesByInterval, ISubscription, ISubscriptionItem, ISubscriptionResponse, ISubscriptionUpdateRequest, ISubscriptionUpdateResponse, IUsageLogEntry, IUsageLogsQuery, IUsageLogsResponse, InviteBlockReason, InviteValidation, InvoiceActions, InvoiceStatus, InvoiceStatusType, MaxUsersConfig, NotificationData, NotificationEvent, NotificationResult, OnWorkspaceChangeParams, PermissionActions, PermissionContext, PermissionKey, PlanActions, PlanVersionWithPricingVariants, QuotaDisplayValue, QuotaDisplayWithOverage, RolePermissionMap, ScopedActions, SettingsActions, SubscriptionActions, SubscriptionItemTypeValue, SubscriptionStatusType, UsageActions, UserActions, UserCreatedEventData, UserUpdatedEventData, WorkspaceActions, WorkspaceChangedEventData, WorkspaceCreatedEventData, WorkspaceDeletedEventData, WorkspaceUpdatedEventData, WorkspaceUserAddedEventData, WorkspaceUserRemovedEventData, WorkspaceUserRoleChangedEventData };
|