@baliola/auth-sdk 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +40 -0
- package/README.md +56 -8
- package/dist/{authError-CUQ1rFAr.js → authError-BPxMHQK2.js} +32 -1
- package/dist/{authError-CDoEEOP_.d.ts → authError-E11ZMcID.d.ts} +16 -1
- package/dist/client/index.d.ts +2 -2
- package/dist/client/index.js +1 -1
- package/dist/{client-Bk9WIMVc.js → client-Dlhhdp-T.js} +29 -11
- package/dist/errors/index.d.ts +2 -2
- package/dist/errors/index.js +2 -2
- package/dist/{index-CFXMA6WD.d.ts → index-DwFEdFaS.d.ts} +41 -11
- package/dist/index.d.ts +6 -6
- package/dist/index.js +3 -3
- package/dist/{requests-C0WoK341.d.ts → roles-BZecOymZ.d.ts} +32 -2
- package/dist/{session-Cs_P7ojF.d.ts → session-flM0yXx2.d.ts} +6 -4
- package/dist/{sessionStore-BDdEpbL8.d.ts → sessionStore-D2kXjvNM.d.ts} +1 -1
- package/dist/store/index.d.ts +1 -1
- package/dist/types/index.d.ts +3 -3
- package/dist/wallet/index.d.ts +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,46 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to `@baliola/auth-sdk` are documented here.
|
|
4
4
|
|
|
5
|
+
## 0.7.0
|
|
6
|
+
|
|
7
|
+
Self-service roles and a stricter login contract. baliola-auth added `POST /auth/roles/apply` and
|
|
8
|
+
`GET /auth/roles/status` (issue #61), dropped `flow` and `methods` from the send-login-code
|
|
9
|
+
response so it can no longer reveal whether an email is registered, and is making `clientId`
|
|
10
|
+
mandatory on every login and register body (issue #60) so that only the Console client can mint a
|
|
11
|
+
token carrying global roles.
|
|
12
|
+
|
|
13
|
+
### New features
|
|
14
|
+
|
|
15
|
+
- feat(client): `auth.roles.apply({ roleName })` posts a self-service application for an
|
|
16
|
+
allowlisted global role and returns the account role row (`RoleApplicationStatus`);
|
|
17
|
+
`auth.roles.status()` returns one `RoleStatus` per self-applicable role, with `status: 'none'`
|
|
18
|
+
when the account never applied. Both need a session. Conflicts surface as `AuthError` with
|
|
19
|
+
`code` `role_already_active` or `application_pending`.
|
|
20
|
+
- feat(types): `ApplyRoleInput`, `RoleApplicationState`, `RoleApplicationStatus`, `RoleStatus`,
|
|
21
|
+
and `RolesNamespace` are exported from the root and the `./types` subpath.
|
|
22
|
+
- feat(errors): `ValidationError` (`code: 'validation_error'`, 400) with
|
|
23
|
+
`issues: ValidationIssue[]`, one `{ path, message }` per rejected request field.
|
|
24
|
+
baliola-auth now routes every request validation failure through the standard error
|
|
25
|
+
envelope under this code, so a login body without `clientId` or an `apply` with a role name
|
|
26
|
+
outside the allowlist is an `instanceof ValidationError`. Exported from the root and the
|
|
27
|
+
`./errors` subpath, together with the `ValidationIssue` type.
|
|
28
|
+
- Admin role management (`/admin/roles/*`: approve, revoke, list applications) is deliberately not
|
|
29
|
+
in this SDK. It is a client library for end-user apps; the Baliola Console keeps its own direct
|
|
30
|
+
client for `/admin/*`. This closes the open question on issue #61.
|
|
31
|
+
|
|
32
|
+
### Breaking changes
|
|
33
|
+
|
|
34
|
+
- feat(client)!: `clientId` is now a required option of `createAuthClient`. Construction throws
|
|
35
|
+
`Error('createAuthClient: clientId is required')` when it is missing or empty, the same way
|
|
36
|
+
`baseUrl` is handled. Every login and register body always carries it, and
|
|
37
|
+
`auth.google.startUrl` no longer has its own `clientId` check. The "central" multi-project login
|
|
38
|
+
that omitted `clientId` is gone on the server side, so there is nothing to migrate to: pass the
|
|
39
|
+
client id of the project the app belongs to.
|
|
40
|
+
- chore(types)!: `SendLoginCodeResult` is narrowed to `{ otp: OtpInfo }`. The `flow` and `methods`
|
|
41
|
+
fields are removed because the server no longer sends them (baliola-auth commit `7f29126`);
|
|
42
|
+
whether the email is a login or a signup is only known after `verifyLoginCode`.
|
|
43
|
+
- Per `RELEASING.md` these are pre-1.0 breaks shipped as a minor with this explicit callout.
|
|
44
|
+
|
|
5
45
|
## 0.6.0
|
|
6
46
|
|
|
7
47
|
Hosted Google login. baliola-auth now runs the Google OAuth round trip itself
|
package/README.md
CHANGED
|
@@ -31,7 +31,7 @@ import { createAuthClient, localStorageStore, OtpInvalidError } from '@baliola/a
|
|
|
31
31
|
|
|
32
32
|
const auth = createAuthClient({
|
|
33
33
|
baseUrl: AUTH_URL,
|
|
34
|
-
clientId: 'your-project-client-id', //
|
|
34
|
+
clientId: 'your-project-client-id', // required; scopes every login to this project
|
|
35
35
|
store: localStorageStore(), // omit for in-memory (server-side / tests)
|
|
36
36
|
});
|
|
37
37
|
await auth.loadSession(); // rehydrate from store at app boot
|
|
@@ -66,7 +66,7 @@ The SDK is namespaced by flow so that each method's purpose is unambiguous at th
|
|
|
66
66
|
|
|
67
67
|
```ts
|
|
68
68
|
auth.emailOtp.sendLoginCode({ email, captchaToken });
|
|
69
|
-
// → {
|
|
69
|
+
// → { otp: OtpInfo } (never says whether the email is registered)
|
|
70
70
|
|
|
71
71
|
auth.emailOtp.verifyLoginCode({ email, code });
|
|
72
72
|
// → AuthSession (also populates the session mirror)
|
|
@@ -143,7 +143,7 @@ import { createAuthClient } from '@baliola/auth-sdk';
|
|
|
143
143
|
import { createRemoteSigner } from '@baliola/auth-sdk/wallet';
|
|
144
144
|
import { toSmartAccount } from '@baliola/smart-account-sdk';
|
|
145
145
|
|
|
146
|
-
const auth = createAuthClient({ baseUrl });
|
|
146
|
+
const auth = createAuthClient({ baseUrl, clientId });
|
|
147
147
|
await auth.emailOtp.verifyLoginCode({ email, code }); // authenticated session
|
|
148
148
|
|
|
149
149
|
const owner = await createRemoteSigner(auth); // viem LocalAccount, signs server-side
|
|
@@ -152,6 +152,22 @@ const account = await toSmartAccount({ owner, chain: 'macTestnet' });
|
|
|
152
152
|
|
|
153
153
|
The private key never leaves baliola-auth; `owner.signMessage({ raw })` calls `POST /auth/wallet/sign`.
|
|
154
154
|
|
|
155
|
+
### `auth.roles` (self-service role applications)
|
|
156
|
+
|
|
157
|
+
```ts
|
|
158
|
+
const app = await auth.roles.apply({ roleName: 'module_deployer' }); // POST /auth/roles/apply
|
|
159
|
+
// app = { id, accountId, roleId, projectId, status: 'pending_approval', assignedBy, assignedAt, approvedAt, revokedAt }
|
|
160
|
+
|
|
161
|
+
const rows = await auth.roles.status(); // GET /auth/roles/status
|
|
162
|
+
// rows = [{ roleName, displayName, status: 'none'|'pending_approval'|'active'|'revoked', accountRoleId, assignedAt, approvedAt, revokedAt }]
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Both need a session. `apply` rejects with `AuthError` whose `code` is `role_already_active` or
|
|
166
|
+
`application_pending` (409) when there is nothing to do, and with a 400 when the role name is not
|
|
167
|
+
on the server's self-applicable allowlist (`ValidationError`, `issues[0].path === 'roleName'`). Approving, revoking, and listing applications are `/admin/*` endpoints and are
|
|
168
|
+
deliberately not part of this SDK; an admin surface such as the Baliola Console calls them with
|
|
169
|
+
its own client.
|
|
170
|
+
|
|
155
171
|
### Profile (identity read)
|
|
156
172
|
|
|
157
173
|
```ts
|
|
@@ -259,6 +275,7 @@ try {
|
|
|
259
275
|
| `RateLimitedError` | (legacy 429) | 429 | `retryAfterSeconds`, `retryAfterHuman` |
|
|
260
276
|
| `GoogleSignInCancelledError` | `oauth_cancelled` | 0 | `reason: 'popup_blocked'\|'popup_closed'\|'access_denied'` |
|
|
261
277
|
| `GoogleSignInError` | `invalid_google_code`, `email_unverified`, `invalid_oauth_state`, `oauth_unexpected`, `oauth_nonce_mismatch` | 401 / 400 / 0 | none |
|
|
278
|
+
| `ValidationError` | `validation_error` | 400 | `issues: { path, message }[]` |
|
|
262
279
|
| `AuthError` (base) | varies | varies | `status: 0` for network/timeout |
|
|
263
280
|
|
|
264
281
|
## Stores
|
|
@@ -282,7 +299,7 @@ Cross-tab sync (login / logout / refresh) is automatic via `BroadcastChannel`, r
|
|
|
282
299
|
```ts
|
|
283
300
|
createAuthClient({
|
|
284
301
|
baseUrl: AUTH_URL, // required, no trailing slash
|
|
285
|
-
clientId: 'your-project-client-id', //
|
|
302
|
+
clientId: 'your-project-client-id', // required; sent on every login and register body
|
|
286
303
|
store: memoryStore(), // default; or localStorageStore() / custom
|
|
287
304
|
fetch: globalThis.fetch, // override for tests / interceptors
|
|
288
305
|
timeoutMs: 15_000, // per-request, default 15s
|
|
@@ -291,7 +308,8 @@ createAuthClient({
|
|
|
291
308
|
});
|
|
292
309
|
```
|
|
293
310
|
|
|
294
|
-
`clientId` is constructor-only
|
|
311
|
+
`clientId` is constructor-only, there is no per-call override. To switch projects, create a new client.
|
|
312
|
+
`createAuthClient` throws a plain `Error` when `clientId` is missing or empty, the same way it does for `baseUrl`.
|
|
295
313
|
|
|
296
314
|
## Decoding the JWT
|
|
297
315
|
|
|
@@ -305,7 +323,7 @@ const session = auth.getSession();
|
|
|
305
323
|
if (session) {
|
|
306
324
|
const claims = decodeJwt<AccessTokenPayload>(session.accessToken);
|
|
307
325
|
// claims.accountId, claims.email
|
|
308
|
-
// claims.projects: { id, name, clientId }[] //
|
|
326
|
+
// claims.projects: { id, name, clientId }[] // the project the login was scoped to; the Console client also carries global roles
|
|
309
327
|
// claims.roles?: string[]; claims.permissions?: string[]
|
|
310
328
|
}
|
|
311
329
|
```
|
|
@@ -318,8 +336,6 @@ if (session) {
|
|
|
318
336
|
|
|
319
337
|
```json
|
|
320
338
|
{
|
|
321
|
-
"flow": "signup",
|
|
322
|
-
"methods": ["passwordless"],
|
|
323
339
|
"otp": {
|
|
324
340
|
"expiresInSeconds": 300,
|
|
325
341
|
"expiresAt": "2026-05-04T12:05:00.000Z",
|
|
@@ -365,6 +381,38 @@ if (session) {
|
|
|
365
381
|
}
|
|
366
382
|
```
|
|
367
383
|
|
|
384
|
+
**`auth.roles.apply` success (`RoleApplicationStatus`, HTTP 201):**
|
|
385
|
+
|
|
386
|
+
```json
|
|
387
|
+
{
|
|
388
|
+
"id": "6f1c2d3e-0000-4000-8000-000000000001",
|
|
389
|
+
"accountId": "6f1c2d3e-0000-4000-8000-0000000000aa",
|
|
390
|
+
"roleId": "6f1c2d3e-0000-4000-8000-0000000000bb",
|
|
391
|
+
"projectId": null,
|
|
392
|
+
"status": "pending_approval",
|
|
393
|
+
"assignedBy": null,
|
|
394
|
+
"assignedAt": "2026-09-04T00:00:00.000Z",
|
|
395
|
+
"approvedAt": null,
|
|
396
|
+
"revokedAt": null
|
|
397
|
+
}
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
**`auth.roles.status` success (`RoleStatus[]`):**
|
|
401
|
+
|
|
402
|
+
```json
|
|
403
|
+
[
|
|
404
|
+
{
|
|
405
|
+
"roleName": "module_deployer",
|
|
406
|
+
"displayName": "Module Deployer",
|
|
407
|
+
"status": "none",
|
|
408
|
+
"accountRoleId": null,
|
|
409
|
+
"assignedAt": null,
|
|
410
|
+
"approvedAt": null,
|
|
411
|
+
"revokedAt": null
|
|
412
|
+
}
|
|
413
|
+
]
|
|
414
|
+
```
|
|
415
|
+
|
|
368
416
|
**Verify-code failure (e.g. `OtpInvalidError`):**
|
|
369
417
|
|
|
370
418
|
```json
|
|
@@ -167,6 +167,18 @@ var GoogleSignInError = class extends AuthError {
|
|
|
167
167
|
this.name = "GoogleSignInError";
|
|
168
168
|
}
|
|
169
169
|
};
|
|
170
|
+
/**
|
|
171
|
+
* Request validation failed. Thrown for `validation_error` (400) on any
|
|
172
|
+
* endpoint; `issues` names each rejected field.
|
|
173
|
+
*/
|
|
174
|
+
var ValidationError = class extends AuthError {
|
|
175
|
+
issues;
|
|
176
|
+
constructor(init) {
|
|
177
|
+
super(init);
|
|
178
|
+
this.name = "ValidationError";
|
|
179
|
+
this.issues = init.issues;
|
|
180
|
+
}
|
|
181
|
+
};
|
|
170
182
|
function num(d, key, fallback = 0) {
|
|
171
183
|
const v = d?.[key];
|
|
172
184
|
return typeof v === "number" ? v : fallback;
|
|
@@ -175,6 +187,21 @@ function str(d, key, fallback = "") {
|
|
|
175
187
|
const v = d?.[key];
|
|
176
188
|
return typeof v === "string" ? v : fallback;
|
|
177
189
|
}
|
|
190
|
+
function issues(d) {
|
|
191
|
+
const raw = d?.["issues"];
|
|
192
|
+
if (!Array.isArray(raw)) return [];
|
|
193
|
+
const out = [];
|
|
194
|
+
for (const entry of raw) {
|
|
195
|
+
if (typeof entry !== "object" || entry === null) continue;
|
|
196
|
+
const record = entry;
|
|
197
|
+
if (typeof record["path"] !== "string" || typeof record["message"] !== "string") continue;
|
|
198
|
+
out.push({
|
|
199
|
+
path: record["path"],
|
|
200
|
+
message: record["message"]
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
return out;
|
|
204
|
+
}
|
|
178
205
|
/**
|
|
179
206
|
* Map a backend error response onto the right AuthError subclass.
|
|
180
207
|
* Falls back to `AuthError` (with status + code preserved) for unknown codes.
|
|
@@ -230,6 +257,10 @@ async function authErrorFromResponse(response) {
|
|
|
230
257
|
...init,
|
|
231
258
|
code
|
|
232
259
|
});
|
|
260
|
+
case "validation_error": return new ValidationError({
|
|
261
|
+
...init,
|
|
262
|
+
issues: issues(details)
|
|
263
|
+
});
|
|
233
264
|
default:
|
|
234
265
|
if (response.status === 429) {
|
|
235
266
|
const retryAfterSeconds = num(details, "retryAfter") || num(details, "retryAfterSeconds") || Number(response.headers.get("Retry-After") ?? 0);
|
|
@@ -253,4 +284,4 @@ function authErrorFromFetchFailure(cause, isTimeout = false) {
|
|
|
253
284
|
});
|
|
254
285
|
}
|
|
255
286
|
//#endregion
|
|
256
|
-
export { ResendCooldownError as _, GoogleSignInCancelledError as a, InvalidEmailError as c, MaxResendsError as d, NoPasswordSetError as f, RateLimitedError as g, OtpInvalidError as h, EmailAlreadyHasPasswordError as i, InvalidPasswordError as l, OtpExpiredError as m, AuthError as n, GoogleSignInError as o, NoPendingOtpError as p, CaptchaFailedError as r, InvalidCredentialsError as s, AccountSuspendedError as t, MaxAttemptsError as u,
|
|
287
|
+
export { ResendCooldownError as _, GoogleSignInCancelledError as a, authErrorFromResponse as b, InvalidEmailError as c, MaxResendsError as d, NoPasswordSetError as f, RateLimitedError as g, OtpInvalidError as h, EmailAlreadyHasPasswordError as i, InvalidPasswordError as l, OtpExpiredError as m, AuthError as n, GoogleSignInError as o, NoPendingOtpError as p, CaptchaFailedError as r, InvalidCredentialsError as s, AccountSuspendedError as t, MaxAttemptsError as u, ValidationError as v, authErrorFromFetchFailure as y };
|
|
@@ -118,6 +118,21 @@ declare class GoogleSignInError extends AuthError {
|
|
|
118
118
|
code: string;
|
|
119
119
|
} & Partial<AuthErrorInit>);
|
|
120
120
|
}
|
|
121
|
+
/** One failing request field, as reported by the server's validation hook. */
|
|
122
|
+
type ValidationIssue = {
|
|
123
|
+
/** Dot-joined path of the field, for example `clientId` or `otp`. */path: string;
|
|
124
|
+
message: string;
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* Request validation failed. Thrown for `validation_error` (400) on any
|
|
128
|
+
* endpoint; `issues` names each rejected field.
|
|
129
|
+
*/
|
|
130
|
+
declare class ValidationError extends AuthError {
|
|
131
|
+
readonly issues: ValidationIssue[];
|
|
132
|
+
constructor(init: AuthErrorInit & {
|
|
133
|
+
issues: ValidationIssue[];
|
|
134
|
+
});
|
|
135
|
+
}
|
|
121
136
|
/**
|
|
122
137
|
* Map a backend error response onto the right AuthError subclass.
|
|
123
138
|
* Falls back to `AuthError` (with status + code preserved) for unknown codes.
|
|
@@ -126,4 +141,4 @@ declare function authErrorFromResponse(response: Response): Promise<AuthError>;
|
|
|
126
141
|
/** Network/timeout failures land here. */
|
|
127
142
|
declare function authErrorFromFetchFailure(cause: unknown, isTimeout?: boolean): AuthError;
|
|
128
143
|
//#endregion
|
|
129
|
-
export { OtpInvalidError as _, EmailAlreadyHasPasswordError as a,
|
|
144
|
+
export { authErrorFromResponse as C, authErrorFromFetchFailure as S, OtpInvalidError as _, EmailAlreadyHasPasswordError as a, ValidationError as b, GoogleSignInError as c, InvalidPasswordError as d, MaxAttemptsError as f, OtpExpiredError as g, NoPendingOtpError as h, CaptchaFailedError as i, InvalidCredentialsError as l, NoPasswordSetError as m, AuthError as n, GoogleSignInCancelledError as o, MaxResendsError as p, AuthErrorInit as r, GoogleSignInCancelledReason as s, AccountSuspendedError as t, InvalidEmailError as u, RateLimitedError as v, ValidationIssue as x, ResendCooldownError as y };
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as GoogleNamespace, c as
|
|
2
|
-
export { AuthClient, AuthFetchInit, CreateAuthClientOptions, EmailOtpNamespace, EmailPasswordNamespace, GoogleNamespace, ProactiveRefreshConfig, SubscribeOptions, WalletNamespace, createAuthClient };
|
|
1
|
+
import { a as GoogleNamespace, c as SubscribeOptions, d as AuthFetchInit, i as EmailPasswordNamespace, l as WalletNamespace, n as CreateAuthClientOptions, o as ProactiveRefreshConfig, r as EmailOtpNamespace, s as RolesNamespace, t as AuthClient, u as createAuthClient } from "../index-DwFEdFaS.js";
|
|
2
|
+
export { AuthClient, AuthFetchInit, CreateAuthClientOptions, EmailOtpNamespace, EmailPasswordNamespace, GoogleNamespace, ProactiveRefreshConfig, RolesNamespace, SubscribeOptions, WalletNamespace, createAuthClient };
|
package/dist/client/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as createAuthClient } from "../client-
|
|
1
|
+
import { t as createAuthClient } from "../client-Dlhhdp-T.js";
|
|
2
2
|
export { createAuthClient };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as GoogleSignInCancelledError,
|
|
1
|
+
import { a as GoogleSignInCancelledError, b as authErrorFromResponse, n as AuthError, o as GoogleSignInError, y as authErrorFromFetchFailure } from "./authError-BPxMHQK2.js";
|
|
2
2
|
import { n as memoryStore } from "./sessionStore-DD6lON9W.js";
|
|
3
3
|
//#region src/client/googleHosted.ts
|
|
4
4
|
const NONCE_STORAGE_KEY = "baliola-auth:google:nonce";
|
|
@@ -48,7 +48,6 @@ function createGoogleHosted(ctx) {
|
|
|
48
48
|
globalThis.sessionStorage.setItem(NONCE_STORAGE_KEY, nonce);
|
|
49
49
|
}
|
|
50
50
|
function startUrl(opts) {
|
|
51
|
-
if (ctx.clientId === void 0) throw new Error("google.startUrl: clientId is required");
|
|
52
51
|
const url = new URL(`${ctx.baseUrl}/auth/google/start`);
|
|
53
52
|
url.searchParams.set("clientId", ctx.clientId);
|
|
54
53
|
url.searchParams.set("returnTo", resolveReturnTo(opts.returnTo));
|
|
@@ -154,13 +153,10 @@ function toAuthSession(data) {
|
|
|
154
153
|
};
|
|
155
154
|
}
|
|
156
155
|
function createMethods(ctx) {
|
|
157
|
-
const withClientId = (body) => {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
clientId: ctx.clientId
|
|
162
|
-
};
|
|
163
|
-
};
|
|
156
|
+
const withClientId = (body) => ({
|
|
157
|
+
...body,
|
|
158
|
+
clientId: ctx.clientId
|
|
159
|
+
});
|
|
164
160
|
return {
|
|
165
161
|
/** emailOtp.* (passwordless) */
|
|
166
162
|
async sendLoginCode(input) {
|
|
@@ -295,6 +291,22 @@ function createMethods(ctx) {
|
|
|
295
291
|
body: { hash }
|
|
296
292
|
});
|
|
297
293
|
},
|
|
294
|
+
/** roles.* */
|
|
295
|
+
async applyRole(input) {
|
|
296
|
+
return ctx.transport.request({
|
|
297
|
+
path: "/auth/roles/apply",
|
|
298
|
+
method: "POST",
|
|
299
|
+
authMode: "bearer+session",
|
|
300
|
+
body: { roleName: input.roleName }
|
|
301
|
+
});
|
|
302
|
+
},
|
|
303
|
+
async getRoleStatus() {
|
|
304
|
+
return ctx.transport.request({
|
|
305
|
+
path: "/auth/roles/status",
|
|
306
|
+
method: "GET",
|
|
307
|
+
authMode: "bearer+session"
|
|
308
|
+
});
|
|
309
|
+
},
|
|
298
310
|
/** profile */
|
|
299
311
|
async getProfile() {
|
|
300
312
|
return ctx.transport.request({
|
|
@@ -527,7 +539,9 @@ const DEFAULT_PROACTIVE_LEAD_TIME_MS = 6e4;
|
|
|
527
539
|
const BROADCAST_CHANNEL_NAME = "baliola.auth.session.v1";
|
|
528
540
|
function createAuthClient(options) {
|
|
529
541
|
if (!options.baseUrl) throw new Error("createAuthClient: baseUrl is required");
|
|
542
|
+
if (!options.clientId) throw new Error("createAuthClient: clientId is required");
|
|
530
543
|
const baseUrl = options.baseUrl.replace(/\/+$/, "");
|
|
544
|
+
const clientId = options.clientId;
|
|
531
545
|
const store = options.store ?? memoryStore();
|
|
532
546
|
const fetchImpl = options.fetch ?? ((input, init) => globalThis.fetch(input, init));
|
|
533
547
|
const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
@@ -585,7 +599,7 @@ function createAuthClient(options) {
|
|
|
585
599
|
});
|
|
586
600
|
const methods = createMethods({
|
|
587
601
|
transport,
|
|
588
|
-
|
|
602
|
+
clientId
|
|
589
603
|
});
|
|
590
604
|
const emailOtp = {
|
|
591
605
|
sendLoginCode: (input) => methods.sendLoginCode(input),
|
|
@@ -619,7 +633,7 @@ function createAuthClient(options) {
|
|
|
619
633
|
}
|
|
620
634
|
const googleHosted = createGoogleHosted({
|
|
621
635
|
baseUrl,
|
|
622
|
-
|
|
636
|
+
clientId,
|
|
623
637
|
exchange: googleExchange
|
|
624
638
|
});
|
|
625
639
|
return {
|
|
@@ -636,6 +650,10 @@ function createAuthClient(options) {
|
|
|
636
650
|
signInWithPopup: (opts) => googleHosted.signInWithPopup(opts),
|
|
637
651
|
completeRedirect: (opts) => googleHosted.completeRedirect(opts)
|
|
638
652
|
},
|
|
653
|
+
roles: {
|
|
654
|
+
apply: (input) => methods.applyRole(input),
|
|
655
|
+
status: () => methods.getRoleStatus()
|
|
656
|
+
},
|
|
639
657
|
wallet: {
|
|
640
658
|
getAddress: async () => (await methods.getWalletAddress()).address,
|
|
641
659
|
signHash: async (hash) => (await methods.signWalletHash(hash)).signature
|
package/dist/errors/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as OtpInvalidError, a as EmailAlreadyHasPasswordError, b as
|
|
2
|
-
export { AccountSuspendedError, AuthError, type AuthErrorInit, CaptchaFailedError, EmailAlreadyHasPasswordError, GoogleSignInCancelledError, type GoogleSignInCancelledReason, GoogleSignInError, InvalidCredentialsError, InvalidEmailError, InvalidPasswordError, MaxAttemptsError, MaxResendsError, NoPasswordSetError, NoPendingOtpError, OtpExpiredError, OtpInvalidError, RateLimitedError, ResendCooldownError, authErrorFromFetchFailure, authErrorFromResponse };
|
|
1
|
+
import { C as authErrorFromResponse, S as authErrorFromFetchFailure, _ as OtpInvalidError, a as EmailAlreadyHasPasswordError, b as ValidationError, c as GoogleSignInError, d as InvalidPasswordError, f as MaxAttemptsError, g as OtpExpiredError, h as NoPendingOtpError, i as CaptchaFailedError, l as InvalidCredentialsError, m as NoPasswordSetError, n as AuthError, o as GoogleSignInCancelledError, p as MaxResendsError, r as AuthErrorInit, s as GoogleSignInCancelledReason, t as AccountSuspendedError, u as InvalidEmailError, v as RateLimitedError, x as ValidationIssue, y as ResendCooldownError } from "../authError-E11ZMcID.js";
|
|
2
|
+
export { AccountSuspendedError, AuthError, type AuthErrorInit, CaptchaFailedError, EmailAlreadyHasPasswordError, GoogleSignInCancelledError, type GoogleSignInCancelledReason, GoogleSignInError, InvalidCredentialsError, InvalidEmailError, InvalidPasswordError, MaxAttemptsError, MaxResendsError, NoPasswordSetError, NoPendingOtpError, OtpExpiredError, OtpInvalidError, RateLimitedError, ResendCooldownError, ValidationError, type ValidationIssue, authErrorFromFetchFailure, authErrorFromResponse };
|
package/dist/errors/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as ResendCooldownError, a as GoogleSignInCancelledError, c as InvalidEmailError, d as MaxResendsError, f as NoPasswordSetError, g as RateLimitedError, h as OtpInvalidError, i as EmailAlreadyHasPasswordError, l as InvalidPasswordError, m as OtpExpiredError, n as AuthError, o as GoogleSignInError, p as NoPendingOtpError, r as CaptchaFailedError, s as InvalidCredentialsError, t as AccountSuspendedError, u as MaxAttemptsError, v as
|
|
2
|
-
export { AccountSuspendedError, AuthError, CaptchaFailedError, EmailAlreadyHasPasswordError, GoogleSignInCancelledError, GoogleSignInError, InvalidCredentialsError, InvalidEmailError, InvalidPasswordError, MaxAttemptsError, MaxResendsError, NoPasswordSetError, NoPendingOtpError, OtpExpiredError, OtpInvalidError, RateLimitedError, ResendCooldownError, authErrorFromFetchFailure, authErrorFromResponse };
|
|
1
|
+
import { _ as ResendCooldownError, a as GoogleSignInCancelledError, b as authErrorFromResponse, c as InvalidEmailError, d as MaxResendsError, f as NoPasswordSetError, g as RateLimitedError, h as OtpInvalidError, i as EmailAlreadyHasPasswordError, l as InvalidPasswordError, m as OtpExpiredError, n as AuthError, o as GoogleSignInError, p as NoPendingOtpError, r as CaptchaFailedError, s as InvalidCredentialsError, t as AccountSuspendedError, u as MaxAttemptsError, v as ValidationError, y as authErrorFromFetchFailure } from "../authError-BPxMHQK2.js";
|
|
2
|
+
export { AccountSuspendedError, AuthError, CaptchaFailedError, EmailAlreadyHasPasswordError, GoogleSignInCancelledError, GoogleSignInError, InvalidCredentialsError, InvalidEmailError, InvalidPasswordError, MaxAttemptsError, MaxResendsError, NoPasswordSetError, NoPendingOtpError, OtpExpiredError, OtpInvalidError, RateLimitedError, ResendCooldownError, ValidationError, authErrorFromFetchFailure, authErrorFromResponse };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { c as ResendCodeResult, l as SendLoginCodeResult, n as AuthSession, r as ErrorHandler, s as RegisterResult, u as SessionChangeHandler } from "./session-
|
|
2
|
-
import { n as SessionStore } from "./sessionStore-
|
|
3
|
-
import {
|
|
1
|
+
import { c as ResendCodeResult, l as SendLoginCodeResult, n as AuthSession, r as ErrorHandler, s as RegisterResult, u as SessionChangeHandler } from "./session-flM0yXx2.js";
|
|
2
|
+
import { n as SessionStore } from "./sessionStore-D2kXjvNM.js";
|
|
3
|
+
import { C as ProfileResult, _ as SendLoginCodeInput, b as VerifyRegistrationCodeInput, c as GoogleExchangeInput, d as GoogleStartOptions, f as LoginWithGoogleInput, g as ResendRegistrationCodeInput, h as ResendLoginCodeInput, i as RoleStatus, l as GoogleSignInWithPopupOptions, m as RegisterInput, o as ChangePasswordInput, p as LoginWithPasswordInput, r as RoleApplicationStatus, s as GoogleCompleteRedirectOptions, t as ApplyRoleInput, v as SetPasswordInput, y as VerifyLoginCodeInput } from "./roles-BZecOymZ.js";
|
|
4
4
|
|
|
5
5
|
//#region src/client/transport.d.ts
|
|
6
6
|
type FetchLike = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
@@ -31,8 +31,13 @@ type ProactiveRefreshConfig = false | {
|
|
|
31
31
|
/** Refresh proactively if `expiresAt - now < leadTimeMs`. Defaults to 60_000 (60s). */leadTimeMs?: number;
|
|
32
32
|
};
|
|
33
33
|
type CreateAuthClientOptions = {
|
|
34
|
-
/** Base URL of the Baliola Auth server (no trailing slash). */baseUrl: string;
|
|
35
|
-
|
|
34
|
+
/** Base URL of the Baliola Auth server (no trailing slash). */baseUrl: string;
|
|
35
|
+
/**
|
|
36
|
+
* The project's client id. Sent on every login and register body and used
|
|
37
|
+
* to build the hosted Google login URL. baliola-auth rejects login and
|
|
38
|
+
* register requests without one.
|
|
39
|
+
*/
|
|
40
|
+
clientId: string;
|
|
36
41
|
/**
|
|
37
42
|
* Pluggable session store. Defaults to `memoryStore()`. Use
|
|
38
43
|
* `localStorageStore()` in browsers for persistence across reloads.
|
|
@@ -65,10 +70,12 @@ type EmailOtpNamespace = {
|
|
|
65
70
|
* Send a 6-digit one-time code to the email. Used for passwordless
|
|
66
71
|
* login (existing accounts) or signup (creates a new account on verify).
|
|
67
72
|
*
|
|
73
|
+
* The response never says whether the email is registered; the login
|
|
74
|
+
* versus signup branch is resolved by `verifyLoginCode`.
|
|
75
|
+
*
|
|
68
76
|
* @example
|
|
69
77
|
* const r = await auth.emailOtp.sendLoginCode({ email, captchaToken })
|
|
70
|
-
* // r = {
|
|
71
|
-
* // otp: { expiresInSeconds, expiresAt, canResendInSeconds, resendsRemaining } }
|
|
78
|
+
* // r = { otp: { expiresInSeconds, expiresAt, canResendInSeconds, resendsRemaining } }
|
|
72
79
|
*
|
|
73
80
|
* @throws CaptchaFailedError, RateLimitedError, InvalidEmailError, AuthError.
|
|
74
81
|
*/
|
|
@@ -133,9 +140,8 @@ type GoogleNamespace = {
|
|
|
133
140
|
* popup. In `redirect` mode the nonce is saved in `sessionStorage` for
|
|
134
141
|
* `completeRedirect` to verify.
|
|
135
142
|
*
|
|
136
|
-
* @throws Error when
|
|
137
|
-
*
|
|
138
|
-
* in `redirect` mode.
|
|
143
|
+
* @throws Error when `returnTo` is relative outside a browser, or when
|
|
144
|
+
* `sessionStorage` is missing in `redirect` mode.
|
|
139
145
|
*/
|
|
140
146
|
startUrl(opts: GoogleStartOptions & {
|
|
141
147
|
nonce: string;
|
|
@@ -183,6 +189,29 @@ type GoogleNamespace = {
|
|
|
183
189
|
*/
|
|
184
190
|
completeRedirect(opts?: GoogleCompleteRedirectOptions): Promise<AuthSession | null>;
|
|
185
191
|
};
|
|
192
|
+
/** Self-service role applications (`/auth/roles/*`). */
|
|
193
|
+
type RolesNamespace = {
|
|
194
|
+
/**
|
|
195
|
+
* Apply for a self-applicable global role. The application lands at
|
|
196
|
+
* `pending_approval` until an admin approves it.
|
|
197
|
+
*
|
|
198
|
+
* @throws AuthError with `code` `role_already_active` or
|
|
199
|
+
* `application_pending` (409), `role_not_self_applicable` (403),
|
|
200
|
+
* a 400 for a role name outside the allowlist, a 401 for a missing
|
|
201
|
+
* or expired session, and other API errors.
|
|
202
|
+
* @example
|
|
203
|
+
* const app = await auth.roles.apply({ roleName: 'module_deployer' });
|
|
204
|
+
* // app.status === 'pending_approval'
|
|
205
|
+
*/
|
|
206
|
+
apply(input: ApplyRoleInput): Promise<RoleApplicationStatus>;
|
|
207
|
+
/**
|
|
208
|
+
* Application status for every self-applicable role. Always one row per
|
|
209
|
+
* role; `status` is `none` when the account has never applied.
|
|
210
|
+
*
|
|
211
|
+
* @throws AuthError on 401 (missing or expired session) and other API errors.
|
|
212
|
+
*/
|
|
213
|
+
status(): Promise<RoleStatus[]>;
|
|
214
|
+
};
|
|
186
215
|
/** Custodial wallet (Console tier). */
|
|
187
216
|
type WalletNamespace = {
|
|
188
217
|
/** The account's custodial EOA address (provisioned on first read). */getAddress(): Promise<string>; /** Sign a 32-byte userOp hash; returns a 65-byte recoverable signature. */
|
|
@@ -192,6 +221,7 @@ type AuthClient = {
|
|
|
192
221
|
emailOtp: EmailOtpNamespace;
|
|
193
222
|
emailPassword: EmailPasswordNamespace;
|
|
194
223
|
google: GoogleNamespace;
|
|
224
|
+
roles: RolesNamespace;
|
|
195
225
|
wallet: WalletNamespace;
|
|
196
226
|
/**
|
|
197
227
|
* Fetch the token holder's identity: account (id, email, live status,
|
|
@@ -218,4 +248,4 @@ type AuthClient = {
|
|
|
218
248
|
};
|
|
219
249
|
declare function createAuthClient(options: CreateAuthClientOptions): AuthClient;
|
|
220
250
|
//#endregion
|
|
221
|
-
export { GoogleNamespace as a,
|
|
251
|
+
export { GoogleNamespace as a, SubscribeOptions as c, AuthFetchInit as d, EmailPasswordNamespace as i, WalletNamespace as l, CreateAuthClientOptions as n, ProactiveRefreshConfig as o, EmailOtpNamespace as r, RolesNamespace as s, AuthClient as t, createAuthClient as u };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { a as OtpInfo, c as ResendCodeResult, i as ErrorSource, l as SendLoginCodeResult, n as AuthSession, o as Project, r as ErrorHandler, s as RegisterResult, t as Account, u as SessionChangeHandler } from "./session-
|
|
2
|
-
import { a as GoogleNamespace, c as
|
|
3
|
-
import { i as memoryStore, n as SessionStore, r as localStorageStore, t as LocalStorageStoreOptions } from "./sessionStore-
|
|
4
|
-
import { _ as
|
|
5
|
-
import { _ as OtpInvalidError, a as EmailAlreadyHasPasswordError, b as
|
|
1
|
+
import { a as OtpInfo, c as ResendCodeResult, i as ErrorSource, l as SendLoginCodeResult, n as AuthSession, o as Project, r as ErrorHandler, s as RegisterResult, t as Account, u as SessionChangeHandler } from "./session-flM0yXx2.js";
|
|
2
|
+
import { a as GoogleNamespace, c as SubscribeOptions, d as AuthFetchInit, i as EmailPasswordNamespace, l as WalletNamespace, n as CreateAuthClientOptions, o as ProactiveRefreshConfig, r as EmailOtpNamespace, s as RolesNamespace, t as AuthClient, u as createAuthClient } from "./index-DwFEdFaS.js";
|
|
3
|
+
import { i as memoryStore, n as SessionStore, r as localStorageStore, t as LocalStorageStoreOptions } from "./sessionStore-D2kXjvNM.js";
|
|
4
|
+
import { C as ProfileResult, S as ProfileAccount, _ as SendLoginCodeInput, a as CaptchaArgs, b as VerifyRegistrationCodeInput, c as GoogleExchangeInput, d as GoogleStartOptions, f as LoginWithGoogleInput, g as ResendRegistrationCodeInput, h as ResendLoginCodeInput, i as RoleStatus, l as GoogleSignInWithPopupOptions, m as RegisterInput, n as RoleApplicationState, o as ChangePasswordInput, p as LoginWithPasswordInput, r as RoleApplicationStatus, s as GoogleCompleteRedirectOptions, t as ApplyRoleInput, u as GoogleStartMode, v as SetPasswordInput, x as Profile, y as VerifyLoginCodeInput } from "./roles-BZecOymZ.js";
|
|
5
|
+
import { C as authErrorFromResponse, S as authErrorFromFetchFailure, _ as OtpInvalidError, a as EmailAlreadyHasPasswordError, b as ValidationError, c as GoogleSignInError, d as InvalidPasswordError, f as MaxAttemptsError, g as OtpExpiredError, h as NoPendingOtpError, i as CaptchaFailedError, l as InvalidCredentialsError, m as NoPasswordSetError, n as AuthError, o as GoogleSignInCancelledError, p as MaxResendsError, r as AuthErrorInit, s as GoogleSignInCancelledReason, t as AccountSuspendedError, u as InvalidEmailError, v as RateLimitedError, x as ValidationIssue, y as ResendCooldownError } from "./authError-E11ZMcID.js";
|
|
6
6
|
import { n as AccessTokenPayloadProject, t as AccessTokenPayload } from "./tokens-BXrPLi5B.js";
|
|
7
7
|
|
|
8
8
|
//#region src/types/wallet.d.ts
|
|
@@ -16,4 +16,4 @@ type SignHashResult = {
|
|
|
16
16
|
address: string;
|
|
17
17
|
};
|
|
18
18
|
//#endregion
|
|
19
|
-
export { type AccessTokenPayload, type AccessTokenPayloadProject, type Account, AccountSuspendedError, type AuthClient, AuthError, type AuthErrorInit, type AuthFetchInit, type AuthSession, type CaptchaArgs, CaptchaFailedError, type ChangePasswordInput, type CreateAuthClientOptions, EmailAlreadyHasPasswordError, type EmailOtpNamespace, type EmailPasswordNamespace, type ErrorHandler, type ErrorSource, type GoogleCompleteRedirectOptions, type GoogleExchangeInput, type GoogleNamespace, GoogleSignInCancelledError, type GoogleSignInCancelledReason, GoogleSignInError, type GoogleSignInWithPopupOptions, type GoogleStartMode, type GoogleStartOptions, InvalidCredentialsError, InvalidEmailError, InvalidPasswordError, type LocalStorageStoreOptions, type LoginWithGoogleInput, type LoginWithPasswordInput, MaxAttemptsError, MaxResendsError, NoPasswordSetError, NoPendingOtpError, OtpExpiredError, type OtpInfo, OtpInvalidError, type ProactiveRefreshConfig, type Profile, type ProfileAccount, type ProfileResult, type Project, RateLimitedError, type RegisterInput, type RegisterResult, type ResendCodeResult, ResendCooldownError, type ResendLoginCodeInput, type ResendRegistrationCodeInput, type SendLoginCodeInput, type SendLoginCodeResult, type SessionChangeHandler, type SessionStore, type SetPasswordInput, type SignHashResult, type SubscribeOptions, type VerifyLoginCodeInput, type VerifyRegistrationCodeInput, type WalletAddressResult, type WalletNamespace, authErrorFromFetchFailure, authErrorFromResponse, createAuthClient, localStorageStore, memoryStore };
|
|
19
|
+
export { type AccessTokenPayload, type AccessTokenPayloadProject, type Account, AccountSuspendedError, type ApplyRoleInput, type AuthClient, AuthError, type AuthErrorInit, type AuthFetchInit, type AuthSession, type CaptchaArgs, CaptchaFailedError, type ChangePasswordInput, type CreateAuthClientOptions, EmailAlreadyHasPasswordError, type EmailOtpNamespace, type EmailPasswordNamespace, type ErrorHandler, type ErrorSource, type GoogleCompleteRedirectOptions, type GoogleExchangeInput, type GoogleNamespace, GoogleSignInCancelledError, type GoogleSignInCancelledReason, GoogleSignInError, type GoogleSignInWithPopupOptions, type GoogleStartMode, type GoogleStartOptions, InvalidCredentialsError, InvalidEmailError, InvalidPasswordError, type LocalStorageStoreOptions, type LoginWithGoogleInput, type LoginWithPasswordInput, MaxAttemptsError, MaxResendsError, NoPasswordSetError, NoPendingOtpError, OtpExpiredError, type OtpInfo, OtpInvalidError, type ProactiveRefreshConfig, type Profile, type ProfileAccount, type ProfileResult, type Project, RateLimitedError, type RegisterInput, type RegisterResult, type ResendCodeResult, ResendCooldownError, type ResendLoginCodeInput, type ResendRegistrationCodeInput, type RoleApplicationState, type RoleApplicationStatus, type RoleStatus, type RolesNamespace, type SendLoginCodeInput, type SendLoginCodeResult, type SessionChangeHandler, type SessionStore, type SetPasswordInput, type SignHashResult, type SubscribeOptions, ValidationError, type ValidationIssue, type VerifyLoginCodeInput, type VerifyRegistrationCodeInput, type WalletAddressResult, type WalletNamespace, authErrorFromFetchFailure, authErrorFromResponse, createAuthClient, localStorageStore, memoryStore };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as ResendCooldownError, a as GoogleSignInCancelledError, c as InvalidEmailError, d as MaxResendsError, f as NoPasswordSetError, g as RateLimitedError, h as OtpInvalidError, i as EmailAlreadyHasPasswordError, l as InvalidPasswordError, m as OtpExpiredError, n as AuthError, o as GoogleSignInError, p as NoPendingOtpError, r as CaptchaFailedError, s as InvalidCredentialsError, t as AccountSuspendedError, u as MaxAttemptsError, v as
|
|
2
|
-
import { t as createAuthClient } from "./client-
|
|
1
|
+
import { _ as ResendCooldownError, a as GoogleSignInCancelledError, b as authErrorFromResponse, c as InvalidEmailError, d as MaxResendsError, f as NoPasswordSetError, g as RateLimitedError, h as OtpInvalidError, i as EmailAlreadyHasPasswordError, l as InvalidPasswordError, m as OtpExpiredError, n as AuthError, o as GoogleSignInError, p as NoPendingOtpError, r as CaptchaFailedError, s as InvalidCredentialsError, t as AccountSuspendedError, u as MaxAttemptsError, v as ValidationError, y as authErrorFromFetchFailure } from "./authError-BPxMHQK2.js";
|
|
2
|
+
import { t as createAuthClient } from "./client-Dlhhdp-T.js";
|
|
3
3
|
import { n as memoryStore, t as localStorageStore } from "./sessionStore-DD6lON9W.js";
|
|
4
|
-
export { AccountSuspendedError, AuthError, CaptchaFailedError, EmailAlreadyHasPasswordError, GoogleSignInCancelledError, GoogleSignInError, InvalidCredentialsError, InvalidEmailError, InvalidPasswordError, MaxAttemptsError, MaxResendsError, NoPasswordSetError, NoPendingOtpError, OtpExpiredError, OtpInvalidError, RateLimitedError, ResendCooldownError, authErrorFromFetchFailure, authErrorFromResponse, createAuthClient, localStorageStore, memoryStore };
|
|
4
|
+
export { AccountSuspendedError, AuthError, CaptchaFailedError, EmailAlreadyHasPasswordError, GoogleSignInCancelledError, GoogleSignInError, InvalidCredentialsError, InvalidEmailError, InvalidPasswordError, MaxAttemptsError, MaxResendsError, NoPasswordSetError, NoPendingOtpError, OtpExpiredError, OtpInvalidError, RateLimitedError, ResendCooldownError, ValidationError, authErrorFromFetchFailure, authErrorFromResponse, createAuthClient, localStorageStore, memoryStore };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as Account } from "./session-
|
|
1
|
+
import { t as Account } from "./session-flM0yXx2.js";
|
|
2
2
|
|
|
3
3
|
//#region src/types/profile.d.ts
|
|
4
4
|
/** The account's profile record; every field is user-editable and nullable. */
|
|
@@ -90,4 +90,34 @@ type GoogleCompleteRedirectOptions = {
|
|
|
90
90
|
/** URL to read `code`, `error`, and `nonce` from. Default: `window.location.href`. */url?: string;
|
|
91
91
|
};
|
|
92
92
|
//#endregion
|
|
93
|
-
|
|
93
|
+
//#region src/types/roles.d.ts
|
|
94
|
+
/** Lifecycle of a role application, as stored on the server. */
|
|
95
|
+
type RoleApplicationState = 'pending_approval' | 'active' | 'revoked';
|
|
96
|
+
/** Input of `auth.roles.apply`. */
|
|
97
|
+
type ApplyRoleInput = {
|
|
98
|
+
/** Role to apply for. Only names on the server's self-applicable allowlist are accepted. */roleName: string;
|
|
99
|
+
};
|
|
100
|
+
/** Result of `auth.roles.apply`: the account role row the server created. */
|
|
101
|
+
type RoleApplicationStatus = {
|
|
102
|
+
id: string;
|
|
103
|
+
accountId: string;
|
|
104
|
+
roleId: string; /** `null` for a global role. */
|
|
105
|
+
projectId: string | null;
|
|
106
|
+
status: RoleApplicationState; /** Account id that created the row: an admin, or the applicant for a self-service application. */
|
|
107
|
+
assignedBy: string | null;
|
|
108
|
+
assignedAt: string;
|
|
109
|
+
approvedAt: string | null;
|
|
110
|
+
revokedAt: string | null;
|
|
111
|
+
};
|
|
112
|
+
/** One row of `auth.roles.status`, from the caller's point of view. */
|
|
113
|
+
type RoleStatus = {
|
|
114
|
+
roleName: string;
|
|
115
|
+
displayName: string | null; /** `none` when the account has never applied for this role. */
|
|
116
|
+
status: RoleApplicationState | 'none'; /** `null` until the account applies. */
|
|
117
|
+
accountRoleId: string | null;
|
|
118
|
+
assignedAt: string | null;
|
|
119
|
+
approvedAt: string | null;
|
|
120
|
+
revokedAt: string | null;
|
|
121
|
+
};
|
|
122
|
+
//#endregion
|
|
123
|
+
export { ProfileResult as C, ProfileAccount as S, SendLoginCodeInput as _, CaptchaArgs as a, VerifyRegistrationCodeInput as b, GoogleExchangeInput as c, GoogleStartOptions as d, LoginWithGoogleInput as f, ResendRegistrationCodeInput as g, ResendLoginCodeInput as h, RoleStatus as i, GoogleSignInWithPopupOptions as l, RegisterInput as m, RoleApplicationState as n, ChangePasswordInput as o, LoginWithPasswordInput as p, RoleApplicationStatus as r, GoogleCompleteRedirectOptions as s, ApplyRoleInput as t, GoogleStartMode as u, SetPasswordInput as v, Profile as x, VerifyLoginCodeInput as y };
|
|
@@ -28,11 +28,13 @@ type OtpInfo = {
|
|
|
28
28
|
canResendInSeconds: number; /** Resend attempts left for this OTP record. */
|
|
29
29
|
resendsRemaining: number;
|
|
30
30
|
};
|
|
31
|
-
/**
|
|
31
|
+
/**
|
|
32
|
+
* Result of `auth.emailOtp.sendLoginCode`. Carries only OTP timing: the
|
|
33
|
+
* server does not reveal whether the email is registered, so login versus
|
|
34
|
+
* signup is only known after `verifyLoginCode`.
|
|
35
|
+
*/
|
|
32
36
|
type SendLoginCodeResult = {
|
|
33
|
-
/**
|
|
34
|
-
methods: ('password' | 'passwordless')[]; /** OTP timing metadata. */
|
|
35
|
-
otp: OtpInfo;
|
|
37
|
+
/** OTP timing metadata. */otp: OtpInfo;
|
|
36
38
|
};
|
|
37
39
|
/** Result of any resend method (`emailOtp.resendLoginCode`, `emailPassword.resendRegistrationCode`). */
|
|
38
40
|
type ResendCodeResult = {
|
package/dist/store/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as memoryStore, n as SessionStore, r as localStorageStore, t as LocalStorageStoreOptions } from "../sessionStore-
|
|
1
|
+
import { i as memoryStore, n as SessionStore, r as localStorageStore, t as LocalStorageStoreOptions } from "../sessionStore-D2kXjvNM.js";
|
|
2
2
|
export { type LocalStorageStoreOptions, type SessionStore, localStorageStore, memoryStore };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as OtpInfo, c as ResendCodeResult, i as ErrorSource, l as SendLoginCodeResult, n as AuthSession, o as Project, r as ErrorHandler, s as RegisterResult, t as Account, u as SessionChangeHandler } from "../session-
|
|
2
|
-
import { _ as
|
|
1
|
+
import { a as OtpInfo, c as ResendCodeResult, i as ErrorSource, l as SendLoginCodeResult, n as AuthSession, o as Project, r as ErrorHandler, s as RegisterResult, t as Account, u as SessionChangeHandler } from "../session-flM0yXx2.js";
|
|
2
|
+
import { C as ProfileResult, S as ProfileAccount, _ as SendLoginCodeInput, a as CaptchaArgs, b as VerifyRegistrationCodeInput, c as GoogleExchangeInput, d as GoogleStartOptions, f as LoginWithGoogleInput, g as ResendRegistrationCodeInput, h as ResendLoginCodeInput, i as RoleStatus, l as GoogleSignInWithPopupOptions, m as RegisterInput, n as RoleApplicationState, o as ChangePasswordInput, p as LoginWithPasswordInput, r as RoleApplicationStatus, s as GoogleCompleteRedirectOptions, t as ApplyRoleInput, u as GoogleStartMode, v as SetPasswordInput, x as Profile, y as VerifyLoginCodeInput } from "../roles-BZecOymZ.js";
|
|
3
3
|
import { n as AccessTokenPayloadProject, t as AccessTokenPayload } from "../tokens-BXrPLi5B.js";
|
|
4
|
-
export { type AccessTokenPayload, type AccessTokenPayloadProject, type Account, type AuthSession, type CaptchaArgs, type ChangePasswordInput, type ErrorHandler, type ErrorSource, type GoogleCompleteRedirectOptions, type GoogleExchangeInput, type GoogleSignInWithPopupOptions, type GoogleStartMode, type GoogleStartOptions, type LoginWithGoogleInput, type LoginWithPasswordInput, type OtpInfo, type Profile, type ProfileAccount, type ProfileResult, type Project, type RegisterInput, type RegisterResult, type ResendCodeResult, type ResendLoginCodeInput, type ResendRegistrationCodeInput, type SendLoginCodeInput, type SendLoginCodeResult, type SessionChangeHandler, type SetPasswordInput, type VerifyLoginCodeInput, type VerifyRegistrationCodeInput };
|
|
4
|
+
export { type AccessTokenPayload, type AccessTokenPayloadProject, type Account, type ApplyRoleInput, type AuthSession, type CaptchaArgs, type ChangePasswordInput, type ErrorHandler, type ErrorSource, type GoogleCompleteRedirectOptions, type GoogleExchangeInput, type GoogleSignInWithPopupOptions, type GoogleStartMode, type GoogleStartOptions, type LoginWithGoogleInput, type LoginWithPasswordInput, type OtpInfo, type Profile, type ProfileAccount, type ProfileResult, type Project, type RegisterInput, type RegisterResult, type ResendCodeResult, type ResendLoginCodeInput, type ResendRegistrationCodeInput, type RoleApplicationState, type RoleApplicationStatus, type RoleStatus, type SendLoginCodeInput, type SendLoginCodeResult, type SessionChangeHandler, type SetPasswordInput, type VerifyLoginCodeInput, type VerifyRegistrationCodeInput };
|
package/dist/wallet/index.d.ts
CHANGED