@passflow/core 0.36.1 → 0.37.1

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/README.md CHANGED
@@ -2,6 +2,39 @@
2
2
 
3
3
  ## Changelog
4
4
 
5
+ ### Version 0.37.1
6
+
7
+ - Changed: a step-up commit answered 401 with `error.grant.predates_credential_reset`,
8
+ `error.token.access_ended` or `error.user.not_found` marks the session invalid, as
9
+ `error.api.request.token.invalid` already did. In cookie mode `isAuthenticated()` then answers
10
+ `false`. In JSON mode the mark is not read: the tokens stay and no `SignOut` is raised until the
11
+ next refresh fails.
12
+ - Changed: `setPreferredTwoFactorMethod(method)` and `passflow.twoFactor.setPreferredMethod(method)`
13
+ are typed to answer the method, without `null`. The server always answers the method it stored.
14
+ - Docs: `suggested_method` from `switchToAlternative` is worked out again at the switch and can
15
+ differ from the first challenge's.
16
+
17
+ ### Version 0.37.0
18
+
19
+ - Added: the preferred second factor. `getPreferredTwoFactorMethod()` answers the method the
20
+ signed-in user prefers on this app, or `null`; `setPreferredTwoFactorMethod(method)` stores one
21
+ and answers it; `clearPreferredTwoFactorMethod()` removes it. The same calls are on
22
+ `passflow.twoFactor` as `getPreferredMethod()`, `setPreferredMethod(method)` and
23
+ `clearPreferredMethod()`. Their `Error` reports carry the operations
24
+ `2fa.preferred-method.read`, `2fa.preferred-method.set` and `2fa.preferred-method.clear`.
25
+ - Added: `suggested_method` and `account_hint` on `TwoFactorChallengeResponse`, and `account_hint`
26
+ on `TwoFactorEnrollmentResponse`.
27
+ - Added: `preferred` on `RegisteredTwoFactorMethod`, so `getRegisteredMethods()` marks the
28
+ preferred method.
29
+ - Added: `reset` on the answer of `validateTwoFactorSetupMagicLink`, on the session from
30
+ `getMagicLinkSession()` and on the `TwoFactorSetupMagicLinkValidated` payload. It is `true` for a
31
+ link an administrator sent to replace an enrolled authenticator, otherwise `false`.
32
+ - Changed on the server: a code check for a user with no second factor answers 400
33
+ `error.2fa.not_enabled` (it was 401). `verifyTwoFactor` and `useTwoFactorRecoveryCode` reject
34
+ with it, and the session and the pending sign-in are kept.
35
+ - These fields and calls need Passflow server v0.84.1 or later. An older server leaves the fields
36
+ out, and the preferred-method calls reject with its 404.
37
+
5
38
  ### Version 0.36.1
6
39
 
7
40
  - Added: `AppSettings.connections` (type `AppSettingsConnection`, `{ id, name, provider }`), the
@@ -958,6 +991,33 @@ switch (enrollment) {
958
991
  codes still work until they are regenerated. The SDK checks only the form (letters, digits and
959
992
  optional dashes) and upper-cases the code; the server decides whether it is valid. `remaining_recovery_codes` may be
960
993
  absent from the answer.
994
+ - **Bypass code.** A bypass code from an administrator has the form `XXXX-XXXX-XXXX` and goes where
995
+ a recovery code goes: pass it to `useTwoFactorRecoveryCode`. The SDK sends it upper-cased with its
996
+ dashes. The answer does not say which kind of code it was. `remaining_recovery_codes`, when sent,
997
+ still counts the user's recovery codes, so `TwoFactorRecoveryCodesLow` or
998
+ `TwoFactorRecoveryCodesExhausted` can follow a bypass code; without the count neither is raised.
999
+ - **Preferred method.** A signed-in user can choose the factor sign-in offers first:
1000
+
1001
+ ```typescript
1002
+ const preferred = await passflow.getPreferredTwoFactorMethod(); // "totp", or null
1003
+ await passflow.setPreferredTwoFactorMethod("email_otp"); // resolves "email_otp"
1004
+ await passflow.clearPreferredTwoFactorMethod();
1005
+ ```
1006
+
1007
+ `null` means the user has no preference this app can use now. The server refuses `recovery_codes`
1008
+ and a method the user cannot present at this app with 400
1009
+ `error.2fa.preferred_method.unavailable`. Clearing when nothing is stored is no error.
1010
+ `passflow.twoFactor.getRegisteredMethods()` marks the preferred method with `preferred: true`.
1011
+ - **Suggested method and account hint.** A v2 challenge carries `suggested_method`, the method
1012
+ sign-in offers first. From `requestChallenge` it equals `method`. From `switchToAlternative`,
1013
+ `method` is the one the user chose and `suggested_method` is the one sign-in would offer first
1014
+ now: the server works it out again at the switch, so it can differ from the first challenge's.
1015
+ `account_hint`, on the challenge and on `getTwoFactorEnrollment()`, is a masked name of the account
1016
+ signing in: the email (`h***@example.com`), else the phone (`***-***-1234`), else the username
1017
+ (`u***`). It is absent when the user has none. Older servers send neither field.
1018
+ - **No second factor.** `verifyTwoFactor` and `useTwoFactorRecoveryCode` reject with 400
1019
+ `error.2fa.not_enabled` when the user has no second factor. The session and the pending sign-in
1020
+ are kept.
961
1021
  - **Step-up offers what the server lists.** The step-up 403 from `/auth/session/exchange` carries
962
1022
  `available_factors`, the factors this user can step up with, and the SDK offers exactly those in
963
1023
  that order. Without it (older servers), TOTP is suggested before passkey. When the list is empty,
@@ -998,6 +1058,10 @@ switch (enrollment) {
998
1058
  - **The emailed link.** Call `validateTwoFactorSetupMagicLink(token)` on its page. While that session
999
1059
  is active, `getTwoFactorStatus`, `beginTwoFactorSetup` and `confirmTwoFactorSetup` run on it instead
1000
1060
  of the stored session, and a correct confirm ends it. A used link reads as error code `ALREADY_USED`.
1061
+ On a success, `reset` is `true` for a link an administrator sent to replace an enrolled
1062
+ authenticator: `beginTwoFactorSetup` on that session replaces it once, without a code. Otherwise
1063
+ `reset` is `false`. `getMagicLinkSession()` and the `TwoFactorSetupMagicLinkValidated` payload
1064
+ carry the same `reset`.
1001
1065
 
1002
1066
  ## Token Management
1003
1067