@lilbox/contracts 0.0.4 → 0.1.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 CHANGED
@@ -36,6 +36,7 @@ One file per group, each holding that group's entities and tools.
36
36
  | `src/billing.ts` | 6. Billing: Plan, Subscription, Billing period, Bonus, their tools |
37
37
  | `src/common.ts` | IDs (`usr_`, `app_`, `dep_`, `evt_`, `key_`, `agt_`, `bpr_`), names, timestamps, pagination, shared enums |
38
38
  | `src/errors.ts` | The error shape and every error code |
39
+ | `src/auth.ts` | The dashboard's `/auth/*` shapes (token pair, sign-in bodies, sessions). Plumbing for our own pages: not operations, not in `openapi.json`, and not covered by the rules below |
39
40
  | `src/define.ts`, `src/registry.ts` | How an API operation is defined, and the list of them |
40
41
  | `src/openapi.ts` | Builds `openapi.json` and the MCP tool list from the registry |
41
42
 
package/dist/auth.d.ts ADDED
@@ -0,0 +1,101 @@
1
+ import { z } from "zod";
2
+ /** `user` in the token pair: enough to show who's signed in and whether they still have to accept the terms. */
3
+ export declare const AuthUser: z.ZodObject<{
4
+ id: z.ZodString;
5
+ email: z.ZodEmail;
6
+ name: z.ZodNullable<z.ZodString>;
7
+ terms_accepted: z.ZodBoolean;
8
+ }, z.core.$strip>;
9
+ /** What every sign-in and every refresh returns. */
10
+ export declare const TokenPair: z.ZodObject<{
11
+ access_token: z.ZodString;
12
+ refresh_token: z.ZodString;
13
+ expires_in: z.ZodNumber;
14
+ user: z.ZodObject<{
15
+ id: z.ZodString;
16
+ email: z.ZodEmail;
17
+ name: z.ZodNullable<z.ZodString>;
18
+ terms_accepted: z.ZodBoolean;
19
+ }, z.core.$strip>;
20
+ }, z.core.$strip>;
21
+ /** POST /auth/magic-link/verify: the pair plus where the person was going. */
22
+ export declare const MagicLinkVerifyResponse: z.ZodObject<{
23
+ access_token: z.ZodString;
24
+ refresh_token: z.ZodString;
25
+ expires_in: z.ZodNumber;
26
+ user: z.ZodObject<{
27
+ id: z.ZodString;
28
+ email: z.ZodEmail;
29
+ name: z.ZodNullable<z.ZodString>;
30
+ terms_accepted: z.ZodBoolean;
31
+ }, z.core.$strip>;
32
+ return_to: z.ZodString;
33
+ }, z.core.$strip>;
34
+ /** One signed-in browser, in GET /auth/sessions. */
35
+ export declare const DashboardSession: z.ZodObject<{
36
+ id: z.ZodString;
37
+ current: z.ZodBoolean;
38
+ browser: z.ZodString;
39
+ os: z.ZodString;
40
+ created_at: z.ZodISODateTime;
41
+ last_active_at: z.ZodISODateTime;
42
+ }, z.core.$strip>;
43
+ export declare const SessionsResponse: z.ZodObject<{
44
+ sessions: z.ZodArray<z.ZodObject<{
45
+ id: z.ZodString;
46
+ current: z.ZodBoolean;
47
+ browser: z.ZodString;
48
+ os: z.ZodString;
49
+ created_at: z.ZodISODateTime;
50
+ last_active_at: z.ZodISODateTime;
51
+ }, z.core.$strip>>;
52
+ }, z.core.$strip>;
53
+ /** POST /auth/accept-terms: the user, now with terms_accepted true. */
54
+ export declare const AcceptTermsResponse: z.ZodObject<{
55
+ user: z.ZodObject<{
56
+ id: z.ZodString;
57
+ email: z.ZodEmail;
58
+ name: z.ZodNullable<z.ZodString>;
59
+ terms_accepted: z.ZodBoolean;
60
+ }, z.core.$strip>;
61
+ }, z.core.$strip>;
62
+ export declare const MagicLinkRequestBody: z.ZodObject<{
63
+ email: z.ZodEmail;
64
+ return_to: z.ZodOptional<z.ZodString>;
65
+ }, z.core.$strip>;
66
+ export declare const MagicLinkVerifyBody: z.ZodObject<{
67
+ token: z.ZodString;
68
+ }, z.core.$strip>;
69
+ /** POST /auth/token: the one-time code from a Google or GitHub sign-in's redirect. */
70
+ export declare const ExchangeCodeBody: z.ZodObject<{
71
+ code: z.ZodString;
72
+ }, z.core.$strip>;
73
+ export declare const RefreshBody: z.ZodObject<{
74
+ refresh_token: z.ZodString;
75
+ }, z.core.$strip>;
76
+ export declare const LogoutBody: z.ZodObject<{
77
+ refresh_token: z.ZodOptional<z.ZodString>;
78
+ everywhere: z.ZodOptional<z.ZodBoolean>;
79
+ }, z.core.$strip>;
80
+ /** The paths, for the clients that call them. */
81
+ export declare const AUTH_PATHS: {
82
+ readonly magicLink: "/auth/magic-link";
83
+ readonly verifyMagicLink: "/auth/magic-link/verify";
84
+ readonly exchangeCode: "/auth/token";
85
+ readonly refresh: "/auth/refresh";
86
+ readonly logout: "/auth/logout";
87
+ readonly sessions: "/auth/sessions";
88
+ readonly acceptTerms: "/auth/accept-terms";
89
+ readonly signIn: (provider: "google" | "github") => "/auth/github" | "/auth/google";
90
+ };
91
+ export type AuthUser = z.infer<typeof AuthUser>;
92
+ export type TokenPair = z.infer<typeof TokenPair>;
93
+ export type MagicLinkVerifyResponse = z.infer<typeof MagicLinkVerifyResponse>;
94
+ export type DashboardSession = z.infer<typeof DashboardSession>;
95
+ export type SessionsResponse = z.infer<typeof SessionsResponse>;
96
+ export type AcceptTermsResponse = z.infer<typeof AcceptTermsResponse>;
97
+ export type MagicLinkRequestBody = z.infer<typeof MagicLinkRequestBody>;
98
+ export type MagicLinkVerifyBody = z.infer<typeof MagicLinkVerifyBody>;
99
+ export type ExchangeCodeBody = z.infer<typeof ExchangeCodeBody>;
100
+ export type RefreshBody = z.infer<typeof RefreshBody>;
101
+ export type LogoutBody = z.infer<typeof LogoutBody>;
package/dist/auth.js ADDED
@@ -0,0 +1,68 @@
1
+ // The dashboard's /auth/* endpoints: signing in, staying signed in, signing out (docs/frontend/05).
2
+ //
3
+ // Dashboard plumbing, not the public API: these endpoints aren't operations, aren't MCP tools and aren't in
4
+ // openapi.json. They're defined here so the api and @lilbox/client/session share one definition. They may
5
+ // change with the dashboard; the stability rules in the README apply to operations, not to these.
6
+ import { z } from "zod";
7
+ import { UserId } from "./common.js";
8
+ // -----------------------------------------------------------------------------------------------------------
9
+ // Responses
10
+ // -----------------------------------------------------------------------------------------------------------
11
+ /** `user` in the token pair: enough to show who's signed in and whether they still have to accept the terms. */
12
+ export const AuthUser = z.object({
13
+ id: UserId,
14
+ email: z.email(),
15
+ name: z.string().nullable(),
16
+ terms_accepted: z.boolean(),
17
+ });
18
+ /** What every sign-in and every refresh returns. */
19
+ export const TokenPair = z.object({
20
+ access_token: z.string().meta({ description: "A 15-minute JWT (ES256). Sent as Authorization: Bearer." }),
21
+ refresh_token: z.string().meta({ description: "rt_…: single use, swapped for a new pair with /auth/refresh." }),
22
+ expires_in: z.number().int().meta({ description: "Seconds until the access token expires." }),
23
+ user: AuthUser,
24
+ });
25
+ /** POST /auth/magic-link/verify: the pair plus where the person was going. */
26
+ export const MagicLinkVerifyResponse = TokenPair.extend({
27
+ return_to: z.string().meta({ description: "A dashboard path, already checked." }),
28
+ });
29
+ /** One signed-in browser, in GET /auth/sessions. */
30
+ export const DashboardSession = z.object({
31
+ id: z.string(),
32
+ current: z.boolean().meta({ description: "The session this request was made from." }),
33
+ browser: z.string().meta({ description: 'e.g. "Chrome"; "Other" when unknown.' }),
34
+ os: z.string().meta({ description: 'e.g. "macOS"; "Other" when unknown.' }),
35
+ created_at: z.iso.datetime(),
36
+ last_active_at: z.iso.datetime(),
37
+ });
38
+ export const SessionsResponse = z.object({ sessions: z.array(DashboardSession) });
39
+ /** POST /auth/accept-terms: the user, now with terms_accepted true. */
40
+ export const AcceptTermsResponse = z.object({ user: AuthUser });
41
+ // -----------------------------------------------------------------------------------------------------------
42
+ // Requests
43
+ // -----------------------------------------------------------------------------------------------------------
44
+ export const MagicLinkRequestBody = z.object({
45
+ email: z.email().max(254),
46
+ return_to: z.string().max(2048).optional(),
47
+ });
48
+ export const MagicLinkVerifyBody = z.object({ token: z.string().min(1).max(256) });
49
+ /** POST /auth/token: the one-time code from a Google or GitHub sign-in's redirect. */
50
+ export const ExchangeCodeBody = z.object({ code: z.string().min(1).max(256) });
51
+ export const RefreshBody = z.object({ refresh_token: z.string().min(1).max(256) });
52
+ export const LogoutBody = z.object({
53
+ /** The current refresh token. The session is taken from the access token. */
54
+ refresh_token: z.string().max(256).optional(),
55
+ /** Sign out of every session of the user. */
56
+ everywhere: z.boolean().optional(),
57
+ });
58
+ /** The paths, for the clients that call them. */
59
+ export const AUTH_PATHS = {
60
+ magicLink: "/auth/magic-link",
61
+ verifyMagicLink: "/auth/magic-link/verify",
62
+ exchangeCode: "/auth/token",
63
+ refresh: "/auth/refresh",
64
+ logout: "/auth/logout",
65
+ sessions: "/auth/sessions",
66
+ acceptTerms: "/auth/accept-terms",
67
+ signIn: (provider) => `/auth/${provider}`,
68
+ };
package/dist/index.d.ts CHANGED
@@ -8,5 +8,6 @@ export * from "./deployment.js";
8
8
  export * from "./runtime.js";
9
9
  export * from "./security.js";
10
10
  export * from "./billing.js";
11
+ export * from "./auth.js";
11
12
  export { operations, operationList, type OperationName } from "./registry.js";
12
13
  export { buildOpenApi, mcpTools } from "./openapi.js";
package/dist/index.js CHANGED
@@ -16,5 +16,6 @@ export * from "./deployment.js";
16
16
  export * from "./runtime.js";
17
17
  export * from "./security.js";
18
18
  export * from "./billing.js";
19
+ export * from "./auth.js"; // dashboard plumbing (/auth/*), not operations
19
20
  export { operations, operationList } from "./registry.js";
20
21
  export { buildOpenApi, mcpTools } from "./openapi.js";
package/dist/openapi.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "openapi": "3.1.0",
3
3
  "info": {
4
4
  "title": "lilbox API",
5
- "version": "0.0.4",
5
+ "version": "0.1.0",
6
6
  "description": "The lilbox REST API. Every operation is also an MCP tool with the same name at https://mcp.lilbox.ai."
7
7
  },
8
8
  "servers": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lilbox/contracts",
3
- "version": "0.0.4",
3
+ "version": "0.1.0",
4
4
  "description": "The lilbox API's shapes: MCP tools, REST operations, errors, app.yaml, and the contracts between lilbox repos. zod schemas.",
5
5
  "license": "MIT",
6
6
  "type": "module",