@midsummer-ai/sdk 0.1.0-staging.3653 → 0.1.0-staging.3656

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 (44) hide show
  1. package/THIRD-PARTY-NOTICES +1279 -0
  2. package/auth/client.d.mts +222 -18
  3. package/auth/client.mjs +321 -40
  4. package/auth/contract.d.mts +10 -1
  5. package/auth/contract.mjs +347 -30
  6. package/auth/files.d.mts +2 -28
  7. package/auth/files.mjs +2 -231
  8. package/auth/impersonate.d.mts +33 -0
  9. package/auth/impersonate.mjs +42 -0
  10. package/auth/import.d.mts +71 -0
  11. package/auth/import.mjs +195 -0
  12. package/auth/index.d.mts +5 -198
  13. package/auth/index.mjs +3 -2
  14. package/auth/mail.d.mts +23 -5
  15. package/auth/mail.mjs +93 -39
  16. package/auth/password.d.mts +10 -2
  17. package/auth/password.mjs +14 -2
  18. package/auth/react.d.mts +86 -0
  19. package/auth/react.mjs +865 -0
  20. package/auth/stand-in.d.mts +14 -3
  21. package/auth/stand-in.mjs +162 -29
  22. package/auth-CND9RW17.mjs +1819 -0
  23. package/authorize-BzDrbYtI-0gOzDrp2.mjs +18783 -0
  24. package/{client-BX56cXDt.mjs → connection-C_JSWUrt.mjs} +3 -668
  25. package/database/client.mjs +665 -1
  26. package/dist-DXtY-DJA.mjs +343 -0
  27. package/engine-BhA0XgI7.mjs +48423 -0
  28. package/esm-E3EvzsGX.mjs +1518 -0
  29. package/factory-9jfDGyc1.mjs +1138 -0
  30. package/files-C-FvBxT4.d.mts +75 -0
  31. package/files-DAFOuID_.mjs +692 -0
  32. package/get-id-field-vhOArqXN.mjs +1455 -0
  33. package/index-CsgQ_ouh.d.mts +246 -0
  34. package/package.json +24 -7
  35. package/qr-C1mfuCT9.mjs +1163 -0
  36. package/request-state-BaLB2Hrt.mjs +85 -0
  37. package/rolldown-runtime-CL6CfywC.mjs +36 -0
  38. package/schemas-DTJTcCdK.mjs +6046 -0
  39. package/settings-si8iBtwc.d.mts +47 -0
  40. package/store-CeIGY-xT.d.mts +16 -0
  41. package/{store-B-1coCxW.mjs → store-CsBhnabU.mjs} +1 -1
  42. package/{tabs-CDplCS02.mjs → tabs-gHJHkhm2.mjs} +1 -1
  43. package/auth-Bf7IuulG.mjs +0 -754
  44. package/store-gCz6XVaG.d.mts +0 -15
package/auth/client.d.mts CHANGED
@@ -1,23 +1,227 @@
1
- import { AuthClient } from "better-auth/client";
2
- import { AdminClientOptions, OrganizationClientOptions, adminClient, emailOTPClient, magicLinkClient, organizationClient, twoFactorClient } from "better-auth/client/plugins";
3
- import { passkeyClient } from "@better-auth/passkey/client";
4
- import { oauthProviderClient } from "@better-auth/oauth-provider/client";
1
+ import { r as PublicSettings } from "../settings-si8iBtwc.mjs";
5
2
  //#region src/auth/client.d.ts
6
- type AuthPlugin = ReturnType<typeof emailOTPClient> | ReturnType<typeof magicLinkClient> | ReturnType<typeof organizationClient<OrganizationClientOptions>> | ReturnType<typeof twoFactorClient> | ReturnType<typeof passkeyClient> | ReturnType<typeof adminClient<AdminClientOptions>> | ReturnType<typeof oauthProviderClient>;
7
- /** What `authClient()` returns: better-auth's client with every plugin's methods, such as `emailOtp` and `organization`. */
8
- type MidsummerAuthClient = AuthClient<{
9
- basePath: string;
10
- baseURL?: string;
11
- plugins: AuthPlugin[];
12
- }>;
13
- /**
14
- * The client plugins that match the server's. With `oauthProviderClient`, a sign-in on the app's sign-in page
15
- * that an MCP client sent the person to carries on to the page that asks them, with nothing more to write.
16
- */
17
- declare const authPlugins: () => AuthPlugin[];
3
+ /** A signed-in user as the browser sees them: never their private metadata. */
4
+ interface ClientUser {
5
+ readonly id: string;
6
+ readonly email: string;
7
+ readonly name: string;
8
+ readonly emailVerified: boolean;
9
+ readonly image?: string | null;
10
+ readonly twoFactorEnabled?: boolean | null;
11
+ readonly publicMetadata?: unknown;
12
+ readonly createdAt: string;
13
+ }
14
+ /** One of a user's sessions. `impersonatedBy` says who signed in as them from the dashboard. */
15
+ interface ClientSession {
16
+ readonly id: string;
17
+ readonly token: string;
18
+ readonly userId: string;
19
+ readonly expiresAt: string;
20
+ readonly createdAt: string;
21
+ readonly ipAddress?: string | null;
22
+ readonly userAgent?: string | null;
23
+ readonly activeOrganizationId?: string | null;
24
+ readonly impersonatedBy?: string | null;
25
+ }
26
+ interface ClientPasskey {
27
+ readonly id: string;
28
+ readonly name?: string | null;
29
+ readonly createdAt?: string | null;
30
+ readonly deviceType?: string;
31
+ }
32
+ interface ClientOrganization {
33
+ readonly id: string;
34
+ readonly name: string;
35
+ readonly slug: string;
36
+ readonly logo?: string | null;
37
+ readonly createdAt: string;
38
+ }
39
+ interface ClientMember {
40
+ readonly id: string;
41
+ readonly userId: string;
42
+ readonly organizationId: string;
43
+ readonly role: string;
44
+ readonly createdAt: string;
45
+ readonly user: {
46
+ readonly id: string;
47
+ readonly email: string;
48
+ readonly name: string;
49
+ readonly image?: string | null;
50
+ };
51
+ }
52
+ interface ClientInvitation {
53
+ readonly id: string;
54
+ readonly organizationId: string;
55
+ readonly email: string;
56
+ readonly role?: string | null;
57
+ readonly status: string;
58
+ readonly expiresAt: string;
59
+ readonly organizationName?: string;
60
+ }
61
+ interface ClientKey {
62
+ readonly id: string;
63
+ readonly name: string | null;
64
+ readonly start: string | null;
65
+ readonly scopes: ReadonlyArray<string>;
66
+ readonly createdAt: string;
67
+ readonly expiresAt: string | null;
68
+ readonly lastUsedAt: string | null;
69
+ }
70
+ interface ClientGrant {
71
+ readonly id: string;
72
+ readonly clientId: string;
73
+ readonly client: string | null;
74
+ readonly scopes: ReadonlyArray<string>;
75
+ readonly createdAt: string;
76
+ }
77
+ /** The app's settings a browser reads, with the scopes an agent's key may carry. */
78
+ interface ClientSettings extends PublicSettings {
79
+ readonly scopes: Readonly<Record<string, string>>;
80
+ }
81
+ type OrganizationRole = "owner" | "admin" | "member";
82
+ /** A refusal from sign-in: its `code` (such as `INVALID_EMAIL_OR_PASSWORD`), and words to show the person. */
83
+ declare class AuthClientError extends Error {
84
+ readonly code: string;
85
+ readonly status: number;
86
+ constructor(code: string, message: string, status: number);
87
+ }
88
+ /** What signing in with a password returns: signed in, or asked for a second factor first. */
89
+ type SignInResult = {
90
+ readonly signedIn: true;
91
+ } | {
92
+ readonly twoFactor: true;
93
+ };
94
+ interface AuthClient {
95
+ /** Who is signed in in this browser, or null. */
96
+ session(): Promise<{
97
+ readonly user: ClientUser;
98
+ readonly session: ClientSession;
99
+ } | null>;
100
+ settings(): Promise<ClientSettings>;
101
+ /** Calls `listener` whenever this client signs in or out; returns a stop. */
102
+ onChange(listener: () => void): () => void;
103
+ signUp(input: {
104
+ readonly email: string;
105
+ readonly password: string;
106
+ readonly name: string;
107
+ readonly captcha?: string;
108
+ }): Promise<void>;
109
+ readonly signIn: {
110
+ password(input: {
111
+ readonly email: string;
112
+ readonly password: string;
113
+ readonly captcha?: string;
114
+ }): Promise<SignInResult>;
115
+ readonly code: {
116
+ send(email: string, options?: {
117
+ readonly captcha?: string;
118
+ }): Promise<void>;
119
+ verify(email: string, code: string): Promise<void>;
120
+ };
121
+ link(email: string, options?: {
122
+ readonly callbackURL?: string;
123
+ readonly captcha?: string;
124
+ }): Promise<void>;
125
+ /** Sends the browser to Google or GitHub, which brings it back to `callbackURL` signed in. */
126
+ social(provider: "google" | "github", options?: {
127
+ readonly callbackURL?: string;
128
+ }): Promise<void>;
129
+ passkey(): Promise<void>;
130
+ };
131
+ signOut(): Promise<void>;
132
+ readonly twoFactor: {
133
+ /** Turns on 2FA after checking the password: the app's address for an authenticator app, and backup codes to keep. */
134
+ enable(password: string): Promise<{
135
+ readonly totpURI: string;
136
+ readonly backupCodes: ReadonlyArray<string>;
137
+ }>;
138
+ disable(password: string): Promise<void>;
139
+ /** Checks a code from the authenticator app: at sign-in, and once after `enable` to finish turning it on. */
140
+ verifyTotp(code: string, options?: {
141
+ readonly trustDevice?: boolean;
142
+ }): Promise<void>;
143
+ sendCode(): Promise<void>;
144
+ verifyCode(code: string): Promise<void>;
145
+ verifyBackupCode(code: string): Promise<void>;
146
+ };
147
+ readonly passkeys: {
148
+ list(): Promise<ReadonlyArray<ClientPasskey>>;
149
+ add(name?: string): Promise<void>;
150
+ remove(id: string): Promise<void>;
151
+ };
152
+ readonly sessions: {
153
+ list(): Promise<ReadonlyArray<ClientSession>>;
154
+ revoke(token: string): Promise<void>;
155
+ revokeOthers(): Promise<void>;
156
+ };
157
+ readonly password: {
158
+ change(input: {
159
+ readonly current: string;
160
+ readonly next: string;
161
+ readonly signOutOthers?: boolean;
162
+ }): Promise<void>;
163
+ requestReset(email: string, options: {
164
+ readonly redirectTo: string;
165
+ readonly captcha?: string;
166
+ }): Promise<void>;
167
+ reset(token: string, password: string): Promise<void>;
168
+ };
169
+ readonly profile: {
170
+ update(input: {
171
+ readonly name?: string;
172
+ readonly image?: string | null;
173
+ }): Promise<void>;
174
+ };
175
+ readonly keys: {
176
+ list(): Promise<ReadonlyArray<ClientKey>>;
177
+ create(input: {
178
+ readonly name: string;
179
+ readonly scopes: ReadonlyArray<string>;
180
+ readonly expiresIn?: number;
181
+ }): Promise<ClientKey & {
182
+ readonly key: string;
183
+ }>;
184
+ revoke(id: string): Promise<void>;
185
+ };
186
+ readonly grants: {
187
+ list(): Promise<ReadonlyArray<ClientGrant>>;
188
+ revoke(id: string): Promise<void>;
189
+ };
190
+ readonly organizations: {
191
+ list(): Promise<ReadonlyArray<ClientOrganization>>;
192
+ create(input: {
193
+ readonly name: string;
194
+ readonly slug: string;
195
+ }): Promise<ClientOrganization>;
196
+ /** Makes an organization the active one, or none with null. */
197
+ setActive(id: string | null): Promise<void>;
198
+ /** One organization with its members and invitations: the active one when `id` is left out. */
199
+ get(id?: string): Promise<(ClientOrganization & {
200
+ readonly members: ReadonlyArray<ClientMember>;
201
+ readonly invitations: ReadonlyArray<ClientInvitation>;
202
+ }) | null>;
203
+ update(id: string, input: {
204
+ readonly name?: string;
205
+ readonly slug?: string;
206
+ readonly logo?: string;
207
+ }): Promise<void>;
208
+ invite(id: string, input: {
209
+ readonly email: string;
210
+ readonly role: OrganizationRole;
211
+ }): Promise<void>;
212
+ cancelInvitation(invitationId: string): Promise<void>;
213
+ removeMember(id: string, memberIdOrEmail: string): Promise<void>;
214
+ setRole(id: string, memberId: string, role: OrganizationRole): Promise<void>;
215
+ leave(id: string): Promise<void>;
216
+ invitation(invitationId: string): Promise<ClientInvitation>;
217
+ acceptInvitation(invitationId: string): Promise<void>;
218
+ rejectInvitation(invitationId: string): Promise<void>;
219
+ };
220
+ }
18
221
  /** A client for the page's own sign-in, or the address `baseURL` gives when the app's server is elsewhere. */
19
222
  declare function authClient(options?: {
20
223
  readonly baseURL?: string;
21
- }): MidsummerAuthClient;
224
+ readonly fetch?: typeof fetch;
225
+ }): AuthClient;
22
226
  //#endregion
23
- export { MidsummerAuthClient, authClient, authPlugins };
227
+ export { AuthClient, AuthClientError, ClientGrant, ClientInvitation, ClientKey, ClientMember, ClientOrganization, ClientPasskey, ClientSession, ClientSettings, ClientUser, OrganizationRole, SignInResult, authClient };
package/auth/client.mjs CHANGED
@@ -1,45 +1,326 @@
1
- import { createAuthClient } from "better-auth/client";
2
- import { adminClient, emailOTPClient, magicLinkClient, organizationClient, twoFactorClient } from "better-auth/client/plugins";
3
- import { passkeyClient } from "@better-auth/passkey/client";
4
- import { oauthProviderClient } from "@better-auth/oauth-provider/client";
5
1
  //#region src/auth/client.ts
6
- /**
7
- * Sign-in from the browser: better-auth's client with the plugins `@midsummer-ai/sdk/auth` turns on, talking to
8
- * `/api/auth` on the page's own address.
9
- *
10
- * import { authClient } from "@midsummer-ai/sdk/auth/client"
11
- *
12
- * const auth = authClient()
13
- * await auth.signUp.email({ email, password, name })
14
- * await auth.emailOtp.sendVerificationOtp({ email, type: "sign-in" })
15
- * await auth.signIn.emailOtp({ email, otp })
16
- * await auth.signIn.social({ provider: "google", callbackURL: "/" })
17
- * await auth.organization.create({ name: "Acme", slug: "acme" })
18
- * const { data } = await auth.getSession()
19
- *
20
- * `auth.useSession` is a store any framework can subscribe to; in React, `better-auth/react`'s `createAuthClient`
21
- * takes the same `plugins`.
22
- */
23
- /**
24
- * The client plugins that match the server's. With `oauthProviderClient`, a sign-in on the app's sign-in page
25
- * that an MCP client sent the person to carries on to the page that asks them, with nothing more to write.
26
- */
27
- const authPlugins = () => [
28
- emailOTPClient(),
29
- magicLinkClient(),
30
- organizationClient(),
31
- twoFactorClient(),
32
- passkeyClient(),
33
- adminClient(),
34
- oauthProviderClient()
35
- ];
2
+ /** A refusal from sign-in: its `code` (such as `INVALID_EMAIL_OR_PASSWORD`), and words to show the person. */
3
+ var AuthClientError = class extends Error {
4
+ code;
5
+ status;
6
+ constructor(code, message, status) {
7
+ super(message);
8
+ this.code = code;
9
+ this.status = status;
10
+ this.name = "AuthClientError";
11
+ }
12
+ };
13
+ const B64 = {
14
+ decode: (text) => Uint8Array.from(atob(text.replace(/-/g, "+").replace(/_/g, "/").padEnd(Math.ceil(text.length / 4) * 4, "=")), (c) => c.charCodeAt(0)),
15
+ encode: (bytes) => btoa(String.fromCharCode(...new Uint8Array(bytes))).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "")
16
+ };
17
+ /** WebAuthn's options as the server sends them, with their binary fields made bytes for the browser's call. */
18
+ function creationOptions(json) {
19
+ const user = json.user;
20
+ return {
21
+ ...json,
22
+ challenge: B64.decode(String(json.challenge)),
23
+ user: {
24
+ ...user,
25
+ id: B64.decode(String(user.id))
26
+ },
27
+ excludeCredentials: (json.excludeCredentials ?? []).map((one) => ({
28
+ ...one,
29
+ id: B64.decode(String(one.id))
30
+ }))
31
+ };
32
+ }
33
+ function requestOptions(json) {
34
+ return {
35
+ ...json,
36
+ challenge: B64.decode(String(json.challenge)),
37
+ allowCredentials: (json.allowCredentials ?? []).map((one) => ({
38
+ ...one,
39
+ id: B64.decode(String(one.id))
40
+ }))
41
+ };
42
+ }
43
+ /** A credential as JSON, its binary fields base64url, as the server checks it. */
44
+ function credentialJson(credential) {
45
+ const response = credential.response;
46
+ const fields = { clientDataJSON: B64.encode(response.clientDataJSON) };
47
+ if ("attestationObject" in response && response.attestationObject) Object.assign(fields, {
48
+ attestationObject: B64.encode(response.attestationObject),
49
+ transports: response.getTransports?.() ?? []
50
+ });
51
+ if ("authenticatorData" in response && response.authenticatorData) Object.assign(fields, {
52
+ authenticatorData: B64.encode(response.authenticatorData),
53
+ signature: B64.encode(response.signature),
54
+ ...response.userHandle ? { userHandle: B64.encode(response.userHandle) } : {}
55
+ });
56
+ return {
57
+ id: credential.id,
58
+ rawId: B64.encode(credential.rawId),
59
+ type: credential.type,
60
+ response: fields,
61
+ clientExtensionResults: credential.getClientExtensionResults(),
62
+ authenticatorAttachment: credential.authenticatorAttachment ?? void 0
63
+ };
64
+ }
36
65
  /** A client for the page's own sign-in, or the address `baseURL` gives when the app's server is elsewhere. */
37
66
  function authClient(options = {}) {
38
- return createAuthClient({
39
- basePath: "/api/auth",
40
- ...options.baseURL ? { baseURL: options.baseURL } : {},
41
- plugins: authPlugins()
42
- });
67
+ const base = `${(options.baseURL ?? "").replace(/\/+$/, "")}/api/auth`;
68
+ const fetcher = options.fetch ?? ((input, init) => fetch(input, init));
69
+ const listeners = /* @__PURE__ */ new Set();
70
+ const changed = () => {
71
+ for (const listener of listeners) listener();
72
+ };
73
+ async function call(path, init = {}) {
74
+ const query = init.query ? `?${new URLSearchParams(Object.entries(init.query).filter((entry) => entry[1] !== void 0))}` : "";
75
+ const method = init.method ?? (init.body === void 0 ? "GET" : "POST");
76
+ const headers = {
77
+ accept: "application/json",
78
+ ...method === "POST" ? { "content-type": "application/json" } : {},
79
+ ...init.captcha ? { "x-captcha-response": init.captcha } : {}
80
+ };
81
+ const response = await fetcher(`${base}${path}${query}`, {
82
+ method,
83
+ headers,
84
+ credentials: "include",
85
+ ...method === "POST" ? { body: JSON.stringify(init.body ?? {}) } : {}
86
+ });
87
+ const text = await response.text();
88
+ const answer = text ? JSON.parse(text) : null;
89
+ if (!response.ok) {
90
+ const refused = answer ?? {};
91
+ throw new AuthClientError(refused.code ?? `HTTP_${response.status}`, refused.message ?? "Something went wrong. Try again.", response.status);
92
+ }
93
+ return answer;
94
+ }
95
+ const page = () => globalThis.location;
96
+ const go = (url) => {
97
+ page().href = url;
98
+ };
99
+ /** The signed query an MCP client's sign-in sent the person here with, which sign-in carries on from. */
100
+ const oauthQuery = () => {
101
+ const search = page()?.search ?? "";
102
+ return new URLSearchParams(search).has("sig") ? search.slice(1) : void 0;
103
+ };
104
+ const post = (path, body = {}, captcha) => {
105
+ const query = oauthQuery();
106
+ return call(path, {
107
+ body: query && !("oauth_query" in body) ? {
108
+ ...body,
109
+ oauth_query: query
110
+ } : body,
111
+ ...captcha ? { captcha } : {}
112
+ });
113
+ };
114
+ /** After signing in: on to the page that asks the person about an MCP client, when that is where they came from. */
115
+ const onward = (answer) => {
116
+ const next = answer;
117
+ if (next?.redirect && next.url) go(next.url);
118
+ };
119
+ return {
120
+ session: async () => await call("/get-session") ?? null,
121
+ settings: () => call("/settings"),
122
+ onChange(listener) {
123
+ listeners.add(listener);
124
+ return () => {
125
+ listeners.delete(listener);
126
+ };
127
+ },
128
+ async signUp(input) {
129
+ onward(await post("/sign-up/email", {
130
+ email: input.email,
131
+ password: input.password,
132
+ name: input.name
133
+ }, input.captcha));
134
+ changed();
135
+ },
136
+ signIn: {
137
+ async password(input) {
138
+ const answer = await post("/sign-in/email", {
139
+ email: input.email,
140
+ password: input.password
141
+ }, input.captcha);
142
+ if (answer?.twoFactorRedirect) return { twoFactor: true };
143
+ changed();
144
+ onward(answer);
145
+ return { signedIn: true };
146
+ },
147
+ code: {
148
+ async send(email, options = {}) {
149
+ await post("/email-otp/send-verification-otp", {
150
+ email,
151
+ type: "sign-in"
152
+ }, options.captcha);
153
+ },
154
+ async verify(email, code) {
155
+ onward(await post("/sign-in/email-otp", {
156
+ email,
157
+ otp: code
158
+ }));
159
+ changed();
160
+ }
161
+ },
162
+ async link(email, options = {}) {
163
+ await post("/sign-in/magic-link", {
164
+ email,
165
+ callbackURL: options.callbackURL ?? "/"
166
+ }, options.captcha);
167
+ },
168
+ async social(provider, options = {}) {
169
+ const answer = await post("/sign-in/social", {
170
+ provider,
171
+ callbackURL: options.callbackURL ?? "/"
172
+ });
173
+ if (answer?.url) go(answer.url);
174
+ },
175
+ async passkey() {
176
+ const asked = await call("/passkey/generate-authenticate-options");
177
+ const credential = await navigator.credentials.get({ publicKey: requestOptions(asked) });
178
+ if (!credential) throw new AuthClientError("PASSKEY_CANCELLED", "Signing in with a passkey was cancelled.", 400);
179
+ onward(await post("/passkey/verify-authentication", { response: credentialJson(credential) }));
180
+ changed();
181
+ }
182
+ },
183
+ async signOut() {
184
+ await post("/sign-out");
185
+ changed();
186
+ },
187
+ twoFactor: {
188
+ enable: (password) => post("/two-factor/enable", { password }),
189
+ async disable(password) {
190
+ await post("/two-factor/disable", { password });
191
+ },
192
+ async verifyTotp(code, options = {}) {
193
+ onward(await post("/two-factor/verify-totp", {
194
+ code,
195
+ trustDevice: options.trustDevice ?? false
196
+ }));
197
+ changed();
198
+ },
199
+ async sendCode() {
200
+ await post("/two-factor/send-otp");
201
+ },
202
+ async verifyCode(code) {
203
+ onward(await post("/two-factor/verify-otp", { code }));
204
+ changed();
205
+ },
206
+ async verifyBackupCode(code) {
207
+ onward(await post("/two-factor/verify-backup-code", { code }));
208
+ changed();
209
+ }
210
+ },
211
+ passkeys: {
212
+ list: () => call("/passkey/list-user-passkeys"),
213
+ async add(name) {
214
+ const asked = await call("/passkey/generate-register-options", { query: { name } });
215
+ const credential = await navigator.credentials.create({ publicKey: creationOptions(asked) });
216
+ if (!credential) throw new AuthClientError("PASSKEY_CANCELLED", "Adding a passkey was cancelled.", 400);
217
+ await post("/passkey/verify-registration", {
218
+ response: credentialJson(credential),
219
+ ...name ? { name } : {}
220
+ });
221
+ },
222
+ async remove(id) {
223
+ await post("/passkey/delete-passkey", { id });
224
+ }
225
+ },
226
+ sessions: {
227
+ list: () => call("/account/sessions"),
228
+ async revoke(token) {
229
+ await post("/revoke-session", { token });
230
+ },
231
+ async revokeOthers() {
232
+ await post("/revoke-other-sessions");
233
+ }
234
+ },
235
+ password: {
236
+ async change(input) {
237
+ await post("/change-password", {
238
+ currentPassword: input.current,
239
+ newPassword: input.next,
240
+ revokeOtherSessions: input.signOutOthers ?? false
241
+ });
242
+ },
243
+ async requestReset(email, options) {
244
+ await post("/request-password-reset", {
245
+ email,
246
+ redirectTo: options.redirectTo
247
+ }, options.captcha);
248
+ },
249
+ async reset(token, password) {
250
+ await post("/reset-password", {
251
+ token,
252
+ newPassword: password
253
+ });
254
+ }
255
+ },
256
+ profile: { async update(input) {
257
+ await post("/update-user", { ...input });
258
+ changed();
259
+ } },
260
+ keys: {
261
+ list: () => call("/account/keys"),
262
+ create: (input) => post("/account/keys", { ...input }),
263
+ async revoke(id) {
264
+ await post("/account/keys/revoke", { id });
265
+ }
266
+ },
267
+ grants: {
268
+ list: () => call("/account/grants"),
269
+ async revoke(id) {
270
+ await post("/account/grants/revoke", { id });
271
+ }
272
+ },
273
+ organizations: {
274
+ list: () => call("/organization/list"),
275
+ create: (input) => post("/organization/create", { ...input }),
276
+ async setActive(id) {
277
+ await post("/organization/set-active", { organizationId: id });
278
+ changed();
279
+ },
280
+ get: (id) => call("/organization/get-full-organization", { query: { organizationId: id } }),
281
+ async update(id, input) {
282
+ await post("/organization/update", {
283
+ organizationId: id,
284
+ data: input
285
+ });
286
+ },
287
+ async invite(id, input) {
288
+ await post("/organization/invite-member", {
289
+ organizationId: id,
290
+ email: input.email,
291
+ role: input.role
292
+ });
293
+ },
294
+ async cancelInvitation(invitationId) {
295
+ await post("/organization/cancel-invitation", { invitationId });
296
+ },
297
+ async removeMember(id, memberIdOrEmail) {
298
+ await post("/organization/remove-member", {
299
+ organizationId: id,
300
+ memberIdOrEmail
301
+ });
302
+ },
303
+ async setRole(id, memberId, role) {
304
+ await post("/organization/update-member-role", {
305
+ organizationId: id,
306
+ memberId,
307
+ role
308
+ });
309
+ },
310
+ async leave(id) {
311
+ await post("/organization/leave", { organizationId: id });
312
+ changed();
313
+ },
314
+ invitation: (invitationId) => call("/organization/get-invitation", { query: { id: invitationId } }),
315
+ async acceptInvitation(invitationId) {
316
+ await post("/organization/accept-invitation", { invitationId });
317
+ changed();
318
+ },
319
+ async rejectInvitation(invitationId) {
320
+ await post("/organization/reject-invitation", { invitationId });
321
+ }
322
+ }
323
+ };
43
324
  }
44
325
  //#endregion
45
- export { authClient, authPlugins };
326
+ export { AuthClientError, authClient };
@@ -1,5 +1,6 @@
1
+ import { n as AuthStore } from "../store-CeIGY-xT.mjs";
1
2
  import { SignInMail } from "./mail.mjs";
2
- import { Auth } from "./index.mjs";
3
+ import { i as Auth } from "../index-CsgQ_ouh.mjs";
3
4
  //#region src/auth/contract.d.ts
4
5
  interface AuthHarness {
5
6
  /** Sign-in over a store with no users, made with `scopes: CONTRACT_SCOPES`. */
@@ -8,6 +9,14 @@ interface AuthHarness {
8
9
  outbox(): ReadonlyArray<SignInMail>;
9
10
  /** How many calls reached the rows so far. */
10
11
  calls(): number;
12
+ /** The same rows, as the platform reads and writes them through `db/auth.ts`. */
13
+ readonly store: AuthStore;
14
+ /**
15
+ * Moves on the clock sign-in keeps its settings and rate limits by (`createAuth({ clock })`), by `ms`. The harness's
16
+ * sign-in also takes `password1234` as a leaked password, and a bot check's token `human` with the secret
17
+ * `CAPTCHA_SECRET` its environment holds.
18
+ */
19
+ later(ms: number): void;
11
20
  }
12
21
  interface AuthContractCase {
13
22
  readonly name: string;