@baliola/auth-sdk 0.4.0 → 0.5.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 +58 -21
- package/README.md +31 -6
- package/dist/{authError-DbEZJnC4.js → authError-CYUAl2Jt.js} +1 -0
- package/dist/{authError-C5g5jP5l.d.ts → authError-DgPEjTfW.d.ts} +1 -0
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.js +1 -1
- package/dist/{client-CX3XFmOA.js → client-DxhQkQcE.js} +18 -28
- package/dist/errors/index.d.ts +1 -1
- package/dist/errors/index.js +1 -1
- package/dist/{index-B2RuGLX_.d.ts → index-URk8yf8l.d.ts} +20 -19
- package/dist/index.d.ts +4 -4
- package/dist/index.js +2 -2
- package/dist/requests-jRLgNXyf.d.ts +75 -0
- package/dist/types/index.d.ts +2 -2
- package/dist/wallet/index.d.ts +1 -1
- package/package.json +38 -4
- package/dist/requests-eTORIjY5.d.ts +0 -42
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,44 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to `@baliola/auth-sdk` are documented here.
|
|
4
4
|
|
|
5
|
+
## 0.5.0
|
|
6
|
+
|
|
7
|
+
- feat(types): `auth.getProfile()` now returns `account.hasPassword`, a boolean
|
|
8
|
+
that is `true` when the account can sign in with a password and `false` for
|
|
9
|
+
Google-only or code-only accounts. Use it to decide between
|
|
10
|
+
`emailPassword.setPassword` and `emailPassword.changePassword`. `ProfileResult.account`
|
|
11
|
+
is typed as the new exported `ProfileAccount` (`Account & { hasPassword }`);
|
|
12
|
+
`Account` itself is unchanged. Requires baliola-auth with `hasPassword` on
|
|
13
|
+
`GET /profile`.
|
|
14
|
+
- feat(client): `auth.google.login` accepts `{ code }` in addition to
|
|
15
|
+
`{ idToken }`. `code` is the authorization code from Google's OAuth popup
|
|
16
|
+
code flow (`google.accounts.oauth2.initCodeClient`, `ux_mode: 'popup'`), which
|
|
17
|
+
the server exchanges for the ID token with its client secret.
|
|
18
|
+
`LoginWithGoogleInput` is now `{ idToken: string } | { code: string }`. The
|
|
19
|
+
server answers `invalid_google_code` (401) when the exchange fails and
|
|
20
|
+
`google_code_unsupported` (400) when it has no client secret configured; both
|
|
21
|
+
surface as `AuthError` with `code` preserved.
|
|
22
|
+
- types: `Profile`, `ProfileAccount`, and `ProfileResult` are now also exported
|
|
23
|
+
from the `./types` subpath, matching the root entry.
|
|
24
|
+
|
|
25
|
+
## 0.4.1
|
|
26
|
+
|
|
27
|
+
- chore(sdk): internal cleanup, no public API change. Removed dead code (the
|
|
28
|
+
unused `bearer-only-passthrough` auth-header mode, the throw-only
|
|
29
|
+
`refreshResponseShape` type helper, and the redundant `stripUndefined` body
|
|
30
|
+
helper, since the transport already drops `undefined` keys via
|
|
31
|
+
`JSON.stringify`), narrowed the internal request method union to the verbs
|
|
32
|
+
actually used (GET / POST), and deduplicated internal wire types against the
|
|
33
|
+
public `RegisterResult` / `ResendCodeResult`.
|
|
34
|
+
- chore(packaging): `viem` is now declared an **optional** peer dependency
|
|
35
|
+
(`peerDependenciesMeta`). It is only needed by the `./wallet` subpath, so
|
|
36
|
+
consumers who never import a wallet no longer have it auto-installed by npm 7+
|
|
37
|
+
and no longer see a missing-peer warning. Wallet users must install `viem`
|
|
38
|
+
themselves, which the wallet setup already required.
|
|
39
|
+
- Repo: this package moved out of the `baliola-auth` backend monorepo into its
|
|
40
|
+
own repository at `baliola/baliola-auth-sdk`. Package name, npm scope, and
|
|
41
|
+
every import path are unchanged.
|
|
42
|
+
|
|
5
43
|
## 0.4.0
|
|
6
44
|
|
|
7
45
|
- feat(sdk): add `auth.getProfile()` → `GET /profile`. Returns `{ account, profile }` where `account` carries the **live** account status (read from the database, not the token) and `profile` is the account's profile record (`displayName`, `avatarUrl`, `primaryEmail`, `primaryPhone`) or `null` when none exists yet. New exported types: `Profile`, `ProfileResult`.
|
|
@@ -9,17 +47,17 @@ All notable changes to `@baliola/auth-sdk` are documented here.
|
|
|
9
47
|
|
|
10
48
|
## 0.3.0
|
|
11
49
|
|
|
12
|
-
- feat(sdk): add the custodial wallet namespace
|
|
13
|
-
- feat(sdk): add `createRemoteSigner` under the `./wallet` subpath
|
|
50
|
+
- feat(sdk): add the custodial wallet namespace: `auth.wallet.getAddress()` (`GET /auth/wallet`, provisioned on first read) and `auth.wallet.signHash(hash)` (`POST /auth/wallet/sign`).
|
|
51
|
+
- feat(sdk): add `createRemoteSigner` under the `./wallet` subpath, a viem-compatible account whose `signMessage({ raw })` delegates to `POST /auth/wallet/sign`, so the custodial private key never leaves baliola-auth.
|
|
14
52
|
|
|
15
53
|
## 0.2.0
|
|
16
54
|
|
|
17
55
|
Distribution change and clean-ups; no method-level API changes.
|
|
18
56
|
|
|
19
|
-
- chore(release): publish to **public npm** (`https://registry.npmjs.org`) instead of GitHub Packages. Installing no longer requires a Personal Access Token, an `.npmrc` registry override, or SSO authorization
|
|
57
|
+
- chore(release): publish to **public npm** (`https://registry.npmjs.org`) instead of GitHub Packages. Installing no longer requires a Personal Access Token, an `.npmrc` registry override, or SSO authorization. Plain `bun add @baliola/auth-sdk` works in every environment.
|
|
20
58
|
- docs: rewrite `README.md`, `docs/install.md`, `docs/ciSetup.md`, and `docs/troubleshooting.md` to reflect public-npm install. CI snippets no longer need build secrets.
|
|
21
59
|
- Consumers previously installing from GitHub Packages should remove any `@baliola:registry=https://npm.pkg.github.com` entries from `~/.npmrc` and project-local `.npmrc` files before upgrading.
|
|
22
|
-
- fix(types): realign `AccessTokenPayload` with the server's current JWT shape. The flat `projectId?: string | null` / `projectName?: string | null` pair is replaced by `projects: AccessTokenPayloadProject[]` (each entry carries `{ id, name, clientId }`). Type-only change
|
|
60
|
+
- fix(types): realign `AccessTokenPayload` with the server's current JWT shape. The flat `projectId?: string | null` / `projectName?: string | null` pair is replaced by `projects: AccessTokenPayloadProject[]` (each entry carries `{ id, name, clientId }`). Type-only change, affecting consumers that decode the JWT manually and reference this type. A scoped login (`clientId` supplied) yields a single-entry array; a central login yields every project the account has active roles in.
|
|
23
61
|
- chore!: remove the `./internal` subpath export and the `internal/` source folder (`createValidateCache`, `newIdempotencyKey`, `consumeHeaders`). Those helpers targeted the retired `/internal/api-keys/*` endpoints and the static "internal token" concept. Service-to-service callers now authenticate with an admin-tier API key (`baliola_admin_…`) against `/admin/api-keys/*`; cache + idempotency helpers for that surface will ship in a dedicated admin SDK.
|
|
24
62
|
|
|
25
63
|
## 0.1.0
|
|
@@ -28,7 +66,7 @@ Breaking redesign of the auth API and SDK surface to eliminate dev confusion bet
|
|
|
28
66
|
|
|
29
67
|
### Breaking changes
|
|
30
68
|
|
|
31
|
-
- feat(sdk)!: replace the flat method surface with namespaced flows
|
|
69
|
+
- feat(sdk)!: replace the flat method surface with namespaced flows: `auth.emailOtp.*`, `auth.emailPassword.*`, `auth.google.*`. The namespaces match the DB provider names (`email_otp`, `email_password`).
|
|
32
70
|
- feat(sdk)!: rename verb-overloaded methods so each one's purpose is unambiguous at the call site:
|
|
33
71
|
- `auth.requestEmailOtp` → `auth.emailOtp.sendLoginCode`
|
|
34
72
|
- `auth.verifyEmailOtp` → `auth.emailOtp.verifyLoginCode`
|
|
@@ -39,14 +77,14 @@ Breaking redesign of the auth API and SDK surface to eliminate dev confusion bet
|
|
|
39
77
|
- `auth.changePassword` → `auth.emailPassword.changePassword`
|
|
40
78
|
- `auth.loginWithGoogle` → `auth.google.login`
|
|
41
79
|
- feat(sdk)!: verify-code methods take `{ email, code }` instead of `{ email, otp }`.
|
|
42
|
-
- feat(sdk)!: `auth.emailPassword.register` no longer branches on `'otp_sent' | 'linked'
|
|
43
|
-
- feat(sdk)!: send/resend/register success responses replace `expiresInMinutes` with a structured `OtpInfo` payload
|
|
80
|
+
- feat(sdk)!: `auth.emailPassword.register` no longer branches on `'otp_sent' | 'linked'`. It always sends a verification OTP and returns `{ otp: OtpInfo }`. The single-step "linked" path is removed.
|
|
81
|
+
- feat(sdk)!: send/resend/register success responses replace `expiresInMinutes` with a structured `OtpInfo` payload: `expiresInSeconds`, `expiresAt`, `canResendInSeconds`, `resendsRemaining`.
|
|
44
82
|
- feat(sdk)!: backend endpoint paths renamed to match the namespaces: `POST /auth/email-otp/send-login-code`, `/auth/email-otp/verify-login-code`, `/auth/email-otp/resend-login-code`, `/auth/email-password/register`, `/auth/email-password/verify-registration-code`, `/auth/email-password/resend-registration-code`, etc.
|
|
45
83
|
|
|
46
84
|
### New features
|
|
47
85
|
|
|
48
|
-
- feat(sdk): add typed error subclasses under `AuthError
|
|
49
|
-
- feat(sdk): add dedicated resend methods
|
|
86
|
+
- feat(sdk): add typed error subclasses under `AuthError`: `OtpInvalidError` (with `attemptsRemaining`, `canResendInSeconds`), `OtpExpiredError`, `MaxAttemptsError` (with `retryAfterSeconds`), `NoPendingOtpError`, `ResendCooldownError` (with `canResendInSeconds`), `MaxResendsError`, `InvalidCredentialsError`, `NoPasswordSetError`, `AccountSuspendedError`, `EmailAlreadyHasPasswordError`, `CaptchaFailedError`, `RateLimitedError` (with `retryAfterSeconds`, `retryAfterHuman`), `InvalidPasswordError` (with `reason`), `InvalidEmailError`. Branch on `instanceof` for TS narrowing, or `err.code` for stable string matching. Backend responses now carry the structured context fields via `error.details` so the SDK lifts them into the typed properties.
|
|
87
|
+
- feat(sdk): add dedicated resend methods: `auth.emailOtp.resendLoginCode` and `auth.emailPassword.resendRegistrationCode`. Each enforces its own resend cooldown (`OTP_RESEND_COOLDOWN_SECONDS`, default 60s) and per-OTP cap (`OTP_MAX_RESENDS`, default 3) on top of the per-OTP attempts limit.
|
|
50
88
|
- feat(sdk): add `captchaToken` option on every public unauthenticated entrypoint (`sendLoginCode`, `resendLoginCode`, `register`, `resendRegistrationCode`, `login`). Backend verifies via Cloudflare Turnstile when `TURNSTILE_SECRET_KEY` is set; dev bypass when unset; server-to-server clients can be allowlisted via `CAPTCHA_BYPASS_CLIENT_IDS`.
|
|
51
89
|
- feat(sdk): `auth.emailOtp.sendLoginCode` response includes `flow: 'login' | 'signup'` and `methods: ('password' | 'passwordless')[]` so the UI can adapt to the account state without an extra round-trip.
|
|
52
90
|
|
|
@@ -57,30 +95,29 @@ Breaking redesign of the auth API and SDK surface to eliminate dev confusion bet
|
|
|
57
95
|
|
|
58
96
|
## 0.0.5
|
|
59
97
|
|
|
60
|
-
- feat(sdk): add cross-tab session sync via `BroadcastChannel
|
|
98
|
+
- feat(sdk): add cross-tab session sync via `BroadcastChannel`. When one tab logs in, logs out, or refreshes the access token, every other tab on the same origin updates its in-memory mirror in real time.
|
|
61
99
|
- feat(sdk): add `auth.fetch({ requireAuth: true })` per-call option that throws `AuthError(401)` before sending when no session is loaded.
|
|
62
100
|
- feat(sdk): add `auth.fetch({ disableRefresh: true })` per-call option that skips both proactive and reactive refresh, letting a 401 propagate to the caller.
|
|
63
101
|
|
|
64
102
|
## 0.0.4
|
|
65
103
|
|
|
66
|
-
- feat(sdk): add `changePassword({ currentPassword, newPassword })` paired with `POST /auth/email-password/change-password` server route
|
|
104
|
+
- feat(sdk): add `changePassword({ currentPassword, newPassword })` paired with `POST /auth/email-password/change-password` server route. It verifies the current password, rotates the bcrypt hash, revokes every other session for the account (caller stays signed in), and sends a confirmation email out-of-band.
|
|
67
105
|
- chore(auth): relax password policy to require only 8+ characters and at least one uppercase letter (number and special-character requirements dropped).
|
|
68
106
|
|
|
69
107
|
## 0.0.3
|
|
70
108
|
|
|
71
|
-
-
|
|
72
|
-
- feat(sdk): expose `Project.allowedOrigins` on `AuthSession`
|
|
109
|
+
- feat(sdk): expose `Project.allowedOrigins` on `AuthSession`, so a consumer can read the origins a project accepts without a second call.
|
|
73
110
|
|
|
74
111
|
## 0.0.2
|
|
75
112
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
-
|
|
79
|
-
-
|
|
80
|
-
- docs(sdk): add README
|
|
81
|
-
- test(sdk): add unit tests for client, transport, and store
|
|
82
|
-
- feat(sdk): implement auth client with auto-refresh, session mirror, and consumer fetch helper
|
|
113
|
+
The first usable release. 0.0.1 published the package shell; this one puts a working client inside it.
|
|
114
|
+
|
|
115
|
+
- feat(sdk): implement the auth client, with proactive and reactive access-token refresh, the in-memory session mirror, and the `auth.fetch` helper that attaches the access token for consumers.
|
|
116
|
+
- refactor(sdk): drop pre-release version labels from public JSDoc, so published docs no longer advertise a version that moves every release.
|
|
117
|
+
- docs(sdk): add the README API reference plus the install, troubleshooting, and CI setup guides, and move the roadmap out to `ROADMAP.md`.
|
|
83
118
|
|
|
84
119
|
## 0.0.1
|
|
85
120
|
|
|
86
|
-
- feat(sdk): scaffold `@baliola/auth-sdk` package config
|
|
121
|
+
- feat(sdk): scaffold the `@baliola/auth-sdk` package config. Package shell and build only, no client implementation yet.
|
|
122
|
+
|
|
123
|
+
These 0.0.x releases went to GitHub Packages, not public npm. 0.2.0 moved distribution to public npm, and nothing below 0.2.0 is installable from the public registry.
|
package/README.md
CHANGED
|
@@ -2,7 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Client SDK for the Baliola Auth service. Two clearly separated email flows (passwordless OTP, password + verification OTP) plus Google login, with typed methods, typed errors, auto-refresh, and cross-tab sync.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Guides:
|
|
6
|
+
|
|
7
|
+
- [docs/concepts.md](./docs/concepts.md): flows, session mirror, refresh, cross-tab sync, errors.
|
|
8
|
+
- [docs/install.md](./docs/install.md): install and first call.
|
|
9
|
+
- [docs/ciSetup.md](./docs/ciSetup.md): installing this SDK in your own pipeline.
|
|
10
|
+
- [docs/troubleshooting.md](./docs/troubleshooting.md): install and build symptoms.
|
|
6
11
|
|
|
7
12
|
## Install
|
|
8
13
|
|
|
@@ -18,11 +23,14 @@ Published to public npm under the `@baliola` scope — no registry config or aut
|
|
|
18
23
|
|
|
19
24
|
## Quick start
|
|
20
25
|
|
|
26
|
+
`AUTH_URL` below is the base URL of the Baliola Auth deployment you are targeting. It differs per
|
|
27
|
+
environment. Baliola developers: the per-environment values are in the internal integration docs.
|
|
28
|
+
|
|
21
29
|
```ts
|
|
22
30
|
import { createAuthClient, localStorageStore, OtpInvalidError } from '@baliola/auth-sdk';
|
|
23
31
|
|
|
24
32
|
const auth = createAuthClient({
|
|
25
|
-
baseUrl:
|
|
33
|
+
baseUrl: AUTH_URL,
|
|
26
34
|
clientId: 'your-project-client-id', // omit for a central multi-project login
|
|
27
35
|
store: localStorageStore(), // omit for in-memory (server-side / tests)
|
|
28
36
|
});
|
|
@@ -91,8 +99,12 @@ auth.emailPassword.changePassword({ currentPassword, newPassword });
|
|
|
91
99
|
### `auth.google`
|
|
92
100
|
|
|
93
101
|
```ts
|
|
94
|
-
// idToken
|
|
102
|
+
// idToken comes from the Google Identity Services button or One Tap.
|
|
95
103
|
auth.google.login({ idToken }); // → AuthSession
|
|
104
|
+
|
|
105
|
+
// code comes from the OAuth popup code flow (google.accounts.oauth2.initCodeClient).
|
|
106
|
+
// The server exchanges it for the ID token with its client secret.
|
|
107
|
+
auth.google.login({ code }); // → AuthSession
|
|
96
108
|
```
|
|
97
109
|
|
|
98
110
|
### Custodial wallet (smart-account signer)
|
|
@@ -115,8 +127,10 @@ The private key never leaves baliola-auth; `owner.signMessage({ raw })` calls `P
|
|
|
115
127
|
|
|
116
128
|
```ts
|
|
117
129
|
const { account, profile } = await auth.getProfile(); // GET /profile (authenticated)
|
|
118
|
-
// account = { id, email, status }
|
|
130
|
+
// account = { id, email, status, hasPassword } (status is live, not a token-time snapshot)
|
|
119
131
|
// profile = { displayName, avatarUrl, primaryEmail, primaryPhone } | null
|
|
132
|
+
|
|
133
|
+
// hasPassword is false for Google-only or code-only accounts: offer setPassword, not changePassword.
|
|
120
134
|
```
|
|
121
135
|
|
|
122
136
|
### Session lifecycle
|
|
@@ -234,7 +248,7 @@ Cross-tab sync (login / logout / refresh) is automatic via `BroadcastChannel`, r
|
|
|
234
248
|
|
|
235
249
|
```ts
|
|
236
250
|
createAuthClient({
|
|
237
|
-
baseUrl:
|
|
251
|
+
baseUrl: AUTH_URL, // required, no trailing slash
|
|
238
252
|
clientId: 'your-project-client-id', // optional; scopes the session to one project. Omit for a central login that carries every project the account has active roles in.
|
|
239
253
|
store: memoryStore(), // default; or localStorageStore() / custom
|
|
240
254
|
fetch: globalThis.fetch, // override for tests / interceptors
|
|
@@ -263,6 +277,8 @@ if (session) {
|
|
|
263
277
|
}
|
|
264
278
|
```
|
|
265
279
|
|
|
280
|
+
`decodeJwt` reads claims without checking the signature, which is fine on the client where the token came from your own session. A service that trusts the token for authorization must verify it: the tokens are EdDSA (Ed25519), issuer `baliola-auth`, and the public keys are served at `GET /.well-known/jwks.json` on the same `baseUrl`.
|
|
281
|
+
|
|
266
282
|
## Sample response shapes
|
|
267
283
|
|
|
268
284
|
**`auth.emailOtp.sendLoginCode` success:**
|
|
@@ -297,7 +313,7 @@ if (session) {
|
|
|
297
313
|
|
|
298
314
|
```json
|
|
299
315
|
{
|
|
300
|
-
"accessToken": "
|
|
316
|
+
"accessToken": "eyJhbGciOiJFZERTQSIs...",
|
|
301
317
|
"refreshToken": "session-uuid",
|
|
302
318
|
"expiresIn": 3600,
|
|
303
319
|
"account": { "id": "...", "email": "user@example.com", "status": "active" },
|
|
@@ -307,6 +323,15 @@ if (session) {
|
|
|
307
323
|
}
|
|
308
324
|
```
|
|
309
325
|
|
|
326
|
+
**`auth.getProfile` success (`ProfileResult`):**
|
|
327
|
+
|
|
328
|
+
```json
|
|
329
|
+
{
|
|
330
|
+
"account": { "id": "...", "email": "user@example.com", "status": "active", "hasPassword": true },
|
|
331
|
+
"profile": { "displayName": "Ada", "avatarUrl": null, "primaryEmail": "user@example.com", "primaryPhone": null }
|
|
332
|
+
}
|
|
333
|
+
```
|
|
334
|
+
|
|
310
335
|
**Verify-code failure (e.g. `OtpInvalidError`):**
|
|
311
336
|
|
|
312
337
|
```json
|
|
@@ -32,6 +32,7 @@ var AuthError = class extends Error {
|
|
|
32
32
|
Object.setPrototypeOf(this, new.target.prototype);
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
|
+
/** Concrete subclasses with structured fields lifted from `details` */
|
|
35
36
|
var OtpInvalidError = class extends AuthError {
|
|
36
37
|
attemptsRemaining;
|
|
37
38
|
canResendInSeconds;
|
|
@@ -30,6 +30,7 @@ declare class AuthError extends Error {
|
|
|
30
30
|
readonly cause?: unknown;
|
|
31
31
|
constructor(init: AuthErrorInit);
|
|
32
32
|
}
|
|
33
|
+
/** Concrete subclasses with structured fields lifted from `details` */
|
|
33
34
|
declare class OtpInvalidError extends AuthError {
|
|
34
35
|
readonly attemptsRemaining: number;
|
|
35
36
|
readonly canResendInSeconds: number;
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as GoogleNamespace, c as WalletNamespace,
|
|
1
|
+
import { a as GoogleNamespace, c as WalletNamespace, i as EmailPasswordNamespace, l as createAuthClient, n as CreateAuthClientOptions, o as ProactiveRefreshConfig, r as EmailOtpNamespace, s as SubscribeOptions, t as AuthClient, u as AuthFetchInit } from "../index-URk8yf8l.js";
|
|
2
2
|
export { AuthClient, AuthFetchInit, CreateAuthClientOptions, EmailOtpNamespace, EmailPasswordNamespace, GoogleNamespace, ProactiveRefreshConfig, 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-DxhQkQcE.js";
|
|
2
2
|
export { createAuthClient };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as authErrorFromResponse, g as authErrorFromFetchFailure, n as AuthError } from "./authError-
|
|
1
|
+
import { _ as authErrorFromResponse, g as authErrorFromFetchFailure, n as AuthError } from "./authError-CYUAl2Jt.js";
|
|
2
2
|
import { n as memoryStore } from "./sessionStore-DD6lON9W.js";
|
|
3
3
|
//#region src/client/methods.ts
|
|
4
4
|
function toAuthSession(data) {
|
|
@@ -23,21 +23,17 @@ function createMethods(ctx) {
|
|
|
23
23
|
clientId: ctx.clientId
|
|
24
24
|
};
|
|
25
25
|
};
|
|
26
|
-
const stripUndefined = (body) => {
|
|
27
|
-
const out = {};
|
|
28
|
-
for (const [k, v] of Object.entries(body)) if (v !== void 0) out[k] = v;
|
|
29
|
-
return out;
|
|
30
|
-
};
|
|
31
26
|
return {
|
|
27
|
+
/** emailOtp.* (passwordless) */
|
|
32
28
|
async sendLoginCode(input) {
|
|
33
29
|
return ctx.transport.request({
|
|
34
30
|
path: "/auth/email-otp/send-login-code",
|
|
35
31
|
method: "POST",
|
|
36
32
|
authMode: "none",
|
|
37
|
-
body:
|
|
33
|
+
body: withClientId({
|
|
38
34
|
email: input.email,
|
|
39
35
|
captchaToken: input.captchaToken
|
|
40
|
-
})
|
|
36
|
+
})
|
|
41
37
|
});
|
|
42
38
|
},
|
|
43
39
|
async verifyLoginCode(input) {
|
|
@@ -56,22 +52,23 @@ function createMethods(ctx) {
|
|
|
56
52
|
path: "/auth/email-otp/resend-login-code",
|
|
57
53
|
method: "POST",
|
|
58
54
|
authMode: "none",
|
|
59
|
-
body:
|
|
55
|
+
body: withClientId({
|
|
60
56
|
email: input.email,
|
|
61
57
|
captchaToken: input.captchaToken
|
|
62
|
-
})
|
|
58
|
+
})
|
|
63
59
|
});
|
|
64
60
|
},
|
|
61
|
+
/** emailPassword.* (password flow) */
|
|
65
62
|
async register(input) {
|
|
66
63
|
return ctx.transport.request({
|
|
67
64
|
path: "/auth/email-password/register",
|
|
68
65
|
method: "POST",
|
|
69
66
|
authMode: "none",
|
|
70
|
-
body:
|
|
67
|
+
body: withClientId({
|
|
71
68
|
email: input.email,
|
|
72
69
|
password: input.password,
|
|
73
70
|
captchaToken: input.captchaToken
|
|
74
|
-
})
|
|
71
|
+
})
|
|
75
72
|
});
|
|
76
73
|
},
|
|
77
74
|
async verifyRegistrationCode(input) {
|
|
@@ -90,10 +87,10 @@ function createMethods(ctx) {
|
|
|
90
87
|
path: "/auth/email-password/resend-registration-code",
|
|
91
88
|
method: "POST",
|
|
92
89
|
authMode: "none",
|
|
93
|
-
body:
|
|
90
|
+
body: withClientId({
|
|
94
91
|
email: input.email,
|
|
95
92
|
captchaToken: input.captchaToken
|
|
96
|
-
})
|
|
93
|
+
})
|
|
97
94
|
});
|
|
98
95
|
},
|
|
99
96
|
async loginWithPassword(input) {
|
|
@@ -101,11 +98,11 @@ function createMethods(ctx) {
|
|
|
101
98
|
path: "/auth/email-password/login",
|
|
102
99
|
method: "POST",
|
|
103
100
|
authMode: "none",
|
|
104
|
-
body:
|
|
101
|
+
body: withClientId({
|
|
105
102
|
email: input.email,
|
|
106
103
|
password: input.password,
|
|
107
104
|
captchaToken: input.captchaToken
|
|
108
|
-
})
|
|
105
|
+
})
|
|
109
106
|
}));
|
|
110
107
|
},
|
|
111
108
|
async setPassword(input) {
|
|
@@ -127,14 +124,16 @@ function createMethods(ctx) {
|
|
|
127
124
|
}
|
|
128
125
|
});
|
|
129
126
|
},
|
|
127
|
+
/** google.* */
|
|
130
128
|
async loginWithGoogle(input) {
|
|
131
129
|
return toAuthSession(await ctx.transport.request({
|
|
132
130
|
path: "/auth/google/login",
|
|
133
131
|
method: "POST",
|
|
134
132
|
authMode: "none",
|
|
135
|
-
body: withClientId({ idToken: input.idToken })
|
|
133
|
+
body: withClientId("idToken" in input ? { idToken: input.idToken } : { code: input.code })
|
|
136
134
|
}));
|
|
137
135
|
},
|
|
136
|
+
/** wallet.* */
|
|
138
137
|
async getWalletAddress() {
|
|
139
138
|
return ctx.transport.request({
|
|
140
139
|
path: "/auth/wallet",
|
|
@@ -150,6 +149,7 @@ function createMethods(ctx) {
|
|
|
150
149
|
body: { hash }
|
|
151
150
|
});
|
|
152
151
|
},
|
|
152
|
+
/** profile */
|
|
153
153
|
async getProfile() {
|
|
154
154
|
return ctx.transport.request({
|
|
155
155
|
path: "/profile",
|
|
@@ -157,20 +157,13 @@ function createMethods(ctx) {
|
|
|
157
157
|
authMode: "bearer+session"
|
|
158
158
|
});
|
|
159
159
|
},
|
|
160
|
+
/** session lifecycle */
|
|
160
161
|
async logoutRequest() {
|
|
161
162
|
await ctx.transport.request({
|
|
162
163
|
path: "/auth/logout",
|
|
163
164
|
method: "POST",
|
|
164
165
|
authMode: "bearer+session"
|
|
165
166
|
});
|
|
166
|
-
},
|
|
167
|
-
/**
|
|
168
|
-
* Type-only helper: declares the refresh response shape so consumers
|
|
169
|
-
* pulling the inferred Methods type don't break. Refresh itself is
|
|
170
|
-
* handled by transport.refreshSession() to keep stampede protection.
|
|
171
|
-
*/
|
|
172
|
-
refreshResponseShape() {
|
|
173
|
-
throw new Error("refreshResponseShape is a type-only helper");
|
|
174
167
|
}
|
|
175
168
|
};
|
|
176
169
|
}
|
|
@@ -202,9 +195,6 @@ function createTransport(options) {
|
|
|
202
195
|
case "session-only":
|
|
203
196
|
headers.set("X-Session-ID", session.refreshToken);
|
|
204
197
|
break;
|
|
205
|
-
case "bearer-only-passthrough":
|
|
206
|
-
headers.set("Authorization", `Bearer ${session.accessToken}`);
|
|
207
|
-
break;
|
|
208
198
|
case "none": break;
|
|
209
199
|
}
|
|
210
200
|
return headers;
|
package/dist/errors/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as authErrorFromFetchFailure, a as EmailAlreadyHasPasswordError, c as InvalidPasswordError, d as NoPasswordSetError, f as NoPendingOtpError, g as ResendCooldownError, h as RateLimitedError, i as CaptchaFailedError, l as MaxAttemptsError, m as OtpInvalidError, n as AuthError, o as InvalidCredentialsError, p as OtpExpiredError, r as AuthErrorInit, s as InvalidEmailError, t as AccountSuspendedError, u as MaxResendsError, v as authErrorFromResponse } from "../authError-
|
|
1
|
+
import { _ as authErrorFromFetchFailure, a as EmailAlreadyHasPasswordError, c as InvalidPasswordError, d as NoPasswordSetError, f as NoPendingOtpError, g as ResendCooldownError, h as RateLimitedError, i as CaptchaFailedError, l as MaxAttemptsError, m as OtpInvalidError, n as AuthError, o as InvalidCredentialsError, p as OtpExpiredError, r as AuthErrorInit, s as InvalidEmailError, t as AccountSuspendedError, u as MaxResendsError, v as authErrorFromResponse } from "../authError-DgPEjTfW.js";
|
|
2
2
|
export { AccountSuspendedError, AuthError, type AuthErrorInit, CaptchaFailedError, EmailAlreadyHasPasswordError, InvalidCredentialsError, InvalidEmailError, InvalidPasswordError, MaxAttemptsError, MaxResendsError, NoPasswordSetError, NoPendingOtpError, OtpExpiredError, OtpInvalidError, RateLimitedError, ResendCooldownError, authErrorFromFetchFailure, authErrorFromResponse };
|
package/dist/errors/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as authErrorFromResponse, a as InvalidCredentialsError, c as MaxAttemptsError, d as NoPendingOtpError, f as OtpExpiredError, g as authErrorFromFetchFailure, h as ResendCooldownError, i as EmailAlreadyHasPasswordError, l as MaxResendsError, m as RateLimitedError, n as AuthError, o as InvalidEmailError, p as OtpInvalidError, r as CaptchaFailedError, s as InvalidPasswordError, t as AccountSuspendedError, u as NoPasswordSetError } from "../authError-
|
|
1
|
+
import { _ as authErrorFromResponse, a as InvalidCredentialsError, c as MaxAttemptsError, d as NoPendingOtpError, f as OtpExpiredError, g as authErrorFromFetchFailure, h as ResendCooldownError, i as EmailAlreadyHasPasswordError, l as MaxResendsError, m as RateLimitedError, n as AuthError, o as InvalidEmailError, p as OtpInvalidError, r as CaptchaFailedError, s as InvalidPasswordError, t as AccountSuspendedError, u as NoPasswordSetError } from "../authError-CYUAl2Jt.js";
|
|
2
2
|
export { AccountSuspendedError, AuthError, CaptchaFailedError, EmailAlreadyHasPasswordError, InvalidCredentialsError, InvalidEmailError, InvalidPasswordError, MaxAttemptsError, MaxResendsError, NoPasswordSetError, NoPendingOtpError, OtpExpiredError, OtpInvalidError, RateLimitedError, ResendCooldownError, authErrorFromFetchFailure, authErrorFromResponse };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { c as ResendCodeResult, l as SendLoginCodeResult, n as AuthSession, r as ErrorHandler, s as RegisterResult,
|
|
1
|
+
import { c as ResendCodeResult, l as SendLoginCodeResult, n as AuthSession, r as ErrorHandler, s as RegisterResult, u as SessionChangeHandler } from "./session-Cs_P7ojF.js";
|
|
2
2
|
import { n as SessionStore } from "./sessionStore-BDdEpbL8.js";
|
|
3
|
-
import { a as RegisterInput, c as SendLoginCodeInput, d as VerifyRegistrationCodeInput, i as LoginWithPasswordInput, l as SetPasswordInput, n as ChangePasswordInput, o as ResendLoginCodeInput, r as LoginWithGoogleInput, s as ResendRegistrationCodeInput, u as VerifyLoginCodeInput } from "./requests-
|
|
3
|
+
import { a as RegisterInput, c as SendLoginCodeInput, d as VerifyRegistrationCodeInput, i as LoginWithPasswordInput, l as SetPasswordInput, m as ProfileResult, n as ChangePasswordInput, o as ResendLoginCodeInput, r as LoginWithGoogleInput, s as ResendRegistrationCodeInput, u as VerifyLoginCodeInput } from "./requests-jRLgNXyf.js";
|
|
4
4
|
|
|
5
5
|
//#region src/client/transport.d.ts
|
|
6
6
|
type FetchLike = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
@@ -26,20 +26,6 @@ type AuthFetchInit = RequestInit & {
|
|
|
26
26
|
disableRefresh?: boolean;
|
|
27
27
|
};
|
|
28
28
|
//#endregion
|
|
29
|
-
//#region src/types/profile.d.ts
|
|
30
|
-
/** The account's profile record; every field is user-editable and nullable. */
|
|
31
|
-
type Profile = {
|
|
32
|
-
displayName: string | null;
|
|
33
|
-
avatarUrl: string | null;
|
|
34
|
-
primaryEmail: string | null;
|
|
35
|
-
primaryPhone: string | null;
|
|
36
|
-
};
|
|
37
|
-
/** Result of `auth.getProfile` — identity read for the token holder. */
|
|
38
|
-
type ProfileResult = {
|
|
39
|
-
/** `status` is the live account status, not a token-time snapshot. */account: Account; /** `null` when the account has no profile row yet. */
|
|
40
|
-
profile: Profile | null;
|
|
41
|
-
};
|
|
42
|
-
//#endregion
|
|
43
29
|
//#region src/client/index.d.ts
|
|
44
30
|
type ProactiveRefreshConfig = false | {
|
|
45
31
|
/** Refresh proactively if `expiresAt - now < leadTimeMs`. Defaults to 60_000 (60s). */leadTimeMs?: number;
|
|
@@ -131,6 +117,19 @@ type EmailPasswordNamespace = {
|
|
|
131
117
|
};
|
|
132
118
|
/** Google flow. */
|
|
133
119
|
type GoogleNamespace = {
|
|
120
|
+
/**
|
|
121
|
+
* Sign in with Google. Pass `{ idToken }` from the Google Identity Services
|
|
122
|
+
* button or One Tap, or `{ code }` from the OAuth popup code flow
|
|
123
|
+
* (`google.accounts.oauth2.initCodeClient`), which the server exchanges
|
|
124
|
+
* for the ID token using its client secret.
|
|
125
|
+
*
|
|
126
|
+
* @throws AuthError with code `invalid_google_code` (401) when the exchange
|
|
127
|
+
* fails, `google_code_unsupported` (400) when the server has no
|
|
128
|
+
* client secret configured, AccountSuspendedError, AuthError.
|
|
129
|
+
* @example
|
|
130
|
+
* await auth.google.login({ idToken });
|
|
131
|
+
* await auth.google.login({ code });
|
|
132
|
+
*/
|
|
134
133
|
login(input: LoginWithGoogleInput): Promise<AuthSession>;
|
|
135
134
|
};
|
|
136
135
|
/** Custodial wallet (Console tier). */
|
|
@@ -144,8 +143,10 @@ type AuthClient = {
|
|
|
144
143
|
google: GoogleNamespace;
|
|
145
144
|
wallet: WalletNamespace;
|
|
146
145
|
/**
|
|
147
|
-
* Fetch the token holder's identity: account (id, email, live status
|
|
148
|
-
* its profile record (`profile: null` when none exists
|
|
146
|
+
* Fetch the token holder's identity: account (id, email, live status,
|
|
147
|
+
* `hasPassword`) plus its profile record (`profile: null` when none exists
|
|
148
|
+
* yet). Use `account.hasPassword` to choose between
|
|
149
|
+
* `emailPassword.setPassword` and `emailPassword.changePassword`.
|
|
149
150
|
*
|
|
150
151
|
* @throws AuthError on 401 (missing/expired session) and other API errors.
|
|
151
152
|
*/
|
|
@@ -166,4 +167,4 @@ type AuthClient = {
|
|
|
166
167
|
};
|
|
167
168
|
declare function createAuthClient(options: CreateAuthClientOptions): AuthClient;
|
|
168
169
|
//#endregion
|
|
169
|
-
export { GoogleNamespace as a, WalletNamespace as c,
|
|
170
|
+
export { GoogleNamespace as a, WalletNamespace as c, EmailPasswordNamespace as i, createAuthClient as l, CreateAuthClientOptions as n, ProactiveRefreshConfig as o, EmailOtpNamespace as r, SubscribeOptions as s, AuthClient as t, AuthFetchInit as u };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
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-Cs_P7ojF.js";
|
|
2
|
-
import { a as GoogleNamespace, c as WalletNamespace,
|
|
2
|
+
import { a as GoogleNamespace, c as WalletNamespace, i as EmailPasswordNamespace, l as createAuthClient, n as CreateAuthClientOptions, o as ProactiveRefreshConfig, r as EmailOtpNamespace, s as SubscribeOptions, t as AuthClient, u as AuthFetchInit } from "./index-URk8yf8l.js";
|
|
3
3
|
import { i as memoryStore, n as SessionStore, r as localStorageStore, t as LocalStorageStoreOptions } from "./sessionStore-BDdEpbL8.js";
|
|
4
|
-
import { a as RegisterInput, c as SendLoginCodeInput, d as VerifyRegistrationCodeInput, i as LoginWithPasswordInput, l as SetPasswordInput, n as ChangePasswordInput, o as ResendLoginCodeInput, r as LoginWithGoogleInput, s as ResendRegistrationCodeInput, t as CaptchaArgs, u as VerifyLoginCodeInput } from "./requests-
|
|
5
|
-
import { _ as authErrorFromFetchFailure, a as EmailAlreadyHasPasswordError, c as InvalidPasswordError, d as NoPasswordSetError, f as NoPendingOtpError, g as ResendCooldownError, h as RateLimitedError, i as CaptchaFailedError, l as MaxAttemptsError, m as OtpInvalidError, n as AuthError, o as InvalidCredentialsError, p as OtpExpiredError, r as AuthErrorInit, s as InvalidEmailError, t as AccountSuspendedError, u as MaxResendsError, v as authErrorFromResponse } from "./authError-
|
|
4
|
+
import { a as RegisterInput, c as SendLoginCodeInput, d as VerifyRegistrationCodeInput, f as Profile, i as LoginWithPasswordInput, l as SetPasswordInput, m as ProfileResult, n as ChangePasswordInput, o as ResendLoginCodeInput, p as ProfileAccount, r as LoginWithGoogleInput, s as ResendRegistrationCodeInput, t as CaptchaArgs, u as VerifyLoginCodeInput } from "./requests-jRLgNXyf.js";
|
|
5
|
+
import { _ as authErrorFromFetchFailure, a as EmailAlreadyHasPasswordError, c as InvalidPasswordError, d as NoPasswordSetError, f as NoPendingOtpError, g as ResendCooldownError, h as RateLimitedError, i as CaptchaFailedError, l as MaxAttemptsError, m as OtpInvalidError, n as AuthError, o as InvalidCredentialsError, p as OtpExpiredError, r as AuthErrorInit, s as InvalidEmailError, t as AccountSuspendedError, u as MaxResendsError, v as authErrorFromResponse } from "./authError-DgPEjTfW.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 GoogleNamespace, InvalidCredentialsError, InvalidEmailError, InvalidPasswordError, type LocalStorageStoreOptions, type LoginWithGoogleInput, type LoginWithPasswordInput, MaxAttemptsError, MaxResendsError, NoPasswordSetError, NoPendingOtpError, OtpExpiredError, type OtpInfo, OtpInvalidError, type ProactiveRefreshConfig, type Profile, 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 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 GoogleNamespace, 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 };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as createAuthClient } from "./client-
|
|
2
|
-
import { _ as authErrorFromResponse, a as InvalidCredentialsError, c as MaxAttemptsError, d as NoPendingOtpError, f as OtpExpiredError, g as authErrorFromFetchFailure, h as ResendCooldownError, i as EmailAlreadyHasPasswordError, l as MaxResendsError, m as RateLimitedError, n as AuthError, o as InvalidEmailError, p as OtpInvalidError, r as CaptchaFailedError, s as InvalidPasswordError, t as AccountSuspendedError, u as NoPasswordSetError } from "./authError-
|
|
1
|
+
import { t as createAuthClient } from "./client-DxhQkQcE.js";
|
|
2
|
+
import { _ as authErrorFromResponse, a as InvalidCredentialsError, c as MaxAttemptsError, d as NoPendingOtpError, f as OtpExpiredError, g as authErrorFromFetchFailure, h as ResendCooldownError, i as EmailAlreadyHasPasswordError, l as MaxResendsError, m as RateLimitedError, n as AuthError, o as InvalidEmailError, p as OtpInvalidError, r as CaptchaFailedError, s as InvalidPasswordError, t as AccountSuspendedError, u as NoPasswordSetError } from "./authError-CYUAl2Jt.js";
|
|
3
3
|
import { n as memoryStore, t as localStorageStore } from "./sessionStore-DD6lON9W.js";
|
|
4
4
|
export { AccountSuspendedError, AuthError, CaptchaFailedError, EmailAlreadyHasPasswordError, InvalidCredentialsError, InvalidEmailError, InvalidPasswordError, MaxAttemptsError, MaxResendsError, NoPasswordSetError, NoPendingOtpError, OtpExpiredError, OtpInvalidError, RateLimitedError, ResendCooldownError, authErrorFromFetchFailure, authErrorFromResponse, createAuthClient, localStorageStore, memoryStore };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { t as Account } from "./session-Cs_P7ojF.js";
|
|
2
|
+
|
|
3
|
+
//#region src/types/profile.d.ts
|
|
4
|
+
/** The account's profile record; every field is user-editable and nullable. */
|
|
5
|
+
type Profile = {
|
|
6
|
+
displayName: string | null;
|
|
7
|
+
avatarUrl: string | null;
|
|
8
|
+
primaryEmail: string | null;
|
|
9
|
+
primaryPhone: string | null;
|
|
10
|
+
};
|
|
11
|
+
/** The account as returned by `auth.getProfile`, with sign-in capability flags. */
|
|
12
|
+
type ProfileAccount = Account & {
|
|
13
|
+
/**
|
|
14
|
+
* `true` when the account can sign in with a password; `false` for
|
|
15
|
+
* Google-only or code-only accounts, which should call
|
|
16
|
+
* `auth.emailPassword.setPassword` rather than `changePassword`.
|
|
17
|
+
*/
|
|
18
|
+
hasPassword: boolean;
|
|
19
|
+
};
|
|
20
|
+
/** Result of `auth.getProfile`, the identity read for the token holder. */
|
|
21
|
+
type ProfileResult = {
|
|
22
|
+
/** `status` is the live account status, not a token-time snapshot. */account: ProfileAccount; /** `null` when the account has no profile row yet. */
|
|
23
|
+
profile: Profile | null;
|
|
24
|
+
};
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region src/types/requests.d.ts
|
|
27
|
+
/** Optional captcha argument shared by every public unauthenticated entrypoint. */
|
|
28
|
+
type CaptchaArgs = {
|
|
29
|
+
/** Cloudflare Turnstile token. Required when captcha is enabled on the server. */captchaToken?: string;
|
|
30
|
+
};
|
|
31
|
+
type SendLoginCodeInput = {
|
|
32
|
+
email: string;
|
|
33
|
+
} & CaptchaArgs;
|
|
34
|
+
type VerifyLoginCodeInput = {
|
|
35
|
+
email: string;
|
|
36
|
+
code: string;
|
|
37
|
+
};
|
|
38
|
+
type ResendLoginCodeInput = {
|
|
39
|
+
email: string;
|
|
40
|
+
} & CaptchaArgs;
|
|
41
|
+
type RegisterInput = {
|
|
42
|
+
email: string;
|
|
43
|
+
password: string;
|
|
44
|
+
} & CaptchaArgs;
|
|
45
|
+
type VerifyRegistrationCodeInput = {
|
|
46
|
+
email: string;
|
|
47
|
+
code: string;
|
|
48
|
+
};
|
|
49
|
+
type ResendRegistrationCodeInput = {
|
|
50
|
+
email: string;
|
|
51
|
+
} & CaptchaArgs;
|
|
52
|
+
type LoginWithPasswordInput = {
|
|
53
|
+
email: string;
|
|
54
|
+
password: string;
|
|
55
|
+
} & CaptchaArgs;
|
|
56
|
+
type SetPasswordInput = {
|
|
57
|
+
password: string;
|
|
58
|
+
};
|
|
59
|
+
type ChangePasswordInput = {
|
|
60
|
+
currentPassword: string;
|
|
61
|
+
newPassword: string;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Exactly one of the two shapes. `idToken` comes from Google Identity Services
|
|
65
|
+
* (`renderButton` / One Tap). `code` is the authorization code from
|
|
66
|
+
* `google.accounts.oauth2.initCodeClient` in popup mode; the server exchanges
|
|
67
|
+
* it for the ID token, so the client secret never reaches the browser.
|
|
68
|
+
*/
|
|
69
|
+
type LoginWithGoogleInput = {
|
|
70
|
+
idToken: string;
|
|
71
|
+
} | {
|
|
72
|
+
code: string;
|
|
73
|
+
};
|
|
74
|
+
//#endregion
|
|
75
|
+
export { RegisterInput as a, SendLoginCodeInput as c, VerifyRegistrationCodeInput as d, Profile as f, LoginWithPasswordInput as i, SetPasswordInput as l, ProfileResult as m, ChangePasswordInput as n, ResendLoginCodeInput as o, ProfileAccount as p, LoginWithGoogleInput as r, ResendRegistrationCodeInput as s, CaptchaArgs as t, VerifyLoginCodeInput as u };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
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-Cs_P7ojF.js";
|
|
2
|
-
import { a as RegisterInput, c as SendLoginCodeInput, d as VerifyRegistrationCodeInput, i as LoginWithPasswordInput, l as SetPasswordInput, n as ChangePasswordInput, o as ResendLoginCodeInput, r as LoginWithGoogleInput, s as ResendRegistrationCodeInput, t as CaptchaArgs, u as VerifyLoginCodeInput } from "../requests-
|
|
2
|
+
import { a as RegisterInput, c as SendLoginCodeInput, d as VerifyRegistrationCodeInput, f as Profile, i as LoginWithPasswordInput, l as SetPasswordInput, m as ProfileResult, n as ChangePasswordInput, o as ResendLoginCodeInput, p as ProfileAccount, r as LoginWithGoogleInput, s as ResendRegistrationCodeInput, t as CaptchaArgs, u as VerifyLoginCodeInput } from "../requests-jRLgNXyf.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 LoginWithGoogleInput, type LoginWithPasswordInput, type OtpInfo, 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 AuthSession, type CaptchaArgs, type ChangePasswordInput, type ErrorHandler, type ErrorSource, 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 };
|
package/dist/wallet/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@baliola/auth-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Client SDK for Baliola Auth",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"auth",
|
|
7
|
+
"authentication",
|
|
8
|
+
"passwordless",
|
|
9
|
+
"otp",
|
|
10
|
+
"email-otp",
|
|
11
|
+
"jwt",
|
|
12
|
+
"session",
|
|
13
|
+
"sdk",
|
|
14
|
+
"typescript",
|
|
15
|
+
"esm",
|
|
16
|
+
"baliola"
|
|
17
|
+
],
|
|
5
18
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
19
|
"author": "Baliola Development Team",
|
|
7
20
|
"type": "module",
|
|
@@ -41,26 +54,47 @@
|
|
|
41
54
|
"README.md",
|
|
42
55
|
"CHANGELOG.md"
|
|
43
56
|
],
|
|
57
|
+
"engines": {
|
|
58
|
+
"node": ">=20.3.0"
|
|
59
|
+
},
|
|
44
60
|
"publishConfig": {
|
|
45
61
|
"registry": "https://registry.npmjs.org",
|
|
46
62
|
"access": "public"
|
|
47
63
|
},
|
|
48
64
|
"repository": {
|
|
49
65
|
"type": "git",
|
|
50
|
-
"url": "git+https://github.com/baliola/baliola-auth.git"
|
|
51
|
-
|
|
66
|
+
"url": "git+https://github.com/baliola/baliola-auth-sdk.git"
|
|
67
|
+
},
|
|
68
|
+
"homepage": "https://github.com/baliola/baliola-auth-sdk#readme",
|
|
69
|
+
"bugs": {
|
|
70
|
+
"url": "https://github.com/baliola/baliola-auth-sdk/issues"
|
|
52
71
|
},
|
|
53
72
|
"scripts": {
|
|
54
73
|
"build": "tsdown",
|
|
55
74
|
"typecheck": "bash scripts/typecheck.sh",
|
|
56
75
|
"test": "bun test test/unit",
|
|
76
|
+
"lint": "eslint",
|
|
77
|
+
"lint:fix": "eslint --fix",
|
|
78
|
+
"format": "prettier --write \"{src,test}/**/*.ts\" \"*.ts\"",
|
|
79
|
+
"format:check": "prettier --check \"{src,test}/**/*.ts\" \"*.ts\"",
|
|
57
80
|
"prepublishOnly": "bun run build"
|
|
58
81
|
},
|
|
59
82
|
"peerDependencies": { "viem": "^2.47.6" },
|
|
83
|
+
"peerDependenciesMeta": { "viem": { "optional": true } },
|
|
60
84
|
"devDependencies": {
|
|
61
|
-
"@
|
|
85
|
+
"@eslint/js": "^10.0.1",
|
|
86
|
+
"@types/bun": "^1.4.0",
|
|
87
|
+
"eslint": "^10.7.0",
|
|
88
|
+
"eslint-config-prettier": "^10.1.8",
|
|
89
|
+
"eslint-plugin-import-x": "^4.17.1",
|
|
90
|
+
"eslint-plugin-prettier": "^5.5.6",
|
|
91
|
+
"eslint-plugin-unused-imports": "^4.4.1",
|
|
92
|
+
"globals": "^17.7.0",
|
|
93
|
+
"jiti": "^2.7.0",
|
|
94
|
+
"prettier": "3.8.1",
|
|
62
95
|
"tsdown": "^0.21.10",
|
|
63
96
|
"typescript": "^5.7.0",
|
|
97
|
+
"typescript-eslint": "^8.64.0",
|
|
64
98
|
"viem": "^2.47.6"
|
|
65
99
|
}
|
|
66
100
|
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
//#region src/types/requests.d.ts
|
|
2
|
-
/** Optional captcha argument shared by every public unauthenticated entrypoint. */
|
|
3
|
-
type CaptchaArgs = {
|
|
4
|
-
/** Cloudflare Turnstile token. Required when captcha is enabled on the server. */captchaToken?: string;
|
|
5
|
-
};
|
|
6
|
-
type SendLoginCodeInput = {
|
|
7
|
-
email: string;
|
|
8
|
-
} & CaptchaArgs;
|
|
9
|
-
type VerifyLoginCodeInput = {
|
|
10
|
-
email: string;
|
|
11
|
-
code: string;
|
|
12
|
-
};
|
|
13
|
-
type ResendLoginCodeInput = {
|
|
14
|
-
email: string;
|
|
15
|
-
} & CaptchaArgs;
|
|
16
|
-
type RegisterInput = {
|
|
17
|
-
email: string;
|
|
18
|
-
password: string;
|
|
19
|
-
} & CaptchaArgs;
|
|
20
|
-
type VerifyRegistrationCodeInput = {
|
|
21
|
-
email: string;
|
|
22
|
-
code: string;
|
|
23
|
-
};
|
|
24
|
-
type ResendRegistrationCodeInput = {
|
|
25
|
-
email: string;
|
|
26
|
-
} & CaptchaArgs;
|
|
27
|
-
type LoginWithPasswordInput = {
|
|
28
|
-
email: string;
|
|
29
|
-
password: string;
|
|
30
|
-
} & CaptchaArgs;
|
|
31
|
-
type SetPasswordInput = {
|
|
32
|
-
password: string;
|
|
33
|
-
};
|
|
34
|
-
type ChangePasswordInput = {
|
|
35
|
-
currentPassword: string;
|
|
36
|
-
newPassword: string;
|
|
37
|
-
};
|
|
38
|
-
type LoginWithGoogleInput = {
|
|
39
|
-
idToken: string;
|
|
40
|
-
};
|
|
41
|
-
//#endregion
|
|
42
|
-
export { RegisterInput as a, SendLoginCodeInput as c, VerifyRegistrationCodeInput as d, LoginWithPasswordInput as i, SetPasswordInput as l, ChangePasswordInput as n, ResendLoginCodeInput as o, LoginWithGoogleInput as r, ResendRegistrationCodeInput as s, CaptchaArgs as t, VerifyLoginCodeInput as u };
|