@sharadox/account-web-library 0.1.0-development.3 → 0.1.0-development.30
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/README.md +267 -8
- package/distribution/account-activity/index.d.ts +16 -0
- package/distribution/account-activity/index.d.ts.map +1 -0
- package/distribution/account-activity/index.js +18 -0
- package/distribution/account-activity/index.js.map +1 -0
- package/distribution/account-activity/type.d.ts +15 -0
- package/distribution/account-activity/type.d.ts.map +1 -0
- package/distribution/account-activity/type.js.map +1 -0
- package/distribution/account-ban/index.d.ts +67 -0
- package/distribution/account-ban/index.d.ts.map +1 -0
- package/distribution/account-ban/index.js +233 -0
- package/distribution/account-ban/index.js.map +1 -0
- package/distribution/account-ban/type.d.ts +44 -0
- package/distribution/account-ban/type.d.ts.map +1 -0
- package/distribution/account-ban/type.js +2 -0
- package/distribution/account-ban/type.js.map +1 -0
- package/distribution/account-database/type.d.ts +264 -0
- package/distribution/account-database/type.d.ts.map +1 -0
- package/distribution/account-database/type.js +2 -0
- package/distribution/account-database/type.js.map +1 -0
- package/distribution/account-deletion/index.d.ts +21 -0
- package/distribution/account-deletion/index.d.ts.map +1 -0
- package/distribution/account-deletion/index.js +66 -0
- package/distribution/account-deletion/index.js.map +1 -0
- package/distribution/account-export/index.d.ts +17 -0
- package/distribution/account-export/index.d.ts.map +1 -0
- package/distribution/account-export/index.js +87 -0
- package/distribution/account-export/index.js.map +1 -0
- package/distribution/account-export/type.d.ts +40 -0
- package/distribution/account-export/type.d.ts.map +1 -0
- package/distribution/account-export/type.js +2 -0
- package/distribution/account-export/type.js.map +1 -0
- package/distribution/account-inactivity/index.d.ts +25 -0
- package/distribution/account-inactivity/index.d.ts.map +1 -0
- package/distribution/account-inactivity/index.js +100 -0
- package/distribution/account-inactivity/index.js.map +1 -0
- package/distribution/account-migration/index.d.ts +18 -0
- package/distribution/account-migration/index.d.ts.map +1 -0
- package/distribution/account-migration/index.js +376 -0
- package/distribution/account-migration/index.js.map +1 -0
- package/distribution/account-name/index.d.ts +13 -0
- package/distribution/account-name/index.d.ts.map +1 -0
- package/distribution/account-name/index.js +22 -0
- package/distribution/account-name/index.js.map +1 -0
- package/distribution/account-name/type.d.ts +9 -0
- package/distribution/account-name/type.d.ts.map +1 -0
- package/distribution/account-name/type.js +2 -0
- package/distribution/account-name/type.js.map +1 -0
- package/distribution/account-name-change/index.d.ts +15 -0
- package/distribution/account-name-change/index.d.ts.map +1 -0
- package/distribution/account-name-change/index.js +26 -0
- package/distribution/account-name-change/index.js.map +1 -0
- package/distribution/account-name-change/type.d.ts +7 -0
- package/distribution/account-name-change/type.d.ts.map +1 -0
- package/distribution/account-name-change/type.js +2 -0
- package/distribution/account-name-change/type.js.map +1 -0
- package/distribution/account-notice/index.d.ts +15 -0
- package/distribution/account-notice/index.d.ts.map +1 -0
- package/distribution/account-notice/index.js +41 -0
- package/distribution/account-notice/index.js.map +1 -0
- package/distribution/account-permission/index.d.ts +14 -0
- package/distribution/account-permission/index.d.ts.map +1 -0
- package/distribution/account-permission/index.js +91 -0
- package/distribution/account-permission/index.js.map +1 -0
- package/distribution/account-permission/type.d.ts +12 -0
- package/distribution/account-permission/type.d.ts.map +1 -0
- package/distribution/account-permission/type.js +2 -0
- package/distribution/account-permission/type.js.map +1 -0
- package/distribution/account-picture-change/index.d.ts +30 -0
- package/distribution/account-picture-change/index.d.ts.map +1 -0
- package/distribution/account-picture-change/index.js +70 -0
- package/distribution/account-picture-change/index.js.map +1 -0
- package/distribution/account-picture-change/type.d.ts +11 -0
- package/distribution/account-picture-change/type.d.ts.map +1 -0
- package/distribution/account-picture-change/type.js +2 -0
- package/distribution/account-picture-change/type.js.map +1 -0
- package/distribution/account-server/index.d.ts +25 -0
- package/distribution/account-server/index.d.ts.map +1 -0
- package/distribution/account-server/index.js +34 -0
- package/distribution/account-server/index.js.map +1 -0
- package/distribution/account-server/type.d.ts +30 -0
- package/distribution/account-server/type.d.ts.map +1 -0
- package/distribution/account-server/type.js +2 -0
- package/distribution/account-server/type.js.map +1 -0
- package/distribution/account-session-end/index.d.ts +15 -0
- package/distribution/account-session-end/index.d.ts.map +1 -0
- package/distribution/account-session-end/index.js +21 -0
- package/distribution/account-session-end/index.js.map +1 -0
- package/distribution/account-session-list/index.d.ts +16 -0
- package/distribution/account-session-list/index.d.ts.map +1 -0
- package/distribution/account-session-list/index.js +33 -0
- package/distribution/account-session-list/index.js.map +1 -0
- package/distribution/account-session-list/type.d.ts +13 -0
- package/distribution/account-session-list/type.d.ts.map +1 -0
- package/distribution/account-session-list/type.js +2 -0
- package/distribution/account-session-list/type.js.map +1 -0
- package/distribution/account-session-revocation/index.d.ts +14 -0
- package/distribution/account-session-revocation/index.d.ts.map +1 -0
- package/distribution/account-session-revocation/index.js +25 -0
- package/distribution/account-session-revocation/index.js.map +1 -0
- package/distribution/account-sign-in/index.d.ts +15 -0
- package/distribution/account-sign-in/index.d.ts.map +1 -0
- package/distribution/account-sign-in/index.js +78 -0
- package/distribution/account-sign-in/index.js.map +1 -0
- package/distribution/account-sign-in/type.d.ts +22 -0
- package/distribution/account-sign-in/type.d.ts.map +1 -0
- package/distribution/account-sign-in/type.js +2 -0
- package/distribution/account-sign-in/type.js.map +1 -0
- package/distribution/account-sign-out/index.d.ts +16 -0
- package/distribution/account-sign-out/index.d.ts.map +1 -0
- package/distribution/account-sign-out/index.js +34 -0
- package/distribution/account-sign-out/index.js.map +1 -0
- package/distribution/application-sync/index.d.ts +14 -0
- package/distribution/application-sync/index.d.ts.map +1 -0
- package/distribution/application-sync/index.js +96 -0
- package/distribution/application-sync/index.js.map +1 -0
- package/distribution/application-sync/type.d.ts +29 -0
- package/distribution/application-sync/type.d.ts.map +1 -0
- package/distribution/application-sync/type.js +2 -0
- package/distribution/application-sync/type.js.map +1 -0
- package/distribution/audit-event/index.d.ts +12 -0
- package/distribution/audit-event/index.d.ts.map +1 -0
- package/distribution/audit-event/index.js +36 -0
- package/distribution/audit-event/index.js.map +1 -0
- package/distribution/audit-event/type.d.ts +16 -0
- package/distribution/audit-event/type.d.ts.map +1 -0
- package/distribution/audit-event/type.js +2 -0
- package/distribution/audit-event/type.js.map +1 -0
- package/distribution/banned-contact/index.d.ts +34 -0
- package/distribution/banned-contact/index.d.ts.map +1 -0
- package/distribution/banned-contact/index.js +52 -0
- package/distribution/banned-contact/index.js.map +1 -0
- package/distribution/browser-session-read/index.d.ts +17 -0
- package/distribution/browser-session-read/index.d.ts.map +1 -0
- package/distribution/browser-session-read/index.js +52 -0
- package/distribution/browser-session-read/index.js.map +1 -0
- package/distribution/browser-session-read/type.d.ts +18 -0
- package/distribution/browser-session-read/type.d.ts.map +1 -0
- package/distribution/browser-session-read/type.js +2 -0
- package/distribution/browser-session-read/type.js.map +1 -0
- package/distribution/challenge-issue/index.d.ts +13 -0
- package/distribution/challenge-issue/index.d.ts.map +1 -0
- package/distribution/challenge-issue/index.js +18 -0
- package/distribution/challenge-issue/index.js.map +1 -0
- package/distribution/code-request/index.d.ts +16 -0
- package/distribution/code-request/index.d.ts.map +1 -0
- package/distribution/code-request/index.js +52 -0
- package/distribution/code-request/index.js.map +1 -0
- package/distribution/code-request/type.d.ts +25 -0
- package/distribution/code-request/type.d.ts.map +1 -0
- package/distribution/code-request/type.js +2 -0
- package/distribution/code-request/type.js.map +1 -0
- package/distribution/code-request-prune/index.d.ts +13 -0
- package/distribution/code-request-prune/index.d.ts.map +1 -0
- package/distribution/code-request-prune/index.js +12 -0
- package/distribution/code-request-prune/index.js.map +1 -0
- package/distribution/code-sending/index.d.ts +14 -0
- package/distribution/code-sending/index.d.ts.map +1 -0
- package/distribution/code-sending/index.js +65 -0
- package/distribution/code-sending/index.js.map +1 -0
- package/distribution/code-sending/type.d.ts +31 -0
- package/distribution/code-sending/type.d.ts.map +1 -0
- package/distribution/code-sending/type.js +2 -0
- package/distribution/code-sending/type.js.map +1 -0
- package/distribution/code-verification/index.d.ts +14 -0
- package/distribution/code-verification/index.d.ts.map +1 -0
- package/distribution/code-verification/index.js +43 -0
- package/distribution/code-verification/index.js.map +1 -0
- package/distribution/code-verification/type.d.ts +22 -0
- package/distribution/code-verification/type.d.ts.map +1 -0
- package/distribution/code-verification/type.js +2 -0
- package/distribution/code-verification/type.js.map +1 -0
- package/distribution/contact-addition/index.d.ts +13 -0
- package/distribution/contact-addition/index.d.ts.map +1 -0
- package/distribution/contact-addition/index.js +48 -0
- package/distribution/contact-addition/index.js.map +1 -0
- package/distribution/contact-addition/type.d.ts +15 -0
- package/distribution/contact-addition/type.d.ts.map +1 -0
- package/distribution/contact-addition/type.js +2 -0
- package/distribution/contact-addition/type.js.map +1 -0
- package/distribution/contact-addition-flow/index.d.ts +32 -0
- package/distribution/contact-addition-flow/index.d.ts.map +1 -0
- package/distribution/contact-addition-flow/index.js +96 -0
- package/distribution/contact-addition-flow/index.js.map +1 -0
- package/distribution/contact-addition-flow/type.d.ts +25 -0
- package/distribution/contact-addition-flow/type.d.ts.map +1 -0
- package/distribution/contact-addition-flow/type.js +2 -0
- package/distribution/contact-addition-flow/type.js.map +1 -0
- package/distribution/contact-channel/type.d.ts +44 -0
- package/distribution/contact-channel/type.d.ts.map +1 -0
- package/distribution/contact-channel/type.js +2 -0
- package/distribution/contact-channel/type.js.map +1 -0
- package/distribution/contact-kind/index.d.ts +12 -0
- package/distribution/contact-kind/index.d.ts.map +1 -0
- package/distribution/contact-kind/index.js +18 -0
- package/distribution/contact-kind/index.js.map +1 -0
- package/distribution/contact-kind/type.d.ts +6 -0
- package/distribution/contact-kind/type.d.ts.map +1 -0
- package/distribution/contact-kind/type.js +2 -0
- package/distribution/contact-kind/type.js.map +1 -0
- package/distribution/contact-lookup/index.d.ts +16 -0
- package/distribution/contact-lookup/index.d.ts.map +1 -0
- package/distribution/contact-lookup/index.js +20 -0
- package/distribution/contact-lookup/index.js.map +1 -0
- package/distribution/contact-removal/index.d.ts +19 -0
- package/distribution/contact-removal/index.d.ts.map +1 -0
- package/distribution/contact-removal/index.js +35 -0
- package/distribution/contact-removal/index.js.map +1 -0
- package/distribution/contact-verification/index.d.ts +20 -0
- package/distribution/contact-verification/index.d.ts.map +1 -0
- package/distribution/contact-verification/index.js +37 -0
- package/distribution/contact-verification/index.js.map +1 -0
- package/distribution/database-error/index.d.ts +12 -0
- package/distribution/database-error/index.d.ts.map +1 -0
- package/distribution/database-error/index.js +14 -0
- package/distribution/database-error/index.js.map +1 -0
- package/distribution/email-channel/index.d.ts +13 -0
- package/distribution/email-channel/index.d.ts.map +1 -0
- package/distribution/email-channel/index.js +168 -0
- package/distribution/email-channel/index.js.map +1 -0
- package/distribution/email-channel/type.d.ts +17 -0
- package/distribution/email-channel/type.d.ts.map +1 -0
- package/distribution/email-channel/type.js +2 -0
- package/distribution/email-channel/type.js.map +1 -0
- package/distribution/identifier/index.d.ts +23 -0
- package/distribution/identifier/index.d.ts.map +1 -0
- package/distribution/identifier/index.js +32 -0
- package/distribution/identifier/index.js.map +1 -0
- package/distribution/identifier/type.d.ts +10 -0
- package/distribution/identifier/type.d.ts.map +1 -0
- package/distribution/identifier/type.js +2 -0
- package/distribution/identifier/type.js.map +1 -0
- package/distribution/identifier-availability/index.d.ts +11 -0
- package/distribution/identifier-availability/index.d.ts.map +1 -0
- package/distribution/identifier-availability/index.js +21 -0
- package/distribution/identifier-availability/index.js.map +1 -0
- package/distribution/identifier-change/index.d.ts +15 -0
- package/distribution/identifier-change/index.d.ts.map +1 -0
- package/distribution/identifier-change/index.js +43 -0
- package/distribution/identifier-change/index.js.map +1 -0
- package/distribution/identifier-change/type.d.ts +7 -0
- package/distribution/identifier-change/type.d.ts.map +1 -0
- package/distribution/identifier-change/type.js +2 -0
- package/distribution/identifier-change/type.js.map +1 -0
- package/distribution/memory-picture-storage/index.d.ts +15 -0
- package/distribution/memory-picture-storage/index.d.ts.map +1 -0
- package/distribution/memory-picture-storage/index.js +16 -0
- package/distribution/memory-picture-storage/index.js.map +1 -0
- package/distribution/one-time-code/index.d.ts +2 -2
- package/distribution/one-time-code/index.js +3 -3
- package/distribution/person-account/index.d.ts +18 -0
- package/distribution/person-account/index.d.ts.map +1 -0
- package/distribution/person-account/index.js +65 -0
- package/distribution/person-account/index.js.map +1 -0
- package/distribution/person-account/type.d.ts +22 -0
- package/distribution/person-account/type.d.ts.map +1 -0
- package/distribution/person-account/type.js +2 -0
- package/distribution/person-account/type.js.map +1 -0
- package/distribution/picture-key/index.d.ts +8 -0
- package/distribution/picture-key/index.d.ts.map +1 -0
- package/distribution/picture-key/index.js +10 -0
- package/distribution/picture-key/index.js.map +1 -0
- package/distribution/picture-preparation/index.d.ts +18 -0
- package/distribution/picture-preparation/index.d.ts.map +1 -0
- package/distribution/picture-preparation/index.js +86 -0
- package/distribution/picture-preparation/index.js.map +1 -0
- package/distribution/picture-preparation/type.d.ts +18 -0
- package/distribution/picture-preparation/type.d.ts.map +1 -0
- package/distribution/picture-preparation/type.js +2 -0
- package/distribution/picture-preparation/type.js.map +1 -0
- package/distribution/picture-storage/type.d.ts +11 -0
- package/distribution/picture-storage/type.d.ts.map +1 -0
- package/distribution/picture-storage/type.js +2 -0
- package/distribution/picture-storage/type.js.map +1 -0
- package/distribution/recovery-code-regeneration/index.d.ts +19 -0
- package/distribution/recovery-code-regeneration/index.d.ts.map +1 -0
- package/distribution/recovery-code-regeneration/index.js +34 -0
- package/distribution/recovery-code-regeneration/index.js.map +1 -0
- package/distribution/recovery-code-store/index.d.ts +25 -0
- package/distribution/recovery-code-store/index.d.ts.map +1 -0
- package/distribution/recovery-code-store/index.js +34 -0
- package/distribution/recovery-code-store/index.js.map +1 -0
- package/distribution/role-grant/index.d.ts +38 -0
- package/distribution/role-grant/index.d.ts.map +1 -0
- package/distribution/role-grant/index.js +142 -0
- package/distribution/role-grant/index.js.map +1 -0
- package/distribution/role-grant/type.d.ts +40 -0
- package/distribution/role-grant/type.d.ts.map +1 -0
- package/distribution/role-grant/type.js +2 -0
- package/distribution/role-grant/type.js.map +1 -0
- package/distribution/rule-sync/index.d.ts +28 -0
- package/distribution/rule-sync/index.d.ts.map +1 -0
- package/distribution/rule-sync/index.js +80 -0
- package/distribution/rule-sync/index.js.map +1 -0
- package/distribution/rule-sync/type.d.ts +17 -0
- package/distribution/rule-sync/type.d.ts.map +1 -0
- package/distribution/rule-sync/type.js +2 -0
- package/distribution/rule-sync/type.js.map +1 -0
- package/distribution/second-factor-finish/index.d.ts +13 -0
- package/distribution/second-factor-finish/index.d.ts.map +1 -0
- package/distribution/second-factor-finish/index.js +83 -0
- package/distribution/second-factor-finish/index.js.map +1 -0
- package/distribution/second-factor-finish/type.d.ts +30 -0
- package/distribution/second-factor-finish/type.d.ts.map +1 -0
- package/distribution/second-factor-finish/type.js +2 -0
- package/distribution/second-factor-finish/type.js.map +1 -0
- package/distribution/secret-derivation/index.d.ts +10 -0
- package/distribution/secret-derivation/index.d.ts.map +1 -0
- package/distribution/secret-derivation/index.js +15 -0
- package/distribution/secret-derivation/index.js.map +1 -0
- package/distribution/secret-encryption/index.d.ts +17 -0
- package/distribution/secret-encryption/index.d.ts.map +1 -0
- package/distribution/secret-encryption/index.js +37 -0
- package/distribution/secret-encryption/index.js.map +1 -0
- package/distribution/session-prune/index.d.ts +17 -0
- package/distribution/session-prune/index.d.ts.map +1 -0
- package/distribution/session-prune/index.js +30 -0
- package/distribution/session-prune/index.js.map +1 -0
- package/distribution/session-token/index.d.ts +19 -0
- package/distribution/session-token/index.d.ts.map +1 -0
- package/distribution/session-token/index.js +22 -0
- package/distribution/session-token/index.js.map +1 -0
- package/distribution/sign-in-finish/index.d.ts +12 -0
- package/distribution/sign-in-finish/index.d.ts.map +1 -0
- package/distribution/sign-in-finish/index.js +64 -0
- package/distribution/sign-in-finish/index.js.map +1 -0
- package/distribution/sign-in-finish/type.d.ts +41 -0
- package/distribution/sign-in-finish/type.d.ts.map +1 -0
- package/distribution/sign-in-finish/type.js +2 -0
- package/distribution/sign-in-finish/type.js.map +1 -0
- package/distribution/sign-in-start/index.d.ts +17 -0
- package/distribution/sign-in-start/index.d.ts.map +1 -0
- package/distribution/sign-in-start/index.js +45 -0
- package/distribution/sign-in-start/index.js.map +1 -0
- package/distribution/sign-in-start/type.d.ts +34 -0
- package/distribution/sign-in-start/type.d.ts.map +1 -0
- package/distribution/sign-in-start/type.js +2 -0
- package/distribution/sign-in-start/type.js.map +1 -0
- package/distribution/sign-up-finish/index.d.ts +13 -0
- package/distribution/sign-up-finish/index.d.ts.map +1 -0
- package/distribution/sign-up-finish/index.js +38 -0
- package/distribution/sign-up-finish/index.js.map +1 -0
- package/distribution/sign-up-finish/type.d.ts +28 -0
- package/distribution/sign-up-finish/type.d.ts.map +1 -0
- package/distribution/sign-up-finish/type.js +2 -0
- package/distribution/sign-up-finish/type.js.map +1 -0
- package/distribution/signed-ticket/index.d.ts +19 -0
- package/distribution/signed-ticket/index.d.ts.map +1 -0
- package/distribution/signed-ticket/index.js +35 -0
- package/distribution/signed-ticket/index.js.map +1 -0
- package/distribution/signed-ticket/type.d.ts +16 -0
- package/distribution/signed-ticket/type.d.ts.map +1 -0
- package/distribution/signed-ticket/type.js +2 -0
- package/distribution/signed-ticket/type.js.map +1 -0
- package/distribution/step-up/index.d.ts +48 -0
- package/distribution/step-up/index.d.ts.map +1 -0
- package/distribution/step-up/index.js +83 -0
- package/distribution/step-up/index.js.map +1 -0
- package/distribution/step-up/type.d.ts +15 -0
- package/distribution/step-up/type.d.ts.map +1 -0
- package/distribution/step-up/type.js +2 -0
- package/distribution/{username → step-up}/type.js.map +1 -1
- package/distribution/test-database/index.d.ts +13 -0
- package/distribution/test-database/index.d.ts.map +1 -0
- package/distribution/test-database/index.js +17 -0
- package/distribution/test-database/index.js.map +1 -0
- package/distribution/test-person/index.d.ts +14 -0
- package/distribution/test-person/index.d.ts.map +1 -0
- package/distribution/test-person/index.js +20 -0
- package/distribution/test-person/index.js.map +1 -0
- package/distribution/test-server/index.d.ts +10 -0
- package/distribution/test-server/index.d.ts.map +1 -0
- package/distribution/test-server/index.js +16 -0
- package/distribution/test-server/index.js.map +1 -0
- package/distribution/totp/type.d.ts +1 -1
- package/distribution/totp/type.d.ts.map +1 -1
- package/distribution/totp-setup/index.d.ts +50 -0
- package/distribution/totp-setup/index.d.ts.map +1 -0
- package/distribution/totp-setup/index.js +136 -0
- package/distribution/totp-setup/index.js.map +1 -0
- package/distribution/totp-setup/type.d.ts +24 -0
- package/distribution/totp-setup/type.d.ts.map +1 -0
- package/distribution/totp-setup/type.js +2 -0
- package/distribution/totp-setup/type.js.map +1 -0
- package/package.json +9 -2
- package/distribution/username/index.d.ts +0 -23
- package/distribution/username/index.d.ts.map +0 -1
- package/distribution/username/index.js +0 -32
- package/distribution/username/index.js.map +0 -1
- package/distribution/username/type.d.ts +0 -10
- package/distribution/username/type.d.ts.map +0 -1
- /package/distribution/{username → account-activity}/type.js +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../source/person-account/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iDAAiD,CAAC;AAE/E,MAAM,WAAW,oBAAoB;IACnC,mDAAmD;IACnD,IAAI,EAAE,MAAM,CAAC;IACb,2CAA2C;IAC3C,UAAU,EAAE,MAAM,CAAC;IACnB,gEAAgE;IAChE,OAAO,EAAE,OAAO,CAAC;IACjB,wEAAwE;IACxE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gDAAgD;IAChD,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,MAAM,mBAAmB,GAC3B;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GACvD;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,cAAc,GAAG,oBAAoB,GAAG,kBAAkB,GAAG,eAAe,CAAA;CAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../source/person-account/type.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The storage key of an account picture's file: `account-picture/<id>.webp` (every picture is stored as WebP).
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* pictureKey("0198f5a2-…"); // "account-picture/0198f5a2-….webp"
|
|
6
|
+
*/
|
|
7
|
+
export declare function pictureKey(pictureId: string): string;
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/picture-key/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEpD"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The storage key of an account picture's file: `account-picture/<id>.webp` (every picture is stored as WebP).
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* pictureKey("0198f5a2-…"); // "account-picture/0198f5a2-….webp"
|
|
6
|
+
*/
|
|
7
|
+
export function pictureKey(pictureId) {
|
|
8
|
+
return `account-picture/${pictureId}.webp`;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/picture-key/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,SAAiB;IAC1C,OAAO,mBAAmB,SAAS,OAAO,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { PreparedPicture } from "@sharadox/account-web-library/picture-preparation/type";
|
|
2
|
+
/** The largest file accepted: 5 MB. */
|
|
3
|
+
export declare const PICTURE_MAXIMUM_BYTES: number;
|
|
4
|
+
/** The widest and tallest picture accepted, in pixels. */
|
|
5
|
+
export declare const PICTURE_MAXIMUM_DIMENSION = 4096;
|
|
6
|
+
/**
|
|
7
|
+
* Checks an uploaded picture and makes the file to store: always WebP, at most 1024 pixels on its longer side,
|
|
8
|
+
* rotated as the photo says, with every piece of metadata (a photo's location, camera, comments) dropped. A GIF
|
|
9
|
+
* keeps its animation. An SVG is drawn into an image, so no script or link in it can ever run. Refuses files over
|
|
10
|
+
* 5 MB or 4096 pixels, files far bigger than their picture needs (something else is hidden in them), and SVGs that
|
|
11
|
+
* load anything from outside themselves.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* const picture = await preparePicture(new Uint8Array(await file.arrayBuffer()));
|
|
15
|
+
* if (!picture.valid) return explain(picture.reason);
|
|
16
|
+
*/
|
|
17
|
+
export declare function preparePicture(bytes: Uint8Array): Promise<PreparedPicture>;
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/picture-preparation/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wDAAwD,CAAC;AAE9F,uCAAuC;AACvC,eAAO,MAAM,qBAAqB,QAAkB,CAAC;AACrD,0DAA0D;AAC1D,eAAO,MAAM,yBAAyB,OAAO,CAAC;AA+B9C;;;;;;;;;;GAUG;AACH,wBAAsB,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,eAAe,CAAC,CA8BhF"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import sharp from "sharp";
|
|
2
|
+
/** The largest file accepted: 5 MB. */
|
|
3
|
+
export const PICTURE_MAXIMUM_BYTES = 5 * 1024 * 1024;
|
|
4
|
+
/** The widest and tallest picture accepted, in pixels. */
|
|
5
|
+
export const PICTURE_MAXIMUM_DIMENSION = 4096;
|
|
6
|
+
/** Stored pictures are at most this many pixels on their longer side. */
|
|
7
|
+
const STORED_DIMENSION = 1024;
|
|
8
|
+
/** Slack for headers, color profiles and palettes when judging whether a file is bigger than its picture. */
|
|
9
|
+
const OVERHEAD_BYTES = 64 * 1024;
|
|
10
|
+
const startsWith = (bytes, text, offset = 0) => Buffer.from(bytes.subarray(offset, offset + text.length)).toString("latin1") === text;
|
|
11
|
+
function kind(bytes) {
|
|
12
|
+
if (bytes[0] === 0xff && bytes[1] === 0xd8 && bytes[2] === 0xff)
|
|
13
|
+
return "raster";
|
|
14
|
+
if (startsWith(bytes, "\x89PNG\r\n\x1a\n") || startsWith(bytes, "GIF8"))
|
|
15
|
+
return "raster";
|
|
16
|
+
if (startsWith(bytes, "RIFF") && startsWith(bytes, "WEBP", 8))
|
|
17
|
+
return "raster";
|
|
18
|
+
if (startsWith(bytes, "ftypavi", 4))
|
|
19
|
+
return "raster";
|
|
20
|
+
const text = new TextDecoder()
|
|
21
|
+
.decode(bytes.subarray(0, 1024))
|
|
22
|
+
.replace(/^\uFEFF/u, "")
|
|
23
|
+
.trimStart();
|
|
24
|
+
if ((text.startsWith("<?xml") || text.startsWith("<svg")) && text.includes("<svg"))
|
|
25
|
+
return "svg";
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
/** References an SVG may make: only to itself (`#id`) or to pictures inside it (`data:image/…`). */
|
|
29
|
+
function unsafeSvg(text) {
|
|
30
|
+
if (/<!(DOCTYPE|ENTITY)/i.test(text))
|
|
31
|
+
return true;
|
|
32
|
+
if (/@import|url\(\s*['"]?(?!#|data:image\/)/i.test(text))
|
|
33
|
+
return true;
|
|
34
|
+
for (const [, value] of text.matchAll(/(?:href|src)\s*=\s*["']([^"']*)["']/gi))
|
|
35
|
+
if (!value.startsWith("#") && !/^data:image\/(png|jpeg|gif|webp);/i.test(value))
|
|
36
|
+
return true;
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Checks an uploaded picture and makes the file to store: always WebP, at most 1024 pixels on its longer side,
|
|
41
|
+
* rotated as the photo says, with every piece of metadata (a photo's location, camera, comments) dropped. A GIF
|
|
42
|
+
* keeps its animation. An SVG is drawn into an image, so no script or link in it can ever run. Refuses files over
|
|
43
|
+
* 5 MB or 4096 pixels, files far bigger than their picture needs (something else is hidden in them), and SVGs that
|
|
44
|
+
* load anything from outside themselves.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* const picture = await preparePicture(new Uint8Array(await file.arrayBuffer()));
|
|
48
|
+
* if (!picture.valid) return explain(picture.reason);
|
|
49
|
+
*/
|
|
50
|
+
export async function preparePicture(bytes) {
|
|
51
|
+
if (bytes.length > PICTURE_MAXIMUM_BYTES)
|
|
52
|
+
return { valid: false, reason: "size" };
|
|
53
|
+
const type = kind(bytes);
|
|
54
|
+
if (!type)
|
|
55
|
+
return { valid: false, reason: "type" };
|
|
56
|
+
if (type === "svg" && unsafeSvg(new TextDecoder().decode(bytes)))
|
|
57
|
+
return { valid: false, reason: "unsafe" };
|
|
58
|
+
const options = { animated: true, limitInputPixels: PICTURE_MAXIMUM_DIMENSION ** 2 * 4 };
|
|
59
|
+
let metadata;
|
|
60
|
+
try {
|
|
61
|
+
metadata = await sharp(bytes, options).metadata();
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
return { valid: false, reason: "type" };
|
|
65
|
+
}
|
|
66
|
+
const width = metadata.width;
|
|
67
|
+
const height = metadata.pageHeight ?? metadata.height;
|
|
68
|
+
if (width > PICTURE_MAXIMUM_DIMENSION || height > PICTURE_MAXIMUM_DIMENSION)
|
|
69
|
+
return { valid: false, reason: "dimensions" };
|
|
70
|
+
if (type === "raster" && bytes.length > width * height * (metadata.pages ?? 1) * 4 + OVERHEAD_BYTES)
|
|
71
|
+
return { valid: false, reason: "suspicious" };
|
|
72
|
+
// An SVG is drawn large enough for its longer side to fill the stored size, however small it says it is.
|
|
73
|
+
const density = type === "svg" ? Math.min(2400, (72 * STORED_DIMENSION) / Math.max(width, height)) : undefined;
|
|
74
|
+
try {
|
|
75
|
+
const { data, info } = await sharp(bytes, { ...options, ...(density ? { density } : {}) })
|
|
76
|
+
.rotate()
|
|
77
|
+
.resize({ width: STORED_DIMENSION, height: STORED_DIMENSION, fit: "inside", withoutEnlargement: !density })
|
|
78
|
+
.webp({ quality: 85 })
|
|
79
|
+
.toBuffer({ resolveWithObject: true });
|
|
80
|
+
return { valid: true, bytes: new Uint8Array(data), width: info.width, height: info.pageHeight ?? info.height };
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
return { valid: false, reason: "type" };
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/picture-preparation/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,uCAAuC;AACvC,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AACrD,0DAA0D;AAC1D,MAAM,CAAC,MAAM,yBAAyB,GAAG,IAAI,CAAC;AAC9C,yEAAyE;AACzE,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAC9B,6GAA6G;AAC7G,MAAM,cAAc,GAAG,EAAE,GAAG,IAAI,CAAC;AAEjC,MAAM,UAAU,GAAG,CAAC,KAAiB,EAAE,IAAY,EAAE,MAAM,GAAG,CAAC,EAAE,EAAE,CACjE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC;AAExF,SAAS,IAAI,CAAC,KAAiB;IAC7B,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,IAAI;QAAE,OAAO,QAAQ,CAAC;IACjF,IAAI,UAAU,CA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+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
} | {
|
|
8
|
+
valid: false;
|
|
9
|
+
/**
|
|
10
|
+
* - `size`: over 5 MB;
|
|
11
|
+
* - `type`: not a JPEG, PNG, GIF, WebP, AVIF or SVG, or broken;
|
|
12
|
+
* - `dimensions`: wider or taller than 4096 pixels;
|
|
13
|
+
* - `suspicious`: far more bytes than its picture needs (something else is hidden in it);
|
|
14
|
+
* - `unsafe`: an SVG that loads something from outside itself or declares entities.
|
|
15
|
+
*/
|
|
16
|
+
reason: "size" | "type" | "dimensions" | "suspicious" | "unsafe";
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../source/picture-preparation/type.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,MAAM,MAAM,eAAe,GACvB;IAAE,KAAK,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,UAAU,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACjE;IACE,KAAK,EAAE,KAAK,CAAC;IACb;;;;;;OAMG;IACH,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,YAAY,GAAG,YAAY,GAAG,QAAQ,CAAC;CAClE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../source/picture-preparation/type.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where picture files live (object storage such as S3): the database keeps only each picture's id and size. The
|
|
3
|
+
* application gives an implementation; tests use `createMemoryPictureStorage`.
|
|
4
|
+
*/
|
|
5
|
+
export interface PictureStorage {
|
|
6
|
+
/** Stores a file under `key`, replacing any file there. */
|
|
7
|
+
put(key: string, bytes: Uint8Array, contentType: string): Promise<void>;
|
|
8
|
+
/** Deletes the file under `key`; a missing file is not an error. */
|
|
9
|
+
remove(key: string): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../source/picture-storage/type.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,2DAA2D;IAC3D,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxE,oEAAoE;IACpE,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACpC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../source/picture-storage/type.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AccountServer } from "@sharadox/account-web-library/account-server/type";
|
|
2
|
+
/**
|
|
3
|
+
* Makes 10 new recovery codes, voiding the old ones, for an account with two-factor on. Show them once. Ask for a
|
|
4
|
+
* fresh code first (step-up).
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* const result = await regenerateRecoveryCodes(server, { accountId });
|
|
8
|
+
* if (result.status === "made") show(result.recoveryCodes);
|
|
9
|
+
*/
|
|
10
|
+
export declare function regenerateRecoveryCodes(server: AccountServer, { accountId, now }: {
|
|
11
|
+
accountId: string;
|
|
12
|
+
now?: number;
|
|
13
|
+
}): Promise<{
|
|
14
|
+
status: "made";
|
|
15
|
+
recoveryCodes: string[];
|
|
16
|
+
} | {
|
|
17
|
+
status: "second-factor-off";
|
|
18
|
+
}>;
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/recovery-code-regeneration/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mDAAmD,CAAC;AAKvF;;;;;;;GAOG;AACH,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,aAAa,EACrB,EAAE,SAAS,EAAE,GAAgB,EAAE,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GACnE,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,EAAE,CAAA;CAAE,GAAG;IAAE,MAAM,EAAE,mBAAmB,CAAA;CAAE,CAAC,CAmBxF"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { accountTables } from "@sharadox/account-web-library/account-server";
|
|
2
|
+
import { recordAuditEvent } from "@sharadox/account-web-library/audit-event";
|
|
3
|
+
import { replaceRecoveryCodes } from "@sharadox/account-web-library/recovery-code-store";
|
|
4
|
+
import { deriveSecret } from "@sharadox/account-web-library/secret-derivation";
|
|
5
|
+
/**
|
|
6
|
+
* Makes 10 new recovery codes, voiding the old ones, for an account with two-factor on. Show them once. Ask for a
|
|
7
|
+
* fresh code first (step-up).
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* const result = await regenerateRecoveryCodes(server, { accountId });
|
|
11
|
+
* if (result.status === "made") show(result.recoveryCodes);
|
|
12
|
+
*/
|
|
13
|
+
export async function regenerateRecoveryCodes(server, { accountId, now = Date.now() }) {
|
|
14
|
+
return accountTables(server)
|
|
15
|
+
.transaction()
|
|
16
|
+
.execute(async (transaction) => {
|
|
17
|
+
const on = await transaction
|
|
18
|
+
.selectFrom("totp_credential")
|
|
19
|
+
.select("id")
|
|
20
|
+
.where("account_id", "=", accountId)
|
|
21
|
+
.where("confirmed_at", "is not", null)
|
|
22
|
+
.executeTakeFirst();
|
|
23
|
+
if (!on)
|
|
24
|
+
return { status: "second-factor-off" };
|
|
25
|
+
const recoveryCodes = await replaceRecoveryCodes(transaction, {
|
|
26
|
+
accountId,
|
|
27
|
+
pepper: deriveSecret(server.secret, "recovery-code"),
|
|
28
|
+
now,
|
|
29
|
+
});
|
|
30
|
+
await recordAuditEvent(transaction, { accountId, action: "second-factor.recovery-codes-made", now });
|
|
31
|
+
return { status: "made", recoveryCodes };
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/recovery-code-regeneration/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,8CAA8C,CAAC;AAE7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAC7E,OAAO,EAAE,oBAAoB,EAAE,MAAM,mDAAmD,CAAC;AACzF,OAAO,EAAE,YAAY,EAAE,MAAM,iDAAiD,CAAC;AAE/E;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,MAAqB,EACrB,EAAE,SAAS,EAAE,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,EAAuC;IAEpE,OAAO,aAAa,CAAC,MAAM,CAAC;SACzB,WAAW,EAAE;SACb,OAAO,CAAC,KAAK,EAAE,WAAW,EAAE,EAAE;QAC7B,MAAM,EAAE,GAAG,MAAM,WAAW;aACzB,UAAU,CAAC,iBAAiB,CAAC;aAC7B,MAAM,CAAC,IAAI,CAAC;aACZ,KAAK,CAAC,YAAY,EAAE,GAAG,EAAE,SAAS,CAAC;aACnC,KAAK,CAAC,cAAc,EAAE,QAAQ,EAAE,IAAI,CAAC;aACrC,gBAAgB,EAAE,CAAC;QACtB,IAAI,CAAC,EAAE;YAAE,OAAO,EAAE,MAAM,EAAE,mBAA4B,EAAE,CAAC;QACzD,MAAM,aAAa,GAAG,MAAM,oBAAoB,CAAC,WAAW,EAAE;YAC5D,SAAS;YACT,MAAM,EAAE,YAAY,CAAC,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC;YACpD,GAAG;SACJ,CAAC,CAAC;QACH,MAAM,gBAAgB,CAAC,WAAW,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,mCAAmC,EAAE,GAAG,EAAE,CAAC,CAAC;QACrG,OAAO,EAAE,MAAM,EAAE,MAAe,EAAE,aAAa,EAAE,CAAC;IACpD,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Kysely } from "kysely";
|
|
2
|
+
import type { AccountDatabase } from "@sharadox/account-web-library/account-database/type";
|
|
3
|
+
/**
|
|
4
|
+
* The stored form of a recovery code: an HMAC bound to its account, never the code.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* const hash = recoveryCodeHash(typed, { accountId, pepper });
|
|
8
|
+
*/
|
|
9
|
+
export declare function recoveryCodeHash(code: string, { accountId, pepper }: {
|
|
10
|
+
accountId: string;
|
|
11
|
+
pepper: string;
|
|
12
|
+
}): string;
|
|
13
|
+
/**
|
|
14
|
+
* Replaces an account's recovery codes with 10 new ones (inside the caller's transaction) and returns them, to show
|
|
15
|
+
* once. Old codes stop working.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* const codes = await replaceRecoveryCodes(transaction, { accountId, pepper });
|
|
19
|
+
*/
|
|
20
|
+
export declare function replaceRecoveryCodes(database: Kysely<AccountDatabase>, { accountId, pepper, now }: {
|
|
21
|
+
accountId: string;
|
|
22
|
+
pepper: string;
|
|
23
|
+
now?: number;
|
|
24
|
+
}): Promise<string[]>;
|
|
25
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/recovery-code-store/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qDAAqD,CAAC;AAI3F;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAEnH;AAED;;;;;;GAMG;AACH,wBAAsB,oBAAoB,CACxC,QAAQ,EAAE,MAAM,CAAC,eAAe,CAAC,EACjC,EAAE,SAAS,EAAE,MAAM,EAAE,GAAgB,EAAE,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAC3F,OAAO,CAAC,MAAM,EAAE,CAAC,CAenB"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { uuidVersion7 } from "@sharadox/web-library/identifier/uuid-version-7";
|
|
2
|
+
import { hashOneTimeCode } from "@sharadox/account-web-library/one-time-code";
|
|
3
|
+
import { createRecoveryCodes, normalizeRecoveryCode } from "@sharadox/account-web-library/recovery-code";
|
|
4
|
+
/**
|
|
5
|
+
* The stored form of a recovery code: an HMAC bound to its account, never the code.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* const hash = recoveryCodeHash(typed, { accountId, pepper });
|
|
9
|
+
*/
|
|
10
|
+
export function recoveryCodeHash(code, { accountId, pepper }) {
|
|
11
|
+
return hashOneTimeCode(normalizeRecoveryCode(code), { pepper, purpose: `recovery:${accountId}` });
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Replaces an account's recovery codes with 10 new ones (inside the caller's transaction) and returns them, to show
|
|
15
|
+
* once. Old codes stop working.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* const codes = await replaceRecoveryCodes(transaction, { accountId, pepper });
|
|
19
|
+
*/
|
|
20
|
+
export async function replaceRecoveryCodes(database, { accountId, pepper, now = Date.now() }) {
|
|
21
|
+
const codes = createRecoveryCodes();
|
|
22
|
+
await database.deleteFrom("recovery_code").where("account_id", "=", accountId).execute();
|
|
23
|
+
await database
|
|
24
|
+
.insertInto("recovery_code")
|
|
25
|
+
.values(codes.map((code) => ({
|
|
26
|
+
id: uuidVersion7({ now }),
|
|
27
|
+
account_id: accountId,
|
|
28
|
+
code_hash: recoveryCodeHash(code, { accountId, pepper }),
|
|
29
|
+
created_at: new Date(now),
|
|
30
|
+
})))
|
|
31
|
+
.execute();
|
|
32
|
+
return codes;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/recovery-code-store/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,iDAAiD,CAAC;AAE/E,OAAO,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AAC9E,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAC;AAEzG;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY,EAAE,EAAE,SAAS,EAAE,MAAM,EAAyC;IACzG,OAAO,eAAe,CAAC,qBAAqB,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,SAAS,EAAE,EAAE,CAAC,CAAC;AACpG,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,QAAiC,EACjC,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,EAAuD;IAE5F,MAAM,KAAK,GAAG,mBAAmB,EAAE,CAAC;IACpC,MAAM,QAAQ,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC,KAAK,CAAC,YAAY,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC,OAAO,EAAE,CAAC;IACzF,MAAM,QAAQ;SACX,UAAU,CAAC,eAAe,CAAC;SAC3B,MAAM,CACL,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACnB,EAAE,EAAE,YAAY,CAAC,EAAE,GAAG,EAAE,CAAC;QACzB,UAAU,EAAE,SAAS;QACrB,SAAS,EAAE,gBAAgB,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC;QACxD,UAAU,EAAE,IAAI,IAAI,CAAC,GAAG,CAAC;KAC1B,CAAC,CAAC,CACJ;SACA,OAAO,EAAE,CAAC;IACb,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Kysely } from "kysely";
|
|
2
|
+
import type { AccountDatabase } from "@sharadox/account-web-library/account-database/type";
|
|
3
|
+
import type { GrantView, RoleGrantRequest, RoleGrantResult } from "@sharadox/account-web-library/role-grant/type";
|
|
4
|
+
/** The permission that lets an account give roles, in the account system's own application. */
|
|
5
|
+
export declare const ROLE_ASSIGN_PERMISSION = "account.role.assign";
|
|
6
|
+
/**
|
|
7
|
+
* Gives an account a role in an application, maybe for one resource and a time. Given by someone (`grantedBy`), it
|
|
8
|
+
* needs their `account.role.assign` and every permission the role has, there: nobody hands out more than they hold.
|
|
9
|
+
* Recorded in the audit log.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* await grantRole(database, { accountId, application: "platform", role: "manager", grantedBy: admin });
|
|
13
|
+
*/
|
|
14
|
+
export declare function grantRole(database: Kysely<AccountDatabase>, { accountId, application, role, resource, startsAt, endsAt, source, grantedBy, reason, now, }: RoleGrantRequest): Promise<RoleGrantResult>;
|
|
15
|
+
/**
|
|
16
|
+
* Ends a grant now (a grant not started yet goes), keeping its history. Recorded in the audit log.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* await revokeGrant(database, { grantId, revokedBy: admin }); // { revoked: true }
|
|
20
|
+
*/
|
|
21
|
+
export declare function revokeGrant(database: Kysely<AccountDatabase>, { grantId, revokedBy, now }: {
|
|
22
|
+
grantId: string;
|
|
23
|
+
revokedBy?: string;
|
|
24
|
+
now?: number;
|
|
25
|
+
}): Promise<{
|
|
26
|
+
revoked: boolean;
|
|
27
|
+
}>;
|
|
28
|
+
/**
|
|
29
|
+
* An account's grants, newest first, each with its role and whether it is active now.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* const grants = await listGrants(database, { accountId });
|
|
33
|
+
*/
|
|
34
|
+
export declare function listGrants(database: Kysely<AccountDatabase>, { accountId, now }: {
|
|
35
|
+
accountId: string;
|
|
36
|
+
now?: number;
|
|
37
|
+
}): Promise<GrantView[]>;
|
|
38
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/role-grant/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qDAAqD,CAAC;AAI3F,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,+CAA+C,CAAC;AAElH,+FAA+F;AAC/F,eAAO,MAAM,sBAAsB,wBAAwB,CAAC;AAE5D;;;;;;;GAOG;AACH,wBAAsB,SAAS,CAC7B,QAAQ,EAAE,MAAM,CAAC,eAAe,CAAC,EACjC,EACE,SAAS,EACT,WAAW,EACX,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,MAAiB,EACjB,SAAS,EACT,MAAM,EACN,GAAgB,GACjB,EAAE,gBAAgB,GAClB,OAAO,CAAC,eAAe,CAAC,CAuD1B;AAED;;;;;GAKG;AACH,wBAAsB,WAAW,CAC/B,QAAQ,EAAE,MAAM,CAAC,eAAe,CAAC,EACjC,EAAE,OAAO,EAAE,SAAS,EAAE,GAAgB,EAAE,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAC9F,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CA8B/B;AAED;;;;;GAKG;AACH,wBAAsB,UAAU,CAC9B,QAAQ,EAAE,MAAM,CAAC,eAAe,CAAC,EACjC,EAAE,SAAS,EAAE,GAAgB,EAAE,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GACnE,OAAO,CAAC,SAAS,EAAE,CAAC,CAuBtB"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { uuidVersion7 } from "@sharadox/web-library/identifier/uuid-version-7";
|
|
2
|
+
import { accountPermissions } from "@sharadox/account-web-library/account-permission";
|
|
3
|
+
import { recordAuditEvent } from "@sharadox/account-web-library/audit-event";
|
|
4
|
+
import { databaseError } from "@sharadox/account-web-library/database-error";
|
|
5
|
+
/** The permission that lets an account give roles, in the account system's own application. */
|
|
6
|
+
export const ROLE_ASSIGN_PERMISSION = "account.role.assign";
|
|
7
|
+
/**
|
|
8
|
+
* Gives an account a role in an application, maybe for one resource and a time. Given by someone (`grantedBy`), it
|
|
9
|
+
* needs their `account.role.assign` and every permission the role has, there: nobody hands out more than they hold.
|
|
10
|
+
* Recorded in the audit log.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* await grantRole(database, { accountId, application: "platform", role: "manager", grantedBy: admin });
|
|
14
|
+
*/
|
|
15
|
+
export async function grantRole(database, { accountId, application, role, resource, startsAt, endsAt, source = "manual", grantedBy, reason, now = Date.now(), }) {
|
|
16
|
+
const found = await database
|
|
17
|
+
.selectFrom("role")
|
|
18
|
+
.innerJoin("application", "application.id", "role.application_id")
|
|
19
|
+
.leftJoin("role_permission", "role_permission.role_id", "role.id")
|
|
20
|
+
.leftJoin("permission", "permission.id", "role_permission.permission_id")
|
|
21
|
+
.select(["role.id", "permission.key as permission"])
|
|
22
|
+
.where("application.key", "=", application)
|
|
23
|
+
.where("role.key", "=", role)
|
|
24
|
+
.execute();
|
|
25
|
+
if (found.length === 0)
|
|
26
|
+
return { granted: false, reason: "no-role" };
|
|
27
|
+
if (grantedBy) {
|
|
28
|
+
const assigning = await accountPermissions(database, { accountId: grantedBy, application: "account", now });
|
|
29
|
+
if (!assigning.has(ROLE_ASSIGN_PERMISSION))
|
|
30
|
+
return { granted: false, reason: "not-allowed" };
|
|
31
|
+
const held = await accountPermissions(database, {
|
|
32
|
+
accountId: grantedBy,
|
|
33
|
+
application,
|
|
34
|
+
now,
|
|
35
|
+
...(resource ? { resource } : {}),
|
|
36
|
+
});
|
|
37
|
+
if (found.some(({ permission }) => permission && !held.has(permission)))
|
|
38
|
+
return { granted: false, reason: "escalation" };
|
|
39
|
+
}
|
|
40
|
+
const grantId = uuidVersion7({ now });
|
|
41
|
+
try {
|
|
42
|
+
await database.transaction().execute(async (transaction) => {
|
|
43
|
+
await transaction
|
|
44
|
+
.insertInto("role_grant")
|
|
45
|
+
.values({
|
|
46
|
+
id: grantId,
|
|
47
|
+
account_id: accountId,
|
|
48
|
+
role_id: found[0].id,
|
|
49
|
+
resource: resource ?? null,
|
|
50
|
+
starts_at: new Date(startsAt ?? now),
|
|
51
|
+
ends_at: endsAt === undefined ? null : new Date(endsAt),
|
|
52
|
+
source,
|
|
53
|
+
granted_by: grantedBy ?? null,
|
|
54
|
+
reason: reason ?? null,
|
|
55
|
+
})
|
|
56
|
+
.execute();
|
|
57
|
+
await recordAuditEvent(transaction, {
|
|
58
|
+
accountId,
|
|
59
|
+
actorAccountId: grantedBy ?? null,
|
|
60
|
+
application,
|
|
61
|
+
action: "role.granted",
|
|
62
|
+
detail: { grantId, role, source },
|
|
63
|
+
now,
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
if (databaseError(error)?.constraint === "role_grant_account_id_fkey")
|
|
69
|
+
return { granted: false, reason: "no-account" };
|
|
70
|
+
throw error;
|
|
71
|
+
}
|
|
72
|
+
return { granted: true, grantId };
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Ends a grant now (a grant not started yet goes), keeping its history. Recorded in the audit log.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* await revokeGrant(database, { grantId, revokedBy: admin }); // { revoked: true }
|
|
79
|
+
*/
|
|
80
|
+
export async function revokeGrant(database, { grantId, revokedBy, now = Date.now() }) {
|
|
81
|
+
const at = new Date(now);
|
|
82
|
+
return database.transaction().execute(async (transaction) => {
|
|
83
|
+
const ended = await transaction
|
|
84
|
+
.updateTable("role_grant")
|
|
85
|
+
.set({ ends_at: at })
|
|
86
|
+
.where("id", "=", grantId)
|
|
87
|
+
.where("starts_at", "<", at)
|
|
88
|
+
.where((where) => where.or([where("ends_at", "is", null), where("ends_at", ">", at)]))
|
|
89
|
+
.returning("account_id")
|
|
90
|
+
.executeTakeFirst();
|
|
91
|
+
const gone = ended
|
|
92
|
+
? undefined
|
|
93
|
+
: await transaction
|
|
94
|
+
.deleteFrom("role_grant")
|
|
95
|
+
.where("id", "=", grantId)
|
|
96
|
+
.where("starts_at", ">=", at)
|
|
97
|
+
.returning("account_id")
|
|
98
|
+
.executeTakeFirst();
|
|
99
|
+
const accountId = ended?.account_id ?? gone?.account_id;
|
|
100
|
+
if (!accountId)
|
|
101
|
+
return { revoked: false };
|
|
102
|
+
await recordAuditEvent(transaction, {
|
|
103
|
+
accountId,
|
|
104
|
+
actorAccountId: revokedBy ?? null,
|
|
105
|
+
action: "role.revoked",
|
|
106
|
+
detail: { grantId },
|
|
107
|
+
now,
|
|
108
|
+
});
|
|
109
|
+
return { revoked: true };
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* An account's grants, newest first, each with its role and whether it is active now.
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* const grants = await listGrants(database, { accountId });
|
|
117
|
+
*/
|
|
118
|
+
export async function listGrants(database, { accountId, now = Date.now() }) {
|
|
119
|
+
const rows = await database
|
|
120
|
+
.selectFrom("role_grant")
|
|
121
|
+
.innerJoin("role", "role.id", "role_grant.role_id")
|
|
122
|
+
.leftJoin("application", "application.id", "role.application_id")
|
|
123
|
+
.select([
|
|
124
|
+
"role_grant.id as grantId",
|
|
125
|
+
"application.key as application",
|
|
126
|
+
"role.key as role",
|
|
127
|
+
"role.name as roleName",
|
|
128
|
+
"role_grant.resource",
|
|
129
|
+
"role_grant.starts_at as startsAt",
|
|
130
|
+
"role_grant.ends_at as endsAt",
|
|
131
|
+
"role_grant.source",
|
|
132
|
+
"role_grant.reason",
|
|
133
|
+
])
|
|
134
|
+
.where("role_grant.account_id", "=", accountId)
|
|
135
|
+
.orderBy("role_grant.id", "desc")
|
|
136
|
+
.execute();
|
|
137
|
+
return rows.map((row) => ({
|
|
138
|
+
...row,
|
|
139
|
+
active: row.startsAt.getTime() <= now && (row.endsAt === null || now < row.endsAt.getTime()),
|
|
140
|
+
}));
|
|
141
|
+
}
|
|
142
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/role-grant/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,iDAAiD,CAAC;AAE/E,OAAO,EAAE,kBAAkB,EAAE,MAAM,kDAAkD,CAAC;AACtF,OAAO,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,8CAA8C,CAAC;AAG7E,+FAA+F;AAC/F,MAAM,CAAC,MAAM,sBAAsB,GAAG,qBAAqB,CAAC;AAE5D;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,QAAiC,EACjC,EACE,SAAS,EACT,WAAW,EACX,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,MA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}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export interface RoleGrantRequest {
|
|
2
|
+
accountId: string;
|
|
3
|
+
/** The role's application key (`platform`). */
|
|
4
|
+
application: string;
|
|
5
|
+
/** The role's key (`manager`). */
|
|
6
|
+
role: string;
|
|
7
|
+
/** `platform:project:42`; the whole application without it. */
|
|
8
|
+
resource?: string;
|
|
9
|
+
/** Milliseconds since 1970 (now by default). */
|
|
10
|
+
startsAt?: number;
|
|
11
|
+
/** Milliseconds since 1970; for good without it. */
|
|
12
|
+
endsAt?: number;
|
|
13
|
+
source?: "manual" | "membership" | "ban" | "system";
|
|
14
|
+
/** Who gives it: they need `account.role.assign` and every permission of the role. The system without it. */
|
|
15
|
+
grantedBy?: string;
|
|
16
|
+
reason?: string;
|
|
17
|
+
now?: number;
|
|
18
|
+
}
|
|
19
|
+
export type RoleGrantResult = {
|
|
20
|
+
granted: true;
|
|
21
|
+
grantId: string;
|
|
22
|
+
} | {
|
|
23
|
+
granted: false;
|
|
24
|
+
reason: "no-role" | "no-account" | "not-allowed" | "escalation";
|
|
25
|
+
};
|
|
26
|
+
/** A grant as an account's page or an administrator sees it. */
|
|
27
|
+
export interface GrantView {
|
|
28
|
+
grantId: string;
|
|
29
|
+
application: string | null;
|
|
30
|
+
role: string;
|
|
31
|
+
roleName: string;
|
|
32
|
+
resource: string | null;
|
|
33
|
+
startsAt: Date;
|
|
34
|
+
endsAt: Date | null;
|
|
35
|
+
source: string;
|
|
36
|
+
reason: string | null;
|
|
37
|
+
/** Started and not ended. */
|
|
38
|
+
active: boolean;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../source/role-grant/type.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,+CAA+C;IAC/C,WAAW,EAAE,MAAM,CAAC;IACpB,kCAAkC;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gDAAgD;IAChD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oDAAoD;IACpD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,QAAQ,GAAG,YAAY,GAAG,KAAK,GAAG,QAAQ,CAAC;IACpD,6GAA6G;IAC7G,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,MAAM,eAAe,GACvB;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAClC;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,SAAS,GAAG,YAAY,GAAG,aAAa,GAAG,YAAY,CAAA;CAAE,CAAC;AAExF,gEAAgE;AAChE,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,QAAQ,EAAE,IAAI,CAAC;IACf,MAAM,EAAE,IAAI,GAAG,IAAI,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,6BAA6B;IAC7B,MAAM,EAAE,OAAO,CAAC;CACjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../source/role-grant/type.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Kysely } from "kysely";
|
|
2
|
+
import type { AccountDatabase } from "@sharadox/account-web-library/account-database/type";
|
|
3
|
+
import type { PublishedRule, RuleDeclaration } from "@sharadox/account-web-library/rule-sync/type";
|
|
4
|
+
/**
|
|
5
|
+
* Publishes an application's rules (or global ones, `application: null`). A rule whose words or penalties changed gets
|
|
6
|
+
* a new version, and earlier bans keep citing the version they broke. Returns the codes given a new version.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* await syncRules(database, { application: "platform", rules: [{ code: "spam", title, description, schedule }] });
|
|
10
|
+
*/
|
|
11
|
+
export declare function syncRules(database: Kysely<AccountDatabase>, { application, rules }: {
|
|
12
|
+
application: string | null;
|
|
13
|
+
rules: RuleDeclaration[];
|
|
14
|
+
}): Promise<{
|
|
15
|
+
versioned: string[];
|
|
16
|
+
unknownApplication?: true;
|
|
17
|
+
}>;
|
|
18
|
+
/**
|
|
19
|
+
* The rules in force for an application, newest versions, global ones first then its own, by code: what the public
|
|
20
|
+
* rules page and `GET /api/rules` show.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* const rules = await listRules(database, { application: "platform" });
|
|
24
|
+
*/
|
|
25
|
+
export declare function listRules(database: Kysely<AccountDatabase>, { application }: {
|
|
26
|
+
application: string;
|
|
27
|
+
}): Promise<PublishedRule[]>;
|
|
28
|
+
//# sourceMappingURL=index.d.ts.map
|