@fuzdev/fuz_app 0.29.0 → 0.31.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.
Files changed (210) hide show
  1. package/dist/actions/CLAUDE.md +630 -0
  2. package/dist/actions/action_rpc.d.ts +29 -0
  3. package/dist/actions/action_rpc.d.ts.map +1 -1
  4. package/dist/actions/action_rpc.js +42 -6
  5. package/dist/actions/action_types.d.ts +2 -2
  6. package/dist/actions/cancel.d.ts +12 -13
  7. package/dist/actions/cancel.d.ts.map +1 -1
  8. package/dist/actions/cancel.js +10 -13
  9. package/dist/actions/heartbeat.d.ts +8 -13
  10. package/dist/actions/heartbeat.d.ts.map +1 -1
  11. package/dist/actions/heartbeat.js +5 -8
  12. package/dist/actions/register_action_ws.d.ts +3 -3
  13. package/dist/actions/register_action_ws.js +2 -2
  14. package/dist/actions/register_ws_endpoint.d.ts +4 -4
  15. package/dist/actions/register_ws_endpoint.d.ts.map +1 -1
  16. package/dist/actions/register_ws_endpoint.js +3 -3
  17. package/dist/actions/socket.svelte.d.ts +16 -16
  18. package/dist/actions/socket.svelte.d.ts.map +1 -1
  19. package/dist/actions/socket.svelte.js +15 -15
  20. package/dist/actions/transports_ws_auth_guard.d.ts.map +1 -1
  21. package/dist/actions/transports_ws_backend.d.ts +15 -0
  22. package/dist/actions/transports_ws_backend.d.ts.map +1 -1
  23. package/dist/actions/transports_ws_backend.js +17 -0
  24. package/dist/auth/CLAUDE.md +923 -0
  25. package/dist/auth/account_action_specs.d.ts +216 -0
  26. package/dist/auth/account_action_specs.d.ts.map +1 -0
  27. package/dist/auth/account_action_specs.js +159 -0
  28. package/dist/auth/account_actions.d.ts +51 -0
  29. package/dist/auth/account_actions.d.ts.map +1 -0
  30. package/dist/auth/account_actions.js +119 -0
  31. package/dist/auth/account_queries.d.ts +6 -2
  32. package/dist/auth/account_queries.d.ts.map +1 -1
  33. package/dist/auth/account_queries.js +40 -4
  34. package/dist/auth/account_routes.d.ts +94 -16
  35. package/dist/auth/account_routes.d.ts.map +1 -1
  36. package/dist/auth/account_routes.js +108 -180
  37. package/dist/auth/account_schema.d.ts +85 -30
  38. package/dist/auth/account_schema.d.ts.map +1 -1
  39. package/dist/auth/account_schema.js +40 -8
  40. package/dist/auth/admin_action_specs.d.ts +674 -0
  41. package/dist/auth/admin_action_specs.d.ts.map +1 -0
  42. package/dist/auth/admin_action_specs.js +287 -0
  43. package/dist/auth/admin_actions.d.ts +69 -0
  44. package/dist/auth/admin_actions.d.ts.map +1 -0
  45. package/dist/auth/admin_actions.js +256 -0
  46. package/dist/auth/api_token.d.ts +10 -0
  47. package/dist/auth/api_token.d.ts.map +1 -1
  48. package/dist/auth/api_token.js +9 -0
  49. package/dist/auth/api_token_queries.d.ts +3 -3
  50. package/dist/auth/api_token_queries.js +3 -3
  51. package/dist/auth/app_settings_schema.d.ts +4 -3
  52. package/dist/auth/app_settings_schema.d.ts.map +1 -1
  53. package/dist/auth/app_settings_schema.js +2 -1
  54. package/dist/auth/audit_log_routes.d.ts +14 -6
  55. package/dist/auth/audit_log_routes.d.ts.map +1 -1
  56. package/dist/auth/audit_log_routes.js +22 -79
  57. package/dist/auth/audit_log_schema.d.ts +100 -29
  58. package/dist/auth/audit_log_schema.d.ts.map +1 -1
  59. package/dist/auth/audit_log_schema.js +83 -11
  60. package/dist/auth/bootstrap_routes.d.ts +14 -0
  61. package/dist/auth/bootstrap_routes.d.ts.map +1 -1
  62. package/dist/auth/bootstrap_routes.js +10 -3
  63. package/dist/auth/cleanup.d.ts +63 -0
  64. package/dist/auth/cleanup.d.ts.map +1 -0
  65. package/dist/auth/cleanup.js +80 -0
  66. package/dist/auth/invite_schema.d.ts +11 -10
  67. package/dist/auth/invite_schema.d.ts.map +1 -1
  68. package/dist/auth/invite_schema.js +4 -3
  69. package/dist/auth/migrations.d.ts +6 -0
  70. package/dist/auth/migrations.d.ts.map +1 -1
  71. package/dist/auth/migrations.js +28 -0
  72. package/dist/auth/permit_offer_action_specs.d.ts +364 -0
  73. package/dist/auth/permit_offer_action_specs.d.ts.map +1 -0
  74. package/dist/auth/permit_offer_action_specs.js +216 -0
  75. package/dist/auth/permit_offer_actions.d.ts +96 -0
  76. package/dist/auth/permit_offer_actions.d.ts.map +1 -0
  77. package/dist/auth/permit_offer_actions.js +428 -0
  78. package/dist/auth/permit_offer_notifications.d.ts +361 -0
  79. package/dist/auth/permit_offer_notifications.d.ts.map +1 -0
  80. package/dist/auth/permit_offer_notifications.js +179 -0
  81. package/dist/auth/permit_offer_queries.d.ts +165 -0
  82. package/dist/auth/permit_offer_queries.d.ts.map +1 -0
  83. package/dist/auth/permit_offer_queries.js +390 -0
  84. package/dist/auth/permit_offer_schema.d.ts +103 -0
  85. package/dist/auth/permit_offer_schema.d.ts.map +1 -0
  86. package/dist/auth/permit_offer_schema.js +142 -0
  87. package/dist/auth/permit_queries.d.ts +77 -14
  88. package/dist/auth/permit_queries.d.ts.map +1 -1
  89. package/dist/auth/permit_queries.js +119 -24
  90. package/dist/auth/session_queries.d.ts +4 -2
  91. package/dist/auth/session_queries.d.ts.map +1 -1
  92. package/dist/auth/session_queries.js +4 -2
  93. package/dist/auth/signup_routes.d.ts +13 -0
  94. package/dist/auth/signup_routes.d.ts.map +1 -1
  95. package/dist/auth/signup_routes.js +14 -7
  96. package/dist/http/CLAUDE.md +584 -0
  97. package/dist/http/pending_effects.d.ts +29 -0
  98. package/dist/http/pending_effects.d.ts.map +1 -0
  99. package/dist/http/pending_effects.js +31 -0
  100. package/dist/http/route_spec.d.ts.map +1 -1
  101. package/dist/http/route_spec.js +4 -3
  102. package/dist/rate_limiter.d.ts +30 -0
  103. package/dist/rate_limiter.d.ts.map +1 -1
  104. package/dist/rate_limiter.js +25 -2
  105. package/dist/realtime/sse_auth_guard.d.ts +2 -0
  106. package/dist/realtime/sse_auth_guard.d.ts.map +1 -1
  107. package/dist/realtime/sse_auth_guard.js +5 -3
  108. package/dist/testing/CLAUDE.md +668 -1
  109. package/dist/testing/admin_integration.d.ts +10 -7
  110. package/dist/testing/admin_integration.d.ts.map +1 -1
  111. package/dist/testing/admin_integration.js +382 -482
  112. package/dist/testing/app_server.d.ts +7 -6
  113. package/dist/testing/app_server.d.ts.map +1 -1
  114. package/dist/testing/attack_surface.d.ts +9 -3
  115. package/dist/testing/attack_surface.d.ts.map +1 -1
  116. package/dist/testing/attack_surface.js +4 -4
  117. package/dist/testing/audit_completeness.d.ts +6 -0
  118. package/dist/testing/audit_completeness.d.ts.map +1 -1
  119. package/dist/testing/audit_completeness.js +158 -134
  120. package/dist/testing/auth_apps.d.ts.map +1 -1
  121. package/dist/testing/auth_apps.js +4 -33
  122. package/dist/testing/db.d.ts +1 -1
  123. package/dist/testing/db.d.ts.map +1 -1
  124. package/dist/testing/db.js +2 -0
  125. package/dist/testing/entities.d.ts +35 -13
  126. package/dist/testing/entities.d.ts.map +1 -1
  127. package/dist/testing/entities.js +17 -0
  128. package/dist/testing/integration.d.ts +10 -0
  129. package/dist/testing/integration.d.ts.map +1 -1
  130. package/dist/testing/integration.js +352 -340
  131. package/dist/testing/integration_helpers.d.ts +16 -5
  132. package/dist/testing/integration_helpers.d.ts.map +1 -1
  133. package/dist/testing/integration_helpers.js +24 -4
  134. package/dist/testing/rate_limiting.d.ts +7 -0
  135. package/dist/testing/rate_limiting.d.ts.map +1 -1
  136. package/dist/testing/rate_limiting.js +41 -10
  137. package/dist/testing/rpc_helpers.d.ts +153 -1
  138. package/dist/testing/rpc_helpers.d.ts.map +1 -1
  139. package/dist/testing/rpc_helpers.js +184 -8
  140. package/dist/testing/sse_round_trip.d.ts +8 -0
  141. package/dist/testing/sse_round_trip.d.ts.map +1 -1
  142. package/dist/testing/sse_round_trip.js +10 -3
  143. package/dist/testing/standard.d.ts +9 -1
  144. package/dist/testing/standard.d.ts.map +1 -1
  145. package/dist/testing/standard.js +6 -2
  146. package/dist/testing/surface_invariants.d.ts +7 -3
  147. package/dist/testing/surface_invariants.d.ts.map +1 -1
  148. package/dist/testing/surface_invariants.js +5 -4
  149. package/dist/testing/ws_round_trip.d.ts.map +1 -1
  150. package/dist/testing/ws_round_trip.js +9 -38
  151. package/dist/ui/AccountSessions.svelte +8 -4
  152. package/dist/ui/AccountSessions.svelte.d.ts.map +1 -1
  153. package/dist/ui/AdminAccounts.svelte +61 -33
  154. package/dist/ui/AdminAccounts.svelte.d.ts.map +1 -1
  155. package/dist/ui/AdminAuditLog.svelte +3 -2
  156. package/dist/ui/AdminAuditLog.svelte.d.ts.map +1 -1
  157. package/dist/ui/AdminInvites.svelte +3 -2
  158. package/dist/ui/AdminInvites.svelte.d.ts.map +1 -1
  159. package/dist/ui/AdminOverview.svelte +14 -9
  160. package/dist/ui/AdminOverview.svelte.d.ts.map +1 -1
  161. package/dist/ui/AdminPermitHistory.svelte +3 -2
  162. package/dist/ui/AdminPermitHistory.svelte.d.ts.map +1 -1
  163. package/dist/ui/AdminSessions.svelte +29 -25
  164. package/dist/ui/AdminSessions.svelte.d.ts.map +1 -1
  165. package/dist/ui/CLAUDE.md +351 -0
  166. package/dist/ui/OpenSignupToggle.svelte +6 -3
  167. package/dist/ui/OpenSignupToggle.svelte.d.ts.map +1 -1
  168. package/dist/ui/PermitOfferForm.svelte +141 -0
  169. package/dist/ui/PermitOfferForm.svelte.d.ts +14 -0
  170. package/dist/ui/PermitOfferForm.svelte.d.ts.map +1 -0
  171. package/dist/ui/PermitOfferHistory.svelte +109 -0
  172. package/dist/ui/PermitOfferHistory.svelte.d.ts +11 -0
  173. package/dist/ui/PermitOfferHistory.svelte.d.ts.map +1 -0
  174. package/dist/ui/PermitOfferInbox.svelte +121 -0
  175. package/dist/ui/PermitOfferInbox.svelte.d.ts +12 -0
  176. package/dist/ui/PermitOfferInbox.svelte.d.ts.map +1 -0
  177. package/dist/ui/account_sessions_state.svelte.d.ts +53 -3
  178. package/dist/ui/account_sessions_state.svelte.d.ts.map +1 -1
  179. package/dist/ui/account_sessions_state.svelte.js +39 -16
  180. package/dist/ui/admin_accounts_state.svelte.d.ts +118 -2
  181. package/dist/ui/admin_accounts_state.svelte.d.ts.map +1 -1
  182. package/dist/ui/admin_accounts_state.svelte.js +99 -23
  183. package/dist/ui/admin_invites_state.svelte.d.ts +47 -1
  184. package/dist/ui/admin_invites_state.svelte.d.ts.map +1 -1
  185. package/dist/ui/admin_invites_state.svelte.js +38 -26
  186. package/dist/ui/admin_sessions_state.svelte.d.ts +26 -0
  187. package/dist/ui/admin_sessions_state.svelte.d.ts.map +1 -1
  188. package/dist/ui/admin_sessions_state.svelte.js +35 -21
  189. package/dist/ui/app_settings_state.svelte.d.ts +39 -0
  190. package/dist/ui/app_settings_state.svelte.d.ts.map +1 -1
  191. package/dist/ui/app_settings_state.svelte.js +34 -18
  192. package/dist/ui/audit_log_state.svelte.d.ts +40 -3
  193. package/dist/ui/audit_log_state.svelte.d.ts.map +1 -1
  194. package/dist/ui/audit_log_state.svelte.js +36 -42
  195. package/dist/ui/auth_state.svelte.d.ts +4 -3
  196. package/dist/ui/auth_state.svelte.d.ts.map +1 -1
  197. package/dist/ui/auth_state.svelte.js +4 -1
  198. package/dist/ui/permit_offers_state.svelte.d.ts +125 -0
  199. package/dist/ui/permit_offers_state.svelte.d.ts.map +1 -0
  200. package/dist/ui/permit_offers_state.svelte.js +197 -0
  201. package/package.json +3 -3
  202. package/dist/auth/admin_routes.d.ts +0 -29
  203. package/dist/auth/admin_routes.d.ts.map +0 -1
  204. package/dist/auth/admin_routes.js +0 -226
  205. package/dist/auth/app_settings_routes.d.ts +0 -27
  206. package/dist/auth/app_settings_routes.d.ts.map +0 -1
  207. package/dist/auth/app_settings_routes.js +0 -66
  208. package/dist/auth/invite_routes.d.ts +0 -18
  209. package/dist/auth/invite_routes.d.ts.map +0 -1
  210. package/dist/auth/invite_routes.js +0 -129
@@ -0,0 +1,216 @@
1
+ /**
2
+ * Account RPC action specs — declarative contract for self-service account
3
+ * operations. Import this module for the specs, Input/Output schemas, and
4
+ * the `all_account_action_specs` registry. Handlers live in
5
+ * `./account_actions.js` so consumers doing typed-client codegen or surface
6
+ * reporting don't transitively drag in server-only query code.
7
+ *
8
+ * @module
9
+ */
10
+ import { z } from 'zod';
11
+ import type { RequestResponseActionSpec } from '../actions/action_spec.js';
12
+ /** Input for `account_verify`. No parameters — the caller is the subject. */
13
+ export declare const VerifyInput: z.ZodNull;
14
+ export type VerifyInput = z.infer<typeof VerifyInput>;
15
+ /** Input for `account_session_list`. No parameters. */
16
+ export declare const SessionListInput: z.ZodNull;
17
+ export type SessionListInput = z.infer<typeof SessionListInput>;
18
+ /** Output for `account_session_list`. */
19
+ export declare const SessionListOutput: z.ZodObject<{
20
+ sessions: z.ZodArray<z.ZodObject<{
21
+ id: z.ZodString;
22
+ account_id: z.core.$ZodBranded<z.ZodUUID, "Uuid", "out">;
23
+ created_at: z.ZodString;
24
+ expires_at: z.ZodString;
25
+ last_seen_at: z.ZodString;
26
+ }, z.core.$strict>>;
27
+ }, z.core.$strict>;
28
+ export type SessionListOutput = z.infer<typeof SessionListOutput>;
29
+ /** Input for `account_session_revoke`. `session_id` is the blake3 hash. */
30
+ export declare const SessionRevokeInput: z.ZodObject<{
31
+ session_id: z.ZodString;
32
+ }, z.core.$strict>;
33
+ export type SessionRevokeInput = z.infer<typeof SessionRevokeInput>;
34
+ /** Output for `account_session_revoke`. `revoked` is `false` for IDOR misses. */
35
+ export declare const SessionRevokeOutput: z.ZodObject<{
36
+ ok: z.ZodLiteral<true>;
37
+ revoked: z.ZodBoolean;
38
+ }, z.core.$strict>;
39
+ export type SessionRevokeOutput = z.infer<typeof SessionRevokeOutput>;
40
+ /** Input for `account_session_revoke_all`. No parameters. */
41
+ export declare const SessionRevokeAllInput: z.ZodNull;
42
+ export type SessionRevokeAllInput = z.infer<typeof SessionRevokeAllInput>;
43
+ /** Output for `account_session_revoke_all`. */
44
+ export declare const SessionRevokeAllOutput: z.ZodObject<{
45
+ ok: z.ZodLiteral<true>;
46
+ count: z.ZodNumber;
47
+ }, z.core.$strict>;
48
+ export type SessionRevokeAllOutput = z.infer<typeof SessionRevokeAllOutput>;
49
+ /** Input for `account_token_create`. */
50
+ export declare const TokenCreateInput: z.ZodObject<{
51
+ name: z.ZodDefault<z.ZodString>;
52
+ }, z.core.$strict>;
53
+ export type TokenCreateInput = z.infer<typeof TokenCreateInput>;
54
+ /** Output for `account_token_create`. `token` is returned exactly once. */
55
+ export declare const TokenCreateOutput: z.ZodObject<{
56
+ ok: z.ZodLiteral<true>;
57
+ token: z.ZodString;
58
+ id: z.ZodString;
59
+ name: z.ZodString;
60
+ }, z.core.$strict>;
61
+ export type TokenCreateOutput = z.infer<typeof TokenCreateOutput>;
62
+ /** Input for `account_token_list`. No parameters. */
63
+ export declare const TokenListInput: z.ZodNull;
64
+ export type TokenListInput = z.infer<typeof TokenListInput>;
65
+ /** Output for `account_token_list`. Hashes are excluded. */
66
+ export declare const TokenListOutput: z.ZodObject<{
67
+ tokens: z.ZodArray<z.ZodObject<{
68
+ id: z.ZodString;
69
+ account_id: z.core.$ZodBranded<z.ZodUUID, "Uuid", "out">;
70
+ name: z.ZodString;
71
+ expires_at: z.ZodNullable<z.ZodString>;
72
+ last_used_at: z.ZodNullable<z.ZodString>;
73
+ last_used_ip: z.ZodNullable<z.ZodString>;
74
+ created_at: z.ZodString;
75
+ }, z.core.$strict>>;
76
+ }, z.core.$strict>;
77
+ export type TokenListOutput = z.infer<typeof TokenListOutput>;
78
+ /** Input for `account_token_revoke`. */
79
+ export declare const TokenRevokeInput: z.ZodObject<{
80
+ token_id: z.ZodString;
81
+ }, z.core.$strict>;
82
+ export type TokenRevokeInput = z.infer<typeof TokenRevokeInput>;
83
+ /** Output for `account_token_revoke`. `revoked` is `false` for IDOR misses. */
84
+ export declare const TokenRevokeOutput: z.ZodObject<{
85
+ ok: z.ZodLiteral<true>;
86
+ revoked: z.ZodBoolean;
87
+ }, z.core.$strict>;
88
+ export type TokenRevokeOutput = z.infer<typeof TokenRevokeOutput>;
89
+ export declare const account_verify_action_spec: {
90
+ method: string;
91
+ kind: "request_response";
92
+ initiator: "frontend";
93
+ auth: "authenticated";
94
+ side_effects: false;
95
+ input: z.ZodNull;
96
+ output: z.ZodObject<{
97
+ id: z.core.$ZodBranded<z.ZodUUID, "Uuid", "out">;
98
+ username: z.ZodString;
99
+ email: z.ZodNullable<z.ZodEmail>;
100
+ email_verified: z.ZodBoolean;
101
+ created_at: z.ZodString;
102
+ }, z.core.$strict>;
103
+ async: true;
104
+ description: string;
105
+ };
106
+ export declare const account_session_list_action_spec: {
107
+ method: string;
108
+ kind: "request_response";
109
+ initiator: "frontend";
110
+ auth: "authenticated";
111
+ side_effects: false;
112
+ input: z.ZodNull;
113
+ output: z.ZodObject<{
114
+ sessions: z.ZodArray<z.ZodObject<{
115
+ id: z.ZodString;
116
+ account_id: z.core.$ZodBranded<z.ZodUUID, "Uuid", "out">;
117
+ created_at: z.ZodString;
118
+ expires_at: z.ZodString;
119
+ last_seen_at: z.ZodString;
120
+ }, z.core.$strict>>;
121
+ }, z.core.$strict>;
122
+ async: true;
123
+ description: string;
124
+ };
125
+ export declare const account_session_revoke_action_spec: {
126
+ method: string;
127
+ kind: "request_response";
128
+ initiator: "frontend";
129
+ auth: "authenticated";
130
+ side_effects: true;
131
+ input: z.ZodObject<{
132
+ session_id: z.ZodString;
133
+ }, z.core.$strict>;
134
+ output: z.ZodObject<{
135
+ ok: z.ZodLiteral<true>;
136
+ revoked: z.ZodBoolean;
137
+ }, z.core.$strict>;
138
+ async: true;
139
+ description: string;
140
+ };
141
+ export declare const account_session_revoke_all_action_spec: {
142
+ method: string;
143
+ kind: "request_response";
144
+ initiator: "frontend";
145
+ auth: "authenticated";
146
+ side_effects: true;
147
+ input: z.ZodNull;
148
+ output: z.ZodObject<{
149
+ ok: z.ZodLiteral<true>;
150
+ count: z.ZodNumber;
151
+ }, z.core.$strict>;
152
+ async: true;
153
+ description: string;
154
+ };
155
+ export declare const account_token_create_action_spec: {
156
+ method: string;
157
+ kind: "request_response";
158
+ initiator: "frontend";
159
+ auth: "authenticated";
160
+ side_effects: true;
161
+ input: z.ZodObject<{
162
+ name: z.ZodDefault<z.ZodString>;
163
+ }, z.core.$strict>;
164
+ output: z.ZodObject<{
165
+ ok: z.ZodLiteral<true>;
166
+ token: z.ZodString;
167
+ id: z.ZodString;
168
+ name: z.ZodString;
169
+ }, z.core.$strict>;
170
+ async: true;
171
+ description: string;
172
+ };
173
+ export declare const account_token_list_action_spec: {
174
+ method: string;
175
+ kind: "request_response";
176
+ initiator: "frontend";
177
+ auth: "authenticated";
178
+ side_effects: false;
179
+ input: z.ZodNull;
180
+ output: z.ZodObject<{
181
+ tokens: z.ZodArray<z.ZodObject<{
182
+ id: z.ZodString;
183
+ account_id: z.core.$ZodBranded<z.ZodUUID, "Uuid", "out">;
184
+ name: z.ZodString;
185
+ expires_at: z.ZodNullable<z.ZodString>;
186
+ last_used_at: z.ZodNullable<z.ZodString>;
187
+ last_used_ip: z.ZodNullable<z.ZodString>;
188
+ created_at: z.ZodString;
189
+ }, z.core.$strict>>;
190
+ }, z.core.$strict>;
191
+ async: true;
192
+ description: string;
193
+ };
194
+ export declare const account_token_revoke_action_spec: {
195
+ method: string;
196
+ kind: "request_response";
197
+ initiator: "frontend";
198
+ auth: "authenticated";
199
+ side_effects: true;
200
+ input: z.ZodObject<{
201
+ token_id: z.ZodString;
202
+ }, z.core.$strict>;
203
+ output: z.ZodObject<{
204
+ ok: z.ZodLiteral<true>;
205
+ revoked: z.ZodBoolean;
206
+ }, z.core.$strict>;
207
+ async: true;
208
+ description: string;
209
+ };
210
+ /**
211
+ * All self-service account action specs — a codegen-ready registry.
212
+ * Consumers spread this into their own action-spec array to include
213
+ * account methods in a typed client surface.
214
+ */
215
+ export declare const all_account_action_specs: Array<RequestResponseActionSpec>;
216
+ //# sourceMappingURL=account_action_specs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account_action_specs.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/account_action_specs.ts"],"names":[],"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/**
2
+ * Account RPC action specs — declarative contract for self-service account
3
+ * operations. Import this module for the specs, Input/Output schemas, and
4
+ * the `all_account_action_specs` registry. Handlers live in
5
+ * `./account_actions.js` so consumers doing typed-client codegen or surface
6
+ * reporting don't transitively drag in server-only query code.
7
+ *
8
+ * @module
9
+ */
10
+ import { z } from 'zod';
11
+ import { Blake3Hash } from '@fuzdev/fuz_util/hash_blake3.js';
12
+ import { AuthSessionJson, ClientApiTokenJson, SessionAccountJson } from './account_schema.js';
13
+ import { ApiTokenId } from './api_token.js';
14
+ // -- Input/output schemas ---------------------------------------------------
15
+ /** Input for `account_verify`. No parameters — the caller is the subject. */
16
+ export const VerifyInput = z.null();
17
+ /** Input for `account_session_list`. No parameters. */
18
+ export const SessionListInput = z.null();
19
+ /** Output for `account_session_list`. */
20
+ export const SessionListOutput = z.strictObject({
21
+ sessions: z.array(AuthSessionJson),
22
+ });
23
+ /** Input for `account_session_revoke`. `session_id` is the blake3 hash. */
24
+ export const SessionRevokeInput = z.strictObject({
25
+ session_id: Blake3Hash.meta({ description: 'Session id (blake3 hash) to revoke.' }),
26
+ });
27
+ /** Output for `account_session_revoke`. `revoked` is `false` for IDOR misses. */
28
+ export const SessionRevokeOutput = z.strictObject({
29
+ ok: z.literal(true),
30
+ revoked: z.boolean(),
31
+ });
32
+ /** Input for `account_session_revoke_all`. No parameters. */
33
+ export const SessionRevokeAllInput = z.null();
34
+ /** Output for `account_session_revoke_all`. */
35
+ export const SessionRevokeAllOutput = z.strictObject({
36
+ ok: z.literal(true),
37
+ count: z.number(),
38
+ });
39
+ /** Input for `account_token_create`. */
40
+ export const TokenCreateInput = z.strictObject({
41
+ name: z
42
+ .string()
43
+ .default('CLI token')
44
+ .meta({ description: 'Human-friendly label; shown in the token list.' }),
45
+ });
46
+ /** Output for `account_token_create`. `token` is returned exactly once. */
47
+ export const TokenCreateOutput = z.strictObject({
48
+ ok: z.literal(true),
49
+ token: z.string().meta({ description: 'Raw token — shown once, store securely.' }),
50
+ id: ApiTokenId,
51
+ name: z.string(),
52
+ });
53
+ /** Input for `account_token_list`. No parameters. */
54
+ export const TokenListInput = z.null();
55
+ /** Output for `account_token_list`. Hashes are excluded. */
56
+ export const TokenListOutput = z.strictObject({
57
+ tokens: z.array(ClientApiTokenJson),
58
+ });
59
+ /** Input for `account_token_revoke`. */
60
+ export const TokenRevokeInput = z.strictObject({
61
+ token_id: ApiTokenId.meta({ description: 'Public API token id (e.g. `tok_<12 chars>`).' }),
62
+ });
63
+ /** Output for `account_token_revoke`. `revoked` is `false` for IDOR misses. */
64
+ export const TokenRevokeOutput = z.strictObject({
65
+ ok: z.literal(true),
66
+ revoked: z.boolean(),
67
+ });
68
+ // -- Action specs -----------------------------------------------------------
69
+ export const account_verify_action_spec = {
70
+ method: 'account_verify',
71
+ kind: 'request_response',
72
+ initiator: 'frontend',
73
+ auth: 'authenticated',
74
+ side_effects: false,
75
+ input: VerifyInput,
76
+ output: SessionAccountJson,
77
+ async: true,
78
+ description: 'Verify the current session and echo the caller account.',
79
+ };
80
+ export const account_session_list_action_spec = {
81
+ method: 'account_session_list',
82
+ kind: 'request_response',
83
+ initiator: 'frontend',
84
+ auth: 'authenticated',
85
+ side_effects: false,
86
+ input: SessionListInput,
87
+ output: SessionListOutput,
88
+ async: true,
89
+ description: 'List auth sessions for the current account.',
90
+ };
91
+ export const account_session_revoke_action_spec = {
92
+ method: 'account_session_revoke',
93
+ kind: 'request_response',
94
+ initiator: 'frontend',
95
+ auth: 'authenticated',
96
+ side_effects: true,
97
+ input: SessionRevokeInput,
98
+ output: SessionRevokeOutput,
99
+ async: true,
100
+ description: 'Revoke a single auth session for the current account (IDOR-guarded).',
101
+ };
102
+ export const account_session_revoke_all_action_spec = {
103
+ method: 'account_session_revoke_all',
104
+ kind: 'request_response',
105
+ initiator: 'frontend',
106
+ auth: 'authenticated',
107
+ side_effects: true,
108
+ input: SessionRevokeAllInput,
109
+ output: SessionRevokeAllOutput,
110
+ async: true,
111
+ description: 'Revoke every auth session for the current account.',
112
+ };
113
+ export const account_token_create_action_spec = {
114
+ method: 'account_token_create',
115
+ kind: 'request_response',
116
+ initiator: 'frontend',
117
+ auth: 'authenticated',
118
+ side_effects: true,
119
+ input: TokenCreateInput,
120
+ output: TokenCreateOutput,
121
+ async: true,
122
+ description: 'Create an API token for the current account. Raw token is returned once.',
123
+ };
124
+ export const account_token_list_action_spec = {
125
+ method: 'account_token_list',
126
+ kind: 'request_response',
127
+ initiator: 'frontend',
128
+ auth: 'authenticated',
129
+ side_effects: false,
130
+ input: TokenListInput,
131
+ output: TokenListOutput,
132
+ async: true,
133
+ description: 'List API tokens for the current account. Hashes are never returned.',
134
+ };
135
+ export const account_token_revoke_action_spec = {
136
+ method: 'account_token_revoke',
137
+ kind: 'request_response',
138
+ initiator: 'frontend',
139
+ auth: 'authenticated',
140
+ side_effects: true,
141
+ input: TokenRevokeInput,
142
+ output: TokenRevokeOutput,
143
+ async: true,
144
+ description: 'Revoke an API token for the current account (IDOR-guarded).',
145
+ };
146
+ /**
147
+ * All self-service account action specs — a codegen-ready registry.
148
+ * Consumers spread this into their own action-spec array to include
149
+ * account methods in a typed client surface.
150
+ */
151
+ export const all_account_action_specs = [
152
+ account_verify_action_spec,
153
+ account_session_list_action_spec,
154
+ account_session_revoke_action_spec,
155
+ account_session_revoke_all_action_spec,
156
+ account_token_create_action_spec,
157
+ account_token_list_action_spec,
158
+ account_token_revoke_action_spec,
159
+ ];
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Account RPC action handlers — self-service operations for the authenticated
3
+ * account.
4
+ *
5
+ * Seven `request_response` actions bound to handlers:
6
+ *
7
+ * - Session reads: `account_verify`, `account_session_list`.
8
+ * - Session mutations: `account_session_revoke`, `account_session_revoke_all`.
9
+ * - API token management: `account_token_create`, `account_token_list`,
10
+ * `account_token_revoke`.
11
+ *
12
+ * The action specs themselves live in `./account_action_specs.js`. Every spec
13
+ * declares `auth: 'authenticated'` so the dispatcher enforces auth before the
14
+ * handler runs. Revoke operations are account-scoped (via
15
+ * `query_session_revoke_for_account` / `query_revoke_api_token_for_account`)
16
+ * so passing another account's session or token id returns `revoked: false`
17
+ * rather than revealing whether the id exists.
18
+ *
19
+ * Counterpart to `account_routes.ts`, which keeps the cookie-lifecycle flows
20
+ * (`login`, `logout`, `password`, `signup`, `bootstrap`) on REST.
21
+ *
22
+ * @module
23
+ */
24
+ import { type RpcAction } from '../actions/action_rpc.js';
25
+ import type { RouteFactoryDeps } from './deps.js';
26
+ /** Options for `create_account_actions`. */
27
+ export interface AccountActionOptions {
28
+ /**
29
+ * Max API tokens per account. When set, `account_token_create` enforces the
30
+ * cap via `query_api_token_enforce_limit` inside the same transaction —
31
+ * oldest tokens are evicted once the cap is exceeded. Default
32
+ * `DEFAULT_MAX_TOKENS`; pass `null` to disable the cap.
33
+ */
34
+ max_tokens?: number | null;
35
+ }
36
+ /**
37
+ * Dependencies for `create_account_actions`.
38
+ *
39
+ * Shares shape with `AdminActionDeps` / `PermitOfferActionDeps` so consumers
40
+ * can pass the same deps to every action factory.
41
+ */
42
+ export type AccountActionDeps = Pick<RouteFactoryDeps, 'log' | 'on_audit_event'>;
43
+ /**
44
+ * Create the self-service account RPC actions.
45
+ *
46
+ * @param deps - stateless capabilities (log, on_audit_event)
47
+ * @param options - per-factory configuration
48
+ * @returns the `RpcAction` array to spread into a `create_rpc_endpoint` call
49
+ */
50
+ export declare const create_account_actions: (deps: AccountActionDeps, options?: AccountActionOptions) => Array<RpcAction>;
51
+ //# sourceMappingURL=account_actions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account_actions.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/account_actions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAiC,KAAK,SAAS,EAAC,MAAM,0BAA0B,CAAC;AAgBxF,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,WAAW,CAAC;AAwBhD,4CAA4C;AAC5C,MAAM,WAAW,oBAAoB;IACpC;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,gBAAgB,EAAE,KAAK,GAAG,gBAAgB,CAAC,CAAC;AAEjF;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,GAClC,MAAM,iBAAiB,EACvB,UAAS,oBAAyB,KAChC,KAAK,CAAC,SAAS,CA8HjB,CAAC"}
@@ -0,0 +1,119 @@
1
+ /**
2
+ * Account RPC action handlers — self-service operations for the authenticated
3
+ * account.
4
+ *
5
+ * Seven `request_response` actions bound to handlers:
6
+ *
7
+ * - Session reads: `account_verify`, `account_session_list`.
8
+ * - Session mutations: `account_session_revoke`, `account_session_revoke_all`.
9
+ * - API token management: `account_token_create`, `account_token_list`,
10
+ * `account_token_revoke`.
11
+ *
12
+ * The action specs themselves live in `./account_action_specs.js`. Every spec
13
+ * declares `auth: 'authenticated'` so the dispatcher enforces auth before the
14
+ * handler runs. Revoke operations are account-scoped (via
15
+ * `query_session_revoke_for_account` / `query_revoke_api_token_for_account`)
16
+ * so passing another account's session or token id returns `revoked: false`
17
+ * rather than revealing whether the id exists.
18
+ *
19
+ * Counterpart to `account_routes.ts`, which keeps the cookie-lifecycle flows
20
+ * (`login`, `logout`, `password`, `signup`, `bootstrap`) on REST.
21
+ *
22
+ * @module
23
+ */
24
+ import { rpc_action } from '../actions/action_rpc.js';
25
+ import { to_session_account } from './account_schema.js';
26
+ import { query_session_list_for_account, query_session_revoke_for_account, query_session_revoke_all_for_account, } from './session_queries.js';
27
+ import { query_api_token_enforce_limit, query_api_token_list_for_account, query_create_api_token, query_revoke_api_token_for_account, } from './api_token_queries.js';
28
+ import { generate_api_token } from './api_token.js';
29
+ import { audit_log_fire_and_forget } from './audit_log_queries.js';
30
+ import { DEFAULT_MAX_TOKENS } from './account_routes.js';
31
+ import { account_verify_action_spec, account_session_list_action_spec, account_session_revoke_action_spec, account_session_revoke_all_action_spec, account_token_create_action_spec, account_token_list_action_spec, account_token_revoke_action_spec, } from './account_action_specs.js';
32
+ /**
33
+ * Create the self-service account RPC actions.
34
+ *
35
+ * @param deps - stateless capabilities (log, on_audit_event)
36
+ * @param options - per-factory configuration
37
+ * @returns the `RpcAction` array to spread into a `create_rpc_endpoint` call
38
+ */
39
+ export const create_account_actions = (deps, options = {}) => {
40
+ const { log, on_audit_event } = deps;
41
+ const { max_tokens = DEFAULT_MAX_TOKENS } = options;
42
+ const verify_handler = (_input, ctx) => {
43
+ const auth = ctx.auth;
44
+ return to_session_account(auth.account);
45
+ };
46
+ const session_list_handler = async (_input, ctx) => {
47
+ const auth = ctx.auth;
48
+ const sessions = await query_session_list_for_account(ctx, auth.account.id);
49
+ return { sessions };
50
+ };
51
+ const session_revoke_handler = async (input, ctx) => {
52
+ const auth = ctx.auth;
53
+ const revoked = await query_session_revoke_for_account(ctx, input.session_id, auth.account.id);
54
+ void audit_log_fire_and_forget(ctx, {
55
+ event_type: 'session_revoke',
56
+ outcome: revoked ? 'success' : 'failure',
57
+ actor_id: auth.actor.id,
58
+ account_id: auth.account.id,
59
+ ip: ctx.client_ip,
60
+ metadata: { session_id: input.session_id },
61
+ }, log, on_audit_event);
62
+ return { ok: true, revoked };
63
+ };
64
+ const session_revoke_all_handler = async (_input, ctx) => {
65
+ const auth = ctx.auth;
66
+ const count = await query_session_revoke_all_for_account(ctx, auth.account.id);
67
+ void audit_log_fire_and_forget(ctx, {
68
+ event_type: 'session_revoke_all',
69
+ actor_id: auth.actor.id,
70
+ account_id: auth.account.id,
71
+ ip: ctx.client_ip,
72
+ metadata: { count },
73
+ }, log, on_audit_event);
74
+ return { ok: true, count };
75
+ };
76
+ const token_create_handler = async (input, ctx) => {
77
+ const auth = ctx.auth;
78
+ const { token, id, token_hash } = generate_api_token();
79
+ await query_create_api_token(ctx, id, auth.account.id, input.name, token_hash);
80
+ if (max_tokens != null) {
81
+ await query_api_token_enforce_limit(ctx, auth.account.id, max_tokens);
82
+ }
83
+ void audit_log_fire_and_forget(ctx, {
84
+ event_type: 'token_create',
85
+ actor_id: auth.actor.id,
86
+ account_id: auth.account.id,
87
+ ip: ctx.client_ip,
88
+ metadata: { token_id: id, name: input.name },
89
+ }, log, on_audit_event);
90
+ return { ok: true, token, id, name: input.name };
91
+ };
92
+ const token_list_handler = async (_input, ctx) => {
93
+ const auth = ctx.auth;
94
+ const tokens = await query_api_token_list_for_account(ctx, auth.account.id);
95
+ return { tokens };
96
+ };
97
+ const token_revoke_handler = async (input, ctx) => {
98
+ const auth = ctx.auth;
99
+ const revoked = await query_revoke_api_token_for_account(ctx, input.token_id, auth.account.id);
100
+ void audit_log_fire_and_forget(ctx, {
101
+ event_type: 'token_revoke',
102
+ outcome: revoked ? 'success' : 'failure',
103
+ actor_id: auth.actor.id,
104
+ account_id: auth.account.id,
105
+ ip: ctx.client_ip,
106
+ metadata: { token_id: input.token_id },
107
+ }, log, on_audit_event);
108
+ return { ok: true, revoked };
109
+ };
110
+ return [
111
+ rpc_action(account_verify_action_spec, verify_handler),
112
+ rpc_action(account_session_list_action_spec, session_list_handler),
113
+ rpc_action(account_session_revoke_action_spec, session_revoke_handler),
114
+ rpc_action(account_session_revoke_all_action_spec, session_revoke_all_handler),
115
+ rpc_action(account_token_create_action_spec, token_create_handler),
116
+ rpc_action(account_token_list_action_spec, token_list_handler),
117
+ rpc_action(account_token_revoke_action_spec, token_revoke_handler),
118
+ ];
119
+ };
@@ -85,9 +85,13 @@ export declare const query_create_account_with_actor: (deps: QueryDeps, input: C
85
85
  actor: Actor;
86
86
  }>;
87
87
  /**
88
- * List all accounts with their actors and active permits for admin display.
88
+ * List all accounts with their actors, active permits, and pending inbound
89
+ * permit offers for admin display.
89
90
  *
90
- * Uses 3 flat queries instead of N+1 per-account loops.
91
+ * Uses 4 flat queries instead of N+1 per-account loops. Pending offers surface
92
+ * the "offer pending — awaiting acceptance" UX without a second round-trip;
93
+ * `message` is intentionally excluded (cross-admin visibility of grantor notes
94
+ * would expand beyond what the audit log discloses).
91
95
  *
92
96
  * @param deps - query dependencies
93
97
  * @returns admin account entries sorted by creation date
@@ -1 +1 @@
1
- {"version":3,"file":"account_queries.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/account_queries.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EAEN,KAAK,OAAO,EACZ,KAAK,KAAK,EACV,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAC1B,MAAM,qBAAqB,CAAC;AAE7B;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,GAChC,MAAM,SAAS,EACf,OAAO,kBAAkB,KACvB,OAAO,CAAC,OAAO,CAQjB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB,GAC/B,MAAM,SAAS,EACf,IAAI,MAAM,KACR,OAAO,CAAC,OAAO,GAAG,SAAS,CAE7B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,yBAAyB,GACrC,MAAM,SAAS,EACf,UAAU,MAAM,KACd,OAAO,CAAC,OAAO,GAAG,SAAS,CAI7B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,sBAAsB,GAClC,MAAM,SAAS,EACf,OAAO,MAAM,KACX,OAAO,CAAC,OAAO,GAAG,SAAS,CAI7B,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,kCAAkC,GAC9C,MAAM,SAAS,EACf,OAAO,MAAM,KACX,OAAO,CAAC,OAAO,GAAG,SAAS,CAS7B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,6BAA6B,GACzC,MAAM,SAAS,EACf,IAAI,MAAM,EACV,eAAe,MAAM,EACrB,YAAY,MAAM,GAAG,IAAI,KACvB,OAAO,CAAC,IAAI,CAKd,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,oBAAoB,GAAU,MAAM,SAAS,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AE3B,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,+BAA+B,GAC3C,MAAM,SAAS,EACf,OAAO,kBAAkB,KACvB,OAAO,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAC,CAI1C,CAAC;AAyBF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,wBAAwB,GACpC,MAAM,SAAS,KACb,OAAO,CAAC,KAAK,CAAC,qBAAqB,CAAC,CA+EtC,CAAC"}
@@ -123,21 +123,36 @@ export const query_create_account_with_actor = async (deps, input) => {
123
123
  return { account, actor };
124
124
  };
125
125
  /**
126
- * List all accounts with their actors and active permits for admin display.
126
+ * List all accounts with their actors, active permits, and pending inbound
127
+ * permit offers for admin display.
127
128
  *
128
- * Uses 3 flat queries instead of N+1 per-account loops.
129
+ * Uses 4 flat queries instead of N+1 per-account loops. Pending offers surface
130
+ * the "offer pending — awaiting acceptance" UX without a second round-trip;
131
+ * `message` is intentionally excluded (cross-admin visibility of grantor notes
132
+ * would expand beyond what the audit log discloses).
129
133
  *
130
134
  * @param deps - query dependencies
131
135
  * @returns admin account entries sorted by creation date
132
136
  */
133
137
  export const query_admin_account_list = async (deps) => {
134
- const [accounts, actors, permits] = await Promise.all([
138
+ const [accounts, actors, permits, pending_offers] = await Promise.all([
135
139
  deps.db.query(`SELECT * FROM account ORDER BY created_at`),
136
140
  deps.db.query(`SELECT * FROM actor`),
137
- deps.db.query(`SELECT id, actor_id, role, created_at, expires_at, granted_by
141
+ deps.db.query(`SELECT id, actor_id, role, scope_id, created_at, expires_at, granted_by
138
142
  FROM permit
139
143
  WHERE revoked_at IS NULL
140
144
  AND (expires_at IS NULL OR expires_at > NOW())`),
145
+ deps.db.query(`SELECT po.id, po.to_account_id, po.from_actor_id, po.role, po.scope_id,
146
+ po.created_at, po.expires_at, a.username AS from_username
147
+ FROM permit_offer po
148
+ JOIN actor act ON act.id = po.from_actor_id
149
+ JOIN account a ON a.id = act.account_id
150
+ WHERE po.accepted_at IS NULL
151
+ AND po.declined_at IS NULL
152
+ AND po.retracted_at IS NULL
153
+ AND po.superseded_at IS NULL
154
+ AND po.expires_at > NOW()
155
+ ORDER BY po.expires_at ASC`),
141
156
  ]);
142
157
  // Index actors by account_id (1:1 in v1)
143
158
  const actor_by_account = new Map();
@@ -154,19 +169,40 @@ export const query_admin_account_list = async (deps) => {
154
169
  }
155
170
  list.push(permit);
156
171
  }
172
+ // Group pending offers by recipient account_id
173
+ const offers_by_account = new Map();
174
+ for (const offer of pending_offers) {
175
+ let list = offers_by_account.get(offer.to_account_id);
176
+ if (!list) {
177
+ list = [];
178
+ offers_by_account.set(offer.to_account_id, list);
179
+ }
180
+ list.push(offer);
181
+ }
157
182
  return accounts.map((account) => {
158
183
  const actor = actor_by_account.get(account.id);
159
184
  const actor_permits = actor ? (permits_by_actor.get(actor.id) ?? []) : [];
185
+ const account_offers = offers_by_account.get(account.id) ?? [];
160
186
  return {
161
187
  account: to_admin_account(account),
162
188
  actor: actor ? { id: actor.id, name: actor.name } : null,
163
189
  permits: actor_permits.map((p) => ({
164
190
  id: p.id,
165
191
  role: p.role,
192
+ scope_id: p.scope_id,
166
193
  created_at: p.created_at,
167
194
  expires_at: p.expires_at,
168
195
  granted_by: p.granted_by,
169
196
  })),
197
+ pending_offers: account_offers.map((o) => ({
198
+ id: o.id,
199
+ role: o.role,
200
+ scope_id: o.scope_id,
201
+ from_actor_id: o.from_actor_id,
202
+ from_username: o.from_username,
203
+ created_at: o.created_at,
204
+ expires_at: o.expires_at,
205
+ })),
170
206
  };
171
207
  });
172
208
  };