@stackframe/stack-shared 2.8.8 → 2.8.11
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/CHANGELOG.md +14 -0
- package/dist/config/format.d.cts +39 -0
- package/dist/config/format.d.ts +14 -13
- package/dist/config/format.js +147 -206
- package/dist/config/format.js.map +1 -0
- package/dist/config/schema.d.cts +729 -0
- package/dist/config/schema.d.ts +59 -51
- package/dist/config/schema.js +232 -172
- package/dist/config/schema.js.map +1 -0
- package/dist/crud.d.cts +102 -0
- package/dist/crud.d.ts +15 -13
- package/dist/crud.js +83 -128
- package/dist/crud.js.map +1 -0
- package/dist/esm/config/format.js +135 -0
- package/dist/esm/config/format.js.map +1 -0
- package/dist/esm/config/schema.js +201 -0
- package/dist/esm/config/schema.js.map +1 -0
- package/dist/esm/crud.js +60 -0
- package/dist/esm/crud.js.map +1 -0
- package/dist/esm/global.d.js +1 -0
- package/dist/esm/global.d.js.map +1 -0
- package/dist/esm/helpers/password.js +17 -0
- package/dist/esm/helpers/password.js.map +1 -0
- package/dist/esm/helpers/production-mode.js +50 -0
- package/dist/esm/helpers/production-mode.js.map +1 -0
- package/dist/esm/hooks/use-async-callback.js +38 -0
- package/dist/esm/hooks/use-async-callback.js.map +1 -0
- package/dist/esm/hooks/use-async-external-store.js +23 -0
- package/dist/esm/hooks/use-async-external-store.js.map +1 -0
- package/dist/esm/hooks/use-hash.js +17 -0
- package/dist/esm/hooks/use-hash.js.map +1 -0
- package/dist/esm/hooks/use-strict-memo.js +61 -0
- package/dist/esm/hooks/use-strict-memo.js.map +1 -0
- package/dist/esm/index.js +22 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/interface/adminInterface.js +244 -0
- package/dist/esm/interface/adminInterface.js.map +1 -0
- package/dist/esm/interface/clientInterface.js +2041 -0
- package/dist/esm/interface/clientInterface.js.map +1 -0
- package/dist/esm/interface/crud/contact-channels.js +77 -0
- package/dist/esm/interface/crud/contact-channels.js.map +1 -0
- package/dist/esm/interface/crud/current-user.js +65 -0
- package/dist/esm/interface/crud/current-user.js.map +1 -0
- package/dist/esm/interface/crud/email-templates.js +52 -0
- package/dist/esm/interface/crud/email-templates.js.map +1 -0
- package/dist/esm/interface/crud/emails.js +20 -0
- package/dist/esm/interface/crud/emails.js.map +1 -0
- package/dist/esm/interface/crud/internal-api-keys.js +69 -0
- package/dist/esm/interface/crud/internal-api-keys.js.map +1 -0
- package/dist/esm/interface/crud/oauth.js +24 -0
- package/dist/esm/interface/crud/oauth.js.map +1 -0
- package/dist/esm/interface/crud/project-api-keys.js +93 -0
- package/dist/esm/interface/crud/project-api-keys.js.map +1 -0
- package/dist/esm/interface/crud/project-permissions.js +113 -0
- package/dist/esm/interface/crud/project-permissions.js.map +1 -0
- package/dist/esm/interface/crud/projects.js +180 -0
- package/dist/esm/interface/crud/projects.js.map +1 -0
- package/dist/esm/interface/crud/sessions.js +62 -0
- package/dist/esm/interface/crud/sessions.js.map +1 -0
- package/dist/esm/interface/crud/svix-token.js +22 -0
- package/dist/esm/interface/crud/svix-token.js.map +1 -0
- package/dist/esm/interface/crud/team-invitation-details.js +23 -0
- package/dist/esm/interface/crud/team-invitation-details.js.map +1 -0
- package/dist/esm/interface/crud/team-invitation.js +36 -0
- package/dist/esm/interface/crud/team-invitation.js.map +1 -0
- package/dist/esm/interface/crud/team-member-profiles.js +62 -0
- package/dist/esm/interface/crud/team-member-profiles.js.map +1 -0
- package/dist/esm/interface/crud/team-memberships.js +60 -0
- package/dist/esm/interface/crud/team-memberships.js.map +1 -0
- package/dist/esm/interface/crud/team-permissions.js +114 -0
- package/dist/esm/interface/crud/team-permissions.js.map +1 -0
- package/dist/esm/interface/crud/teams.js +143 -0
- package/dist/esm/interface/crud/teams.js.map +1 -0
- package/dist/esm/interface/crud/users.js +139 -0
- package/dist/esm/interface/crud/users.js.map +1 -0
- package/dist/esm/interface/serverInterface.js +485 -0
- package/dist/esm/interface/serverInterface.js.map +1 -0
- package/dist/esm/interface/webhooks.js +21 -0
- package/dist/esm/interface/webhooks.js.map +1 -0
- package/dist/esm/known-errors.js +1238 -0
- package/dist/esm/known-errors.js.map +1 -0
- package/dist/esm/schema-fields.js +484 -0
- package/dist/esm/schema-fields.js.map +1 -0
- package/dist/esm/sessions.js +168 -0
- package/dist/esm/sessions.js.map +1 -0
- package/dist/esm/utils/api-keys.js +79 -0
- package/dist/esm/utils/api-keys.js.map +1 -0
- package/dist/esm/utils/arrays.js +78 -0
- package/dist/esm/utils/arrays.js.map +1 -0
- package/dist/esm/utils/base64.js +18 -0
- package/dist/esm/utils/base64.js.map +1 -0
- package/dist/esm/utils/booleans.js +12 -0
- package/dist/esm/utils/booleans.js.map +1 -0
- package/dist/esm/utils/browser-compat.js +21 -0
- package/dist/esm/utils/browser-compat.js.map +1 -0
- package/dist/esm/utils/bytes.js +160 -0
- package/dist/esm/utils/bytes.js.map +1 -0
- package/dist/esm/utils/caches.js +167 -0
- package/dist/esm/utils/caches.js.map +1 -0
- package/dist/esm/utils/compile-time.js +11 -0
- package/dist/esm/utils/compile-time.js.map +1 -0
- package/dist/esm/utils/crypto.js +25 -0
- package/dist/esm/utils/crypto.js.map +1 -0
- package/dist/esm/utils/dates.js +64 -0
- package/dist/esm/utils/dates.js.map +1 -0
- package/dist/esm/utils/dom.js +11 -0
- package/dist/esm/utils/dom.js.map +1 -0
- package/dist/esm/utils/env.js +58 -0
- package/dist/esm/utils/env.js.map +1 -0
- package/dist/esm/utils/errors.js +174 -0
- package/dist/esm/utils/errors.js.map +1 -0
- package/dist/esm/utils/fs.js +37 -0
- package/dist/esm/utils/fs.js.map +1 -0
- package/dist/esm/utils/functions.js +12 -0
- package/dist/esm/utils/functions.js.map +1 -0
- package/dist/esm/utils/geo.js +15 -0
- package/dist/esm/utils/geo.js.map +1 -0
- package/dist/esm/utils/globals.js +18 -0
- package/dist/esm/utils/globals.js.map +1 -0
- package/dist/esm/utils/hashes.js +55 -0
- package/dist/esm/utils/hashes.js.map +1 -0
- package/dist/esm/utils/html.js +13 -0
- package/dist/esm/utils/html.js.map +1 -0
- package/dist/esm/utils/http.js +60 -0
- package/dist/esm/utils/http.js.map +1 -0
- package/dist/esm/utils/ips.js +15 -0
- package/dist/esm/utils/ips.js.map +1 -0
- package/dist/esm/utils/json.js +31 -0
- package/dist/esm/utils/json.js.map +1 -0
- package/dist/esm/utils/jwt.js +87 -0
- package/dist/esm/utils/jwt.js.map +1 -0
- package/dist/esm/utils/locks.js +57 -0
- package/dist/esm/utils/locks.js.map +1 -0
- package/dist/esm/utils/maps.js +181 -0
- package/dist/esm/utils/maps.js.map +1 -0
- package/dist/esm/utils/math.js +8 -0
- package/dist/esm/utils/math.js.map +1 -0
- package/dist/esm/utils/node-http.js +42 -0
- package/dist/esm/utils/node-http.js.map +1 -0
- package/dist/esm/utils/numbers.js +32 -0
- package/dist/esm/utils/numbers.js.map +1 -0
- package/dist/esm/utils/oauth.js +10 -0
- package/dist/esm/utils/oauth.js.map +1 -0
- package/dist/esm/utils/objects.js +177 -0
- package/dist/esm/utils/objects.js.map +1 -0
- package/dist/esm/utils/passkey.js +1 -0
- package/dist/esm/utils/passkey.js.map +1 -0
- package/dist/esm/utils/promises.js +233 -0
- package/dist/esm/utils/promises.js.map +1 -0
- package/dist/esm/utils/proxies.js +128 -0
- package/dist/esm/utils/proxies.js.map +1 -0
- package/dist/esm/utils/react.js +78 -0
- package/dist/esm/utils/react.js.map +1 -0
- package/dist/esm/utils/results.js +141 -0
- package/dist/esm/utils/results.js.map +1 -0
- package/dist/esm/utils/sentry.js +20 -0
- package/dist/esm/utils/sentry.js.map +1 -0
- package/dist/esm/utils/stores.js +195 -0
- package/dist/esm/utils/stores.js.map +1 -0
- package/dist/esm/utils/strings.js +295 -0
- package/dist/esm/utils/strings.js.map +1 -0
- package/dist/esm/utils/strings.nicify.test.js +222 -0
- package/dist/esm/utils/strings.nicify.test.js.map +1 -0
- package/dist/esm/utils/types.js +1 -0
- package/dist/esm/utils/types.js.map +1 -0
- package/dist/esm/utils/unicode.js +11 -0
- package/dist/esm/utils/unicode.js.map +1 -0
- package/dist/esm/utils/urls.js +53 -0
- package/dist/esm/utils/urls.js.map +1 -0
- package/dist/esm/utils/uuids.js +16 -0
- package/dist/esm/utils/uuids.js.map +1 -0
- package/dist/global.d.d.cts +1 -0
- package/dist/global.d.d.ts +1 -0
- package/dist/global.d.js +2 -0
- package/dist/global.d.js.map +1 -0
- package/dist/helpers/password.d.cts +11 -0
- package/dist/helpers/password.d.ts +11 -2
- package/dist/helpers/password.js +41 -11
- package/dist/helpers/password.js.map +1 -0
- package/dist/helpers/production-mode.d.cts +12 -0
- package/dist/helpers/production-mode.d.ts +9 -3
- package/dist/helpers/production-mode.js +72 -45
- package/dist/helpers/production-mode.js.map +1 -0
- package/dist/hooks/use-async-callback.d.cts +6 -0
- package/dist/hooks/use-async-callback.d.ts +6 -3
- package/dist/hooks/use-async-callback.js +72 -30
- package/dist/hooks/use-async-callback.js.map +1 -0
- package/dist/hooks/use-async-external-store.d.cts +7 -0
- package/dist/hooks/use-async-external-store.d.ts +5 -2
- package/dist/hooks/use-async-external-store.js +47 -19
- package/dist/hooks/use-async-external-store.js.map +1 -0
- package/dist/hooks/use-hash.d.cts +3 -0
- package/dist/hooks/use-hash.d.ts +3 -1
- package/dist/hooks/use-hash.js +41 -8
- package/dist/hooks/use-hash.js.map +1 -0
- package/dist/hooks/use-strict-memo.d.cts +8 -0
- package/dist/hooks/use-strict-memo.d.ts +3 -1
- package/dist/hooks/use-strict-memo.js +78 -131
- package/dist/hooks/use-strict-memo.js.map +1 -0
- package/dist/index.d.cts +30 -0
- package/dist/index.d.ts +30 -4
- package/dist/index.js +42 -4
- package/dist/index.js.map +1 -0
- package/dist/interface/adminInterface.d.cts +94 -0
- package/dist/interface/adminInterface.d.ts +38 -15
- package/dist/interface/adminInterface.js +269 -174
- package/dist/interface/adminInterface.js.map +1 -0
- package/dist/interface/clientInterface.d.cts +260 -0
- package/dist/interface/clientInterface.d.ts +25 -18
- package/dist/interface/clientInterface.js +2054 -995
- package/dist/interface/clientInterface.js.map +1 -0
- package/dist/interface/crud/contact-channels.d.cts +180 -0
- package/dist/interface/crud/contact-channels.d.ts +30 -25
- package/dist/interface/crud/contact-channels.js +101 -59
- package/dist/interface/crud/contact-channels.js.map +1 -0
- package/dist/interface/crud/current-user.d.cts +205 -0
- package/dist/interface/crud/current-user.d.ts +17 -12
- package/dist/interface/crud/current-user.js +86 -56
- package/dist/interface/crud/current-user.js.map +1 -0
- package/dist/interface/crud/email-templates.d.cts +84 -0
- package/dist/interface/crud/email-templates.d.ts +24 -19
- package/dist/interface/crud/email-templates.js +77 -37
- package/dist/interface/crud/email-templates.js.map +1 -0
- package/dist/interface/crud/emails.d.cts +69 -0
- package/dist/interface/crud/emails.d.ts +12 -7
- package/dist/interface/crud/emails.js +54 -12
- package/dist/interface/crud/emails.js.map +1 -0
- package/dist/interface/crud/internal-api-keys.d.cts +139 -0
- package/dist/interface/crud/internal-api-keys.d.ts +22 -17
- package/dist/interface/crud/internal-api-keys.js +92 -54
- package/dist/interface/crud/internal-api-keys.js.map +1 -0
- package/dist/interface/crud/oauth.d.cts +34 -0
- package/dist/interface/crud/oauth.d.ts +16 -11
- package/dist/interface/crud/oauth.js +48 -14
- package/dist/interface/crud/oauth.js.map +1 -0
- package/dist/interface/crud/project-api-keys.d.cts +196 -0
- package/dist/interface/crud/project-api-keys.d.ts +20 -12
- package/dist/interface/crud/project-api-keys.js +121 -74
- package/dist/interface/crud/project-api-keys.js.map +1 -0
- package/dist/interface/crud/project-permissions.d.cts +160 -0
- package/dist/interface/crud/project-permissions.d.ts +38 -33
- package/dist/interface/crud/project-permissions.js +148 -90
- package/dist/interface/crud/project-permissions.js.map +1 -0
- package/dist/interface/crud/projects.d.cts +627 -0
- package/dist/interface/crud/projects.d.ts +43 -51
- package/dist/interface/crud/projects.js +210 -156
- package/dist/interface/crud/projects.js.map +1 -0
- package/dist/interface/crud/sessions.d.cts +149 -0
- package/dist/interface/crud/sessions.d.ts +21 -16
- package/dist/interface/crud/sessions.js +86 -50
- package/dist/interface/crud/sessions.js.map +1 -0
- package/dist/interface/crud/svix-token.d.cts +26 -0
- package/dist/interface/crud/svix-token.d.ts +14 -9
- package/dist/interface/crud/svix-token.js +46 -12
- package/dist/interface/crud/svix-token.js.map +1 -0
- package/dist/interface/crud/team-invitation-details.d.cts +30 -0
- package/dist/interface/crud/team-invitation-details.d.ts +12 -7
- package/dist/interface/crud/team-invitation-details.js +57 -15
- package/dist/interface/crud/team-invitation-details.js.map +1 -0
- package/dist/interface/crud/team-invitation.d.cts +49 -0
- package/dist/interface/crud/team-invitation.d.ts +13 -8
- package/dist/interface/crud/team-invitation.js +69 -27
- package/dist/interface/crud/team-invitation.js.map +1 -0
- package/dist/interface/crud/team-member-profiles.d.cts +229 -0
- package/dist/interface/crud/team-member-profiles.d.ts +20 -15
- package/dist/interface/crud/team-member-profiles.js +95 -49
- package/dist/interface/crud/team-member-profiles.js.map +1 -0
- package/dist/interface/crud/team-memberships.d.cts +74 -0
- package/dist/interface/crud/team-memberships.d.ts +22 -17
- package/dist/interface/crud/team-memberships.js +85 -45
- package/dist/interface/crud/team-memberships.js.map +1 -0
- package/dist/interface/crud/team-permissions.d.cts +168 -0
- package/dist/interface/crud/team-permissions.d.ts +38 -33
- package/dist/interface/crud/team-permissions.js +149 -91
- package/dist/interface/crud/team-permissions.js.map +1 -0
- package/dist/interface/crud/teams.d.cts +298 -0
- package/dist/interface/crud/teams.d.ts +45 -40
- package/dist/interface/crud/teams.js +177 -119
- package/dist/interface/crud/teams.js.map +1 -0
- package/dist/interface/crud/users.d.cts +469 -0
- package/dist/interface/crud/users.d.ts +31 -26
- package/dist/interface/crud/users.js +172 -118
- package/dist/interface/crud/users.js.map +1 -0
- package/dist/interface/serverInterface.d.cts +128 -0
- package/dist/interface/serverInterface.d.ts +29 -17
- package/dist/interface/serverInterface.js +506 -339
- package/dist/interface/serverInterface.js.map +1 -0
- package/dist/interface/webhooks.d.cts +292 -0
- package/dist/interface/webhooks.d.ts +6 -3
- package/dist/interface/webhooks.js +45 -15
- package/dist/interface/webhooks.js.map +1 -0
- package/dist/known-errors.d.cts +447 -0
- package/dist/known-errors.d.ts +15 -9
- package/dist/known-errors.js +1104 -562
- package/dist/known-errors.js.map +1 -0
- package/dist/schema-fields.d.cts +163 -0
- package/dist/schema-fields.d.ts +116 -114
- package/dist/schema-fields.js +593 -427
- package/dist/schema-fields.js.map +1 -0
- package/dist/sessions.d.cts +109 -0
- package/dist/sessions.d.ts +6 -3
- package/dist/sessions.js +201 -172
- package/dist/sessions.js.map +1 -0
- package/dist/utils/api-keys.d.cts +24 -0
- package/dist/utils/api-keys.d.ts +5 -4
- package/dist/utils/api-keys.js +106 -66
- package/dist/utils/api-keys.js.map +1 -0
- package/dist/utils/arrays.d.cts +18 -0
- package/dist/utils/arrays.d.ts +15 -13
- package/dist/utils/arrays.js +101 -168
- package/dist/utils/arrays.js.map +1 -0
- package/dist/utils/base64.d.cts +4 -0
- package/dist/utils/base64.d.ts +4 -2
- package/dist/utils/base64.js +41 -20
- package/dist/utils/base64.js.map +1 -0
- package/dist/utils/booleans.d.cts +6 -0
- package/dist/utils/booleans.d.ts +6 -4
- package/dist/utils/booleans.js +35 -27
- package/dist/utils/booleans.js.map +1 -0
- package/dist/utils/browser-compat.d.cts +8 -0
- package/dist/utils/browser-compat.d.ts +3 -1
- package/dist/utils/browser-compat.js +45 -16
- package/dist/utils/browser-compat.js.map +1 -0
- package/dist/utils/bytes.d.cts +15 -0
- package/dist/utils/bytes.d.ts +15 -13
- package/dist/utils/bytes.js +182 -270
- package/dist/utils/bytes.js.map +1 -0
- package/dist/utils/caches.d.cts +98 -0
- package/dist/utils/caches.d.ts +17 -14
- package/dist/utils/caches.js +188 -193
- package/dist/utils/caches.js.map +1 -0
- package/dist/utils/compile-time.d.cts +8 -0
- package/dist/utils/compile-time.d.ts +3 -1
- package/dist/utils/compile-time.js +35 -10
- package/dist/utils/compile-time.js.map +1 -0
- package/dist/utils/crypto.d.cts +8 -0
- package/dist/utils/crypto.d.ts +4 -2
- package/dist/utils/crypto.js +49 -21
- package/dist/utils/crypto.js.map +1 -0
- package/dist/utils/dates.d.cts +15 -0
- package/dist/utils/dates.d.ts +6 -4
- package/dist/utils/dates.js +83 -105
- package/dist/utils/dates.js.map +1 -0
- package/dist/utils/dom.d.cts +3 -0
- package/dist/utils/dom.d.ts +3 -1
- package/dist/utils/dom.js +35 -7
- package/dist/utils/dom.js.map +1 -0
- package/dist/utils/env.d.cts +9 -0
- package/dist/utils/env.d.ts +6 -4
- package/dist/utils/env.js +70 -43
- package/dist/utils/env.js.map +1 -0
- package/dist/utils/errors.d.cts +223 -0
- package/dist/utils/errors.d.ts +14 -11
- package/dist/utils/errors.js +148 -126
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/fs.d.cts +7 -0
- package/dist/utils/fs.d.ts +5 -3
- package/dist/utils/fs.js +70 -27
- package/dist/utils/fs.js.map +1 -0
- package/dist/utils/functions.d.cts +4 -0
- package/dist/utils/functions.d.ts +4 -2
- package/dist/utils/functions.js +35 -18
- package/dist/utils/functions.js.map +1 -0
- package/dist/utils/geo.d.cts +22 -0
- package/dist/utils/geo.d.ts +6 -3
- package/dist/utils/geo.js +39 -9
- package/dist/utils/geo.js.map +1 -0
- package/dist/utils/globals.d.cts +5 -0
- package/dist/utils/globals.d.ts +4 -2
- package/dist/utils/globals.js +41 -14
- package/dist/utils/globals.js.map +1 -0
- package/dist/utils/hashes.d.cts +7 -0
- package/dist/utils/hashes.d.ts +7 -5
- package/dist/utils/hashes.js +87 -41
- package/dist/utils/hashes.js.map +1 -0
- package/dist/utils/html.d.cts +4 -0
- package/dist/utils/html.d.ts +4 -2
- package/dist/utils/html.js +36 -37
- package/dist/utils/html.js.map +1 -0
- package/dist/utils/http.d.cts +43 -0
- package/dist/utils/http.d.ts +6 -4
- package/dist/utils/http.js +83 -83
- package/dist/utils/http.js.map +1 -0
- package/dist/utils/ips.d.cts +6 -0
- package/dist/utils/ips.d.ts +6 -4
- package/dist/utils/ips.js +48 -35
- package/dist/utils/ips.js.map +1 -0
- package/dist/utils/json.d.cts +13 -0
- package/dist/utils/json.d.ts +9 -6
- package/dist/utils/json.js +54 -157
- package/dist/utils/json.js.map +1 -0
- package/dist/utils/jwt.d.cts +44 -0
- package/dist/utils/jwt.d.ts +14 -11
- package/dist/utils/jwt.js +119 -84
- package/dist/utils/jwt.js.map +1 -0
- package/dist/utils/locks.d.cts +15 -0
- package/dist/utils/locks.d.ts +3 -2
- package/dist/utils/locks.js +76 -56
- package/dist/utils/locks.js.map +1 -0
- package/dist/utils/maps.d.cts +59 -0
- package/dist/utils/maps.d.ts +6 -4
- package/dist/utils/maps.js +207 -343
- package/dist/utils/maps.js.map +1 -0
- package/dist/utils/math.d.cts +6 -0
- package/dist/utils/math.d.ts +3 -1
- package/dist/utils/math.js +31 -16
- package/dist/utils/math.js.map +1 -0
- package/dist/utils/node-http.d.cts +15 -0
- package/dist/utils/node-http.d.ts +5 -5
- package/dist/utils/node-http.js +65 -36
- package/dist/utils/node-http.js.map +1 -0
- package/dist/utils/numbers.d.cts +5 -0
- package/dist/utils/numbers.d.ts +5 -3
- package/dist/utils/numbers.js +53 -66
- package/dist/utils/numbers.js.map +1 -0
- package/dist/utils/oauth.d.cts +8 -0
- package/dist/utils/oauth.d.ts +8 -6
- package/dist/utils/oauth.js +37 -4
- package/dist/utils/oauth.js.map +1 -0
- package/dist/utils/objects.d.cts +69 -0
- package/dist/utils/objects.d.ts +37 -32
- package/dist/utils/objects.js +224 -374
- package/dist/utils/objects.js.map +1 -0
- package/dist/utils/passkey.d.cts +1 -0
- package/dist/utils/passkey.d.ts +1 -1
- package/dist/utils/passkey.js +19 -1
- package/dist/utils/passkey.js.map +1 -0
- package/dist/utils/promises.d.cts +74 -0
- package/dist/utils/promises.d.ts +20 -18
- package/dist/utils/promises.js +252 -393
- package/dist/utils/promises.js.map +1 -0
- package/dist/utils/proxies.d.cts +4 -0
- package/dist/utils/proxies.d.ts +4 -2
- package/dist/utils/proxies.js +150 -161
- package/dist/utils/proxies.js.map +1 -0
- package/dist/utils/react.d.cts +25 -0
- package/dist/utils/react.d.ts +9 -6
- package/dist/utils/react.js +88 -134
- package/dist/utils/react.js.map +1 -0
- package/dist/utils/results.d.cts +78 -0
- package/dist/utils/results.d.ts +10 -9
- package/dist/utils/results.js +143 -324
- package/dist/utils/results.js.map +1 -0
- package/dist/utils/sentry.d.cts +5 -0
- package/dist/utils/sentry.d.ts +5 -2
- package/dist/utils/sentry.js +44 -14
- package/dist/utils/sentry.js.map +1 -0
- package/dist/utils/stores.d.cts +102 -0
- package/dist/utils/stores.d.ts +12 -9
- package/dist/utils/stores.js +219 -189
- package/dist/utils/stores.js.map +1 -0
- package/dist/utils/strings.d.cts +72 -0
- package/dist/utils/strings.d.ts +22 -20
- package/dist/utils/strings.js +300 -580
- package/dist/utils/strings.js.map +1 -0
- package/dist/utils/strings.nicify.test.d.cts +2 -0
- package/dist/utils/strings.nicify.test.d.ts +2 -1
- package/dist/utils/strings.nicify.test.js +168 -158
- package/dist/utils/strings.nicify.test.js.map +1 -0
- package/dist/utils/types.d.cts +23 -0
- package/dist/utils/types.d.ts +8 -6
- package/dist/utils/types.js +19 -1
- package/dist/utils/types.js.map +1 -0
- package/dist/utils/unicode.d.cts +3 -0
- package/dist/utils/unicode.d.ts +3 -1
- package/dist/utils/unicode.js +34 -21
- package/dist/utils/unicode.js.map +1 -0
- package/dist/utils/urls.d.cts +20 -0
- package/dist/utils/urls.d.ts +10 -8
- package/dist/utils/urls.js +76 -165
- package/dist/utils/urls.js.map +1 -0
- package/dist/utils/uuids.d.cts +4 -0
- package/dist/utils/uuids.d.ts +4 -2
- package/dist/utils/uuids.js +39 -35
- package/dist/utils/uuids.js.map +1 -0
- package/package.json +5 -5
package/dist/schema-fields.js
CHANGED
|
@@ -1,463 +1,629 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/schema-fields.ts
|
|
31
|
+
var schema_fields_exports = {};
|
|
32
|
+
__export(schema_fields_exports, {
|
|
33
|
+
ReplaceFieldWithOwnUserId: () => ReplaceFieldWithOwnUserId,
|
|
34
|
+
accessTokenResponseSchema: () => accessTokenResponseSchema,
|
|
35
|
+
adaptSchema: () => adaptSchema,
|
|
36
|
+
adminAuthTypeSchema: () => adminAuthTypeSchema,
|
|
37
|
+
base64Schema: () => base64Schema,
|
|
38
|
+
basicAuthorizationHeaderSchema: () => basicAuthorizationHeaderSchema,
|
|
39
|
+
clientOrHigherAuthTypeSchema: () => clientOrHigherAuthTypeSchema,
|
|
40
|
+
contactChannelIdSchema: () => contactChannelIdSchema,
|
|
41
|
+
contactChannelIsPrimarySchema: () => contactChannelIsPrimarySchema,
|
|
42
|
+
contactChannelIsVerifiedSchema: () => contactChannelIsVerifiedSchema,
|
|
43
|
+
contactChannelTypeSchema: () => contactChannelTypeSchema,
|
|
44
|
+
contactChannelUsedForAuthSchema: () => contactChannelUsedForAuthSchema,
|
|
45
|
+
contactChannelValueSchema: () => contactChannelValueSchema,
|
|
46
|
+
containedPermissionIdsSchema: () => containedPermissionIdsSchema,
|
|
47
|
+
customPermissionDefinitionIdSchema: () => customPermissionDefinitionIdSchema,
|
|
48
|
+
emailHostSchema: () => emailHostSchema,
|
|
49
|
+
emailOtpSignInCallbackUrlSchema: () => emailOtpSignInCallbackUrlSchema,
|
|
50
|
+
emailPasswordSchema: () => emailPasswordSchema,
|
|
51
|
+
emailPortSchema: () => emailPortSchema,
|
|
52
|
+
emailSchema: () => emailSchema,
|
|
53
|
+
emailSenderEmailSchema: () => emailSenderEmailSchema,
|
|
54
|
+
emailSenderNameSchema: () => emailSenderNameSchema,
|
|
55
|
+
emailTypeSchema: () => emailTypeSchema,
|
|
56
|
+
emailUsernameSchema: () => emailUsernameSchema,
|
|
57
|
+
emailVerificationCallbackUrlSchema: () => emailVerificationCallbackUrlSchema,
|
|
58
|
+
ensureObjectSchema: () => ensureObjectSchema,
|
|
59
|
+
handlerPathSchema: () => handlerPathSchema,
|
|
60
|
+
jsonSchema: () => jsonSchema,
|
|
61
|
+
jsonStringOrEmptySchema: () => jsonStringOrEmptySchema,
|
|
62
|
+
jsonStringSchema: () => jsonStringSchema,
|
|
63
|
+
neonAuthorizationHeaderSchema: () => neonAuthorizationHeaderSchema,
|
|
64
|
+
oauthAccountMergeStrategySchema: () => oauthAccountMergeStrategySchema,
|
|
65
|
+
oauthClientIdSchema: () => oauthClientIdSchema,
|
|
66
|
+
oauthClientSecretSchema: () => oauthClientSecretSchema,
|
|
67
|
+
oauthEnabledSchema: () => oauthEnabledSchema,
|
|
68
|
+
oauthFacebookConfigIdSchema: () => oauthFacebookConfigIdSchema,
|
|
69
|
+
oauthIdSchema: () => oauthIdSchema,
|
|
70
|
+
oauthMicrosoftTenantIdSchema: () => oauthMicrosoftTenantIdSchema,
|
|
71
|
+
oauthTypeSchema: () => oauthTypeSchema,
|
|
72
|
+
passwordSchema: () => passwordSchema,
|
|
73
|
+
permissionDefinitionIdSchema: () => permissionDefinitionIdSchema,
|
|
74
|
+
primaryEmailAuthEnabledSchema: () => primaryEmailAuthEnabledSchema,
|
|
75
|
+
primaryEmailSchema: () => primaryEmailSchema,
|
|
76
|
+
primaryEmailVerifiedSchema: () => primaryEmailVerifiedSchema,
|
|
77
|
+
profileImageUrlSchema: () => profileImageUrlSchema,
|
|
78
|
+
projectAllowLocalhostSchema: () => projectAllowLocalhostSchema,
|
|
79
|
+
projectClientTeamCreationEnabledSchema: () => projectClientTeamCreationEnabledSchema,
|
|
80
|
+
projectClientUserDeletionEnabledSchema: () => projectClientUserDeletionEnabledSchema,
|
|
81
|
+
projectConfigIdSchema: () => projectConfigIdSchema,
|
|
82
|
+
projectCreateTeamOnSignUpSchema: () => projectCreateTeamOnSignUpSchema,
|
|
83
|
+
projectCreatedAtMillisSchema: () => projectCreatedAtMillisSchema,
|
|
84
|
+
projectCredentialEnabledSchema: () => projectCredentialEnabledSchema,
|
|
85
|
+
projectDescriptionSchema: () => projectDescriptionSchema,
|
|
86
|
+
projectDisplayNameSchema: () => projectDisplayNameSchema,
|
|
87
|
+
projectIdSchema: () => projectIdSchema,
|
|
88
|
+
projectIsProductionModeSchema: () => projectIsProductionModeSchema,
|
|
89
|
+
projectMagicLinkEnabledSchema: () => projectMagicLinkEnabledSchema,
|
|
90
|
+
projectPasskeyEnabledSchema: () => projectPasskeyEnabledSchema,
|
|
91
|
+
projectSignUpEnabledSchema: () => projectSignUpEnabledSchema,
|
|
92
|
+
projectUserCountSchema: () => projectUserCountSchema,
|
|
93
|
+
refreshTokenResponseSchema: () => refreshTokenResponseSchema,
|
|
94
|
+
selectedTeamIdSchema: () => selectedTeamIdSchema,
|
|
95
|
+
serverOrHigherAuthTypeSchema: () => serverOrHigherAuthTypeSchema,
|
|
96
|
+
signInEmailSchema: () => signInEmailSchema,
|
|
97
|
+
signInResponseSchema: () => signInResponseSchema,
|
|
98
|
+
signedUpAtMillisSchema: () => signedUpAtMillisSchema,
|
|
99
|
+
strictEmailSchema: () => strictEmailSchema,
|
|
100
|
+
teamClientMetadataSchema: () => teamClientMetadataSchema,
|
|
101
|
+
teamClientReadOnlyMetadataSchema: () => teamClientReadOnlyMetadataSchema,
|
|
102
|
+
teamCreatedAtMillisSchema: () => teamCreatedAtMillisSchema,
|
|
103
|
+
teamCreatorUserIdSchema: () => teamCreatorUserIdSchema,
|
|
104
|
+
teamDisplayNameSchema: () => teamDisplayNameSchema,
|
|
105
|
+
teamIdSchema: () => teamIdSchema,
|
|
106
|
+
teamInvitationCallbackUrlSchema: () => teamInvitationCallbackUrlSchema,
|
|
107
|
+
teamInvitationEmailSchema: () => teamInvitationEmailSchema,
|
|
108
|
+
teamMemberDisplayNameSchema: () => teamMemberDisplayNameSchema,
|
|
109
|
+
teamMemberProfileImageUrlSchema: () => teamMemberProfileImageUrlSchema,
|
|
110
|
+
teamPermissionDescriptionSchema: () => teamPermissionDescriptionSchema,
|
|
111
|
+
teamProfileImageUrlSchema: () => teamProfileImageUrlSchema,
|
|
112
|
+
teamServerMetadataSchema: () => teamServerMetadataSchema,
|
|
113
|
+
teamSystemPermissions: () => teamSystemPermissions,
|
|
114
|
+
urlSchema: () => urlSchema,
|
|
115
|
+
userClientMetadataSchema: () => userClientMetadataSchema,
|
|
116
|
+
userClientReadOnlyMetadataSchema: () => userClientReadOnlyMetadataSchema,
|
|
117
|
+
userDisplayNameSchema: () => userDisplayNameSchema,
|
|
118
|
+
userHasPasswordSchema: () => userHasPasswordSchema,
|
|
119
|
+
userIdOrMeSchema: () => userIdOrMeSchema,
|
|
120
|
+
userIdSchema: () => userIdSchema,
|
|
121
|
+
userLastActiveAtMillisSchema: () => userLastActiveAtMillisSchema,
|
|
122
|
+
userOAuthProviderSchema: () => userOAuthProviderSchema,
|
|
123
|
+
userOtpAuthEnabledMutationSchema: () => userOtpAuthEnabledMutationSchema,
|
|
124
|
+
userOtpAuthEnabledSchema: () => userOtpAuthEnabledSchema,
|
|
125
|
+
userPasskeyAuthEnabledSchema: () => userPasskeyAuthEnabledSchema,
|
|
126
|
+
userPasswordHashMutationSchema: () => userPasswordHashMutationSchema,
|
|
127
|
+
userPasswordMutationSchema: () => userPasswordMutationSchema,
|
|
128
|
+
userServerMetadataSchema: () => userServerMetadataSchema,
|
|
129
|
+
userTotpSecretMutationSchema: () => userTotpSecretMutationSchema,
|
|
130
|
+
yupArray: () => yupArray,
|
|
131
|
+
yupBoolean: () => yupBoolean,
|
|
132
|
+
yupDate: () => yupDate,
|
|
133
|
+
yupDefinedAndNonEmptyWhen: () => yupDefinedAndNonEmptyWhen,
|
|
134
|
+
yupDefinedWhen: () => yupDefinedWhen,
|
|
135
|
+
yupMixed: () => yupMixed,
|
|
136
|
+
yupNever: () => yupNever,
|
|
137
|
+
yupNumber: () => yupNumber,
|
|
138
|
+
yupObject: () => yupObject,
|
|
139
|
+
yupRecord: () => yupRecord,
|
|
140
|
+
yupString: () => yupString,
|
|
141
|
+
yupTuple: () => yupTuple,
|
|
142
|
+
yupUnion: () => yupUnion,
|
|
143
|
+
yupValidate: () => yupValidate
|
|
20
144
|
});
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
145
|
+
module.exports = __toCommonJS(schema_fields_exports);
|
|
146
|
+
var yup = __toESM(require("yup"), 1);
|
|
147
|
+
var import__ = require(".");
|
|
148
|
+
var import_bytes = require("./utils/bytes");
|
|
149
|
+
var import_errors = require("./utils/errors");
|
|
150
|
+
var import_http = require("./utils/http");
|
|
151
|
+
var import_oauth = require("./utils/oauth");
|
|
152
|
+
var import_objects = require("./utils/objects");
|
|
153
|
+
var import_urls = require("./utils/urls");
|
|
154
|
+
var import_uuids = require("./utils/uuids");
|
|
155
|
+
yup.addMethod(yup.string, "nonEmpty", function(message) {
|
|
156
|
+
return this.test(
|
|
157
|
+
"non-empty",
|
|
158
|
+
message ?? (({ path }) => `${path} must not be empty`),
|
|
159
|
+
(value) => {
|
|
160
|
+
return value !== "";
|
|
30
161
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
162
|
+
);
|
|
163
|
+
});
|
|
164
|
+
yup.addMethod(yup.Schema, "getNested", function(path) {
|
|
165
|
+
if (!path.match(/^[a-zA-Z_][a-zA-Z0-9_]*$/)) throw new import_errors.StackAssertionError(`yupSchema.getNested can currently only be used with alphanumeric keys. Fix this in the future. Provided key: ${path}`);
|
|
166
|
+
return yup.reach(this, path);
|
|
167
|
+
});
|
|
168
|
+
async function yupValidate(schema, obj, options) {
|
|
169
|
+
try {
|
|
170
|
+
return await schema.validate(obj, {
|
|
171
|
+
...(0, import_objects.omit)(options ?? {}, ["currentUserId"]),
|
|
172
|
+
context: {
|
|
173
|
+
...options?.context,
|
|
174
|
+
stackAllowUserIdMe: options?.currentUserId !== void 0
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
} catch (error) {
|
|
178
|
+
if (error instanceof ReplaceFieldWithOwnUserId) {
|
|
179
|
+
const currentUserId = options?.currentUserId;
|
|
180
|
+
if (!currentUserId) throw new import__.KnownErrors.CannotGetOwnUserWithoutUser();
|
|
181
|
+
let pathRemaining = error.path;
|
|
182
|
+
const fieldPath = [];
|
|
183
|
+
while (pathRemaining.length > 0) {
|
|
184
|
+
if (pathRemaining.startsWith("[")) {
|
|
185
|
+
const index = pathRemaining.indexOf("]");
|
|
186
|
+
if (index < 0) throw new import_errors.StackAssertionError("Invalid path");
|
|
187
|
+
fieldPath.push(JSON.parse(pathRemaining.slice(1, index)));
|
|
188
|
+
pathRemaining = pathRemaining.slice(index + 1);
|
|
189
|
+
} else {
|
|
190
|
+
let dotIndex = pathRemaining.indexOf(".");
|
|
191
|
+
if (dotIndex === -1) dotIndex = pathRemaining.length;
|
|
192
|
+
fieldPath.push(pathRemaining.slice(0, dotIndex));
|
|
193
|
+
pathRemaining = pathRemaining.slice(dotIndex + 1);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
const newObj = (0, import_objects.deepPlainClone)(obj);
|
|
197
|
+
let it = newObj;
|
|
198
|
+
for (const field of fieldPath.slice(0, -1)) {
|
|
199
|
+
if (!Object.prototype.hasOwnProperty.call(it, field)) {
|
|
200
|
+
throw new import_errors.StackAssertionError(`Segment ${field} of path ${error.path} not found in object`);
|
|
65
201
|
}
|
|
66
|
-
|
|
202
|
+
it = it[field];
|
|
203
|
+
}
|
|
204
|
+
it[fieldPath[fieldPath.length - 1]] = currentUserId;
|
|
205
|
+
return await yupValidate(schema, newObj, options);
|
|
67
206
|
}
|
|
207
|
+
throw error;
|
|
208
|
+
}
|
|
68
209
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
82
|
-
return yup.string(...args);
|
|
210
|
+
var _idDescription = (identify) => `The unique identifier of the ${identify}`;
|
|
211
|
+
var _displayNameDescription = (identify) => `Human-readable ${identify} display name. This is not a unique identifier.`;
|
|
212
|
+
var _clientMetaDataDescription = (identify) => `Client metadata. Used as a data store, accessible from the client side. Do not store information that should not be exposed to the client.`;
|
|
213
|
+
var _clientReadOnlyMetaDataDescription = (identify) => `Client read-only, server-writable metadata. Used as a data store, accessible from the client side. Do not store information that should not be exposed to the client. The client can read this data, but cannot modify it. This is useful for things like subscription status.`;
|
|
214
|
+
var _profileImageUrlDescription = (identify) => `URL of the profile image for ${identify}. Can be a Base64 encoded image. Must be smaller than 100KB. Please compress and crop to a square before passing in.`;
|
|
215
|
+
var _serverMetaDataDescription = (identify) => `Server metadata. Used as a data store, only accessible from the server side. You can store secret information related to the ${identify} here.`;
|
|
216
|
+
var _atMillisDescription = (identify) => `(the number of milliseconds since epoch, January 1, 1970, UTC)`;
|
|
217
|
+
var _createdAtMillisDescription = (identify) => `The time the ${identify} was created ${_atMillisDescription(identify)}`;
|
|
218
|
+
var _signedUpAtMillisDescription = `The time the user signed up ${_atMillisDescription}`;
|
|
219
|
+
var _lastActiveAtMillisDescription = `The time the user was last active ${_atMillisDescription}`;
|
|
220
|
+
function yupString(...args) {
|
|
221
|
+
return yup.string(...args);
|
|
83
222
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
return yup.number(...args);
|
|
223
|
+
function yupNumber(...args) {
|
|
224
|
+
return yup.number(...args);
|
|
87
225
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
return yup.boolean(...args);
|
|
226
|
+
function yupBoolean(...args) {
|
|
227
|
+
return yup.boolean(...args);
|
|
91
228
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
*/
|
|
95
|
-
export function yupDate(...args) {
|
|
96
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
97
|
-
return yup.date(...args);
|
|
229
|
+
function yupDate(...args) {
|
|
230
|
+
return yup.date(...args);
|
|
98
231
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
return yup.mixed(...args);
|
|
232
|
+
function yupMixed(...args) {
|
|
233
|
+
return yup.mixed(...args);
|
|
102
234
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
return yup.array(...args);
|
|
235
|
+
function yupArray(...args) {
|
|
236
|
+
return yup.array(...args);
|
|
106
237
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
return yup.tuple(...args);
|
|
238
|
+
function yupTuple(...args) {
|
|
239
|
+
return yup.tuple(...args);
|
|
110
240
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
241
|
+
function yupObject(...args) {
|
|
242
|
+
const object2 = yup.object(...args).test(
|
|
243
|
+
"no-unknown-object-properties",
|
|
244
|
+
({ path }) => `${path} contains unknown properties`,
|
|
245
|
+
(value, context) => {
|
|
246
|
+
if (context.options.context?.noUnknownPathPrefixes?.some((prefix) => context.path.startsWith(prefix))) {
|
|
247
|
+
if (context.schema.spec.noUnknown !== false) {
|
|
248
|
+
const availableKeys = new Set(Object.keys(context.schema.fields));
|
|
249
|
+
const unknownKeys = Object.keys(value ?? {}).filter((key) => !availableKeys.has(key));
|
|
250
|
+
if (unknownKeys.length > 0) {
|
|
251
|
+
return context.createError({
|
|
252
|
+
message: `${context.path || "Object"} contains unknown properties: ${unknownKeys.join(", ")}`,
|
|
253
|
+
path: context.path,
|
|
254
|
+
params: { unknownKeys, availableKeys }
|
|
255
|
+
});
|
|
256
|
+
}
|
|
127
257
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
258
|
+
}
|
|
259
|
+
return true;
|
|
260
|
+
}
|
|
261
|
+
);
|
|
262
|
+
return object2.default(void 0);
|
|
132
263
|
}
|
|
133
|
-
|
|
134
|
-
|
|
264
|
+
function yupNever() {
|
|
265
|
+
return yupMixed().test("never", "This value should never be reached", () => false);
|
|
135
266
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
267
|
+
function yupUnion(...args) {
|
|
268
|
+
if (args.length === 0) throw new Error("yupUnion must have at least one schema");
|
|
269
|
+
const [first] = args;
|
|
270
|
+
const firstDesc = first.describe();
|
|
271
|
+
for (const schema of args) {
|
|
272
|
+
const desc = schema.describe();
|
|
273
|
+
if (desc.type !== firstDesc.type) throw new import_errors.StackAssertionError(`yupUnion must have schemas of the same type (got: ${firstDesc.type} and ${desc.type})`, { first, schema, firstDesc, desc });
|
|
274
|
+
}
|
|
275
|
+
return yupMixed().test("is-one-of", "Invalid value", async (value, context) => {
|
|
276
|
+
const errors = [];
|
|
141
277
|
for (const schema of args) {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
278
|
+
try {
|
|
279
|
+
await yupValidate(schema, value, context.options);
|
|
280
|
+
return true;
|
|
281
|
+
} catch (e) {
|
|
282
|
+
errors.push(e);
|
|
283
|
+
}
|
|
145
284
|
}
|
|
146
|
-
return
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
await yupValidate(schema, value, context.options);
|
|
151
|
-
return true;
|
|
152
|
-
}
|
|
153
|
-
catch (e) {
|
|
154
|
-
errors.push(e);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
return context.createError({
|
|
158
|
-
message: `${context.path} is not matched by any of the provided schemas:\n${errors.map((e, i) => '\tSchema ' + i + ": \n\t\t" + e.errors.join('\n\t\t')).join('\n')}`,
|
|
159
|
-
path: context.path,
|
|
160
|
-
});
|
|
285
|
+
return context.createError({
|
|
286
|
+
message: `${context.path} is not matched by any of the provided schemas:
|
|
287
|
+
${errors.map((e, i) => " Schema " + i + ": \n " + e.errors.join("\n ")).join("\n")}`,
|
|
288
|
+
path: context.path
|
|
161
289
|
});
|
|
290
|
+
});
|
|
162
291
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
path: path ? `${path}.${key}` : key,
|
|
182
|
-
},
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
catch (e) {
|
|
186
|
-
return createError({
|
|
187
|
-
path: path ? `${path}.${key}` : key,
|
|
188
|
-
message: e.message,
|
|
189
|
-
});
|
|
292
|
+
function yupRecord(keySchema, valueSchema) {
|
|
293
|
+
return yupObject().unknown(true).test(
|
|
294
|
+
"record",
|
|
295
|
+
"${path} must be a record of valid values",
|
|
296
|
+
async function(value, context) {
|
|
297
|
+
if (value == null) return true;
|
|
298
|
+
const { path, createError } = this;
|
|
299
|
+
if (typeof value !== "object") {
|
|
300
|
+
return createError({ message: `${path} must be an object` });
|
|
301
|
+
}
|
|
302
|
+
for (const key of Object.keys(value)) {
|
|
303
|
+
await yupValidate(keySchema, key, context.options);
|
|
304
|
+
try {
|
|
305
|
+
await yupValidate(valueSchema, value[key], {
|
|
306
|
+
...context.options,
|
|
307
|
+
context: {
|
|
308
|
+
...context.options.context,
|
|
309
|
+
path: path ? `${path}.${key}` : key
|
|
190
310
|
}
|
|
311
|
+
});
|
|
312
|
+
} catch (e) {
|
|
313
|
+
return createError({
|
|
314
|
+
path: path ? `${path}.${key}` : key,
|
|
315
|
+
message: e.message
|
|
316
|
+
});
|
|
191
317
|
}
|
|
192
|
-
|
|
193
|
-
|
|
318
|
+
}
|
|
319
|
+
return true;
|
|
320
|
+
}
|
|
321
|
+
);
|
|
194
322
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
return schema;
|
|
323
|
+
function ensureObjectSchema(schema) {
|
|
324
|
+
if (!(schema instanceof yup.ObjectSchema)) throw new import_errors.StackAssertionError(`assertObjectSchema: schema is not an ObjectSchema: ${schema.describe().type}`);
|
|
325
|
+
return schema;
|
|
199
326
|
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
export const urlSchema = yupString().test({
|
|
206
|
-
name: 'no-spaces',
|
|
207
|
-
message: (params) => `${params.path} contains spaces`,
|
|
208
|
-
test: (value) => value == null || !value.includes(' ')
|
|
327
|
+
var adaptSchema = yupMixed();
|
|
328
|
+
var urlSchema = yupString().test({
|
|
329
|
+
name: "no-spaces",
|
|
330
|
+
message: (params) => `${params.path} contains spaces`,
|
|
331
|
+
test: (value) => value == null || !value.includes(" ")
|
|
209
332
|
}).test({
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
});
|
|
214
|
-
export const jsonSchema = yupMixed().nullable().defined().transform((value) => JSON.parse(JSON.stringify(value)));
|
|
215
|
-
export const jsonStringSchema = yupString().test("json", (params) => `${params.path} is not valid JSON`, (value) => {
|
|
216
|
-
if (value == null)
|
|
217
|
-
return true;
|
|
218
|
-
try {
|
|
219
|
-
JSON.parse(value);
|
|
220
|
-
return true;
|
|
221
|
-
}
|
|
222
|
-
catch (error) {
|
|
223
|
-
return false;
|
|
224
|
-
}
|
|
333
|
+
name: "url",
|
|
334
|
+
message: (params) => `${params.path} is not a valid URL`,
|
|
335
|
+
test: (value) => value == null || (0, import_urls.isValidUrl)(value)
|
|
225
336
|
});
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
}
|
|
337
|
+
var jsonSchema = yupMixed().nullable().defined().transform((value) => JSON.parse(JSON.stringify(value)));
|
|
338
|
+
var jsonStringSchema = yupString().test("json", (params) => `${params.path} is not valid JSON`, (value) => {
|
|
339
|
+
if (value == null) return true;
|
|
340
|
+
try {
|
|
341
|
+
JSON.parse(value);
|
|
342
|
+
return true;
|
|
343
|
+
} catch (error) {
|
|
344
|
+
return false;
|
|
345
|
+
}
|
|
236
346
|
});
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
347
|
+
var jsonStringOrEmptySchema = yupString().test("json", (params) => `${params.path} is not valid JSON`, (value) => {
|
|
348
|
+
if (!value) return true;
|
|
349
|
+
try {
|
|
350
|
+
JSON.parse(value);
|
|
351
|
+
return true;
|
|
352
|
+
} catch (error) {
|
|
353
|
+
return false;
|
|
354
|
+
}
|
|
241
355
|
});
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
* example `test@localhost` or `abc@gmail`, but almost certainly a user input error.)
|
|
246
|
-
*
|
|
247
|
-
* Note that some users in the DB have an email that doesn't match this regex, so most of the time you should use
|
|
248
|
-
* `emailSchema` instead until we do the DB migration.
|
|
249
|
-
*/
|
|
250
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
251
|
-
export const strictEmailSchema = (message) => yupString().email(message).matches(/^[^.]+(\.[^.]+)*@.*\.[^.][^.]+$/, message);
|
|
252
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
253
|
-
export const emailSchema = yupString().email();
|
|
254
|
-
import.meta.vitest?.test('strictEmailSchema', ({ expect }) => {
|
|
255
|
-
const validEmails = [
|
|
256
|
-
"a@example.com",
|
|
257
|
-
"abc@example.com",
|
|
258
|
-
"a.b@example.com",
|
|
259
|
-
"throwaway.mail+token@example.com",
|
|
260
|
-
"email-alt-dash@demo-mail.com",
|
|
261
|
-
"test-account@weird-domain.net",
|
|
262
|
-
"%!~&+{}=|`#@domain.test",
|
|
263
|
-
"admin@a.longtldexample",
|
|
264
|
-
];
|
|
265
|
-
for (const email of validEmails) {
|
|
266
|
-
expect(strictEmailSchema(undefined).validateSync(email)).toBe(email);
|
|
267
|
-
}
|
|
268
|
-
const invalidEmails = [
|
|
269
|
-
"test@localhost",
|
|
270
|
-
"test@gmail",
|
|
271
|
-
"test@gmail.com.a",
|
|
272
|
-
"test@gmail.a",
|
|
273
|
-
"test.@example.com",
|
|
274
|
-
"test..test@example.com",
|
|
275
|
-
".test@example.com",
|
|
276
|
-
];
|
|
277
|
-
for (const email of invalidEmails) {
|
|
278
|
-
expect(() => strictEmailSchema(undefined).validateSync(email)).toThrow();
|
|
279
|
-
}
|
|
356
|
+
var base64Schema = yupString().test("is-base64", (params) => `${params.path} is not valid base64`, (value) => {
|
|
357
|
+
if (value == null) return true;
|
|
358
|
+
return (0, import_bytes.isBase64)(value);
|
|
280
359
|
});
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
const userIdMeSentinelUuid = "cad564fd-f81b-43f4-b390-98abf3fcc17e";
|
|
329
|
-
export const userIdOrMeSchema = yupString().uuid().transform(v => {
|
|
330
|
-
if (v === "me")
|
|
331
|
-
return userIdMeSentinelUuid;
|
|
332
|
-
else
|
|
333
|
-
return v;
|
|
360
|
+
var passwordSchema = yupString().max(70);
|
|
361
|
+
var strictEmailSchema = (message) => yupString().email(message).matches(/^[^.]+(\.[^.]+)*@.*\.[^.][^.]+$/, message);
|
|
362
|
+
var emailSchema = yupString().email();
|
|
363
|
+
var clientOrHigherAuthTypeSchema = yupString().oneOf(["client", "server", "admin"]).defined();
|
|
364
|
+
var serverOrHigherAuthTypeSchema = yupString().oneOf(["server", "admin"]).defined();
|
|
365
|
+
var adminAuthTypeSchema = yupString().oneOf(["admin"]).defined();
|
|
366
|
+
var projectIdSchema = yupString().test((v) => v === void 0 || v === "internal" || (0, import_uuids.isUuid)(v)).meta({ openapiField: { description: _idDescription("project"), exampleValue: "e0b52f4d-dece-408c-af49-d23061bb0f8d" } });
|
|
367
|
+
var projectDisplayNameSchema = yupString().meta({ openapiField: { description: _displayNameDescription("project"), exampleValue: "MyMusic" } });
|
|
368
|
+
var projectDescriptionSchema = yupString().nullable().meta({ openapiField: { description: "A human readable description of the project", exampleValue: "A music streaming service" } });
|
|
369
|
+
var projectCreatedAtMillisSchema = yupNumber().meta({ openapiField: { description: _createdAtMillisDescription("project"), exampleValue: 163e10 } });
|
|
370
|
+
var projectUserCountSchema = yupNumber().meta({ openapiField: { description: "The number of users in this project", exampleValue: 10 } });
|
|
371
|
+
var projectIsProductionModeSchema = yupBoolean().meta({ openapiField: { description: "Whether the project is in production mode", exampleValue: true } });
|
|
372
|
+
var projectConfigIdSchema = yupString().meta({ openapiField: { description: _idDescription("project config"), exampleValue: "d09201f0-54f5-40bd-89ff-6d1815ddad24" } });
|
|
373
|
+
var projectAllowLocalhostSchema = yupBoolean().meta({ openapiField: { description: "Whether localhost is allowed as a domain for this project. Should only be allowed in development mode", exampleValue: true } });
|
|
374
|
+
var projectCreateTeamOnSignUpSchema = yupBoolean().meta({ openapiField: { description: "Whether a team should be created for each user that signs up", exampleValue: true } });
|
|
375
|
+
var projectMagicLinkEnabledSchema = yupBoolean().meta({ openapiField: { description: "Whether magic link authentication is enabled for this project", exampleValue: true } });
|
|
376
|
+
var projectPasskeyEnabledSchema = yupBoolean().meta({ openapiField: { description: "Whether passkey authentication is enabled for this project", exampleValue: true } });
|
|
377
|
+
var projectClientTeamCreationEnabledSchema = yupBoolean().meta({ openapiField: { description: "Whether client users can create teams", exampleValue: true } });
|
|
378
|
+
var projectClientUserDeletionEnabledSchema = yupBoolean().meta({ openapiField: { description: "Whether client users can delete their own account from the client", exampleValue: true } });
|
|
379
|
+
var projectSignUpEnabledSchema = yupBoolean().meta({ openapiField: { description: "Whether users can sign up new accounts, or whether they are only allowed to sign in to existing accounts. Regardless of this option, the server API can always create new users with the `POST /users` endpoint.", exampleValue: true } });
|
|
380
|
+
var projectCredentialEnabledSchema = yupBoolean().meta({ openapiField: { description: "Whether email password authentication is enabled for this project", exampleValue: true } });
|
|
381
|
+
var oauthIdSchema = yupString().oneOf(import_oauth.allProviders).meta({ openapiField: { description: `OAuth provider ID, one of ${import_oauth.allProviders.map((x) => `\`${x}\``).join(", ")}`, exampleValue: "google" } });
|
|
382
|
+
var oauthEnabledSchema = yupBoolean().meta({ openapiField: { description: "Whether the OAuth provider is enabled. If an provider is first enabled, then disabled, it will be shown in the list but with enabled=false", exampleValue: true } });
|
|
383
|
+
var oauthTypeSchema = yupString().oneOf(["shared", "standard"]).meta({ openapiField: { description: 'OAuth provider type, one of shared, standard. "shared" uses Stack shared OAuth keys and it is only meant for development. "standard" uses your own OAuth keys and will show your logo and company name when signing in with the provider.', exampleValue: "standard" } });
|
|
384
|
+
var oauthClientIdSchema = yupString().meta({ openapiField: { description: 'OAuth client ID. Needs to be specified when using type="standard"', exampleValue: "google-oauth-client-id" } });
|
|
385
|
+
var oauthClientSecretSchema = yupString().meta({ openapiField: { description: 'OAuth client secret. Needs to be specified when using type="standard"', exampleValue: "google-oauth-client-secret" } });
|
|
386
|
+
var oauthFacebookConfigIdSchema = yupString().meta({ openapiField: { description: "The configuration id for Facebook business login (for things like ads and marketing). This is only required if you are using the standard OAuth with Facebook and you are using Facebook business login." } });
|
|
387
|
+
var oauthMicrosoftTenantIdSchema = yupString().meta({ openapiField: { description: "The Microsoft tenant id for Microsoft directory. This is only required if you are using the standard OAuth with Microsoft and you have an Azure AD tenant." } });
|
|
388
|
+
var oauthAccountMergeStrategySchema = yupString().oneOf(["link_method", "raise_error", "allow_duplicates"]).meta({ openapiField: { description: "Determines how to handle OAuth logins that match an existing user by email. `link_method` adds the OAuth method to the existing user. `raise_error` rejects the login with an error. `allow_duplicates` creates a new user.", exampleValue: "link_method" } });
|
|
389
|
+
var emailTypeSchema = yupString().oneOf(["shared", "standard"]).meta({ openapiField: { description: 'Email provider type, one of shared, standard. "shared" uses Stack shared email provider and it is only meant for development. "standard" uses your own email server and will have your email address as the sender.', exampleValue: "standard" } });
|
|
390
|
+
var emailSenderNameSchema = yupString().meta({ openapiField: { description: 'Email sender name. Needs to be specified when using type="standard"', exampleValue: "Stack" } });
|
|
391
|
+
var emailHostSchema = yupString().meta({ openapiField: { description: 'Email host. Needs to be specified when using type="standard"', exampleValue: "smtp.your-domain.com" } });
|
|
392
|
+
var emailPortSchema = yupNumber().min(0).max(65535).meta({ openapiField: { description: 'Email port. Needs to be specified when using type="standard"', exampleValue: 587 } });
|
|
393
|
+
var emailUsernameSchema = yupString().meta({ openapiField: { description: 'Email username. Needs to be specified when using type="standard"', exampleValue: "smtp-email" } });
|
|
394
|
+
var emailSenderEmailSchema = emailSchema.meta({ openapiField: { description: 'Email sender email. Needs to be specified when using type="standard"', exampleValue: "example@your-domain.com" } });
|
|
395
|
+
var emailPasswordSchema = passwordSchema.meta({ openapiField: { description: 'Email password. Needs to be specified when using type="standard"', exampleValue: "your-email-password" } });
|
|
396
|
+
var handlerPathSchema = yupString().test("is-handler-path", "Handler path must start with /", (value) => value?.startsWith("/")).meta({ openapiField: { description: 'Handler path. If you did not setup a custom handler path, it should be "/handler" by default. It needs to start with /', exampleValue: "/handler" } });
|
|
397
|
+
var ReplaceFieldWithOwnUserId = class extends Error {
|
|
398
|
+
constructor(path) {
|
|
399
|
+
super(`This error should be caught by whoever validated the schema, and the field in the path '${path}' should be replaced with the current user's id. This is a workaround to yup not providing access to the context inside the transform function.`);
|
|
400
|
+
this.path = path;
|
|
401
|
+
}
|
|
402
|
+
};
|
|
403
|
+
var userIdMeSentinelUuid = "cad564fd-f81b-43f4-b390-98abf3fcc17e";
|
|
404
|
+
var userIdOrMeSchema = yupString().uuid().transform((v) => {
|
|
405
|
+
if (v === "me") return userIdMeSentinelUuid;
|
|
406
|
+
else return v;
|
|
334
407
|
}).test((v, context) => {
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
id: yupString().defined(),
|
|
356
|
-
type: yupString().oneOf(allProviders).defined(),
|
|
357
|
-
provider_user_id: yupString().defined(),
|
|
408
|
+
if (!("stackAllowUserIdMe" in (context.options.context ?? {}))) throw new import_errors.StackAssertionError("userIdOrMeSchema is not allowed in this context. Make sure you're using yupValidate from schema-fields.ts to validate, instead of schema.validate(...).");
|
|
409
|
+
if (!context.options.context?.stackAllowUserIdMe) throw new import_errors.StackAssertionError("userIdOrMeSchema is not allowed in this context. Make sure you're passing in the currentUserId option in yupValidate.");
|
|
410
|
+
if (v === userIdMeSentinelUuid) throw new ReplaceFieldWithOwnUserId(context.path);
|
|
411
|
+
return true;
|
|
412
|
+
}).meta({ openapiField: { description: "The ID of the user, or the special value `me` for the currently authenticated user", exampleValue: "3241a285-8329-4d69-8f3d-316e08cf140c" } });
|
|
413
|
+
var userIdSchema = yupString().uuid().meta({ openapiField: { description: _idDescription("user"), exampleValue: "3241a285-8329-4d69-8f3d-316e08cf140c" } });
|
|
414
|
+
var primaryEmailSchema = emailSchema.meta({ openapiField: { description: "Primary email", exampleValue: "johndoe@example.com" } });
|
|
415
|
+
var primaryEmailAuthEnabledSchema = yupBoolean().meta({ openapiField: { description: "Whether the primary email is used for authentication. If this is set to `false`, the user will not be able to sign in with the primary email with password or OTP", exampleValue: true } });
|
|
416
|
+
var primaryEmailVerifiedSchema = yupBoolean().meta({ openapiField: { description: "Whether the primary email has been verified to belong to this user", exampleValue: true } });
|
|
417
|
+
var userDisplayNameSchema = yupString().nullable().meta({ openapiField: { description: _displayNameDescription("user"), exampleValue: "John Doe" } });
|
|
418
|
+
var selectedTeamIdSchema = yupString().uuid().meta({ openapiField: { description: "ID of the team currently selected by the user", exampleValue: "team-id" } });
|
|
419
|
+
var profileImageUrlSchema = urlSchema.max(1e6).meta({ openapiField: { description: _profileImageUrlDescription("user"), exampleValue: "https://example.com/image.jpg" } });
|
|
420
|
+
var signedUpAtMillisSchema = yupNumber().meta({ openapiField: { description: _signedUpAtMillisDescription, exampleValue: 163e10 } });
|
|
421
|
+
var userClientMetadataSchema = jsonSchema.meta({ openapiField: { description: _clientMetaDataDescription("user"), exampleValue: { key: "value" } } });
|
|
422
|
+
var userClientReadOnlyMetadataSchema = jsonSchema.meta({ openapiField: { description: _clientReadOnlyMetaDataDescription("user"), exampleValue: { key: "value" } } });
|
|
423
|
+
var userServerMetadataSchema = jsonSchema.meta({ openapiField: { description: _serverMetaDataDescription("user"), exampleValue: { key: "value" } } });
|
|
424
|
+
var userOAuthProviderSchema = yupObject({
|
|
425
|
+
id: yupString().defined(),
|
|
426
|
+
type: yupString().oneOf(import_oauth.allProviders).defined(),
|
|
427
|
+
provider_user_id: yupString().defined()
|
|
358
428
|
});
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
access_token: accessTokenResponseSchema.defined(),
|
|
378
|
-
is_new_user: yupBoolean().meta({ openapiField: { description: 'Whether the user is a new user', exampleValue: true } }).defined(),
|
|
379
|
-
user_id: userIdSchema.defined(),
|
|
429
|
+
var userLastActiveAtMillisSchema = yupNumber().nullable().meta({ openapiField: { description: _lastActiveAtMillisDescription, exampleValue: 163e10 } });
|
|
430
|
+
var userPasskeyAuthEnabledSchema = yupBoolean().meta({ openapiField: { hidden: true, description: "Whether the user has passkeys enabled", exampleValue: false } });
|
|
431
|
+
var userOtpAuthEnabledSchema = yupBoolean().meta({ openapiField: { hidden: true, description: "Whether the user has OTP/magic link enabled. ", exampleValue: true } });
|
|
432
|
+
var userOtpAuthEnabledMutationSchema = yupBoolean().meta({ openapiField: { hidden: true, description: "Whether the user has OTP/magic link enabled. Note that only accounts with verified emails can sign-in with OTP.", exampleValue: true } });
|
|
433
|
+
var userHasPasswordSchema = yupBoolean().meta({ openapiField: { hidden: true, description: "Whether the user has a password set. If the user does not have a password set, they will not be able to sign in with email/password.", exampleValue: true } });
|
|
434
|
+
var userPasswordMutationSchema = passwordSchema.nullable().meta({ openapiField: { description: "Sets the user's password. Doing so revokes all current sessions.", exampleValue: "my-new-password" } }).max(70);
|
|
435
|
+
var userPasswordHashMutationSchema = yupString().nonEmpty().meta({ openapiField: { description: "If `password` is not given, sets the user's password hash to the given string in Modular Crypt Format (ex.: `$2a$10$VIhIOofSMqGdGlL4wzE//e.77dAQGqNtF/1dT7bqCrVtQuInWy2qi`). Doing so revokes all current sessions." } });
|
|
436
|
+
var userTotpSecretMutationSchema = base64Schema.nullable().meta({ openapiField: { description: "Enables 2FA and sets a TOTP secret for the user. Set to null to disable 2FA.", exampleValue: "dG90cC1zZWNyZXQ=" } });
|
|
437
|
+
var signInEmailSchema = strictEmailSchema(void 0).meta({ openapiField: { description: "The email to sign in with.", exampleValue: "johndoe@example.com" } });
|
|
438
|
+
var emailOtpSignInCallbackUrlSchema = urlSchema.meta({ openapiField: { description: "The base callback URL to construct the magic link from. A query parameter `code` with the verification code will be appended to it. The page should then make a request to the `/auth/otp/sign-in` endpoint.", exampleValue: "https://example.com/handler/magic-link-callback" } });
|
|
439
|
+
var emailVerificationCallbackUrlSchema = urlSchema.meta({ openapiField: { description: "The base callback URL to construct a verification link for the verification e-mail. A query parameter `code` with the verification code will be appended to it. The page should then make a request to the `/contact-channels/verify` endpoint.", exampleValue: "https://example.com/handler/email-verification" } });
|
|
440
|
+
var accessTokenResponseSchema = yupString().meta({ openapiField: { description: "Short-lived access token that can be used to authenticate the user", exampleValue: "eyJhmMiJB2TO...diI4QT" } });
|
|
441
|
+
var refreshTokenResponseSchema = yupString().meta({ openapiField: { description: "Long-lived refresh token that can be used to obtain a new access token", exampleValue: "i8ns3aq2...14y" } });
|
|
442
|
+
var signInResponseSchema = yupObject({
|
|
443
|
+
refresh_token: refreshTokenResponseSchema.defined(),
|
|
444
|
+
access_token: accessTokenResponseSchema.defined(),
|
|
445
|
+
is_new_user: yupBoolean().meta({ openapiField: { description: "Whether the user is a new user", exampleValue: true } }).defined(),
|
|
446
|
+
user_id: userIdSchema.defined()
|
|
380
447
|
});
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
'$manage_api_keys',
|
|
448
|
+
var teamSystemPermissions = [
|
|
449
|
+
"$update_team",
|
|
450
|
+
"$delete_team",
|
|
451
|
+
"$read_members",
|
|
452
|
+
"$remove_members",
|
|
453
|
+
"$invite_members",
|
|
454
|
+
"$manage_api_keys"
|
|
389
455
|
];
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
})
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
is: 'email',
|
|
425
|
-
then: (schema) => schema.email(),
|
|
426
|
-
}).meta({ openapiField: { description: 'The value of the contact channel. For email, this should be a valid email address.', exampleValue: 'johndoe@example.com' } });
|
|
427
|
-
export const contactChannelUsedForAuthSchema = yupBoolean().meta({ openapiField: { description: 'Whether the contact channel is used for authentication. If this is set to `true`, the user will be able to sign in with the contact channel with password or OTP.', exampleValue: true } });
|
|
428
|
-
export const contactChannelIsVerifiedSchema = yupBoolean().meta({ openapiField: { description: 'Whether the contact channel has been verified. If this is set to `true`, the contact channel has been verified to belong to the user.', exampleValue: true } });
|
|
429
|
-
export const contactChannelIsPrimarySchema = yupBoolean().meta({ openapiField: { description: 'Whether the contact channel is the primary contact channel. If this is set to `true`, it will be used for authentication and notifications by default.', exampleValue: true } });
|
|
430
|
-
// Headers
|
|
431
|
-
export const basicAuthorizationHeaderSchema = yupString().test('is-basic-authorization-header', 'Authorization header must be in the format "Basic <base64>"', (value) => {
|
|
432
|
-
if (!value)
|
|
433
|
-
return true;
|
|
434
|
-
return decodeBasicAuthorizationHeader(value) !== null;
|
|
456
|
+
var permissionDefinitionIdSchema = yupString().matches(/^\$?[a-z0-9_:]+$/, 'Only lowercase letters, numbers, ":", "_" and optional "$" at the beginning are allowed').test("is-system-permission", "System permissions must start with a dollar sign", (value, ctx) => {
|
|
457
|
+
if (!value) return true;
|
|
458
|
+
if (value.startsWith("$") && !teamSystemPermissions.includes(value)) {
|
|
459
|
+
return ctx.createError({ message: "Invalid system permission" });
|
|
460
|
+
}
|
|
461
|
+
return true;
|
|
462
|
+
}).meta({ openapiField: { description: `The permission ID used to uniquely identify a permission. Can either be a custom permission with lowercase letters, numbers, \`:\`, and \`_\` characters, or one of the system permissions: ${teamSystemPermissions.map((x) => `\`${x}\``).join(", ")}`, exampleValue: "read_secret_info" } });
|
|
463
|
+
var customPermissionDefinitionIdSchema = yupString().matches(/^[a-z0-9_:]+$/, 'Only lowercase letters, numbers, ":", "_" are allowed').meta({ openapiField: { description: 'The permission ID used to uniquely identify a permission. Can only contain lowercase letters, numbers, ":", and "_" characters', exampleValue: "read_secret_info" } });
|
|
464
|
+
var teamPermissionDescriptionSchema = yupString().meta({ openapiField: { description: "A human-readable description of the permission", exampleValue: "Read secret information" } });
|
|
465
|
+
var containedPermissionIdsSchema = yupArray(permissionDefinitionIdSchema.defined()).meta({ openapiField: { description: "The IDs of the permissions that are contained in this permission", exampleValue: ["read_public_info"] } });
|
|
466
|
+
var teamIdSchema = yupString().uuid().meta({ openapiField: { description: _idDescription("team"), exampleValue: "ad962777-8244-496a-b6a2-e0c6a449c79e" } });
|
|
467
|
+
var teamDisplayNameSchema = yupString().meta({ openapiField: { description: _displayNameDescription("team"), exampleValue: "My Team" } });
|
|
468
|
+
var teamProfileImageUrlSchema = urlSchema.max(1e6).meta({ openapiField: { description: _profileImageUrlDescription("team"), exampleValue: "https://example.com/image.jpg" } });
|
|
469
|
+
var teamClientMetadataSchema = jsonSchema.meta({ openapiField: { description: _clientMetaDataDescription("team"), exampleValue: { key: "value" } } });
|
|
470
|
+
var teamClientReadOnlyMetadataSchema = jsonSchema.meta({ openapiField: { description: _clientReadOnlyMetaDataDescription("team"), exampleValue: { key: "value" } } });
|
|
471
|
+
var teamServerMetadataSchema = jsonSchema.meta({ openapiField: { description: _serverMetaDataDescription("team"), exampleValue: { key: "value" } } });
|
|
472
|
+
var teamCreatedAtMillisSchema = yupNumber().meta({ openapiField: { description: _createdAtMillisDescription("team"), exampleValue: 163e10 } });
|
|
473
|
+
var teamInvitationEmailSchema = emailSchema.meta({ openapiField: { description: "The email of the user to invite.", exampleValue: "johndoe@example.com" } });
|
|
474
|
+
var teamInvitationCallbackUrlSchema = urlSchema.meta({ openapiField: { description: "The base callback URL to construct an invite link with. A query parameter `code` with the verification code will be appended to it. The page should then make a request to the `/team-invitations/accept` endpoint.", exampleValue: "https://example.com/handler/team-invitation" } });
|
|
475
|
+
var teamCreatorUserIdSchema = userIdOrMeSchema.meta({ openapiField: { description: 'The ID of the creator of the team. If not specified, the user will not be added to the team. Can be either "me" or the ID of the user. Only used on the client side.', exampleValue: "me" } });
|
|
476
|
+
var teamMemberDisplayNameSchema = yupString().meta({ openapiField: { description: _displayNameDescription("team member") + " Note that this is separate from the display_name of the user.", exampleValue: "John Doe" } });
|
|
477
|
+
var teamMemberProfileImageUrlSchema = urlSchema.max(1e6).meta({ openapiField: { description: _profileImageUrlDescription("team member"), exampleValue: "https://example.com/image.jpg" } });
|
|
478
|
+
var contactChannelIdSchema = yupString().uuid().meta({ openapiField: { description: _idDescription("contact channel"), exampleValue: "b3d396b8-c574-4c80-97b3-50031675ceb2" } });
|
|
479
|
+
var contactChannelTypeSchema = yupString().oneOf(["email"]).meta({ openapiField: { description: `The type of the contact channel. Currently only "email" is supported.`, exampleValue: "email" } });
|
|
480
|
+
var contactChannelValueSchema = yupString().when("type", {
|
|
481
|
+
is: "email",
|
|
482
|
+
then: (schema) => schema.email()
|
|
483
|
+
}).meta({ openapiField: { description: "The value of the contact channel. For email, this should be a valid email address.", exampleValue: "johndoe@example.com" } });
|
|
484
|
+
var contactChannelUsedForAuthSchema = yupBoolean().meta({ openapiField: { description: "Whether the contact channel is used for authentication. If this is set to `true`, the user will be able to sign in with the contact channel with password or OTP.", exampleValue: true } });
|
|
485
|
+
var contactChannelIsVerifiedSchema = yupBoolean().meta({ openapiField: { description: "Whether the contact channel has been verified. If this is set to `true`, the contact channel has been verified to belong to the user.", exampleValue: true } });
|
|
486
|
+
var contactChannelIsPrimarySchema = yupBoolean().meta({ openapiField: { description: "Whether the contact channel is the primary contact channel. If this is set to `true`, it will be used for authentication and notifications by default.", exampleValue: true } });
|
|
487
|
+
var basicAuthorizationHeaderSchema = yupString().test("is-basic-authorization-header", 'Authorization header must be in the format "Basic <base64>"', (value) => {
|
|
488
|
+
if (!value) return true;
|
|
489
|
+
return (0, import_http.decodeBasicAuthorizationHeader)(value) !== null;
|
|
435
490
|
});
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
return true;
|
|
444
|
-
}
|
|
445
|
-
return false;
|
|
491
|
+
var neonAuthorizationHeaderSchema = basicAuthorizationHeaderSchema.test("is-neon-authorization-header", "Invalid client_id:client_secret values; did you use the correct values for the Neon integration?", (value) => {
|
|
492
|
+
if (!value) return true;
|
|
493
|
+
const [clientId, clientSecret] = (0, import_http.decodeBasicAuthorizationHeader)(value) ?? (0, import_errors.throwErr)(`Neon authz header invalid? This should've been validated by basicAuthorizationHeaderSchema: ${value}`);
|
|
494
|
+
for (const neonClientConfig of JSON.parse(process.env.STACK_NEON_INTEGRATION_CLIENTS_CONFIG || "[]")) {
|
|
495
|
+
if (clientId === neonClientConfig.client_id && clientSecret === neonClientConfig.client_secret) return true;
|
|
496
|
+
}
|
|
497
|
+
return false;
|
|
446
498
|
});
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
});
|
|
499
|
+
function yupDefinedWhen(schema, triggers) {
|
|
500
|
+
const entries = Object.entries(triggers);
|
|
501
|
+
return schema.when(entries.map(([key]) => key), {
|
|
502
|
+
is: (...values) => entries.every(([key, value], index) => value === values[index]),
|
|
503
|
+
then: (schema2) => schema2.defined(),
|
|
504
|
+
otherwise: (schema2) => schema2.optional()
|
|
505
|
+
});
|
|
455
506
|
}
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
507
|
+
function yupDefinedAndNonEmptyWhen(schema, triggers) {
|
|
508
|
+
const entries = Object.entries(triggers);
|
|
509
|
+
return schema.when(entries.map(([key]) => key), {
|
|
510
|
+
is: (...values) => entries.every(([key, value], index) => value === values[index]),
|
|
511
|
+
then: (schema2) => schema2.defined().nonEmpty(),
|
|
512
|
+
otherwise: (schema2) => schema2.optional()
|
|
513
|
+
});
|
|
463
514
|
}
|
|
515
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
516
|
+
0 && (module.exports = {
|
|
517
|
+
ReplaceFieldWithOwnUserId,
|
|
518
|
+
accessTokenResponseSchema,
|
|
519
|
+
adaptSchema,
|
|
520
|
+
adminAuthTypeSchema,
|
|
521
|
+
base64Schema,
|
|
522
|
+
basicAuthorizationHeaderSchema,
|
|
523
|
+
clientOrHigherAuthTypeSchema,
|
|
524
|
+
contactChannelIdSchema,
|
|
525
|
+
contactChannelIsPrimarySchema,
|
|
526
|
+
contactChannelIsVerifiedSchema,
|
|
527
|
+
contactChannelTypeSchema,
|
|
528
|
+
contactChannelUsedForAuthSchema,
|
|
529
|
+
contactChannelValueSchema,
|
|
530
|
+
containedPermissionIdsSchema,
|
|
531
|
+
customPermissionDefinitionIdSchema,
|
|
532
|
+
emailHostSchema,
|
|
533
|
+
emailOtpSignInCallbackUrlSchema,
|
|
534
|
+
emailPasswordSchema,
|
|
535
|
+
emailPortSchema,
|
|
536
|
+
emailSchema,
|
|
537
|
+
emailSenderEmailSchema,
|
|
538
|
+
emailSenderNameSchema,
|
|
539
|
+
emailTypeSchema,
|
|
540
|
+
emailUsernameSchema,
|
|
541
|
+
emailVerificationCallbackUrlSchema,
|
|
542
|
+
ensureObjectSchema,
|
|
543
|
+
handlerPathSchema,
|
|
544
|
+
jsonSchema,
|
|
545
|
+
jsonStringOrEmptySchema,
|
|
546
|
+
jsonStringSchema,
|
|
547
|
+
neonAuthorizationHeaderSchema,
|
|
548
|
+
oauthAccountMergeStrategySchema,
|
|
549
|
+
oauthClientIdSchema,
|
|
550
|
+
oauthClientSecretSchema,
|
|
551
|
+
oauthEnabledSchema,
|
|
552
|
+
oauthFacebookConfigIdSchema,
|
|
553
|
+
oauthIdSchema,
|
|
554
|
+
oauthMicrosoftTenantIdSchema,
|
|
555
|
+
oauthTypeSchema,
|
|
556
|
+
passwordSchema,
|
|
557
|
+
permissionDefinitionIdSchema,
|
|
558
|
+
primaryEmailAuthEnabledSchema,
|
|
559
|
+
primaryEmailSchema,
|
|
560
|
+
primaryEmailVerifiedSchema,
|
|
561
|
+
profileImageUrlSchema,
|
|
562
|
+
projectAllowLocalhostSchema,
|
|
563
|
+
projectClientTeamCreationEnabledSchema,
|
|
564
|
+
projectClientUserDeletionEnabledSchema,
|
|
565
|
+
projectConfigIdSchema,
|
|
566
|
+
projectCreateTeamOnSignUpSchema,
|
|
567
|
+
projectCreatedAtMillisSchema,
|
|
568
|
+
projectCredentialEnabledSchema,
|
|
569
|
+
projectDescriptionSchema,
|
|
570
|
+
projectDisplayNameSchema,
|
|
571
|
+
projectIdSchema,
|
|
572
|
+
projectIsProductionModeSchema,
|
|
573
|
+
projectMagicLinkEnabledSchema,
|
|
574
|
+
projectPasskeyEnabledSchema,
|
|
575
|
+
projectSignUpEnabledSchema,
|
|
576
|
+
projectUserCountSchema,
|
|
577
|
+
refreshTokenResponseSchema,
|
|
578
|
+
selectedTeamIdSchema,
|
|
579
|
+
serverOrHigherAuthTypeSchema,
|
|
580
|
+
signInEmailSchema,
|
|
581
|
+
signInResponseSchema,
|
|
582
|
+
signedUpAtMillisSchema,
|
|
583
|
+
strictEmailSchema,
|
|
584
|
+
teamClientMetadataSchema,
|
|
585
|
+
teamClientReadOnlyMetadataSchema,
|
|
586
|
+
teamCreatedAtMillisSchema,
|
|
587
|
+
teamCreatorUserIdSchema,
|
|
588
|
+
teamDisplayNameSchema,
|
|
589
|
+
teamIdSchema,
|
|
590
|
+
teamInvitationCallbackUrlSchema,
|
|
591
|
+
teamInvitationEmailSchema,
|
|
592
|
+
teamMemberDisplayNameSchema,
|
|
593
|
+
teamMemberProfileImageUrlSchema,
|
|
594
|
+
teamPermissionDescriptionSchema,
|
|
595
|
+
teamProfileImageUrlSchema,
|
|
596
|
+
teamServerMetadataSchema,
|
|
597
|
+
teamSystemPermissions,
|
|
598
|
+
urlSchema,
|
|
599
|
+
userClientMetadataSchema,
|
|
600
|
+
userClientReadOnlyMetadataSchema,
|
|
601
|
+
userDisplayNameSchema,
|
|
602
|
+
userHasPasswordSchema,
|
|
603
|
+
userIdOrMeSchema,
|
|
604
|
+
userIdSchema,
|
|
605
|
+
userLastActiveAtMillisSchema,
|
|
606
|
+
userOAuthProviderSchema,
|
|
607
|
+
userOtpAuthEnabledMutationSchema,
|
|
608
|
+
userOtpAuthEnabledSchema,
|
|
609
|
+
userPasskeyAuthEnabledSchema,
|
|
610
|
+
userPasswordHashMutationSchema,
|
|
611
|
+
userPasswordMutationSchema,
|
|
612
|
+
userServerMetadataSchema,
|
|
613
|
+
userTotpSecretMutationSchema,
|
|
614
|
+
yupArray,
|
|
615
|
+
yupBoolean,
|
|
616
|
+
yupDate,
|
|
617
|
+
yupDefinedAndNonEmptyWhen,
|
|
618
|
+
yupDefinedWhen,
|
|
619
|
+
yupMixed,
|
|
620
|
+
yupNever,
|
|
621
|
+
yupNumber,
|
|
622
|
+
yupObject,
|
|
623
|
+
yupRecord,
|
|
624
|
+
yupString,
|
|
625
|
+
yupTuple,
|
|
626
|
+
yupUnion,
|
|
627
|
+
yupValidate
|
|
628
|
+
});
|
|
629
|
+
//# sourceMappingURL=schema-fields.js.map
|