@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,316 @@
|
|
|
1
|
+
# API keys
|
|
2
|
+
|
|
3
|
+
Personal keys that a user creates for their own scripts, and that act as that
|
|
4
|
+
user. `janus({ apiKeys })` adds `auth.apiKeys` to the instance: **create**,
|
|
5
|
+
**list**, **revoke**, **revokeAll**. Without the block there is no
|
|
6
|
+
`auth.apiKeys` — not at run time, and not in the type.
|
|
7
|
+
|
|
8
|
+
## Wiring
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
import { createMemoryApiKeys, janus } from '@softistx/janus';
|
|
12
|
+
|
|
13
|
+
const auth = janus({
|
|
14
|
+
user: User,
|
|
15
|
+
password: { login: 'email' },
|
|
16
|
+
store, // users, sessions, tokens
|
|
17
|
+
hasher,
|
|
18
|
+
apiKeys: {
|
|
19
|
+
store: createMemoryApiKeys(), // or an adapter's
|
|
20
|
+
prefix: 'sl_',
|
|
21
|
+
lifetimes: ['30d', '90d', '365d'],
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
| Option | Default | Meaning |
|
|
27
|
+
| --- | --- | --- |
|
|
28
|
+
| `store` | required | An [`ApiKeyStore`](adapters.md). A port of its own, **not** a slot of `store`: the three identity stores are unchanged |
|
|
29
|
+
| `prefix` | required | The start of every token, so a leaked key can be recognised and scanned for. Lowercase letters and digits, starting with a letter, at most 16 characters, ending in `_` |
|
|
30
|
+
| `lifetimes` | required | The lifetimes a key may be created with, each at least `'1d'`. **No default and no unlimited key**: every key expires, and the user picks one of these |
|
|
31
|
+
| `maxActive` | `10` | Standing keys one user may hold, 1 to 100 |
|
|
32
|
+
| `freshWithin` | `'10m'` | How recently the session must have proved who it is to create a key |
|
|
33
|
+
| `lastUsedEvery` | `'1h'` | At most one write of `lastUsedAt` per key and per this span (used when keys are accepted) |
|
|
34
|
+
| `types` | every type | The user types that may hold keys |
|
|
35
|
+
| `revokeOnPasswordReset` | `true` | `resetPassword.confirm` revokes every key of the user. `false` leaves them |
|
|
36
|
+
|
|
37
|
+
A wrong value is a `TypeError` naming it, at wiring: `janus: apiKeys.prefix …`,
|
|
38
|
+
`janus: apiKeys.lifetimes: "12h" is under one day …`, `janus: apiKeys.store: the
|
|
39
|
+
API key store has no method …`. `lifetime` in `create` is typed as the
|
|
40
|
+
lifetimes you listed.
|
|
41
|
+
|
|
42
|
+
## Creating a key
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
const current = await auth.authenticate(request);
|
|
46
|
+
if (current === null) return new Response(null, { status: 401 });
|
|
47
|
+
|
|
48
|
+
const { apiKey, token } = await auth.apiKeys.create(current, {
|
|
49
|
+
name: 'CI deploy',
|
|
50
|
+
lifetime: '90d',
|
|
51
|
+
});
|
|
52
|
+
// token: 'sl_0192ab…_…' — show it to the user now. Only its hash is stored.
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
- **The token is shown once.** It is `${prefix}${id}_${secret}`: the key's id
|
|
56
|
+
(a UUIDv7 without hyphens) and 256 bits of secret. The store holds
|
|
57
|
+
`sha256(secret)`, so a dump of it cannot be replayed, and a lost token is a
|
|
58
|
+
new key. `apiKey.hint` (`sl_0192ab…`) is what a list shows.
|
|
59
|
+
- **Behind a fresh proof.** `current.session.authenticatedAt` must be less than
|
|
60
|
+
`freshWithin` old, else `STEP_UP_REQUIRED`: ask for a [step-up](step-up.md),
|
|
61
|
+
then try again. The password and the session are checked again once the key is stored: a
|
|
62
|
+
password written since this session proved who it is (a reset, a
|
|
63
|
+
`changePassword`), or a session that no longer stands (a reset or a first
|
|
64
|
+
proof of the e-mail ended it), revokes the new key and answers
|
|
65
|
+
`STEP_UP_REQUIRED` — sign
|
|
66
|
+
in again or confirm a step-up.
|
|
67
|
+
- **A key never creates a key.** A principal that came in by an API key is
|
|
68
|
+
refused with `STEP_UP_REQUIRED` and `reason: 'apiKey'` — there is no
|
|
69
|
+
step-up for it to do.
|
|
70
|
+
- **The e-mail must be verified.** A user with an address that was never proved is
|
|
71
|
+
refused with `EMAIL_UNVERIFIED` (403) and nothing is written: a key outlives
|
|
72
|
+
the session that made it, and an address someone signed up with is not yet
|
|
73
|
+
theirs. A user type with no e-mail (a username login) has nothing to squat and is not
|
|
74
|
+
asked. There is no option to allow it; verify the address first
|
|
75
|
+
([`verifyEmail`](email-flows.md)).
|
|
76
|
+
- The user is read again: `USER_INACTIVE` for an inactive one, `NOT_FOUND` for a
|
|
77
|
+
user who is gone or of a type `types` leaves out.
|
|
78
|
+
- `name` is trimmed and must be 1 to 100 characters, with no NUL character or
|
|
79
|
+
lone surrogate (no store can keep one); `lifetime` must be one
|
|
80
|
+
of `lifetimes`. Either wrong is `API_KEY_INVALID` (400) with `field: 'name'`
|
|
81
|
+
or `'lifetime'`, and nothing is written.
|
|
82
|
+
- **At most `maxActive` standing keys** (not revoked, not lapsed). A user at
|
|
83
|
+
the limit is refused with `API_KEY_LIMIT` (409, carrying `maxActive`) before
|
|
84
|
+
anything is written. The key is then inserted and the user's keys counted
|
|
85
|
+
again, which guards the race: two creations at the limit both count the
|
|
86
|
+
other and are both refused (their keys are revoked again) rather than one
|
|
87
|
+
too many accepted. A store failure after the insert revokes the new key
|
|
88
|
+
before the error reaches you, so no key stands that nobody holds — unless
|
|
89
|
+
the revoke fails too, which is reported with `process.emitWarning` (code
|
|
90
|
+
`JANUS_API_KEY_REVOKE_FAILED`) while the first failure is the one thrown.
|
|
91
|
+
|
|
92
|
+
## Listing and revoking
|
|
93
|
+
|
|
94
|
+
```ts
|
|
95
|
+
const page = await auth.apiKeys.list(user, { limit: 20 }); // oldest first
|
|
96
|
+
const key = await auth.apiKeys.get(id, { owner: current.user }); // ApiKey | null
|
|
97
|
+
await auth.apiKeys.revoke(id, { owner: current.user }); // a request-supplied id
|
|
98
|
+
await auth.apiKeys.revokeAll(user); // → how many
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
- `list` answers every key of the user — standing, revoked and lapsed — as
|
|
102
|
+
`ApiKey`s (no hash, no token), with the usual `limit` and `after` cursor. A
|
|
103
|
+
user without keys has an empty page.
|
|
104
|
+
- `get(id, { owner })` answers one key as `list` does, or `null` for an
|
|
105
|
+
unknown or malformed id (without reading the store) and, with `owner`, for
|
|
106
|
+
a key of another user. A revoked or lapsed key is answered as it is: `get`
|
|
107
|
+
does not check validity, `authenticate` does. **Pass `owner` whenever the
|
|
108
|
+
id came from a request.** Without it any key is answered: the
|
|
109
|
+
administrator's path, never to be answered to a request without checking
|
|
110
|
+
`userId`. A store failure throws.
|
|
111
|
+
- `revoke(id, { owner })` makes a key of **another user** `NOT_FOUND`, the same
|
|
112
|
+
as an unknown or malformed id, so a request cannot tell which keys exist.
|
|
113
|
+
**Always pass `owner` when the id came from a request.** Without it any key
|
|
114
|
+
is revoked: the administrator's path. Revoking a revoked key is not an
|
|
115
|
+
error, and keeps its first `revokedAt`. It sends no `user.apiKeyRevoked` for a
|
|
116
|
+
key already revoked, **for sequential calls**: two concurrent `revoke(id)`
|
|
117
|
+
calls of one key can both send the event.
|
|
118
|
+
- `revokeAll(user)` revokes every standing key and answers how many.
|
|
119
|
+
|
|
120
|
+
## Accepting a key
|
|
121
|
+
|
|
122
|
+
Keys are **opt-in per call**. Without `apiKey: true`, a key-shaped bearer
|
|
123
|
+
answers `null` (anonymous), so a route written for sessions never accepts one:
|
|
124
|
+
|
|
125
|
+
```ts
|
|
126
|
+
// A route for scripts: a session or a key.
|
|
127
|
+
const principal = await auth.authenticate(request, { apiKey: true });
|
|
128
|
+
if (principal === null) return new Response(null, { status: 401 });
|
|
129
|
+
|
|
130
|
+
if (principal.via === 'apiKey') {
|
|
131
|
+
principal.apiKey.id; // limit by key; principal.session is null
|
|
132
|
+
} else {
|
|
133
|
+
principal.session.expiresAt; // a session, as before
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// A route for people only: a key answers null here.
|
|
137
|
+
const person = await auth.authenticate(request);
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
With `apiKey: true`, a token shaped like a key (`prefix`, 32 hex characters,
|
|
141
|
+
`_`, 43 base64url characters) is looked up **before** any session. It
|
|
142
|
+
authenticates when all of these hold, and answers `null` otherwise:
|
|
143
|
+
|
|
144
|
+
- the key exists and the SHA-256 of the presented secret equals the stored
|
|
145
|
+
hash (compared in constant time);
|
|
146
|
+
- it is not revoked, and `expiresAt` is after now;
|
|
147
|
+
- its user exists, is active, is of an allowed type (`apiKeys.types`) and of
|
|
148
|
+
`options.type` when given.
|
|
149
|
+
|
|
150
|
+
**A key is accepted only from `Authorization: Bearer`.** A key-shaped token in
|
|
151
|
+
the session cookie or in `X-Session-Token` answers `null`, with `apiKey: true`
|
|
152
|
+
too: a cookie is sent by a browser without being asked, and a key is not meant
|
|
153
|
+
to live there. A session token keeps all three routes.
|
|
154
|
+
|
|
155
|
+
A token that merely starts with the prefix but is not shaped like a key goes
|
|
156
|
+
to the session path. As for sessions, the first credential present wins.
|
|
157
|
+
|
|
158
|
+
Nothing is renewed: a key's `expiresAt` never moves. `lastUsedAt` is written
|
|
159
|
+
at most once per `lastUsedEvery` (default `1h`), so a busy key costs one write
|
|
160
|
+
per hour; the principal's `apiKey.lastUsedAt` shows it when this call wrote.
|
|
161
|
+
|
|
162
|
+
**An outage is not anonymous**: a key store that cannot answer rejects with
|
|
163
|
+
`STORE_FAILED`, as the other stores do; answer 503.
|
|
164
|
+
|
|
165
|
+
A key is **never fresh**. `assertFresh(principal, maxAge)` throws
|
|
166
|
+
`STEP_UP_REQUIRED` with `reason: 'apiKey'` for one, whatever its age, and
|
|
167
|
+
`apiKeys.create` refuses it likewise: guard sensitive actions with it, and
|
|
168
|
+
the key gets a 403 that a step-up cannot clear. Passing `apiKey: true` on an
|
|
169
|
+
instance wired without `apiKeys` is a `TypeError`.
|
|
170
|
+
|
|
171
|
+
## Scopes and a bound object
|
|
172
|
+
|
|
173
|
+
A key can carry **scopes** (what it may do) and be **bound** to one object
|
|
174
|
+
(what it acts for: a workspace, an account), both chosen at creation:
|
|
175
|
+
|
|
176
|
+
```ts
|
|
177
|
+
const { apiKey, token } = await auth.apiKeys.create(current, {
|
|
178
|
+
name: 'Assistant',
|
|
179
|
+
lifetime: '30d',
|
|
180
|
+
scopes: ['tools:read', 'tools:write'],
|
|
181
|
+
bound: { type: 'workspace', id: workspace.id },
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
const principal = await auth.authenticate(request, { apiKey: true });
|
|
185
|
+
if (principal?.via === 'apiKey') {
|
|
186
|
+
principal.scopes; // ['tools:read', 'tools:write'], or null for an unscoped key
|
|
187
|
+
principal.bound; // { type: 'workspace', id: '…' }, or null
|
|
188
|
+
}
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
- **Janus stores them and hands them back; it never enforces them.** Your
|
|
192
|
+
route checks that the scope it needs is in `principal.scopes` and that
|
|
193
|
+
`principal.bound` is the object the request touches. A key without
|
|
194
|
+
either answers `null` for both, and is stored exactly as before.
|
|
195
|
+
- `scopes`: 1 to 32 OAuth scope tokens (printable ASCII without space, `"`
|
|
196
|
+
or `\`), each at most 100 characters; duplicates are dropped, the order
|
|
197
|
+
kept. `bound`: `{ type, id }`, `type` of 1 to 64 characters and `id` of 1 to
|
|
198
|
+
200, with no NUL character or lone surrogate; other properties are dropped.
|
|
199
|
+
Either wrong is `API_KEY_INVALID` (400) with `field: 'scopes'` or `'bound'`,
|
|
200
|
+
and nothing is written.
|
|
201
|
+
- **The store must be able to keep them.** Passing `scopes` or `bound` to an
|
|
202
|
+
instance whose key store lacks the optional `bound` capability
|
|
203
|
+
(`listBoundApiKeys` and `revokeBoundApiKeys`) is a `TypeError`, before
|
|
204
|
+
anything is written: a store that silently dropped them would turn a
|
|
205
|
+
restricted key into a full one. `createMemoryApiKeys()` and
|
|
206
|
+
`createMongoApiKeys(db)` have it.
|
|
207
|
+
|
|
208
|
+
```ts
|
|
209
|
+
const page = await auth.apiKeys.listBound({ type: 'workspace', id }, { limit: 20 });
|
|
210
|
+
const revoked = await auth.apiKeys.revokeAllBound(user, { type: 'workspace', id }); // → how many
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
- `listBound(object, page?)` answers every key bound to the object — any
|
|
214
|
+
user's, standing, revoked or lapsed — oldest first, with the usual `limit`
|
|
215
|
+
and `after` cursor. An object that is not `{ type, id }` has an empty page.
|
|
216
|
+
- `revokeAllBound(user, object)` revokes that user's standing keys bound to the
|
|
217
|
+
object and answers how many: when a member leaves a workspace, say. The
|
|
218
|
+
user's other keys stand.
|
|
219
|
+
- Both need the `bound` capability; without it they are a `TypeError`.
|
|
220
|
+
|
|
221
|
+
To list **one user's** keys of an object, filter `list`:
|
|
222
|
+
|
|
223
|
+
```ts
|
|
224
|
+
const mine = await auth.apiKeys.list(user, { bound: { type: 'workspace', id } });
|
|
225
|
+
const unbound = await auth.apiKeys.list(user, { bound: null }); // the user's unbound keys
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
- `bound` absent lists every key; an object lists those bound to it; `null`
|
|
229
|
+
lists the unbound ones. A value that is not `{ type, id }` has an empty
|
|
230
|
+
page. A bad cursor is `INVALID_CURSOR`.
|
|
231
|
+
- It needs the `bound` capability (a `TypeError` before any read without it).
|
|
232
|
+
A store with `listUserBoundApiKeys` answers in one read; without it the core
|
|
233
|
+
reads the user's keys 100 at a time and keeps those that match.
|
|
234
|
+
|
|
235
|
+
## Expiry notices
|
|
236
|
+
|
|
237
|
+
To warn a user before a key lapses, sweep the keys that expire soon and claim
|
|
238
|
+
each one before sending:
|
|
239
|
+
|
|
240
|
+
```ts
|
|
241
|
+
let after: string | null = null;
|
|
242
|
+
do {
|
|
243
|
+
const page = await auth.apiKeys.expiring({ within: '7d', limit: 100, after });
|
|
244
|
+
for (const key of page.items) {
|
|
245
|
+
// true for the one sweep that claimed it: send then.
|
|
246
|
+
if (await auth.apiKeys.markExpiryNotified(key.id)) await notify(key);
|
|
247
|
+
}
|
|
248
|
+
after = page.nextCursor;
|
|
249
|
+
} while (after !== null);
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
- `expiring({ within, limit?, after? })` answers the standing keys (not
|
|
253
|
+
revoked, not lapsed) whose `expiresAt` falls within `within` from now and
|
|
254
|
+
that were not marked yet, oldest first. `within` is a duration (`'7d'`, or
|
|
255
|
+
milliseconds); a wrong one is a `TypeError`.
|
|
256
|
+
- `markExpiryNotified(id)` records `expiryNotifiedAt` once. It answers `true`
|
|
257
|
+
for the call that wrote it and `false` when the key was already marked, so
|
|
258
|
+
of two sweeps running at once only one sends. An unknown or malformed id is
|
|
259
|
+
`NOT_FOUND`. `apiKey.expiryNotifiedAt` shows it in a list.
|
|
260
|
+
- Both need the optional `expiryNotice` capability of the key store
|
|
261
|
+
(`listExpiringApiKeys` and `markApiKeyExpiryNotified`); without it they are a
|
|
262
|
+
`TypeError`.
|
|
263
|
+
|
|
264
|
+
## What else ends a key
|
|
265
|
+
|
|
266
|
+
| Event | Keys |
|
|
267
|
+
| --- | --- |
|
|
268
|
+
| `resetPassword.confirm` | Revoked, unless `revokeOnPasswordReset: false` — whoever had the old password may have made keys with it. Always revoked when the link proved the e-mail for the first time. Each ending (sessions, keys, links) runs whatever the others do, and the first store failure is thrown after all were tried |
|
|
269
|
+
| First proof of an e-mail (`magicLink.confirm`, `signInCode.confirm`, `verifyEmail.confirm(token, { firstProof: true })`, `verifyEmail.proveFirst`) | Revoked, whatever `revokeOnPasswordReset` says — whoever signed up with the address and a password may have made keys, and the holder of the inbox did not |
|
|
270
|
+
| `changePassword`, `signOutEverywhere` | Left: the user is still who they were |
|
|
271
|
+
| `delete(user)` | Deleted with the user |
|
|
272
|
+
| `collectExpired()` | Lapsed keys are deleted, when the key store implements `deleteExpiredApiKeys` |
|
|
273
|
+
|
|
274
|
+
## Events
|
|
275
|
+
|
|
276
|
+
Two [user events](events.md) report a key's life to `janus({ events })`, and
|
|
277
|
+
to webhooks:
|
|
278
|
+
|
|
279
|
+
| `type` | Sent by | `count` |
|
|
280
|
+
| --- | --- | --- |
|
|
281
|
+
| `user.apiKeyCreated` | `create`, once the key is stored | none |
|
|
282
|
+
| `user.apiKeyRevoked` | `revoke`, `revokeAll`, `revokeAllBound`, and the password reset and first proof above when they revoke keys | the keys the call revoked |
|
|
283
|
+
|
|
284
|
+
```ts
|
|
285
|
+
const auth = janus({
|
|
286
|
+
// …
|
|
287
|
+
events(event) {
|
|
288
|
+
if (event.type === 'user.apiKeyRevoked') {
|
|
289
|
+
audit(event.userId, `${event.count} API key(s) revoked`);
|
|
290
|
+
}
|
|
291
|
+
},
|
|
292
|
+
});
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
- **One event per call**: a bulk revoke sends one `user.apiKeyRevoked` with
|
|
296
|
+
its `count`, not one per key. A call that revokes nothing sends none: a key
|
|
297
|
+
already revoked, a user with no standing key, an object with no bound key.
|
|
298
|
+
- **The event names the user (`userId`, `userType`) and nothing of the key**:
|
|
299
|
+
no id, no secret, no name. Read the keys with `apiKeys.list(event.userId)`.
|
|
300
|
+
- **`count` stays in the process**: a webhook posts the user alone.
|
|
301
|
+
- **`delete(user)` sends `user.deleted`**, not a revoke event: its keys are
|
|
302
|
+
deleted with the user.
|
|
303
|
+
|
|
304
|
+
There is no e-mail notice when a key is created: listen to `user.apiKeyCreated` to send your own.
|
|
305
|
+
|
|
306
|
+
## Types
|
|
307
|
+
|
|
308
|
+
`ApiKey` (a key without its hash, with a `hint`, and `scopes`, `bound` and
|
|
309
|
+
`expiryNotifiedAt`, each `null` when unset), `CreatedApiKey`
|
|
310
|
+
(`{ apiKey, token }`), `CreateApiKeyInput`, `ApiKeyBound` (`{ type, id }`),
|
|
311
|
+
`ApiKeyPage` (`{ limit?, after? }`; `expiring` takes `{ within } & ApiKeyPage`),
|
|
312
|
+
`ApiKeyListOptions` (`ApiKeyPage & { bound? }`, what `list` takes), `ApiKeysApi`, `ApiKeysConfig`, and for
|
|
313
|
+
the principal of a request, `Principal<U> = Authenticated<U> | KeyAuthenticated<U>`,
|
|
314
|
+
told apart by `via` (`'session'` or `'apiKey'`; a key's has `session: null`,
|
|
315
|
+
and `scopes` and `bound`). `apiKeys`
|
|
316
|
+
is a reserved name: a user type cannot be called that.
|
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
# Account avatars
|
|
2
|
+
|
|
3
|
+
This page is the full recipe for giving accounts an avatar: the upload route,
|
|
4
|
+
the remove route, the route that serves the image, who may see it, and what
|
|
5
|
+
fails in what order. Janus is a small part of it: **it records which image is
|
|
6
|
+
the account's — an opaque id your application chose — and stores no bytes.**
|
|
7
|
+
Storing, processing, serving and deleting the image is your application's,
|
|
8
|
+
in whatever storage it already runs.
|
|
9
|
+
|
|
10
|
+
The calls it adds are `auth.avatar.set` and `auth.avatar.remove` on an instance
|
|
11
|
+
of one user type (with several, `auth.<type>.avatar.set`, and the same at the
|
|
12
|
+
root for a page that holds only an id; the reference is in [the README](../../README.md#avatars--avatar)); the
|
|
13
|
+
avatar is read back as `user.avatar`, `{ id, updatedAt } | null`.
|
|
14
|
+
|
|
15
|
+
The image side below is written with
|
|
16
|
+
[`@softistx/image`](https://github.com/softistx/nxgt-data/blob/develop/packages/image/README.md)
|
|
17
|
+
0.4 and its `@softistx/image/s3` subpath over
|
|
18
|
+
[`@softistx/s3`](https://github.com/softistx/nxgt-data/blob/develop/packages/s3/README.md),
|
|
19
|
+
**for example**: any storage works, since janus keeps only the id. Both are
|
|
20
|
+
private `@softistx` packages (they moved from `@nxgt/image` and
|
|
21
|
+
`@nxgt/s3` on npm). Their calls — `defineImageSet`, `bindImageStore`,
|
|
22
|
+
`store.replace`, `store.remove`, `store.bytes` — are the ones the recipe uses;
|
|
23
|
+
swap them for your own storage calls. `@softistx/image` runs on Bun 1.4.1 or
|
|
24
|
+
later only, and its bucket must accept `image/webp` and a `maxSize` of at least
|
|
25
|
+
the largest size: see its README and
|
|
26
|
+
[`docs/guide/storing.md`](https://github.com/softistx/nxgt-data/blob/develop/packages/image/docs/guide/storing.md).
|
|
27
|
+
|
|
28
|
+
## What you decide, and what janus does
|
|
29
|
+
|
|
30
|
+
| | |
|
|
31
|
+
| --- | --- |
|
|
32
|
+
| The id | Yours: `crypto.randomUUID()`, a **new one for every upload** |
|
|
33
|
+
| The bytes | Yours: processed, stored, served and deleted by your application |
|
|
34
|
+
| The record | Janus's: `user.avatar`, written by `avatar.set` / `avatar.remove` |
|
|
35
|
+
| Who may change it | Yours: janus has **no access check** on either call |
|
|
36
|
+
| Who may see it | Yours: janus has no access check on `user.avatar` either |
|
|
37
|
+
| Reading | A stream through **your own authenticated route** — see *Never a public URL* in the traps |
|
|
38
|
+
| History | None: only the current image is kept |
|
|
39
|
+
|
|
40
|
+
## The image store
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
import { defineImageSet, ImageError } from '@softistx/image';
|
|
44
|
+
import { bindImageStore } from '@softistx/image/s3';
|
|
45
|
+
import { bindBucket, defineBucket } from '@softistx/s3';
|
|
46
|
+
|
|
47
|
+
const sizes = [256, 64]; // the only sizes the proxy route will serve
|
|
48
|
+
|
|
49
|
+
const avatarBucket = defineBucket({
|
|
50
|
+
bucket: 'avatars',
|
|
51
|
+
// a fresh imageId per upload, so a new image never lands on the former one's keys
|
|
52
|
+
key: (p: { imageId: string; size: number }) => `avatars/${p.imageId}/${p.size}.webp`,
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const s3Config = { endpoint: env.S3_ENDPOINT, accessKeyId: env.S3_KEY, secretAccessKey: env.S3_SECRET };
|
|
56
|
+
|
|
57
|
+
export const store = bindImageStore(
|
|
58
|
+
defineImageSet({ sizes }), // limits, quality: see the @softistx/image README
|
|
59
|
+
bindBucket(avatarBucket, s3Config), // never with a public default acl
|
|
60
|
+
);
|
|
61
|
+
// store.replace({ imageId }, input) — decode, resize, write every size
|
|
62
|
+
// store.remove({ imageId }) — delete every size
|
|
63
|
+
// store.bytes({ imageId }, size) — the stored bytes of one size
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
A refused image throws an `ImageError` whose `code` is `TOO_LARGE`,
|
|
67
|
+
`UNSUPPORTED_TYPE`, `UNDECODABLE` or `TOO_SMALL`: answer it with a 4xx of
|
|
68
|
+
your own.
|
|
69
|
+
|
|
70
|
+
## 1. The upload route
|
|
71
|
+
|
|
72
|
+
Any HTTP framework; this one is Hono-like. The order is the point: **session,
|
|
73
|
+
fresh id, bytes, record, then the former image.**
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
import { bodyLimit } from 'hono/body-limit';
|
|
77
|
+
|
|
78
|
+
app.put(
|
|
79
|
+
'/me/avatar',
|
|
80
|
+
// Before the body is read: `arrayBuffer()` below holds the whole upload in
|
|
81
|
+
// memory, so a limit in front of the route stops a huge body before it does.
|
|
82
|
+
bodyLimit({ maxSize: 5 * 1024 * 1024, onError: (c) => c.body(null, 413) }),
|
|
83
|
+
async (c) => {
|
|
84
|
+
const current = await auth.authenticate(c.req.raw); // 1. who is asking
|
|
85
|
+
if (current === null) return c.body(null, 401);
|
|
86
|
+
const userId = current.user.id; // only ever the caller's own avatar
|
|
87
|
+
|
|
88
|
+
const imageId = crypto.randomUUID(); // 2. a new id for every upload
|
|
89
|
+
try {
|
|
90
|
+
await store.replace({ imageId }, await c.req.arrayBuffer()); // 3. the bytes FIRST
|
|
91
|
+
} catch (error) {
|
|
92
|
+
if (error instanceof ImageError) {
|
|
93
|
+
return c.json({ code: error.code }, error.code === 'TOO_LARGE' ? 413 : 422);
|
|
94
|
+
}
|
|
95
|
+
throw error;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const former = current.user.avatar?.id ?? null; // read before the call (webhook-only receivers)
|
|
99
|
+
try {
|
|
100
|
+
await auth.avatar.set(userId, { id: imageId }); // 4. then the record
|
|
101
|
+
} catch (error) {
|
|
102
|
+
await store.remove({ imageId }); // any failure: nothing points at this upload
|
|
103
|
+
throw error;
|
|
104
|
+
}
|
|
105
|
+
if (former !== null) await store.remove({ imageId: former }); // 5. then the former image
|
|
106
|
+
return c.json({ id: imageId }, 200);
|
|
107
|
+
},
|
|
108
|
+
);
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
The body limit is the route's, not janus's: `c.req.arrayBuffer()` reads the
|
|
112
|
+
whole body before `@softistx/image` can refuse it as `TOO_LARGE`, so without a
|
|
113
|
+
limit in front, one large request is held in memory first. Any equivalent —
|
|
114
|
+
the framework's, or the reverse proxy's — does the same.
|
|
115
|
+
|
|
116
|
+
Step 5 has two homes. In the process that wrote, the `janus({ events })`
|
|
117
|
+
listener hears `user.avatarChanged` with `formerAvatarId` — see
|
|
118
|
+
[user events](events.md#what-an-event-carries) — and is the one place that
|
|
119
|
+
deletes the former image whichever route changed it:
|
|
120
|
+
|
|
121
|
+
```ts
|
|
122
|
+
const auth = janus({
|
|
123
|
+
...config,
|
|
124
|
+
async events(event) {
|
|
125
|
+
if (
|
|
126
|
+
(event.type === 'user.avatarChanged' || event.type === 'user.avatarRemoved') &&
|
|
127
|
+
event.formerAvatarId != null
|
|
128
|
+
) {
|
|
129
|
+
await store.remove({ imageId: event.formerAvatarId });
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
With that listener, drop step 5 from the route. A receiver that only gets
|
|
136
|
+
**webhooks** never sees `formerAvatarId` (`@softistx/janus-webhooks` strips it),
|
|
137
|
+
so it reads `user.avatar?.id` before the call, as the route above does, and
|
|
138
|
+
deletes that image once the call answered.
|
|
139
|
+
|
|
140
|
+
## 2. The remove route
|
|
141
|
+
|
|
142
|
+
```ts
|
|
143
|
+
app.delete('/me/avatar', async (c) => {
|
|
144
|
+
const current = await auth.authenticate(c.req.raw);
|
|
145
|
+
if (current === null) return c.body(null, 401);
|
|
146
|
+
|
|
147
|
+
const former = current.user.avatar?.id ?? null;
|
|
148
|
+
await auth.avatar.remove(current.user.id); // the record first: nothing points at the bytes any more
|
|
149
|
+
if (former !== null) await store.remove({ imageId: former }); // then the bytes (or the listener above)
|
|
150
|
+
return c.body(null, 204);
|
|
151
|
+
});
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
Removing the record before the bytes is the safe order here too: a failure
|
|
155
|
+
in between leaves an orphan image, never a record pointing at nothing.
|
|
156
|
+
`avatar.remove` on a user with no avatar writes and sends nothing.
|
|
157
|
+
|
|
158
|
+
## 3. The proxy route
|
|
159
|
+
|
|
160
|
+
Reading is a stream through your application, behind its session and its
|
|
161
|
+
access rule. The `url` a client holds points here.
|
|
162
|
+
|
|
163
|
+
```ts
|
|
164
|
+
app.get('/avatars/:userId/:size', async (c) => {
|
|
165
|
+
const current = await auth.authenticate(c.req.raw);
|
|
166
|
+
if (current === null) return c.body(null, 401);
|
|
167
|
+
|
|
168
|
+
const { userId } = c.req.param();
|
|
169
|
+
const size = Number(c.req.param('size'));
|
|
170
|
+
if (!sizes.includes(size)) return c.body(null, 404); // only the sizes you store
|
|
171
|
+
|
|
172
|
+
const user = await auth.find(userId);
|
|
173
|
+
if (user === null || !(await canViewAvatar(current.user, user))) return c.body(null, 404); // the access check
|
|
174
|
+
if (user.avatar === null) return c.body(null, 404); // no avatar
|
|
175
|
+
|
|
176
|
+
const etag = `"${user.avatar.id}"`; // a new upload is a new id, so a new ETag
|
|
177
|
+
const cache = 'private, no-cache'; // revalidate on every view, so the access check re-runs
|
|
178
|
+
if (c.req.header('If-None-Match') === etag) {
|
|
179
|
+
return c.body(null, 304, { ETag: etag, 'Cache-Control': cache });
|
|
180
|
+
}
|
|
181
|
+
const bytes = await store.bytes({ imageId: user.avatar.id }, size);
|
|
182
|
+
if (bytes === undefined) return c.body(null, 404); // the record outlived its bytes
|
|
183
|
+
return new Response(bytes, {
|
|
184
|
+
headers: {
|
|
185
|
+
'Content-Type': 'image/webp',
|
|
186
|
+
'Cache-Control': cache, // private: never a shared cache or a CDN
|
|
187
|
+
ETag: etag,
|
|
188
|
+
},
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
Answer **404 when the caller may not see it**, as you would for an account
|
|
194
|
+
that does not exist: a 403 tells them the account has an avatar. The
|
|
195
|
+
`?v=<id>` your GraphQL `url` adds is for the browser's cache only; the route
|
|
196
|
+
reads the current avatar, never the one the query names. Put the id in a
|
|
197
|
+
`?v=` with `encodeURIComponent(id)`: ids are the application's own strings.
|
|
198
|
+
|
|
199
|
+
The `ETag` is built from the id and quoted, as the header requires. That is
|
|
200
|
+
fine for a UUID; an id you choose yourself must not hold a `"` or a control
|
|
201
|
+
character, or the header is malformed.
|
|
202
|
+
|
|
203
|
+
## 4. Who may see an account: a privacy recipe
|
|
204
|
+
|
|
205
|
+
Janus has no organizations, so "an account is visible to the members of an
|
|
206
|
+
organization it belongs to" is yours to enforce — with
|
|
207
|
+
[`@softistx/janus/permissions`](permissions.md). Model the organization's members,
|
|
208
|
+
and give each account a `viewAvatar` permission that is its own owner or
|
|
209
|
+
anyone in an organization it belongs to:
|
|
210
|
+
|
|
211
|
+
```ts
|
|
212
|
+
import { defineModel, fromField, permissions } from '@softistx/janus/permissions';
|
|
213
|
+
|
|
214
|
+
const model = defineModel({
|
|
215
|
+
subjects: auth.types, // ['user']
|
|
216
|
+
types: {
|
|
217
|
+
organization: {
|
|
218
|
+
related: { members: ['user'] },
|
|
219
|
+
},
|
|
220
|
+
user: {
|
|
221
|
+
related: {
|
|
222
|
+
self: fromField('id', 'user'), // the account itself, read from its own id
|
|
223
|
+
viewers: ['organization#members'], // every member of an organization it belongs to
|
|
224
|
+
},
|
|
225
|
+
permits: { viewAvatar: ['self', 'viewers'] },
|
|
226
|
+
},
|
|
227
|
+
},
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
export const access = permissions({ model, store: relations }); // relations: your relation store
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
**Granted when a membership is created, revoked when it ends** — beside your
|
|
234
|
+
own membership write, so the two never drift:
|
|
235
|
+
|
|
236
|
+
```ts
|
|
237
|
+
async function addMember(user: { type: 'user'; id: string }, organizationId: string) {
|
|
238
|
+
const organization = { type: 'organization', id: organizationId } as const;
|
|
239
|
+
await access.grant(organization, 'members', user);
|
|
240
|
+
// the account is now visible to every member of the organization:
|
|
241
|
+
await access.grant(user, 'viewers', { ...organization, relation: 'members' });
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
async function removeMember(user: { type: 'user'; id: string }, organizationId: string) {
|
|
245
|
+
const organization = { type: 'organization', id: organizationId } as const;
|
|
246
|
+
await access.revoke(user, 'viewers', { ...organization, relation: 'members' });
|
|
247
|
+
await access.revoke(organization, 'members', user);
|
|
248
|
+
}
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
Both calls are idempotent, so a retry is safe. The subject set follows the
|
|
252
|
+
data as it stands: a member added to the organization later sees every
|
|
253
|
+
account granted to its members, with no new tuple.
|
|
254
|
+
|
|
255
|
+
**Check it in the proxy route** — the `canViewAvatar` of step 3:
|
|
256
|
+
|
|
257
|
+
```ts
|
|
258
|
+
const canViewAvatar = (viewer: { type: 'user'; id: string }, owner: { type: 'user'; id: string }) =>
|
|
259
|
+
access.can(viewer, 'viewAvatar', owner); // a user passed as it is, is that user
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
`can()` answers `false` for a denial and throws `STORE_FAILED` for an
|
|
263
|
+
outage: answer the outage 503, never 404.
|
|
264
|
+
|
|
265
|
+
**And on the GraphQL field**, with
|
|
266
|
+
[`@softistx/janus-graphql`](https://github.com/softistx/nxgt-janus/blob/develop/packages/janus-graphql/docs/guide/avatars.md), either
|
|
267
|
+
the directive or `can()`:
|
|
268
|
+
|
|
269
|
+
```graphql
|
|
270
|
+
type Member {
|
|
271
|
+
id: ID!
|
|
272
|
+
avatar: JanusAvatar @permission(name: "viewAvatar", type: "user", id: "parent.id")
|
|
273
|
+
}
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
The directive's ids, loaders and the `null`-on-deny alternative are in
|
|
277
|
+
[the GraphQL avatars guide](https://github.com/softistx/nxgt-janus/blob/develop/packages/janus-graphql/docs/guide/avatars.md#who-may-see-an-avatar).
|
|
278
|
+
|
|
279
|
+
## 5. Failure order and traps
|
|
280
|
+
|
|
281
|
+
- **Bytes before the record.** If `avatar.set` fails after the bytes were
|
|
282
|
+
written, the image is an orphan nobody points at; the other order could
|
|
283
|
+
leave a record pointing at bytes that were never written. An orphan costs
|
|
284
|
+
storage; a dangling record costs a broken image.
|
|
285
|
+
- **A fresh id for every upload.** `store.replace` writes under keys built
|
|
286
|
+
from its params. Reusing the user's id overwrites the image they are
|
|
287
|
+
showing, and the later removal of the former image — the same id — deletes
|
|
288
|
+
the new one. Janus refuses an id that is not a non-empty string of at most
|
|
289
|
+
512 characters that every store can keep (no NUL, no lone surrogate;
|
|
290
|
+
`AVATAR_ID_INVALID`) and nothing else.
|
|
291
|
+
- **Setting the same id is a no-op**: no write, no event, so no former image
|
|
292
|
+
to delete.
|
|
293
|
+
- **Janus has no access check.** `avatar.set`, `avatar.remove`, `find` and
|
|
294
|
+
`get` answer whoever calls them. Check the session and the rule before
|
|
295
|
+
each, as the routes above do.
|
|
296
|
+
- **Webhooks strip `formerAvatarId`.** Delete the former image from the
|
|
297
|
+
in-process listener, or read `user.avatar?.id` before the call.
|
|
298
|
+
- **`Cache-Control: private, no-cache`, not `max-age`.** `no-cache` lets the
|
|
299
|
+
browser keep the bytes but makes it ask the route on every view, so the
|
|
300
|
+
access check runs again: a member removed from an organization stops seeing
|
|
301
|
+
its accounts' images at the next view, and an unchanged image costs one 304.
|
|
302
|
+
A `max-age=86400` would serve a revoked viewer the cached image for a day,
|
|
303
|
+
with no request to refuse. `private` keeps a shared cache or a CDN out.
|
|
304
|
+
- **`VERSION_CONFLICT` is not only a stale `ifVersion`.** Any write that
|
|
305
|
+
landed between the read and the write conflicts too, with or without an
|
|
306
|
+
`ifVersion` of yours: a sign-in that rehashed the password is one. Delete
|
|
307
|
+
your fresh upload on any failure of `avatar.set`, as the route above does.
|
|
308
|
+
- **Never a public URL.** A public bucket or a signed URL needs no session:
|
|
309
|
+
anyone holding the link, an ex-member included, keeps seeing the image.
|
|
310
|
+
The proxy route is what makes the rule above hold.
|
|
311
|
+
- **Deploy the schema first.** `avatar` is a column or a document field, and
|
|
312
|
+
the two adapters fail differently before it exists. On MongoDB, run
|
|
313
|
+
`syncMongoStores(db)` before the release that calls `avatar.set` or
|
|
314
|
+
`avatar.remove`: until then only a write that sets an avatar fails, with
|
|
315
|
+
`STORE_FAILED`. On PostgreSQL, run the
|
|
316
|
+
[drizzle migration](https://github.com/softistx/nxgt-janus/blob/develop/packages/janus-drizzle/docs/guide/migrations.md)
|
|
317
|
+
before the release at all: the columns are missing, so every query on
|
|
318
|
+
`users` fails with `STORE_FAILED`, sign-in included.
|
|
319
|
+
- **An avatar set before the address was proven is not cleared by the
|
|
320
|
+
proof.** The first e-mail proof clears the password, the second factor and the avatar
|
|
321
|
+
of a user who registered an address they do not own (a squatter's), but not
|
|
322
|
+
the avatar. An application that shows avatars of unverified accounts calls
|
|
323
|
+
`avatar.remove` for a user whose `user.emailVerified` has just turned true, or does
|
|
324
|
+
not show the avatar of a user whose `emailVerified` is `false`.
|
|
325
|
+
- **Delete the account's image with the account.** `user.deleted` carries
|
|
326
|
+
no avatar id: read `user.avatar?.id` before calling `delete`, and remove
|
|
327
|
+
that image once it answered.
|
|
328
|
+
|
|
329
|
+
## See also
|
|
330
|
+
|
|
331
|
+
- [User events](events.md) — `user.avatarChanged`, `user.avatarRemoved` and `formerAvatarId`
|
|
332
|
+
- [Users](users.md) — `user.avatar` and the reserved name
|
|
333
|
+
- [Permissions](permissions.md) — `defineModel`, `fromField`, `grant`, `can`
|
|
334
|
+
- [`@softistx/janus-graphql`'s avatar guide](https://github.com/softistx/nxgt-janus/blob/develop/packages/janus-graphql/docs/guide/avatars.md) — the `JanusAvatar` type and its `url(size:)`
|