cauthy-auth 0.12.0 → 0.14.0
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/README.md +8 -0
- package/dist/client.d.mts +86 -1
- package/dist/client.d.ts +86 -1
- package/dist/client.js +21 -7
- package/dist/client.js.map +1 -1
- package/dist/client.mjs +21 -7
- package/dist/client.mjs.map +1 -1
- package/dist/index.js +81 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +81 -2
- package/dist/index.mjs.map +1 -1
- package/dist/mcp.d.mts +103 -0
- package/dist/mcp.d.ts +103 -0
- package/dist/mcp.js +218 -0
- package/dist/mcp.js.map +1 -0
- package/dist/mcp.mjs +191 -0
- package/dist/mcp.mjs.map +1 -0
- package/dist/react.d.mts +104 -1
- package/dist/react.d.ts +104 -1
- package/dist/react.js +259 -12
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +259 -12
- package/dist/react.mjs.map +1 -1
- package/dist/styles.css +5 -0
- package/dist/svelte.js +21 -7
- package/dist/svelte.js.map +1 -1
- package/dist/svelte.mjs +21 -7
- package/dist/svelte.mjs.map +1 -1
- package/dist/vue.js +21 -7
- package/dist/vue.js.map +1 -1
- package/dist/vue.mjs +21 -7
- package/dist/vue.mjs.map +1 -1
- package/package.json +6 -1
package/dist/mcp.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/mcp.ts","../src/verify.ts"],"sourcesContent":["// An MCP server (or any API) that AI agents use as one of your people.\n//\n// import { mcpAuth } from 'cauthy-auth/mcp'\n// const auth = mcpAuth({ resource: 'https://mcp.example.com/mcp', scopes: ['books:read'] })\n//\n// // Fetch-style (Hono, Next.js, Workers, Bun, Deno):\n// export default { fetch: auth.protect((request, agent) => handleMcp(request, agent)) }\n//\n// // Express or plain Node, with the MCP TypeScript SDK (its transport reads req.auth):\n// app.use(auth.middleware())\n//\n// How an agent gets in, as the MCP specification lays it out: it calls the\n// server, which answers 401 and points at its protected resource metadata\n// (RFC 9728); that names Cauthy as the authorization server; the agent\n// registers itself there, sends the person to sign in and allow it, and comes\n// back with a token issued for this server alone (its `aud`). This module is\n// the server's half: the metadata, the 401 that points at it, and checking\n// the token. The resource must be registered in Cauthy's dashboard (AI\n// agents), with the same address, for the workspace whose people use it.\n\nimport { jwtVerify, type JWTVerifyGetKey } from 'jose'\nimport { keysOf } from './verify'\n\n/** The person an agent acts for, and what they allowed it. */\nexport interface AgentIdentity {\n /** The person. */\n userId: string\n tenantId: string\n email?: string\n /** The person's roles in the workspace. */\n roles: string[]\n /** What the person allowed the agent to do here. */\n scopes: string[]\n /** The agent (its client_id at Cauthy). */\n clientId: string\n /** UTC, ISO 8601. */\n expiresAt: string\n /** The token as it arrived. */\n token: string\n}\n\nexport interface McpAuthOptions {\n /** This server's address, as registered in Cauthy. Default: `CAUTHY_MCP_RESOURCE`. */\n resource?: string\n /** Cauthy's address. Default: `CAUTHY_ISSUER`. */\n issuer?: string\n /** Scopes every call needs. Default: none. */\n scopes?: string[]\n /** The scopes this server understands, to tell agents (`scopes_supported`). Default: `scopes`. */\n scopesSupported?: string[]\n /** A name for the server, shown by some agents. */\n resourceName?: string\n /** Cauthy's keys. Default: fetched from the issuer and cached. */\n jwks?: JWTVerifyGetKey\n /** The moment to verify at. Default: now. */\n now?: () => Date\n}\n\n/** A token refused: `status` is 401 (no token, or not a good one) or 403 (a scope missing). */\nexport class McpAuthError extends Error {\n constructor(\n readonly status: 401 | 403,\n readonly code: 'invalid_request' | 'invalid_token' | 'insufficient_scope',\n readonly description: string,\n ) {\n super(`cauthy-auth: ${description}`)\n this.name = 'McpAuthError'\n }\n}\n\n/** What the MCP TypeScript SDK reads from `req.auth` (its AuthInfo). */\nexport interface McpAuthInfo {\n token: string\n clientId: string\n scopes: string[]\n /** Seconds since the epoch. */\n expiresAt: number\n resource: URL\n extra: { userId: string; tenantId: string; email?: string; roles: string[] }\n}\n\nexport interface McpAuth {\n /** This server's address, in the form Cauthy compares it in. */\n resource: string\n /** Where the protected resource metadata is served. */\n metadataUrl: string\n /** The protected resource metadata (RFC 9728). */\n metadata(): Record<string, unknown>\n /** The metadata's paths: `/.well-known/oauth-protected-resource` plus this server's path. */\n metadataPaths: string[]\n /** Verifies the `Authorization: Bearer` of a request (or a token). Throws `McpAuthError`. */\n verify(from: string | Request | Headers, needs?: string[]): Promise<AgentIdentity>\n /** The answer to a refused token: 401 or 403, with the `WWW-Authenticate` that points an agent at Cauthy. */\n challenge(error?: McpAuthError): Response\n /** The metadata, when the request asks for it; `null` otherwise. */\n handleMetadata(request: Request): Response | null\n /** Wraps a fetch-style handler: serves the metadata, refuses what has no good token, passes the rest with who it is. */\n protect(handler: (request: Request, agent: AgentIdentity) => Response | Promise<Response>, needs?: string[]): (request: Request) => Promise<Response>\n /**\n * Connect-style middleware (Express, Node's http): serves the metadata,\n * refuses what has no good token, and sets `req.agent` and `req.auth` —\n * what the MCP TypeScript SDK's transport hands its tools as `authInfo`.\n */\n middleware(needs?: string[]): (req: NodeRequest, res: NodeResponse, next: (err?: unknown) => void) => void\n}\n\n// The slice of Node's (and Express's) request and response this needs.\ninterface NodeRequest {\n method?: string\n url?: string\n originalUrl?: string\n headers: Record<string, string | string[] | undefined>\n auth?: McpAuthInfo\n agent?: AgentIdentity\n}\ninterface NodeResponse {\n statusCode: number\n setHeader(name: string, value: string): unknown\n end(body?: string): unknown\n}\n\nfunction env(name: string): string | undefined {\n return typeof process !== 'undefined' ? process.env?.[name] : undefined\n}\n\n/**\n * The address in the one form Cauthy keeps it: scheme and host in lower case,\n * no default port, no trailing slash, no query, no fragment.\n */\nexport function canonicalResource(raw: string): string {\n let u: URL\n try {\n u = new URL(raw.trim())\n } catch {\n throw new Error(`cauthy-auth: resource ${JSON.stringify(raw)} is not an absolute address`)\n }\n const local = u.hostname === 'localhost' || u.hostname === '127.0.0.1' || u.hostname === '[::1]'\n if (u.protocol !== 'https:' && !(u.protocol === 'http:' && local)) {\n throw new Error('cauthy-auth: resource must be an https address')\n }\n if (u.search !== '' || u.hash !== '') throw new Error('cauthy-auth: resource may not have a query or a fragment')\n return `${u.protocol}//${u.host}${u.pathname.replace(/\\/+$/, '')}`\n}\n\nfunction bearer(from: string | Request | Headers): string {\n if (typeof from === 'string') return from.replace(/^Bearer\\s+/i, '').trim()\n const header = (from instanceof Headers ? from : from.headers).get('authorization') ?? ''\n return /^Bearer\\s+/i.test(header) ? header.replace(/^Bearer\\s+/i, '').trim() : ''\n}\n\nfunction quoted(v: string): string {\n return `\"${v.replace(/[\"\\\\]/g, '')}\"`\n}\n\n/** Protects an MCP server with Cauthy. */\nexport function mcpAuth(options: McpAuthOptions = {}): McpAuth {\n const rawResource = options.resource ?? env('CAUTHY_MCP_RESOURCE') ?? ''\n if (rawResource === '') throw new Error('cauthy-auth: resource (CAUTHY_MCP_RESOURCE) is not set')\n const resource = canonicalResource(rawResource)\n const issuer = (options.issuer ?? env('CAUTHY_ISSUER') ?? '').replace(/\\/+$/, '')\n if (issuer === '') throw new Error('cauthy-auth: issuer (CAUTHY_ISSUER) is not set')\n const required = options.scopes ?? []\n const url = new URL(resource)\n const path = url.pathname === '/' ? '' : url.pathname\n const metadataPaths = [...new Set([`/.well-known/oauth-protected-resource${path}`, '/.well-known/oauth-protected-resource'])]\n const metadataUrl = `${url.origin}${metadataPaths[0]}`\n\n const metadata = () => ({\n resource,\n authorization_servers: [issuer],\n bearer_methods_supported: ['header'],\n scopes_supported: options.scopesSupported ?? required,\n ...(options.resourceName ? { resource_name: options.resourceName } : {}),\n })\n\n const verify = async (from: string | Request | Headers, needs: string[] = []): Promise<AgentIdentity> => {\n const token = bearer(from)\n if (token === '') throw new McpAuthError(401, 'invalid_request', 'no access token')\n let claims: Record<string, unknown>\n try {\n const verified = await jwtVerify(token, options.jwks ?? keysOf(issuer), {\n algorithms: ['RS256'],\n issuer,\n audience: resource,\n requiredClaims: ['exp', 'sub'],\n currentDate: options.now?.(),\n })\n claims = verified.payload as Record<string, unknown>\n } catch (err) {\n throw new McpAuthError(401, 'invalid_token', err instanceof Error ? err.message : 'the token is not valid')\n }\n const clientId = typeof claims.client_id === 'string' ? claims.client_id : ''\n if (clientId === '') throw new McpAuthError(401, 'invalid_token', 'not a token issued to an agent')\n const scopes = typeof claims.scope === 'string' ? claims.scope.split(' ').filter(Boolean) : []\n const missing = [...required, ...needs].filter((s) => !scopes.includes(s))\n if (missing.length > 0) throw new McpAuthError(403, 'insufficient_scope', `this needs ${missing.join(' ')}`)\n return {\n userId: String(claims.sub),\n tenantId: typeof claims.tid === 'string' ? claims.tid : '',\n ...(typeof claims.email === 'string' && claims.email !== '' ? { email: claims.email } : {}),\n roles: Array.isArray(claims.roles) ? claims.roles.filter((r): r is string => typeof r === 'string') : [],\n scopes,\n clientId,\n expiresAt: new Date((claims.exp as number) * 1000).toISOString(),\n token,\n }\n }\n\n const authenticate = (error?: McpAuthError): string => {\n const parts = [`resource_metadata=${quoted(metadataUrl)}`]\n if (error && error.code !== 'invalid_request') {\n parts.push(`error=${quoted(error.code)}`, `error_description=${quoted(error.description)}`)\n }\n // What to ask the person for: said when there is no token or it falls short.\n const scope = error?.code === 'invalid_token' ? [] : required\n if (scope.length > 0) parts.push(`scope=${quoted(scope.join(' '))}`)\n return `Bearer ${parts.join(', ')}`\n }\n\n const challenge = (error?: McpAuthError): Response => {\n const status = error?.status ?? 401\n return new Response(JSON.stringify({ error: error?.code ?? 'invalid_request', error_description: error?.description ?? 'an access token is required' }), {\n status,\n headers: { 'content-type': 'application/json', 'www-authenticate': authenticate(error) },\n })\n }\n\n const metadataResponse = () =>\n new Response(JSON.stringify(metadata()), {\n headers: { 'content-type': 'application/json', 'cache-control': 'public, max-age=3600', 'access-control-allow-origin': '*' },\n })\n\n const isMetadata = (pathname: string, method = 'GET') => method === 'GET' && metadataPaths.includes(pathname.replace(/\\/+$/, '') || '/')\n\n const handleMetadata = (request: Request): Response | null =>\n isMetadata(new URL(request.url).pathname, request.method) ? metadataResponse() : null\n\n const toAuthInfo = (a: AgentIdentity): McpAuthInfo => ({\n token: a.token,\n clientId: a.clientId,\n scopes: a.scopes,\n expiresAt: Math.floor(new Date(a.expiresAt).getTime() / 1000),\n resource: new URL(resource),\n extra: { userId: a.userId, tenantId: a.tenantId, ...(a.email ? { email: a.email } : {}), roles: a.roles },\n })\n\n return {\n resource,\n metadataUrl,\n metadataPaths,\n metadata,\n verify,\n challenge,\n handleMetadata,\n protect(handler, needs) {\n return async (request) => {\n const meta = handleMetadata(request)\n if (meta) return meta\n let agent: AgentIdentity\n try {\n agent = await verify(request, needs)\n } catch (err) {\n if (err instanceof McpAuthError) return challenge(err)\n throw err\n }\n return handler(request, agent)\n }\n },\n middleware(needs) {\n return (req, res, next) => {\n const pathname = (req.originalUrl ?? req.url ?? '/').split('?')[0] ?? '/'\n if (isMetadata(pathname, req.method)) {\n res.statusCode = 200\n res.setHeader('content-type', 'application/json')\n res.setHeader('cache-control', 'public, max-age=3600')\n res.setHeader('access-control-allow-origin', '*')\n res.end(JSON.stringify(metadata()))\n return\n }\n const raw = req.headers.authorization\n const header = Array.isArray(raw) ? (raw[0] ?? '') : (raw ?? '')\n verify(/^Bearer\\s+/i.test(header) ? header : '', needs).then(\n (agent) => {\n req.agent = agent\n req.auth = toAuthInfo(agent)\n next()\n },\n (err: unknown) => {\n if (!(err instanceof McpAuthError)) return next(err)\n res.statusCode = err.status\n res.setHeader('content-type', 'application/json')\n res.setHeader('www-authenticate', authenticate(err))\n res.end(JSON.stringify({ error: err.code, error_description: err.description }))\n },\n )\n }\n },\n }\n}\n","// A backend that is handed a Cauthy access token: is it real, and whose is it?\n//\n// const who = await verifyToken(request) // or the token itself\n// who.userId, who.tenantId, who.roles\n//\n// Cauthy signs its tokens with a key it publishes (/.well-known/jwks.json), so\n// checking one needs no secret and no call to Cauthy per request: the keys are\n// fetched once and cached. Throws `CauthyTokenError` for anything else: answer\n// it 401.\n\nimport { createRemoteJWKSet, jwtVerify, type JWTVerifyGetKey } from 'jose'\n\n/** Who a verified access token belongs to. */\nexport interface TokenIdentity {\n /** The person. For a system's own token, the client it identifies as. */\n userId: string\n tenantId: string\n email?: string\n roles: string[]\n /** Set when the token is a system's own and not a person's. */\n system?: string\n /** UTC, ISO 8601. */\n expiresAt: string\n /** The token as it arrived, to pass on. */\n token: string\n}\n\nexport class CauthyTokenError extends Error {\n constructor(readonly reason: string) {\n super(`cauthy-auth: token refused: ${reason}`)\n this.name = 'CauthyTokenError'\n }\n}\n\nexport interface VerifyTokenOptions {\n /** Cauthy's address. Default: `CAUTHY_ISSUER`. */\n issuer?: string\n /** The audience the tokens must carry. Default: `CAUTHY_AUDIENCE`; unchecked when neither is set. */\n audience?: string\n /** Refuse a token of any other workspace. Default: `CAUTHY_TENANT_ID`; unchecked when neither is set. */\n tenantId?: string\n /** Cauthy's keys. Default: fetched from the issuer and cached. */\n jwks?: JWTVerifyGetKey\n /** The moment to verify at. Default: now. */\n now?: Date\n}\n\nconst keys = new Map<string, JWTVerifyGetKey>()\n\n/** Cauthy's published keys, fetched once per issuer and cached. */\nexport function keysOf(issuer: string): JWTVerifyGetKey {\n let set = keys.get(issuer)\n if (set === undefined) {\n set = createRemoteJWKSet(new URL(`${issuer}/.well-known/jwks.json`), { cooldownDuration: 30_000 })\n keys.set(issuer, set)\n }\n return set\n}\n\nfunction env(name: string): string | undefined {\n return typeof process !== 'undefined' ? process.env?.[name] : undefined\n}\n\nfunction bearer(from: string | Request | Headers): string {\n if (typeof from === 'string') return from.replace(/^Bearer\\s+/i, '').trim()\n const header = (from instanceof Headers ? from : from.headers).get('authorization') ?? ''\n return /^Bearer\\s+/i.test(header) ? header.replace(/^Bearer\\s+/i, '').trim() : ''\n}\n\n/**\n * Verifies an access token (or the `Authorization: Bearer` of a request) and\n * answers who it belongs to. Checked: the signature, against Cauthy's\n * published keys; that Cauthy issued it; that it has not expired; and the\n * audience and the workspace, when given.\n */\nexport async function verifyToken(from: string | Request | Headers, options: VerifyTokenOptions = {}): Promise<TokenIdentity> {\n const issuer = (options.issuer ?? env('CAUTHY_ISSUER') ?? '').replace(/\\/+$/, '')\n if (issuer === '') throw new CauthyTokenError('issuer (CAUTHY_ISSUER) is not set')\n const token = bearer(from)\n if (token === '') throw new CauthyTokenError('no token')\n\n let claims: Record<string, unknown>\n try {\n const verified = await jwtVerify(token, options.jwks ?? keysOf(issuer), {\n algorithms: ['RS256'],\n issuer,\n audience: options.audience ?? env('CAUTHY_AUDIENCE'),\n requiredClaims: ['exp', 'sub'],\n currentDate: options.now,\n })\n claims = verified.payload as Record<string, unknown>\n } catch (err) {\n throw new CauthyTokenError(err instanceof Error ? err.message : 'bad signature')\n }\n\n const tenantId = typeof claims.tid === 'string' ? claims.tid : ''\n const wanted = options.tenantId ?? env('CAUTHY_TENANT_ID')\n if (wanted && tenantId !== wanted) throw new CauthyTokenError('issued for another workspace')\n\n return {\n userId: String(claims.sub),\n tenantId,\n ...(typeof claims.email === 'string' && claims.email !== '' ? { email: claims.email } : {}),\n roles: Array.isArray(claims.roles) ? claims.roles.filter((r): r is string => typeof r === 'string') : [],\n ...(typeof claims.sys === 'string' && claims.sys !== '' ? { system: claims.sys } : {}),\n expiresAt: new Date((claims.exp as number) * 1000).toISOString(),\n token,\n }\n}\n"],"mappings":";AAoBA,SAAS,aAAAA,kBAAuC;;;ACVhD,SAAS,oBAAoB,iBAAuC;AAqCpE,IAAM,OAAO,oBAAI,IAA6B;AAGvC,SAAS,OAAO,QAAiC;AACtD,MAAI,MAAM,KAAK,IAAI,MAAM;AACzB,MAAI,QAAQ,QAAW;AACrB,UAAM,mBAAmB,IAAI,IAAI,GAAG,MAAM,wBAAwB,GAAG,EAAE,kBAAkB,IAAO,CAAC;AACjG,SAAK,IAAI,QAAQ,GAAG;AAAA,EACtB;AACA,SAAO;AACT;;;ADEO,IAAM,eAAN,cAA2B,MAAM;AAAA,EACtC,YACW,QACA,MACA,aACT;AACA,UAAM,gBAAgB,WAAW,EAAE;AAJ1B;AACA;AACA;AAGT,SAAK,OAAO;AAAA,EAC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eAAe,aAAc,QAAO,UAAU,GAAG;AACrD,gBAAM;AAAA,QACR;AACA,eAAO,QAAQ,SAAS,KAAK;AAAA,MAC/B;AAAA,IACF;AAAA,IACA,WAAW,OAAO;AAChB,aAAO,CAAC,KAAK,KAAK,SAAS;AACzB,cAAM,YAAY,IAAI,eAAe,IAAI,OAAO,KAAK,MAAM,GAAG,EAAE,CAAC,KAAK;AACtE,YAAI,WAAW,UAAU,IAAI,MAAM,GAAG;AACpC,cAAI,aAAa;AACjB,cAAI,UAAU,gBAAgB,kBAAkB;AAChD,cAAI,UAAU,iBAAiB,sBAAsB;AACrD,cAAI,UAAU,+BAA+B,GAAG;AAChD,cAAI,IAAI,KAAK,UAAU,SAAS,CAAC,CAAC;AAClC;AAAA,QACF;AACA,cAAM,MAAM,IAAI,QAAQ;AACxB,cAAM,SAAS,MAAM,QAAQ,GAAG,IAAK,IAAI,CAAC,KAAK,KAAO,OAAO;AAC7D,eAAO,cAAc,KAAK,MAAM,IAAI,SAAS,IAAI,KAAK,EAAE;AAAA,UACtD,CAAC,UAAU;AACT,gBAAI,QAAQ;AACZ,gBAAI,OAAO,WAAW,KAAK;AAC3B,iBAAK;AAAA,UACP;AAAA,UACA,CAAC,QAAiB;AAChB,gBAAI,EAAE,eAAe,cAAe,QAAO,KAAK,GAAG;AACnD,gBAAI,aAAa,IAAI;AACrB,gBAAI,UAAU,gBAAgB,kBAAkB;AAChD,gBAAI,UAAU,oBAAoB,aAAa,GAAG,CAAC;AACnD,gBAAI,IAAI,KAAK,UAAU,EAAE,OAAO,IAAI,MAAM,mBAAmB,IAAI,YAAY,CAAC,CAAC;AAAA,UACjF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":["jwtVerify","jwtVerify"]}
|
package/dist/react.d.mts
CHANGED
|
@@ -258,6 +258,13 @@ interface AuthMethods {
|
|
|
258
258
|
* page that cannot, or a browser that refuses to here, sends the person.
|
|
259
259
|
*/
|
|
260
260
|
passkeyOnCauthy: boolean;
|
|
261
|
+
/**
|
|
262
|
+
* The workspace's Cloudflare Turnstile site key, when it asks for the
|
|
263
|
+
* challenge: signing in, creating an account, and asking for a sign-in link
|
|
264
|
+
* or a new password then take its answer (`captchaToken`). The ready-made
|
|
265
|
+
* forms show it themselves.
|
|
266
|
+
*/
|
|
267
|
+
captchaSiteKey?: string;
|
|
261
268
|
}
|
|
262
269
|
/** A passkey of the signed-in account. Moments are UTC. */
|
|
263
270
|
interface Passkey {
|
|
@@ -279,6 +286,26 @@ interface Account$1 {
|
|
|
279
286
|
mfaEnabled: boolean;
|
|
280
287
|
}
|
|
281
288
|
/** Somewhere the person is signed in. Moments are UTC. */
|
|
289
|
+
/** An AI agent the person allowed to act for them on one of the workspace's servers. */
|
|
290
|
+
interface ConnectedAgent {
|
|
291
|
+
id: string;
|
|
292
|
+
/** The name the agent gave itself (Claude, Cursor…): not checked by anyone. */
|
|
293
|
+
name: string;
|
|
294
|
+
/** Where the agent receives its access: the one thing about it that is sure. */
|
|
295
|
+
redirectHost: string;
|
|
296
|
+
resource: {
|
|
297
|
+
name: string;
|
|
298
|
+
uri: string;
|
|
299
|
+
};
|
|
300
|
+
/** What the person allowed it, in their words. */
|
|
301
|
+
scopes: {
|
|
302
|
+
name: string;
|
|
303
|
+
description: string;
|
|
304
|
+
}[];
|
|
305
|
+
/** UTC, ISO 8601. */
|
|
306
|
+
connectedAt: string;
|
|
307
|
+
lastUsedAt: string;
|
|
308
|
+
}
|
|
282
309
|
interface AccountSession {
|
|
283
310
|
/** "Mac · Chrome", or "" when the browser did not say. */
|
|
284
311
|
device: string;
|
|
@@ -299,6 +326,17 @@ interface LinkedIdentity {
|
|
|
299
326
|
/** When it was linked, in UTC (ISO 8601). */
|
|
300
327
|
linkedAt: string;
|
|
301
328
|
}
|
|
329
|
+
/** How an account takes its second step. */
|
|
330
|
+
interface SecondStep {
|
|
331
|
+
totp: boolean;
|
|
332
|
+
/** The phone codes are sent to, masked (`+57 ••• ••• 4567`). */
|
|
333
|
+
phone: {
|
|
334
|
+
number: string;
|
|
335
|
+
channel: string;
|
|
336
|
+
} | null;
|
|
337
|
+
/** The ways the workspace sends codes to phones. */
|
|
338
|
+
phoneChannels: string[];
|
|
339
|
+
}
|
|
302
340
|
interface AccountClient {
|
|
303
341
|
/** The account, or null when nobody is signed in. */
|
|
304
342
|
get(): Promise<Account$1 | null>;
|
|
@@ -337,6 +375,30 @@ interface AccountClient {
|
|
|
337
375
|
}): Promise<AuthResult<'renewed', {
|
|
338
376
|
recoveryCodes: string[];
|
|
339
377
|
}>>;
|
|
378
|
+
/**
|
|
379
|
+
* How the account takes its second step: an authenticator app, a phone
|
|
380
|
+
* (masked), and the ways the workspace sends codes to phones (`sms`,
|
|
381
|
+
* `whatsapp`; none when it has no Twilio account for it).
|
|
382
|
+
*/
|
|
383
|
+
factors(): Promise<SecondStep | null>;
|
|
384
|
+
/** Adds a phone as the second step: a code is sent to it, for `verifyPhone`. */
|
|
385
|
+
addPhone(form: {
|
|
386
|
+
phone: string;
|
|
387
|
+
channel: 'sms' | 'whatsapp';
|
|
388
|
+
password: string;
|
|
389
|
+
}): Promise<AuthResult<'sent', {
|
|
390
|
+
sentTo: string;
|
|
391
|
+
channel: string;
|
|
392
|
+
}>>;
|
|
393
|
+
/** Proves the phone with the code it received. `recoveryCodes` come with a first second step, shown this once. */
|
|
394
|
+
verifyPhone(form: {
|
|
395
|
+
code: string;
|
|
396
|
+
}): Promise<AuthResult<'enabled', {
|
|
397
|
+
recoveryCodes: string[];
|
|
398
|
+
}>>;
|
|
399
|
+
removePhone(form: {
|
|
400
|
+
password: string;
|
|
401
|
+
}): Promise<AuthResult<'removed'>>;
|
|
340
402
|
};
|
|
341
403
|
/**
|
|
342
404
|
* Asks to sign in with another address. Nothing changes yet: the new address
|
|
@@ -370,6 +432,12 @@ interface AccountClient {
|
|
|
370
432
|
sessions(): Promise<AccountSession[]>;
|
|
371
433
|
/** Signs the account out everywhere, here too. */
|
|
372
434
|
signOutEverywhere(): Promise<AuthResult<'signed_out'>>;
|
|
435
|
+
/** The AI agents the person connected. */
|
|
436
|
+
agents(): Promise<ConnectedAgent[]>;
|
|
437
|
+
/** Disconnects an agent: it loses its access within minutes. */
|
|
438
|
+
disconnectAgent(id: string): Promise<AuthResult<'disconnected', {
|
|
439
|
+
id: string;
|
|
440
|
+
}>>;
|
|
373
441
|
/** The account's passkeys. */
|
|
374
442
|
passkeys(): Promise<Passkey[]>;
|
|
375
443
|
/**
|
|
@@ -393,6 +461,7 @@ interface AuthClient {
|
|
|
393
461
|
email(form: {
|
|
394
462
|
email: string;
|
|
395
463
|
password: string;
|
|
464
|
+
captchaToken?: string;
|
|
396
465
|
}): Promise<AuthResult<'signed_in', {
|
|
397
466
|
session: PublicSession;
|
|
398
467
|
}> | AuthResult<'mfa_required'>>;
|
|
@@ -402,9 +471,23 @@ interface AuthClient {
|
|
|
402
471
|
}): Promise<AuthResult<'signed_in', {
|
|
403
472
|
session: PublicSession;
|
|
404
473
|
}>>;
|
|
474
|
+
/** While the second step is asked for: whether the account has an authenticator app, and the phone (masked) a code can be sent to. */
|
|
475
|
+
mfaMethods(): Promise<AuthResult<'ok', {
|
|
476
|
+
totp: boolean;
|
|
477
|
+
phone: {
|
|
478
|
+
number: string;
|
|
479
|
+
channel: string;
|
|
480
|
+
} | null;
|
|
481
|
+
}>>;
|
|
482
|
+
/** Sends a code to the account's phone, by SMS or WhatsApp; `mfa` takes it. A few per sign-in. */
|
|
483
|
+
mfaSendCode(): Promise<AuthResult<'sent', {
|
|
484
|
+
sentTo: string;
|
|
485
|
+
channel: string;
|
|
486
|
+
}>>;
|
|
405
487
|
/** Mails a link that signs the person in. The answer is the same whether or not the address has an account. */
|
|
406
488
|
magicLink(form: {
|
|
407
489
|
email: string;
|
|
490
|
+
captchaToken?: string;
|
|
408
491
|
}): Promise<AuthResult<'sent'>>;
|
|
409
492
|
/** Signs in with the token the mailed link opened the page with (`ml_token`). */
|
|
410
493
|
magicLinkVerify(form: {
|
|
@@ -480,6 +563,7 @@ interface AuthClient {
|
|
|
480
563
|
email: string;
|
|
481
564
|
password: string;
|
|
482
565
|
name?: string;
|
|
566
|
+
captchaToken?: string;
|
|
483
567
|
}): Promise<AuthResult<'signed_in', {
|
|
484
568
|
session: PublicSession;
|
|
485
569
|
}> | AuthResult<'verification_required', {
|
|
@@ -489,6 +573,7 @@ interface AuthClient {
|
|
|
489
573
|
/** Mails a link to choose a new password. The answer is the same whether or not the address has an account. */
|
|
490
574
|
forgotPassword(form: {
|
|
491
575
|
email: string;
|
|
576
|
+
captchaToken?: string;
|
|
492
577
|
}): Promise<AuthResult<'sent'>>;
|
|
493
578
|
/** Sets the new password, with the token the mailed link opened the page with (`token`). */
|
|
494
579
|
resetPassword(form: {
|
|
@@ -542,6 +627,20 @@ interface AuthTexts {
|
|
|
542
627
|
sendLink: string;
|
|
543
628
|
linkSent: string;
|
|
544
629
|
codeHelp: string;
|
|
630
|
+
/** The second step when it is a phone only. */
|
|
631
|
+
codeHelpPhone: string;
|
|
632
|
+
/** "{to}" is the phone, masked. */
|
|
633
|
+
sendCodeSms: string;
|
|
634
|
+
sendCodeWhatsapp: string;
|
|
635
|
+
codeSent: string;
|
|
636
|
+
phone: string;
|
|
637
|
+
phoneHelp: string;
|
|
638
|
+
phoneOn: string;
|
|
639
|
+
phoneOff: string;
|
|
640
|
+
addPhone: string;
|
|
641
|
+
removePhone: string;
|
|
642
|
+
bySms: string;
|
|
643
|
+
byWhatsapp: string;
|
|
545
644
|
verify: string;
|
|
546
645
|
checkEmail: string;
|
|
547
646
|
backToSignIn: string;
|
|
@@ -581,6 +680,10 @@ interface AuthTexts {
|
|
|
581
680
|
passkeyUnnamed: string;
|
|
582
681
|
sessions: string;
|
|
583
682
|
signOutEverywhere: string;
|
|
683
|
+
agents: string;
|
|
684
|
+
agentsHelp: string;
|
|
685
|
+
disconnect: string;
|
|
686
|
+
anAgent: string;
|
|
584
687
|
unknownDevice: string;
|
|
585
688
|
emailAddress: string;
|
|
586
689
|
newEmail: string;
|
|
@@ -734,4 +837,4 @@ declare function useSession(): SessionContext;
|
|
|
734
837
|
*/
|
|
735
838
|
declare function useAuth(): AuthClient & Pick<SessionContext, 'session' | 'status' | 'refresh'>;
|
|
736
839
|
|
|
737
|
-
export { Account, type AccountClient, type Account$1 as AccountDetails, type AccountProps, type AccountSession, type AuthClient, type AuthError, type AuthFormProps, type AuthMethods, type AuthResult, type AuthTexts, CauthyProvider, type CauthyProviderProps, ForgotPassword, GoogleOneTap, type GoogleOneTapProps, type JsonValue, type LinkedIdentity, type Passkey, type PermissionOf, type Policy, type PublicSession, ResetPassword, type RoleOf, type SessionContext, type SessionOrganization, type SessionUser, SignIn, SignUp, VerifyEmail, can, canAutofillPasskeys, canUsePasskeys, createAuthClient, definePolicy, useAuth, useSession };
|
|
840
|
+
export { Account, type AccountClient, type Account$1 as AccountDetails, type AccountProps, type AccountSession, type AuthClient, type AuthError, type AuthFormProps, type AuthMethods, type AuthResult, type AuthTexts, CauthyProvider, type CauthyProviderProps, type ConnectedAgent, ForgotPassword, GoogleOneTap, type GoogleOneTapProps, type JsonValue, type LinkedIdentity, type Passkey, type PermissionOf, type Policy, type PublicSession, ResetPassword, type RoleOf, type SecondStep, type SessionContext, type SessionOrganization, type SessionUser, SignIn, SignUp, VerifyEmail, can, canAutofillPasskeys, canUsePasskeys, createAuthClient, definePolicy, useAuth, useSession };
|
package/dist/react.d.ts
CHANGED
|
@@ -258,6 +258,13 @@ interface AuthMethods {
|
|
|
258
258
|
* page that cannot, or a browser that refuses to here, sends the person.
|
|
259
259
|
*/
|
|
260
260
|
passkeyOnCauthy: boolean;
|
|
261
|
+
/**
|
|
262
|
+
* The workspace's Cloudflare Turnstile site key, when it asks for the
|
|
263
|
+
* challenge: signing in, creating an account, and asking for a sign-in link
|
|
264
|
+
* or a new password then take its answer (`captchaToken`). The ready-made
|
|
265
|
+
* forms show it themselves.
|
|
266
|
+
*/
|
|
267
|
+
captchaSiteKey?: string;
|
|
261
268
|
}
|
|
262
269
|
/** A passkey of the signed-in account. Moments are UTC. */
|
|
263
270
|
interface Passkey {
|
|
@@ -279,6 +286,26 @@ interface Account$1 {
|
|
|
279
286
|
mfaEnabled: boolean;
|
|
280
287
|
}
|
|
281
288
|
/** Somewhere the person is signed in. Moments are UTC. */
|
|
289
|
+
/** An AI agent the person allowed to act for them on one of the workspace's servers. */
|
|
290
|
+
interface ConnectedAgent {
|
|
291
|
+
id: string;
|
|
292
|
+
/** The name the agent gave itself (Claude, Cursor…): not checked by anyone. */
|
|
293
|
+
name: string;
|
|
294
|
+
/** Where the agent receives its access: the one thing about it that is sure. */
|
|
295
|
+
redirectHost: string;
|
|
296
|
+
resource: {
|
|
297
|
+
name: string;
|
|
298
|
+
uri: string;
|
|
299
|
+
};
|
|
300
|
+
/** What the person allowed it, in their words. */
|
|
301
|
+
scopes: {
|
|
302
|
+
name: string;
|
|
303
|
+
description: string;
|
|
304
|
+
}[];
|
|
305
|
+
/** UTC, ISO 8601. */
|
|
306
|
+
connectedAt: string;
|
|
307
|
+
lastUsedAt: string;
|
|
308
|
+
}
|
|
282
309
|
interface AccountSession {
|
|
283
310
|
/** "Mac · Chrome", or "" when the browser did not say. */
|
|
284
311
|
device: string;
|
|
@@ -299,6 +326,17 @@ interface LinkedIdentity {
|
|
|
299
326
|
/** When it was linked, in UTC (ISO 8601). */
|
|
300
327
|
linkedAt: string;
|
|
301
328
|
}
|
|
329
|
+
/** How an account takes its second step. */
|
|
330
|
+
interface SecondStep {
|
|
331
|
+
totp: boolean;
|
|
332
|
+
/** The phone codes are sent to, masked (`+57 ••• ••• 4567`). */
|
|
333
|
+
phone: {
|
|
334
|
+
number: string;
|
|
335
|
+
channel: string;
|
|
336
|
+
} | null;
|
|
337
|
+
/** The ways the workspace sends codes to phones. */
|
|
338
|
+
phoneChannels: string[];
|
|
339
|
+
}
|
|
302
340
|
interface AccountClient {
|
|
303
341
|
/** The account, or null when nobody is signed in. */
|
|
304
342
|
get(): Promise<Account$1 | null>;
|
|
@@ -337,6 +375,30 @@ interface AccountClient {
|
|
|
337
375
|
}): Promise<AuthResult<'renewed', {
|
|
338
376
|
recoveryCodes: string[];
|
|
339
377
|
}>>;
|
|
378
|
+
/**
|
|
379
|
+
* How the account takes its second step: an authenticator app, a phone
|
|
380
|
+
* (masked), and the ways the workspace sends codes to phones (`sms`,
|
|
381
|
+
* `whatsapp`; none when it has no Twilio account for it).
|
|
382
|
+
*/
|
|
383
|
+
factors(): Promise<SecondStep | null>;
|
|
384
|
+
/** Adds a phone as the second step: a code is sent to it, for `verifyPhone`. */
|
|
385
|
+
addPhone(form: {
|
|
386
|
+
phone: string;
|
|
387
|
+
channel: 'sms' | 'whatsapp';
|
|
388
|
+
password: string;
|
|
389
|
+
}): Promise<AuthResult<'sent', {
|
|
390
|
+
sentTo: string;
|
|
391
|
+
channel: string;
|
|
392
|
+
}>>;
|
|
393
|
+
/** Proves the phone with the code it received. `recoveryCodes` come with a first second step, shown this once. */
|
|
394
|
+
verifyPhone(form: {
|
|
395
|
+
code: string;
|
|
396
|
+
}): Promise<AuthResult<'enabled', {
|
|
397
|
+
recoveryCodes: string[];
|
|
398
|
+
}>>;
|
|
399
|
+
removePhone(form: {
|
|
400
|
+
password: string;
|
|
401
|
+
}): Promise<AuthResult<'removed'>>;
|
|
340
402
|
};
|
|
341
403
|
/**
|
|
342
404
|
* Asks to sign in with another address. Nothing changes yet: the new address
|
|
@@ -370,6 +432,12 @@ interface AccountClient {
|
|
|
370
432
|
sessions(): Promise<AccountSession[]>;
|
|
371
433
|
/** Signs the account out everywhere, here too. */
|
|
372
434
|
signOutEverywhere(): Promise<AuthResult<'signed_out'>>;
|
|
435
|
+
/** The AI agents the person connected. */
|
|
436
|
+
agents(): Promise<ConnectedAgent[]>;
|
|
437
|
+
/** Disconnects an agent: it loses its access within minutes. */
|
|
438
|
+
disconnectAgent(id: string): Promise<AuthResult<'disconnected', {
|
|
439
|
+
id: string;
|
|
440
|
+
}>>;
|
|
373
441
|
/** The account's passkeys. */
|
|
374
442
|
passkeys(): Promise<Passkey[]>;
|
|
375
443
|
/**
|
|
@@ -393,6 +461,7 @@ interface AuthClient {
|
|
|
393
461
|
email(form: {
|
|
394
462
|
email: string;
|
|
395
463
|
password: string;
|
|
464
|
+
captchaToken?: string;
|
|
396
465
|
}): Promise<AuthResult<'signed_in', {
|
|
397
466
|
session: PublicSession;
|
|
398
467
|
}> | AuthResult<'mfa_required'>>;
|
|
@@ -402,9 +471,23 @@ interface AuthClient {
|
|
|
402
471
|
}): Promise<AuthResult<'signed_in', {
|
|
403
472
|
session: PublicSession;
|
|
404
473
|
}>>;
|
|
474
|
+
/** While the second step is asked for: whether the account has an authenticator app, and the phone (masked) a code can be sent to. */
|
|
475
|
+
mfaMethods(): Promise<AuthResult<'ok', {
|
|
476
|
+
totp: boolean;
|
|
477
|
+
phone: {
|
|
478
|
+
number: string;
|
|
479
|
+
channel: string;
|
|
480
|
+
} | null;
|
|
481
|
+
}>>;
|
|
482
|
+
/** Sends a code to the account's phone, by SMS or WhatsApp; `mfa` takes it. A few per sign-in. */
|
|
483
|
+
mfaSendCode(): Promise<AuthResult<'sent', {
|
|
484
|
+
sentTo: string;
|
|
485
|
+
channel: string;
|
|
486
|
+
}>>;
|
|
405
487
|
/** Mails a link that signs the person in. The answer is the same whether or not the address has an account. */
|
|
406
488
|
magicLink(form: {
|
|
407
489
|
email: string;
|
|
490
|
+
captchaToken?: string;
|
|
408
491
|
}): Promise<AuthResult<'sent'>>;
|
|
409
492
|
/** Signs in with the token the mailed link opened the page with (`ml_token`). */
|
|
410
493
|
magicLinkVerify(form: {
|
|
@@ -480,6 +563,7 @@ interface AuthClient {
|
|
|
480
563
|
email: string;
|
|
481
564
|
password: string;
|
|
482
565
|
name?: string;
|
|
566
|
+
captchaToken?: string;
|
|
483
567
|
}): Promise<AuthResult<'signed_in', {
|
|
484
568
|
session: PublicSession;
|
|
485
569
|
}> | AuthResult<'verification_required', {
|
|
@@ -489,6 +573,7 @@ interface AuthClient {
|
|
|
489
573
|
/** Mails a link to choose a new password. The answer is the same whether or not the address has an account. */
|
|
490
574
|
forgotPassword(form: {
|
|
491
575
|
email: string;
|
|
576
|
+
captchaToken?: string;
|
|
492
577
|
}): Promise<AuthResult<'sent'>>;
|
|
493
578
|
/** Sets the new password, with the token the mailed link opened the page with (`token`). */
|
|
494
579
|
resetPassword(form: {
|
|
@@ -542,6 +627,20 @@ interface AuthTexts {
|
|
|
542
627
|
sendLink: string;
|
|
543
628
|
linkSent: string;
|
|
544
629
|
codeHelp: string;
|
|
630
|
+
/** The second step when it is a phone only. */
|
|
631
|
+
codeHelpPhone: string;
|
|
632
|
+
/** "{to}" is the phone, masked. */
|
|
633
|
+
sendCodeSms: string;
|
|
634
|
+
sendCodeWhatsapp: string;
|
|
635
|
+
codeSent: string;
|
|
636
|
+
phone: string;
|
|
637
|
+
phoneHelp: string;
|
|
638
|
+
phoneOn: string;
|
|
639
|
+
phoneOff: string;
|
|
640
|
+
addPhone: string;
|
|
641
|
+
removePhone: string;
|
|
642
|
+
bySms: string;
|
|
643
|
+
byWhatsapp: string;
|
|
545
644
|
verify: string;
|
|
546
645
|
checkEmail: string;
|
|
547
646
|
backToSignIn: string;
|
|
@@ -581,6 +680,10 @@ interface AuthTexts {
|
|
|
581
680
|
passkeyUnnamed: string;
|
|
582
681
|
sessions: string;
|
|
583
682
|
signOutEverywhere: string;
|
|
683
|
+
agents: string;
|
|
684
|
+
agentsHelp: string;
|
|
685
|
+
disconnect: string;
|
|
686
|
+
anAgent: string;
|
|
584
687
|
unknownDevice: string;
|
|
585
688
|
emailAddress: string;
|
|
586
689
|
newEmail: string;
|
|
@@ -734,4 +837,4 @@ declare function useSession(): SessionContext;
|
|
|
734
837
|
*/
|
|
735
838
|
declare function useAuth(): AuthClient & Pick<SessionContext, 'session' | 'status' | 'refresh'>;
|
|
736
839
|
|
|
737
|
-
export { Account, type AccountClient, type Account$1 as AccountDetails, type AccountProps, type AccountSession, type AuthClient, type AuthError, type AuthFormProps, type AuthMethods, type AuthResult, type AuthTexts, CauthyProvider, type CauthyProviderProps, ForgotPassword, GoogleOneTap, type GoogleOneTapProps, type JsonValue, type LinkedIdentity, type Passkey, type PermissionOf, type Policy, type PublicSession, ResetPassword, type RoleOf, type SessionContext, type SessionOrganization, type SessionUser, SignIn, SignUp, VerifyEmail, can, canAutofillPasskeys, canUsePasskeys, createAuthClient, definePolicy, useAuth, useSession };
|
|
840
|
+
export { Account, type AccountClient, type Account$1 as AccountDetails, type AccountProps, type AccountSession, type AuthClient, type AuthError, type AuthFormProps, type AuthMethods, type AuthResult, type AuthTexts, CauthyProvider, type CauthyProviderProps, type ConnectedAgent, ForgotPassword, GoogleOneTap, type GoogleOneTapProps, type JsonValue, type LinkedIdentity, type Passkey, type PermissionOf, type Policy, type PublicSession, ResetPassword, type RoleOf, type SecondStep, type SessionContext, type SessionOrganization, type SessionUser, SignIn, SignUp, VerifyEmail, can, canAutofillPasskeys, canUsePasskeys, createAuthClient, definePolicy, useAuth, useSession };
|