@robelest/convex-auth 0.0.4-preview.22 → 0.0.4-preview.24

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 (314) hide show
  1. package/README.md +10 -11
  2. package/dist/authorization/index.d.ts +1 -1
  3. package/dist/authorization/index.js +1 -1
  4. package/dist/authorization/index.js.map +1 -1
  5. package/dist/client/index.d.ts +1 -2
  6. package/dist/client/index.d.ts.map +1 -1
  7. package/dist/client/index.js +36 -39
  8. package/dist/client/index.js.map +1 -1
  9. package/dist/component/client/index.d.ts +1 -2
  10. package/dist/component/index.js +2 -2
  11. package/dist/component/model.d.ts +9 -9
  12. package/dist/component/model.d.ts.map +1 -1
  13. package/dist/component/public/enterprise/audit.d.ts.map +1 -1
  14. package/dist/component/public/enterprise/audit.js.map +1 -1
  15. package/dist/component/public/enterprise/core.d.ts.map +1 -1
  16. package/dist/component/public/enterprise/core.js.map +1 -1
  17. package/dist/component/public/enterprise/domains.d.ts.map +1 -1
  18. package/dist/component/public/enterprise/domains.js.map +1 -1
  19. package/dist/component/public/enterprise/scim.d.ts.map +1 -1
  20. package/dist/component/public/enterprise/scim.js.map +1 -1
  21. package/dist/component/public/enterprise/secrets.d.ts.map +1 -1
  22. package/dist/component/public/enterprise/secrets.js.map +1 -1
  23. package/dist/component/public/enterprise/webhooks.d.ts.map +1 -1
  24. package/dist/component/public/enterprise/webhooks.js.map +1 -1
  25. package/dist/component/public/factors/devices.d.ts.map +1 -1
  26. package/dist/component/public/factors/devices.js.map +1 -1
  27. package/dist/component/public/factors/passkeys.d.ts.map +1 -1
  28. package/dist/component/public/factors/passkeys.js.map +1 -1
  29. package/dist/component/public/factors/totp.d.ts.map +1 -1
  30. package/dist/component/public/factors/totp.js.map +1 -1
  31. package/dist/component/public/groups/core.js.map +1 -1
  32. package/dist/component/public/groups/invites.d.ts.map +1 -1
  33. package/dist/component/public/groups/invites.js.map +1 -1
  34. package/dist/component/public/groups/members.d.ts.map +1 -1
  35. package/dist/component/public/groups/members.js.map +1 -1
  36. package/dist/component/public/identity/accounts.d.ts.map +1 -1
  37. package/dist/component/public/identity/accounts.js.map +1 -1
  38. package/dist/component/public/identity/codes.d.ts.map +1 -1
  39. package/dist/component/public/identity/codes.js.map +1 -1
  40. package/dist/component/public/identity/sessions.d.ts.map +1 -1
  41. package/dist/component/public/identity/sessions.js.map +1 -1
  42. package/dist/component/public/identity/tokens.d.ts.map +1 -1
  43. package/dist/component/public/identity/tokens.js.map +1 -1
  44. package/dist/component/public/identity/users.d.ts.map +1 -1
  45. package/dist/component/public/identity/users.js.map +1 -1
  46. package/dist/component/public/identity/verifiers.d.ts.map +1 -1
  47. package/dist/component/public/identity/verifiers.js.map +1 -1
  48. package/dist/component/public/security/keys.d.ts.map +1 -1
  49. package/dist/component/public/security/keys.js.map +1 -1
  50. package/dist/component/public/security/limits.d.ts.map +1 -1
  51. package/dist/component/public/security/limits.js.map +1 -1
  52. package/dist/component/schema.d.ts +41 -41
  53. package/dist/component/server/auth.d.ts +127 -130
  54. package/dist/component/server/auth.d.ts.map +1 -1
  55. package/dist/component/server/auth.js +100 -64
  56. package/dist/component/server/auth.js.map +1 -1
  57. package/dist/component/server/context.js +53 -0
  58. package/dist/component/server/context.js.map +1 -0
  59. package/dist/component/server/core.js +113 -250
  60. package/dist/component/server/core.js.map +1 -1
  61. package/dist/component/server/crypto.js +25 -7
  62. package/dist/component/server/crypto.js.map +1 -1
  63. package/dist/component/server/device.js +59 -16
  64. package/dist/component/server/device.js.map +1 -1
  65. package/dist/component/server/enterprise/domain.js +148 -59
  66. package/dist/component/server/enterprise/domain.js.map +1 -1
  67. package/dist/component/server/enterprise/http.js +36 -15
  68. package/dist/component/server/enterprise/http.js.map +1 -1
  69. package/dist/component/server/enterprise/oidc.js +1 -1
  70. package/dist/component/server/http.d.ts +85 -0
  71. package/dist/component/server/http.d.ts.map +1 -0
  72. package/dist/component/server/http.js +85 -22
  73. package/dist/component/server/http.js.map +1 -1
  74. package/dist/component/server/identity.js +5 -2
  75. package/dist/component/server/identity.js.map +1 -1
  76. package/dist/component/server/limits.js +21 -30
  77. package/dist/component/server/limits.js.map +1 -1
  78. package/dist/component/server/mutations/account.js +12 -10
  79. package/dist/component/server/mutations/account.js.map +1 -1
  80. package/dist/component/server/mutations/code.js +5 -2
  81. package/dist/component/server/mutations/code.js.map +1 -1
  82. package/dist/component/server/mutations/invalidate.js +1 -1
  83. package/dist/component/server/mutations/invalidate.js.map +1 -1
  84. package/dist/component/server/mutations/oauth.js +10 -4
  85. package/dist/component/server/mutations/oauth.js.map +1 -1
  86. package/dist/component/server/mutations/refresh.js +2 -2
  87. package/dist/component/server/mutations/refresh.js.map +1 -1
  88. package/dist/component/server/mutations/register.js +46 -42
  89. package/dist/component/server/mutations/register.js.map +1 -1
  90. package/dist/component/server/mutations/retrieve.js +21 -25
  91. package/dist/component/server/mutations/retrieve.js.map +1 -1
  92. package/dist/component/server/mutations/signature.js +10 -4
  93. package/dist/component/server/mutations/signature.js.map +1 -1
  94. package/dist/component/server/mutations/signout.js.map +1 -1
  95. package/dist/component/server/mutations/store.js +9 -24
  96. package/dist/component/server/mutations/store.js.map +1 -1
  97. package/dist/component/server/mutations/verifier.js.map +1 -1
  98. package/dist/component/server/mutations/verify.js +1 -1
  99. package/dist/component/server/mutations/verify.js.map +1 -1
  100. package/dist/component/server/oauth.js +53 -16
  101. package/dist/component/server/oauth.js.map +1 -1
  102. package/dist/component/server/passkey.js +115 -31
  103. package/dist/component/server/passkey.js.map +1 -1
  104. package/dist/component/server/redirects.js +9 -3
  105. package/dist/component/server/redirects.js.map +1 -1
  106. package/dist/component/server/refresh.js +10 -7
  107. package/dist/component/server/refresh.js.map +1 -1
  108. package/dist/component/server/runtime.d.ts +5 -5
  109. package/dist/component/server/runtime.js +156 -113
  110. package/dist/component/server/runtime.js.map +1 -1
  111. package/dist/component/server/signin.js +34 -10
  112. package/dist/component/server/signin.js.map +1 -1
  113. package/dist/component/server/totp.js +79 -19
  114. package/dist/component/server/totp.js.map +1 -1
  115. package/dist/component/server/types.d.ts +12 -20
  116. package/dist/component/server/types.d.ts.map +1 -1
  117. package/dist/component/server/types.js.map +1 -1
  118. package/dist/component/server/users.js +6 -3
  119. package/dist/component/server/users.js.map +1 -1
  120. package/dist/component/server/utils.js +10 -4
  121. package/dist/component/server/utils.js.map +1 -1
  122. package/dist/core/types.d.ts +14 -22
  123. package/dist/core/types.d.ts.map +1 -1
  124. package/dist/factors/device.js +8 -9
  125. package/dist/factors/device.js.map +1 -1
  126. package/dist/factors/passkey.js +18 -21
  127. package/dist/factors/passkey.js.map +1 -1
  128. package/dist/providers/password.js +66 -81
  129. package/dist/providers/password.js.map +1 -1
  130. package/dist/runtime/invite.js +2 -8
  131. package/dist/runtime/invite.js.map +1 -1
  132. package/dist/server/auth.d.ts +127 -130
  133. package/dist/server/auth.d.ts.map +1 -1
  134. package/dist/server/auth.js +100 -64
  135. package/dist/server/auth.js.map +1 -1
  136. package/dist/server/context.d.ts +1 -0
  137. package/dist/server/context.js +53 -0
  138. package/dist/server/context.js.map +1 -0
  139. package/dist/server/core.d.ts +74 -195
  140. package/dist/server/core.d.ts.map +1 -1
  141. package/dist/server/core.js +113 -250
  142. package/dist/server/core.js.map +1 -1
  143. package/dist/server/crypto.d.ts.map +1 -1
  144. package/dist/server/crypto.js +25 -7
  145. package/dist/server/crypto.js.map +1 -1
  146. package/dist/server/device.js +59 -16
  147. package/dist/server/device.js.map +1 -1
  148. package/dist/server/enterprise/domain.d.ts +0 -8
  149. package/dist/server/enterprise/domain.d.ts.map +1 -1
  150. package/dist/server/enterprise/domain.js +148 -59
  151. package/dist/server/enterprise/domain.js.map +1 -1
  152. package/dist/server/enterprise/http.d.ts.map +1 -1
  153. package/dist/server/enterprise/http.js +35 -14
  154. package/dist/server/enterprise/http.js.map +1 -1
  155. package/dist/server/http.d.ts +81 -3
  156. package/dist/server/http.d.ts.map +1 -1
  157. package/dist/server/http.js +84 -21
  158. package/dist/server/http.js.map +1 -1
  159. package/dist/server/identity.js +5 -2
  160. package/dist/server/identity.js.map +1 -1
  161. package/dist/server/index.d.ts +3 -2
  162. package/dist/server/index.js +2 -2
  163. package/dist/server/limits.js +21 -30
  164. package/dist/server/limits.js.map +1 -1
  165. package/dist/server/mounts.d.ts +25 -63
  166. package/dist/server/mounts.d.ts.map +1 -1
  167. package/dist/server/mounts.js +46 -107
  168. package/dist/server/mounts.js.map +1 -1
  169. package/dist/server/mutations/account.d.ts +8 -9
  170. package/dist/server/mutations/account.d.ts.map +1 -1
  171. package/dist/server/mutations/account.js +11 -9
  172. package/dist/server/mutations/account.js.map +1 -1
  173. package/dist/server/mutations/code.d.ts +12 -12
  174. package/dist/server/mutations/code.d.ts.map +1 -1
  175. package/dist/server/mutations/code.js +5 -2
  176. package/dist/server/mutations/code.js.map +1 -1
  177. package/dist/server/mutations/invalidate.d.ts +4 -4
  178. package/dist/server/mutations/invalidate.d.ts.map +1 -1
  179. package/dist/server/mutations/invalidate.js.map +1 -1
  180. package/dist/server/mutations/oauth.d.ts +14 -12
  181. package/dist/server/mutations/oauth.d.ts.map +1 -1
  182. package/dist/server/mutations/oauth.js +9 -3
  183. package/dist/server/mutations/oauth.js.map +1 -1
  184. package/dist/server/mutations/refresh.d.ts +3 -3
  185. package/dist/server/mutations/refresh.d.ts.map +1 -1
  186. package/dist/server/mutations/refresh.js +1 -1
  187. package/dist/server/mutations/refresh.js.map +1 -1
  188. package/dist/server/mutations/register.d.ts +11 -11
  189. package/dist/server/mutations/register.d.ts.map +1 -1
  190. package/dist/server/mutations/register.js +45 -41
  191. package/dist/server/mutations/register.js.map +1 -1
  192. package/dist/server/mutations/retrieve.d.ts +6 -6
  193. package/dist/server/mutations/retrieve.d.ts.map +1 -1
  194. package/dist/server/mutations/retrieve.js +20 -24
  195. package/dist/server/mutations/retrieve.js.map +1 -1
  196. package/dist/server/mutations/signature.d.ts +6 -7
  197. package/dist/server/mutations/signature.d.ts.map +1 -1
  198. package/dist/server/mutations/signature.js +9 -3
  199. package/dist/server/mutations/signature.js.map +1 -1
  200. package/dist/server/mutations/signin.d.ts +5 -5
  201. package/dist/server/mutations/signout.js.map +1 -1
  202. package/dist/server/mutations/store.d.ts +83 -83
  203. package/dist/server/mutations/store.js +8 -23
  204. package/dist/server/mutations/store.js.map +1 -1
  205. package/dist/server/mutations/verifier.js.map +1 -1
  206. package/dist/server/mutations/verify.d.ts +7 -7
  207. package/dist/server/mutations/verify.d.ts.map +1 -1
  208. package/dist/server/mutations/verify.js.map +1 -1
  209. package/dist/server/oauth.js +53 -16
  210. package/dist/server/oauth.js.map +1 -1
  211. package/dist/server/passkey.d.ts +2 -2
  212. package/dist/server/passkey.d.ts.map +1 -1
  213. package/dist/server/passkey.js +114 -30
  214. package/dist/server/passkey.js.map +1 -1
  215. package/dist/server/redirects.js +9 -3
  216. package/dist/server/redirects.js.map +1 -1
  217. package/dist/server/refresh.js +10 -7
  218. package/dist/server/refresh.js.map +1 -1
  219. package/dist/server/runtime.d.ts +11 -11
  220. package/dist/server/runtime.js +155 -112
  221. package/dist/server/runtime.js.map +1 -1
  222. package/dist/server/signin.js +34 -10
  223. package/dist/server/signin.js.map +1 -1
  224. package/dist/server/ssr.d.ts.map +1 -1
  225. package/dist/server/ssr.js +175 -184
  226. package/dist/server/ssr.js.map +1 -1
  227. package/dist/server/totp.js +78 -18
  228. package/dist/server/totp.js.map +1 -1
  229. package/dist/server/types.d.ts +13 -21
  230. package/dist/server/types.d.ts.map +1 -1
  231. package/dist/server/types.js.map +1 -1
  232. package/dist/server/users.js +6 -3
  233. package/dist/server/users.js.map +1 -1
  234. package/dist/server/utils.js +10 -4
  235. package/dist/server/utils.js.map +1 -1
  236. package/package.json +1 -5
  237. package/src/authorization/index.ts +1 -1
  238. package/src/client/core/types.ts +14 -14
  239. package/src/client/factors/device.ts +10 -12
  240. package/src/client/factors/passkey.ts +23 -26
  241. package/src/client/index.ts +54 -64
  242. package/src/client/runtime/invite.ts +5 -7
  243. package/src/component/index.ts +9 -3
  244. package/src/component/public/enterprise/audit.ts +6 -1
  245. package/src/component/public/enterprise/core.ts +1 -0
  246. package/src/component/public/enterprise/domains.ts +5 -1
  247. package/src/component/public/enterprise/scim.ts +1 -0
  248. package/src/component/public/enterprise/secrets.ts +1 -0
  249. package/src/component/public/enterprise/webhooks.ts +1 -0
  250. package/src/component/public/factors/devices.ts +1 -0
  251. package/src/component/public/factors/passkeys.ts +1 -0
  252. package/src/component/public/factors/totp.ts +1 -0
  253. package/src/component/public/groups/core.ts +1 -1
  254. package/src/component/public/groups/invites.ts +7 -1
  255. package/src/component/public/groups/members.ts +1 -0
  256. package/src/component/public/identity/accounts.ts +1 -0
  257. package/src/component/public/identity/codes.ts +1 -0
  258. package/src/component/public/identity/sessions.ts +1 -0
  259. package/src/component/public/identity/tokens.ts +1 -0
  260. package/src/component/public/identity/users.ts +1 -0
  261. package/src/component/public/identity/verifiers.ts +1 -0
  262. package/src/component/public/security/keys.ts +1 -0
  263. package/src/component/public/security/limits.ts +1 -0
  264. package/src/providers/password.ts +89 -110
  265. package/src/server/auth.ts +240 -182
  266. package/src/server/context.ts +90 -0
  267. package/src/server/core.ts +195 -286
  268. package/src/server/crypto.ts +31 -29
  269. package/src/server/device.ts +65 -32
  270. package/src/server/enterprise/domain.ts +158 -170
  271. package/src/server/enterprise/http.ts +46 -39
  272. package/src/server/http.ts +289 -30
  273. package/src/server/identity.ts +5 -5
  274. package/src/server/index.ts +9 -3
  275. package/src/server/limits.ts +53 -80
  276. package/src/server/mounts.ts +56 -80
  277. package/src/server/mutations/account.ts +22 -36
  278. package/src/server/mutations/code.ts +6 -6
  279. package/src/server/mutations/invalidate.ts +1 -1
  280. package/src/server/mutations/oauth.ts +14 -8
  281. package/src/server/mutations/refresh.ts +5 -4
  282. package/src/server/mutations/register.ts +87 -132
  283. package/src/server/mutations/retrieve.ts +44 -44
  284. package/src/server/mutations/signature.ts +13 -6
  285. package/src/server/mutations/signout.ts +1 -1
  286. package/src/server/mutations/store.ts +16 -31
  287. package/src/server/mutations/verifier.ts +1 -1
  288. package/src/server/mutations/verify.ts +3 -5
  289. package/src/server/oauth.ts +60 -69
  290. package/src/server/passkey.ts +567 -517
  291. package/src/server/redirects.ts +10 -6
  292. package/src/server/refresh.ts +14 -18
  293. package/src/server/runtime.ts +340 -302
  294. package/src/server/signin.ts +44 -37
  295. package/src/server/ssr.ts +390 -407
  296. package/src/server/totp.ts +85 -35
  297. package/src/server/types.ts +19 -22
  298. package/src/server/users.ts +7 -6
  299. package/src/server/utils.ts +10 -12
  300. package/dist/component/server/authError.js +0 -34
  301. package/dist/component/server/authError.js.map +0 -1
  302. package/dist/component/server/errors.d.ts +0 -1
  303. package/dist/component/server/errors.js +0 -137
  304. package/dist/component/server/errors.js.map +0 -1
  305. package/dist/server/authError.d.ts +0 -46
  306. package/dist/server/authError.d.ts.map +0 -1
  307. package/dist/server/authError.js +0 -34
  308. package/dist/server/authError.js.map +0 -1
  309. package/dist/server/errors.d.ts +0 -177
  310. package/dist/server/errors.d.ts.map +0 -1
  311. package/dist/server/errors.js +0 -212
  312. package/dist/server/errors.js.map +0 -1
  313. package/src/server/authError.ts +0 -44
  314. package/src/server/errors.ts +0 -290
@@ -60,39 +60,7 @@ type CoreDeps = {
60
60
  declare function createCoreDomains(deps: CoreDeps): {
61
61
  user: {
62
62
  /**
63
- * Resolve the current user's ID.
64
- *
65
- * Checks two sources in order:
66
- *
67
- * 1. **Session JWT** — extracts the `userId` from `ctx.auth.getUserIdentity()`.
68
- * This is the standard path for browser sessions and costs zero DB reads.
69
- * 2. **API key** — if a `request` is provided and contains a
70
- * `Bearer sk_*` Authorization header, the key is verified against the
71
- * database and the owning `userId` is returned.
72
- *
73
- * Returns `null` when neither source produces a valid identity.
74
- *
75
- * @param ctx - Convex query, mutation, or action context.
76
- * @param request - Optional incoming `Request` to check for API key auth.
77
- * Only needed in HTTP actions or server-side handlers.
78
- * @returns The user's document ID, or `null` if unauthenticated.
79
- *
80
- * @example Session auth (queries, mutations)
81
- * ```ts
82
- * const userId = await auth.user.id(ctx);
83
- * if (!userId) return { ok: false, code: "NOT_SIGNED_IN" };
84
- * ```
85
- *
86
- * @example API key auth (HTTP actions)
87
- * ```ts
88
- * const userId = await auth.user.id(ctx, request);
89
- * ```
90
- */
91
- id: (ctx: {
92
- auth: Auth;
93
- } & Partial<ComponentCtx>, request?: Request) => Promise<string | null>;
94
- /**
95
- * Fetch a user document by ID.
63
+ * Fetch a user document by ID.
96
64
  *
97
65
  * Results are **cached per-execution** — calling `auth.user.get(ctx, id)`
98
66
  * multiple times within the same query or mutation handler for the same
@@ -140,9 +108,8 @@ declare function createCoreDomains(deps: CoreDeps): {
140
108
  order?: "asc" | "desc";
141
109
  }) => Promise<any>;
142
110
  /**
143
- * Convenience method: resolve the current user ID from the session
144
- * and fetch their full document in one call. Returns `null` if
145
- * unauthenticated. Equivalent to `auth.user.id(ctx)` then `auth.user.get(ctx, id)`.
111
+ * Convenience method: resolve the current session user and fetch their
112
+ * full document in one call. Returns `null` if unauthenticated.
146
113
  *
147
114
  * @param ctx - Convex query or mutation context with `auth` for session lookup.
148
115
  * @returns The authenticated user's document, or `null` if unauthenticated.
@@ -162,7 +129,7 @@ declare function createCoreDomains(deps: CoreDeps): {
162
129
  * @param ctx - Convex mutation context.
163
130
  * @param userId - The user's document ID.
164
131
  * @param data - Fields to merge into the user document.
165
- * @returns `{ ok: true, userId }`.
132
+ * @returns `{ userId }`.
166
133
  *
167
134
  * @example
168
135
  * ```ts
@@ -173,7 +140,6 @@ declare function createCoreDomains(deps: CoreDeps): {
173
140
  * ```
174
141
  */
175
142
  update: (ctx: ComponentCtx, userId: string, data: Record<string, unknown>) => Promise<{
176
- ok: true;
177
143
  userId: string;
178
144
  }>;
179
145
  /**
@@ -184,7 +150,7 @@ declare function createCoreDomains(deps: CoreDeps): {
184
150
  * @param ctx - Convex mutation context.
185
151
  * @param opts.userId - The user's document ID.
186
152
  * @param opts.groupId - Group ID to set as active, or `null` to clear.
187
- * @returns `{ ok: true, userId, groupId }` confirming the active group was set (or cleared).
153
+ * @returns `{ userId, groupId }` confirming the active group was set (or cleared).
188
154
  *
189
155
  * @example
190
156
  * ```ts
@@ -199,11 +165,9 @@ declare function createCoreDomains(deps: CoreDeps): {
199
165
  userId: string;
200
166
  groupId: string | null;
201
167
  }) => Promise<{
202
- ok: true;
203
168
  userId: string;
204
169
  groupId: null;
205
170
  } | {
206
- ok: true;
207
171
  userId: string;
208
172
  groupId: string;
209
173
  }>;
@@ -236,18 +200,13 @@ declare function createCoreDomains(deps: CoreDeps): {
236
200
  * @param ctx - Convex mutation context.
237
201
  * @param userId - The user's document ID.
238
202
  * @param opts.cascade - Whether to delete related records (default `true`).
239
- * @returns `{ ok: true, userId }`.
203
+ * @returns `{ userId }`.
204
+ * @throws `INVALID_PARAMETERS` if `cascade` is `false` but the user has linked data.
240
205
  */
241
206
  delete: (ctx: ComponentCtx, userId: string, opts?: {
242
207
  cascade?: boolean;
243
208
  }) => Promise<{
244
- ok: false;
245
- code: "INVALID_PARAMETERS";
246
- userId?: undefined;
247
- } | {
248
- ok: true;
249
209
  userId: string;
250
- code?: undefined;
251
210
  }>;
252
211
  };
253
212
  session: {
@@ -289,7 +248,7 @@ declare function createCoreDomains(deps: CoreDeps): {
289
248
  * @param ctx - Convex action context.
290
249
  * @param args.userId - The user whose sessions should be invalidated.
291
250
  * @param args.except - Optional array of session IDs to keep valid.
292
- * @returns `{ ok: true, userId, except }` confirming the operation.
251
+ * @returns `{ userId, except }` confirming the operation.
293
252
  *
294
253
  * @example Sign out everywhere except the current session
295
254
  * ```ts
@@ -304,7 +263,6 @@ declare function createCoreDomains(deps: CoreDeps): {
304
263
  userId: GenericId<"User">;
305
264
  except?: GenericId<"Session">[];
306
265
  }) => Promise<{
307
- ok: true;
308
266
  userId: GenericId<"User">;
309
267
  except: GenericId<"Session">[];
310
268
  }>;
@@ -367,7 +325,7 @@ declare function createCoreDomains(deps: CoreDeps): {
367
325
  * @param args.profile - Profile data used to create or update the user document.
368
326
  * @param args.shouldLinkViaEmail - If `true`, link to an existing user by email match.
369
327
  * @param args.shouldLinkViaPhone - If `true`, link to an existing user by phone match.
370
- * @returns `{ ok: true, ...created }` with the created account and user information.
328
+ * @returns The created account and user information.
371
329
  *
372
330
  * @example
373
331
  * ```ts
@@ -417,7 +375,7 @@ declare function createCoreDomains(deps: CoreDeps): {
417
375
  * @param args.provider - The provider ID (e.g. `"password"`).
418
376
  * @param args.account.id - Provider-specific account identifier.
419
377
  * @param args.account.secret - The new credential secret to store.
420
- * @returns `{ ok: true, accountId }` confirming the update.
378
+ * @returns `{ accountId }` confirming the update.
421
379
  *
422
380
  * @example Password reset
423
381
  * ```ts
@@ -428,7 +386,6 @@ declare function createCoreDomains(deps: CoreDeps): {
428
386
  * ```
429
387
  */
430
388
  update: <DataModel extends GenericDataModel>(ctx: GenericActionCtx<DataModel>, args: UpdateAccountCredentialsArgs) => Promise<{
431
- ok: true;
432
389
  accountId: string;
433
390
  }>;
434
391
  /**
@@ -441,30 +398,17 @@ declare function createCoreDomains(deps: CoreDeps): {
441
398
  *
442
399
  * @param ctx - Convex mutation context.
443
400
  * @param accountId - The account's document ID.
444
- * @returns `{ ok: true, accountId }` on success, or
445
- * `{ ok: false, code: "ACCOUNT_NOT_FOUND" }` if the account does not exist, or
446
- * `{ ok: false, code: "INVALID_PARAMETERS" }` if it is the user's last account.
401
+ * @returns `{ accountId }` on success.
402
+ * @throws `ACCOUNT_NOT_FOUND` if the account does not exist.
403
+ * @throws `INVALID_PARAMETERS` if it is the user's last account.
447
404
  *
448
405
  * @example
449
406
  * ```ts
450
- * const result = await auth.account.delete(ctx, accountId);
451
- * if (!result.ok) {
452
- * console.error("Cannot delete account:", result.code);
453
- * }
407
+ * await auth.account.delete(ctx, accountId);
454
408
  * ```
455
409
  */
456
410
  delete: (ctx: ComponentCtx, accountId: string) => Promise<{
457
- ok: false;
458
- code: "ACCOUNT_NOT_FOUND";
459
- accountId?: undefined;
460
- } | {
461
- ok: false;
462
- code: "INVALID_PARAMETERS";
463
- accountId?: undefined;
464
- } | {
465
- ok: true;
466
411
  accountId: string;
467
- code?: undefined;
468
412
  }>;
469
413
  /**
470
414
  * List all passkey credentials registered for a user.
@@ -499,7 +443,7 @@ declare function createCoreDomains(deps: CoreDeps): {
499
443
  * @param ctx - Convex mutation context.
500
444
  * @param passkeyId - The passkey credential's document ID.
501
445
  * @param name - The new display name for the passkey.
502
- * @returns `{ ok: true, passkeyId }` confirming the rename.
446
+ * @returns `{ passkeyId }` confirming the rename.
503
447
  *
504
448
  * @example
505
449
  * ```ts
@@ -507,7 +451,6 @@ declare function createCoreDomains(deps: CoreDeps): {
507
451
  * ```
508
452
  */
509
453
  renamePasskey: (ctx: ComponentCtx, passkeyId: string, name: string) => Promise<{
510
- ok: true;
511
454
  passkeyId: string;
512
455
  }>;
513
456
  /**
@@ -519,7 +462,7 @@ declare function createCoreDomains(deps: CoreDeps): {
519
462
  *
520
463
  * @param ctx - Convex mutation context.
521
464
  * @param passkeyId - The passkey credential's document ID.
522
- * @returns `{ ok: true, passkeyId }` confirming the deletion.
465
+ * @returns `{ passkeyId }` confirming the deletion.
523
466
  *
524
467
  * @example
525
468
  * ```ts
@@ -527,7 +470,6 @@ declare function createCoreDomains(deps: CoreDeps): {
527
470
  * ```
528
471
  */
529
472
  deletePasskey: (ctx: ComponentCtx, passkeyId: string) => Promise<{
530
- ok: true;
531
473
  passkeyId: string;
532
474
  }>;
533
475
  /**
@@ -559,7 +501,7 @@ declare function createCoreDomains(deps: CoreDeps): {
559
501
  *
560
502
  * @param ctx - Convex mutation context.
561
503
  * @param totpId - The TOTP factor's document ID.
562
- * @returns `{ ok: true, totpId }` confirming the deletion.
504
+ * @returns `{ totpId }` confirming the deletion.
563
505
  *
564
506
  * @example
565
507
  * ```ts
@@ -567,7 +509,6 @@ declare function createCoreDomains(deps: CoreDeps): {
567
509
  * ```
568
510
  */
569
511
  deleteTotp: (ctx: ComponentCtx, totpId: string) => Promise<{
570
- ok: true;
571
512
  totpId: string;
572
513
  }>;
573
514
  };
@@ -629,7 +570,7 @@ declare function createCoreDomains(deps: CoreDeps): {
629
570
  * @param data.parentGroupId - Nest under this group. Omit for a root group.
630
571
  * @param data.tags - Faceted classification tags (normalized at write time).
631
572
  * @param data.extend - Arbitrary app-specific metadata.
632
- * @returns `{ ok: true, groupId }`.
573
+ * @returns `{ groupId }`.
633
574
  *
634
575
  * @example Root group
635
576
  * ```ts
@@ -656,7 +597,6 @@ declare function createCoreDomains(deps: CoreDeps): {
656
597
  }>;
657
598
  extend?: Record<string, unknown>;
658
599
  }) => Promise<{
659
- ok: true;
660
600
  groupId: string;
661
601
  }>;
662
602
  /**
@@ -733,7 +673,7 @@ declare function createCoreDomains(deps: CoreDeps): {
733
673
  * @param ctx - Convex mutation context.
734
674
  * @param groupId - The group's document ID.
735
675
  * @param data - Fields to merge (e.g. `name`, `slug`, `tags`, `parentGroupId`).
736
- * @returns `{ ok: true, groupId }`.
676
+ * @returns `{ groupId }`.
737
677
  *
738
678
  * @example
739
679
  * ```ts
@@ -744,7 +684,6 @@ declare function createCoreDomains(deps: CoreDeps): {
744
684
  * ```
745
685
  */
746
686
  update: (ctx: ComponentCtx, groupId: string, data: Record<string, unknown>) => Promise<{
747
- ok: true;
748
687
  groupId: string;
749
688
  }>;
750
689
  /**
@@ -753,7 +692,7 @@ declare function createCoreDomains(deps: CoreDeps): {
753
692
  *
754
693
  * @param ctx - Convex mutation context.
755
694
  * @param groupId - The group's document ID.
756
- * @returns `{ ok: true, groupId }`.
695
+ * @returns `{ groupId }`.
757
696
  *
758
697
  * @example
759
698
  * ```ts
@@ -761,7 +700,6 @@ declare function createCoreDomains(deps: CoreDeps): {
761
700
  * ```
762
701
  */
763
702
  delete: (ctx: ComponentCtx, groupId: string) => Promise<{
764
- ok: true;
765
703
  groupId: string;
766
704
  }>;
767
705
  /**
@@ -799,7 +737,7 @@ declare function createCoreDomains(deps: CoreDeps): {
799
737
  * Add a user to a group with optional role IDs.
800
738
  *
801
739
  * Role IDs are validated against the roles defined in `defineRoles()` —
802
- * invalid IDs return `{ ok: false, code: "INVALID_ROLE_IDS" }`.
740
+ * invalid IDs throw `INVALID_ROLE_IDS`.
803
741
  * Throws `DUPLICATE_MEMBERSHIP` if the user is already a member.
804
742
  *
805
743
  * @param ctx - Convex mutation context.
@@ -808,7 +746,8 @@ declare function createCoreDomains(deps: CoreDeps): {
808
746
  * @param data.roleIds - Role IDs from `defineRoles()` (optional).
809
747
  * @param data.status - Membership status string (optional, app-defined).
810
748
  * @param data.extend - Arbitrary app-specific metadata.
811
- * @returns `{ ok: true, memberId }` or `{ ok: false, code, invalidRoleIds }`.
749
+ * @returns `{ memberId }`.
750
+ * @throws `INVALID_ROLE_IDS` if any supplied role IDs are not defined.
812
751
  *
813
752
  * @example
814
753
  * ```ts
@@ -826,15 +765,7 @@ declare function createCoreDomains(deps: CoreDeps): {
826
765
  status?: string;
827
766
  extend?: Record<string, unknown>;
828
767
  }) => Promise<{
829
- ok: false;
830
- code: "INVALID_ROLE_IDS";
831
- invalidRoleIds: string[];
832
- memberId?: undefined;
833
- } | {
834
- ok: true;
835
768
  memberId: string;
836
- code?: undefined;
837
- invalidRoleIds?: undefined;
838
769
  }>;
839
770
  /**
840
771
  * Fetch a membership document by its document ID.
@@ -893,7 +824,7 @@ declare function createCoreDomains(deps: CoreDeps): {
893
824
  *
894
825
  * @param ctx - Convex mutation context.
895
826
  * @param memberId - The membership document ID.
896
- * @returns `{ ok: true, memberId }`.
827
+ * @returns `{ memberId }`.
897
828
  *
898
829
  * @example
899
830
  * ```ts
@@ -901,7 +832,6 @@ declare function createCoreDomains(deps: CoreDeps): {
901
832
  * ```
902
833
  */
903
834
  delete: (ctx: ComponentCtx, memberId: string) => Promise<{
904
- ok: true;
905
835
  memberId: string;
906
836
  }>;
907
837
  /**
@@ -911,7 +841,8 @@ declare function createCoreDomains(deps: CoreDeps): {
911
841
  * @param ctx - Convex mutation context.
912
842
  * @param memberId - The membership document ID.
913
843
  * @param data - Fields to merge. `roleIds` are validated.
914
- * @returns `{ ok: true, memberId }` or `{ ok: false, code: "INVALID_ROLE_IDS" }`.
844
+ * @returns `{ memberId }`.
845
+ * @throws `INVALID_ROLE_IDS` if any supplied role IDs are not defined.
915
846
  *
916
847
  * @example
917
848
  * ```ts
@@ -922,15 +853,7 @@ declare function createCoreDomains(deps: CoreDeps): {
922
853
  * ```
923
854
  */
924
855
  update: (ctx: ComponentCtx, memberId: string, data: Record<string, unknown>) => Promise<{
925
- ok: false;
926
- code: "INVALID_ROLE_IDS";
927
- invalidRoleIds: string[];
928
- memberId?: undefined;
929
- } | {
930
- ok: true;
931
856
  memberId: string;
932
- code?: undefined;
933
- invalidRoleIds?: undefined;
934
857
  }>;
935
858
  /**
936
859
  * Resolve a user's membership in a group, optionally walking the
@@ -951,34 +874,41 @@ declare function createCoreDomains(deps: CoreDeps): {
951
874
  * @param opts.userId - The user's document ID.
952
875
  * @param opts.groupId - The group to check membership in.
953
876
  * @param opts.ancestry - Walk the hierarchy (default `false`).
954
- * @param opts.grants - Grant strings to check (optional).
955
- * @param opts.roleIds - Role IDs to filter by (optional).
956
877
  * @param opts.maxDepth - Max hierarchy levels (default 32, only with ancestry).
957
- * @returns `{ ok, membership, roleIds, grants, missingGrants, ... }`.
958
- * `ok` is `true` when membership exists and all requested grants are satisfied.
878
+ * @returns `{ membership, roleIds, grants }`.
959
879
  *
960
880
  * @example Direct lookup
961
881
  * ```ts
962
- * const result = await auth.member.resolve(ctx, { userId, groupId });
963
- * if (!result.membership) return { ok: false, code: "NOT_A_MEMBER" };
882
+ * const result = await auth.member.inspect(ctx, { userId, groupId });
883
+ * if (!result.membership) return null;
964
884
  * ```
965
885
  *
966
- * @example Check grants (no hierarchy walk)
886
+ * @example Check grants after inspection
967
887
  * ```ts
968
- * const result = await auth.member.resolve(ctx, {
969
- * userId, groupId, grants: ["issues.create"],
888
+ * const result = await auth.member.inspect(ctx, {
889
+ * userId, groupId,
970
890
  * });
971
- * if (!result.ok) return { ok: false, code: "FORBIDDEN" };
891
+ * const canCreate = result.grants.includes("issues.create");
972
892
  * ```
973
893
  *
974
894
  * @example Walk hierarchy + check grants
975
895
  * ```ts
976
- * const result = await auth.member.resolve(ctx, {
977
- * userId, groupId: teamId, ancestry: true, grants: ["issues.create"],
896
+ * const result = await auth.member.inspect(ctx, {
897
+ * userId, groupId: teamId, ancestry: true,
978
898
  * });
979
899
  * ```
980
900
  */
981
- resolve: (ctx: ComponentReadCtx, opts: {
901
+ inspect: (ctx: ComponentReadCtx, opts: {
902
+ userId: string;
903
+ groupId: string;
904
+ ancestry?: boolean;
905
+ maxDepth?: number;
906
+ }) => Promise<{
907
+ membership: any;
908
+ roleIds: any;
909
+ grants: string[];
910
+ }>;
911
+ require: (ctx: ComponentReadCtx, opts: {
982
912
  userId: string;
983
913
  groupId: string;
984
914
  ancestry?: boolean;
@@ -986,31 +916,9 @@ declare function createCoreDomains(deps: CoreDeps): {
986
916
  grants?: string[];
987
917
  maxDepth?: number;
988
918
  }) => Promise<{
989
- ok: false;
990
- membership: null;
991
- matchedGroupId: null;
992
- roleIds: string[];
993
- grants: string[];
994
- missingGrants: string[];
995
- depth: null;
996
- isDirect: boolean;
997
- isInherited: boolean;
998
- traversedGroupIds: string[];
999
- code: "INVALID_ROLE_IDS";
1000
- invalidRoleIds: string[];
1001
- } | {
1002
- ok: boolean;
1003
919
  membership: any;
1004
- matchedGroupId: string | null;
1005
920
  roleIds: any;
1006
921
  grants: string[];
1007
- missingGrants: string[];
1008
- depth: number | null;
1009
- isDirect: boolean;
1010
- isInherited: boolean;
1011
- traversedGroupIds: string[];
1012
- code?: undefined;
1013
- invalidRoleIds?: undefined;
1014
922
  }>;
1015
923
  };
1016
924
  invite: {
@@ -1025,7 +933,8 @@ declare function createCoreDomains(deps: CoreDeps): {
1025
933
  * @param data.roleIds - Role IDs from `defineRoles()` to assign on acceptance (optional).
1026
934
  * @param data.expiresTime - Expiration timestamp in ms since epoch (optional).
1027
935
  * @param data.extend - Arbitrary app-specific metadata (optional).
1028
- * @returns `{ ok: true, inviteId, token }` or `{ ok: false, code: "INVALID_ROLE_IDS" }`.
936
+ * @returns `{ inviteId, token }`.
937
+ * @throws `INVALID_ROLE_IDS` if any supplied role IDs are not defined.
1029
938
  *
1030
939
  * @example
1031
940
  * ```ts
@@ -1042,17 +951,8 @@ declare function createCoreDomains(deps: CoreDeps): {
1042
951
  expiresTime?: number;
1043
952
  extend?: Record<string, unknown>;
1044
953
  }) => Promise<{
1045
- ok: false;
1046
- code: "INVALID_ROLE_IDS";
1047
- invalidRoleIds: string[];
1048
- inviteId?: undefined;
1049
- token?: undefined;
1050
- } | {
1051
- ok: true;
1052
954
  inviteId: string;
1053
955
  token: string;
1054
- code?: undefined;
1055
- invalidRoleIds?: undefined;
1056
956
  }>;
1057
957
  /**
1058
958
  * Fetch an invite document by ID.
@@ -1105,7 +1005,7 @@ declare function createCoreDomains(deps: CoreDeps): {
1105
1005
  * @param ctx - Convex mutation context.
1106
1006
  * @param args.token - The raw invite token string.
1107
1007
  * @param args.acceptedByUserId - The user accepting the invite.
1108
- * @returns `{ ok: true, ...result }` with the created membership details.
1008
+ * @returns The created membership details.
1109
1009
  *
1110
1010
  * @example
1111
1011
  * ```ts
@@ -1169,7 +1069,7 @@ declare function createCoreDomains(deps: CoreDeps): {
1169
1069
  * @param ctx - Convex mutation context.
1170
1070
  * @param inviteId - The invite's document ID.
1171
1071
  * @param acceptedByUserId - The user who accepted the invite (optional).
1172
- * @returns `{ ok: true, inviteId, acceptedByUserId }`.
1072
+ * @returns `{ inviteId, acceptedByUserId }`.
1173
1073
  *
1174
1074
  * @example
1175
1075
  * ```ts
@@ -1177,7 +1077,6 @@ declare function createCoreDomains(deps: CoreDeps): {
1177
1077
  * ```
1178
1078
  */
1179
1079
  accept: (ctx: ComponentCtx, inviteId: string, acceptedByUserId?: string) => Promise<{
1180
- ok: true;
1181
1080
  inviteId: string;
1182
1081
  acceptedByUserId: string | null;
1183
1082
  }>;
@@ -1189,7 +1088,7 @@ declare function createCoreDomains(deps: CoreDeps): {
1189
1088
  *
1190
1089
  * @param ctx - Convex mutation context.
1191
1090
  * @param inviteId - The invite's document ID.
1192
- * @returns `{ ok: true, inviteId }`.
1091
+ * @returns `{ inviteId }`.
1193
1092
  *
1194
1093
  * @example
1195
1094
  * ```ts
@@ -1197,7 +1096,6 @@ declare function createCoreDomains(deps: CoreDeps): {
1197
1096
  * ```
1198
1097
  */
1199
1098
  revoke: (ctx: ComponentCtx, inviteId: string) => Promise<{
1200
- ok: true;
1201
1099
  inviteId: string;
1202
1100
  }>;
1203
1101
  };
@@ -1213,7 +1111,7 @@ declare function createCoreDomains(deps: CoreDeps): {
1213
1111
  * @param opts.rateLimit - Optional per-key rate limit `{ maxRequests, windowMs }`.
1214
1112
  * @param opts.expiresAt - Optional expiration timestamp (ms since epoch).
1215
1113
  * @param opts.metadata - Arbitrary app-specific metadata.
1216
- * @returns `{ ok: true, keyId, secret }`. Store `secret` securely — it cannot be retrieved later.
1114
+ * @returns `{ keyId, secret }`. Store `secret` securely — it cannot be retrieved later.
1217
1115
  *
1218
1116
  * @example
1219
1117
  * ```ts
@@ -1235,7 +1133,6 @@ declare function createCoreDomains(deps: CoreDeps): {
1235
1133
  expiresAt?: number;
1236
1134
  metadata?: Record<string, unknown>;
1237
1135
  }) => Promise<{
1238
- ok: true;
1239
1136
  keyId: string;
1240
1137
  secret: string;
1241
1138
  }>;
@@ -1247,28 +1144,22 @@ declare function createCoreDomains(deps: CoreDeps): {
1247
1144
  *
1248
1145
  * @param ctx - Convex mutation context (updates `lastUsedAt` and rate limit state).
1249
1146
  * @param rawKey - The raw `sk_*` key string.
1250
- * @returns On success: `{ ok: true, userId, keyId, scopes }` where `scopes.can(resource, action)` checks permissions.
1251
- * On failure: `{ ok: false, code }` with one of:
1252
- * - `"INVALID_API_KEY"` key not found.
1253
- * - `"API_KEY_REVOKED"` key was revoked.
1254
- * - `"API_KEY_EXPIRED"` key past its `expiresAt`.
1255
- * - `"API_KEY_RATE_LIMITED"` — rate limit exceeded.
1147
+ * @returns `{ userId, keyId, scopes }` where `scopes.can(resource, action)` checks permissions.
1148
+ * @throws `INVALID_API_KEY` if the key is not found.
1149
+ * @throws `API_KEY_REVOKED` if the key was revoked.
1150
+ * @throws `API_KEY_EXPIRED` if the key is past its `expiresAt`.
1151
+ * @throws `API_KEY_RATE_LIMITED` if the rate limit is exceeded.
1256
1152
  *
1257
1153
  * @example
1258
1154
  * ```ts
1259
- * const result = await auth.key.verify(ctx, rawKey);
1260
- * if (!result.ok) return { ok: false, code: result.code };
1261
- * const canRead = result.scopes.can("data", "read");
1155
+ * const { userId, scopes } = await auth.key.verify(ctx, rawKey);
1156
+ * const canRead = scopes.can("data", "read");
1262
1157
  * ```
1263
1158
  */
1264
1159
  verify: (ctx: ComponentCtx, rawKey: string) => Promise<{
1265
- ok: true;
1266
1160
  userId: string;
1267
1161
  keyId: string;
1268
1162
  scopes: ScopeChecker;
1269
- } | {
1270
- ok: false;
1271
- code: "INVALID_API_KEY" | "API_KEY_REVOKED" | "API_KEY_EXPIRED" | "API_KEY_RATE_LIMITED";
1272
1163
  }>;
1273
1164
  /**
1274
1165
  * List API keys with optional filtering by user, revocation status, name,
@@ -1312,21 +1203,16 @@ declare function createCoreDomains(deps: CoreDeps): {
1312
1203
  *
1313
1204
  * @param ctx - Convex query or mutation context.
1314
1205
  * @param keyId - The API key's document ID.
1315
- * @returns `{ ok: true, key }` with the key document, or `{ ok: false }` if not found.
1206
+ * @returns The key document, or `null` if not found.
1316
1207
  *
1317
1208
  * @example
1318
1209
  * ```ts
1319
- * const result = await auth.key.get(ctx, keyId);
1320
- * if (!result.ok) throw new Error("Key not found");
1321
- * console.log(result.key.name, result.key.prefix);
1210
+ * const key = await auth.key.get(ctx, keyId);
1211
+ * if (!key) throw new Error("Key not found");
1212
+ * console.log(key.name, key.prefix);
1322
1213
  * ```
1323
1214
  */
1324
- get: (ctx: ComponentReadCtx, keyId: string) => Promise<{
1325
- ok: true;
1326
- key: KeyDoc;
1327
- } | {
1328
- ok: false;
1329
- }>;
1215
+ get: (ctx: ComponentReadCtx, keyId: string) => Promise<KeyDoc | null>;
1330
1216
  /**
1331
1217
  * Update a key's name, scopes, or rate limit.
1332
1218
  *
@@ -1336,7 +1222,7 @@ declare function createCoreDomains(deps: CoreDeps): {
1336
1222
  * @param ctx - Convex mutation context.
1337
1223
  * @param keyId - The API key's document ID.
1338
1224
  * @param data - Fields to merge into the key document.
1339
- * @returns `{ ok: true, keyId }`.
1225
+ * @returns `{ keyId }`.
1340
1226
  *
1341
1227
  * @example
1342
1228
  * ```ts
@@ -1354,19 +1240,18 @@ declare function createCoreDomains(deps: CoreDeps): {
1354
1240
  windowMs: number;
1355
1241
  };
1356
1242
  }) => Promise<{
1357
- ok: true;
1358
1243
  keyId: string;
1359
1244
  }>;
1360
1245
  /**
1361
1246
  * Soft-delete: set `revoked: true`. The key can no longer be verified.
1362
1247
  *
1363
1248
  * After revocation, any subsequent calls to `auth.key.verify` with
1364
- * this key will return `{ ok: false, code: "API_KEY_REVOKED" }`.
1249
+ * this key will throw `API_KEY_REVOKED`.
1365
1250
  * The key record is preserved for audit purposes.
1366
1251
  *
1367
1252
  * @param ctx - Convex mutation context.
1368
1253
  * @param keyId - The API key's document ID.
1369
- * @returns `{ ok: true, keyId }`.
1254
+ * @returns `{ keyId }`.
1370
1255
  *
1371
1256
  * @example
1372
1257
  * ```ts
@@ -1374,7 +1259,6 @@ declare function createCoreDomains(deps: CoreDeps): {
1374
1259
  * ```
1375
1260
  */
1376
1261
  revoke: (ctx: ComponentCtx, keyId: string) => Promise<{
1377
- ok: true;
1378
1262
  keyId: string;
1379
1263
  }>;
1380
1264
  /**
@@ -1386,7 +1270,7 @@ declare function createCoreDomains(deps: CoreDeps): {
1386
1270
  *
1387
1271
  * @param ctx - Convex mutation context.
1388
1272
  * @param keyId - The API key's document ID.
1389
- * @returns `{ ok: true, keyId }`.
1273
+ * @returns `{ keyId }`.
1390
1274
  *
1391
1275
  * @example
1392
1276
  * ```ts
@@ -1394,40 +1278,35 @@ declare function createCoreDomains(deps: CoreDeps): {
1394
1278
  * ```
1395
1279
  */
1396
1280
  delete: (ctx: ComponentCtx, keyId: string) => Promise<{
1397
- ok: true;
1398
1281
  keyId: string;
1399
1282
  }>;
1400
1283
  /**
1401
1284
  * Rotate a key: revokes the old key and creates a new one with the
1402
1285
  * same user, scopes, and rate limit. Returns the new `keyId` and `secret`.
1403
- * Fails with `{ ok: false }` if the key is already revoked.
1286
+ * Throws if the key does not exist or is already revoked.
1404
1287
  *
1405
1288
  * @param ctx - Convex mutation context.
1406
1289
  * @param keyId - The existing API key's document ID to rotate.
1407
1290
  * @param opts.name - Optional new name for the rotated key (defaults to the old name).
1408
1291
  * @param opts.expiresAt - Optional new expiration timestamp in ms since epoch.
1409
- * @returns `{ ok: true, keyId, secret }` with the new key, or `{ ok: false, code }` on failure.
1292
+ * @returns `{ keyId, secret }` with the new key.
1293
+ * @throws `INVALID_PARAMETERS` if the key does not exist.
1294
+ * @throws `API_KEY_REVOKED` if the key is already revoked.
1410
1295
  *
1411
1296
  * @example
1412
1297
  * ```ts
1413
- * const result = await auth.key.rotate(ctx, oldKeyId, {
1298
+ * const { keyId, secret } = await auth.key.rotate(ctx, oldKeyId, {
1414
1299
  * expiresAt: Date.now() + 30 * 24 * 60 * 60 * 1000, // 30 days
1415
1300
  * });
1416
- * if (result.ok) {
1417
- * // Store result.secret securely — shown only once
1418
- * }
1301
+ * // Store secret securely — shown only once
1419
1302
  * ```
1420
1303
  */
1421
1304
  rotate: (ctx: ComponentCtx, keyId: string, opts?: {
1422
1305
  name?: string;
1423
1306
  expiresAt?: number;
1424
1307
  }) => Promise<{
1425
- ok: true;
1426
1308
  keyId: string;
1427
1309
  secret: string;
1428
- } | {
1429
- ok: false;
1430
- code: "INVALID_PARAMETERS" | "API_KEY_REVOKED";
1431
1310
  }>;
1432
1311
  };
1433
1312
  };