@softistx/janus 0.0.0-stage → 0.74.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/LICENSE +21 -0
- package/README.md +2929 -2
- package/dist/auth/api-keys/authenticate-key.d.ts +21 -0
- package/dist/auth/api-keys/authenticate-key.d.ts.map +1 -0
- package/dist/auth/api-keys/bound.d.ts +11 -0
- package/dist/auth/api-keys/bound.d.ts.map +1 -0
- package/dist/auth/api-keys/count.d.ts +8 -0
- package/dist/auth/api-keys/count.d.ts.map +1 -0
- package/dist/auth/api-keys/create/checks.d.ts +42 -0
- package/dist/auth/api-keys/create/checks.d.ts.map +1 -0
- package/dist/auth/api-keys/create/index.d.ts +10 -0
- package/dist/auth/api-keys/create/index.d.ts.map +1 -0
- package/dist/auth/api-keys/events.d.ts +22 -0
- package/dist/auth/api-keys/events.d.ts.map +1 -0
- package/dist/auth/api-keys/expiry.d.ts +11 -0
- package/dist/auth/api-keys/expiry.d.ts.map +1 -0
- package/dist/auth/api-keys/flows.d.ts +13 -0
- package/dist/auth/api-keys/flows.d.ts.map +1 -0
- package/dist/auth/api-keys/index.d.ts +11 -0
- package/dist/auth/api-keys/index.d.ts.map +1 -0
- package/dist/auth/api-keys/read.d.ts +10 -0
- package/dist/auth/api-keys/read.d.ts.map +1 -0
- package/dist/auth/api-keys/shape.d.ts +24 -0
- package/dist/auth/api-keys/shape.d.ts.map +1 -0
- package/dist/auth/api-keys/to-api-key.d.ts +8 -0
- package/dist/auth/api-keys/to-api-key.d.ts.map +1 -0
- package/dist/auth/api-keys/token.d.ts +23 -0
- package/dist/auth/api-keys/token.d.ts.map +1 -0
- package/dist/auth/api-keys/user-bound.d.ts +10 -0
- package/dist/auth/api-keys/user-bound.d.ts.map +1 -0
- package/dist/auth/at.d.ts +9 -0
- package/dist/auth/at.d.ts.map +1 -0
- package/dist/auth/avatar/any-type.d.ts +13 -0
- package/dist/auth/avatar/any-type.d.ts.map +1 -0
- package/dist/auth/avatar/flows.d.ts +7 -0
- package/dist/auth/avatar/flows.d.ts.map +1 -0
- package/dist/auth/avatar/id.d.ts +10 -0
- package/dist/auth/avatar/id.d.ts.map +1 -0
- package/dist/auth/avatar/index.d.ts +7 -0
- package/dist/auth/avatar/index.d.ts.map +1 -0
- package/dist/auth/avatar/remove.d.ts +10 -0
- package/dist/auth/avatar/remove.d.ts.map +1 -0
- package/dist/auth/avatar/set.d.ts +12 -0
- package/dist/auth/avatar/set.d.ts.map +1 -0
- package/dist/auth/concurrency-limit.d.ts +13 -0
- package/dist/auth/concurrency-limit.d.ts.map +1 -0
- package/dist/auth/config/api-keys-config.d.ts +33 -0
- package/dist/auth/config/api-keys-config.d.ts.map +1 -0
- package/dist/auth/config/hasher.d.ts +22 -0
- package/dist/auth/config/hasher.d.ts.map +1 -0
- package/dist/auth/config/index.d.ts +24 -0
- package/dist/auth/config/index.d.ts.map +1 -0
- package/dist/auth/config/invitations-config.d.ts +74 -0
- package/dist/auth/config/invitations-config.d.ts.map +1 -0
- package/dist/auth/config/janus-config.d.ts +233 -0
- package/dist/auth/config/janus-config.d.ts.map +1 -0
- package/dist/auth/config/magic-link-config.d.ts +6 -0
- package/dist/auth/config/magic-link-config.d.ts.map +1 -0
- package/dist/auth/config/names.d.ts +9 -0
- package/dist/auth/config/names.d.ts.map +1 -0
- package/dist/auth/config/normalize.d.ts +26 -0
- package/dist/auth/config/normalize.d.ts.map +1 -0
- package/dist/auth/config/passkeys-config.d.ts +49 -0
- package/dist/auth/config/passkeys-config.d.ts.map +1 -0
- package/dist/auth/config/password-config.d.ts +22 -0
- package/dist/auth/config/password-config.d.ts.map +1 -0
- package/dist/auth/config/reserved.d.ts +14 -0
- package/dist/auth/config/reserved.d.ts.map +1 -0
- package/dist/auth/config/resolve-api-keys.d.ts +5 -0
- package/dist/auth/config/resolve-api-keys.d.ts.map +1 -0
- package/dist/auth/config/resolve-config.d.ts +9 -0
- package/dist/auth/config/resolve-config.d.ts.map +1 -0
- package/dist/auth/config/resolve-cookie.d.ts +5 -0
- package/dist/auth/config/resolve-cookie.d.ts.map +1 -0
- package/dist/auth/config/resolve-devices.d.ts +5 -0
- package/dist/auth/config/resolve-devices.d.ts.map +1 -0
- package/dist/auth/config/resolve-invitation-types.d.ts +5 -0
- package/dist/auth/config/resolve-invitation-types.d.ts.map +1 -0
- package/dist/auth/config/resolve-invitations.d.ts +5 -0
- package/dist/auth/config/resolve-invitations.d.ts.map +1 -0
- package/dist/auth/config/resolve-magic-link.d.ts +4 -0
- package/dist/auth/config/resolve-magic-link.d.ts.map +1 -0
- package/dist/auth/config/resolve-passkeys.d.ts +5 -0
- package/dist/auth/config/resolve-passkeys.d.ts.map +1 -0
- package/dist/auth/config/resolve-second-factor.d.ts +5 -0
- package/dist/auth/config/resolve-second-factor.d.ts.map +1 -0
- package/dist/auth/config/resolve-social.d.ts +17 -0
- package/dist/auth/config/resolve-social.d.ts.map +1 -0
- package/dist/auth/config/resolve-throttle.d.ts +37 -0
- package/dist/auth/config/resolve-throttle.d.ts.map +1 -0
- package/dist/auth/config/resolve-type.d.ts +6 -0
- package/dist/auth/config/resolve-type.d.ts.map +1 -0
- package/dist/auth/config/resolved-config.d.ts +126 -0
- package/dist/auth/config/resolved-config.d.ts.map +1 -0
- package/dist/auth/config/social-config.d.ts +154 -0
- package/dist/auth/config/social-config.d.ts.map +1 -0
- package/dist/auth/config/user-type.d.ts +79 -0
- package/dist/auth/config/user-type.d.ts.map +1 -0
- package/dist/auth/config/warn-throttle-window.d.ts +14 -0
- package/dist/auth/config/warn-throttle-window.d.ts.map +1 -0
- package/dist/auth/context/create-context.d.ts +31 -0
- package/dist/auth/context/create-context.d.ts.map +1 -0
- package/dist/auth/context/index.d.ts +17 -0
- package/dist/auth/context/index.d.ts.map +1 -0
- package/dist/auth/context/logins.d.ts +28 -0
- package/dist/auth/context/logins.d.ts.map +1 -0
- package/dist/auth/context/password.d.ts +34 -0
- package/dist/auth/context/password.d.ts.map +1 -0
- package/dist/auth/context/records.d.ts +27 -0
- package/dist/auth/context/records.d.ts.map +1 -0
- package/dist/auth/context/user.d.ts +21 -0
- package/dist/auth/context/user.d.ts.map +1 -0
- package/dist/auth/context/validate-fields.d.ts +12 -0
- package/dist/auth/context/validate-fields.d.ts.map +1 -0
- package/dist/auth/counter-key.d.ts +20 -0
- package/dist/auth/counter-key.d.ts.map +1 -0
- package/dist/auth/derived-keys.d.ts +9 -0
- package/dist/auth/derived-keys.d.ts.map +1 -0
- package/dist/auth/devices/cookie.d.ts +56 -0
- package/dist/auth/devices/cookie.d.ts.map +1 -0
- package/dist/auth/devices/hint.d.ts +42 -0
- package/dist/auth/devices/hint.d.ts.map +1 -0
- package/dist/auth/devices/index.d.ts +11 -0
- package/dist/auth/devices/index.d.ts.map +1 -0
- package/dist/auth/devices/report.d.ts +11 -0
- package/dist/auth/devices/report.d.ts.map +1 -0
- package/dist/auth/devices/token.d.ts +13 -0
- package/dist/auth/devices/token.d.ts.map +1 -0
- package/dist/auth/email-flows/any-type-change-email.d.ts +18 -0
- package/dist/auth/email-flows/any-type-change-email.d.ts.map +1 -0
- package/dist/auth/email-flows/any-type-reset-password.d.ts +19 -0
- package/dist/auth/email-flows/any-type-reset-password.d.ts.map +1 -0
- package/dist/auth/email-flows/any-type-verify-email.d.ts +18 -0
- package/dist/auth/email-flows/any-type-verify-email.d.ts.map +1 -0
- package/dist/auth/email-flows/change-email-token.d.ts +47 -0
- package/dist/auth/email-flows/change-email-token.d.ts.map +1 -0
- package/dist/auth/email-flows/change-email.d.ts +17 -0
- package/dist/auth/email-flows/change-email.d.ts.map +1 -0
- package/dist/auth/email-flows/confirm-reset.d.ts +16 -0
- package/dist/auth/email-flows/confirm-reset.d.ts.map +1 -0
- package/dist/auth/email-flows/email-token.d.ts +30 -0
- package/dist/auth/email-flows/email-token.d.ts.map +1 -0
- package/dist/auth/email-flows/flows.d.ts +13 -0
- package/dist/auth/email-flows/flows.d.ts.map +1 -0
- package/dist/auth/email-flows/index.d.ts +10 -0
- package/dist/auth/email-flows/index.d.ts.map +1 -0
- package/dist/auth/email-flows/owner-of.d.ts +17 -0
- package/dist/auth/email-flows/owner-of.d.ts.map +1 -0
- package/dist/auth/email-flows/prove-first.d.ts +45 -0
- package/dist/auth/email-flows/prove-first.d.ts.map +1 -0
- package/dist/auth/email-flows/reset-password.d.ts +17 -0
- package/dist/auth/email-flows/reset-password.d.ts.map +1 -0
- package/dist/auth/email-flows/set-email-verified.d.ts +19 -0
- package/dist/auth/email-flows/set-email-verified.d.ts.map +1 -0
- package/dist/auth/email-flows/verify-email.d.ts +25 -0
- package/dist/auth/email-flows/verify-email.d.ts.map +1 -0
- package/dist/auth/email-sign-in.d.ts +51 -0
- package/dist/auth/email-sign-in.d.ts.map +1 -0
- package/dist/auth/events.d.ts +166 -0
- package/dist/auth/events.d.ts.map +1 -0
- package/dist/auth/first-proof.d.ts +43 -0
- package/dist/auth/first-proof.d.ts.map +1 -0
- package/dist/auth/hashers.d.ts +52 -0
- package/dist/auth/hashers.d.ts.map +1 -0
- package/dist/auth/index.d.ts +22 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/invitations/accept.d.ts +10 -0
- package/dist/auth/invitations/accept.d.ts.map +1 -0
- package/dist/auth/invitations/change-pending.d.ts +17 -0
- package/dist/auth/invitations/change-pending.d.ts.map +1 -0
- package/dist/auth/invitations/claim.d.ts +31 -0
- package/dist/auth/invitations/claim.d.ts.map +1 -0
- package/dist/auth/invitations/events.d.ts +46 -0
- package/dist/auth/invitations/events.d.ts.map +1 -0
- package/dist/auth/invitations/find-invitee.d.ts +20 -0
- package/dist/auth/invitations/find-invitee.d.ts.map +1 -0
- package/dist/auth/invitations/find-pending.d.ts +5 -0
- package/dist/auth/invitations/find-pending.d.ts.map +1 -0
- package/dist/auth/invitations/flows.d.ts +7 -0
- package/dist/auth/invitations/flows.d.ts.map +1 -0
- package/dist/auth/invitations/history-input.d.ts +29 -0
- package/dist/auth/invitations/history-input.d.ts.map +1 -0
- package/dist/auth/invitations/history.d.ts +10 -0
- package/dist/auth/invitations/history.d.ts.map +1 -0
- package/dist/auth/invitations/index.d.ts +11 -0
- package/dist/auth/invitations/index.d.ts.map +1 -0
- package/dist/auth/invitations/input.d.ts +30 -0
- package/dist/auth/invitations/input.d.ts.map +1 -0
- package/dist/auth/invitations/invited-type.d.ts +22 -0
- package/dist/auth/invitations/invited-type.d.ts.map +1 -0
- package/dist/auth/invitations/invitee.d.ts +11 -0
- package/dist/auth/invitations/invitee.d.ts.map +1 -0
- package/dist/auth/invitations/issue.d.ts +9 -0
- package/dist/auth/invitations/issue.d.ts.map +1 -0
- package/dist/auth/invitations/limit.d.ts +7 -0
- package/dist/auth/invitations/limit.d.ts.map +1 -0
- package/dist/auth/invitations/password-invitee.d.ts +18 -0
- package/dist/auth/invitations/password-invitee.d.ts.map +1 -0
- package/dist/auth/invitations/passwordless-invitee.d.ts +13 -0
- package/dist/auth/invitations/passwordless-invitee.d.ts.map +1 -0
- package/dist/auth/invitations/preview.d.ts +8 -0
- package/dist/auth/invitations/preview.d.ts.map +1 -0
- package/dist/auth/invitations/read.d.ts +10 -0
- package/dist/auth/invitations/read.d.ts.map +1 -0
- package/dist/auth/invitations/resend.d.ts +12 -0
- package/dist/auth/invitations/resend.d.ts.map +1 -0
- package/dist/auth/invitations/to-invitation.d.ts +11 -0
- package/dist/auth/invitations/to-invitation.d.ts.map +1 -0
- package/dist/auth/invitations/write.d.ts +17 -0
- package/dist/auth/invitations/write.d.ts.map +1 -0
- package/dist/auth/issuers/cache.d.ts +21 -0
- package/dist/auth/issuers/cache.d.ts.map +1 -0
- package/dist/auth/issuers/create.d.ts +18 -0
- package/dist/auth/issuers/create.d.ts.map +1 -0
- package/dist/auth/issuers/index.d.ts +3 -0
- package/dist/auth/issuers/index.d.ts.map +1 -0
- package/dist/auth/issuers/types.d.ts +45 -0
- package/dist/auth/issuers/types.d.ts.map +1 -0
- package/dist/auth/janus.d.ts +39 -0
- package/dist/auth/janus.d.ts.map +1 -0
- package/dist/auth/magic-link.d.ts +25 -0
- package/dist/auth/magic-link.d.ts.map +1 -0
- package/dist/auth/mail-requests.d.ts +55 -0
- package/dist/auth/mail-requests.d.ts.map +1 -0
- package/dist/auth/one-time/codes.d.ts +46 -0
- package/dist/auth/one-time/codes.d.ts.map +1 -0
- package/dist/auth/one-time/index.d.ts +15 -0
- package/dist/auth/one-time/index.d.ts.map +1 -0
- package/dist/auth/one-time/issue.d.ts +45 -0
- package/dist/auth/one-time/issue.d.ts.map +1 -0
- package/dist/auth/one-time/refusals.d.ts +26 -0
- package/dist/auth/one-time/refusals.d.ts.map +1 -0
- package/dist/auth/one-time/spend.d.ts +24 -0
- package/dist/auth/one-time/spend.d.ts.map +1 -0
- package/dist/auth/one-time/window.d.ts +50 -0
- package/dist/auth/one-time/window.d.ts.map +1 -0
- package/dist/auth/outage.d.ts +66 -0
- package/dist/auth/outage.d.ts.map +1 -0
- package/dist/auth/parse-sealing-keys.d.ts +26 -0
- package/dist/auth/parse-sealing-keys.d.ts.map +1 -0
- package/dist/auth/passkeys/assert.d.ts +51 -0
- package/dist/auth/passkeys/assert.d.ts.map +1 -0
- package/dist/auth/passkeys/assertion-options.d.ts +9 -0
- package/dist/auth/passkeys/assertion-options.d.ts.map +1 -0
- package/dist/auth/passkeys/challenge.d.ts +19 -0
- package/dist/auth/passkeys/challenge.d.ts.map +1 -0
- package/dist/auth/passkeys/commit.d.ts +33 -0
- package/dist/auth/passkeys/commit.d.ts.map +1 -0
- package/dist/auth/passkeys/flows.d.ts +13 -0
- package/dist/auth/passkeys/flows.d.ts.map +1 -0
- package/dist/auth/passkeys/index.d.ts +12 -0
- package/dist/auth/passkeys/index.d.ts.map +1 -0
- package/dist/auth/passkeys/manage.d.ts +11 -0
- package/dist/auth/passkeys/manage.d.ts.map +1 -0
- package/dist/auth/passkeys/name.d.ts +4 -0
- package/dist/auth/passkeys/name.d.ts.map +1 -0
- package/dist/auth/passkeys/register.d.ts +20 -0
- package/dist/auth/passkeys/register.d.ts.map +1 -0
- package/dist/auth/passkeys/registration-options.d.ts +22 -0
- package/dist/auth/passkeys/registration-options.d.ts.map +1 -0
- package/dist/auth/passkeys/remove-all.d.ts +26 -0
- package/dist/auth/passkeys/remove-all.d.ts.map +1 -0
- package/dist/auth/passkeys/sign-in-options.d.ts +12 -0
- package/dist/auth/passkeys/sign-in-options.d.ts.map +1 -0
- package/dist/auth/passkeys/sign-in.d.ts +21 -0
- package/dist/auth/passkeys/sign-in.d.ts.map +1 -0
- package/dist/auth/passkeys/verifier.d.ts +113 -0
- package/dist/auth/passkeys/verifier.d.ts.map +1 -0
- package/dist/auth/passkeys/view.d.ts +5 -0
- package/dist/auth/passkeys/view.d.ts.map +1 -0
- package/dist/auth/passkeys/wiring.d.ts +24 -0
- package/dist/auth/passkeys/wiring.d.ts.map +1 -0
- package/dist/auth/password-written.d.ts +55 -0
- package/dist/auth/password-written.d.ts.map +1 -0
- package/dist/auth/port/assert-api-keys.d.ts +21 -0
- package/dist/auth/port/assert-api-keys.d.ts.map +1 -0
- package/dist/auth/port/assert-invitations.d.ts +15 -0
- package/dist/auth/port/assert-invitations.d.ts.map +1 -0
- package/dist/auth/port/assert-stores.d.ts +16 -0
- package/dist/auth/port/assert-stores.d.ts.map +1 -0
- package/dist/auth/port/memory/api-keys/capabilities.d.ts +8 -0
- package/dist/auth/port/memory/api-keys/capabilities.d.ts.map +1 -0
- package/dist/auth/port/memory/api-keys/index.d.ts +13 -0
- package/dist/auth/port/memory/api-keys/index.d.ts.map +1 -0
- package/dist/auth/port/memory/api-keys/pages.d.ts +7 -0
- package/dist/auth/port/memory/api-keys/pages.d.ts.map +1 -0
- package/dist/auth/port/memory/copy.d.ts +6 -0
- package/dist/auth/port/memory/copy.d.ts.map +1 -0
- package/dist/auth/port/memory/index.d.ts +10 -0
- package/dist/auth/port/memory/index.d.ts.map +1 -0
- package/dist/auth/port/memory/invitations-pending.d.ts +6 -0
- package/dist/auth/port/memory/invitations-pending.d.ts.map +1 -0
- package/dist/auth/port/memory/invitations.d.ts +12 -0
- package/dist/auth/port/memory/invitations.d.ts.map +1 -0
- package/dist/auth/port/memory/passkeys.d.ts +9 -0
- package/dist/auth/port/memory/passkeys.d.ts.map +1 -0
- package/dist/auth/port/memory/sessions.d.ts +4 -0
- package/dist/auth/port/memory/sessions.d.ts.map +1 -0
- package/dist/auth/port/memory/social-links.d.ts +10 -0
- package/dist/auth/port/memory/social-links.d.ts.map +1 -0
- package/dist/auth/port/memory/stores.d.ts +26 -0
- package/dist/auth/port/memory/stores.d.ts.map +1 -0
- package/dist/auth/port/memory/tokens.d.ts +4 -0
- package/dist/auth/port/memory/tokens.d.ts.map +1 -0
- package/dist/auth/port/memory/user-index.d.ts +20 -0
- package/dist/auth/port/memory/user-index.d.ts.map +1 -0
- package/dist/auth/port/memory/user-update.d.ts +10 -0
- package/dist/auth/port/memory/user-update.d.ts.map +1 -0
- package/dist/auth/port/memory/users.d.ts +4 -0
- package/dist/auth/port/memory/users.d.ts.map +1 -0
- package/dist/auth/port/types/api-keys.d.ts +199 -0
- package/dist/auth/port/types/api-keys.d.ts.map +1 -0
- package/dist/auth/port/types/credentials.d.ts +46 -0
- package/dist/auth/port/types/credentials.d.ts.map +1 -0
- package/dist/auth/port/types/index.d.ts +75 -0
- package/dist/auth/port/types/index.d.ts.map +1 -0
- package/dist/auth/port/types/invitations/index.d.ts +15 -0
- package/dist/auth/port/types/invitations/index.d.ts.map +1 -0
- package/dist/auth/port/types/invitations/page.d.ts +52 -0
- package/dist/auth/port/types/invitations/page.d.ts.map +1 -0
- package/dist/auth/port/types/invitations/records.d.ts +101 -0
- package/dist/auth/port/types/invitations/records.d.ts.map +1 -0
- package/dist/auth/port/types/invitations/store.d.ts +82 -0
- package/dist/auth/port/types/invitations/store.d.ts.map +1 -0
- package/dist/auth/port/types/json.d.ts +27 -0
- package/dist/auth/port/types/json.d.ts.map +1 -0
- package/dist/auth/port/types/passkeys.d.ts +94 -0
- package/dist/auth/port/types/passkeys.d.ts.map +1 -0
- package/dist/auth/port/types/sessions.d.ts +142 -0
- package/dist/auth/port/types/sessions.d.ts.map +1 -0
- package/dist/auth/port/types/social-links.d.ts +72 -0
- package/dist/auth/port/types/social-links.d.ts.map +1 -0
- package/dist/auth/port/types/stores.d.ts +48 -0
- package/dist/auth/port/types/stores.d.ts.map +1 -0
- package/dist/auth/port/types/tokens.d.ts +168 -0
- package/dist/auth/port/types/tokens.d.ts.map +1 -0
- package/dist/auth/port/types/users.d.ts +260 -0
- package/dist/auth/port/types/users.d.ts.map +1 -0
- package/dist/auth/prepared.d.ts +21 -0
- package/dist/auth/prepared.d.ts.map +1 -0
- package/dist/auth/proven-sign-in.d.ts +22 -0
- package/dist/auth/proven-sign-in.d.ts.map +1 -0
- package/dist/auth/sealer-for.d.ts +44 -0
- package/dist/auth/sealer-for.d.ts.map +1 -0
- package/dist/auth/sealing.d.ts +36 -0
- package/dist/auth/sealing.d.ts.map +1 -0
- package/dist/auth/second-factor/activate.d.ts +9 -0
- package/dist/auth/second-factor/activate.d.ts.map +1 -0
- package/dist/auth/second-factor/app-code-attempts.d.ts +47 -0
- package/dist/auth/second-factor/app-code-attempts.d.ts.map +1 -0
- package/dist/auth/second-factor/challenge.d.ts +15 -0
- package/dist/auth/second-factor/challenge.d.ts.map +1 -0
- package/dist/auth/second-factor/codes-left.d.ts +14 -0
- package/dist/auth/second-factor/codes-left.d.ts.map +1 -0
- package/dist/auth/second-factor/disable.d.ts +10 -0
- package/dist/auth/second-factor/disable.d.ts.map +1 -0
- package/dist/auth/second-factor/enroll.d.ts +6 -0
- package/dist/auth/second-factor/enroll.d.ts.map +1 -0
- package/dist/auth/second-factor/factor.d.ts +33 -0
- package/dist/auth/second-factor/factor.d.ts.map +1 -0
- package/dist/auth/second-factor/flows.d.ts +36 -0
- package/dist/auth/second-factor/flows.d.ts.map +1 -0
- package/dist/auth/second-factor/lifecycle.d.ts +14 -0
- package/dist/auth/second-factor/lifecycle.d.ts.map +1 -0
- package/dist/auth/second-factor/passkey-confirm.d.ts +21 -0
- package/dist/auth/second-factor/passkey-confirm.d.ts.map +1 -0
- package/dist/auth/second-factor/recovery-codes.d.ts +36 -0
- package/dist/auth/second-factor/recovery-codes.d.ts.map +1 -0
- package/dist/auth/second-factor/recovery.d.ts +20 -0
- package/dist/auth/second-factor/recovery.d.ts.map +1 -0
- package/dist/auth/second-factor/redeem.d.ts +42 -0
- package/dist/auth/second-factor/redeem.d.ts.map +1 -0
- package/dist/auth/second-factor/refusal.d.ts +6 -0
- package/dist/auth/second-factor/refusal.d.ts.map +1 -0
- package/dist/auth/second-factor/regenerate.d.ts +12 -0
- package/dist/auth/second-factor/regenerate.d.ts.map +1 -0
- package/dist/auth/second-factor/reseal.d.ts +17 -0
- package/dist/auth/second-factor/reseal.d.ts.map +1 -0
- package/dist/auth/second-factor/spend-recovery-code.d.ts +15 -0
- package/dist/auth/second-factor/spend-recovery-code.d.ts.map +1 -0
- package/dist/auth/secrets.d.ts +17 -0
- package/dist/auth/secrets.d.ts.map +1 -0
- package/dist/auth/sessions/amr.d.ts +36 -0
- package/dist/auth/sessions/amr.d.ts.map +1 -0
- package/dist/auth/sessions/authenticate.d.ts +12 -0
- package/dist/auth/sessions/authenticate.d.ts.map +1 -0
- package/dist/auth/sessions/collect-expired.d.ts +15 -0
- package/dist/auth/sessions/collect-expired.d.ts.map +1 -0
- package/dist/auth/sessions/cookie.d.ts +9 -0
- package/dist/auth/sessions/cookie.d.ts.map +1 -0
- package/dist/auth/sessions/fresh.d.ts +35 -0
- package/dist/auth/sessions/fresh.d.ts.map +1 -0
- package/dist/auth/sessions/index.d.ts +12 -0
- package/dist/auth/sessions/index.d.ts.map +1 -0
- package/dist/auth/sessions/open-session.d.ts +22 -0
- package/dist/auth/sessions/open-session.d.ts.map +1 -0
- package/dist/auth/sessions/presented-token.d.ts +25 -0
- package/dist/auth/sessions/presented-token.d.ts.map +1 -0
- package/dist/auth/sessions/shared-api.d.ts +17 -0
- package/dist/auth/sessions/shared-api.d.ts.map +1 -0
- package/dist/auth/sessions/standing.d.ts +32 -0
- package/dist/auth/sessions/standing.d.ts.map +1 -0
- package/dist/auth/shared-api.d.ts +142 -0
- package/dist/auth/shared-api.d.ts.map +1 -0
- package/dist/auth/sign-in-attempts.d.ts +45 -0
- package/dist/auth/sign-in-attempts.d.ts.map +1 -0
- package/dist/auth/sign-in-code.d.ts +26 -0
- package/dist/auth/sign-in-code.d.ts.map +1 -0
- package/dist/auth/social/attach.d.ts +31 -0
- package/dist/auth/social/attach.d.ts.map +1 -0
- package/dist/auth/social/begin.d.ts +30 -0
- package/dist/auth/social/begin.d.ts.map +1 -0
- package/dist/auth/social/complete-link.d.ts +17 -0
- package/dist/auth/social/complete-link.d.ts.map +1 -0
- package/dist/auth/social/complete.d.ts +54 -0
- package/dist/auth/social/complete.d.ts.map +1 -0
- package/dist/auth/social/cookie.d.ts +16 -0
- package/dist/auth/social/cookie.d.ts.map +1 -0
- package/dist/auth/social/find-provider.d.ts +23 -0
- package/dist/auth/social/find-provider.d.ts.map +1 -0
- package/dist/auth/social/finish.d.ts +60 -0
- package/dist/auth/social/finish.d.ts.map +1 -0
- package/dist/auth/social/flow-cookie-value.d.ts +26 -0
- package/dist/auth/social/flow-cookie-value.d.ts.map +1 -0
- package/dist/auth/social/flow-secret.d.ts +40 -0
- package/dist/auth/social/flow-secret.d.ts.map +1 -0
- package/dist/auth/social/index.d.ts +19 -0
- package/dist/auth/social/index.d.ts.map +1 -0
- package/dist/auth/social/link-holder.d.ts +33 -0
- package/dist/auth/social/link-holder.d.ts.map +1 -0
- package/dist/auth/social/provider-call.d.ts +31 -0
- package/dist/auth/social/provider-call.d.ts.map +1 -0
- package/dist/auth/social/redeem.d.ts +45 -0
- package/dist/auth/social/redeem.d.ts.map +1 -0
- package/dist/auth/social/return-to.d.ts +18 -0
- package/dist/auth/social/return-to.d.ts.map +1 -0
- package/dist/auth/social/sign-in.d.ts +41 -0
- package/dist/auth/social/sign-in.d.ts.map +1 -0
- package/dist/auth/social/sign-up.d.ts +37 -0
- package/dist/auth/social/sign-up.d.ts.map +1 -0
- package/dist/auth/social/start.d.ts +21 -0
- package/dist/auth/social/start.d.ts.map +1 -0
- package/dist/auth/social/step-up-proof.d.ts +26 -0
- package/dist/auth/social/step-up-proof.d.ts.map +1 -0
- package/dist/auth/social/step-up-request.d.ts +28 -0
- package/dist/auth/social/step-up-request.d.ts.map +1 -0
- package/dist/auth/social/step-up.d.ts +19 -0
- package/dist/auth/social/step-up.d.ts.map +1 -0
- package/dist/auth/social/types-of.d.ts +12 -0
- package/dist/auth/social/types-of.d.ts.map +1 -0
- package/dist/auth/social/unlink.d.ts +23 -0
- package/dist/auth/social/unlink.d.ts.map +1 -0
- package/dist/auth/social/wiring.d.ts +10 -0
- package/dist/auth/social/wiring.d.ts.map +1 -0
- package/dist/auth/standard-schema.d.ts +41 -0
- package/dist/auth/standard-schema.d.ts.map +1 -0
- package/dist/auth/step-up/codes.d.ts +35 -0
- package/dist/auth/step-up/codes.d.ts.map +1 -0
- package/dist/auth/step-up/flows.d.ts +18 -0
- package/dist/auth/step-up/flows.d.ts.map +1 -0
- package/dist/auth/step-up/open.d.ts +23 -0
- package/dist/auth/step-up/open.d.ts.map +1 -0
- package/dist/auth/step-up/passkey.d.ts +31 -0
- package/dist/auth/step-up/passkey.d.ts.map +1 -0
- package/dist/auth/step-up/request.d.ts +15 -0
- package/dist/auth/step-up/request.d.ts.map +1 -0
- package/dist/auth/step-up/spend.d.ts +4 -0
- package/dist/auth/step-up/spend.d.ts.map +1 -0
- package/dist/auth/totp.d.ts +36 -0
- package/dist/auth/totp.d.ts.map +1 -0
- package/dist/auth/types/api-keys-of.d.ts +19 -0
- package/dist/auth/types/api-keys-of.d.ts.map +1 -0
- package/dist/auth/types/api-keys.d.ts +164 -0
- package/dist/auth/types/api-keys.d.ts.map +1 -0
- package/dist/auth/types/avatar.d.ts +72 -0
- package/dist/auth/types/avatar.d.ts.map +1 -0
- package/dist/auth/types/change-email.d.ts +82 -0
- package/dist/auth/types/change-email.d.ts.map +1 -0
- package/dist/auth/types/checks.d.ts +147 -0
- package/dist/auth/types/checks.d.ts.map +1 -0
- package/dist/auth/types/email-flows.d.ts +117 -0
- package/dist/auth/types/email-flows.d.ts.map +1 -0
- package/dist/auth/types/find-by-email.d.ts +31 -0
- package/dist/auth/types/find-by-email.d.ts.map +1 -0
- package/dist/auth/types/find-or-create.d.ts +59 -0
- package/dist/auth/types/find-or-create.d.ts.map +1 -0
- package/dist/auth/types/index.d.ts +38 -0
- package/dist/auth/types/index.d.ts.map +1 -0
- package/dist/auth/types/inference.d.ts +62 -0
- package/dist/auth/types/inference.d.ts.map +1 -0
- package/dist/auth/types/invitations/api.d.ts +203 -0
- package/dist/auth/types/invitations/api.d.ts.map +1 -0
- package/dist/auth/types/invitations/history.d.ts +87 -0
- package/dist/auth/types/invitations/history.d.ts.map +1 -0
- package/dist/auth/types/invitations/index.d.ts +10 -0
- package/dist/auth/types/invitations/index.d.ts.map +1 -0
- package/dist/auth/types/invitations/invitation.d.ts +76 -0
- package/dist/auth/types/invitations/invitation.d.ts.map +1 -0
- package/dist/auth/types/invitations/issue-type.d.ts +15 -0
- package/dist/auth/types/invitations/issue-type.d.ts.map +1 -0
- package/dist/auth/types/invitations-of.d.ts +26 -0
- package/dist/auth/types/invitations-of.d.ts.map +1 -0
- package/dist/auth/types/janus.d.ts +51 -0
- package/dist/auth/types/janus.d.ts.map +1 -0
- package/dist/auth/types/magic-link.d.ts +69 -0
- package/dist/auth/types/magic-link.d.ts.map +1 -0
- package/dist/auth/types/passkeys.d.ts +183 -0
- package/dist/auth/types/passkeys.d.ts.map +1 -0
- package/dist/auth/types/password.d.ts +113 -0
- package/dist/auth/types/password.d.ts.map +1 -0
- package/dist/auth/types/prepared.d.ts +68 -0
- package/dist/auth/types/prepared.d.ts.map +1 -0
- package/dist/auth/types/proven-sign-in.d.ts +43 -0
- package/dist/auth/types/proven-sign-in.d.ts.map +1 -0
- package/dist/auth/types/reset-password.d.ts +46 -0
- package/dist/auth/types/reset-password.d.ts.map +1 -0
- package/dist/auth/types/second-factor.d.ts +164 -0
- package/dist/auth/types/second-factor.d.ts.map +1 -0
- package/dist/auth/types/session.d.ts +68 -0
- package/dist/auth/types/session.d.ts.map +1 -0
- package/dist/auth/types/shared-api.d.ts +96 -0
- package/dist/auth/types/shared-api.d.ts.map +1 -0
- package/dist/auth/types/sign-in.d.ts +102 -0
- package/dist/auth/types/sign-in.d.ts.map +1 -0
- package/dist/auth/types/social-flow.d.ts +28 -0
- package/dist/auth/types/social-flow.d.ts.map +1 -0
- package/dist/auth/types/social-step-up.d.ts +38 -0
- package/dist/auth/types/social-step-up.d.ts.map +1 -0
- package/dist/auth/types/social.d.ts +201 -0
- package/dist/auth/types/social.d.ts.map +1 -0
- package/dist/auth/types/step-up.d.ts +133 -0
- package/dist/auth/types/step-up.d.ts.map +1 -0
- package/dist/auth/types/type-api.d.ts +29 -0
- package/dist/auth/types/type-api.d.ts.map +1 -0
- package/dist/auth/types/user-type.d.ts +106 -0
- package/dist/auth/types/user-type.d.ts.map +1 -0
- package/dist/auth/types/user.d.ts +62 -0
- package/dist/auth/types/user.d.ts.map +1 -0
- package/dist/auth/types/verify-email.d.ts +190 -0
- package/dist/auth/types/verify-email.d.ts.map +1 -0
- package/dist/auth/users/any-type-api.d.ts +6 -0
- package/dist/auth/users/any-type-api.d.ts.map +1 -0
- package/dist/auth/users/by-login.d.ts +10 -0
- package/dist/auth/users/by-login.d.ts.map +1 -0
- package/dist/auth/users/change-password.d.ts +26 -0
- package/dist/auth/users/change-password.d.ts.map +1 -0
- package/dist/auth/users/delete.d.ts +10 -0
- package/dist/auth/users/delete.d.ts.map +1 -0
- package/dist/auth/users/email-move-guard.d.ts +20 -0
- package/dist/auth/users/email-move-guard.d.ts.map +1 -0
- package/dist/auth/users/email-prefix.d.ts +23 -0
- package/dist/auth/users/email-prefix.d.ts.map +1 -0
- package/dist/auth/users/fields-patch.d.ts +21 -0
- package/dist/auth/users/fields-patch.d.ts.map +1 -0
- package/dist/auth/users/find-by-email.d.ts +11 -0
- package/dist/auth/users/find-by-email.d.ts.map +1 -0
- package/dist/auth/users/find-many.d.ts +29 -0
- package/dist/auth/users/find-many.d.ts.map +1 -0
- package/dist/auth/users/find-or-create.d.ts +12 -0
- package/dist/auth/users/find-or-create.d.ts.map +1 -0
- package/dist/auth/users/flow-types.d.ts +15 -0
- package/dist/auth/users/flow-types.d.ts.map +1 -0
- package/dist/auth/users/index.d.ts +9 -0
- package/dist/auth/users/index.d.ts.map +1 -0
- package/dist/auth/users/insert.d.ts +15 -0
- package/dist/auth/users/insert.d.ts.map +1 -0
- package/dist/auth/users/name-prefix.d.ts +19 -0
- package/dist/auth/users/name-prefix.d.ts.map +1 -0
- package/dist/auth/users/password-flows.d.ts +11 -0
- package/dist/auth/users/password-flows.d.ts.map +1 -0
- package/dist/auth/users/record-flows.d.ts +11 -0
- package/dist/auth/users/record-flows.d.ts.map +1 -0
- package/dist/auth/users/sign-in.d.ts +24 -0
- package/dist/auth/users/sign-in.d.ts.map +1 -0
- package/dist/auth/users/sign-up.d.ts +13 -0
- package/dist/auth/users/sign-up.d.ts.map +1 -0
- package/dist/auth/users/type-api.d.ts +10 -0
- package/dist/auth/users/type-api.d.ts.map +1 -0
- package/dist/auth/users/update.d.ts +16 -0
- package/dist/auth/users/update.d.ts.map +1 -0
- package/dist/background/background.d.ts +22 -0
- package/dist/background/background.d.ts.map +1 -0
- package/dist/chunks/index-2ttdcz7n.js +354 -0
- package/dist/chunks/index-2ttdcz7n.js.map +16 -0
- package/dist/chunks/index-5dxynm32.js +85 -0
- package/dist/chunks/index-5dxynm32.js.map +10 -0
- package/dist/chunks/index-7h34nqrm.js +732 -0
- package/dist/chunks/index-7h34nqrm.js.map +24 -0
- package/dist/chunks/index-ftz0ne6j.js +127 -0
- package/dist/chunks/index-ftz0ne6j.js.map +11 -0
- package/dist/chunks/index-n8jxmxeg.js +64 -0
- package/dist/chunks/index-n8jxmxeg.js.map +11 -0
- package/dist/conformance/api-keys/cases/bound.d.ts +3 -0
- package/dist/conformance/api-keys/cases/bound.d.ts.map +1 -0
- package/dist/conformance/api-keys/cases/expiry.d.ts +3 -0
- package/dist/conformance/api-keys/cases/expiry.d.ts.map +1 -0
- package/dist/conformance/api-keys/cases/index.d.ts +4 -0
- package/dist/conformance/api-keys/cases/index.d.ts.map +1 -0
- package/dist/conformance/api-keys/cases/insert.d.ts +3 -0
- package/dist/conformance/api-keys/cases/insert.d.ts.map +1 -0
- package/dist/conformance/api-keys/cases/outage.d.ts +3 -0
- package/dist/conformance/api-keys/cases/outage.d.ts.map +1 -0
- package/dist/conformance/api-keys/cases/revoke.d.ts +3 -0
- package/dist/conformance/api-keys/cases/revoke.d.ts.map +1 -0
- package/dist/conformance/api-keys/cases/touch.d.ts +3 -0
- package/dist/conformance/api-keys/cases/touch.d.ts.map +1 -0
- package/dist/conformance/api-keys/cases/user-bound.d.ts +3 -0
- package/dist/conformance/api-keys/cases/user-bound.d.ts.map +1 -0
- package/dist/conformance/api-keys/describe.d.ts +20 -0
- package/dist/conformance/api-keys/describe.d.ts.map +1 -0
- package/dist/conformance/api-keys/fixtures.d.ts +4 -0
- package/dist/conformance/api-keys/fixtures.d.ts.map +1 -0
- package/dist/conformance/api-keys/index.d.ts +18 -0
- package/dist/conformance/api-keys/index.d.ts.map +1 -0
- package/dist/conformance/api-keys/reference.d.ts +4 -0
- package/dist/conformance/api-keys/reference.d.ts.map +1 -0
- package/dist/conformance/api-keys/types.d.ts +42 -0
- package/dist/conformance/api-keys/types.d.ts.map +1 -0
- package/dist/conformance/assert.d.ts +40 -0
- package/dist/conformance/assert.d.ts.map +1 -0
- package/dist/conformance/cases/outage.d.ts +3 -0
- package/dist/conformance/cases/outage.d.ts.map +1 -0
- package/dist/conformance/cases/outage.passkeys.d.ts +12 -0
- package/dist/conformance/cases/outage.passkeys.d.ts.map +1 -0
- package/dist/conformance/cases/passkeys/deletion.d.ts +4 -0
- package/dist/conformance/cases/passkeys/deletion.d.ts.map +1 -0
- package/dist/conformance/cases/passkeys/index.d.ts +8 -0
- package/dist/conformance/cases/passkeys/index.d.ts.map +1 -0
- package/dist/conformance/cases/passkeys/inserts.d.ts +4 -0
- package/dist/conformance/cases/passkeys/inserts.d.ts.map +1 -0
- package/dist/conformance/cases/passkeys/reads.d.ts +4 -0
- package/dist/conformance/cases/passkeys/reads.d.ts.map +1 -0
- package/dist/conformance/cases/passkeys/uses.d.ts +4 -0
- package/dist/conformance/cases/passkeys/uses.d.ts.map +1 -0
- package/dist/conformance/cases/sessions/deletion.d.ts +4 -0
- package/dist/conformance/cases/sessions/deletion.d.ts.map +1 -0
- package/dist/conformance/cases/sessions/extension.d.ts +4 -0
- package/dist/conformance/cases/sessions/extension.d.ts.map +1 -0
- package/dist/conformance/cases/sessions/index.d.ts +4 -0
- package/dist/conformance/cases/sessions/index.d.ts.map +1 -0
- package/dist/conformance/cases/sessions/inserts.d.ts +4 -0
- package/dist/conformance/cases/sessions/inserts.d.ts.map +1 -0
- package/dist/conformance/cases/sessions/list.d.ts +4 -0
- package/dist/conformance/cases/sessions/list.d.ts.map +1 -0
- package/dist/conformance/cases/sessions/reads.d.ts +4 -0
- package/dist/conformance/cases/sessions/reads.d.ts.map +1 -0
- package/dist/conformance/cases/sessions/reauthentication.d.ts +4 -0
- package/dist/conformance/cases/sessions/reauthentication.d.ts.map +1 -0
- package/dist/conformance/cases/sessions/revocation.d.ts +4 -0
- package/dist/conformance/cases/sessions/revocation.d.ts.map +1 -0
- package/dist/conformance/cases/social-links/deletion.d.ts +4 -0
- package/dist/conformance/cases/social-links/deletion.d.ts.map +1 -0
- package/dist/conformance/cases/social-links/index.d.ts +8 -0
- package/dist/conformance/cases/social-links/index.d.ts.map +1 -0
- package/dist/conformance/cases/social-links/inserts.d.ts +4 -0
- package/dist/conformance/cases/social-links/inserts.d.ts.map +1 -0
- package/dist/conformance/cases/social-links/reads.d.ts +4 -0
- package/dist/conformance/cases/social-links/reads.d.ts.map +1 -0
- package/dist/conformance/cases/tokens/attempts.d.ts +7 -0
- package/dist/conformance/cases/tokens/attempts.d.ts.map +1 -0
- package/dist/conformance/cases/tokens/change-email.d.ts +8 -0
- package/dist/conformance/cases/tokens/change-email.d.ts.map +1 -0
- package/dist/conformance/cases/tokens/deletion.d.ts +4 -0
- package/dist/conformance/cases/tokens/deletion.d.ts.map +1 -0
- package/dist/conformance/cases/tokens/index.d.ts +4 -0
- package/dist/conformance/cases/tokens/index.d.ts.map +1 -0
- package/dist/conformance/cases/tokens/inserts.d.ts +7 -0
- package/dist/conformance/cases/tokens/inserts.d.ts.map +1 -0
- package/dist/conformance/cases/tokens/kinds.d.ts +7 -0
- package/dist/conformance/cases/tokens/kinds.d.ts.map +1 -0
- package/dist/conformance/cases/tokens/redemption.d.ts +7 -0
- package/dist/conformance/cases/tokens/redemption.d.ts.map +1 -0
- package/dist/conformance/cases/tokens/social-flow.d.ts +8 -0
- package/dist/conformance/cases/tokens/social-flow.d.ts.map +1 -0
- package/dist/conformance/cases/tokens/spending.d.ts +7 -0
- package/dist/conformance/cases/tokens/spending.d.ts.map +1 -0
- package/dist/conformance/cases/users/avatar.d.ts +8 -0
- package/dist/conformance/cases/users/avatar.d.ts.map +1 -0
- package/dist/conformance/cases/users/batch.d.ts +8 -0
- package/dist/conformance/cases/users/batch.d.ts.map +1 -0
- package/dist/conformance/cases/users/deletion.d.ts +4 -0
- package/dist/conformance/cases/users/deletion.d.ts.map +1 -0
- package/dist/conformance/cases/users/index.d.ts +4 -0
- package/dist/conformance/cases/users/index.d.ts.map +1 -0
- package/dist/conformance/cases/users/inserts.d.ts +4 -0
- package/dist/conformance/cases/users/inserts.d.ts.map +1 -0
- package/dist/conformance/cases/users/listing.d.ts +4 -0
- package/dist/conformance/cases/users/listing.d.ts.map +1 -0
- package/dist/conformance/cases/users/patches.d.ts +7 -0
- package/dist/conformance/cases/users/patches.d.ts.map +1 -0
- package/dist/conformance/cases/users/reads.d.ts +7 -0
- package/dist/conformance/cases/users/reads.d.ts.map +1 -0
- package/dist/conformance/cases/users/second-factor.d.ts +16 -0
- package/dist/conformance/cases/users/second-factor.d.ts.map +1 -0
- package/dist/conformance/cases/users/versions.d.ts +7 -0
- package/dist/conformance/cases/users/versions.d.ts.map +1 -0
- package/dist/conformance/describe.d.ts +82 -0
- package/dist/conformance/describe.d.ts.map +1 -0
- package/dist/conformance/fixtures.d.ts +31 -0
- package/dist/conformance/fixtures.d.ts.map +1 -0
- package/dist/conformance/index.d.ts +46 -0
- package/dist/conformance/index.d.ts.map +1 -0
- package/dist/conformance/index.js +4442 -0
- package/dist/conformance/index.js.map +86 -0
- package/dist/conformance/invitations/cases/actors.d.ts +3 -0
- package/dist/conformance/invitations/cases/actors.d.ts.map +1 -0
- package/dist/conformance/invitations/cases/find-pending.d.ts +3 -0
- package/dist/conformance/invitations/cases/find-pending.d.ts.map +1 -0
- package/dist/conformance/invitations/cases/imported.d.ts +3 -0
- package/dist/conformance/invitations/cases/imported.d.ts.map +1 -0
- package/dist/conformance/invitations/cases/index.d.ts +4 -0
- package/dist/conformance/invitations/cases/index.d.ts.map +1 -0
- package/dist/conformance/invitations/cases/insert.d.ts +3 -0
- package/dist/conformance/invitations/cases/insert.d.ts.map +1 -0
- package/dist/conformance/invitations/cases/list-lapsed.d.ts +3 -0
- package/dist/conformance/invitations/cases/list-lapsed.d.ts.map +1 -0
- package/dist/conformance/invitations/cases/list-status.d.ts +3 -0
- package/dist/conformance/invitations/cases/list-status.d.ts.map +1 -0
- package/dist/conformance/invitations/cases/list.d.ts +3 -0
- package/dist/conformance/invitations/cases/list.d.ts.map +1 -0
- package/dist/conformance/invitations/cases/outage.d.ts +3 -0
- package/dist/conformance/invitations/cases/outage.d.ts.map +1 -0
- package/dist/conformance/invitations/cases/scope.d.ts +3 -0
- package/dist/conformance/invitations/cases/scope.d.ts.map +1 -0
- package/dist/conformance/invitations/cases/update.d.ts +3 -0
- package/dist/conformance/invitations/cases/update.d.ts.map +1 -0
- package/dist/conformance/invitations/describe.d.ts +20 -0
- package/dist/conformance/invitations/describe.d.ts.map +1 -0
- package/dist/conformance/invitations/fixtures.d.ts +4 -0
- package/dist/conformance/invitations/fixtures.d.ts.map +1 -0
- package/dist/conformance/invitations/index.d.ts +18 -0
- package/dist/conformance/invitations/index.d.ts.map +1 -0
- package/dist/conformance/invitations/reference.d.ts +4 -0
- package/dist/conformance/invitations/reference.d.ts.map +1 -0
- package/dist/conformance/invitations/types.d.ts +34 -0
- package/dist/conformance/invitations/types.d.ts.map +1 -0
- package/dist/conformance/reference.d.ts +13 -0
- package/dist/conformance/reference.d.ts.map +1 -0
- package/dist/conformance/relations/cases/deletion.d.ts +4 -0
- package/dist/conformance/relations/cases/deletion.d.ts.map +1 -0
- package/dist/conformance/relations/cases/holders.d.ts +9 -0
- package/dist/conformance/relations/cases/holders.d.ts.map +1 -0
- package/dist/conformance/relations/cases/index.d.ts +4 -0
- package/dist/conformance/relations/cases/index.d.ts.map +1 -0
- package/dist/conformance/relations/cases/outage.d.ts +3 -0
- package/dist/conformance/relations/cases/outage.d.ts.map +1 -0
- package/dist/conformance/relations/cases/reads.d.ts +8 -0
- package/dist/conformance/relations/cases/reads.d.ts.map +1 -0
- package/dist/conformance/relations/cases/traversal.d.ts +7 -0
- package/dist/conformance/relations/cases/traversal.d.ts.map +1 -0
- package/dist/conformance/relations/cases/writes.d.ts +4 -0
- package/dist/conformance/relations/cases/writes.d.ts.map +1 -0
- package/dist/conformance/relations/describe.d.ts +20 -0
- package/dist/conformance/relations/describe.d.ts.map +1 -0
- package/dist/conformance/relations/fixtures.d.ts +8 -0
- package/dist/conformance/relations/fixtures.d.ts.map +1 -0
- package/dist/conformance/relations/index.d.ts +18 -0
- package/dist/conformance/relations/index.d.ts.map +1 -0
- package/dist/conformance/relations/reference.d.ts +4 -0
- package/dist/conformance/relations/reference.d.ts.map +1 -0
- package/dist/conformance/relations/types.d.ts +34 -0
- package/dist/conformance/relations/types.d.ts.map +1 -0
- package/dist/conformance/types.d.ts +79 -0
- package/dist/conformance/types.d.ts.map +1 -0
- package/dist/errors/janus-error/base.d.ts +47 -0
- package/dist/errors/janus-error/base.d.ts.map +1 -0
- package/dist/errors/janus-error/codes.credentials.d.ts +36 -0
- package/dist/errors/janus-error/codes.credentials.d.ts.map +1 -0
- package/dist/errors/janus-error/codes.d.ts +23 -0
- package/dist/errors/janus-error/codes.d.ts.map +1 -0
- package/dist/errors/janus-error/codes.invitations.d.ts +52 -0
- package/dist/errors/janus-error/codes.invitations.d.ts.map +1 -0
- package/dist/errors/janus-error/codes.one-time.d.ts +63 -0
- package/dist/errors/janus-error/codes.one-time.d.ts.map +1 -0
- package/dist/errors/janus-error/codes.records.d.ts +86 -0
- package/dist/errors/janus-error/codes.records.d.ts.map +1 -0
- package/dist/errors/janus-error/codes.social.d.ts +88 -0
- package/dist/errors/janus-error/codes.social.d.ts.map +1 -0
- package/dist/errors/janus-error/index.d.ts +17 -0
- package/dist/errors/janus-error/index.d.ts.map +1 -0
- package/dist/errors/janus-error/options.d.ts +105 -0
- package/dist/errors/janus-error/options.d.ts.map +1 -0
- package/dist/errors/janus-error/refusals.d.ts +151 -0
- package/dist/errors/janus-error/refusals.d.ts.map +1 -0
- package/dist/errors/janus-error/status.d.ts +21 -0
- package/dist/errors/janus-error/status.d.ts.map +1 -0
- package/dist/errors/janus-error/store.d.ts +36 -0
- package/dist/errors/janus-error/store.d.ts.map +1 -0
- package/dist/ids/derived.d.ts +25 -0
- package/dist/ids/derived.d.ts.map +1 -0
- package/dist/ids/id.d.ts +55 -0
- package/dist/ids/id.d.ts.map +1 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6948 -0
- package/dist/index.js.map +208 -0
- package/dist/pagination/cursor-page.d.ts +53 -0
- package/dist/pagination/cursor-page.d.ts.map +1 -0
- package/dist/permissions/bound-model.d.ts +10 -0
- package/dist/permissions/bound-model.d.ts.map +1 -0
- package/dist/permissions/can.d.ts +13 -0
- package/dist/permissions/can.d.ts.map +1 -0
- package/dist/permissions/engine.d.ts +49 -0
- package/dist/permissions/engine.d.ts.map +1 -0
- package/dist/permissions/holders.d.ts +12 -0
- package/dist/permissions/holders.d.ts.map +1 -0
- package/dist/permissions/index.d.ts +36 -0
- package/dist/permissions/index.d.ts.map +1 -0
- package/dist/permissions/index.js +924 -0
- package/dist/permissions/index.js.map +28 -0
- package/dist/permissions/input.d.ts +43 -0
- package/dist/permissions/input.d.ts.map +1 -0
- package/dist/permissions/list.d.ts +16 -0
- package/dist/permissions/list.d.ts.map +1 -0
- package/dist/permissions/model/can.d.ts +41 -0
- package/dist/permissions/model/can.d.ts.map +1 -0
- package/dist/permissions/model/config.d.ts +36 -0
- package/dist/permissions/model/config.d.ts.map +1 -0
- package/dist/permissions/model/constraint.d.ts +37 -0
- package/dist/permissions/model/constraint.d.ts.map +1 -0
- package/dist/permissions/model/ctx.d.ts +23 -0
- package/dist/permissions/model/ctx.d.ts.map +1 -0
- package/dist/permissions/model/define.d.ts +78 -0
- package/dist/permissions/model/define.d.ts.map +1 -0
- package/dist/permissions/model/from-field.d.ts +31 -0
- package/dist/permissions/model/from-field.d.ts.map +1 -0
- package/dist/permissions/model/grant.d.ts +81 -0
- package/dist/permissions/model/grant.d.ts.map +1 -0
- package/dist/permissions/model/list.d.ts +48 -0
- package/dist/permissions/model/list.d.ts.map +1 -0
- package/dist/permissions/model/names.d.ts +51 -0
- package/dist/permissions/model/names.d.ts.map +1 -0
- package/dist/permissions/model/permissions.d.ts +48 -0
- package/dist/permissions/model/permissions.d.ts.map +1 -0
- package/dist/permissions/model/refs.d.ts +36 -0
- package/dist/permissions/model/refs.d.ts.map +1 -0
- package/dist/permissions/model/refusal.d.ts +13 -0
- package/dist/permissions/model/refusal.d.ts.map +1 -0
- package/dist/permissions/model/unions.d.ts +3 -0
- package/dist/permissions/model/unions.d.ts.map +1 -0
- package/dist/permissions/model/when.d.ts +16 -0
- package/dist/permissions/model/when.d.ts.map +1 -0
- package/dist/permissions/port/holders.d.ts +38 -0
- package/dist/permissions/port/holders.d.ts.map +1 -0
- package/dist/permissions/port/memory.d.ts +17 -0
- package/dist/permissions/port/memory.d.ts.map +1 -0
- package/dist/permissions/port/types.d.ts +101 -0
- package/dist/permissions/port/types.d.ts.map +1 -0
- package/dist/permissions/replace.d.ts +25 -0
- package/dist/permissions/replace.d.ts.map +1 -0
- package/dist/permissions/resolve/declared-names.d.ts +24 -0
- package/dist/permissions/resolve/declared-names.d.ts.map +1 -0
- package/dist/permissions/resolve/refuse-data-beyond-root.d.ts +11 -0
- package/dist/permissions/resolve/refuse-data-beyond-root.d.ts.map +1 -0
- package/dist/permissions/resolve/refuse-loops.d.ts +10 -0
- package/dist/permissions/resolve/refuse-loops.d.ts.map +1 -0
- package/dist/permissions/resolve/resolve-model.d.ts +13 -0
- package/dist/permissions/resolve/resolve-model.d.ts.map +1 -0
- package/dist/permissions/resolve/resolve-relation.d.ts +9 -0
- package/dist/permissions/resolve/resolve-relation.d.ts.map +1 -0
- package/dist/permissions/resolve/resolve-rule.d.ts +12 -0
- package/dist/permissions/resolve/resolve-rule.d.ts.map +1 -0
- package/dist/permissions/resolve/resolved.d.ts +52 -0
- package/dist/permissions/resolve/resolved.d.ts.map +1 -0
- package/dist/permissions/resolve/step.d.ts +4 -0
- package/dist/permissions/resolve/step.d.ts.map +1 -0
- package/dist/permissions/reverse.d.ts +53 -0
- package/dist/permissions/reverse.d.ts.map +1 -0
- package/dist/permissions/walk.d.ts +29 -0
- package/dist/permissions/walk.d.ts.map +1 -0
- package/dist/stores/guard.d.ts +24 -0
- package/dist/stores/guard.d.ts.map +1 -0
- package/dist/stores/storable.d.ts +15 -0
- package/dist/stores/storable.d.ts.map +1 -0
- package/dist/subjects/notation.d.ts +39 -0
- package/dist/subjects/notation.d.ts.map +1 -0
- package/dist/subjects/subject.d.ts +128 -0
- package/dist/subjects/subject.d.ts.map +1 -0
- package/dist/testing/index.d.ts +12 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +26 -0
- package/dist/testing/index.js.map +10 -0
- package/dist/time/clock.d.ts +31 -0
- package/dist/time/clock.d.ts.map +1 -0
- package/dist/time/duration.d.ts +23 -0
- package/dist/time/duration.d.ts.map +1 -0
- package/docs/README.md +46 -0
- package/docs/guide/adapters.md +861 -0
- package/docs/guide/api-keys.md +316 -0
- package/docs/guide/avatars.md +334 -0
- package/docs/guide/devices.md +441 -0
- package/docs/guide/email-flows.md +880 -0
- package/docs/guide/errors.md +180 -0
- package/docs/guide/events.md +467 -0
- package/docs/guide/invitations.md +465 -0
- package/docs/guide/issuers.md +107 -0
- package/docs/guide/magic-link.md +580 -0
- package/docs/guide/migrating-invitations.md +142 -0
- package/docs/guide/passkeys.md +425 -0
- package/docs/guide/passwords.md +325 -0
- package/docs/guide/permissions.md +719 -0
- package/docs/guide/second-factor.md +1124 -0
- package/docs/guide/sessions.md +521 -0
- package/docs/guide/sign-in-code.md +631 -0
- package/docs/guide/social.md +648 -0
- package/docs/guide/step-up.md +262 -0
- package/docs/guide/users.md +557 -0
- package/docs/guide/vocabulary.md +316 -0
- package/docs/roadmap.md +102 -0
- package/docs/troubleshooting.md +3318 -0
- package/package.json +77 -5
|
@@ -0,0 +1,648 @@
|
|
|
1
|
+
# Social sign-in
|
|
2
|
+
|
|
3
|
+
This page is for letting users sign in, sign up and link accounts through an
|
|
4
|
+
external identity provider (Google, GitHub, …): the flow, the configuration,
|
|
5
|
+
every case `social.complete` decides, linking and unlinking, the second factor,
|
|
6
|
+
writing a provider, and testing with a fake one.
|
|
7
|
+
|
|
8
|
+
The core does **no HTTP and knows no protocol**. A provider is an object with
|
|
9
|
+
two calls (`SocialProvider`); everything else — the flow's secret, its cookie,
|
|
10
|
+
the account links, the sessions — is `@softistx/janus`'s. A ready-made package
|
|
11
|
+
of providers, `@softistx/janus-social`, follows; until it ships, write a
|
|
12
|
+
provider against the interface ([below](#writing-a-provider)).
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
import { z } from 'zod';
|
|
16
|
+
import { createMemoryStores, janus, scryptHasher, type SocialProvider } from '@softistx/janus';
|
|
17
|
+
|
|
18
|
+
declare const google: SocialProvider; // see "Writing a provider"
|
|
19
|
+
declare const github: SocialProvider;
|
|
20
|
+
|
|
21
|
+
export const auth = janus({
|
|
22
|
+
user: z.object({ email: z.email(), name: z.string() }),
|
|
23
|
+
password: { login: 'email' },
|
|
24
|
+
store: createMemoryStores(),
|
|
25
|
+
hasher: scryptHasher(),
|
|
26
|
+
social: {
|
|
27
|
+
providers: { google, github },
|
|
28
|
+
signUp: (profile) => ({ email: profile.email ?? '', name: profile.name ?? 'Unnamed' }),
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const start = await auth.social.start({ provider: 'google', returnTo: '/dashboard' });
|
|
33
|
+
// start.url — send the visitor there (302)
|
|
34
|
+
// start.setCookie — send it with the redirect
|
|
35
|
+
export { start };
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## How a flow works
|
|
39
|
+
|
|
40
|
+
1. **`start`** mints a secret, stores a one-time `socialFlow` token for it,
|
|
41
|
+
and derives `state`, `nonce` and the PKCE code verifier from the secret. It
|
|
42
|
+
hands those three to the provider's `authorizationUrl`, and answers the URL,
|
|
43
|
+
the `flow` (the secret and what it binds) and the `setCookie` that carries it.
|
|
44
|
+
2. The visitor goes to the provider, and the provider redirects back to your
|
|
45
|
+
callback route with query parameters.
|
|
46
|
+
3. **`complete`** takes those parameters and the cookie's value. It checks the
|
|
47
|
+
cookie and the `state`, spends the flow, hands the callback and the same
|
|
48
|
+
three values to the provider's `exchange`, and decides from the identity
|
|
49
|
+
the provider vouches for ([the cases](#what-complete-decides)).
|
|
50
|
+
|
|
51
|
+
The flow's `provider`, user type and `returnTo` are bound to the stored token:
|
|
52
|
+
a cookie edited to name another provider or another `returnTo`, or presented
|
|
53
|
+
with another flow's `state`, is refused (`FLOW_MISMATCH`).
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
interface SocialFlowStart {
|
|
57
|
+
readonly url: string; // the provider's authorization URL
|
|
58
|
+
readonly flow: string; // a secret: the cookie's value
|
|
59
|
+
readonly expiresAt: Date; // tokens.socialFlow, ten minutes by default
|
|
60
|
+
readonly setCookie: string; // the cookie as a Set-Cookie value
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
**The flow is a secret** like a session token. `setCookie` is `HttpOnly` and
|
|
65
|
+
`SameSite=Lax` — never `Strict`, which the browser would not send on the
|
|
66
|
+
provider's redirect — with the session cookie's `Path`, `Domain` and `Secure`.
|
|
67
|
+
Behind a backend-for-frontend, `flow` may be kept in that server's own cookie
|
|
68
|
+
instead of `setCookie`; hand it back to `complete` unchanged.
|
|
69
|
+
`setCookie` also carries `Max-Age` beside `Expires`. When the session cookie has
|
|
70
|
+
no `Domain`, is `Secure` and has `Path=/` (the defaults), the cookie is named
|
|
71
|
+
`__Host-janus-social-flow`, a prefix browsers hold to those terms; otherwise
|
|
72
|
+
`janus-social-flow`. Always read the name from `auth.social.cookie.name`.
|
|
73
|
+
`auth.social.cookie` has `name`, `serialize(flow, expiresAt)` and `clear()` for
|
|
74
|
+
reading the cookie and for clearing it after `complete`.
|
|
75
|
+
|
|
76
|
+
### What a refusal carries
|
|
77
|
+
|
|
78
|
+
An error raised **after** the flow was authenticated (`SOCIAL_ACCOUNT_TAKEN`,
|
|
79
|
+
`EMAIL_NOT_VERIFIED_FOR_LINK`, `SIGN_UP_DISABLED`, `EMAIL_UNVERIFIED`,
|
|
80
|
+
`USER_INACTIVE`, `SOCIAL_STEP_UP_UNMET`, and `PROVIDER_ERROR` from the exchange) has `returnTo`, the
|
|
81
|
+
path the flow was started with (`null` for none), so a redirect can send the
|
|
82
|
+
visitor back with `?socialError=<code>`. It is **not for logs**. `FLOW_MISMATCH`
|
|
83
|
+
and `FLOW_EXPIRED` never carry it: nobody vouched for that cookie. Nor does
|
|
84
|
+
`FLOW_PURPOSE_MISMATCH` (the flow is spent, `flowSpent: true`). Every
|
|
85
|
+
refusal of `complete` also has `flowSpent`: `false` for a missing cookie or a
|
|
86
|
+
foreign `state`, refused before anything was spent (keep the cookie, the real
|
|
87
|
+
callback may still come), `true` once the flow was spent (clear it). Read `flowSpent === false` as the only reason to keep the cookie: any other error, `flowSpent` unset included, means the flow is gone.
|
|
88
|
+
|
|
89
|
+
## Step-up per request
|
|
90
|
+
|
|
91
|
+
`start` and `link` take an optional `stepUp` to ask the provider for more than
|
|
92
|
+
a plain sign-in on **this** flow: a stronger authentication context
|
|
93
|
+
(`acr_values`), a recent active login (`max_age`), or both.
|
|
94
|
+
|
|
95
|
+
```ts
|
|
96
|
+
const { url, setCookie } = await auth.social.start({
|
|
97
|
+
provider: 'work-idp',
|
|
98
|
+
returnTo: '/billing',
|
|
99
|
+
stepUp: { acrValues: ['urn:example:mfa'], maxAge: 300 },
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
const result = await auth.social.complete({ callback, flow });
|
|
103
|
+
if (result.status === 'signedIn' && result.stepUp === null) {
|
|
104
|
+
// A plain flow: nothing was proven. Treat it as the plain sign-in it is.
|
|
105
|
+
}
|
|
106
|
+
// result.stepUp: { acrValues, maxAge, acr, authTime } — what was asked, what the provider reported
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
- **Shape.** `acrValues`: 1 to 10 strings, each 1 to 128 visible ASCII
|
|
110
|
+
characters without whitespace. `maxAge`: whole seconds, 0 to 2 592 000. At
|
|
111
|
+
least one of the two; anything else is a `TypeError` from `start`. The
|
|
112
|
+
request travels in the flow cookie, which holds 4 096 characters: a long
|
|
113
|
+
`returnTo` with many long `acrValues` that no longer fits is a `TypeError`
|
|
114
|
+
from `start` too (`returnTo and stepUp together are too long for the flow
|
|
115
|
+
cookie`), before the provider is asked, rather than a flow that is dead on
|
|
116
|
+
arrival.
|
|
117
|
+
- **The provider opts in** with `supportsStepUp: true` (`@softistx/janus-social`'s
|
|
118
|
+
`oidcProvider`, `oidcStepUp` do from 0.5.0; `google`,
|
|
119
|
+
`microsoft`, `github` and `oauth2Provider` do not). Without it `start` throws a
|
|
120
|
+
`TypeError` before any token: a provider that ignores `acr_values` would
|
|
121
|
+
otherwise look as if it had stepped up. It then sees the request as
|
|
122
|
+
`flow.stepUp` (`{ acrValues: string[] | null, maxAge: number | null }`, or
|
|
123
|
+
`null` for a plain flow) on `authorizationUrl` **and** `exchange`.
|
|
124
|
+
- **The core checks the proof**, never the provider. After `exchange` the
|
|
125
|
+
identity must carry `acr` (one of `acrValues`, byte for byte) and `authTime`
|
|
126
|
+
(a `Date`; within `maxAge` of the core's own clock, with 60 s of tolerance in
|
|
127
|
+
both directions, so `maxAge: 0` means "within about a minute"). **Evidence
|
|
128
|
+
that is missing counts as unmet**: `acr_values` is only a request. A flow
|
|
129
|
+
that does not hold up is `SOCIAL_STEP_UP_UNMET` (403, `reason`: `'acr'` or
|
|
130
|
+
`'authTime'` for your logs), spent, with nobody signed in or linked.
|
|
131
|
+
- **It is part of the flow.** The request travels in the flow cookie and is
|
|
132
|
+
bound to the stored token: removing or editing it is `FLOW_MISMATCH`. A flow
|
|
133
|
+
without `stepUp` keeps the four-part cookie it always had.
|
|
134
|
+
- **Every ending echoes it.** `signedIn`, `secondFactor` and `linked` carry
|
|
135
|
+
`stepUp: SocialStepUpProof | null`; on `secondFactor` the proof is here, not
|
|
136
|
+
asked again at `secondFactor.confirm`.
|
|
137
|
+
|
|
138
|
+
**Check `result.stepUp` yourself.** A plain flow and a step-up flow of the same
|
|
139
|
+
provider complete at the same callback, so a visitor can swap a plain cookie
|
|
140
|
+
into the callback of a flow you started with `stepUp`; it is genuine and signs
|
|
141
|
+
in with `stepUp: null`. When the sensitive action follows the callback, allow
|
|
142
|
+
it only when `result.stepUp !== null` (and, if it matters, that its `acr` or
|
|
143
|
+
`authTime` is what you need).
|
|
144
|
+
|
|
145
|
+
Rolling deploys: an instance from before this version reading a six-part cookie
|
|
146
|
+
answers `FLOW_MISMATCH`; the visitor starts again.
|
|
147
|
+
|
|
148
|
+
## Configuration
|
|
149
|
+
|
|
150
|
+
`social` sits on a user type, beside `password`. With several types, each
|
|
151
|
+
configures its own; a type that does not configure it has none.
|
|
152
|
+
|
|
153
|
+
```ts
|
|
154
|
+
interface SocialConfig {
|
|
155
|
+
readonly providers?: { readonly [name: string]: SocialProvider };
|
|
156
|
+
readonly resolveProvider?: SocialProviderResolver;
|
|
157
|
+
readonly signUp?: false | ((profile: SocialProfile) => unknown);
|
|
158
|
+
readonly freshWithin?: Duration;
|
|
159
|
+
}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
| Option | Type | Default | Effect |
|
|
163
|
+
| --- | --- | --- | --- |
|
|
164
|
+
| `social.providers` | `{ [name]: SocialProvider }` | required unless `resolveProvider` is given | The providers, by the application's name for each: lowercase letters, digits and `-`, starting with a letter, at most 32 characters. At least one, unless `resolveProvider` names the rest |
|
|
165
|
+
| `social.resolveProvider` | `SocialProviderResolver` (`(name) => Promise<SocialProvider \| null>`) | absent | Looks a provider up at request time, [below](#providers-resolved-at-request-time) |
|
|
166
|
+
| `social.signUp` | `false \| (profile: SocialProfile) => fields` | absent: a stranger is refused | Answers the fields of a new user from the profile. Only on a type whose login is its e-mail |
|
|
167
|
+
| `social.freshWithin` | `Duration` | `'10m'` | How recently the session must have proved who it is for `social.link` |
|
|
168
|
+
| `tokens.socialFlow` | `Duration` | `'10m'` | How long a flow waits for its callback |
|
|
169
|
+
|
|
170
|
+
```ts
|
|
171
|
+
import { z } from 'zod';
|
|
172
|
+
import { createMemoryStores, janus, scryptHasher, type SocialProvider } from '@softistx/janus';
|
|
173
|
+
|
|
174
|
+
declare const google: SocialProvider;
|
|
175
|
+
declare const github: SocialProvider;
|
|
176
|
+
|
|
177
|
+
const clinic = janus({
|
|
178
|
+
users: {
|
|
179
|
+
patient: {
|
|
180
|
+
schema: z.object({ email: z.email(), name: z.string() }),
|
|
181
|
+
password: { login: 'email' },
|
|
182
|
+
social: { providers: { google, github }, signUp: (profile) => ({ email: profile.email ?? '', name: profile.name ?? '' }) },
|
|
183
|
+
},
|
|
184
|
+
staff: { schema: z.object({ username: z.string() }), password: { login: 'username' } },
|
|
185
|
+
},
|
|
186
|
+
store: createMemoryStores(),
|
|
187
|
+
hasher: scryptHasher(),
|
|
188
|
+
tokens: { socialFlow: '5m' },
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
await clinic.social.start({ provider: 'github' }); // only patient has social: `type` is optional
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
- **`type`** on `start` is needed only when several user types configure
|
|
195
|
+
`social`; its type then requires it.
|
|
196
|
+
- **`signUp` receives a frozen `SocialProfile`**: `provider`, `accountId`,
|
|
197
|
+
`email`, `emailVerified`, and `name` and `picture` when the provider gave them.
|
|
198
|
+
Answer the schema's fields. The e-mail field must equal the provider's (else
|
|
199
|
+
`USER_INVALID`, nothing written). A `password` or `active` in the answer is
|
|
200
|
+
ignored: the user is created active, verified, with no password.
|
|
201
|
+
- **`signUp` on a type whose login is not its e-mail is refused at compile
|
|
202
|
+
time**, and at wiring with a `TypeError`: a username type would let a provider
|
|
203
|
+
claim a login. A type whose login is its e-mail is one with no password, or
|
|
204
|
+
`password.login` naming the e-mail field.
|
|
205
|
+
- **The store needs the `socialLinks` slot.** A type that configures `social`
|
|
206
|
+
on stores without it makes `janus()` throw a `TypeError` naming the type;
|
|
207
|
+
`createMemoryStores()` has it, and so does an adapter that implements
|
|
208
|
+
[`SocialLinkStore`](adapters.md). A bad provider name, no provider and no resolver, a
|
|
209
|
+
`signUp` that is not a function, or a `freshWithin` that is not a duration
|
|
210
|
+
are `TypeError`s at wiring too, and `social` cannot be a user type's name.
|
|
211
|
+
|
|
212
|
+
## Providers resolved at request time
|
|
213
|
+
|
|
214
|
+
When the providers are not known at wiring — each tenant of a product brings
|
|
215
|
+
its own identity provider, kept in the application's database — give
|
|
216
|
+
`social.resolveProvider` instead of (or beside) `providers`:
|
|
217
|
+
|
|
218
|
+
```ts
|
|
219
|
+
import type { SocialProvider, SocialProviderResolver } from '@softistx/janus';
|
|
220
|
+
|
|
221
|
+
declare function connectionOf(name: string): Promise<SocialProvider | null>;
|
|
222
|
+
|
|
223
|
+
const resolveProvider: SocialProviderResolver = (name) => connectionOf(name);
|
|
224
|
+
|
|
225
|
+
const auth = janus({
|
|
226
|
+
user: z.object({ email: z.email() }),
|
|
227
|
+
store: createMemoryStores(),
|
|
228
|
+
social: {
|
|
229
|
+
providers: { google }, // a name listed here always wins
|
|
230
|
+
resolveProvider, // null: not a connection
|
|
231
|
+
},
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
await auth.social.start({ provider: 'acme' }); // any name, known at request time
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
- **The static `providers` come first.** A name listed there never reaches the
|
|
238
|
+
resolver. This holds for a name of **any** user type's `providers`, not only
|
|
239
|
+
this one's: a name another type configures statically is
|
|
240
|
+
`SOCIAL_PROVIDER_UNKNOWN` here, without a call, so a resolver cannot shadow
|
|
241
|
+
a provider configured elsewhere.
|
|
242
|
+
- **The resolver only receives names that fit the provider-name pattern**
|
|
243
|
+
(lowercase letters, digits and `-`, starting with a letter, at most 32
|
|
244
|
+
characters); any other name is `SOCIAL_PROVIDER_UNKNOWN` without a call.
|
|
245
|
+
- **`null` is `SOCIAL_PROVIDER_UNKNOWN`.** It is asked at `start`, `link` **and
|
|
246
|
+
again at `complete`**, so a connection deleted between the two refuses the
|
|
247
|
+
callback (`flowSpent: true`, with the flow's `returnTo`); the flow is already
|
|
248
|
+
spent by then.
|
|
249
|
+
- **A throw propagates untouched**, never turned into `PROVIDER_ERROR`: a
|
|
250
|
+
`StoreFailure` from the application's database keeps its identity, so an
|
|
251
|
+
outage is not read as an unknown provider. At the callback the flow is spent
|
|
252
|
+
before the lookup, so a resolver outage there forces the user to restart.
|
|
253
|
+
- **The answer is checked like a static provider**: an object with
|
|
254
|
+
`authorizationUrl` and `exchange`, else a `TypeError` (the resolver's bug).
|
|
255
|
+
- **Answer the provider for exactly that name.** One provider answered for every
|
|
256
|
+
name merges accounts across connections.
|
|
257
|
+
- **The name is the connection's identity.** The flow cookie binds the name, and
|
|
258
|
+
the link is keyed by it: two tenants never share a link key. Do not reuse a
|
|
259
|
+
name for another identity provider while links to it exist.
|
|
260
|
+
- **A per-request step-up works** with a resolved provider: `supportsStepUp` is
|
|
261
|
+
read from the object the resolver answers.
|
|
262
|
+
- **Types**: with `resolveProvider`, `provider` is any `string` in `start`,
|
|
263
|
+
`link` and `unlink`; the compile-time check of provider names applies to a
|
|
264
|
+
type that lists `providers` only.
|
|
265
|
+
- The resolver runs on every `start` and `complete`: keep it cheap. (`oidcConnections`
|
|
266
|
+
reads one record per call and caches discovery per issuer.)
|
|
267
|
+
- **A `PROVIDER_ERROR` the resolver throws at `complete`** carries the flow's
|
|
268
|
+
`returnTo` and `flowSpent: true`, like any provider failure at the callback.
|
|
269
|
+
|
|
270
|
+
## What `complete` decides
|
|
271
|
+
|
|
272
|
+
`social.complete` is the callback route. It answers a `SocialCompleted`:
|
|
273
|
+
|
|
274
|
+
```ts
|
|
275
|
+
type SocialCompleted<U, Challenge extends SecondFactorRequired = SecondFactorRequired> =
|
|
276
|
+
| (SignedIn<U> & { provider: string; created: boolean; linked: boolean; returnTo: string | null })
|
|
277
|
+
| (Challenge & { provider: string; returnTo: string | null })
|
|
278
|
+
| SocialLinked<U>;
|
|
279
|
+
|
|
280
|
+
interface SocialLinked<U> { status: 'linked'; user: U; link: SocialLink; returnTo: string | null }
|
|
281
|
+
interface SocialLink { provider: string; accountId: string; email: string | null; linkedAt: Date }
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
Switch on `status`: `signedIn` has a `session` and a `token` like `signIn`,
|
|
285
|
+
`created` (a user was made for this account) and `linked` (this call linked the
|
|
286
|
+
account: a sign-up or an e-mail match; `false` for one linked already);
|
|
287
|
+
Both sign-in variants carry `provider`, the name you gave the provider that vouched.
|
|
288
|
+
`secondFactor` is a challenge; `linked` answers a link flow. `returnTo` is the
|
|
289
|
+
path the flow was started with, or `null`.
|
|
290
|
+
|
|
291
|
+
For a sign-in flow, the provider's identity decides, in this order:
|
|
292
|
+
|
|
293
|
+
| The identity | Answer | Event |
|
|
294
|
+
| --- | --- | --- |
|
|
295
|
+
| Its account is linked to a user of this flow's type | `signedIn`, `created: false`, `linked: false` | none |
|
|
296
|
+
| Its account is linked to a user of **another type** | `SOCIAL_ACCOUNT_TAKEN` (409) | none |
|
|
297
|
+
| Linked user is inactive | `USER_INACTIVE` (403) | none |
|
|
298
|
+
| Not linked; a user of the type holds its e-mail, the provider vouches for it **and** the user verified it | the account is linked, `signedIn`, `linked: true` | `user.socialLinked` |
|
|
299
|
+
| Not linked; a user holds the e-mail, but the provider or the user does not vouch for it | `EMAIL_NOT_VERIFIED_FOR_LINK` (409) | none |
|
|
300
|
+
| Not linked; nobody holds the e-mail; `social.signUp` is set; the provider vouches for the e-mail | a user is created, verified, no password; `signedIn`, `created: true`, `linked: true` | `user.created`, then `user.socialLinked` |
|
|
301
|
+
| …as above, but the provider does not vouch for the e-mail, or gave none | `EMAIL_UNVERIFIED` (403); nobody is created | none |
|
|
302
|
+
| …as above, with `social.signUp` absent or `false` | `SIGN_UP_DISABLED` (403) | none |
|
|
303
|
+
|
|
304
|
+
The e-mail is compared the way a login is: `Ada@Example.test` matches
|
|
305
|
+
`ada@example.test`. Two sign-ups racing for one address create one user; the
|
|
306
|
+
loser is linked to it, as an e-mail match is. A sign-up whose link cannot be
|
|
307
|
+
written (the account taken meanwhile, a store outage) is rolled back: the user
|
|
308
|
+
is deleted again, so the application sees `user.created` then `user.deleted`,
|
|
309
|
+
and the original failure is the one thrown.
|
|
310
|
+
|
|
311
|
+
**Two of these answers reveal that an account exists**:
|
|
312
|
+
`EMAIL_NOT_VERIFIED_FOR_LINK` and `SIGN_UP_DISABLED` — as `findByEmail` does.
|
|
313
|
+
Neither is told to a stranger by any other flow, so answer them to the visitor
|
|
314
|
+
only as far as that is acceptable to you.
|
|
315
|
+
|
|
316
|
+
### A callback route
|
|
317
|
+
|
|
318
|
+
```ts
|
|
319
|
+
import { JanusError, statusOf } from '@softistx/janus';
|
|
320
|
+
import { auth } from './auth';
|
|
321
|
+
|
|
322
|
+
function flowOf(request: Request): string {
|
|
323
|
+
const pattern = new RegExp(`(?:^|; )${auth.social.cookie.name}=([^;]*)`);
|
|
324
|
+
return pattern.exec(request.headers.get('cookie') ?? '')?.[1] ?? '';
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
export async function callback(request: Request): Promise<Response> {
|
|
328
|
+
const headers = new Headers();
|
|
329
|
+
headers.append('set-cookie', auth.social.cookie.clear()); // spent whatever happens next
|
|
330
|
+
try {
|
|
331
|
+
const done = await auth.social.complete({ callback: new URL(request.url).searchParams, flow: flowOf(request) });
|
|
332
|
+
headers.set('location', done.returnTo ?? '/');
|
|
333
|
+
if (done.status === 'signedIn') {
|
|
334
|
+
headers.append('set-cookie', auth.cookie.serialize(done.token, done.session));
|
|
335
|
+
}
|
|
336
|
+
// with janus({ secondFactor }) wired, done.status may also be 'secondFactor': see below
|
|
337
|
+
return new Response(null, { status: 302, headers });
|
|
338
|
+
} catch (error) {
|
|
339
|
+
if (!(error instanceof JanusError)) throw error;
|
|
340
|
+
// error.reason on PROVIDER_ERROR is for your logs, never for the body
|
|
341
|
+
return Response.json({ code: error.code }, { status: statusOf(error.code), headers });
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
- **Clear the cookie on every outcome.** A refused flow is spent too (below).
|
|
347
|
+
- **`complete` is spent once the `state` matched**, whatever follows —
|
|
348
|
+
`PROVIDER_ERROR`, `SIGN_UP_DISABLED`, a refusal: the next callback is
|
|
349
|
+
`FLOW_EXPIRED` and the visitor starts again.
|
|
350
|
+
- **`FLOW_MISMATCH`** leaves the flow alone when it is only the cookie missing
|
|
351
|
+
or the callback's `state` foreign, so a forged callback cannot burn a real
|
|
352
|
+
flow. A cookie whose contents were edited, or a link flow completed by
|
|
353
|
+
somebody else, is `FLOW_MISMATCH` **and** spends the flow.
|
|
354
|
+
- **`FLOW_PURPOSE_MISMATCH`** (400) answers a flow of the other kind than the
|
|
355
|
+
`purpose` the caller named, and spends it. `start` and `link` answer the same
|
|
356
|
+
kind of `flow` string, and `complete` alone tells them apart, so an endpoint
|
|
357
|
+
that is only for linking (or only for signing in) says so:
|
|
358
|
+
|
|
359
|
+
```ts
|
|
360
|
+
// The "finish linking" endpoint: a sign-in flow is refused, never signed in.
|
|
361
|
+
await auth.social.complete({ callback, flow, current, purpose: 'link' });
|
|
362
|
+
// The sign-in callback: a link flow is refused even with `current` passed.
|
|
363
|
+
await auth.social.complete({ callback, flow, purpose: 'signIn' });
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
The check runs before the provider is called, so nothing is exchanged,
|
|
367
|
+
linked or signed in. `purpose` left out accepts either kind.
|
|
368
|
+
- **`PROVIDER_ERROR`** (502) wraps anything the provider threw, with the
|
|
369
|
+
original as `cause`, and carries `reason`: `denied` (the visitor refused),
|
|
370
|
+
`refused` (any protocol failure) or `unreachable`. `reason` is for logs.
|
|
371
|
+
A `JanusError` the provider throws passes through unchanged.
|
|
372
|
+
- `callback` must be a `URLSearchParams`; anything else is a `TypeError`.
|
|
373
|
+
|
|
374
|
+
## The second factor and devices
|
|
375
|
+
|
|
376
|
+
`complete` takes the `SignInOptions` every sign-in takes, and finishes the way
|
|
377
|
+
`signIn` does: a user with an active second factor gets a challenge, not a
|
|
378
|
+
session.
|
|
379
|
+
|
|
380
|
+
```ts
|
|
381
|
+
const done = await auth.social.complete({ callback, flow }, { device: deviceCookie ?? null });
|
|
382
|
+
if (done.status === 'secondFactor') {
|
|
383
|
+
// (with janus({ secondFactor }) wired) done.challenge — keep it in a short-lived HttpOnly cookie, then:
|
|
384
|
+
// await auth.secondFactor.confirm(done.challenge, code, { device: deviceCookie ?? null });
|
|
385
|
+
}
|
|
386
|
+
if (done.status === 'signedIn') {
|
|
387
|
+
done.newDevice; // true when the device was new: user.newDeviceSignedIn was sent
|
|
388
|
+
done.deviceToken; // keep it in the device cookie
|
|
389
|
+
}
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
A second factor needs `janus({ secondFactor })` and a new device needs
|
|
393
|
+
`janus({ devices })`; see [the second factor](second-factor.md) and
|
|
394
|
+
[devices](devices.md). A user the call just created has no second factor, so a
|
|
395
|
+
social sign-up answers `signedIn`.
|
|
396
|
+
|
|
397
|
+
## Linking and unlinking
|
|
398
|
+
|
|
399
|
+
Linking an account to a signed-in user takes the session `authenticate`
|
|
400
|
+
answered, **not a bare user reference**: freshness is the session's, and a
|
|
401
|
+
session that proved who it is longer ago than `social.freshWithin` (ten minutes
|
|
402
|
+
by default) is `STEP_UP_REQUIRED`; ask for a [step-up](step-up.md) and try again.
|
|
403
|
+
|
|
404
|
+
```ts
|
|
405
|
+
import { auth } from './auth';
|
|
406
|
+
|
|
407
|
+
export async function link(request: Request): Promise<Response> {
|
|
408
|
+
const current = await auth.authenticate(request); // Authenticated<User> | null
|
|
409
|
+
if (current === null) return new Response(null, { status: 401 });
|
|
410
|
+
|
|
411
|
+
const start = await auth.social.link(current, { provider: 'github', returnTo: '/settings' });
|
|
412
|
+
const headers = new Headers({ location: start.url });
|
|
413
|
+
headers.append('set-cookie', start.setCookie);
|
|
414
|
+
return new Response(null, { status: 302, headers });
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
// the callback authenticates again and hands the same session to complete:
|
|
418
|
+
// const current = await auth.authenticate(request);
|
|
419
|
+
// const done = await auth.social.complete({ callback, flow, current });
|
|
420
|
+
// // { status: 'linked', user, link: { provider, accountId, email, linkedAt }, returnTo }
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
- **No e-mail match is required**: the account may carry any e-mail, or none.
|
|
424
|
+
- **Do not use `sameSite: 'strict'` on the session cookie when you link.**
|
|
425
|
+
The provider's callback is a cross-site navigation, and a Strict cookie is
|
|
426
|
+
not sent on it: the callback sees no session, the link flow ends in
|
|
427
|
+
`FLOW_MISMATCH` and is spent. Use `lax` for the session cookie.
|
|
428
|
+
- **A link flow is for the user who started it.** Completed with no `current`,
|
|
429
|
+
or another user's, it is `FLOW_MISMATCH`, and the flow is spent; a link flow
|
|
430
|
+
cannot be completed as a sign-in.
|
|
431
|
+
- **An account already linked to this user** answers `linked` with no write
|
|
432
|
+
and no event. **One linked to another user**, or to a user of another type,
|
|
433
|
+
is `SOCIAL_ACCOUNT_TAKEN`: one provider account links to one user per
|
|
434
|
+
instance, so one Google account cannot be both a patient and a staff member.
|
|
435
|
+
- **An inactive user** is `USER_INACTIVE` at the callback. A new link sends
|
|
436
|
+
`user.socialLinked`; it opens no session.
|
|
437
|
+
|
|
438
|
+
```ts
|
|
439
|
+
await auth.social.list(user); // readonly SocialLink[], oldest first; [] for nobody
|
|
440
|
+
await auth.social.unlink(user, { provider: 'github', accountId }); // true if this call deleted it, false for one not theirs or not there
|
|
441
|
+
await auth.social.countLinks({ provider: 'github' }); // how many accounts are linked through it; 0 for none
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
`countLinks` is what an admin screen calls before deleting a provider: refuse
|
|
445
|
+
while it answers more than `0`. It counts in the partition the instance's
|
|
446
|
+
store is bound to (`createMongoStores(db, { partition })`), so one tenant never
|
|
447
|
+
sees another's links. It needs a store that implements the optional
|
|
448
|
+
`countSocialLinks(provider)`: `createMemoryStores()`, `janus-mongo` and
|
|
449
|
+
`janus-drizzle` do; a store without it makes the call throw `UNSUPPORTED`
|
|
450
|
+
(`UnsupportedError`, `slot` and `operation` set).
|
|
451
|
+
|
|
452
|
+
`unlink` refuses with `LAST_SIGN_IN_METHOD` (409) when the link is the user's
|
|
453
|
+
only way to sign in. It counts **a password, the user's other links and, on a
|
|
454
|
+
type with no password, a verified e-mail** (the e-mail signs in by link or code).
|
|
455
|
+
It is a read and then a delete, not a lock: two concurrent unlinks of a user's
|
|
456
|
+
last two links can both pass. A deleted link sends `user.socialUnlinked`.
|
|
457
|
+
|
|
458
|
+
`accountId` is the provider's identifier: keep it out of logs and events.
|
|
459
|
+
Events carry the `provider` only.
|
|
460
|
+
|
|
461
|
+
## `returnTo`
|
|
462
|
+
|
|
463
|
+
`returnTo` is a path of your own site the visitor lands on after the callback.
|
|
464
|
+
It is checked at `start` and `link`, before anything is issued, and bound into
|
|
465
|
+
the flow. It must start with a single `/` and be at most 2048 characters, with no
|
|
466
|
+
`//` start, no `\`, no control character and no scheme: `//evil.test`,
|
|
467
|
+
`/\evil.test`, `/.//evil.test` (a browser reads it as `//evil.test`) and `https://evil.test` are all `RETURN_TO_INVALID` (400); so is any empty, `.` or `..` segment before the query (`/a//b`, `/a/../b`). A query
|
|
468
|
+
and a fragment are fine (`/billing?plan=pro#top`). Absent, `returnTo` is `null`.
|
|
469
|
+
|
|
470
|
+
`isReturnTo(value)` is the same check as a predicate, exported for the code that
|
|
471
|
+
redirects: run it again on a `returnTo` before you send the visitor there, even
|
|
472
|
+
one `complete` or a refusal handed you.
|
|
473
|
+
|
|
474
|
+
```ts
|
|
475
|
+
import { isReturnTo } from '@softistx/janus';
|
|
476
|
+
|
|
477
|
+
const target = isReturnTo(done.returnTo) ? done.returnTo : '/';
|
|
478
|
+
```
|
|
479
|
+
|
|
480
|
+
## Writing a provider
|
|
481
|
+
|
|
482
|
+
```ts
|
|
483
|
+
interface SocialProvider {
|
|
484
|
+
authorizationUrl(flow: {
|
|
485
|
+
state: string;
|
|
486
|
+
nonce: string;
|
|
487
|
+
codeVerifier: string;
|
|
488
|
+
stepUp: SocialStepUpRequest | null; // see "Step-up per request"
|
|
489
|
+
}): Promise<URL>;
|
|
490
|
+
exchange(flow: {
|
|
491
|
+
callback: URLSearchParams;
|
|
492
|
+
state: string;
|
|
493
|
+
nonce: string;
|
|
494
|
+
codeVerifier: string;
|
|
495
|
+
stepUp: SocialStepUpRequest | null;
|
|
496
|
+
}): Promise<SocialIdentity>;
|
|
497
|
+
readonly supportsStepUp?: boolean; // true: sends stepUp to the provider and reports acr / authTime
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
interface SocialIdentity {
|
|
501
|
+
readonly accountId: string; // the provider's stable id for the account: an OIDC `sub`
|
|
502
|
+
readonly email: string | null;
|
|
503
|
+
readonly emailVerified: boolean; // the provider's claim; false when it cannot vouch
|
|
504
|
+
readonly name?: string;
|
|
505
|
+
readonly picture?: string;
|
|
506
|
+
readonly acr?: string; // the sign-in's authentication context class (OIDC `acr`), at most 256 characters
|
|
507
|
+
readonly authTime?: Date; // when the user last actively authenticated (OIDC `auth_time`)
|
|
508
|
+
}
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
`acr` and `authTime` are checked on **every** identity, plain flow or not: an `acr` that is not a string of at most 256 storable characters, or an `authTime` that is not a valid `Date`, is `PROVIDER_ERROR` (`reason: 'refused'`), so a provider reports them well formed or leaves them out.
|
|
512
|
+
|
|
513
|
+
The core mints the secret and derives `state`, `nonce` and `codeVerifier` from
|
|
514
|
+
it; the provider owns its client id, its redirect URI and its scopes. **The
|
|
515
|
+
provider must**:
|
|
516
|
+
|
|
517
|
+
- put `state` and `nonce` in the authorization URL and send the S256 challenge
|
|
518
|
+
of `codeVerifier` (`code_challenge_method=S256`);
|
|
519
|
+
- on `exchange`, refuse a callback whose `state` is not the one given, trade the
|
|
520
|
+
`code` with `codeVerifier`, and check the ID token's `nonce`, issuer, audience
|
|
521
|
+
and signature;
|
|
522
|
+
- treat a callback carrying `error` (`access_denied`) as a failure, not an
|
|
523
|
+
identity;
|
|
524
|
+
- report **`emailVerified` honestly**: `true` only when the provider says the
|
|
525
|
+
account holds the address. The core links accounts by e-mail on that claim
|
|
526
|
+
alone, so a provider that answers `true` by default hands accounts away. A
|
|
527
|
+
provider that cannot vouch answers `false`.
|
|
528
|
+
|
|
529
|
+
A minimal skeleton, for a provider that speaks OIDC:
|
|
530
|
+
|
|
531
|
+
```ts
|
|
532
|
+
import type { SocialIdentity, SocialProvider } from '@softistx/janus';
|
|
533
|
+
|
|
534
|
+
const authorize = 'https://idp.example/authorize';
|
|
535
|
+
const token = 'https://idp.example/token';
|
|
536
|
+
const redirectUri = 'https://app.example/auth/idp/callback';
|
|
537
|
+
const clientId = 'client-id';
|
|
538
|
+
const clientSecret = process.env['IDP_SECRET'] ?? '';
|
|
539
|
+
|
|
540
|
+
async function s256(verifier: string): Promise<string> {
|
|
541
|
+
const digest = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(verifier));
|
|
542
|
+
return Buffer.from(digest).toString('base64url');
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
export const idp: SocialProvider = {
|
|
546
|
+
async authorizationUrl({ state, nonce, codeVerifier }) {
|
|
547
|
+
const url = new URL(authorize);
|
|
548
|
+
url.search = new URLSearchParams({
|
|
549
|
+
response_type: 'code',
|
|
550
|
+
client_id: clientId,
|
|
551
|
+
redirect_uri: redirectUri,
|
|
552
|
+
scope: 'openid email profile',
|
|
553
|
+
state,
|
|
554
|
+
nonce,
|
|
555
|
+
code_challenge: await s256(codeVerifier),
|
|
556
|
+
code_challenge_method: 'S256',
|
|
557
|
+
}).toString();
|
|
558
|
+
return url;
|
|
559
|
+
},
|
|
560
|
+
|
|
561
|
+
async exchange({ callback, state, nonce, codeVerifier }): Promise<SocialIdentity> {
|
|
562
|
+
if (callback.get('error') !== null) throw new Error(`denied: ${callback.get('error')}`);
|
|
563
|
+
if (callback.get('state') !== state) throw new Error('state mismatch');
|
|
564
|
+
const response = await fetch(token, {
|
|
565
|
+
method: 'POST',
|
|
566
|
+
body: new URLSearchParams({
|
|
567
|
+
grant_type: 'authorization_code',
|
|
568
|
+
code: callback.get('code') ?? '',
|
|
569
|
+
redirect_uri: redirectUri,
|
|
570
|
+
client_id: clientId,
|
|
571
|
+
client_secret: clientSecret,
|
|
572
|
+
code_verifier: codeVerifier,
|
|
573
|
+
}),
|
|
574
|
+
});
|
|
575
|
+
if (!response.ok) throw new Error(`token endpoint answered ${response.status}`);
|
|
576
|
+
const claims = await verifyIdToken(await response.json(), { nonce }); // signature, iss, aud, exp, nonce — yours
|
|
577
|
+
return { accountId: claims.sub, email: claims.email ?? null, emailVerified: claims.email_verified === true };
|
|
578
|
+
},
|
|
579
|
+
};
|
|
580
|
+
|
|
581
|
+
declare function verifyIdToken(
|
|
582
|
+
tokens: unknown,
|
|
583
|
+
expected: { nonce: string },
|
|
584
|
+
): Promise<{ sub: string; email?: string; email_verified?: boolean; name?: string }>;
|
|
585
|
+
```
|
|
586
|
+
|
|
587
|
+
Both calls are asynchronous and may throw anything: a failure becomes
|
|
588
|
+
`PROVIDER_ERROR` with the original as `cause`, and a `JanusError` you throw
|
|
589
|
+
yourself (a `SocialError` with `PROVIDER_ERROR`) passes through. An identity the
|
|
590
|
+
core cannot keep — an empty or over-512-character `accountId`, one with a NUL,
|
|
591
|
+
a missing `email` or a non-boolean `emailVerified` — is `PROVIDER_ERROR` too.
|
|
592
|
+
|
|
593
|
+
## Testing with a fake provider
|
|
594
|
+
|
|
595
|
+
A fake provider does no HTTP, hands out the identity you register for a
|
|
596
|
+
callback `code`, and checks `state` as a real one does. The package's own specs
|
|
597
|
+
use the same shape.
|
|
598
|
+
|
|
599
|
+
```ts
|
|
600
|
+
import { expect, it } from 'bun:test';
|
|
601
|
+
import { z } from 'zod';
|
|
602
|
+
import { createMemoryStores, janus, scryptHasher, type SocialIdentity, type SocialProvider } from '@softistx/janus';
|
|
603
|
+
|
|
604
|
+
function fakeProvider(identities: Record<string, SocialIdentity>): SocialProvider {
|
|
605
|
+
return {
|
|
606
|
+
async authorizationUrl({ state }) {
|
|
607
|
+
return new URL(`https://idp.test/authorize?state=${state}`);
|
|
608
|
+
},
|
|
609
|
+
async exchange({ callback, state }) {
|
|
610
|
+
const identity = identities[callback.get('code') ?? ''];
|
|
611
|
+
if (callback.get('state') !== state || identity === undefined) throw new Error('invalid_grant');
|
|
612
|
+
return identity;
|
|
613
|
+
},
|
|
614
|
+
};
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
it('signs a stranger up through the provider', async () => {
|
|
618
|
+
const auth = janus({
|
|
619
|
+
user: z.object({ email: z.email(), name: z.string() }),
|
|
620
|
+
password: { login: 'email' },
|
|
621
|
+
store: createMemoryStores(),
|
|
622
|
+
hasher: scryptHasher(),
|
|
623
|
+
social: {
|
|
624
|
+
providers: { idp: fakeProvider({ c1: { accountId: 'sub-1', email: 'ada@example.test', emailVerified: true, name: 'Ada' } }) },
|
|
625
|
+
signUp: (profile) => ({ email: profile.email ?? '', name: profile.name ?? 'Unnamed' }),
|
|
626
|
+
},
|
|
627
|
+
});
|
|
628
|
+
|
|
629
|
+
const start = await auth.social.start({ provider: 'idp', returnTo: '/home' });
|
|
630
|
+
const state = new URL(start.url).searchParams.get('state') ?? '';
|
|
631
|
+
const done = await auth.social.complete({ callback: new URLSearchParams({ code: 'c1', state }), flow: start.flow });
|
|
632
|
+
|
|
633
|
+
expect(done).toMatchObject({ status: 'signedIn', created: true, linked: true, returnTo: '/home' });
|
|
634
|
+
});
|
|
635
|
+
```
|
|
636
|
+
|
|
637
|
+
Register a different `emailVerified` or an existing user to drive the other
|
|
638
|
+
rows of [the table](#what-complete-decides). Every refusal is a `SocialError` (or
|
|
639
|
+
`EmailUnverifiedError`, `UserInactiveError`) with a `code`; see
|
|
640
|
+
[Errors](errors.md#the-codes).
|
|
641
|
+
|
|
642
|
+
## See also
|
|
643
|
+
|
|
644
|
+
- [Errors](errors.md) — the ten social codes and their statuses
|
|
645
|
+
- [User events](events.md) — `user.socialLinked` and `user.socialUnlinked`
|
|
646
|
+
- [The second factor](second-factor.md), [devices](devices.md) and [step-up](step-up.md) — what `complete` and `link` hand over to
|
|
647
|
+
- [Writing an adapter](adapters.md) — the `socialLinks` slot
|
|
648
|
+
- [Troubleshooting](../troubleshooting.md) — by the message you see
|