@lumoauth/client 1.4.2 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +35 -13
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -179,8 +179,10 @@ such as `document.edit`.
179
179
  ```ts
180
180
  const canEdit = await client.permissions.check('document.edit');
181
181
 
182
- // Optional context for policies that read request data
183
- const canEditThis = await client.permissions.check('document.edit', { document_id: 456 });
182
+ // Optional context for ABAC policies: `resource_id` selects the resource whose stored
183
+ // attributes the policies read. Other keys count only when they are the slug of an
184
+ // environment attribute that your organization defined; anything else is ignored.
185
+ const canEditThis = await client.permissions.check('document.edit', { resource_id: 'doc-456' });
184
186
 
185
187
  // Many permissions in one request
186
188
  const { results } = await client.permissions.checkBulk(['document.edit', 'document.delete']);
@@ -341,14 +343,15 @@ user straight to that social provider.
341
343
  These calls let you build your own sign-in screen.
342
344
 
343
345
  ```ts
344
- // Which sign-in methods can this person use?
345
- const found = await client.auth.checkEmailExists('ada@example.com');
346
- // found.exists, found.passwordEnabled, found.passkeyEnabled, found.magicLinkEnabled,
347
- // found.hasPasskey, found.hasPushDevice, found.maskedEmail, …
346
+ // Which sign-in methods does the organization offer?
347
+ const methods = await client.auth.checkEmailExists('ada@example.com');
348
+ // methods.passwordEnabled, methods.passkeyEnabled, methods.magicLinkEnabled
349
+ // methods.exists is true whenever the server answered. It does not say
350
+ // whether the address has an account.
348
351
 
349
- // Email a one-time sign-in link. The result is always { sent: true },
350
- // so the response never reveals whether the account exists.
351
- await client.auth.requestMagicLink({ email: 'ada@example.com', redirectUri: 'https://myapp.example.com/' });
352
+ // Email a one-time sign-in link. The answer is { sent: true } whether or not
353
+ // the account exists, so the response never reveals that.
354
+ await client.auth.requestMagicLink({ email: 'ada@example.com', returnTo: 'https://myapp.example.com/signed-in' });
352
355
 
353
356
  // Sign in with a password on your own form
354
357
  const result = await client.auth.loginWithPassword({ email, password });
@@ -360,8 +363,27 @@ if (result.status === 'complete') {
360
363
  }
361
364
  ```
362
365
 
363
- `checkEmailExists` never throws for a network failure or an unknown email. It returns an object
364
- in which every flag is `false`, so your screen can fall back to the hosted login page.
366
+ `checkEmailExists` names your application (`clientId`) and sends no cookie. From a browser, the
367
+ origin of your app must be one of the application's allowed origins. The answer holds the
368
+ sign-in methods of the organization and is the same for every address. A known address and a new
369
+ one cannot be told apart, so show the same next step to everyone. An unknown address fails at
370
+ that step in the same way as a wrong password. `hasPasskey` and `hasPushDevice` are always
371
+ `false`. Offer a passkey when `passkeyEnabled` is `true`.
372
+
373
+ `checkEmailExists` never throws. When the check is not available (a network failure, a rate
374
+ limit, or a refused request such as an origin that is not allowed), it returns an object in
375
+ which every flag is `false`, `exists` included. Your screen can then fall back to the hosted
376
+ login page.
377
+
378
+ `requestMagicLink` names your application (`clientId`) and sends no cookie. From a browser, the
379
+ origin of your app must be one of the application's allowed origins. The link opens a
380
+ confirmation page at LumoAuth. After the person confirms, they are signed in at LumoAuth and sent
381
+ to `returnTo`: a page of your app on an allowed origin or on the origin of a redirect URI, with at
382
+ most 1,024 characters. Start the PKCE redirect on that page. LumoAuth issues a code without
383
+ showing its own login page. The call throws a `LumoAuthApiError` when the server refuses the
384
+ request. `code` holds the reason: `magic_link_disabled`, `invalid_client`, `origin_not_allowed`,
385
+ `invalid_return_to`, `captcha_required`, `captcha_failed` or `rate_limited`. When the organization
386
+ protects sign-in link requests with a CAPTCHA, pass the token of the widget as `captchaToken`.
365
387
 
366
388
  `loginWithPassword` returns one of these statuses: `complete`, `mfa_required`,
367
389
  `invalid_credentials`, `blocked`, `inactive`, `rate_limited`, `invalid_request` or `error`. The
@@ -701,8 +723,8 @@ Every request and response also has a Zod schema, exported with its type, such a
701
723
  | | `refreshToken(refreshToken)` | `TokenResponse` | `orgId`, `clientId` |
702
724
  | | `revokeToken(token, accessToken?)` | `void` | `orgId`, `clientId` |
703
725
  | | `getUserInfo(accessToken)` | `UserInfo` | `orgId` |
704
- | | `checkEmailExists(email)` | `EmailCheckResult` | `orgId` |
705
- | | `requestMagicLink({ email, redirectUri? })` | `{ sent: true }` | `orgId` |
726
+ | | `checkEmailExists(email)` | `EmailCheckResult` | `orgId`, `clientId` |
727
+ | | `requestMagicLink({ email, returnTo?, captchaToken? })` | `{ sent: true }` | `orgId`, `clientId` |
706
728
  | | `loginWithPassword({ email, password })` | `{ status, challengeUrl? }` | `orgId` |
707
729
  | | `passwordGrant(username, password, …)` | `TokenResponse` | older grant; the organization must allow it |
708
730
  | `agents` | `ask(action, context?)` / `isAllowed(action, context?)` | decision / `boolean` | `orgId` |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lumoauth/client",
3
- "version": "1.4.2",
3
+ "version": "1.6.0",
4
4
  "description": "Official LumoAuth browser SDK — OAuth 2.0 PKCE, permissions, Zanzibar (ReBAC), and ABAC for any JavaScript/TypeScript application.",
5
5
  "license": "MIT",
6
6
  "author": "LumoAuth",
@@ -38,7 +38,7 @@
38
38
  "browser"
39
39
  ],
40
40
  "dependencies": {
41
- "@lumoauth/shared": "^1.4.2",
41
+ "@lumoauth/shared": "^1.6.0",
42
42
  "zod": "^4.6.7"
43
43
  },
44
44
  "devDependencies": {