@softistx/janus 0.0.0-stage → 0.73.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +2928 -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 +64 -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 +139 -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 +16 -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 +193 -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-ftz0ne6j.js +127 -0
- package/dist/chunks/index-ftz0ne6j.js.map +11 -0
- package/dist/chunks/index-k6y18nx9.js +724 -0
- package/dist/chunks/index-k6y18nx9.js.map +24 -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 +4411 -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 +6933 -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 +858 -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 +639 -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 +101 -0
- package/docs/troubleshooting.md +3305 -0
- package/package.json +77 -5
|
@@ -0,0 +1,719 @@
|
|
|
1
|
+
# Permissions — `@softistx/janus/permissions`
|
|
2
|
+
|
|
3
|
+
This page is for modelling who may do what, and asking: `defineModel`,
|
|
4
|
+
`fromField`, `when`, then `can`, `list`, `grant`, `revoke` and `replace`. It is
|
|
5
|
+
Zanzibar's model — relations between objects and subjects, permissions
|
|
6
|
+
computed from them — **without its infrastructure**: the tuples live in your
|
|
7
|
+
database, so a read follows a write and there is nothing to cache.
|
|
8
|
+
|
|
9
|
+
It is the **permissions** side, and it is usable alone: the example below wires
|
|
10
|
+
it to `janus()` so the user types become the subjects, but `subjects` takes
|
|
11
|
+
any list of names — `defineModel({ subjects: ['user'], … })` — when your users
|
|
12
|
+
live elsewhere. Importing `@softistx/janus/permissions` loads no identity code.
|
|
13
|
+
|
|
14
|
+
## The running example: a clinic
|
|
15
|
+
|
|
16
|
+
Every snippet on this page uses this model, and only its names. Two sections
|
|
17
|
+
need something else and say so: a [folder tree](#a-hierarchy) and
|
|
18
|
+
[permissions on a user](#permissions-on-a-user).
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import { z } from 'zod';
|
|
22
|
+
import { createMemoryStores, type CursorPage, janus, scryptHasher } from '@softistx/janus';
|
|
23
|
+
import { createMemoryRelations, defineModel, fromField, permissions, when } from '@softistx/janus/permissions';
|
|
24
|
+
|
|
25
|
+
const relations = createMemoryRelations();
|
|
26
|
+
|
|
27
|
+
const auth = janus({
|
|
28
|
+
users: {
|
|
29
|
+
staff: { schema: z.object({ username: z.string() }), password: { login: 'username' } },
|
|
30
|
+
patient: { schema: z.object({ email: z.email() }), password: { login: 'email' } },
|
|
31
|
+
},
|
|
32
|
+
store: createMemoryStores(),
|
|
33
|
+
relations, // deleting a user deletes every tuple naming them
|
|
34
|
+
hasher: scryptHasher(),
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const model = defineModel({
|
|
38
|
+
subjects: auth.types, // 'staff' | 'patient': a user type is a subject type
|
|
39
|
+
types: {
|
|
40
|
+
team: {
|
|
41
|
+
related: { members: ['staff', 'team#members'], leads: ['staff'] },
|
|
42
|
+
permits: { manage: ['leads'], view: ['members', 'manage'] },
|
|
43
|
+
},
|
|
44
|
+
record: {
|
|
45
|
+
related: {
|
|
46
|
+
doctors: fromField('doctorId', 'staff', { lookup: (staffId) => db.records.idsByDoctor(staffId) }),
|
|
47
|
+
patients: fromField('patientId', 'patient', { lookup: (patientId) => db.records.idsByPatient(patientId) }),
|
|
48
|
+
teams: ['team'],
|
|
49
|
+
},
|
|
50
|
+
permits: {
|
|
51
|
+
view: ['doctors', 'patients', 'teams->view'],
|
|
52
|
+
review: ['teams->leads'],
|
|
53
|
+
edit: [when('doctors', (ctx: { onShift: boolean }) => ctx.onShift)],
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
const access = permissions({ model, store: relations });
|
|
60
|
+
|
|
61
|
+
const grace = await auth.staff.create({ username: 'grace' }); // a doctor
|
|
62
|
+
const ada = await auth.staff.create({ username: 'ada' }); // a team lead
|
|
63
|
+
const team = { type: 'team', id: 't1' } as const;
|
|
64
|
+
const record = { id: 'r1', doctorId: grace.id, patientId: 'p1', title: 'Chart' }; // as your database answered it
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
`db` is your database; the two `lookup`s answer the ids of the records whose
|
|
68
|
+
field names the subject — see [`fromField`](#a-relation-read-from-the-object).
|
|
69
|
+
|
|
70
|
+
In words: a team has **members** — staff, or every member of another team —
|
|
71
|
+
and **leads**; whoever leads it may **manage** it, and members and managers
|
|
72
|
+
may **view** it. A record's **doctors** and **patients** are read from its own
|
|
73
|
+
fields, its **teams** are stored; its doctors, its patients and whoever can
|
|
74
|
+
view one of its teams may **view** it, the leads of its teams may **review**
|
|
75
|
+
it, and its doctors may **edit** it while on shift.
|
|
76
|
+
|
|
77
|
+
## The model
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
function defineModel<
|
|
81
|
+
const Subjects extends readonly string[], // auth.types
|
|
82
|
+
const Ts extends ModelConfig['types'] & ModelTypesOf<Subjects[number], Ts>, // what your editor completes
|
|
83
|
+
>(config: { readonly subjects: Subjects; readonly types: Ts }): PermissionModel<{ readonly subjects: Subjects; readonly types: Ts }>;
|
|
84
|
+
// ModelTypesOf<S, Ts>: the names each relation and rule of each type may take
|
|
85
|
+
|
|
86
|
+
interface ModelConfig {
|
|
87
|
+
readonly subjects: readonly string[]; // pass auth.types
|
|
88
|
+
readonly types: {
|
|
89
|
+
readonly [objectType: string]: {
|
|
90
|
+
readonly related?: { readonly [relation: string]: readonly string[] | FromField };
|
|
91
|
+
readonly permits?: { readonly [permission: string]: readonly (string | When)[] };
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
An object type has two keys, Keto's words: **`related`**, who may hold each
|
|
98
|
+
relation, and **`permits`**, what each permission is made of. Relation names
|
|
99
|
+
are plural by convention — `members`, `doctors`, `teams` — because a relation
|
|
100
|
+
holds many; `defineModel` does not enforce it.
|
|
101
|
+
|
|
102
|
+
**A relation** lists who may hold it:
|
|
103
|
+
|
|
104
|
+
| Holder | Means |
|
|
105
|
+
| --- | --- |
|
|
106
|
+
| `'staff'` | one user of type `staff` |
|
|
107
|
+
| `'team'` | one object of type `team` — what an arrow follows |
|
|
108
|
+
| `'team#members'` | a **subject set**: every member of a team |
|
|
109
|
+
| `fromField('doctorId', 'staff')` | read from the object's own data — see [`fromField`](#a-relation-read-from-the-object) |
|
|
110
|
+
|
|
111
|
+
**A permission** is the union of its rules:
|
|
112
|
+
|
|
113
|
+
| Rule | Means |
|
|
114
|
+
| --- | --- |
|
|
115
|
+
| `'members'` | a relation of the same object |
|
|
116
|
+
| `'manage'` | another permission of the same object |
|
|
117
|
+
| `'teams->view'` | an **arrow**: whoever holds `view` on one of the object's `teams` |
|
|
118
|
+
| `'teams->leads'` | an arrow to a relation: whoever leads one of the object's `teams` |
|
|
119
|
+
| `when('doctors', (ctx: { onShift: boolean }) => ctx.onShift)` | a rule under a condition — see [`when`](#a-condition) |
|
|
120
|
+
|
|
121
|
+
A rule may name another permission of the same type — `view: ['members',
|
|
122
|
+
'manage']` — but never the permission itself: `view: ['view']` adds nothing
|
|
123
|
+
and is a loop no relation ends, so your editor does not offer it and the
|
|
124
|
+
compiler refuses it. A loop through another permission (`view: ['edit'],
|
|
125
|
+
edit: ['view']`) is refused by `defineModel` when it runs.
|
|
126
|
+
|
|
127
|
+
A permission may be asked of `can` and `list` like a relation, and a relation
|
|
128
|
+
like a permission.
|
|
129
|
+
|
|
130
|
+
### What the compiler refuses
|
|
131
|
+
|
|
132
|
+
A relation naming a type that does not exist, a rule naming nothing, an arrow
|
|
133
|
+
to a permission its target lacks, an arrow through a relation that can hold a
|
|
134
|
+
subject set, a name that is both a relation and a permission, a key other than
|
|
135
|
+
`related` and `permits` — `permit:`, singular — on an object type: each is a
|
|
136
|
+
compile error **on the offending name** — on the whole `fromField(…)` or
|
|
137
|
+
`when(…)` call for those two. Except for the name used twice, which says to
|
|
138
|
+
rename one, the error lists what you could have written, with "Did you mean"
|
|
139
|
+
when one is close.
|
|
140
|
+
|
|
141
|
+
```ts
|
|
142
|
+
defineModel({
|
|
143
|
+
subjects: ['staff'],
|
|
144
|
+
types: {
|
|
145
|
+
team: {
|
|
146
|
+
// @ts-expect-error — Type '"staf"' is not assignable to type '"staff" | "team" | "team#members"'. Did you mean '"staff"'?
|
|
147
|
+
related: { members: ['staf'] },
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
});
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
**The keys before 0.2**, `relations` and `permissions`, are refused with the
|
|
154
|
+
name that replaced them — rename the key, nothing else changes:
|
|
155
|
+
|
|
156
|
+
```ts
|
|
157
|
+
defineModel({
|
|
158
|
+
subjects: ['staff'],
|
|
159
|
+
types: {
|
|
160
|
+
team: {
|
|
161
|
+
// @ts-expect-error — 'members' does not exist in type 'Refusal<"team.relations is now related: rename the key", never>'
|
|
162
|
+
relations: { members: ['staff'] },
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
});
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
`permissions:` is refused the same way: `team.permissions is now permits:
|
|
169
|
+
rename the key`.
|
|
170
|
+
|
|
171
|
+
Your editor offers those names as you type — subject types and subject sets
|
|
172
|
+
in a relation, subject types in `fromField`, relations, permissions and arrows
|
|
173
|
+
in a rule and in `when` — because `defineModel` types its `types` with a
|
|
174
|
+
constraint an editor reads, not only with a check. A spec asks the TypeScript
|
|
175
|
+
language service what it completes, so a change that loses it fails.
|
|
176
|
+
|
|
177
|
+
### What `defineModel` refuses at run time
|
|
178
|
+
|
|
179
|
+
With a `TypeError`, when the model is defined — never at a check. Each names
|
|
180
|
+
the key you wrote, `types.record.permits.view` or `types.team.related.members`:
|
|
181
|
+
|
|
182
|
+
- `relations` or `permissions` — the keys before 0.2 — and any key other than
|
|
183
|
+
`related` and `permits`;
|
|
184
|
+
- a name that is not camelCase;
|
|
185
|
+
- a permission that reaches itself without crossing a relation (`view:
|
|
186
|
+
['edit'], edit: ['view']`) — no data could ever end that loop;
|
|
187
|
+
- a subject set or an arrow that would have to read **another** object's
|
|
188
|
+
`fromField` — only the object passed to `can()` carries its data. Store that
|
|
189
|
+
relation instead.
|
|
190
|
+
|
|
191
|
+
A loop that crosses a relation — a folder viewable through its parents — is
|
|
192
|
+
fine: the data ends it. See [a hierarchy](#a-hierarchy).
|
|
193
|
+
|
|
194
|
+
## Use cases
|
|
195
|
+
|
|
196
|
+
Each case below runs against the clinic above, in order — except the two that
|
|
197
|
+
say otherwise: a folder tree for a hierarchy, and staff members who manage
|
|
198
|
+
each other for permissions on a user.
|
|
199
|
+
|
|
200
|
+
### A direct relation
|
|
201
|
+
|
|
202
|
+
A relation is what you store: `grant` writes it, `can` reads it.
|
|
203
|
+
|
|
204
|
+
```ts
|
|
205
|
+
await access.grant(team, 'leads', ada);
|
|
206
|
+
await access.can(ada, 'leads', team); // true: a relation may be asked like a permission
|
|
207
|
+
await access.can(grace, 'leads', team); // false
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### A permission naming a permission
|
|
211
|
+
|
|
212
|
+
`view: ['members', 'manage']` includes whoever holds `manage`, which is
|
|
213
|
+
`['leads']` — so a lead can view the team without being a member.
|
|
214
|
+
|
|
215
|
+
```ts
|
|
216
|
+
await access.can(ada, 'manage', team); // true: ada leads t1
|
|
217
|
+
await access.can(ada, 'view', team); // true: view includes manage
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
### A subject set
|
|
221
|
+
|
|
222
|
+
`members: ['staff', 'team#members']` admits a staff member, or **every member
|
|
223
|
+
of another team** at once. Grant the set with its `relation`:
|
|
224
|
+
|
|
225
|
+
```ts
|
|
226
|
+
const cardiology = { type: 'team', id: 't2' } as const;
|
|
227
|
+
await access.grant(cardiology, 'members', grace);
|
|
228
|
+
await access.grant(team, 'members', { type: 'team', id: 't2', relation: 'members' });
|
|
229
|
+
await access.can(grace, 'view', team); // true: grace is a member of t2, whose members are members of t1
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
`setOf(cardiology, 'members')`, from `@softistx/janus`, writes the same set. On an
|
|
233
|
+
object type the two are the same; on a user type only `setOf` makes a set —
|
|
234
|
+
see [permissions on a user](#permissions-on-a-user).
|
|
235
|
+
|
|
236
|
+
The set is followed as the data stands: revoke grace from `t2`, and she no
|
|
237
|
+
longer views `t1`. A team member of itself — a cycle in the data — is cut, and
|
|
238
|
+
is not an error.
|
|
239
|
+
|
|
240
|
+
### An arrow
|
|
241
|
+
|
|
242
|
+
`'teams->view'` is **whoever can view one of the record's teams**; the arrow
|
|
243
|
+
follows the objects the `teams` relation holds, and asks them `view`. Grant
|
|
244
|
+
the record its team, then everyone who views the team views the record:
|
|
245
|
+
|
|
246
|
+
```ts
|
|
247
|
+
await access.grant({ type: 'record', id: record.id }, 'teams', team);
|
|
248
|
+
await access.can(ada, 'view', { type: 'record', ...record }); // true: ada views t1 (she leads it)
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
An arrow may end on a relation too: `review: ['teams->leads']` is whoever
|
|
252
|
+
**leads** one of the record's teams — not its members.
|
|
253
|
+
|
|
254
|
+
```ts
|
|
255
|
+
await access.can(ada, 'review', { type: 'record', ...record }); // true: ada leads t1
|
|
256
|
+
await access.can(grace, 'review', { type: 'record', ...record }); // false: grace is a member, not a lead
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
An arrow follows **object types only**: through a relation that can hold a
|
|
260
|
+
subject set (`teams: ['team', 'team#members']`), `'teams->view'` is a compile
|
|
261
|
+
error.
|
|
262
|
+
|
|
263
|
+
### A hierarchy
|
|
264
|
+
|
|
265
|
+
A folder tree, one of the two models on this page besides the clinic: a folder is
|
|
266
|
+
viewable by its owners and by whoever views one of its parents. The arrow
|
|
267
|
+
names the folder's own `view` — a loop in the model, which **the data ends**:
|
|
268
|
+
the walk stops at a folder with no parents.
|
|
269
|
+
|
|
270
|
+
```ts
|
|
271
|
+
const files = permissions({
|
|
272
|
+
model: defineModel({
|
|
273
|
+
subjects: auth.types,
|
|
274
|
+
types: {
|
|
275
|
+
folder: {
|
|
276
|
+
related: { owners: ['staff'], parents: ['folder'] },
|
|
277
|
+
permits: { view: ['owners', 'parents->view'] },
|
|
278
|
+
},
|
|
279
|
+
},
|
|
280
|
+
}),
|
|
281
|
+
store: createMemoryRelations(),
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
const root = { type: 'folder', id: 'root' } as const;
|
|
285
|
+
const reports = { type: 'folder', id: 'reports' } as const;
|
|
286
|
+
await files.grant(root, 'owners', grace);
|
|
287
|
+
await files.grant(reports, 'parents', root);
|
|
288
|
+
await files.can(grace, 'view', reports); // true: she owns its parent
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
A deep tree crosses one relation per level; past `maxDepth` (`25`) the check
|
|
292
|
+
is `PERMISSION_DEPTH`, never `false`.
|
|
293
|
+
|
|
294
|
+
### A relation read from the object
|
|
295
|
+
|
|
296
|
+
```ts
|
|
297
|
+
function fromField(field, subjectType): FromField;
|
|
298
|
+
function fromField(field, subjectType, { lookup }): ReversibleFromField;
|
|
299
|
+
type Lookup = (subjectId: string) => Promise<readonly string[]>;
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
`doctors: fromField('doctorId', 'staff')` reads the record's own `doctorId`
|
|
303
|
+
rather than a tuple kept in sync with it. Nothing is stored, and `grant`
|
|
304
|
+
refuses it at compile time. `can()` is given the object, and the compiler
|
|
305
|
+
requires every field a `fromField` of its type reads — here `doctorId` and
|
|
306
|
+
`patientId`:
|
|
307
|
+
|
|
308
|
+
```ts
|
|
309
|
+
await access.can(grace, 'view', { type: 'record', ...record }); // true: record.doctorId is grace's id
|
|
310
|
+
// @ts-expect-error — doctors is read from a field: there is nothing to grant
|
|
311
|
+
await access.grant({ type: 'record', id: record.id }, 'doctors', grace);
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
**Spread the loaded object.** A field missing at run time is a `TypeError`,
|
|
315
|
+
never a denial. `null` in the field holds nobody.
|
|
316
|
+
|
|
317
|
+
**`list()` needs a `lookup`.** It cannot read a field of objects it has not
|
|
318
|
+
found, so it asks `lookup` for the ids of the objects whose field names the
|
|
319
|
+
subject — in the clinic, `db.records.idsByDoctor(staffId)`. A `list()` that
|
|
320
|
+
would reach a `fromField` without one is a compile error, and your editor does
|
|
321
|
+
not offer that permission.
|
|
322
|
+
|
|
323
|
+
A lookup is your code, and it is not guarded: one that throws rejects `list()`
|
|
324
|
+
with its own error. **Never answer `[]` for a database that could not answer**
|
|
325
|
+
— that is a denial made of an outage.
|
|
326
|
+
|
|
327
|
+
### A condition
|
|
328
|
+
|
|
329
|
+
```ts
|
|
330
|
+
function when<const Rule extends string, Ctx>(rule: Rule, test: (ctx: Ctx) => boolean): When<Rule, Ctx>;
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
`edit: [when('doctors', (ctx: { onShift: boolean }) => ctx.onShift)]` grants
|
|
334
|
+
the record's doctors, **while on shift**. The rule is any rule of the same
|
|
335
|
+
type — a relation, a permission, an arrow. The test is synchronous and pure:
|
|
336
|
+
it decides on what the caller passes, and reads nothing. Its `ctx` is what
|
|
337
|
+
`can()` and `list()` then **require** — and only for the permissions whose
|
|
338
|
+
rules reach it:
|
|
339
|
+
|
|
340
|
+
```ts
|
|
341
|
+
await access.can(grace, 'edit', { type: 'record', ...record }, { ctx: { onShift: true } }); // true
|
|
342
|
+
await access.can(grace, 'edit', { type: 'record', ...record }, { ctx: { onShift: false } }); // false
|
|
343
|
+
// @ts-expect-error — ctx is required: edit reaches a condition
|
|
344
|
+
await access.can(grace, 'edit', { type: 'record', ...record });
|
|
345
|
+
|
|
346
|
+
await access.can(grace, 'view', { type: 'record', ...record }); // no ctx: view reaches no condition
|
|
347
|
+
await access.list(grace, 'edit', 'record', { ctx: { onShift: true } });
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
### Permissions on a user
|
|
351
|
+
|
|
352
|
+
A user type may also be an object type: declare `staff` under `types`, and a
|
|
353
|
+
staff member is an object like a record — asked `can()`, granted relations,
|
|
354
|
+
listed. To decide who may edit a staff member, give `staff` the relations that
|
|
355
|
+
say so:
|
|
356
|
+
|
|
357
|
+
```ts
|
|
358
|
+
import { setOf } from '@softistx/janus';
|
|
359
|
+
|
|
360
|
+
const people = permissions({
|
|
361
|
+
model: defineModel({
|
|
362
|
+
subjects: auth.types,
|
|
363
|
+
types: {
|
|
364
|
+
staff: {
|
|
365
|
+
related: {
|
|
366
|
+
self: fromField('id', 'staff', { lookup: async (staffId) => [staffId] }),
|
|
367
|
+
managers: ['staff', 'staff#managers'],
|
|
368
|
+
},
|
|
369
|
+
permits: { edit: ['self', 'managers'] },
|
|
370
|
+
},
|
|
371
|
+
note: {
|
|
372
|
+
related: { readers: ['staff', 'staff#managers'] },
|
|
373
|
+
permits: { read: ['readers'] },
|
|
374
|
+
},
|
|
375
|
+
},
|
|
376
|
+
}),
|
|
377
|
+
store: relations,
|
|
378
|
+
});
|
|
379
|
+
|
|
380
|
+
const bob = await auth.staff.create({ username: 'bob' });
|
|
381
|
+
await people.can(bob, 'edit', bob); // true: himself, read from his id
|
|
382
|
+
await people.can(ada, 'edit', bob); // false
|
|
383
|
+
await people.grant(bob, 'managers', ada);
|
|
384
|
+
await people.can(ada, 'edit', bob); // true: she manages him
|
|
385
|
+
await people.list(ada, 'edit', 'staff'); // herself, and bob
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
**A user passed as it is, is that user** — never a set, even when one of its
|
|
389
|
+
fields is named `relation`. A set on a user type is made by **`setOf`**: every
|
|
390
|
+
staff member who manages bob reads the note, as the data stands:
|
|
391
|
+
|
|
392
|
+
```ts
|
|
393
|
+
const note = { type: 'note', id: 'n1' } as const;
|
|
394
|
+
await people.grant(note, 'readers', setOf(bob, 'managers'));
|
|
395
|
+
await people.can(ada, 'read', note); // true: she manages bob
|
|
396
|
+
await people.can(bob, 'read', note); // false: bob is not his own manager
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
Only `setOf` marks a set. `{ type: 'staff', id: bob.id, relation: 'managers' }`
|
|
400
|
+
written out is bob himself at run time: granted silently where the relation
|
|
401
|
+
admits a staff member, refused where it does not. The compiler refuses it in
|
|
402
|
+
`grant()` and `revoke()`; `can()` and `list()` accept it and ask about bob, a
|
|
403
|
+
gap the README names. A spread
|
|
404
|
+
of a set keeps the mark; `JSON` and `structuredClone` drop it, so a set read
|
|
405
|
+
back from either is bob again — call `setOf` on it, or keep its notation
|
|
406
|
+
(`staff:…#managers`), which `parseSubject` reads back as the set. It copies
|
|
407
|
+
`type` and `id` only, so none of bob's fields reaches a tuple. A set on a user type
|
|
408
|
+
the model does not also declare under `types` is refused by `can()`, `list()`,
|
|
409
|
+
`grant()` and `revoke()` — and by the compiler first: there is no relation to
|
|
410
|
+
hold.
|
|
411
|
+
|
|
412
|
+
The `lookup` of `self` answers the one staff member whose id is the subject's,
|
|
413
|
+
so `list()` finds ada herself too.
|
|
414
|
+
|
|
415
|
+
## `permissions()`
|
|
416
|
+
|
|
417
|
+
```ts
|
|
418
|
+
function permissions<C extends ModelConfig>(options: PermissionsOptions<C>): Permissions<C>;
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
| Option | Type | Default | Effect |
|
|
422
|
+
| --- | --- | --- | --- |
|
|
423
|
+
| `model` | `PermissionModel` | — | What `defineModel` answered |
|
|
424
|
+
| `store` | `RelationStore` | — | Where tuples live: `createMemoryRelations()` in tests, `createMongoRelations(db)` from `@softistx/janus-mongo` |
|
|
425
|
+
| `maxDepth` | positive integer | `25` | How many relations a check may cross. Past it: `PERMISSION_DEPTH` |
|
|
426
|
+
|
|
427
|
+
It connects to nothing, and refuses a store missing a method with a
|
|
428
|
+
`TypeError`.
|
|
429
|
+
|
|
430
|
+
### `can`
|
|
431
|
+
|
|
432
|
+
```ts
|
|
433
|
+
can(subject, permission, object, options?): Promise<boolean>;
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
- `subject` is a user from `janus()` as it is — any object with `type` and
|
|
437
|
+
`id` — an object of the model, or `null` for anonymous, which answers `false`
|
|
438
|
+
before any store call.
|
|
439
|
+
- `permission` must be a relation or a permission of the object's type.
|
|
440
|
+
- `object` is `{ type, id }` plus every field its `fromField`s read.
|
|
441
|
+
- `options.ctx` is required exactly when a `when` is reachable.
|
|
442
|
+
|
|
443
|
+
Your editor completes `permission` with the names of the object's type once
|
|
444
|
+
the object is written. **Before, it offers the names of every type**: the
|
|
445
|
+
permission comes before the object, and nothing yet says which type it is.
|
|
446
|
+
|
|
447
|
+
```ts
|
|
448
|
+
await access.can(grace, 'view', { type: 'record', ...record }); // true
|
|
449
|
+
await access.can(grace, 'edit', { type: 'record', ...record }, { ctx: { onShift: false } }); // false
|
|
450
|
+
await access.can(null, 'view', { type: 'record', ...record }); // false, no store call
|
|
451
|
+
```
|
|
452
|
+
|
|
453
|
+
**A denial is `false`; a failure throws.** A store that cannot answer is
|
|
454
|
+
`STORE_FAILED`; a walk past `maxDepth` is `PERMISSION_DEPTH`. Neither is ever
|
|
455
|
+
`false`, which would deny everybody everything during an outage and say
|
|
456
|
+
nothing. A cycle in the data — a team member of itself — is cut, and is not an
|
|
457
|
+
error.
|
|
458
|
+
|
|
459
|
+
**An id no store can keep is held by nobody.** An id holding a NUL character
|
|
460
|
+
(`\u0000`) or a lone surrogate cannot be written to PostgreSQL, so no tuple can
|
|
461
|
+
name it: `can()` answers `false` for such an object or subject before any
|
|
462
|
+
store call, a `fromField` whose value holds one names nobody, and `list()`
|
|
463
|
+
leaves out an id a `lookup` answers holding one. Every other character is an
|
|
464
|
+
id like any other.
|
|
465
|
+
|
|
466
|
+
### `list`
|
|
467
|
+
|
|
468
|
+
```ts
|
|
469
|
+
list(subject, permission, objectType, options?): Promise<CursorPage<string>>;
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
The ids of the objects of `objectType` on which `subject` holds `permission`,
|
|
473
|
+
ascending, by pages — what `can()` answers `true` for, found without naming
|
|
474
|
+
them. Page with `limit` and `after`, passing each `nextCursor` back as it
|
|
475
|
+
came, until it is `null`:
|
|
476
|
+
|
|
477
|
+
```ts
|
|
478
|
+
const page = await access.list(grace, 'view', 'record', { limit: 50 });
|
|
479
|
+
page.items; // readonly string[]: the records grace can view — hers, and her teams'
|
|
480
|
+
page.nextCursor; // string | null
|
|
481
|
+
await access.list(grace, 'view', 'record', { after: page.nextCursor, limit: 50 });
|
|
482
|
+
|
|
483
|
+
// Every page — annotate the page, or TypeScript cannot type the loop (TS7022):
|
|
484
|
+
let after: string | null = null;
|
|
485
|
+
do {
|
|
486
|
+
const next: CursorPage<string> = await access.list(grace, 'view', 'record', { after, limit: 100 });
|
|
487
|
+
for (const id of next.items) console.log(id);
|
|
488
|
+
after = next.nextCursor;
|
|
489
|
+
} while (after);
|
|
490
|
+
```
|
|
491
|
+
|
|
492
|
+
`CursorPage` is exported from `@softistx/janus`.
|
|
493
|
+
|
|
494
|
+
`limit` is 20 by default and at most 100 — a larger one is capped, and one
|
|
495
|
+
that is not a positive integer is a `TypeError`, so parse a limit read from a
|
|
496
|
+
request first ([troubleshooting](../troubleshooting.md#call-limit-must-be-an-integer-of-at-least-1-or-absent)).
|
|
497
|
+
`ctx` is required as for `can` — `list(grace, 'edit', 'record', { ctx })`.
|
|
498
|
+
Your editor completes `permission` with what `list()` can answer only: a name
|
|
499
|
+
reaching a `fromField` with no `lookup` is neither offered nor accepted.
|
|
500
|
+
`null` answers an empty page before any store call, and so does a subject
|
|
501
|
+
whose id no store can keep; an id a `lookup` answers that no store can keep is
|
|
502
|
+
left out of the page.
|
|
503
|
+
|
|
504
|
+
`list()` walks backwards from the subject, reading every page of the reverse
|
|
505
|
+
index for every id each step reaches. That is fine for what one user can see,
|
|
506
|
+
and not for a subject set holding most of the database — write a query of your
|
|
507
|
+
own for that.
|
|
508
|
+
|
|
509
|
+
### `grant` and `revoke`
|
|
510
|
+
|
|
511
|
+
```ts
|
|
512
|
+
grant(object, relation, subject): Promise<void>;
|
|
513
|
+
revoke(object, relation, subject): Promise<void>;
|
|
514
|
+
```
|
|
515
|
+
|
|
516
|
+
Both are typed from the model: only a stored relation (never a `fromField`),
|
|
517
|
+
and only a holder the relation admits — a staff member, or a team's members
|
|
518
|
+
where `'team#members'` is declared.
|
|
519
|
+
|
|
520
|
+
```ts
|
|
521
|
+
await access.grant(team, 'members', grace); // a staff member
|
|
522
|
+
await access.grant(team, 'members', { type: 'team', id: 't2', relation: 'members' }); // a subject set
|
|
523
|
+
await access.grant({ type: 'record', id: 'r1' }, 'teams', team); // what 'teams->view' follows
|
|
524
|
+
await access.revoke(team, 'members', grace);
|
|
525
|
+
```
|
|
526
|
+
|
|
527
|
+
An object or subject id holding a NUL character or a lone surrogate is a
|
|
528
|
+
`TypeError` — no store can keep it, so nothing could hold it
|
|
529
|
+
([troubleshooting](../troubleshooting.md#other-can-list-grant-and-revoke-messages)).
|
|
530
|
+
Both are idempotent: granting what is held, or revoking what is not, is not an
|
|
531
|
+
error. Each writes one tuple.
|
|
532
|
+
|
|
533
|
+
The same rule holds when reading: `can()` and `list()` follow only the holders
|
|
534
|
+
a relation admits. A tuple stored past `grant()` — by an older model, or by
|
|
535
|
+
hand — that the model does not admit grants nothing. `revoke()` refuses it as
|
|
536
|
+
it refuses to `grant()` it, so remove it with the store:
|
|
537
|
+
|
|
538
|
+
```ts
|
|
539
|
+
await relations.write({
|
|
540
|
+
remove: [{ object: { type: 'record', id: 'r1' }, relation: 'teams', subject: { type: 'team', id: 't1' } }],
|
|
541
|
+
});
|
|
542
|
+
```
|
|
543
|
+
|
|
544
|
+
Narrowing a model therefore hides the tuples it no longer admits; it does not
|
|
545
|
+
delete them, and widening it again brings them back.
|
|
546
|
+
|
|
547
|
+
### `replace`
|
|
548
|
+
|
|
549
|
+
```ts
|
|
550
|
+
replace(object, relation, subjects): Promise<{ added: RelationTuple[]; removed: RelationTuple[] }>;
|
|
551
|
+
```
|
|
552
|
+
|
|
553
|
+
Makes `subjects` the only holders of `relation` on `object`: the use is
|
|
554
|
+
keeping a group's members equal to a list the application already holds.
|
|
555
|
+
`subjects` is typed as `grant`'s `subject`, as an array. It answers the
|
|
556
|
+
tuples it added and the tuples it removed, `{ object, relation, subject }`
|
|
557
|
+
each, in the order written, so the application can audit or mirror them.
|
|
558
|
+
|
|
559
|
+
```ts
|
|
560
|
+
const wanted = await db.staff.membersOf('cardiology');
|
|
561
|
+
const { added, removed } = await access.replace(cardiology, 'members', wanted);
|
|
562
|
+
// added[0] is { object: cardiology, relation: 'members', subject: … }
|
|
563
|
+
|
|
564
|
+
await access.replace(cardiology, 'members', []); // removes every holder
|
|
565
|
+
```
|
|
566
|
+
|
|
567
|
+
- Every subject is checked first, as `grant()` checks it, and one refusal
|
|
568
|
+
anywhere in the list is a `TypeError` that writes nothing. An empty list
|
|
569
|
+
still names an object and a stored relation, and those are checked.
|
|
570
|
+
- The current holders are read (`findEntities` and `findSubjectSets`), and the
|
|
571
|
+
difference is one `write`: removals and additions together, all or nothing
|
|
572
|
+
as the port requires, and no write when both are empty.
|
|
573
|
+
- A holder is told apart by its type, id and, for a subject set, its relation:
|
|
574
|
+
`team:t2#members` is not the entity `team:t2`. A subject listed twice counts
|
|
575
|
+
once.
|
|
576
|
+
- Tuples of other relations, and of other objects, are never touched. A tuple
|
|
577
|
+
stored past the model (an older model, or by hand) that the list does not
|
|
578
|
+
name is removed like any other holder.
|
|
579
|
+
- A failure is `STORE_FAILED`, as for `grant()`.
|
|
580
|
+
- It reads every holder of the relation, so a relation store must answer them
|
|
581
|
+
all through `findEntities` and `findSubjectSets` and never cap.
|
|
582
|
+
|
|
583
|
+
**Two concurrent calls on the same object and relation are not serialised.**
|
|
584
|
+
Each reads, then writes its own diff, so the result can hold the union of both
|
|
585
|
+
adds. A caller that needs one winner serialises them itself, with a lock or a
|
|
586
|
+
queue of its own.
|
|
587
|
+
|
|
588
|
+
### `holders`
|
|
589
|
+
|
|
590
|
+
```ts
|
|
591
|
+
holders(object, relation, { first?, after?, search?, matches?, matchesMany?, scanLimit? }): Promise<CursorPage<Entity>>;
|
|
592
|
+
```
|
|
593
|
+
|
|
594
|
+
The single entities holding `relation` on `object`, ordered by type then id,
|
|
595
|
+
by pages: the reverse of `grant`, for a screen that lists who holds a role.
|
|
596
|
+
Subject sets are not listed.
|
|
597
|
+
|
|
598
|
+
```ts
|
|
599
|
+
const platform = { type: 'platform', id: 'main' };
|
|
600
|
+
|
|
601
|
+
const page = await access.holders(platform, 'admins', { first: 20, search: 'ada' });
|
|
602
|
+
// page.items: [{ type: 'user', id: 'u1' }, ...]; page.nextCursor is null on the last page
|
|
603
|
+
const next = await access.holders(platform, 'admins', { first: 20, search: 'ada', after: page.nextCursor });
|
|
604
|
+
```
|
|
605
|
+
|
|
606
|
+
- `first` is between 1 and 100, 20 when absent; `after` is the `nextCursor` of
|
|
607
|
+
the previous page. A cursor the store did not mint is `InvalidCursorError`.
|
|
608
|
+
- `search` keeps the holders whose **id** contains the text, ignoring case
|
|
609
|
+
(ASCII on PostgreSQL); `%`, `_` and `.` match themselves. The relation store
|
|
610
|
+
holds ids only, so a match on the holder's email or name is `matches`, a
|
|
611
|
+
predicate over each holder (it may be async) that you answer from your user
|
|
612
|
+
store: `matches: async (h) => (await users.find(h.id))?.email.includes(text)`.
|
|
613
|
+
Paging stays right, and a selective predicate costs more reads.
|
|
614
|
+
- `matchesMany(holders)` is `matches` for a batch: it receives up to 100
|
|
615
|
+
holders in order and answers one boolean per holder, in the same order, so
|
|
616
|
+
the page's users are read in one query:
|
|
617
|
+
`matchesMany: async (hs) => { const found = await users.findMany(hs.map((h) => h.id)); return hs.map((h) => found.some((u) => u.id === h.id && u.email.includes(text))); }`.
|
|
618
|
+
Pass `matches` or `matchesMany`, never both.
|
|
619
|
+
- `scanLimit` bounds the cost of a call that has a predicate: it looks at most
|
|
620
|
+
that many holders (a positive integer or `Infinity`; 500 when absent). When
|
|
621
|
+
the limit is spent before `first` holders are kept, the call answers the
|
|
622
|
+
holders kept so far, possibly none, with a `nextCursor` to resume from. **A
|
|
623
|
+
page may therefore hold fewer than `first` and still not be the last: only a
|
|
624
|
+
`null` `nextCursor` ends the list.** Loop on `nextCursor` until it is null:
|
|
625
|
+
|
|
626
|
+
```ts
|
|
627
|
+
let after: string | null = null;
|
|
628
|
+
do {
|
|
629
|
+
const page = await access.holders(platform, 'admins', { first: 20, matchesMany, scanLimit: 200, after });
|
|
630
|
+
show(page.items);
|
|
631
|
+
after = page.nextCursor;
|
|
632
|
+
} while (after !== null);
|
|
633
|
+
```
|
|
634
|
+
- A store with `findHolders` pages in the database. One without it still
|
|
635
|
+
works: the core pages `findEntities` in memory, which is fine for a handful
|
|
636
|
+
of holders and does not scale for thousands.
|
|
637
|
+
- A failure is `STORE_FAILED`, as for `list()`.
|
|
638
|
+
|
|
639
|
+
### Deleting
|
|
640
|
+
|
|
641
|
+
Wire the relation store into `janus({ relations })`, as the clinic does, and
|
|
642
|
+
deleting a user deletes every tuple naming them. Deleting an object's tuples
|
|
643
|
+
is yours, from your own code, when you delete the object:
|
|
644
|
+
|
|
645
|
+
```ts
|
|
646
|
+
await auth.staff.delete(grace); // grace, her sessions, and every tuple naming her
|
|
647
|
+
await relations.deleteEntity({ type: 'record', id: 'r1' }); // answers how many tuples it removed
|
|
648
|
+
```
|
|
649
|
+
|
|
650
|
+
## A route guard
|
|
651
|
+
|
|
652
|
+
```ts
|
|
653
|
+
import { PermissionDepthError, StoreFailure } from '@softistx/janus';
|
|
654
|
+
|
|
655
|
+
export async function getRecord(request: Request, id: string): Promise<Response> {
|
|
656
|
+
try {
|
|
657
|
+
const current = await auth.authenticate(request, { type: 'staff' });
|
|
658
|
+
const record = await loadRecord(id);
|
|
659
|
+
if (record === null) return new Response(null, { status: 404 });
|
|
660
|
+
|
|
661
|
+
const allowed = await access.can(current?.user ?? null, 'view', { type: 'record', ...record });
|
|
662
|
+
if (!allowed) return new Response(null, { status: current ? 403 : 401 });
|
|
663
|
+
return Response.json(record);
|
|
664
|
+
} catch (error) {
|
|
665
|
+
if (error instanceof StoreFailure) return new Response(null, { status: 503 });
|
|
666
|
+
if (error instanceof PermissionDepthError) return new Response(null, { status: 500 });
|
|
667
|
+
throw error;
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
```
|
|
671
|
+
|
|
672
|
+
Load the record first: `can()` needs its `doctorId` and `patientId`. An
|
|
673
|
+
anonymous caller is `null`, which `can()` answers `false` without a store call
|
|
674
|
+
— a `401` here, a `403` for a signed-in one.
|
|
675
|
+
|
|
676
|
+
### A function of your own around `can()`
|
|
677
|
+
|
|
678
|
+
`Can<C>` is `can()`'s signature, and `CheckArgs<C, T, P>` its options
|
|
679
|
+
argument — required exactly when a `when` is reachable, as for `can()`
|
|
680
|
+
itself. A wrapper that spreads them refuses the same mistakes:
|
|
681
|
+
|
|
682
|
+
```ts
|
|
683
|
+
import type {
|
|
684
|
+
CheckableOf, CheckArgs, ModelConfig, ObjectRef, ObjectTypeOf, Permissions, SubjectRef,
|
|
685
|
+
} from '@softistx/janus/permissions';
|
|
686
|
+
|
|
687
|
+
export function audited<C extends ModelConfig, const T extends ObjectTypeOf<C>, const P extends CheckableOf<C, T>>(
|
|
688
|
+
access: Permissions<C>,
|
|
689
|
+
subject: SubjectRef<C> | null,
|
|
690
|
+
permission: P,
|
|
691
|
+
object: ObjectRef<C, T>,
|
|
692
|
+
...options: CheckArgs<C, T, P>
|
|
693
|
+
): Promise<boolean> {
|
|
694
|
+
log.info({ permission, object: object.id });
|
|
695
|
+
return access.can(subject, permission, object, ...options);
|
|
696
|
+
}
|
|
697
|
+
```
|
|
698
|
+
|
|
699
|
+
## Subjects and the notation
|
|
700
|
+
|
|
701
|
+
A user **is** a subject: `subjectOf(user)` from `@softistx/janus` answers its
|
|
702
|
+
`{ type, id }`, and `can` takes the user as it is. Tuples print in Zanzibar's
|
|
703
|
+
notation, typed — `record:r1#teams@team:t1`, `team:t1#members@team:t2#members`
|
|
704
|
+
— see [the shared vocabulary](vocabulary.md#subjects-and-the-tuple-notation).
|
|
705
|
+
|
|
706
|
+
## The relation store
|
|
707
|
+
|
|
708
|
+
`RelationStore` is six methods (and an optional seventh, `findHolders`) answering one-hop questions about stored tuples
|
|
709
|
+
— `write`, `has`, `findSubjectSets`, `findEntities`, `findObjects`,
|
|
710
|
+
`deleteEntity`. The traversal is the core's. `createMemoryRelations()` is the
|
|
711
|
+
reference implementation, and [Writing an adapter](adapters.md) covers the
|
|
712
|
+
rest.
|
|
713
|
+
|
|
714
|
+
## See also
|
|
715
|
+
|
|
716
|
+
- [Users](users.md) — `janus({ relations })`, and user types as subject types
|
|
717
|
+
- [Errors](errors.md) — `STORE_FAILED` and `PERMISSION_DEPTH`
|
|
718
|
+
- [Writing an adapter](adapters.md) — `RelationStore` and its conformance suite
|
|
719
|
+
- [Troubleshooting](../troubleshooting.md#definemodel-) — every `defineModel` message
|