@spacefast/common 0.0.2

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.
Files changed (202) hide show
  1. package/README.md +42 -0
  2. package/dist/brand.d.ts +15 -0
  3. package/dist/brand.js +24 -0
  4. package/dist/config/domains.d.ts +30 -0
  5. package/dist/config/domains.js +75 -0
  6. package/dist/config/index.d.ts +1 -0
  7. package/dist/config/index.js +3 -0
  8. package/dist/contracts/abuse.d.ts +93 -0
  9. package/dist/contracts/abuse.js +50 -0
  10. package/dist/contracts/access.d.ts +409 -0
  11. package/dist/contracts/access.js +396 -0
  12. package/dist/contracts/account.d.ts +28 -0
  13. package/dist/contracts/account.js +54 -0
  14. package/dist/contracts/activity.d.ts +118 -0
  15. package/dist/contracts/activity.js +180 -0
  16. package/dist/contracts/analytics.d.ts +56 -0
  17. package/dist/contracts/analytics.js +91 -0
  18. package/dist/contracts/annotations.d.ts +327 -0
  19. package/dist/contracts/annotations.js +234 -0
  20. package/dist/contracts/api-keys.d.ts +517 -0
  21. package/dist/contracts/api-keys.js +235 -0
  22. package/dist/contracts/archives.d.ts +332 -0
  23. package/dist/contracts/archives.js +120 -0
  24. package/dist/contracts/auth.d.ts +86 -0
  25. package/dist/contracts/auth.js +82 -0
  26. package/dist/contracts/beta.d.ts +106 -0
  27. package/dist/contracts/beta.js +104 -0
  28. package/dist/contracts/billing.d.ts +328 -0
  29. package/dist/contracts/billing.js +203 -0
  30. package/dist/contracts/builds.d.ts +504 -0
  31. package/dist/contracts/builds.js +248 -0
  32. package/dist/contracts/channels.d.ts +49 -0
  33. package/dist/contracts/channels.js +51 -0
  34. package/dist/contracts/common.d.ts +238 -0
  35. package/dist/contracts/common.js +175 -0
  36. package/dist/contracts/deployments.d.ts +574 -0
  37. package/dist/contracts/deployments.js +97 -0
  38. package/dist/contracts/device-auth.d.ts +194 -0
  39. package/dist/contracts/device-auth.js +162 -0
  40. package/dist/contracts/domains.d.ts +6115 -0
  41. package/dist/contracts/domains.js +1435 -0
  42. package/dist/contracts/enums.d.ts +196 -0
  43. package/dist/contracts/enums.js +211 -0
  44. package/dist/contracts/error-code-meta.d.ts +1560 -0
  45. package/dist/contracts/error-code-meta.js +400 -0
  46. package/dist/contracts/error-codes.d.ts +13 -0
  47. package/dist/contracts/error-codes.js +416 -0
  48. package/dist/contracts/events.d.ts +398 -0
  49. package/dist/contracts/events.js +320 -0
  50. package/dist/contracts/fast-domain-search.d.ts +19 -0
  51. package/dist/contracts/fast-domain-search.js +22 -0
  52. package/dist/contracts/features.d.ts +240 -0
  53. package/dist/contracts/features.js +406 -0
  54. package/dist/contracts/git.d.ts +288 -0
  55. package/dist/contracts/git.js +116 -0
  56. package/dist/contracts/ids.d.ts +35 -0
  57. package/dist/contracts/ids.js +45 -0
  58. package/dist/contracts/intercom.d.ts +6 -0
  59. package/dist/contracts/intercom.js +5 -0
  60. package/dist/contracts/internal.d.ts +103 -0
  61. package/dist/contracts/internal.js +92 -0
  62. package/dist/contracts/mcp.d.ts +788 -0
  63. package/dist/contracts/mcp.js +161 -0
  64. package/dist/contracts/me.d.ts +81 -0
  65. package/dist/contracts/me.js +104 -0
  66. package/dist/contracts/oauth-resources.d.ts +30 -0
  67. package/dist/contracts/oauth-resources.js +61 -0
  68. package/dist/contracts/operations.d.ts +54 -0
  69. package/dist/contracts/operations.js +14 -0
  70. package/dist/contracts/plan-policy.d.ts +85 -0
  71. package/dist/contracts/plan-policy.js +75 -0
  72. package/dist/contracts/platform.d.ts +359 -0
  73. package/dist/contracts/platform.js +216 -0
  74. package/dist/contracts/push-new.d.ts +156 -0
  75. package/dist/contracts/push-new.js +52 -0
  76. package/dist/contracts/quotas.d.ts +16 -0
  77. package/dist/contracts/quotas.js +36 -0
  78. package/dist/contracts/repository-connections.d.ts +231 -0
  79. package/dist/contracts/repository-connections.js +106 -0
  80. package/dist/contracts/resources.d.ts +529 -0
  81. package/dist/contracts/resources.js +209 -0
  82. package/dist/contracts/routes.d.ts +45 -0
  83. package/dist/contracts/routes.js +31 -0
  84. package/dist/contracts/runtime-api.d.ts +449 -0
  85. package/dist/contracts/runtime-api.js +513 -0
  86. package/dist/contracts/sites.d.ts +393 -0
  87. package/dist/contracts/sites.js +121 -0
  88. package/dist/contracts/slugs.d.ts +31 -0
  89. package/dist/contracts/slugs.js +47 -0
  90. package/dist/contracts/space-config.d.ts +216 -0
  91. package/dist/contracts/space-config.js +237 -0
  92. package/dist/contracts/space-theme.d.ts +25 -0
  93. package/dist/contracts/space-theme.js +49 -0
  94. package/dist/contracts/spaces.d.ts +2760 -0
  95. package/dist/contracts/spaces.js +589 -0
  96. package/dist/contracts/superadmin-activity.d.ts +205 -0
  97. package/dist/contracts/superadmin-activity.js +107 -0
  98. package/dist/contracts/superadmin-emails.d.ts +212 -0
  99. package/dist/contracts/superadmin-emails.js +112 -0
  100. package/dist/contracts/superadmin-queues.d.ts +414 -0
  101. package/dist/contracts/superadmin-queues.js +202 -0
  102. package/dist/contracts/superadmin-runtime.d.ts +27 -0
  103. package/dist/contracts/superadmin-runtime.js +38 -0
  104. package/dist/contracts/superadmin-spaces.d.ts +429 -0
  105. package/dist/contracts/superadmin-spaces.js +82 -0
  106. package/dist/contracts/superadmin-tenants.d.ts +180 -0
  107. package/dist/contracts/superadmin-tenants.js +117 -0
  108. package/dist/contracts/superadmin.d.ts +654 -0
  109. package/dist/contracts/superadmin.js +309 -0
  110. package/dist/contracts/tags.d.ts +1140 -0
  111. package/dist/contracts/tags.js +1050 -0
  112. package/dist/contracts/teams.d.ts +233 -0
  113. package/dist/contracts/teams.js +174 -0
  114. package/dist/contracts/telemetry.d.ts +2 -0
  115. package/dist/contracts/telemetry.js +1 -0
  116. package/dist/contracts/transfers.d.ts +105 -0
  117. package/dist/contracts/transfers.js +48 -0
  118. package/dist/contracts/variables.d.ts +189 -0
  119. package/dist/contracts/variables.js +82 -0
  120. package/dist/contracts/webhooks.d.ts +159 -0
  121. package/dist/contracts/webhooks.js +59 -0
  122. package/dist/contracts/zero.d.ts +1538 -0
  123. package/dist/contracts/zero.js +755 -0
  124. package/dist/docs/agent-prose.d.ts +35 -0
  125. package/dist/docs/agent-prose.js +153 -0
  126. package/dist/docs/agent-setup.d.ts +6 -0
  127. package/dist/docs/agent-setup.js +164 -0
  128. package/dist/docs/agent-solutions.d.ts +110 -0
  129. package/dist/docs/agent-solutions.js +181 -0
  130. package/dist/docs/error-docs.d.ts +12 -0
  131. package/dist/docs/error-docs.js +1601 -0
  132. package/dist/docs/skill-distribution.d.ts +12 -0
  133. package/dist/docs/skill-distribution.js +18 -0
  134. package/dist/domain-exploration.d.ts +108 -0
  135. package/dist/domain-exploration.js +488 -0
  136. package/dist/domain-normalize.d.ts +1 -0
  137. package/dist/domain-normalize.js +14 -0
  138. package/dist/domain-zones.d.ts +1 -0
  139. package/dist/domain-zones.js +5272 -0
  140. package/dist/index.d.ts +1 -0
  141. package/dist/index.js +1 -0
  142. package/dist/utils/access-policy.d.ts +39 -0
  143. package/dist/utils/access-policy.js +232 -0
  144. package/dist/utils/api.d.ts +4 -0
  145. package/dist/utils/api.js +13 -0
  146. package/dist/utils/auth-redirect.d.ts +1 -0
  147. package/dist/utils/auth-redirect.js +48 -0
  148. package/dist/utils/auth.d.ts +5 -0
  149. package/dist/utils/auth.js +13 -0
  150. package/dist/utils/build-settings.d.ts +49 -0
  151. package/dist/utils/build-settings.js +366 -0
  152. package/dist/utils/claim-token.d.ts +1 -0
  153. package/dist/utils/claim-token.js +9 -0
  154. package/dist/utils/collections.d.ts +1 -0
  155. package/dist/utils/collections.js +5 -0
  156. package/dist/utils/concurrency.d.ts +1 -0
  157. package/dist/utils/concurrency.js +18 -0
  158. package/dist/utils/content-type.d.ts +10 -0
  159. package/dist/utils/content-type.js +145 -0
  160. package/dist/utils/error-display.d.ts +7 -0
  161. package/dist/utils/error-display.js +42 -0
  162. package/dist/utils/error.d.ts +1 -0
  163. package/dist/utils/error.js +3 -0
  164. package/dist/utils/generate-space-name.d.ts +14 -0
  165. package/dist/utils/generate-space-name.js +95 -0
  166. package/dist/utils/git-repository.d.ts +5 -0
  167. package/dist/utils/git-repository.js +99 -0
  168. package/dist/utils/guards.d.ts +1 -0
  169. package/dist/utils/guards.js +3 -0
  170. package/dist/utils/publish-detection.d.ts +10 -0
  171. package/dist/utils/publish-detection.js +118 -0
  172. package/dist/utils/publish-policy.d.ts +69 -0
  173. package/dist/utils/publish-policy.js +429 -0
  174. package/dist/utils/query-client.d.ts +7 -0
  175. package/dist/utils/query-client.js +21 -0
  176. package/dist/utils/query-keys.d.ts +75 -0
  177. package/dist/utils/query-keys.js +78 -0
  178. package/dist/utils/runtime-paths.d.ts +7 -0
  179. package/dist/utils/runtime-paths.js +28 -0
  180. package/dist/utils/runtime-upload.d.ts +19 -0
  181. package/dist/utils/runtime-upload.js +27 -0
  182. package/dist/utils/slug.d.ts +5 -0
  183. package/dist/utils/slug.js +13 -0
  184. package/dist/utils/space-config.d.ts +75 -0
  185. package/dist/utils/space-config.js +415 -0
  186. package/dist/utils/space-theme.d.ts +16 -0
  187. package/dist/utils/space-theme.js +89 -0
  188. package/dist/utils/static-runtime-policy.d.ts +17 -0
  189. package/dist/utils/static-runtime-policy.js +103 -0
  190. package/dist/utils/upload-session.d.ts +34 -0
  191. package/dist/utils/upload-session.js +69 -0
  192. package/dist/utils/urls.d.ts +2 -0
  193. package/dist/utils/urls.js +7 -0
  194. package/dist/utils/version-path.d.ts +6 -0
  195. package/dist/utils/version-path.js +51 -0
  196. package/dist/utils/wpcom-auth-redirects.d.ts +14 -0
  197. package/dist/utils/wpcom-auth-redirects.js +49 -0
  198. package/dist/utils/zero-realtime-signature.d.ts +12 -0
  199. package/dist/utils/zero-realtime-signature.js +45 -0
  200. package/dist/vocabulary.d.ts +230 -0
  201. package/dist/vocabulary.js +218 -0
  202. package/package.json +58 -0
@@ -0,0 +1,194 @@
1
+ import { z } from "zod";
2
+ export declare const DeviceAuthorizationStartRequestSchema: z.ZodObject<{
3
+ clientId: z.ZodDefault<z.ZodString>;
4
+ scope: z.ZodOptional<z.ZodString>;
5
+ claim: z.ZodOptional<z.ZodObject<{
6
+ spaceId: z.ZodString;
7
+ claimToken: z.ZodString;
8
+ }, z.core.$strict>>;
9
+ }, z.core.$strict>;
10
+ export type DeviceAuthorizationStartRequest = z.infer<typeof DeviceAuthorizationStartRequestSchema>;
11
+ export declare const DeviceAuthorizationStartResponseSchema: z.ZodObject<{
12
+ deviceCode: z.ZodString;
13
+ userCode: z.ZodString;
14
+ verificationUrl: z.ZodString;
15
+ interval: z.ZodNumber;
16
+ expiresAt: z.ZodString;
17
+ }, z.core.$strip>;
18
+ export type DeviceAuthorizationStartResponse = z.infer<typeof DeviceAuthorizationStartResponseSchema>;
19
+ export declare const DeviceAuthorizationPollRequestSchema: z.ZodObject<{
20
+ deviceCode: z.ZodString;
21
+ }, z.core.$strip>;
22
+ export type DeviceAuthorizationPollRequest = z.infer<typeof DeviceAuthorizationPollRequestSchema>;
23
+ export declare const DeviceAuthorizationStatusSchema: z.ZodEnum<{
24
+ expired: "expired";
25
+ pending: "pending";
26
+ approved: "approved";
27
+ denied: "denied";
28
+ consumed: "consumed";
29
+ }>;
30
+ export type DeviceAuthorizationStatus = z.infer<typeof DeviceAuthorizationStatusSchema>;
31
+ export declare const DeviceAuthorizationPollResponseSchema: z.ZodObject<{
32
+ status: z.ZodEnum<{
33
+ expired: "expired";
34
+ pending: "pending";
35
+ approved: "approved";
36
+ denied: "denied";
37
+ consumed: "consumed";
38
+ }>;
39
+ apiKey: z.ZodOptional<z.ZodObject<{
40
+ id: z.ZodString;
41
+ name: z.ZodNullable<z.ZodString>;
42
+ tenantId: z.ZodNullable<z.ZodString>;
43
+ subject: z.ZodNullable<z.ZodObject<{
44
+ type: z.ZodEnum<{
45
+ external: "external";
46
+ user: "user";
47
+ system: "system";
48
+ team: "team";
49
+ }>;
50
+ id: z.ZodString;
51
+ }, z.core.$strip>>;
52
+ ownerPrincipal: z.ZodNullable<z.ZodObject<{
53
+ type: z.ZodEnum<{
54
+ external: "external";
55
+ team: "team";
56
+ }>;
57
+ id: z.ZodString;
58
+ }, z.core.$strip>>;
59
+ createdByUserId: z.ZodString;
60
+ preset: z.ZodNullable<z.ZodEnum<{
61
+ ci_deploy: "ci_deploy";
62
+ space_publisher: "space_publisher";
63
+ space_admin: "space_admin";
64
+ site_admin: "site_admin";
65
+ domain_manager: "domain_manager";
66
+ team_admin: "team_admin";
67
+ billing_viewer: "billing_viewer";
68
+ }>>;
69
+ policy: z.ZodNullable<z.ZodObject<{
70
+ version: z.ZodLiteral<"2026-06-09">;
71
+ statements: z.ZodArray<z.ZodObject<{
72
+ effect: z.ZodEnum<{
73
+ allow: "allow";
74
+ deny: "deny";
75
+ }>;
76
+ actions: z.ZodArray<z.ZodEnum<{
77
+ "*": "*";
78
+ "sites:read": "sites:read";
79
+ "sites:create": "sites:create";
80
+ "sites:write": "sites:write";
81
+ "sites:delete": "sites:delete";
82
+ "sites:policy.write": "sites:policy.write";
83
+ "spaces:read": "spaces:read";
84
+ "spaces:create": "spaces:create";
85
+ "spaces:write": "spaces:write";
86
+ "spaces:delete": "spaces:delete";
87
+ "spaces:publish": "spaces:publish";
88
+ "spaces:transfer": "spaces:transfer";
89
+ "spaces:export": "spaces:export";
90
+ "spaces:import": "spaces:import";
91
+ "versions:read": "versions:read";
92
+ "versions:promote": "versions:promote";
93
+ "versions:delete": "versions:delete";
94
+ "versions:download": "versions:download";
95
+ "domains:read": "domains:read";
96
+ "domains:create": "domains:create";
97
+ "domains:verify": "domains:verify";
98
+ "domains:assign": "domains:assign";
99
+ "domains:bind": "domains:bind";
100
+ "domains:delete": "domains:delete";
101
+ "domains:dns.write": "domains:dns.write";
102
+ "domains:dns.credentials.write": "domains:dns.credentials.write";
103
+ "domains:purchase": "domains:purchase";
104
+ "webhooks:read": "webhooks:read";
105
+ "webhooks:write": "webhooks:write";
106
+ "builds:read": "builds:read";
107
+ "builds:create": "builds:create";
108
+ "teams:read": "teams:read";
109
+ "teams:write": "teams:write";
110
+ "teams:members.write": "teams:members.write";
111
+ "billing:read": "billing:read";
112
+ "billing:write": "billing:write";
113
+ "tokens:read": "tokens:read";
114
+ "tokens:create": "tokens:create";
115
+ "tokens:revoke": "tokens:revoke";
116
+ "mcp:tools": "mcp:tools";
117
+ "runtime:manage": "runtime:manage";
118
+ }>>;
119
+ resources: z.ZodArray<z.ZodString>;
120
+ conditions: z.ZodOptional<z.ZodObject<{
121
+ "request.client": z.ZodOptional<z.ZodEnum<{
122
+ api: "api";
123
+ dashboard: "dashboard";
124
+ cli: "cli";
125
+ worker: "worker";
126
+ }>>;
127
+ }, z.core.$strict>>;
128
+ }, z.core.$strict>>;
129
+ }, z.core.$strict>>;
130
+ metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
131
+ secretPreview: z.ZodString;
132
+ secret: z.ZodOptional<z.ZodString>;
133
+ notBefore: z.ZodNullable<z.ZodString>;
134
+ expiresAt: z.ZodNullable<z.ZodString>;
135
+ ipAllowlist: z.ZodNullable<z.ZodArray<z.ZodString>>;
136
+ revokedAt: z.ZodNullable<z.ZodString>;
137
+ enabled: z.ZodBoolean;
138
+ createdAt: z.ZodString;
139
+ updatedAt: z.ZodString;
140
+ lastRequestAt: z.ZodNullable<z.ZodString>;
141
+ }, z.core.$strip>>;
142
+ claimedSpaceId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
143
+ }, z.core.$strip>;
144
+ export type DeviceAuthorizationPollResponse = z.infer<typeof DeviceAuthorizationPollResponseSchema>;
145
+ export declare const DeviceAuthorizationVerifyQuerySchema: z.ZodObject<{
146
+ user_code: z.ZodString;
147
+ }, z.core.$strip>;
148
+ export type DeviceAuthorizationVerifyQuery = z.infer<typeof DeviceAuthorizationVerifyQuerySchema>;
149
+ export declare const DeviceAuthorizationVerifyResponseSchema: z.ZodObject<{
150
+ status: z.ZodEnum<{
151
+ expired: "expired";
152
+ pending: "pending";
153
+ approved: "approved";
154
+ denied: "denied";
155
+ consumed: "consumed";
156
+ }>;
157
+ clientId: z.ZodNullable<z.ZodString>;
158
+ scope: z.ZodNullable<z.ZodString>;
159
+ origin: z.ZodNullable<z.ZodString>;
160
+ expiresAt: z.ZodString;
161
+ claim: z.ZodNullable<z.ZodObject<{
162
+ spaceId: z.ZodString;
163
+ title: z.ZodNullable<z.ZodString>;
164
+ liveUrl: z.ZodNullable<z.ZodString>;
165
+ }, z.core.$strict>>;
166
+ }, z.core.$strip>;
167
+ export type DeviceAuthorizationVerifyResponse = z.infer<typeof DeviceAuthorizationVerifyResponseSchema>;
168
+ export declare const DeviceAuthorizationApproveRequestSchema: z.ZodObject<{
169
+ userCode: z.ZodString;
170
+ teamId: z.ZodString;
171
+ preset: z.ZodEnum<{
172
+ ci_deploy: "ci_deploy";
173
+ space_publisher: "space_publisher";
174
+ space_admin: "space_admin";
175
+ site_admin: "site_admin";
176
+ domain_manager: "domain_manager";
177
+ team_admin: "team_admin";
178
+ billing_viewer: "billing_viewer";
179
+ }>;
180
+ }, z.core.$strict>;
181
+ export type DeviceAuthorizationApproveRequest = z.infer<typeof DeviceAuthorizationApproveRequestSchema>;
182
+ export declare const DeviceAuthorizationApproveResponseSchema: z.ZodObject<{
183
+ status: z.ZodLiteral<"approved">;
184
+ claimedSpaceId: z.ZodNullable<z.ZodString>;
185
+ }, z.core.$strict>;
186
+ export type DeviceAuthorizationApproveResponse = z.infer<typeof DeviceAuthorizationApproveResponseSchema>;
187
+ export declare const DeviceAuthorizationDenyRequestSchema: z.ZodObject<{
188
+ userCode: z.ZodString;
189
+ }, z.core.$strip>;
190
+ export type DeviceAuthorizationDenyRequest = z.infer<typeof DeviceAuthorizationDenyRequestSchema>;
191
+ export declare const DeviceAuthorizationDenyResponseSchema: z.ZodObject<{
192
+ status: z.ZodLiteral<"denied">;
193
+ }, z.core.$strip>;
194
+ export type DeviceAuthorizationDenyResponse = z.infer<typeof DeviceAuthorizationDenyResponseSchema>;
@@ -0,0 +1,162 @@
1
+ import { z } from "zod";
2
+ import { ApiKeyPresetSchema, ApiKeySchema } from "./api-keys.js";
3
+ // Device authorization flow (internal-docs/platform.md Credential Bootstrap):
4
+ // `POST /v1/auth/device` starts the flow, `POST /v1/auth/device/poll` redeems
5
+ // it. Device codes are bearer capabilities: they ride POST bodies only, are
6
+ // never logged, and redeem exactly once. User codes are short display codes the
7
+ // person types on the dashboard verification page; verification attempts are
8
+ // rate-limited per caller and per code with lockout so user codes cannot be
9
+ // brute-forced into approving an attacker's device.
10
+ export const DeviceAuthorizationStartRequestSchema = z
11
+ .object({
12
+ clientId: z
13
+ .string()
14
+ .trim()
15
+ .min(1)
16
+ .max(255)
17
+ .default("spacefast-cli")
18
+ .describe("Requesting client identifier shown on the verification page."),
19
+ scope: z
20
+ .string()
21
+ .trim()
22
+ .min(1)
23
+ .max(4096)
24
+ .optional()
25
+ .describe("Requested access preset name. The approver chooses the final preset; this only seeds the verification page default."),
26
+ claim: z
27
+ .object({
28
+ spaceId: z
29
+ .string()
30
+ .min(1)
31
+ .describe("Anonymous space id being claimed with this device flow."),
32
+ claimToken: z
33
+ .string()
34
+ .trim()
35
+ .min(1)
36
+ .max(512)
37
+ .describe("Anonymous-space claim token. Stored server-side only as a hash."),
38
+ })
39
+ .strict()
40
+ .optional()
41
+ .describe("Explicit claim handoff intent. Only claim flows send this; ordinary device login leaves it absent."),
42
+ })
43
+ .strict();
44
+ export const DeviceAuthorizationStartResponseSchema = z.object({
45
+ deviceCode: z
46
+ .string()
47
+ .min(1)
48
+ .describe("High-entropy bearer capability the device polls with. Never log or display it."),
49
+ userCode: z
50
+ .string()
51
+ .min(1)
52
+ .describe("Short display code the user types on the dashboard verification page."),
53
+ verificationUrl: z
54
+ .string()
55
+ .url()
56
+ .describe("Dashboard verification page URL where the user approves this device."),
57
+ interval: z
58
+ .number()
59
+ .int()
60
+ .positive()
61
+ .describe("Minimum number of seconds the device must wait between polls."),
62
+ expiresAt: z
63
+ .string()
64
+ .datetime()
65
+ .describe("Instant after which the device and user codes are no longer redeemable."),
66
+ });
67
+ export const DeviceAuthorizationPollRequestSchema = z.object({
68
+ deviceCode: z
69
+ .string()
70
+ .trim()
71
+ .min(1)
72
+ .max(512)
73
+ .describe("Device code returned by POST /v1/auth/device. Body-only, never a URL."),
74
+ });
75
+ export const DeviceAuthorizationStatusSchema = z
76
+ .enum(["pending", "approved", "denied", "expired", "consumed"])
77
+ .describe("Device authorization state. `approved` carries the one-time API key exactly once, then the record is `consumed`.");
78
+ export const DeviceAuthorizationPollResponseSchema = z.object({
79
+ status: DeviceAuthorizationStatusSchema,
80
+ apiKey: ApiKeySchema.optional().describe("The minted API key including its one-time `secret`. Present only on the first poll after approval."),
81
+ claimedSpaceId: z
82
+ .string()
83
+ .nullable()
84
+ .optional()
85
+ .describe("Space claimed during approval, when the device flow was started by `sf spaces claim`."),
86
+ });
87
+ // Verification-page surface (`GET /v1/auth/device?user_code=…`). Returns
88
+ // requester context only — never the device code (it is the bearer capability).
89
+ export const DeviceAuthorizationVerifyQuerySchema = z.object({
90
+ user_code: z
91
+ .string()
92
+ .trim()
93
+ .min(1)
94
+ .max(32)
95
+ .describe("User code typed by the person approving the device (dashes ignored)."),
96
+ });
97
+ export const DeviceAuthorizationVerifyResponseSchema = z.object({
98
+ status: DeviceAuthorizationStatusSchema,
99
+ clientId: z
100
+ .string()
101
+ .nullable()
102
+ .describe("Requesting client identifier recorded at device start."),
103
+ scope: z.string().nullable().describe("Access preset the device requested at start, if any."),
104
+ origin: z
105
+ .string()
106
+ .nullable()
107
+ .describe("Request origin (client IP) recorded when the device flow started."),
108
+ expiresAt: z
109
+ .string()
110
+ .datetime()
111
+ .describe("Instant after which this device authorization can no longer be approved."),
112
+ claim: z
113
+ .object({
114
+ spaceId: z.string().describe("Anonymous space that will be claimed if approval succeeds."),
115
+ title: z.string().nullable().describe("Display title of the anonymous space, if available."),
116
+ liveUrl: z.string().nullable().describe("Current live URL of the anonymous space, if any."),
117
+ })
118
+ .strict()
119
+ .nullable()
120
+ .describe("Explicit claim handoff attached to this device authorization, if any."),
121
+ });
122
+ // Approval intent (`POST /v1/auth/device/approve`): the approver chooses the
123
+ // team and preset. If the device start request carried a claim handoff, approval
124
+ // also claims that anonymous space into the chosen team after the approval CAS
125
+ // wins. The intent persists server-side and the poll mints from it; the chosen
126
+ // preset's compiled policy must be a subset of the approver's effective
127
+ // team-role policy.
128
+ export const DeviceAuthorizationApproveRequestSchema = z
129
+ .object({
130
+ userCode: z
131
+ .string()
132
+ .trim()
133
+ .min(1)
134
+ .max(32)
135
+ .describe("User code shown on the device being approved (dashes ignored)."),
136
+ teamId: z
137
+ .string()
138
+ .min(1)
139
+ .describe("Team the minted API key will belong to. The approver must be a member."),
140
+ preset: ApiKeyPresetSchema.describe("Policy preset for the minted key. Its compiled policy must be a subset of the approver's team-role policy."),
141
+ })
142
+ .strict();
143
+ export const DeviceAuthorizationApproveResponseSchema = z
144
+ .object({
145
+ status: z.literal("approved").describe("The device authorization is approved."),
146
+ claimedSpaceId: z
147
+ .string()
148
+ .nullable()
149
+ .describe("Space claimed by the server-side claim handoff, if one was attached."),
150
+ })
151
+ .strict();
152
+ export const DeviceAuthorizationDenyRequestSchema = z.object({
153
+ userCode: z
154
+ .string()
155
+ .trim()
156
+ .min(1)
157
+ .max(32)
158
+ .describe("User code shown on the device being denied (dashes ignored)."),
159
+ });
160
+ export const DeviceAuthorizationDenyResponseSchema = z.object({
161
+ status: z.literal("denied").describe("The device authorization is denied."),
162
+ });