@kayjs/auth 0.0.0-stage → 1.104.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 +78 -2
- package/llms/admin-and-organizations.md +70 -0
- package/llms/admin-pages.md +30 -0
- package/llms/grouped-methods.md +106 -0
- package/llms/hardening-and-testing.md +108 -0
- package/llms/oauth-passkeys-two-factor.md +111 -0
- package/llms/oauth-providers.md +28 -0
- package/llms/oauth-server-and-tokens.md +76 -0
- package/llms/organization-pages.md +20 -0
- package/llms/passwords-and-mails.md +129 -0
- package/llms/sessions-and-guards.md +51 -0
- package/llms/setup.md +122 -0
- package/llms/signed-in-components.md +59 -0
- package/llms.txt +28 -0
- package/package.json +85 -4
- package/src/access.ts +31 -0
- package/src/account.ts +198 -0
- package/src/add.ts +70 -0
- package/src/address.ts +51 -0
- package/src/admin.ts +361 -0
- package/src/auditWording.ts +153 -0
- package/src/auth.ts +219 -0
- package/src/authorize/clients.ts +160 -0
- package/src/authorize/grants.ts +44 -0
- package/src/authorize/metadata.ts +72 -0
- package/src/authorize/register.ts +38 -0
- package/src/authorize/reply.ts +9 -0
- package/src/authorize/request.ts +253 -0
- package/src/authorize/resource.ts +34 -0
- package/src/authorize/revoke.ts +36 -0
- package/src/authorize/routes.ts +87 -0
- package/src/authorize/token.ts +213 -0
- package/src/authorize/uris.ts +76 -0
- package/src/bearer.ts +208 -0
- package/src/bearerHeader.ts +11 -0
- package/src/breached.ts +47 -0
- package/src/browser.ts +59 -0
- package/src/captcha.ts +196 -0
- package/src/cbor.ts +129 -0
- package/src/components/deletion-banner.kay +20 -0
- package/src/components/impersonation-banner.kay +21 -0
- package/src/components/signed-in.kay +8 -0
- package/src/components/signed-out.kay +6 -0
- package/src/components/user-menu.kay +21 -0
- package/src/context.ts +5 -0
- package/src/core.ts +308 -0
- package/src/createUserCommand.ts +217 -0
- package/src/decide.ts +45 -0
- package/src/deletion.ts +80 -0
- package/src/devTool.ts +104 -0
- package/src/device.ts +37 -0
- package/src/email.ts +594 -0
- package/src/erase.ts +237 -0
- package/src/events.ts +297 -0
- package/src/export.ts +101 -0
- package/src/failure.ts +63 -0
- package/src/forwardAuth.ts +55 -0
- package/src/forwardRoutes.ts +68 -0
- package/src/gate.ts +104 -0
- package/src/guard.ts +22 -0
- package/src/guards.ts +72 -0
- package/src/guesses.ts +99 -0
- package/src/index.ts +46 -0
- package/src/keys.ts +51 -0
- package/src/limits.ts +182 -0
- package/src/load.ts +18 -0
- package/src/locale.ts +15 -0
- package/src/log.ts +4 -0
- package/src/mail.ts +225 -0
- package/src/memoryStore.ts +599 -0
- package/src/messages/fr.ts +357 -0
- package/src/methods/account.ts +80 -0
- package/src/methods/admin.ts +63 -0
- package/src/methods/audit.ts +15 -0
- package/src/methods/email.ts +39 -0
- package/src/methods/magicLink.ts +32 -0
- package/src/methods/oauth.ts +35 -0
- package/src/methods/oauthServer.ts +31 -0
- package/src/methods/organizations.ts +96 -0
- package/src/methods/passkeys.ts +61 -0
- package/src/methods/password.ts +53 -0
- package/src/methods/sessions.ts +18 -0
- package/src/methods/tokens.ts +24 -0
- package/src/methods/twoFactor.ts +62 -0
- package/src/oauth/client.ts +324 -0
- package/src/oauth/flow.ts +350 -0
- package/src/oauth/index.ts +5 -0
- package/src/oauth/pkce.ts +20 -0
- package/src/oauth/providers.ts +490 -0
- package/src/oauth/refresher.ts +177 -0
- package/src/oauth/timeout.ts +2 -0
- package/src/oauth/types.ts +78 -0
- package/src/oauthTest.ts +112 -0
- package/src/organizations.ts +675 -0
- package/src/organizationsCore.ts +60 -0
- package/src/own.ts +313 -0
- package/src/pages/components/captcha.kay +16 -0
- package/src/pages/components/frame.kay +11 -0
- package/src/pages/components/message.kay +8 -0
- package/src/pages/components/panel.kay +12 -0
- package/src/pages/components/passkey-add.kay +48 -0
- package/src/pages/components/passkey-sign-in.kay +34 -0
- package/src/pages/components/passkey-two-factor.kay +33 -0
- package/src/pages/components/proof.kay +15 -0
- package/src/pages/components/provider-buttons.kay +25 -0
- package/src/pages/components/recovery-codes.kay +13 -0
- package/src/pages/components/separator.kay +4 -0
- package/src/pages/english.ts +82 -0
- package/src/pages/forms.ts +185 -0
- package/src/pages/index.ts +361 -0
- package/src/pages/organizationPage.ts +12 -0
- package/src/pages/routes/account/_guard.ts +15 -0
- package/src/pages/routes/account/_layout.kay +37 -0
- package/src/pages/routes/account/clients.kay +33 -0
- package/src/pages/routes/account/connections.kay +57 -0
- package/src/pages/routes/account/data.kay +106 -0
- package/src/pages/routes/account/index.kay +109 -0
- package/src/pages/routes/account/organizations/[org].kay +188 -0
- package/src/pages/routes/account/organizations/_guard.ts +8 -0
- package/src/pages/routes/account/organizations/index.kay +86 -0
- package/src/pages/routes/account/security.kay +164 -0
- package/src/pages/routes/account/sessions.kay +51 -0
- package/src/pages/routes/account/tokens.kay +84 -0
- package/src/pages/routes/admin/_layout.kay +43 -0
- package/src/pages/routes/admin/audit.kay +43 -0
- package/src/pages/routes/admin/index.kay +60 -0
- package/src/pages/routes/admin/users/[id].kay +181 -0
- package/src/pages/routes/confirm-email.kay +39 -0
- package/src/pages/routes/invitation.kay +104 -0
- package/src/pages/routes/magic-link.kay +42 -0
- package/src/pages/routes/oauth/authorize.kay +80 -0
- package/src/pages/routes/register.kay +83 -0
- package/src/pages/routes/reset-password.kay +73 -0
- package/src/pages/routes/sign-in.kay +128 -0
- package/src/pages/routes/two-factor.kay +61 -0
- package/src/pages/routes/verify-email.kay +83 -0
- package/src/passkeys.ts +373 -0
- package/src/password.ts +316 -0
- package/src/payloads.ts +22 -0
- package/src/pg.ts +705 -0
- package/src/profile.ts +43 -0
- package/src/proof.ts +110 -0
- package/src/prune.ts +123 -0
- package/src/rates.ts +82 -0
- package/src/request.ts +712 -0
- package/src/requiredTwoFactor.ts +71 -0
- package/src/requirement.ts +23 -0
- package/src/roles.ts +18 -0
- package/src/routes.ts +202 -0
- package/src/rules-check.ts +37 -0
- package/src/rules.ts +108 -0
- package/src/securityNotice.ts +45 -0
- package/src/sessions.ts +184 -0
- package/src/setup.ts +417 -0
- package/src/signInOptions.ts +9 -0
- package/src/state.ts +34 -0
- package/src/store.ts +410 -0
- package/src/storeHelpers.ts +23 -0
- package/src/test.ts +46 -0
- package/src/testCookies.ts +9 -0
- package/src/testHelpers.ts +58 -0
- package/src/testing.ts +113 -0
- package/src/text.ts +6 -0
- package/src/totp.ts +120 -0
- package/src/twoFactor.ts +200 -0
- package/src/types.ts +23 -0
- package/src/userData.ts +47 -0
- package/src/viewer-layout/_layout.kay +11 -0
- package/src/viewer.ts +116 -0
- package/src/wayIn.ts +40 -0
- package/src/webauthn.ts +375 -0
- package/src/wsAuth.ts +53 -0
- package/types/access.d.ts +12 -0
- package/types/access.d.ts.map +1 -0
- package/types/account.d.ts +32 -0
- package/types/account.d.ts.map +1 -0
- package/types/add.d.ts +29 -0
- package/types/add.d.ts.map +1 -0
- package/types/address.d.ts +2 -0
- package/types/address.d.ts.map +1 -0
- package/types/admin.d.ts +84 -0
- package/types/admin.d.ts.map +1 -0
- package/types/auditWording.d.ts +9 -0
- package/types/auditWording.d.ts.map +1 -0
- package/types/auth.d.ts +3475 -0
- package/types/auth.d.ts.map +1 -0
- package/types/authorize/clients.d.ts +15 -0
- package/types/authorize/clients.d.ts.map +1 -0
- package/types/authorize/grants.d.ts +15 -0
- package/types/authorize/grants.d.ts.map +1 -0
- package/types/authorize/metadata.d.ts +20 -0
- package/types/authorize/metadata.d.ts.map +1 -0
- package/types/authorize/register.d.ts +4 -0
- package/types/authorize/register.d.ts.map +1 -0
- package/types/authorize/reply.d.ts +6 -0
- package/types/authorize/reply.d.ts.map +1 -0
- package/types/authorize/request.d.ts +48 -0
- package/types/authorize/request.d.ts.map +1 -0
- package/types/authorize/resource.d.ts +4 -0
- package/types/authorize/resource.d.ts.map +1 -0
- package/types/authorize/revoke.d.ts +4 -0
- package/types/authorize/revoke.d.ts.map +1 -0
- package/types/authorize/routes.d.ts +5 -0
- package/types/authorize/routes.d.ts.map +1 -0
- package/types/authorize/token.d.ts +7 -0
- package/types/authorize/token.d.ts.map +1 -0
- package/types/authorize/uris.d.ts +5 -0
- package/types/authorize/uris.d.ts.map +1 -0
- package/types/bearer.d.ts +45 -0
- package/types/bearer.d.ts.map +1 -0
- package/types/bearerHeader.d.ts +3 -0
- package/types/bearerHeader.d.ts.map +1 -0
- package/types/breached.d.ts +5 -0
- package/types/breached.d.ts.map +1 -0
- package/types/browser.d.ts +11 -0
- package/types/browser.d.ts.map +1 -0
- package/types/captcha.d.ts +42 -0
- package/types/captcha.d.ts.map +1 -0
- package/types/cbor.d.ts +4 -0
- package/types/cbor.d.ts.map +1 -0
- package/types/context.d.ts +3 -0
- package/types/context.d.ts.map +1 -0
- package/types/core.d.ts +180 -0
- package/types/core.d.ts.map +1 -0
- package/types/createUserCommand.d.ts +11 -0
- package/types/createUserCommand.d.ts.map +1 -0
- package/types/decide.d.ts +12 -0
- package/types/decide.d.ts.map +1 -0
- package/types/deletion.d.ts +17 -0
- package/types/deletion.d.ts.map +1 -0
- package/types/devTool.d.ts +3 -0
- package/types/devTool.d.ts.map +1 -0
- package/types/device.d.ts +7 -0
- package/types/device.d.ts.map +1 -0
- package/types/email.d.ts +73 -0
- package/types/email.d.ts.map +1 -0
- package/types/erase.d.ts +31 -0
- package/types/erase.d.ts.map +1 -0
- package/types/events.d.ts +139 -0
- package/types/events.d.ts.map +1 -0
- package/types/export.d.ts +54 -0
- package/types/export.d.ts.map +1 -0
- package/types/failure.d.ts +19 -0
- package/types/failure.d.ts.map +1 -0
- package/types/forwardAuth.d.ts +12 -0
- package/types/forwardAuth.d.ts.map +1 -0
- package/types/forwardRoutes.d.ts +11 -0
- package/types/forwardRoutes.d.ts.map +1 -0
- package/types/gate.d.ts +31 -0
- package/types/gate.d.ts.map +1 -0
- package/types/guard.d.ts +10 -0
- package/types/guard.d.ts.map +1 -0
- package/types/guards.d.ts +37 -0
- package/types/guards.d.ts.map +1 -0
- package/types/guesses.d.ts +18 -0
- package/types/guesses.d.ts.map +1 -0
- package/types/index.d.ts +47 -0
- package/types/index.d.ts.map +1 -0
- package/types/keys.d.ts +11 -0
- package/types/keys.d.ts.map +1 -0
- package/types/limits.d.ts +133 -0
- package/types/limits.d.ts.map +1 -0
- package/types/load.d.ts +18 -0
- package/types/load.d.ts.map +1 -0
- package/types/locale.d.ts +4 -0
- package/types/locale.d.ts.map +1 -0
- package/types/log.d.ts +2 -0
- package/types/log.d.ts.map +1 -0
- package/types/mail.d.ts +51 -0
- package/types/mail.d.ts.map +1 -0
- package/types/memoryStore.d.ts +3 -0
- package/types/memoryStore.d.ts.map +1 -0
- package/types/messages/fr.d.ts +409 -0
- package/types/messages/fr.d.ts.map +1 -0
- package/types/methods/account.d.ts +24 -0
- package/types/methods/account.d.ts.map +1 -0
- package/types/methods/admin.d.ts +30 -0
- package/types/methods/admin.d.ts.map +1 -0
- package/types/methods/audit.d.ts +11 -0
- package/types/methods/audit.d.ts.map +1 -0
- package/types/methods/email.d.ts +14 -0
- package/types/methods/email.d.ts.map +1 -0
- package/types/methods/magicLink.d.ts +12 -0
- package/types/methods/magicLink.d.ts.map +1 -0
- package/types/methods/oauth.d.ts +16 -0
- package/types/methods/oauth.d.ts.map +1 -0
- package/types/methods/oauthServer.d.ts +13 -0
- package/types/methods/oauthServer.d.ts.map +1 -0
- package/types/methods/organizations.d.ts +30 -0
- package/types/methods/organizations.d.ts.map +1 -0
- package/types/methods/passkeys.d.ts +19 -0
- package/types/methods/passkeys.d.ts.map +1 -0
- package/types/methods/password.d.ts +17 -0
- package/types/methods/password.d.ts.map +1 -0
- package/types/methods/sessions.d.ts +9 -0
- package/types/methods/sessions.d.ts.map +1 -0
- package/types/methods/tokens.d.ts +11 -0
- package/types/methods/tokens.d.ts.map +1 -0
- package/types/methods/twoFactor.d.ts +20 -0
- package/types/methods/twoFactor.d.ts.map +1 -0
- package/types/oauth/client.d.ts +39 -0
- package/types/oauth/client.d.ts.map +1 -0
- package/types/oauth/flow.d.ts +38 -0
- package/types/oauth/flow.d.ts.map +1 -0
- package/types/oauth/index.d.ts +6 -0
- package/types/oauth/index.d.ts.map +1 -0
- package/types/oauth/pkce.d.ts +10 -0
- package/types/oauth/pkce.d.ts.map +1 -0
- package/types/oauth/providers.d.ts +100 -0
- package/types/oauth/providers.d.ts.map +1 -0
- package/types/oauth/refresher.d.ts +55 -0
- package/types/oauth/refresher.d.ts.map +1 -0
- package/types/oauth/timeout.d.ts +2 -0
- package/types/oauth/timeout.d.ts.map +1 -0
- package/types/oauth/types.d.ts +75 -0
- package/types/oauth/types.d.ts.map +1 -0
- package/types/oauthTest.d.ts +23 -0
- package/types/oauthTest.d.ts.map +1 -0
- package/types/organizations.d.ts +111 -0
- package/types/organizations.d.ts.map +1 -0
- package/types/organizationsCore.d.ts +29 -0
- package/types/organizationsCore.d.ts.map +1 -0
- package/types/own.d.ts +55 -0
- package/types/own.d.ts.map +1 -0
- package/types/pages/english.d.ts +80 -0
- package/types/pages/english.d.ts.map +1 -0
- package/types/pages/forms.d.ts +204 -0
- package/types/pages/forms.d.ts.map +1 -0
- package/types/pages/index.d.ts +166 -0
- package/types/pages/index.d.ts.map +1 -0
- package/types/pages/organizationPage.d.ts +7 -0
- package/types/pages/organizationPage.d.ts.map +1 -0
- package/types/pages/routes/account/_guard.d.ts +3 -0
- package/types/pages/routes/account/_guard.d.ts.map +1 -0
- package/types/pages/routes/account/organizations/_guard.d.ts +3 -0
- package/types/pages/routes/account/organizations/_guard.d.ts.map +1 -0
- package/types/passkeys.d.ts +61 -0
- package/types/passkeys.d.ts.map +1 -0
- package/types/password.d.ts +49 -0
- package/types/password.d.ts.map +1 -0
- package/types/payloads.d.ts +4 -0
- package/types/payloads.d.ts.map +1 -0
- package/types/pg.d.ts +303 -0
- package/types/pg.d.ts.map +1 -0
- package/types/profile.d.ts +11 -0
- package/types/profile.d.ts.map +1 -0
- package/types/proof.d.ts +33 -0
- package/types/proof.d.ts.map +1 -0
- package/types/prune.d.ts +5 -0
- package/types/prune.d.ts.map +1 -0
- package/types/rates.d.ts +15 -0
- package/types/rates.d.ts.map +1 -0
- package/types/request.d.ts +119 -0
- package/types/request.d.ts.map +1 -0
- package/types/requiredTwoFactor.d.ts +16 -0
- package/types/requiredTwoFactor.d.ts.map +1 -0
- package/types/requirement.d.ts +4 -0
- package/types/requirement.d.ts.map +1 -0
- package/types/roles.d.ts +9 -0
- package/types/roles.d.ts.map +1 -0
- package/types/routes.d.ts +31 -0
- package/types/routes.d.ts.map +1 -0
- package/types/rules-check.d.ts +3 -0
- package/types/rules-check.d.ts.map +1 -0
- package/types/rules.d.ts +38 -0
- package/types/rules.d.ts.map +1 -0
- package/types/securityNotice.d.ts +7 -0
- package/types/securityNotice.d.ts.map +1 -0
- package/types/sessions.d.ts +32 -0
- package/types/sessions.d.ts.map +1 -0
- package/types/setup.d.ts +18 -0
- package/types/setup.d.ts.map +1 -0
- package/types/signInOptions.d.ts +6 -0
- package/types/signInOptions.d.ts.map +1 -0
- package/types/state.d.ts +25 -0
- package/types/state.d.ts.map +1 -0
- package/types/store.d.ts +295 -0
- package/types/store.d.ts.map +1 -0
- package/types/storeHelpers.d.ts +4 -0
- package/types/storeHelpers.d.ts.map +1 -0
- package/types/test.d.ts +21 -0
- package/types/test.d.ts.map +1 -0
- package/types/testCookies.d.ts +3 -0
- package/types/testCookies.d.ts.map +1 -0
- package/types/testHelpers.d.ts +34 -0
- package/types/testHelpers.d.ts.map +1 -0
- package/types/testing.d.ts +12 -0
- package/types/testing.d.ts.map +1 -0
- package/types/text.d.ts +2 -0
- package/types/text.d.ts.map +1 -0
- package/types/totp.d.ts +12 -0
- package/types/totp.d.ts.map +1 -0
- package/types/twoFactor.d.ts +41 -0
- package/types/twoFactor.d.ts.map +1 -0
- package/types/types.d.ts +17 -0
- package/types/types.d.ts.map +1 -0
- package/types/userData.d.ts +9 -0
- package/types/userData.d.ts.map +1 -0
- package/types/viewer.d.ts +23 -0
- package/types/viewer.d.ts.map +1 -0
- package/types/wayIn.d.ts +12 -0
- package/types/wayIn.d.ts.map +1 -0
- package/types/webauthn.d.ts +111 -0
- package/types/webauthn.d.ts.map +1 -0
- package/types/wsAuth.d.ts +14 -0
- package/types/wsAuth.d.ts.map +1 -0
package/src/webauthn.ts
ADDED
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
import type { CborMap } from './cbor'
|
|
2
|
+
import { Buffer } from 'node:buffer'
|
|
3
|
+
import { decodeCbor } from './cbor'
|
|
4
|
+
|
|
5
|
+
// The WebAuthn half of passkeys, on Web Crypto: the options a ceremony hands the browser, and the checks of what the authenticator answers.
|
|
6
|
+
|
|
7
|
+
export type Requirement = 'required' | 'preferred' | 'discouraged'
|
|
8
|
+
|
|
9
|
+
export interface CredentialDescriptorJSON {
|
|
10
|
+
id: string
|
|
11
|
+
type: 'public-key'
|
|
12
|
+
transports?: string[]
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// The options for `navigator.credentials.create`, as `PublicKeyCredential.parseCreationOptionsFromJSON` reads them.
|
|
16
|
+
export interface PublicKeyCredentialCreationOptionsJSON {
|
|
17
|
+
rp: { name: string, id?: string }
|
|
18
|
+
user: { id: string, name: string, displayName: string }
|
|
19
|
+
challenge: string
|
|
20
|
+
pubKeyCredParams: { alg: number, type: 'public-key' }[]
|
|
21
|
+
timeout?: number
|
|
22
|
+
excludeCredentials?: CredentialDescriptorJSON[]
|
|
23
|
+
authenticatorSelection?: { authenticatorAttachment?: 'platform' | 'cross-platform', requireResidentKey?: boolean, residentKey?: Requirement, userVerification?: Requirement }
|
|
24
|
+
hints?: ('hybrid' | 'security-key' | 'client-device')[]
|
|
25
|
+
attestation?: 'none' | 'indirect' | 'direct' | 'enterprise'
|
|
26
|
+
extensions?: { credProps?: boolean }
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// The options for `navigator.credentials.get`, as `PublicKeyCredential.parseRequestOptionsFromJSON` reads them.
|
|
30
|
+
export interface PublicKeyCredentialRequestOptionsJSON {
|
|
31
|
+
challenge: string
|
|
32
|
+
timeout?: number
|
|
33
|
+
rpId?: string
|
|
34
|
+
allowCredentials?: CredentialDescriptorJSON[]
|
|
35
|
+
userVerification?: Requirement
|
|
36
|
+
hints?: ('hybrid' | 'security-key' | 'client-device')[]
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
interface CredentialJSON<Response> {
|
|
40
|
+
id: string
|
|
41
|
+
rawId: string
|
|
42
|
+
type: 'public-key'
|
|
43
|
+
response: Response
|
|
44
|
+
authenticatorAttachment?: 'platform' | 'cross-platform'
|
|
45
|
+
clientExtensionResults: Record<string, unknown>
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// A new passkey as `credential.toJSON()` writes it.
|
|
49
|
+
export type RegistrationResponseJSON = CredentialJSON<{ clientDataJSON: string, attestationObject: string, authenticatorData?: string, transports?: string[], publicKeyAlgorithm?: number, publicKey?: string }>
|
|
50
|
+
|
|
51
|
+
// A passkey's signature as `credential.toJSON()` writes it.
|
|
52
|
+
export type AuthenticationResponseJSON = CredentialJSON<{ clientDataJSON: string, authenticatorData: string, signature: string, userHandle?: string }>
|
|
53
|
+
|
|
54
|
+
// What an answer must match: the challenge parked for it, one of the site's origins, its rpId, and whether the user had to be verified.
|
|
55
|
+
export interface Expected {
|
|
56
|
+
challenge: string
|
|
57
|
+
origins: string[]
|
|
58
|
+
rpId: string
|
|
59
|
+
requireUserVerification: boolean
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// A passkey a registration made: its COSE public key is base64url, as the store keeps it.
|
|
63
|
+
export interface RegisteredCredential {
|
|
64
|
+
id: string
|
|
65
|
+
publicKey: string
|
|
66
|
+
counter: number
|
|
67
|
+
transports: string[]
|
|
68
|
+
multiDevice: boolean
|
|
69
|
+
backedUp: boolean
|
|
70
|
+
userVerified: boolean
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface Assertion {
|
|
74
|
+
counter: number
|
|
75
|
+
multiDevice: boolean
|
|
76
|
+
backedUp: boolean
|
|
77
|
+
userVerified: boolean
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const TIMEOUT_MS = 60_000
|
|
81
|
+
// The COSE algorithms a new passkey may use, in the order offered: ML-DSA-44, EdDSA, ES256, RS256.
|
|
82
|
+
const ALGORITHMS = [-48, -8, -7, -257]
|
|
83
|
+
const BASE64URL = /^[\w-]*={0,2}$/
|
|
84
|
+
const UTF8 = new TextDecoder('utf-8', { fatal: true })
|
|
85
|
+
// The authenticator data's flags: user present, user verified, backup eligible, backed up, attested credential data, extensions.
|
|
86
|
+
const UP = 0x01
|
|
87
|
+
const UV = 0x04
|
|
88
|
+
const BE = 0x08
|
|
89
|
+
const BS = 0x10
|
|
90
|
+
const AT = 0x40
|
|
91
|
+
const ED = 0x80
|
|
92
|
+
const CREDENTIAL_ID_MAX = 1023
|
|
93
|
+
|
|
94
|
+
// Kept on the authenticator, so it signs in without a name typed first. Signing in requires user verification, so a passkey made without it would count as a way in and never open.
|
|
95
|
+
export function registrationOptions(options: { rpName: string, rpId: string, userName: string, userId: string, exclude: { id: string, transports: string[] }[] }): PublicKeyCredentialCreationOptionsJSON {
|
|
96
|
+
return {
|
|
97
|
+
challenge: newChallenge(),
|
|
98
|
+
rp: { name: options.rpName, id: options.rpId },
|
|
99
|
+
user: { id: Buffer.from(options.userId).toString('base64url'), name: options.userName, displayName: '' },
|
|
100
|
+
pubKeyCredParams: ALGORITHMS.map(alg => ({ alg, type: 'public-key' })),
|
|
101
|
+
timeout: TIMEOUT_MS,
|
|
102
|
+
attestation: 'none',
|
|
103
|
+
excludeCredentials: options.exclude.map(({ id, transports }) => ({ id, transports, type: 'public-key' })),
|
|
104
|
+
authenticatorSelection: { residentKey: 'required', userVerification: 'required', requireResidentKey: true },
|
|
105
|
+
extensions: { credProps: true },
|
|
106
|
+
hints: [],
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// With no `allow`, the browser offers every passkey it holds for the site.
|
|
111
|
+
export function authenticationOptions(options: { rpId: string, allow?: { id: string, transports: string[] }[], userVerification: Requirement }): PublicKeyCredentialRequestOptionsJSON {
|
|
112
|
+
return {
|
|
113
|
+
rpId: options.rpId,
|
|
114
|
+
challenge: newChallenge(),
|
|
115
|
+
...options.allow && { allowCredentials: options.allow.map(({ id, transports }) => ({ id, transports, type: 'public-key' })) },
|
|
116
|
+
timeout: TIMEOUT_MS,
|
|
117
|
+
userVerification: options.userVerification,
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// The passkey `response` makes, when it answers `expected`; undefined for any answer that does not. The attestation is decoded, so one holding a CBOR tag or float is refused, but never checked: kay asks for none and trusts no attestation root, and every sign-in proves the key itself.
|
|
122
|
+
export async function verifyRegistration(response: RegistrationResponseJSON, expected: Expected): Promise<RegisteredCredential | undefined> {
|
|
123
|
+
try {
|
|
124
|
+
if (!credentialHolds(response) || !clientDataHolds(response.response.clientDataJSON, 'webauthn.create', expected))
|
|
125
|
+
return undefined
|
|
126
|
+
|
|
127
|
+
const [attestation] = decodeCbor(fromBase64url(response.response.attestationObject))
|
|
128
|
+
const authData = attestation instanceof Map ? attestation.get('authData') : undefined
|
|
129
|
+
|
|
130
|
+
if (!(attestation instanceof Map) || !(authData instanceof Uint8Array) || typeof attestation.get('fmt') !== 'string' || !(attestation.get('attStmt') instanceof Map))
|
|
131
|
+
return undefined
|
|
132
|
+
|
|
133
|
+
const data = parseAuthData(authData)
|
|
134
|
+
const id = data.credential && Buffer.from(data.credential.id).toString('base64url')
|
|
135
|
+
|
|
136
|
+
// Sign-in finds the passkey by the id the browser sends, so one stored under another id than the answer named could never be found again.
|
|
137
|
+
if (!data.credential || id !== response.id || !(await flagsHold(data, expected)))
|
|
138
|
+
return undefined
|
|
139
|
+
|
|
140
|
+
// A key of an algorithm not offered, or that Web Crypto cannot import, could never sign in, so it throws here rather than being stored.
|
|
141
|
+
await importCoseKey(data.credential.publicKey)
|
|
142
|
+
|
|
143
|
+
return {
|
|
144
|
+
id,
|
|
145
|
+
publicKey: Buffer.from(data.credential.publicKey).toString('base64url'),
|
|
146
|
+
counter: data.counter,
|
|
147
|
+
transports: response.response.transports ?? [],
|
|
148
|
+
multiDevice: data.backupEligible,
|
|
149
|
+
backedUp: data.backedUp,
|
|
150
|
+
userVerified: data.userVerified,
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
catch {
|
|
154
|
+
return undefined
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// What `response` asserts, when it answers `expected` and is signed by `stored`'s key past its counter; undefined for any answer that does not.
|
|
159
|
+
export async function verifyAuthentication(response: AuthenticationResponseJSON, expected: Expected, stored: { publicKey: string, counter: number }): Promise<Assertion | undefined> {
|
|
160
|
+
try {
|
|
161
|
+
if (!credentialHolds(response) || !clientDataHolds(response.response.clientDataJSON, 'webauthn.get', expected))
|
|
162
|
+
return undefined
|
|
163
|
+
|
|
164
|
+
const authData = fromBase64url(response.response.authenticatorData)
|
|
165
|
+
const data = parseAuthData(authData)
|
|
166
|
+
|
|
167
|
+
if (!(await flagsHold(data, expected)))
|
|
168
|
+
return undefined
|
|
169
|
+
|
|
170
|
+
// An authenticator that counts must count past the stored value; one going back, or standing still, is the sign of a cloned key. One that never counts sends 0 every time.
|
|
171
|
+
if ((data.counter > 0 || stored.counter > 0) && data.counter <= stored.counter)
|
|
172
|
+
return undefined
|
|
173
|
+
|
|
174
|
+
const key = await importCoseKey(fromBase64url(stored.publicKey))
|
|
175
|
+
const signed = Buffer.concat([authData, await sha256(fromBase64url(response.response.clientDataJSON))])
|
|
176
|
+
const signature = fromBase64url(response.response.signature)
|
|
177
|
+
|
|
178
|
+
if (!(await crypto.subtle.verify(key.verify, key.key, key.alg === -7 ? rawEcdsa(signature) : signature, signed)))
|
|
179
|
+
return undefined
|
|
180
|
+
|
|
181
|
+
return { counter: data.counter, multiDevice: data.backupEligible, backedUp: data.backedUp, userVerified: data.userVerified }
|
|
182
|
+
}
|
|
183
|
+
catch {
|
|
184
|
+
return undefined
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function newChallenge(): string {
|
|
189
|
+
return Buffer.from(crypto.getRandomValues(new Uint8Array(32))).toString('base64url')
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function credentialHolds(response: RegistrationResponseJSON | AuthenticationResponseJSON): boolean {
|
|
193
|
+
return typeof response.id === 'string' && response.id !== '' && response.id === response.rawId && response.type === 'public-key'
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// The client data the browser wrote is of the ceremony's `type`, carries the parked challenge and comes from one of the site's origins, in no frame of another origin: kay serves its pages with `frame-ancestors 'self'`, so a ceremony that says `crossOrigin` or names a `topOrigin` is refused.
|
|
197
|
+
function clientDataHolds(encoded: string, type: string, expected: Expected): boolean {
|
|
198
|
+
const clientData: unknown = JSON.parse(UTF8.decode(fromBase64url(encoded)))
|
|
199
|
+
|
|
200
|
+
if (typeof clientData !== 'object' || clientData === null)
|
|
201
|
+
return false
|
|
202
|
+
|
|
203
|
+
const fields = clientData as Record<string, unknown>
|
|
204
|
+
|
|
205
|
+
return fields.type === type
|
|
206
|
+
&& fields.challenge === expected.challenge
|
|
207
|
+
&& typeof fields.origin === 'string'
|
|
208
|
+
&& expected.origins.includes(fields.origin)
|
|
209
|
+
&& (fields.crossOrigin === undefined || fields.crossOrigin === false)
|
|
210
|
+
&& fields.topOrigin === undefined
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
interface AuthData {
|
|
214
|
+
rpIdHash: Uint8Array
|
|
215
|
+
userPresent: boolean
|
|
216
|
+
userVerified: boolean
|
|
217
|
+
backupEligible: boolean
|
|
218
|
+
backedUp: boolean
|
|
219
|
+
counter: number
|
|
220
|
+
credential?: { id: Uint8Array, publicKey: Uint8Array }
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// The authenticator data: the rpId's hash, the flags, the counter, then the new credential when AT is set and the extensions when ED is, nothing left after them.
|
|
224
|
+
function parseAuthData(bytes: Uint8Array): AuthData {
|
|
225
|
+
if (bytes.length < 37)
|
|
226
|
+
throw new Error('authenticator data cut short')
|
|
227
|
+
|
|
228
|
+
const flags = bytes[32]!
|
|
229
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength)
|
|
230
|
+
let offset = 37
|
|
231
|
+
let credential: AuthData['credential']
|
|
232
|
+
|
|
233
|
+
if (flags & AT) {
|
|
234
|
+
// 16 bytes of AAGUID, then the credential id's length and the id.
|
|
235
|
+
const idLength = view.getUint16(offset + 16)
|
|
236
|
+
const idStart = offset + 18
|
|
237
|
+
|
|
238
|
+
if (idLength === 0 || idLength > CREDENTIAL_ID_MAX || idStart + idLength > bytes.length)
|
|
239
|
+
throw new Error('invalid credential id')
|
|
240
|
+
|
|
241
|
+
const [, keyEnd] = decodeCbor(bytes, idStart + idLength)
|
|
242
|
+
|
|
243
|
+
credential = { id: bytes.slice(idStart, idStart + idLength), publicKey: bytes.slice(idStart + idLength, keyEnd) }
|
|
244
|
+
offset = keyEnd
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
if (flags & ED) {
|
|
248
|
+
const [extensions, end] = decodeCbor(bytes, offset)
|
|
249
|
+
|
|
250
|
+
if (!(extensions instanceof Map))
|
|
251
|
+
throw new Error('invalid extensions')
|
|
252
|
+
|
|
253
|
+
offset = end
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
if (offset !== bytes.length)
|
|
257
|
+
throw new Error('bytes left after the authenticator data')
|
|
258
|
+
|
|
259
|
+
return {
|
|
260
|
+
rpIdHash: bytes.subarray(0, 32),
|
|
261
|
+
userPresent: (flags & UP) !== 0,
|
|
262
|
+
userVerified: (flags & UV) !== 0,
|
|
263
|
+
backupEligible: (flags & BE) !== 0,
|
|
264
|
+
backedUp: (flags & BS) !== 0,
|
|
265
|
+
counter: view.getUint32(33),
|
|
266
|
+
...credential && { credential },
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// The authenticator signed for the site's rpId, with the user present, verified when asked, and backed up only when it may be.
|
|
271
|
+
async function flagsHold(data: AuthData, expected: Expected): Promise<boolean> {
|
|
272
|
+
return Buffer.from(await sha256(Buffer.from(expected.rpId))).equals(data.rpIdHash)
|
|
273
|
+
&& data.userPresent
|
|
274
|
+
&& (data.userVerified || !expected.requireUserVerification)
|
|
275
|
+
&& (data.backupEligible || !data.backedUp)
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
interface CoseKey {
|
|
279
|
+
alg: number
|
|
280
|
+
key: CryptoKey
|
|
281
|
+
verify: AlgorithmIdentifier | EcdsaParams
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
// A COSE public key as Web Crypto verifies with it, for ES256, RS256, EdDSA (Ed25519) and ML-DSA-44; any other key, or one whose parts do not fit its algorithm, throws.
|
|
285
|
+
async function importCoseKey(bytes: Uint8Array): Promise<CoseKey> {
|
|
286
|
+
const [cose] = decodeCbor(bytes)
|
|
287
|
+
|
|
288
|
+
if (!(cose instanceof Map))
|
|
289
|
+
throw new Error('COSE key is not a map')
|
|
290
|
+
|
|
291
|
+
const kty = cose.get(1)
|
|
292
|
+
const alg = cose.get(3)
|
|
293
|
+
|
|
294
|
+
if (alg === -7 && kty === 2 && cose.get(-1) === 1) {
|
|
295
|
+
const jwk = { kty: 'EC', crv: 'P-256', x: part(cose, -2, 32), y: part(cose, -3, 32) }
|
|
296
|
+
|
|
297
|
+
return { alg, key: await crypto.subtle.importKey('jwk', jwk, { name: 'ECDSA', namedCurve: 'P-256' }, false, ['verify']), verify: { name: 'ECDSA', hash: 'SHA-256' } }
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
if (alg === -257 && kty === 3) {
|
|
301
|
+
const jwk = { kty: 'RSA', alg: 'RS256', n: part(cose, -1), e: part(cose, -2) }
|
|
302
|
+
|
|
303
|
+
return { alg, key: await crypto.subtle.importKey('jwk', jwk, { name: 'RSASSA-PKCS1-v1_5', hash: 'SHA-256' }, false, ['verify']), verify: 'RSASSA-PKCS1-v1_5' }
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
if (alg === -8 && kty === 1 && cose.get(-1) === 6) {
|
|
307
|
+
const jwk = { kty: 'OKP', crv: 'Ed25519', x: part(cose, -2, 32) }
|
|
308
|
+
|
|
309
|
+
return { alg, key: await crypto.subtle.importKey('jwk', jwk, 'Ed25519', false, ['verify']), verify: 'Ed25519' }
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
if (alg === -48 && kty === 7) {
|
|
313
|
+
const jwk = { kty: 'AKP', alg: 'ML-DSA-44', pub: part(cose, -1) }
|
|
314
|
+
|
|
315
|
+
return { alg, key: await crypto.subtle.importKey('jwk', jwk as JsonWebKey, 'ML-DSA-44', false, ['verify']), verify: 'ML-DSA-44' }
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
throw new Error('unsupported COSE key')
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
// A byte string of the COSE key, base64url as a JWK holds it, `length` bytes long when given.
|
|
322
|
+
function part(cose: CborMap, label: number, length?: number): string {
|
|
323
|
+
const value = cose.get(label)
|
|
324
|
+
|
|
325
|
+
if (!(value instanceof Uint8Array) || value.length === 0 || (length !== undefined && value.length !== length))
|
|
326
|
+
throw new Error('invalid COSE key part')
|
|
327
|
+
|
|
328
|
+
return Buffer.from(value).toString('base64url')
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
// An ES256 signature comes DER-encoded, SEQUENCE { INTEGER r, INTEGER s }, where Web Crypto takes r and s as two 32-byte halves.
|
|
332
|
+
function rawEcdsa(der: Uint8Array): Uint8Array<ArrayBuffer> {
|
|
333
|
+
if (der[0] !== 0x30 || der[1] !== der.length - 2)
|
|
334
|
+
throw new Error('invalid DER signature')
|
|
335
|
+
|
|
336
|
+
const raw = new Uint8Array(64)
|
|
337
|
+
const end = derInteger(der, derInteger(der, 2, raw, 0), raw, 32)
|
|
338
|
+
|
|
339
|
+
if (end !== der.length)
|
|
340
|
+
throw new Error('invalid DER signature')
|
|
341
|
+
|
|
342
|
+
return raw
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
// Writes the DER integer at `offset` as the 32 bytes of `raw` from `at`, a shorter one padded and the zero byte that keeps a 32-byte one positive dropped, and answers where it ends. DER writes an integer in its fewest bytes and r and s are positive, so a leading zero before a byte without its high bit, or a first byte with it, is another encoding of the same signature and refused.
|
|
346
|
+
function derInteger(der: Uint8Array, offset: number, raw: Uint8Array, at: number): number {
|
|
347
|
+
const length = der[offset + 1]
|
|
348
|
+
|
|
349
|
+
if (der[offset] !== 0x02 || length === undefined || length === 0 || length > 33 || offset + 2 + length > der.length)
|
|
350
|
+
throw new Error('invalid DER integer')
|
|
351
|
+
|
|
352
|
+
const end = offset + 2 + length
|
|
353
|
+
let value = der.subarray(offset + 2, end)
|
|
354
|
+
|
|
355
|
+
if (value[0]! & 0x80 || (value.length > 1 && value[0] === 0 && !(value[1]! & 0x80)) || (value.length === 33 && value[0] !== 0))
|
|
356
|
+
throw new Error('invalid DER integer')
|
|
357
|
+
|
|
358
|
+
if (value.length === 33)
|
|
359
|
+
value = value.subarray(1)
|
|
360
|
+
|
|
361
|
+
raw.set(value, at + 32 - value.length)
|
|
362
|
+
|
|
363
|
+
return end
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
function fromBase64url(value: unknown): Uint8Array<ArrayBuffer> {
|
|
367
|
+
if (typeof value !== 'string' || !BASE64URL.test(value))
|
|
368
|
+
throw new Error('not base64url')
|
|
369
|
+
|
|
370
|
+
return new Uint8Array(Buffer.from(value, 'base64url'))
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
async function sha256(bytes: Uint8Array<ArrayBuffer>): Promise<Uint8Array> {
|
|
374
|
+
return new Uint8Array(await crypto.subtle.digest('SHA-256', bytes))
|
|
375
|
+
}
|
package/src/wsAuth.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export interface WsSender {
|
|
2
|
+
send: (msg: string) => void
|
|
3
|
+
close: () => void
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export interface Ws extends WsSender {
|
|
7
|
+
id: string | number
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// How long a verified token stays good before `get` checks it again, so a revoked token or a banned user loses the socket.
|
|
11
|
+
const VERIFIED_FRESH_MS = 30 * 1000
|
|
12
|
+
|
|
13
|
+
/** Shared WS auth handshake: verifies the token, tracks the authed value per connection, replies `{type:'authed'}`; `verify` returns null to reject. `get` verifies the token again past 30 seconds, and closes the socket once it is refused. */
|
|
14
|
+
export function wsAuthStore<T>(verify: (token: string, ws: Ws) => Promise<T | null> | T | null) {
|
|
15
|
+
const authed = new Map<string, { token: string, value: T, at: number }>()
|
|
16
|
+
|
|
17
|
+
return {
|
|
18
|
+
async handleAuth(ws: Ws, token: string): Promise<void> {
|
|
19
|
+
const value = await verify(token, ws)
|
|
20
|
+
|
|
21
|
+
if (value === null || value === undefined)
|
|
22
|
+
return
|
|
23
|
+
|
|
24
|
+
authed.set(String(ws.id), { token, value, at: Date.now() })
|
|
25
|
+
ws.send(JSON.stringify({ type: 'authed' }))
|
|
26
|
+
},
|
|
27
|
+
async get(ws: Ws): Promise<T | undefined> {
|
|
28
|
+
const id = String(ws.id)
|
|
29
|
+
const entry = authed.get(id)
|
|
30
|
+
|
|
31
|
+
if (!entry || Date.now() - entry.at <= VERIFIED_FRESH_MS)
|
|
32
|
+
return entry?.value
|
|
33
|
+
|
|
34
|
+
const value = await verify(entry.token, ws)
|
|
35
|
+
|
|
36
|
+
// Forgotten meanwhile, as by the socket closing.
|
|
37
|
+
if (authed.get(id) !== entry)
|
|
38
|
+
return authed.get(id)?.value
|
|
39
|
+
|
|
40
|
+
if (value === null || value === undefined) {
|
|
41
|
+
authed.delete(id)
|
|
42
|
+
ws.close()
|
|
43
|
+
|
|
44
|
+
return undefined
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
authed.set(id, { token: entry.token, value, at: Date.now() })
|
|
48
|
+
|
|
49
|
+
return value
|
|
50
|
+
},
|
|
51
|
+
forget: (ws: Ws) => authed.delete(String(ws.id)),
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { BareUser } from './core';
|
|
2
|
+
import type { Level, PolicyContext, Predicate, Requirement } from './types';
|
|
3
|
+
export interface Access<Role extends string> {
|
|
4
|
+
hasRole: (required: Role) => Predicate<BareUser>;
|
|
5
|
+
isGranted: (role: Role, roles: string[]) => boolean;
|
|
6
|
+
authorize: (user: BareUser | null, requirement: Requirement<BareUser, Role>, level: Level, ctx: PolicyContext) => Promise<boolean>;
|
|
7
|
+
}
|
|
8
|
+
export declare function accessOf<Role extends string>(options: {
|
|
9
|
+
roles?: Record<Role, Role[]> | undefined;
|
|
10
|
+
authorize?: Access<Role>['authorize'] | undefined;
|
|
11
|
+
}): Access<Role>;
|
|
12
|
+
//# sourceMappingURL=access.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"access.d.ts","sourceRoot":"","sources":["../src/access.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAEtC,OAAO,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAK3E,MAAM,WAAW,MAAM,CAAC,IAAI,SAAS,MAAM;IACzC,OAAO,EAAE,CAAC,QAAQ,EAAE,IAAI,KAAK,SAAS,CAAC,QAAQ,CAAC,CAAA;IAChD,SAAS,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,OAAO,CAAA;IACnD,SAAS,EAAE,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI,EAAE,WAAW,EAAE,WAAW,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;CACnI;AAED,wBAAgB,QAAQ,CAAC,IAAI,SAAS,MAAM,EAAE,OAAO,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,GAAG,SAAS,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,GAAG,SAAS,CAAA;CAAE,GAAG,MAAM,CAAC,IAAI,CAAC,CAiBpK"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { BareUser } from './core';
|
|
2
|
+
import type { AuthFailed, AuthRejected } from './failure';
|
|
3
|
+
import type { Proof, ProofFailure } from './proof';
|
|
4
|
+
import type { PasswordProblem, UsernameProblem } from './rules';
|
|
5
|
+
import type { RequestState } from './state';
|
|
6
|
+
export type ChangePasswordResult = {
|
|
7
|
+
ok: true;
|
|
8
|
+
} | AuthFailed<ProofFailure> | AuthRejected<{
|
|
9
|
+
password: PasswordProblem | 'breached';
|
|
10
|
+
}>;
|
|
11
|
+
export declare function changePassword(state: RequestState, proof: Proof, password: string): Promise<ChangePasswordResult>;
|
|
12
|
+
export type UpdateLocaleResult = {
|
|
13
|
+
ok: true;
|
|
14
|
+
} | AuthFailed<'signed-out' | 'invalid-locale'>;
|
|
15
|
+
export declare function updateLocale(state: RequestState, locale: string): Promise<UpdateLocaleResult>;
|
|
16
|
+
export type ChangeUsernameResult = {
|
|
17
|
+
ok: true;
|
|
18
|
+
user: BareUser;
|
|
19
|
+
} | AuthFailed<'signed-out'> | AuthRejected<{
|
|
20
|
+
username: UsernameProblem | 'taken' | 'unchanged';
|
|
21
|
+
}>;
|
|
22
|
+
export declare function changeUsername(state: RequestState, username: string): Promise<ChangeUsernameResult>;
|
|
23
|
+
export type UnlinkResult = {
|
|
24
|
+
ok: true;
|
|
25
|
+
} | AuthFailed<ProofFailure | 'not-linked' | 'last-way-in'>;
|
|
26
|
+
export declare function unlink(state: RequestState, provider: string, proof: Proof): Promise<UnlinkResult>;
|
|
27
|
+
export type DeleteAccountResult = {
|
|
28
|
+
ok: true;
|
|
29
|
+
deleteAt?: Date;
|
|
30
|
+
} | AuthFailed<ProofFailure | 'last-admin' | 'last-owner' | 'refused'>;
|
|
31
|
+
export declare function deleteAccount(state: RequestState, proof: Proof, signOut: () => Promise<void>): Promise<DeleteAccountResult>;
|
|
32
|
+
//# sourceMappingURL=account.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../src/account.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AACzD,OAAO,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAClD,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAmB3C,MAAM,MAAM,oBAAoB,GAAG;IAAE,EAAE,EAAE,IAAI,CAAA;CAAE,GAAG,UAAU,CAAC,YAAY,CAAC,GAAG,YAAY,CAAC;IAAE,QAAQ,EAAE,eAAe,GAAG,UAAU,CAAA;CAAE,CAAC,CAAA;AAGrI,wBAAsB,cAAc,CAAC,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAoBvH;AAED,MAAM,MAAM,kBAAkB,GAAG;IAAE,EAAE,EAAE,IAAI,CAAA;CAAE,GAAG,UAAU,CAAC,YAAY,GAAG,gBAAgB,CAAC,CAAA;AAG3F,wBAAsB,YAAY,CAAC,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAYnG;AAED,MAAM,MAAM,oBAAoB,GAAG;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,QAAQ,CAAA;CAAE,GAAG,UAAU,CAAC,YAAY,CAAC,GAAG,YAAY,CAAC;IAAE,QAAQ,EAAE,eAAe,GAAG,OAAO,GAAG,WAAW,CAAA;CAAE,CAAC,CAAA;AAGhK,wBAAsB,cAAc,CAAC,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC,CA0CzG;AAED,MAAM,MAAM,YAAY,GAAG;IAAE,EAAE,EAAE,IAAI,CAAA;CAAE,GAAG,UAAU,CAAC,YAAY,GAAG,YAAY,GAAG,aAAa,CAAC,CAAA;AAGjG,wBAAsB,MAAM,CAAC,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,YAAY,CAAC,CA8BvG;AAGD,MAAM,MAAM,mBAAmB,GAAG;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,EAAE,IAAI,CAAA;CAAE,GAAG,UAAU,CAAC,YAAY,GAAG,YAAY,GAAG,YAAY,GAAG,SAAS,CAAC,CAAA;AAGpI,wBAAsB,aAAa,CAAC,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,mBAAmB,CAAC,CA8CjI"}
|
package/types/add.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
interface Project {
|
|
2
|
+
name: string;
|
|
3
|
+
exists: (path: string) => boolean;
|
|
4
|
+
read: (path: string) => string | undefined;
|
|
5
|
+
depends: (name: string) => boolean;
|
|
6
|
+
}
|
|
7
|
+
declare function withAuthTables(_match: string, open: string, space: string, close: string): string;
|
|
8
|
+
export default function auth(project: Project): {
|
|
9
|
+
description: string;
|
|
10
|
+
files: {
|
|
11
|
+
'src/routes/_guard.ts': string;
|
|
12
|
+
};
|
|
13
|
+
edits: {
|
|
14
|
+
file: string;
|
|
15
|
+
find: RegExp;
|
|
16
|
+
replace: typeof withAuthTables;
|
|
17
|
+
done: string;
|
|
18
|
+
import: string;
|
|
19
|
+
}[];
|
|
20
|
+
example: string[];
|
|
21
|
+
ignore: string[];
|
|
22
|
+
extension: {
|
|
23
|
+
import: string;
|
|
24
|
+
expression: string;
|
|
25
|
+
};
|
|
26
|
+
notes: string[];
|
|
27
|
+
};
|
|
28
|
+
export {};
|
|
29
|
+
//# sourceMappingURL=add.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../src/add.ts"],"names":[],"mappings":"AAAA,UAAU,OAAO;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAA;IACjC,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAA;IAC1C,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAA;CACnC;AAOD,iBAAS,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAK1F;AAUD,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,OAAO,EAAE,OAAO;;;QAWvC,sBAAsB;;;;;;;;;;;;QAOX,MAAM;QAA0C,UAAU;;;EAO1E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../src/address.ts"],"names":[],"mappings":"AAGA,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAqBxD"}
|
package/types/admin.d.ts
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { BareUser, SignedIn } from './core';
|
|
2
|
+
import type { AuditCursorInput, AuditEntry } from './events';
|
|
3
|
+
import type { AuthFailed } from './failure';
|
|
4
|
+
import type { RequestState } from './state';
|
|
5
|
+
import type { UserRecord } from './store';
|
|
6
|
+
export interface ManagedUser extends BareUser {
|
|
7
|
+
createdAt: Date;
|
|
8
|
+
ban: {
|
|
9
|
+
bannedAt: Date;
|
|
10
|
+
until: Date | null;
|
|
11
|
+
reason: string | null;
|
|
12
|
+
} | null;
|
|
13
|
+
}
|
|
14
|
+
export type AdminFailure = 'forbidden' | 'not-found' | 'two-factor-required';
|
|
15
|
+
export type AdminChangeFailure = AdminFailure | 'stale';
|
|
16
|
+
export type RoleResult = {
|
|
17
|
+
ok: true;
|
|
18
|
+
user: ManagedUser;
|
|
19
|
+
} | AuthFailed<AdminChangeFailure | 'unknown-role' | 'self' | 'last-admin'>;
|
|
20
|
+
export type BanResult = {
|
|
21
|
+
ok: true;
|
|
22
|
+
user: ManagedUser;
|
|
23
|
+
} | AuthFailed<AdminChangeFailure | 'self' | 'admin' | 'until'>;
|
|
24
|
+
export type UnbanResult = {
|
|
25
|
+
ok: true;
|
|
26
|
+
user: ManagedUser;
|
|
27
|
+
} | AuthFailed<AdminChangeFailure>;
|
|
28
|
+
export type DeleteResult = {
|
|
29
|
+
ok: true;
|
|
30
|
+
} | AuthFailed<AdminChangeFailure | 'self' | 'admin' | 'refused'>;
|
|
31
|
+
export declare function managedUser(record: UserRecord): ManagedUser;
|
|
32
|
+
export declare function actingAdmin(state: RequestState): Promise<UserRecord | null>;
|
|
33
|
+
export declare function changingAdmin(state: RequestState): Promise<{
|
|
34
|
+
ok: true;
|
|
35
|
+
actor: UserRecord;
|
|
36
|
+
} | AuthFailed<'forbidden' | 'two-factor-required' | 'stale'>>;
|
|
37
|
+
export declare function askingAdmin(state: RequestState): Promise<{
|
|
38
|
+
ok: true;
|
|
39
|
+
actor: UserRecord;
|
|
40
|
+
} | AuthFailed<'forbidden' | 'two-factor-required'>>;
|
|
41
|
+
export declare function isAdmin(state: RequestState, record: UserRecord): Promise<boolean>;
|
|
42
|
+
export declare function lastAdmin(state: RequestState, record: UserRecord): Promise<boolean>;
|
|
43
|
+
export declare function stepAside(state: RequestState, record: UserRecord): Promise<{
|
|
44
|
+
restore: () => Promise<void>;
|
|
45
|
+
} | undefined>;
|
|
46
|
+
export type ListUsersResult = {
|
|
47
|
+
ok: true;
|
|
48
|
+
users: ManagedUser[];
|
|
49
|
+
total: number;
|
|
50
|
+
} | AuthFailed<'forbidden' | 'two-factor-required'>;
|
|
51
|
+
export declare function listUsers(state: RequestState, query: {
|
|
52
|
+
search?: string | undefined;
|
|
53
|
+
offset?: number | undefined;
|
|
54
|
+
limit?: number | undefined;
|
|
55
|
+
}): Promise<ListUsersResult>;
|
|
56
|
+
export type GetUserResult = {
|
|
57
|
+
ok: true;
|
|
58
|
+
user: ManagedUser;
|
|
59
|
+
admin: boolean;
|
|
60
|
+
} | AuthFailed<AdminFailure>;
|
|
61
|
+
export declare function getUser(state: RequestState, userId: string): Promise<GetUserResult>;
|
|
62
|
+
export declare function changeRole(state: RequestState, userId: string, role: string, granted: boolean): Promise<RoleResult>;
|
|
63
|
+
export declare function banUser(state: RequestState, userId: string, options: {
|
|
64
|
+
reason?: string | undefined;
|
|
65
|
+
until?: Date | undefined;
|
|
66
|
+
}): Promise<BanResult>;
|
|
67
|
+
export declare function unbanUser(state: RequestState, userId: string): Promise<UnbanResult>;
|
|
68
|
+
export declare function deleteUser(state: RequestState, userId: string): Promise<DeleteResult>;
|
|
69
|
+
export type AdminAuditLogResult = {
|
|
70
|
+
ok: true;
|
|
71
|
+
entries: AuditEntry[];
|
|
72
|
+
} | AuthFailed<'forbidden' | 'two-factor-required'>;
|
|
73
|
+
export declare function adminAuditLog(state: RequestState, query: {
|
|
74
|
+
userId?: string | undefined;
|
|
75
|
+
before?: AuditCursorInput | undefined;
|
|
76
|
+
limit?: number | undefined;
|
|
77
|
+
}): Promise<AdminAuditLogResult>;
|
|
78
|
+
export type ImpersonateResult = {
|
|
79
|
+
ok: true;
|
|
80
|
+
} | AuthFailed<AdminFailure | 'stale' | 'self' | 'admin' | 'banned'>;
|
|
81
|
+
export declare function impersonate(state: RequestState, userId: string): Promise<ImpersonateResult>;
|
|
82
|
+
export declare function stopImpersonating(state: RequestState): Promise<boolean>;
|
|
83
|
+
export declare function endImpersonation(state: RequestState, signedIn: SignedIn, expired?: boolean): Promise<void>;
|
|
84
|
+
//# sourceMappingURL=admin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin.d.ts","sourceRoot":"","sources":["../src/admin.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AuditEntry, AuthEvent } from './events';
|
|
2
|
+
export type AuditPhrase = string | ((detail: string | null) => string);
|
|
3
|
+
export type AuditWording = Record<AuthEvent, AuditPhrase>;
|
|
4
|
+
export declare const auditWording: Record<string, AuditWording>;
|
|
5
|
+
export declare function describeAuditEntry(entry: Pick<AuditEntry, 'event' | 'detail'>, options?: {
|
|
6
|
+
locale?: string | undefined;
|
|
7
|
+
wording?: Partial<AuditWording> | undefined;
|
|
8
|
+
}): string;
|
|
9
|
+
//# sourceMappingURL=auditWording.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auditWording.d.ts","sourceRoot":"","sources":["../src/auditWording.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAIrD,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,KAAK,MAAM,CAAC,CAAA;AAEtE,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,SAAS,EAAE,WAAW,CAAC,CAAA;AAwIzD,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAA+B,CAAA;AAGrF,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,EAAE,OAAO,GAAG,QAAQ,CAAC,EAAE,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,SAAS,CAAA;CAAO,GAAG,MAAM,CAOlL"}
|