@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,924 @@
|
|
|
1
|
+
import {
|
|
2
|
+
guardRelations,
|
|
3
|
+
isStorable,
|
|
4
|
+
UNSTORABLE
|
|
5
|
+
} from "../chunks/index-n8jxmxeg.js";
|
|
6
|
+
import {
|
|
7
|
+
PermissionDepthError2,
|
|
8
|
+
MAX_PAGE_SIZE2,
|
|
9
|
+
pageLimit2,
|
|
10
|
+
invalidCursor2,
|
|
11
|
+
isSubjectSet2,
|
|
12
|
+
isSetOf2,
|
|
13
|
+
formatEntity2
|
|
14
|
+
} from "../chunks/index-2ttdcz7n.js";
|
|
15
|
+
import {
|
|
16
|
+
holderCursor2,
|
|
17
|
+
readHolderCursor2,
|
|
18
|
+
idMatches2,
|
|
19
|
+
pageOfHolders2,
|
|
20
|
+
createMemoryRelations2
|
|
21
|
+
} from "../chunks/index-ftz0ne6j.js";
|
|
22
|
+
|
|
23
|
+
// src/permissions/resolve/resolved.ts
|
|
24
|
+
function admits(holders, subject) {
|
|
25
|
+
return holders.some((holder) => holder.kind === "type" ? !("relation" in subject) && holder.type === subject.type : ("relation" in subject) && holder.type === subject.type && holder.relation === subject.relation);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// src/permissions/input.ts
|
|
29
|
+
var RESERVED = /[@#()]/;
|
|
30
|
+
var isRecord = (value) => typeof value === "object" && value !== null;
|
|
31
|
+
function idOf(value, what, where) {
|
|
32
|
+
if (typeof value !== "string" || value === "" || RESERVED.test(value)) {
|
|
33
|
+
throw new TypeError(`${where}: ${what} must be a non-empty string without @, # or parentheses`);
|
|
34
|
+
}
|
|
35
|
+
return value;
|
|
36
|
+
}
|
|
37
|
+
function typeOf(model, name, where) {
|
|
38
|
+
const type = model.types.get(name);
|
|
39
|
+
if (type === undefined) {
|
|
40
|
+
throw new TypeError(`${where}: "${name}" is not an object type of the model`);
|
|
41
|
+
}
|
|
42
|
+
return type;
|
|
43
|
+
}
|
|
44
|
+
function objectOf(model, value, where) {
|
|
45
|
+
if (!isRecord(value) || typeof value["type"] !== "string") {
|
|
46
|
+
throw new TypeError(`${where}: the object must be { type, id, …its fields }`);
|
|
47
|
+
}
|
|
48
|
+
typeOf(model, value["type"], where);
|
|
49
|
+
return {
|
|
50
|
+
type: value["type"],
|
|
51
|
+
id: idOf(value["id"], "the object id", where),
|
|
52
|
+
data: value
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function subjectOf(model, value, where) {
|
|
56
|
+
if (!isRecord(value) || typeof value["type"] !== "string") {
|
|
57
|
+
throw new TypeError(`${where}: the subject must be a user, or { type, id }`);
|
|
58
|
+
}
|
|
59
|
+
const id = idOf(value["id"], "the subject id", where);
|
|
60
|
+
const isUserType = model.subjects.has(value["type"]);
|
|
61
|
+
const isSet = isSetOf2(value);
|
|
62
|
+
if (isUserType && !isSet)
|
|
63
|
+
return { type: value["type"], id };
|
|
64
|
+
if (isUserType && isSet && !model.types.has(value.type)) {
|
|
65
|
+
throw new TypeError(`${where}: ${value.type} is a user type the model does not declare as an object type, so ${value.type}#${String(value.relation)} is no subject set`);
|
|
66
|
+
}
|
|
67
|
+
const type = typeOf(model, value["type"], where);
|
|
68
|
+
if (typeof value["relation"] !== "string")
|
|
69
|
+
return { type: type.name, id };
|
|
70
|
+
if (!type.relations.has(value["relation"])) {
|
|
71
|
+
throw new TypeError(`${where}: "${value["relation"]}" is not a relation of ${type.name}, so ${type.name}#${value["relation"]} is no subject set`);
|
|
72
|
+
}
|
|
73
|
+
return { type: type.name, id, relation: value["relation"] };
|
|
74
|
+
}
|
|
75
|
+
function targetOf(model, object, relation, where) {
|
|
76
|
+
const target = objectOf(model, object, where);
|
|
77
|
+
const type = typeOf(model, target.type, where);
|
|
78
|
+
const def = type.relations.get(relation);
|
|
79
|
+
if (def === undefined) {
|
|
80
|
+
throw new TypeError(`${where}: "${relation}" is not a relation of ${type.name}`);
|
|
81
|
+
}
|
|
82
|
+
if (def.kind === "fromField") {
|
|
83
|
+
throw new TypeError(`${where}: ${type.name}.${relation} is read from ${def.field}; there is nothing to store — change the ${type.name} instead`);
|
|
84
|
+
}
|
|
85
|
+
if (!isStorable(target.id)) {
|
|
86
|
+
throw new TypeError(`${where}: the object id ${UNSTORABLE}`);
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
entity: { type: target.type, id: target.id },
|
|
90
|
+
type,
|
|
91
|
+
holders: def.holders
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
function tupleOf(model, object, relation, subject, where) {
|
|
95
|
+
const target = targetOf(model, object, relation, where);
|
|
96
|
+
const who = subjectOf(model, subject, where);
|
|
97
|
+
if (!isStorable(who.id)) {
|
|
98
|
+
throw new TypeError(`${where}: the subject id ${UNSTORABLE}`);
|
|
99
|
+
}
|
|
100
|
+
if (!admits(target.holders, who)) {
|
|
101
|
+
throw new TypeError(`${where}: ${target.type.name}.${relation} is not held by ${"relation" in who ? `${who.type}#${who.relation}` : who.type}`);
|
|
102
|
+
}
|
|
103
|
+
return { object: target.entity, relation, subject: who };
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// src/permissions/walk.ts
|
|
107
|
+
class Walk {
|
|
108
|
+
model;
|
|
109
|
+
store;
|
|
110
|
+
maxDepth;
|
|
111
|
+
ctx;
|
|
112
|
+
question;
|
|
113
|
+
path = new Set;
|
|
114
|
+
constructor(model, store, maxDepth, ctx, question) {
|
|
115
|
+
this.model = model;
|
|
116
|
+
this.store = store;
|
|
117
|
+
this.maxDepth = maxDepth;
|
|
118
|
+
this.ctx = ctx;
|
|
119
|
+
this.question = question;
|
|
120
|
+
}
|
|
121
|
+
async holds(subject, node, name, depth) {
|
|
122
|
+
if (depth > this.maxDepth) {
|
|
123
|
+
throw new PermissionDepthError2(`can: checking ${this.question} crossed more than ${this.maxDepth} relations without an answer`, { permission: this.question, maxDepth: this.maxDepth });
|
|
124
|
+
}
|
|
125
|
+
const key = `${formatEntity2(node.entity)}#${name}`;
|
|
126
|
+
if (this.path.has(key))
|
|
127
|
+
return false;
|
|
128
|
+
const type = this.model.types.get(node.entity.type);
|
|
129
|
+
if (type === undefined)
|
|
130
|
+
return false;
|
|
131
|
+
this.path.add(key);
|
|
132
|
+
try {
|
|
133
|
+
return type.permissions.has(name) ? await this.permission(subject, type, node, name, depth) : await this.relation(subject, type, node, name, depth);
|
|
134
|
+
} finally {
|
|
135
|
+
this.path.delete(key);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
async relation(subject, type, node, name, depth) {
|
|
139
|
+
const relation = type.relations.get(name);
|
|
140
|
+
if (relation === undefined)
|
|
141
|
+
return false;
|
|
142
|
+
if (relation.kind === "fromField") {
|
|
143
|
+
const id = fieldOf(node, relation.field, `${type.name}.${name}`);
|
|
144
|
+
return id !== null && !("relation" in subject) && subject.type === relation.subject && subject.id === id;
|
|
145
|
+
}
|
|
146
|
+
if (admits(relation.holders, subject) && await this.store.has({ object: node.entity, relation: name, subject })) {
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
for (const set of await this.store.findSubjectSets(node.entity, name)) {
|
|
150
|
+
if (!admits(relation.holders, set))
|
|
151
|
+
continue;
|
|
152
|
+
const through = { entity: { type: set.type, id: set.id }, data: null };
|
|
153
|
+
if (await this.holds(subject, through, set.relation, depth + 1)) {
|
|
154
|
+
return true;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
async permission(subject, type, node, name, depth) {
|
|
160
|
+
for (const rule of type.permissions.get(name) ?? []) {
|
|
161
|
+
if (rule.test !== undefined && !this.passes(rule, type, name))
|
|
162
|
+
continue;
|
|
163
|
+
if (rule.kind === "name") {
|
|
164
|
+
if (await this.holds(subject, node, rule.name, depth))
|
|
165
|
+
return true;
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
for (const target of await this.targets(type, node, rule.relation)) {
|
|
169
|
+
if (await this.holds(subject, target, rule.target, depth + 1)) {
|
|
170
|
+
return true;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
176
|
+
passes(rule, type, name) {
|
|
177
|
+
if (this.ctx === undefined) {
|
|
178
|
+
throw new TypeError(`can: ${type.name}.${name} reaches a condition, and no ctx was passed — pass { ctx }`);
|
|
179
|
+
}
|
|
180
|
+
return rule.test(this.ctx) === true;
|
|
181
|
+
}
|
|
182
|
+
async targets(type, node, relation) {
|
|
183
|
+
const through = type.relations.get(relation);
|
|
184
|
+
if (through === undefined)
|
|
185
|
+
return [];
|
|
186
|
+
if (through.kind === "fromField") {
|
|
187
|
+
const id = fieldOf(node, through.field, `${type.name}.${relation}`);
|
|
188
|
+
return id === null ? [] : [{ entity: { type: through.subject, id }, data: null }];
|
|
189
|
+
}
|
|
190
|
+
return (await this.store.findEntities(node.entity, relation)).filter((entity) => admits(through.holders, entity)).map((entity) => ({
|
|
191
|
+
entity: { type: entity.type, id: entity.id },
|
|
192
|
+
data: null
|
|
193
|
+
}));
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
function fieldOf(node, field, what) {
|
|
197
|
+
if (node.data === null) {
|
|
198
|
+
throw new TypeError(`can: ${what} reads ${field} from an object nobody passed`);
|
|
199
|
+
}
|
|
200
|
+
const value = node.data[field];
|
|
201
|
+
if (value === null)
|
|
202
|
+
return null;
|
|
203
|
+
if (typeof value !== "string") {
|
|
204
|
+
throw new TypeError(`can: ${what} reads ${field}, which the object ${value === undefined ? "does not carry — pass the loaded object, spread" : "holds as something other than a string id"}`);
|
|
205
|
+
}
|
|
206
|
+
return isStorable(value) ? value : null;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// src/permissions/can.ts
|
|
210
|
+
async function can({ model, store, maxDepth }, subject, permission, object, options) {
|
|
211
|
+
if (subject === null || subject === undefined)
|
|
212
|
+
return false;
|
|
213
|
+
const root = objectOf(model, object, "can");
|
|
214
|
+
const type = typeOf(model, root.type, "can");
|
|
215
|
+
if (!type.relations.has(permission) && !type.permissions.has(permission)) {
|
|
216
|
+
throw new TypeError(`can: "${permission}" is not a relation or a permission of ${type.name}`);
|
|
217
|
+
}
|
|
218
|
+
const who = subjectOf(model, subject, "can");
|
|
219
|
+
if (!isStorable(root.id) || !isStorable(who.id))
|
|
220
|
+
return false;
|
|
221
|
+
return new Walk(model, store, maxDepth, options?.ctx, `${type.name}#${permission}`).holds(who, { entity: { type: root.type, id: root.id }, data: root.data }, permission, 0);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// src/permissions/holders.ts
|
|
225
|
+
var DEFAULT_SCAN_LIMIT = 500;
|
|
226
|
+
async function holders(model, store, object, relation, options) {
|
|
227
|
+
const where = "holders";
|
|
228
|
+
const limit = pageLimit2(options?.first, where);
|
|
229
|
+
const after = options?.after ?? null;
|
|
230
|
+
if (after !== null && typeof after !== "string") {
|
|
231
|
+
throw new TypeError(`${where}: after must be the nextCursor of a page, or null`);
|
|
232
|
+
}
|
|
233
|
+
const text = options?.search;
|
|
234
|
+
if (text !== undefined && typeof text !== "string") {
|
|
235
|
+
throw new TypeError(`${where}: search must be a string, or absent`);
|
|
236
|
+
}
|
|
237
|
+
const predicate = checkedPredicate(where, options);
|
|
238
|
+
const { entity } = targetOf(model, object, relation, where);
|
|
239
|
+
const search = text === undefined || text === "" ? null : text;
|
|
240
|
+
if (search !== null && !isStorable(search)) {
|
|
241
|
+
return { items: [], nextCursor: null };
|
|
242
|
+
}
|
|
243
|
+
if (after !== null && !isStorable(after))
|
|
244
|
+
throw invalidCursor2(where, after);
|
|
245
|
+
const read = async (cursor, size) => {
|
|
246
|
+
if (store.findHolders !== undefined) {
|
|
247
|
+
return store.findHolders({
|
|
248
|
+
object: entity,
|
|
249
|
+
relation,
|
|
250
|
+
after: cursor,
|
|
251
|
+
limit: size,
|
|
252
|
+
search
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
const all = await store.findEntities(entity, relation);
|
|
256
|
+
return pageOfHolders2(all, { after: cursor, limit: size, search }, where);
|
|
257
|
+
};
|
|
258
|
+
if (predicate === null)
|
|
259
|
+
return read(after, limit);
|
|
260
|
+
return scanHolders(read, after, limit, predicate);
|
|
261
|
+
}
|
|
262
|
+
function checkedPredicate(where, options) {
|
|
263
|
+
const matches = options?.matches;
|
|
264
|
+
if (matches !== undefined && typeof matches !== "function") {
|
|
265
|
+
throw new TypeError(`${where}: matches must be a function, or absent`);
|
|
266
|
+
}
|
|
267
|
+
const matchesMany = options?.matchesMany;
|
|
268
|
+
if (matchesMany !== undefined && typeof matchesMany !== "function") {
|
|
269
|
+
throw new TypeError(`${where}: matchesMany must be a function, or absent`);
|
|
270
|
+
}
|
|
271
|
+
if (matches !== undefined && matchesMany !== undefined) {
|
|
272
|
+
throw new TypeError(`${where}: matches and matchesMany are exclusive, pass one`);
|
|
273
|
+
}
|
|
274
|
+
const scanLimit = options?.scanLimit ?? DEFAULT_SCAN_LIMIT;
|
|
275
|
+
if (scanLimit !== Number.POSITIVE_INFINITY && (!Number.isSafeInteger(scanLimit) || scanLimit < 1)) {
|
|
276
|
+
throw new TypeError(`${where}: scanLimit must be a positive integer, or Infinity`);
|
|
277
|
+
}
|
|
278
|
+
if (matchesMany !== undefined) {
|
|
279
|
+
return {
|
|
280
|
+
scanLimit,
|
|
281
|
+
step: MAX_PAGE_SIZE2,
|
|
282
|
+
judge: async (batch) => {
|
|
283
|
+
const answers = await matchesMany(batch);
|
|
284
|
+
if (!Array.isArray(answers) || answers.length !== batch.length) {
|
|
285
|
+
throw new TypeError(`${where}: matchesMany must answer one boolean per holder, in order`);
|
|
286
|
+
}
|
|
287
|
+
return answers.map(Boolean);
|
|
288
|
+
}
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
if (matches === undefined)
|
|
292
|
+
return null;
|
|
293
|
+
return {
|
|
294
|
+
scanLimit,
|
|
295
|
+
step: 1,
|
|
296
|
+
judge: async (batch) => [Boolean(await matches(batch[0]))]
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
async function scanHolders(read, after, limit, { judge, step, scanLimit }) {
|
|
300
|
+
const kept = [];
|
|
301
|
+
let cursor = after;
|
|
302
|
+
let scanned = 0;
|
|
303
|
+
for (;; ) {
|
|
304
|
+
const page = await read(cursor, MAX_PAGE_SIZE2);
|
|
305
|
+
const room = Math.max(scanLimit - scanned, 0);
|
|
306
|
+
const visible = page.items.slice(0, room);
|
|
307
|
+
for (let at = 0;at < visible.length; at += step) {
|
|
308
|
+
const batch = visible.slice(at, at + step);
|
|
309
|
+
const answers = await judge(batch);
|
|
310
|
+
scanned += batch.length;
|
|
311
|
+
for (const [i, holder] of batch.entries()) {
|
|
312
|
+
if (answers[i])
|
|
313
|
+
kept.push(holder);
|
|
314
|
+
if (kept.length > limit) {
|
|
315
|
+
const items = kept.slice(0, limit);
|
|
316
|
+
return {
|
|
317
|
+
items,
|
|
318
|
+
nextCursor: holderCursor2(items[limit - 1])
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
if (visible.length < page.items.length) {
|
|
324
|
+
return {
|
|
325
|
+
items: kept,
|
|
326
|
+
nextCursor: holderCursor2(visible[visible.length - 1])
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
if (page.nextCursor === null)
|
|
330
|
+
return { items: kept, nextCursor: null };
|
|
331
|
+
if (scanned >= scanLimit)
|
|
332
|
+
return { items: kept, nextCursor: page.nextCursor };
|
|
333
|
+
cursor = page.nextCursor;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
// src/permissions/reverse.ts
|
|
338
|
+
class Reverse {
|
|
339
|
+
model;
|
|
340
|
+
store;
|
|
341
|
+
maxDepth;
|
|
342
|
+
ctx;
|
|
343
|
+
subject;
|
|
344
|
+
question;
|
|
345
|
+
previous = new Map;
|
|
346
|
+
current = new Map;
|
|
347
|
+
path = new Set;
|
|
348
|
+
looped = false;
|
|
349
|
+
constructor(model, store, maxDepth, ctx, subject, question) {
|
|
350
|
+
this.model = model;
|
|
351
|
+
this.store = store;
|
|
352
|
+
this.maxDepth = maxDepth;
|
|
353
|
+
this.ctx = ctx;
|
|
354
|
+
this.subject = subject;
|
|
355
|
+
this.question = question;
|
|
356
|
+
}
|
|
357
|
+
async objects(type, name) {
|
|
358
|
+
for (let round = 0;round <= this.maxDepth; round += 1) {
|
|
359
|
+
this.current = new Map;
|
|
360
|
+
this.looped = false;
|
|
361
|
+
const found = await this.reach(type, name);
|
|
362
|
+
if (!this.looped || this.same())
|
|
363
|
+
return found;
|
|
364
|
+
this.previous = this.current;
|
|
365
|
+
}
|
|
366
|
+
throw new PermissionDepthError2(`list: listing ${this.question} crossed more than ${this.maxDepth} relations without an answer`, { permission: this.question, maxDepth: this.maxDepth });
|
|
367
|
+
}
|
|
368
|
+
same() {
|
|
369
|
+
for (const [key, ids] of this.current) {
|
|
370
|
+
if ((this.previous.get(key)?.size ?? 0) !== ids.size)
|
|
371
|
+
return false;
|
|
372
|
+
}
|
|
373
|
+
return true;
|
|
374
|
+
}
|
|
375
|
+
async reach(typeName, name) {
|
|
376
|
+
const key = `${typeName}#${name}`;
|
|
377
|
+
const done = this.current.get(key);
|
|
378
|
+
if (done !== undefined)
|
|
379
|
+
return done;
|
|
380
|
+
if (this.path.has(key)) {
|
|
381
|
+
this.looped = true;
|
|
382
|
+
return this.previous.get(key) ?? new Set;
|
|
383
|
+
}
|
|
384
|
+
const type = this.model.types.get(typeName);
|
|
385
|
+
if (type === undefined)
|
|
386
|
+
return new Set;
|
|
387
|
+
this.path.add(key);
|
|
388
|
+
try {
|
|
389
|
+
const found = type.permissions.has(name) ? await this.permission(type, name) : await this.relation(type, name);
|
|
390
|
+
this.current.set(key, found);
|
|
391
|
+
return found;
|
|
392
|
+
} finally {
|
|
393
|
+
this.path.delete(key);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
async relation(type, name) {
|
|
397
|
+
const relation = type.relations.get(name);
|
|
398
|
+
if (relation === undefined)
|
|
399
|
+
return new Set;
|
|
400
|
+
if (relation.kind === "fromField") {
|
|
401
|
+
const subject = this.subject;
|
|
402
|
+
return "relation" in subject || subject.type !== relation.subject ? new Set : new Set(await this.lookup(type, name, subject.id));
|
|
403
|
+
}
|
|
404
|
+
const found = new Set(admits(relation.holders, this.subject) ? await this.holding(type.name, name, this.subject) : []);
|
|
405
|
+
for (const holder of relation.holders) {
|
|
406
|
+
if (holder.kind !== "set")
|
|
407
|
+
continue;
|
|
408
|
+
for (const id of await this.reach(holder.type, holder.relation)) {
|
|
409
|
+
const set = { type: holder.type, id, relation: holder.relation };
|
|
410
|
+
for (const object of await this.holding(type.name, name, set)) {
|
|
411
|
+
found.add(object);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
return found;
|
|
416
|
+
}
|
|
417
|
+
async permission(type, name) {
|
|
418
|
+
const found = new Set;
|
|
419
|
+
for (const rule of type.permissions.get(name) ?? []) {
|
|
420
|
+
if (rule.test !== undefined && !this.passes(rule, type, name))
|
|
421
|
+
continue;
|
|
422
|
+
if (rule.kind === "name") {
|
|
423
|
+
for (const id of await this.reach(type.name, rule.name))
|
|
424
|
+
found.add(id);
|
|
425
|
+
continue;
|
|
426
|
+
}
|
|
427
|
+
for (const id of await this.arrow(type, rule.relation, rule.target)) {
|
|
428
|
+
found.add(id);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
return found;
|
|
432
|
+
}
|
|
433
|
+
async arrow(type, relation, target) {
|
|
434
|
+
const through = type.relations.get(relation);
|
|
435
|
+
const found = new Set;
|
|
436
|
+
if (through === undefined)
|
|
437
|
+
return found;
|
|
438
|
+
if (through.kind === "fromField") {
|
|
439
|
+
for (const id of await this.reach(through.subject, target)) {
|
|
440
|
+
for (const object of await this.lookup(type, relation, id)) {
|
|
441
|
+
found.add(object);
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
return found;
|
|
445
|
+
}
|
|
446
|
+
for (const holder of through.holders) {
|
|
447
|
+
if (holder.kind !== "type" || !this.model.types.has(holder.type)) {
|
|
448
|
+
continue;
|
|
449
|
+
}
|
|
450
|
+
for (const id of await this.reach(holder.type, target)) {
|
|
451
|
+
const entity = { type: holder.type, id };
|
|
452
|
+
for (const object of await this.holding(type.name, relation, entity)) {
|
|
453
|
+
found.add(object);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
return found;
|
|
458
|
+
}
|
|
459
|
+
async holding(type, relation, subject) {
|
|
460
|
+
const ids = [];
|
|
461
|
+
let after = null;
|
|
462
|
+
do {
|
|
463
|
+
const page = await this.store.findObjects({
|
|
464
|
+
type,
|
|
465
|
+
relation,
|
|
466
|
+
subject,
|
|
467
|
+
after,
|
|
468
|
+
limit: MAX_PAGE_SIZE2
|
|
469
|
+
});
|
|
470
|
+
ids.push(...page.items);
|
|
471
|
+
after = page.nextCursor;
|
|
472
|
+
} while (after !== null);
|
|
473
|
+
return ids;
|
|
474
|
+
}
|
|
475
|
+
async lookup(type, relation, id) {
|
|
476
|
+
const def = type.relations.get(relation);
|
|
477
|
+
if (def?.kind !== "fromField" || def.lookup === undefined) {
|
|
478
|
+
const field = def?.kind === "fromField" ? def.field : relation;
|
|
479
|
+
const subject = def?.kind === "fromField" ? def.subject : "subject";
|
|
480
|
+
throw new TypeError(`list: ${type.name}.${relation} is read from a field, and has no lookup to find the ${type.name}s naming a subject of type '${subject}' — fromField('${field}', '${subject}', { lookup })`);
|
|
481
|
+
}
|
|
482
|
+
const ids = await def.lookup(id);
|
|
483
|
+
if (!Array.isArray(ids) || ids.some((each) => typeof each !== "string")) {
|
|
484
|
+
throw new TypeError(`list: the lookup of ${type.name}.${relation} must answer an array of ids`);
|
|
485
|
+
}
|
|
486
|
+
return ids.filter(isStorable);
|
|
487
|
+
}
|
|
488
|
+
passes(rule, type, name) {
|
|
489
|
+
if (this.ctx === undefined) {
|
|
490
|
+
throw new TypeError(`list: ${type.name}.${name} reaches a condition, and no ctx was passed — pass { ctx }`);
|
|
491
|
+
}
|
|
492
|
+
return rule.test(this.ctx) === true;
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
// src/permissions/list.ts
|
|
497
|
+
async function list({ model, store, maxDepth }, subject, permission, typeName, options) {
|
|
498
|
+
const limit = pageLimit2(options?.limit, "list");
|
|
499
|
+
const after = options?.after ?? null;
|
|
500
|
+
if (after !== null && typeof after !== "string") {
|
|
501
|
+
throw new TypeError("list: after must be the nextCursor of a page, or null");
|
|
502
|
+
}
|
|
503
|
+
if (subject === null || subject === undefined) {
|
|
504
|
+
return { items: [], nextCursor: null };
|
|
505
|
+
}
|
|
506
|
+
if (typeof typeName !== "string") {
|
|
507
|
+
throw new TypeError("list: the type must be an object type of the model");
|
|
508
|
+
}
|
|
509
|
+
const type = typeOf(model, typeName, "list");
|
|
510
|
+
if (!type.relations.has(permission) && !type.permissions.has(permission)) {
|
|
511
|
+
throw new TypeError(`list: "${permission}" is not a relation or a permission of ${type.name}`);
|
|
512
|
+
}
|
|
513
|
+
const who = subjectOf(model, subject, "list");
|
|
514
|
+
if (!isStorable(who.id))
|
|
515
|
+
return { items: [], nextCursor: null };
|
|
516
|
+
const ids = await new Reverse(model, store, maxDepth, options?.ctx, who, `${type.name}#${permission}`).objects(type.name, permission);
|
|
517
|
+
return pageOf(ids, after, limit);
|
|
518
|
+
}
|
|
519
|
+
function pageOf(ids, after, limit) {
|
|
520
|
+
const rest = [...ids].sort().filter((id) => after === null || id > after);
|
|
521
|
+
const items = rest.slice(0, limit);
|
|
522
|
+
const last = items.at(-1);
|
|
523
|
+
return {
|
|
524
|
+
items,
|
|
525
|
+
nextCursor: rest.length > limit && last !== undefined ? last : null
|
|
526
|
+
};
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
// src/permissions/resolve/step.ts
|
|
530
|
+
var isRecord2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
531
|
+
|
|
532
|
+
// src/permissions/resolve/declared-names.ts
|
|
533
|
+
var NAME = /^[a-z][A-Za-z0-9]*$/;
|
|
534
|
+
var RENAMED = {
|
|
535
|
+
relations: "related",
|
|
536
|
+
permissions: "permits"
|
|
537
|
+
};
|
|
538
|
+
function subjectTypesOf(value, refuse) {
|
|
539
|
+
if (!Array.isArray(value)) {
|
|
540
|
+
throw refuse("subjects must be an array of subject type names — auth.types from janus(), or your own");
|
|
541
|
+
}
|
|
542
|
+
for (const subject of value) {
|
|
543
|
+
if (typeof subject !== "string" || !NAME.test(subject)) {
|
|
544
|
+
throw refuse(`the subject type "${String(subject)}" must be a camelCase name`);
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
return new Set(value);
|
|
548
|
+
}
|
|
549
|
+
function objectTypeNamesOf(value, refuse) {
|
|
550
|
+
if (!isRecord2(value) || Object.keys(value).length === 0) {
|
|
551
|
+
throw refuse("types declares no object type");
|
|
552
|
+
}
|
|
553
|
+
const typeNames = new Set(Object.keys(value));
|
|
554
|
+
for (const name of typeNames) {
|
|
555
|
+
if (!NAME.test(name)) {
|
|
556
|
+
throw refuse(`the object type "${name}" must be a camelCase name — letters and digits, starting with a lowercase letter`);
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
return typeNames;
|
|
560
|
+
}
|
|
561
|
+
function collectNames(types, refuse) {
|
|
562
|
+
const relationNames = new Map;
|
|
563
|
+
const permissionNames = new Map;
|
|
564
|
+
for (const [name, def] of Object.entries(types)) {
|
|
565
|
+
const at = `types.${name}`;
|
|
566
|
+
if (!isRecord2(def))
|
|
567
|
+
throw refuse(`${at} must be an object`);
|
|
568
|
+
for (const key of Object.keys(def)) {
|
|
569
|
+
if (key === "related" || key === "permits")
|
|
570
|
+
continue;
|
|
571
|
+
throw refuse(Object.hasOwn(RENAMED, key) ? `${at}.${key} is now ${RENAMED[key]}: rename the key` : `${at}.${key} is not a key of an object type: related or permits`);
|
|
572
|
+
}
|
|
573
|
+
const relations = namesIn(def["related"], `${at}.related`, refuse);
|
|
574
|
+
const permissions = namesIn(def["permits"], `${at}.permits`, refuse);
|
|
575
|
+
for (const permission of permissions) {
|
|
576
|
+
if (relations.has(permission)) {
|
|
577
|
+
throw refuse(`${at}: "${permission}" names a relation and a permission; rename one`);
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
relationNames.set(name, relations);
|
|
581
|
+
permissionNames.set(name, permissions);
|
|
582
|
+
}
|
|
583
|
+
return { relationNames, permissionNames };
|
|
584
|
+
}
|
|
585
|
+
function namesIn(value, at, refuse) {
|
|
586
|
+
if (value === undefined)
|
|
587
|
+
return new Set;
|
|
588
|
+
if (!isRecord2(value))
|
|
589
|
+
throw refuse(`${at} must be an object`);
|
|
590
|
+
for (const name of Object.keys(value)) {
|
|
591
|
+
if (!NAME.test(name)) {
|
|
592
|
+
throw refuse(`${at}: "${name}" must be a camelCase name — letters and digits, starting with a lowercase letter`);
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
return new Set(Object.keys(value));
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
// src/permissions/resolve/refuse-data-beyond-root.ts
|
|
599
|
+
function refuseDataBeyondRoot(types, refuse) {
|
|
600
|
+
const fieldRead = (type, name) => {
|
|
601
|
+
const relation = type.relations.get(name);
|
|
602
|
+
if (relation !== undefined) {
|
|
603
|
+
return relation.kind === "fromField" ? relation.field : null;
|
|
604
|
+
}
|
|
605
|
+
for (const rule of type.permissions.get(name) ?? []) {
|
|
606
|
+
const field = rule.kind === "name" ? fieldRead(type, rule.name) : fieldRead(type, rule.relation);
|
|
607
|
+
if (field !== null)
|
|
608
|
+
return field;
|
|
609
|
+
}
|
|
610
|
+
return null;
|
|
611
|
+
};
|
|
612
|
+
for (const type of types.values()) {
|
|
613
|
+
for (const [relation, def] of type.relations) {
|
|
614
|
+
if (def.kind !== "stored")
|
|
615
|
+
continue;
|
|
616
|
+
for (const holder of def.holders) {
|
|
617
|
+
if (holder.kind !== "set")
|
|
618
|
+
continue;
|
|
619
|
+
const target = types.get(holder.type);
|
|
620
|
+
const field = target === undefined ? null : fieldRead(target, holder.relation);
|
|
621
|
+
if (field !== null) {
|
|
622
|
+
throw refuse(`types.${type.name}.related.${relation}: "${holder.type}#${holder.relation}" reads ${holder.type}.${field}, and a subject set reaches ${holder.type}s nobody passed to can() — store that relation instead of reading it`);
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
for (const [permission, rules] of type.permissions) {
|
|
627
|
+
for (const rule of rules) {
|
|
628
|
+
if (rule.kind !== "arrow")
|
|
629
|
+
continue;
|
|
630
|
+
const through = type.relations.get(rule.relation);
|
|
631
|
+
const targets = through?.kind === "fromField" ? [through.subject] : (through?.holders ?? []).map((holder) => holder.type);
|
|
632
|
+
for (const name of targets) {
|
|
633
|
+
const target = types.get(name);
|
|
634
|
+
const field = target === undefined ? null : fieldRead(target, rule.target);
|
|
635
|
+
if (field !== null) {
|
|
636
|
+
throw refuse(`types.${type.name}.permits.${permission}: "${rule.relation}->${rule.target}" reaches ${name}.${rule.target}, which reads ${name}.${field}, and only the object passed to can() carries its data — store that relation instead of reading it`);
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
// src/permissions/resolve/refuse-loops.ts
|
|
645
|
+
function refuseLoops(types, refuse) {
|
|
646
|
+
for (const type of types.values()) {
|
|
647
|
+
const visiting = [];
|
|
648
|
+
const done = new Set;
|
|
649
|
+
const visit = (permission) => {
|
|
650
|
+
if (done.has(permission))
|
|
651
|
+
return;
|
|
652
|
+
const loop = visiting.indexOf(permission);
|
|
653
|
+
if (loop >= 0) {
|
|
654
|
+
throw refuse(`types.${type.name}.permits: ${[...visiting.slice(loop), permission].join(" → ")} is a loop no relation ends`);
|
|
655
|
+
}
|
|
656
|
+
visiting.push(permission);
|
|
657
|
+
for (const rule of type.permissions.get(permission) ?? []) {
|
|
658
|
+
if (rule.kind === "name" && type.permissions.has(rule.name)) {
|
|
659
|
+
visit(rule.name);
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
visiting.pop();
|
|
663
|
+
done.add(permission);
|
|
664
|
+
};
|
|
665
|
+
for (const permission of type.permissions.keys())
|
|
666
|
+
visit(permission);
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
// src/permissions/resolve/resolve-relation.ts
|
|
671
|
+
var FIELD = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
|
|
672
|
+
function resolveRelation(value, here, {
|
|
673
|
+
refuse,
|
|
674
|
+
isSubjectType,
|
|
675
|
+
relationNames
|
|
676
|
+
}) {
|
|
677
|
+
if (isRecord2(value) && value["kind"] === "fromField") {
|
|
678
|
+
const { field, subject, lookup } = value;
|
|
679
|
+
if (typeof field !== "string" || !FIELD.test(field)) {
|
|
680
|
+
throw refuse(`${here}: fromField must name a top-level field`);
|
|
681
|
+
}
|
|
682
|
+
if (typeof subject !== "string" || !isSubjectType(subject)) {
|
|
683
|
+
throw refuse(`${here}: fromField names "${String(subject)}", which is not a subject type`);
|
|
684
|
+
}
|
|
685
|
+
if (lookup !== undefined && typeof lookup !== "function") {
|
|
686
|
+
throw refuse(`${here}: fromField's lookup must be a function`);
|
|
687
|
+
}
|
|
688
|
+
return lookup === undefined ? { kind: "fromField", field, subject } : {
|
|
689
|
+
kind: "fromField",
|
|
690
|
+
field,
|
|
691
|
+
subject,
|
|
692
|
+
lookup
|
|
693
|
+
};
|
|
694
|
+
}
|
|
695
|
+
if (!Array.isArray(value) || value.length === 0) {
|
|
696
|
+
throw refuse(`${here} must be a non-empty array of subject types, or fromField()`);
|
|
697
|
+
}
|
|
698
|
+
const holders = value.map((holder) => {
|
|
699
|
+
if (typeof holder !== "string") {
|
|
700
|
+
throw refuse(`${here}: a holder must be a string`);
|
|
701
|
+
}
|
|
702
|
+
const hash = holder.indexOf("#");
|
|
703
|
+
if (hash < 0) {
|
|
704
|
+
if (!isSubjectType(holder)) {
|
|
705
|
+
throw refuse(`${here}: "${holder}" is not a subject type`);
|
|
706
|
+
}
|
|
707
|
+
return { kind: "type", type: holder };
|
|
708
|
+
}
|
|
709
|
+
const type = holder.slice(0, hash);
|
|
710
|
+
const relation = holder.slice(hash + 1);
|
|
711
|
+
if (!relationNames.get(type)?.has(relation)) {
|
|
712
|
+
throw refuse(`${here}: "${holder}" is not a subject set — it must name an object type and one of its relations`);
|
|
713
|
+
}
|
|
714
|
+
return { kind: "set", type, relation };
|
|
715
|
+
});
|
|
716
|
+
return { kind: "stored", holders };
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
// src/permissions/resolve/resolve-rule.ts
|
|
720
|
+
function resolveRule(value, here, context) {
|
|
721
|
+
const { refuse } = context;
|
|
722
|
+
if (isRecord2(value) && value["kind"] === "when") {
|
|
723
|
+
if (typeof value["test"] !== "function") {
|
|
724
|
+
throw refuse(`${here}: when() takes a function as its test`);
|
|
725
|
+
}
|
|
726
|
+
const inner = resolveRule(value["rule"], here, context);
|
|
727
|
+
return { ...inner, test: value["test"] };
|
|
728
|
+
}
|
|
729
|
+
if (typeof value !== "string") {
|
|
730
|
+
throw refuse(`${here}: a rule is a name, an arrow, or when()`);
|
|
731
|
+
}
|
|
732
|
+
const arrow = value.indexOf("->");
|
|
733
|
+
if (arrow < 0) {
|
|
734
|
+
if (!context.own.has(value)) {
|
|
735
|
+
throw refuse(`${here}: "${value}" is not a relation or a permission of ${context.self}`);
|
|
736
|
+
}
|
|
737
|
+
return { kind: "name", name: value };
|
|
738
|
+
}
|
|
739
|
+
const relation = value.slice(0, arrow);
|
|
740
|
+
const target = value.slice(arrow + 2);
|
|
741
|
+
const through = context.relations.get(relation);
|
|
742
|
+
if (through === undefined) {
|
|
743
|
+
throw refuse(`${here}: "${value}" goes through "${relation}", which is not a relation of ${context.self}`);
|
|
744
|
+
}
|
|
745
|
+
const targets = through.kind === "fromField" ? [through.subject] : through.holders.map((holder) => holder.kind === "type" ? holder.type : null);
|
|
746
|
+
for (const type of targets) {
|
|
747
|
+
if (type === null || !context.typeNames.has(type)) {
|
|
748
|
+
throw refuse(`${here}: "${value}" goes through "${relation}", which can hold ${type === null ? "a subject set" : `a ${type}`}; an arrow follows object types only`);
|
|
749
|
+
}
|
|
750
|
+
if (!context.namesOf(type).has(target)) {
|
|
751
|
+
throw refuse(`${here}: "${value}" names "${target}", which ${type} does not declare`);
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
return { kind: "arrow", relation, target };
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
// src/permissions/resolve/resolve-model.ts
|
|
758
|
+
function resolveModel(config, where) {
|
|
759
|
+
const refuse = (message) => new TypeError(`${where}: ${message}`);
|
|
760
|
+
if (!isRecord2(config))
|
|
761
|
+
throw refuse("pass { subjects, types }");
|
|
762
|
+
const subjects = subjectTypesOf(config.subjects, refuse);
|
|
763
|
+
const typeNames = objectTypeNamesOf(config.types, refuse);
|
|
764
|
+
const declared = collectNames(config.types, refuse);
|
|
765
|
+
const types = resolveTypes(config.types, {
|
|
766
|
+
refuse,
|
|
767
|
+
subjects,
|
|
768
|
+
typeNames,
|
|
769
|
+
declared
|
|
770
|
+
});
|
|
771
|
+
refuseLoops(types, refuse);
|
|
772
|
+
refuseDataBeyondRoot(types, refuse);
|
|
773
|
+
return { subjects, types };
|
|
774
|
+
}
|
|
775
|
+
function resolveTypes(defs, context) {
|
|
776
|
+
const { refuse, subjects, typeNames } = context;
|
|
777
|
+
const { relationNames, permissionNames } = context.declared;
|
|
778
|
+
const isSubjectType = (type) => subjects.has(type) || typeNames.has(type);
|
|
779
|
+
const namesOf = (type) => new Set([
|
|
780
|
+
...relationNames.get(type) ?? [],
|
|
781
|
+
...permissionNames.get(type) ?? []
|
|
782
|
+
]);
|
|
783
|
+
const types = new Map;
|
|
784
|
+
for (const [name, def] of Object.entries(defs)) {
|
|
785
|
+
const at = `types.${name}`;
|
|
786
|
+
const relations = new Map;
|
|
787
|
+
for (const [relation, holders] of Object.entries(def.related ?? {})) {
|
|
788
|
+
const here = `${at}.related.${relation}`;
|
|
789
|
+
relations.set(relation, resolveRelation(holders, here, {
|
|
790
|
+
refuse,
|
|
791
|
+
isSubjectType,
|
|
792
|
+
relationNames
|
|
793
|
+
}));
|
|
794
|
+
}
|
|
795
|
+
const permissions = new Map;
|
|
796
|
+
for (const [permission, rules] of Object.entries(def.permits ?? {})) {
|
|
797
|
+
const here = `${at}.permits.${permission}`;
|
|
798
|
+
if (!Array.isArray(rules) || rules.length === 0) {
|
|
799
|
+
throw refuse(`${here} must be a non-empty array of rules`);
|
|
800
|
+
}
|
|
801
|
+
permissions.set(permission, rules.map((rule, index) => resolveRule(rule, `${here}[${index}]`, {
|
|
802
|
+
refuse,
|
|
803
|
+
own: namesOf(name),
|
|
804
|
+
relations,
|
|
805
|
+
typeNames,
|
|
806
|
+
namesOf,
|
|
807
|
+
self: name
|
|
808
|
+
})));
|
|
809
|
+
}
|
|
810
|
+
types.set(name, { name, relations, permissions });
|
|
811
|
+
}
|
|
812
|
+
return types;
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
// src/permissions/model/define.ts
|
|
816
|
+
var RESOLVED = new WeakMap;
|
|
817
|
+
function defineModel(config) {
|
|
818
|
+
const resolved = resolveModel(config, "defineModel");
|
|
819
|
+
const model = Object.freeze({
|
|
820
|
+
subjects: [...resolved.subjects],
|
|
821
|
+
types: [...resolved.types.keys()],
|
|
822
|
+
definition: config
|
|
823
|
+
});
|
|
824
|
+
RESOLVED.set(model, resolved);
|
|
825
|
+
return model;
|
|
826
|
+
}
|
|
827
|
+
function resolvedOf(model) {
|
|
828
|
+
const resolved = RESOLVED.get(model);
|
|
829
|
+
if (resolved === undefined) {
|
|
830
|
+
throw new TypeError("permissions: this model was not made by defineModel() — pass what defineModel() answered");
|
|
831
|
+
}
|
|
832
|
+
return resolved;
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
// src/permissions/replace.ts
|
|
836
|
+
var keyOf = (subject) => isSubjectSet2(subject) ? `set\x00${subject.type}\x00${subject.id}\x00${subject.relation}` : `entity\x00${subject.type}\x00${subject.id}`;
|
|
837
|
+
async function replace(model, store, object, relation, subjects) {
|
|
838
|
+
const where = "replace";
|
|
839
|
+
if (!Array.isArray(subjects)) {
|
|
840
|
+
throw new TypeError(`${where}: the subjects must be an array`);
|
|
841
|
+
}
|
|
842
|
+
const { entity } = targetOf(model, object, relation, where);
|
|
843
|
+
const wanted = new Map;
|
|
844
|
+
for (const subject of subjects) {
|
|
845
|
+
const tuple = tupleOf(model, object, relation, subject, where);
|
|
846
|
+
wanted.set(keyOf(tuple.subject), tuple);
|
|
847
|
+
}
|
|
848
|
+
const [entities, sets] = await Promise.all([
|
|
849
|
+
store.findEntities(entity, relation),
|
|
850
|
+
store.findSubjectSets(entity, relation)
|
|
851
|
+
]);
|
|
852
|
+
const held = new Map;
|
|
853
|
+
for (const subject of [...entities, ...sets]) {
|
|
854
|
+
held.set(keyOf(subject), subject);
|
|
855
|
+
}
|
|
856
|
+
const add = [...wanted].filter(([key]) => !held.has(key)).map(([, t]) => t);
|
|
857
|
+
const remove = [...held].filter(([key]) => !wanted.has(key)).map(([, subject]) => ({ object: entity, relation, subject }));
|
|
858
|
+
if (add.length > 0 || remove.length > 0)
|
|
859
|
+
await store.write({ remove, add });
|
|
860
|
+
return { added: add, removed: remove };
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
// src/permissions/engine.ts
|
|
864
|
+
var DEFAULT_MAX_DEPTH = 25;
|
|
865
|
+
var REQUIRED = [
|
|
866
|
+
"write",
|
|
867
|
+
"has",
|
|
868
|
+
"findSubjectSets",
|
|
869
|
+
"findEntities",
|
|
870
|
+
"findObjects",
|
|
871
|
+
"deleteEntity"
|
|
872
|
+
];
|
|
873
|
+
function permissions(options) {
|
|
874
|
+
const where = "permissions";
|
|
875
|
+
const model = resolvedOf(options.model);
|
|
876
|
+
const maxDepth = options.maxDepth ?? DEFAULT_MAX_DEPTH;
|
|
877
|
+
if (!Number.isInteger(maxDepth) || maxDepth < 1) {
|
|
878
|
+
throw new TypeError(`${where}: maxDepth must be a positive integer`);
|
|
879
|
+
}
|
|
880
|
+
const raw = options.store;
|
|
881
|
+
for (const method of REQUIRED) {
|
|
882
|
+
if (typeof raw?.[method] !== "function") {
|
|
883
|
+
throw new TypeError(`${where}: store.${method} is missing`);
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
const store = guardRelations(options.store);
|
|
887
|
+
const bound = { model, store, maxDepth };
|
|
888
|
+
const withBoundModel = (call) => (...rest) => call(bound, ...rest);
|
|
889
|
+
const change = (operation) => async (object, relation, subject) => {
|
|
890
|
+
const tuple = tupleOf(model, object, relation, subject, operation);
|
|
891
|
+
await store.write(operation === "grant" ? { add: [tuple] } : { remove: [tuple] });
|
|
892
|
+
};
|
|
893
|
+
return Object.freeze({
|
|
894
|
+
model: options.model,
|
|
895
|
+
can: withBoundModel(can),
|
|
896
|
+
list: withBoundModel(list),
|
|
897
|
+
grant: change("grant"),
|
|
898
|
+
revoke: change("revoke"),
|
|
899
|
+
holders: (object, relation, page) => holders(model, store, object, relation, page),
|
|
900
|
+
replace: (object, relation, subjects) => replace(model, store, object, relation, subjects)
|
|
901
|
+
});
|
|
902
|
+
}
|
|
903
|
+
// src/permissions/model/from-field.ts
|
|
904
|
+
function fromField(field, subject, options) {
|
|
905
|
+
return Object.freeze(options === undefined ? { kind: "fromField", field, subject } : { kind: "fromField", field, subject, lookup: options.lookup });
|
|
906
|
+
}
|
|
907
|
+
// src/permissions/model/when.ts
|
|
908
|
+
function when(rule, test) {
|
|
909
|
+
return Object.freeze({ kind: "when", rule, test });
|
|
910
|
+
}
|
|
911
|
+
export {
|
|
912
|
+
createMemoryRelations2 as createMemoryRelations,
|
|
913
|
+
defineModel,
|
|
914
|
+
fromField,
|
|
915
|
+
holderCursor2 as holderCursor,
|
|
916
|
+
idMatches2 as idMatches,
|
|
917
|
+
pageOfHolders2 as pageOfHolders,
|
|
918
|
+
permissions,
|
|
919
|
+
readHolderCursor2 as readHolderCursor,
|
|
920
|
+
when
|
|
921
|
+
};
|
|
922
|
+
|
|
923
|
+
//# debugId=66747879E997722F64756E2164756E21
|
|
924
|
+
//# sourceMappingURL=index.js.map
|