@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
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
// src/interface/crud/users.ts
|
|
2
|
+
import { createCrud } from "../../crud";
|
|
3
|
+
import * as fieldSchema from "../../schema-fields";
|
|
4
|
+
import { teamsCrudServerReadSchema } from "./teams";
|
|
5
|
+
var usersCrudServerUpdateSchema = fieldSchema.yupObject({
|
|
6
|
+
display_name: fieldSchema.userDisplayNameSchema.optional(),
|
|
7
|
+
profile_image_url: fieldSchema.profileImageUrlSchema.nullable().optional(),
|
|
8
|
+
client_metadata: fieldSchema.userClientMetadataSchema.optional(),
|
|
9
|
+
client_read_only_metadata: fieldSchema.userClientReadOnlyMetadataSchema.optional(),
|
|
10
|
+
server_metadata: fieldSchema.userServerMetadataSchema.optional(),
|
|
11
|
+
primary_email: fieldSchema.primaryEmailSchema.nullable().optional().nonEmpty(),
|
|
12
|
+
primary_email_verified: fieldSchema.primaryEmailVerifiedSchema.optional(),
|
|
13
|
+
primary_email_auth_enabled: fieldSchema.primaryEmailAuthEnabledSchema.optional(),
|
|
14
|
+
passkey_auth_enabled: fieldSchema.userOtpAuthEnabledSchema.optional(),
|
|
15
|
+
password: fieldSchema.userPasswordMutationSchema.optional(),
|
|
16
|
+
password_hash: fieldSchema.userPasswordHashMutationSchema.optional(),
|
|
17
|
+
otp_auth_enabled: fieldSchema.userOtpAuthEnabledMutationSchema.optional(),
|
|
18
|
+
totp_secret_base64: fieldSchema.userTotpSecretMutationSchema.optional(),
|
|
19
|
+
selected_team_id: fieldSchema.selectedTeamIdSchema.nullable().optional(),
|
|
20
|
+
is_anonymous: fieldSchema.yupBoolean().oneOf([false]).optional()
|
|
21
|
+
}).defined();
|
|
22
|
+
var usersCrudServerReadSchema = fieldSchema.yupObject({
|
|
23
|
+
id: fieldSchema.userIdSchema.defined(),
|
|
24
|
+
primary_email: fieldSchema.primaryEmailSchema.nullable().defined(),
|
|
25
|
+
primary_email_verified: fieldSchema.primaryEmailVerifiedSchema.defined(),
|
|
26
|
+
primary_email_auth_enabled: fieldSchema.primaryEmailAuthEnabledSchema.defined(),
|
|
27
|
+
display_name: fieldSchema.userDisplayNameSchema.nullable().defined(),
|
|
28
|
+
selected_team: teamsCrudServerReadSchema.nullable().defined(),
|
|
29
|
+
selected_team_id: fieldSchema.selectedTeamIdSchema.nullable().defined(),
|
|
30
|
+
profile_image_url: fieldSchema.profileImageUrlSchema.nullable().defined(),
|
|
31
|
+
signed_up_at_millis: fieldSchema.signedUpAtMillisSchema.defined(),
|
|
32
|
+
has_password: fieldSchema.userHasPasswordSchema.defined(),
|
|
33
|
+
otp_auth_enabled: fieldSchema.userOtpAuthEnabledSchema.defined(),
|
|
34
|
+
passkey_auth_enabled: fieldSchema.userOtpAuthEnabledSchema.defined(),
|
|
35
|
+
client_metadata: fieldSchema.userClientMetadataSchema,
|
|
36
|
+
client_read_only_metadata: fieldSchema.userClientReadOnlyMetadataSchema,
|
|
37
|
+
server_metadata: fieldSchema.userServerMetadataSchema,
|
|
38
|
+
last_active_at_millis: fieldSchema.userLastActiveAtMillisSchema.nonNullable().defined(),
|
|
39
|
+
is_anonymous: fieldSchema.yupBoolean().defined(),
|
|
40
|
+
oauth_providers: fieldSchema.yupArray(fieldSchema.yupObject({
|
|
41
|
+
id: fieldSchema.yupString().defined(),
|
|
42
|
+
account_id: fieldSchema.yupString().defined(),
|
|
43
|
+
email: fieldSchema.yupString().nullable()
|
|
44
|
+
}).defined()).defined().meta({ openapiField: { hidden: true } }),
|
|
45
|
+
/**
|
|
46
|
+
* @deprecated
|
|
47
|
+
*/
|
|
48
|
+
auth_with_email: fieldSchema.yupBoolean().defined().meta({ openapiField: { hidden: true, description: "Whether the user can authenticate with their primary e-mail. If set to true, the user can log-in with credentials and/or magic link, if enabled in the project settings.", exampleValue: true } }),
|
|
49
|
+
/**
|
|
50
|
+
* @deprecated
|
|
51
|
+
*/
|
|
52
|
+
requires_totp_mfa: fieldSchema.yupBoolean().defined().meta({ openapiField: { hidden: true, description: "Whether the user is required to use TOTP MFA to sign in", exampleValue: false } })
|
|
53
|
+
}).defined();
|
|
54
|
+
var usersCrudServerCreateSchema = usersCrudServerUpdateSchema.omit(["selected_team_id"]).concat(fieldSchema.yupObject({
|
|
55
|
+
oauth_providers: fieldSchema.yupArray(fieldSchema.yupObject({
|
|
56
|
+
id: fieldSchema.yupString().defined(),
|
|
57
|
+
account_id: fieldSchema.yupString().defined(),
|
|
58
|
+
email: fieldSchema.yupString().nullable().defined().default(null)
|
|
59
|
+
}).defined()).optional().meta({ openapiField: { hidden: true } }),
|
|
60
|
+
is_anonymous: fieldSchema.yupBoolean().optional()
|
|
61
|
+
}).defined());
|
|
62
|
+
var usersCrudServerDeleteSchema = fieldSchema.yupMixed();
|
|
63
|
+
var usersCrud = createCrud({
|
|
64
|
+
serverReadSchema: usersCrudServerReadSchema,
|
|
65
|
+
serverUpdateSchema: usersCrudServerUpdateSchema,
|
|
66
|
+
serverCreateSchema: usersCrudServerCreateSchema,
|
|
67
|
+
serverDeleteSchema: usersCrudServerDeleteSchema,
|
|
68
|
+
docs: {
|
|
69
|
+
serverCreate: {
|
|
70
|
+
tags: ["Users"],
|
|
71
|
+
summary: "Create user",
|
|
72
|
+
description: "Creates a new user. E-mail authentication is always enabled, and no password is set, meaning the only way to authenticate the newly created user is through magic link."
|
|
73
|
+
},
|
|
74
|
+
serverRead: {
|
|
75
|
+
tags: ["Users"],
|
|
76
|
+
summary: "Get user",
|
|
77
|
+
description: "Gets a user by user ID."
|
|
78
|
+
},
|
|
79
|
+
serverUpdate: {
|
|
80
|
+
tags: ["Users"],
|
|
81
|
+
summary: "Update user",
|
|
82
|
+
description: "Updates a user. Only the values provided will be updated."
|
|
83
|
+
},
|
|
84
|
+
serverDelete: {
|
|
85
|
+
tags: ["Users"],
|
|
86
|
+
summary: "Delete user",
|
|
87
|
+
description: "Deletes a user. Use this with caution."
|
|
88
|
+
},
|
|
89
|
+
serverList: {
|
|
90
|
+
tags: ["Users"],
|
|
91
|
+
summary: "List users",
|
|
92
|
+
description: "Lists all the users in the project."
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
var userCreatedWebhookEvent = {
|
|
97
|
+
type: "user.created",
|
|
98
|
+
schema: usersCrud.server.readSchema,
|
|
99
|
+
metadata: {
|
|
100
|
+
summary: "User Created",
|
|
101
|
+
description: "This event is triggered when a user is created.",
|
|
102
|
+
tags: ["Users"]
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
var userUpdatedWebhookEvent = {
|
|
106
|
+
type: "user.updated",
|
|
107
|
+
schema: usersCrud.server.readSchema,
|
|
108
|
+
metadata: {
|
|
109
|
+
summary: "User Updated",
|
|
110
|
+
description: "This event is triggered when a user is updated.",
|
|
111
|
+
tags: ["Users"]
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
var webhookUserDeletedSchema = fieldSchema.yupObject({
|
|
115
|
+
id: fieldSchema.userIdSchema.defined(),
|
|
116
|
+
teams: fieldSchema.yupArray(fieldSchema.yupObject({
|
|
117
|
+
id: fieldSchema.yupString().defined()
|
|
118
|
+
})).defined()
|
|
119
|
+
}).defined();
|
|
120
|
+
var userDeletedWebhookEvent = {
|
|
121
|
+
type: "user.deleted",
|
|
122
|
+
schema: webhookUserDeletedSchema,
|
|
123
|
+
metadata: {
|
|
124
|
+
summary: "User Deleted",
|
|
125
|
+
description: "This event is triggered when a user is deleted.",
|
|
126
|
+
tags: ["Users"]
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
export {
|
|
130
|
+
userCreatedWebhookEvent,
|
|
131
|
+
userDeletedWebhookEvent,
|
|
132
|
+
userUpdatedWebhookEvent,
|
|
133
|
+
usersCrud,
|
|
134
|
+
usersCrudServerCreateSchema,
|
|
135
|
+
usersCrudServerDeleteSchema,
|
|
136
|
+
usersCrudServerReadSchema,
|
|
137
|
+
usersCrudServerUpdateSchema
|
|
138
|
+
};
|
|
139
|
+
//# sourceMappingURL=users.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/interface/crud/users.ts"],"sourcesContent":["import { CrudTypeOf, createCrud } from \"../../crud\";\nimport * as fieldSchema from \"../../schema-fields\";\nimport { WebhookEvent } from \"../webhooks\";\nimport { teamsCrudServerReadSchema } from \"./teams\";\n\nexport const usersCrudServerUpdateSchema = fieldSchema.yupObject({\n display_name: fieldSchema.userDisplayNameSchema.optional(),\n profile_image_url: fieldSchema.profileImageUrlSchema.nullable().optional(),\n client_metadata: fieldSchema.userClientMetadataSchema.optional(),\n client_read_only_metadata: fieldSchema.userClientReadOnlyMetadataSchema.optional(),\n server_metadata: fieldSchema.userServerMetadataSchema.optional(),\n primary_email: fieldSchema.primaryEmailSchema.nullable().optional().nonEmpty(),\n primary_email_verified: fieldSchema.primaryEmailVerifiedSchema.optional(),\n primary_email_auth_enabled: fieldSchema.primaryEmailAuthEnabledSchema.optional(),\n passkey_auth_enabled: fieldSchema.userOtpAuthEnabledSchema.optional(),\n password: fieldSchema.userPasswordMutationSchema.optional(),\n password_hash: fieldSchema.userPasswordHashMutationSchema.optional(),\n otp_auth_enabled: fieldSchema.userOtpAuthEnabledMutationSchema.optional(),\n totp_secret_base64: fieldSchema.userTotpSecretMutationSchema.optional(),\n selected_team_id: fieldSchema.selectedTeamIdSchema.nullable().optional(),\n is_anonymous: fieldSchema.yupBoolean().oneOf([false]).optional(),\n}).defined();\n\nexport const usersCrudServerReadSchema = fieldSchema.yupObject({\n id: fieldSchema.userIdSchema.defined(),\n primary_email: fieldSchema.primaryEmailSchema.nullable().defined(),\n primary_email_verified: fieldSchema.primaryEmailVerifiedSchema.defined(),\n primary_email_auth_enabled: fieldSchema.primaryEmailAuthEnabledSchema.defined(),\n display_name: fieldSchema.userDisplayNameSchema.nullable().defined(),\n selected_team: teamsCrudServerReadSchema.nullable().defined(),\n selected_team_id: fieldSchema.selectedTeamIdSchema.nullable().defined(),\n profile_image_url: fieldSchema.profileImageUrlSchema.nullable().defined(),\n signed_up_at_millis: fieldSchema.signedUpAtMillisSchema.defined(),\n has_password: fieldSchema.userHasPasswordSchema.defined(),\n otp_auth_enabled: fieldSchema.userOtpAuthEnabledSchema.defined(),\n passkey_auth_enabled: fieldSchema.userOtpAuthEnabledSchema.defined(),\n client_metadata: fieldSchema.userClientMetadataSchema,\n client_read_only_metadata: fieldSchema.userClientReadOnlyMetadataSchema,\n server_metadata: fieldSchema.userServerMetadataSchema,\n last_active_at_millis: fieldSchema.userLastActiveAtMillisSchema.nonNullable().defined(),\n is_anonymous: fieldSchema.yupBoolean().defined(),\n\n oauth_providers: fieldSchema.yupArray(fieldSchema.yupObject({\n id: fieldSchema.yupString().defined(),\n account_id: fieldSchema.yupString().defined(),\n email: fieldSchema.yupString().nullable(),\n }).defined()).defined().meta({ openapiField: { hidden: true } }),\n\n /**\n * @deprecated\n */\n auth_with_email: fieldSchema.yupBoolean().defined().meta({ openapiField: { hidden: true, description: 'Whether the user can authenticate with their primary e-mail. If set to true, the user can log-in with credentials and/or magic link, if enabled in the project settings.', exampleValue: true } }),\n /**\n * @deprecated\n */\n requires_totp_mfa: fieldSchema.yupBoolean().defined().meta({ openapiField: { hidden: true, description: 'Whether the user is required to use TOTP MFA to sign in', exampleValue: false } }),\n}).defined();\n\nexport const usersCrudServerCreateSchema = usersCrudServerUpdateSchema.omit(['selected_team_id']).concat(fieldSchema.yupObject({\n oauth_providers: fieldSchema.yupArray(fieldSchema.yupObject({\n id: fieldSchema.yupString().defined(),\n account_id: fieldSchema.yupString().defined(),\n email: fieldSchema.yupString().nullable().defined().default(null),\n }).defined()).optional().meta({ openapiField: { hidden: true } }),\n is_anonymous: fieldSchema.yupBoolean().optional(),\n}).defined());\n\nexport const usersCrudServerDeleteSchema = fieldSchema.yupMixed();\n\nexport const usersCrud = createCrud({\n serverReadSchema: usersCrudServerReadSchema,\n serverUpdateSchema: usersCrudServerUpdateSchema,\n serverCreateSchema: usersCrudServerCreateSchema,\n serverDeleteSchema: usersCrudServerDeleteSchema,\n docs: {\n serverCreate: {\n tags: [\"Users\"],\n summary: 'Create user',\n description: 'Creates a new user. E-mail authentication is always enabled, and no password is set, meaning the only way to authenticate the newly created user is through magic link.',\n },\n serverRead: {\n tags: [\"Users\"],\n summary: 'Get user',\n description: 'Gets a user by user ID.',\n },\n serverUpdate: {\n tags: [\"Users\"],\n summary: 'Update user',\n description: 'Updates a user. Only the values provided will be updated.',\n },\n serverDelete: {\n tags: [\"Users\"],\n summary: 'Delete user',\n description: 'Deletes a user. Use this with caution.',\n },\n serverList: {\n tags: [\"Users\"],\n summary: 'List users',\n description: 'Lists all the users in the project.',\n },\n },\n});\nexport type UsersCrud = CrudTypeOf<typeof usersCrud>;\n\nexport const userCreatedWebhookEvent = {\n type: \"user.created\",\n schema: usersCrud.server.readSchema,\n metadata: {\n summary: \"User Created\",\n description: \"This event is triggered when a user is created.\",\n tags: [\"Users\"],\n },\n} satisfies WebhookEvent<typeof usersCrud.server.readSchema>;\n\nexport const userUpdatedWebhookEvent = {\n type: \"user.updated\",\n schema: usersCrud.server.readSchema,\n metadata: {\n summary: \"User Updated\",\n description: \"This event is triggered when a user is updated.\",\n tags: [\"Users\"],\n },\n} satisfies WebhookEvent<typeof usersCrud.server.readSchema>;\n\nconst webhookUserDeletedSchema = fieldSchema.yupObject({\n id: fieldSchema.userIdSchema.defined(),\n teams: fieldSchema.yupArray(fieldSchema.yupObject({\n id: fieldSchema.yupString().defined(),\n })).defined(),\n}).defined();\n\nexport const userDeletedWebhookEvent = {\n type: \"user.deleted\",\n schema: webhookUserDeletedSchema,\n metadata: {\n summary: \"User Deleted\",\n description: \"This event is triggered when a user is deleted.\",\n tags: [\"Users\"],\n },\n} satisfies WebhookEvent<typeof webhookUserDeletedSchema>;\n"],"mappings":";AAAA,SAAqB,kBAAkB;AACvC,YAAY,iBAAiB;AAE7B,SAAS,iCAAiC;AAEnC,IAAM,8BAA0C,sBAAU;AAAA,EAC/D,cAA0B,kCAAsB,SAAS;AAAA,EACzD,mBAA+B,kCAAsB,SAAS,EAAE,SAAS;AAAA,EACzE,iBAA6B,qCAAyB,SAAS;AAAA,EAC/D,2BAAuC,6CAAiC,SAAS;AAAA,EACjF,iBAA6B,qCAAyB,SAAS;AAAA,EAC/D,eAA2B,+BAAmB,SAAS,EAAE,SAAS,EAAE,SAAS;AAAA,EAC7E,wBAAoC,uCAA2B,SAAS;AAAA,EACxE,4BAAwC,0CAA8B,SAAS;AAAA,EAC/E,sBAAkC,qCAAyB,SAAS;AAAA,EACpE,UAAsB,uCAA2B,SAAS;AAAA,EAC1D,eAA2B,2CAA+B,SAAS;AAAA,EACnE,kBAA8B,6CAAiC,SAAS;AAAA,EACxE,oBAAgC,yCAA6B,SAAS;AAAA,EACtE,kBAA8B,iCAAqB,SAAS,EAAE,SAAS;AAAA,EACvE,cAA0B,uBAAW,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,SAAS;AACjE,CAAC,EAAE,QAAQ;AAEJ,IAAM,4BAAwC,sBAAU;AAAA,EAC7D,IAAgB,yBAAa,QAAQ;AAAA,EACrC,eAA2B,+BAAmB,SAAS,EAAE,QAAQ;AAAA,EACjE,wBAAoC,uCAA2B,QAAQ;AAAA,EACvE,4BAAwC,0CAA8B,QAAQ;AAAA,EAC9E,cAA0B,kCAAsB,SAAS,EAAE,QAAQ;AAAA,EACnE,eAAe,0BAA0B,SAAS,EAAE,QAAQ;AAAA,EAC5D,kBAA8B,iCAAqB,SAAS,EAAE,QAAQ;AAAA,EACtE,mBAA+B,kCAAsB,SAAS,EAAE,QAAQ;AAAA,EACxE,qBAAiC,mCAAuB,QAAQ;AAAA,EAChE,cAA0B,kCAAsB,QAAQ;AAAA,EACxD,kBAA8B,qCAAyB,QAAQ;AAAA,EAC/D,sBAAkC,qCAAyB,QAAQ;AAAA,EACnE,iBAA6B;AAAA,EAC7B,2BAAuC;AAAA,EACvC,iBAA6B;AAAA,EAC7B,uBAAmC,yCAA6B,YAAY,EAAE,QAAQ;AAAA,EACtF,cAA0B,uBAAW,EAAE,QAAQ;AAAA,EAE/C,iBAA6B,qBAAqB,sBAAU;AAAA,IAC1D,IAAgB,sBAAU,EAAE,QAAQ;AAAA,IACpC,YAAwB,sBAAU,EAAE,QAAQ;AAAA,IAC5C,OAAmB,sBAAU,EAAE,SAAS;AAAA,EAC1C,CAAC,EAAE,QAAQ,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,cAAc,EAAE,QAAQ,KAAK,EAAE,CAAC;AAAA;AAAA;AAAA;AAAA,EAK/D,iBAA6B,uBAAW,EAAE,QAAQ,EAAE,KAAK,EAAE,cAAc,EAAE,QAAQ,MAAM,aAAa,4KAA4K,cAAc,KAAK,EAAE,CAAC;AAAA;AAAA;AAAA;AAAA,EAIxS,mBAA+B,uBAAW,EAAE,QAAQ,EAAE,KAAK,EAAE,cAAc,EAAE,QAAQ,MAAM,aAAa,2DAA2D,cAAc,MAAM,EAAE,CAAC;AAC5L,CAAC,EAAE,QAAQ;AAEJ,IAAM,8BAA8B,4BAA4B,KAAK,CAAC,kBAAkB,CAAC,EAAE,OAAmB,sBAAU;AAAA,EAC7H,iBAA6B,qBAAqB,sBAAU;AAAA,IAC1D,IAAgB,sBAAU,EAAE,QAAQ;AAAA,IACpC,YAAwB,sBAAU,EAAE,QAAQ;AAAA,IAC5C,OAAmB,sBAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,IAAI;AAAA,EAClE,CAAC,EAAE,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,cAAc,EAAE,QAAQ,KAAK,EAAE,CAAC;AAAA,EAChE,cAA0B,uBAAW,EAAE,SAAS;AAClD,CAAC,EAAE,QAAQ,CAAC;AAEL,IAAM,8BAA0C,qBAAS;AAEzD,IAAM,YAAY,WAAW;AAAA,EAClC,kBAAkB;AAAA,EAClB,oBAAoB;AAAA,EACpB,oBAAoB;AAAA,EACpB,oBAAoB;AAAA,EACpB,MAAM;AAAA,IACJ,cAAc;AAAA,MACZ,MAAM,CAAC,OAAO;AAAA,MACd,SAAS;AAAA,MACT,aAAa;AAAA,IACf;AAAA,IACA,YAAY;AAAA,MACV,MAAM,CAAC,OAAO;AAAA,MACd,SAAS;AAAA,MACT,aAAa;AAAA,IACf;AAAA,IACA,cAAc;AAAA,MACZ,MAAM,CAAC,OAAO;AAAA,MACd,SAAS;AAAA,MACT,aAAa;AAAA,IACf;AAAA,IACA,cAAc;AAAA,MACZ,MAAM,CAAC,OAAO;AAAA,MACd,SAAS;AAAA,MACT,aAAa;AAAA,IACf;AAAA,IACA,YAAY;AAAA,MACV,MAAM,CAAC,OAAO;AAAA,MACd,SAAS;AAAA,MACT,aAAa;AAAA,IACf;AAAA,EACF;AACF,CAAC;AAGM,IAAM,0BAA0B;AAAA,EACrC,MAAM;AAAA,EACN,QAAQ,UAAU,OAAO;AAAA,EACzB,UAAU;AAAA,IACR,SAAS;AAAA,IACT,aAAa;AAAA,IACb,MAAM,CAAC,OAAO;AAAA,EAChB;AACF;AAEO,IAAM,0BAA0B;AAAA,EACrC,MAAM;AAAA,EACN,QAAQ,UAAU,OAAO;AAAA,EACzB,UAAU;AAAA,IACR,SAAS;AAAA,IACT,aAAa;AAAA,IACb,MAAM,CAAC,OAAO;AAAA,EAChB;AACF;AAEA,IAAM,2BAAuC,sBAAU;AAAA,EACrD,IAAgB,yBAAa,QAAQ;AAAA,EACrC,OAAmB,qBAAqB,sBAAU;AAAA,IAChD,IAAgB,sBAAU,EAAE,QAAQ;AAAA,EACtC,CAAC,CAAC,EAAE,QAAQ;AACd,CAAC,EAAE,QAAQ;AAEJ,IAAM,0BAA0B;AAAA,EACrC,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,UAAU;AAAA,IACR,SAAS;AAAA,IACT,aAAa;AAAA,IACb,MAAM,CAAC,OAAO;AAAA,EAChB;AACF;","names":[]}
|
|
@@ -0,0 +1,485 @@
|
|
|
1
|
+
// src/interface/serverInterface.ts
|
|
2
|
+
import { KnownErrors } from "../known-errors";
|
|
3
|
+
import { StackAssertionError } from "../utils/errors";
|
|
4
|
+
import { filterUndefined } from "../utils/objects";
|
|
5
|
+
import { Result } from "../utils/results";
|
|
6
|
+
import { urlString } from "../utils/urls";
|
|
7
|
+
import {
|
|
8
|
+
StackClientInterface
|
|
9
|
+
} from "./clientInterface";
|
|
10
|
+
var StackServerInterface = class extends StackClientInterface {
|
|
11
|
+
constructor(options) {
|
|
12
|
+
super(options);
|
|
13
|
+
this.options = options;
|
|
14
|
+
}
|
|
15
|
+
async sendServerRequest(path, options, session, requestType = "server") {
|
|
16
|
+
return await this.sendClientRequest(
|
|
17
|
+
path,
|
|
18
|
+
{
|
|
19
|
+
...options,
|
|
20
|
+
headers: {
|
|
21
|
+
"x-stack-secret-server-key": "secretServerKey" in this.options ? this.options.secretServerKey : "",
|
|
22
|
+
...options.headers
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
session,
|
|
26
|
+
requestType
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
async sendServerRequestAndCatchKnownError(path, requestOptions, tokenStoreOrNull, errorsToCatch) {
|
|
30
|
+
try {
|
|
31
|
+
return Result.ok(await this.sendServerRequest(path, requestOptions, tokenStoreOrNull));
|
|
32
|
+
} catch (e) {
|
|
33
|
+
for (const errorType of errorsToCatch) {
|
|
34
|
+
if (e instanceof errorType) {
|
|
35
|
+
return Result.error(e);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
throw e;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
async createServerUser(data) {
|
|
42
|
+
const response = await this.sendServerRequest(
|
|
43
|
+
"/users",
|
|
44
|
+
{
|
|
45
|
+
method: "POST",
|
|
46
|
+
headers: {
|
|
47
|
+
"content-type": "application/json"
|
|
48
|
+
},
|
|
49
|
+
body: JSON.stringify(data)
|
|
50
|
+
},
|
|
51
|
+
null
|
|
52
|
+
);
|
|
53
|
+
return await response.json();
|
|
54
|
+
}
|
|
55
|
+
async getServerUserByToken(session) {
|
|
56
|
+
const responseOrError = await this.sendServerRequestAndCatchKnownError(
|
|
57
|
+
"/users/me",
|
|
58
|
+
{},
|
|
59
|
+
session,
|
|
60
|
+
[KnownErrors.CannotGetOwnUserWithoutUser]
|
|
61
|
+
);
|
|
62
|
+
if (responseOrError.status === "error") {
|
|
63
|
+
if (responseOrError.error instanceof KnownErrors.CannotGetOwnUserWithoutUser) {
|
|
64
|
+
return null;
|
|
65
|
+
} else {
|
|
66
|
+
throw new StackAssertionError("Unexpected uncaught error", { cause: responseOrError.error });
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
const response = responseOrError.data;
|
|
70
|
+
const user = await response.json();
|
|
71
|
+
if (!user) throw new StackAssertionError("User endpoint returned null; this should never happen");
|
|
72
|
+
return user;
|
|
73
|
+
}
|
|
74
|
+
async getServerUserById(userId) {
|
|
75
|
+
const responseOrError = await this.sendServerRequestAndCatchKnownError(
|
|
76
|
+
urlString`/users/${userId}`,
|
|
77
|
+
{},
|
|
78
|
+
null,
|
|
79
|
+
[KnownErrors.UserNotFound]
|
|
80
|
+
);
|
|
81
|
+
if (responseOrError.status === "error") {
|
|
82
|
+
return Result.error(responseOrError.error);
|
|
83
|
+
}
|
|
84
|
+
const user = await responseOrError.data.json();
|
|
85
|
+
return Result.ok(user);
|
|
86
|
+
}
|
|
87
|
+
async listServerTeamInvitations(options) {
|
|
88
|
+
const response = await this.sendServerRequest(
|
|
89
|
+
urlString`/team-invitations?team_id=${options.teamId}`,
|
|
90
|
+
{},
|
|
91
|
+
null
|
|
92
|
+
);
|
|
93
|
+
const result = await response.json();
|
|
94
|
+
return result.items;
|
|
95
|
+
}
|
|
96
|
+
async revokeServerTeamInvitation(invitationId, teamId) {
|
|
97
|
+
await this.sendServerRequest(
|
|
98
|
+
urlString`/team-invitations/${invitationId}?team_id=${teamId}`,
|
|
99
|
+
{ method: "DELETE" },
|
|
100
|
+
null
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
async listServerTeamMemberProfiles(options) {
|
|
104
|
+
const response = await this.sendServerRequest(
|
|
105
|
+
urlString`/team-member-profiles?team_id=${options.teamId}`,
|
|
106
|
+
{},
|
|
107
|
+
null
|
|
108
|
+
);
|
|
109
|
+
const result = await response.json();
|
|
110
|
+
return result.items;
|
|
111
|
+
}
|
|
112
|
+
async getServerTeamMemberProfile(options) {
|
|
113
|
+
const response = await this.sendServerRequest(
|
|
114
|
+
urlString`/team-member-profiles/${options.teamId}/${options.userId}`,
|
|
115
|
+
{},
|
|
116
|
+
null
|
|
117
|
+
);
|
|
118
|
+
return await response.json();
|
|
119
|
+
}
|
|
120
|
+
async listServerTeamPermissions(options, session) {
|
|
121
|
+
const response = await this.sendServerRequest(
|
|
122
|
+
`/team-permissions?${new URLSearchParams(filterUndefined({
|
|
123
|
+
user_id: options.userId,
|
|
124
|
+
team_id: options.teamId,
|
|
125
|
+
recursive: options.recursive.toString()
|
|
126
|
+
}))}`,
|
|
127
|
+
{},
|
|
128
|
+
session
|
|
129
|
+
);
|
|
130
|
+
const result = await response.json();
|
|
131
|
+
return result.items;
|
|
132
|
+
}
|
|
133
|
+
async listServerProjectPermissions(options, session) {
|
|
134
|
+
const response = await this.sendServerRequest(
|
|
135
|
+
`/project-permissions?${new URLSearchParams(filterUndefined({
|
|
136
|
+
user_id: options.userId,
|
|
137
|
+
recursive: options.recursive.toString()
|
|
138
|
+
}))}`,
|
|
139
|
+
{},
|
|
140
|
+
session
|
|
141
|
+
);
|
|
142
|
+
const result = await response.json();
|
|
143
|
+
return result.items;
|
|
144
|
+
}
|
|
145
|
+
async listServerUsers(options) {
|
|
146
|
+
const searchParams = new URLSearchParams(filterUndefined({
|
|
147
|
+
cursor: options.cursor,
|
|
148
|
+
limit: options.limit?.toString(),
|
|
149
|
+
desc: options.desc?.toString(),
|
|
150
|
+
...options.orderBy ? {
|
|
151
|
+
order_by: {
|
|
152
|
+
signedUpAt: "signed_up_at"
|
|
153
|
+
}[options.orderBy]
|
|
154
|
+
} : {},
|
|
155
|
+
...options.query ? {
|
|
156
|
+
query: options.query
|
|
157
|
+
} : {}
|
|
158
|
+
}));
|
|
159
|
+
const response = await this.sendServerRequest("/users?" + searchParams.toString(), {}, null);
|
|
160
|
+
return await response.json();
|
|
161
|
+
}
|
|
162
|
+
async listServerTeams(options) {
|
|
163
|
+
const response = await this.sendServerRequest(
|
|
164
|
+
`/teams?${new URLSearchParams(filterUndefined({
|
|
165
|
+
user_id: options?.userId
|
|
166
|
+
}))}`,
|
|
167
|
+
{},
|
|
168
|
+
null
|
|
169
|
+
);
|
|
170
|
+
const result = await response.json();
|
|
171
|
+
return result.items;
|
|
172
|
+
}
|
|
173
|
+
async getServerTeam(teamId) {
|
|
174
|
+
const response = await this.sendServerRequest(
|
|
175
|
+
`/teams/${teamId}`,
|
|
176
|
+
{},
|
|
177
|
+
null
|
|
178
|
+
);
|
|
179
|
+
return await response.json();
|
|
180
|
+
}
|
|
181
|
+
async listServerTeamUsers(teamId) {
|
|
182
|
+
const response = await this.sendServerRequest(`/users?team_id=${teamId}`, {}, null);
|
|
183
|
+
const result = await response.json();
|
|
184
|
+
return result.items;
|
|
185
|
+
}
|
|
186
|
+
/* when passing a session, the user will be added to the team */
|
|
187
|
+
async createServerTeam(data) {
|
|
188
|
+
const response = await this.sendServerRequest(
|
|
189
|
+
"/teams",
|
|
190
|
+
{
|
|
191
|
+
method: "POST",
|
|
192
|
+
headers: {
|
|
193
|
+
"content-type": "application/json"
|
|
194
|
+
},
|
|
195
|
+
body: JSON.stringify(data)
|
|
196
|
+
},
|
|
197
|
+
null
|
|
198
|
+
);
|
|
199
|
+
return await response.json();
|
|
200
|
+
}
|
|
201
|
+
async updateServerTeam(teamId, data) {
|
|
202
|
+
const response = await this.sendServerRequest(
|
|
203
|
+
urlString`/teams/${teamId}`,
|
|
204
|
+
{
|
|
205
|
+
method: "PATCH",
|
|
206
|
+
headers: {
|
|
207
|
+
"content-type": "application/json"
|
|
208
|
+
},
|
|
209
|
+
body: JSON.stringify(data)
|
|
210
|
+
},
|
|
211
|
+
null
|
|
212
|
+
);
|
|
213
|
+
return await response.json();
|
|
214
|
+
}
|
|
215
|
+
async deleteServerTeam(teamId) {
|
|
216
|
+
await this.sendServerRequest(
|
|
217
|
+
urlString`/teams/${teamId}`,
|
|
218
|
+
{ method: "DELETE" },
|
|
219
|
+
null
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
async addServerUserToTeam(options) {
|
|
223
|
+
const response = await this.sendServerRequest(
|
|
224
|
+
urlString`/team-memberships/${options.teamId}/${options.userId}`,
|
|
225
|
+
{
|
|
226
|
+
method: "POST",
|
|
227
|
+
headers: {
|
|
228
|
+
"content-type": "application/json"
|
|
229
|
+
},
|
|
230
|
+
body: JSON.stringify({})
|
|
231
|
+
},
|
|
232
|
+
null
|
|
233
|
+
);
|
|
234
|
+
return await response.json();
|
|
235
|
+
}
|
|
236
|
+
async removeServerUserFromTeam(options) {
|
|
237
|
+
await this.sendServerRequest(
|
|
238
|
+
urlString`/team-memberships/${options.teamId}/${options.userId}`,
|
|
239
|
+
{
|
|
240
|
+
method: "DELETE",
|
|
241
|
+
headers: {
|
|
242
|
+
"content-type": "application/json"
|
|
243
|
+
},
|
|
244
|
+
body: JSON.stringify({})
|
|
245
|
+
},
|
|
246
|
+
null
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
async updateServerUser(userId, update) {
|
|
250
|
+
const response = await this.sendServerRequest(
|
|
251
|
+
urlString`/users/${userId}`,
|
|
252
|
+
{
|
|
253
|
+
method: "PATCH",
|
|
254
|
+
headers: {
|
|
255
|
+
"content-type": "application/json"
|
|
256
|
+
},
|
|
257
|
+
body: JSON.stringify(update)
|
|
258
|
+
},
|
|
259
|
+
null
|
|
260
|
+
);
|
|
261
|
+
return await response.json();
|
|
262
|
+
}
|
|
263
|
+
async createServerProviderAccessToken(userId, provider, scope) {
|
|
264
|
+
const response = await this.sendServerRequest(
|
|
265
|
+
urlString`/connected-accounts/${userId}/${provider}/access-token`,
|
|
266
|
+
{
|
|
267
|
+
method: "POST",
|
|
268
|
+
headers: {
|
|
269
|
+
"content-type": "application/json"
|
|
270
|
+
},
|
|
271
|
+
body: JSON.stringify({ scope })
|
|
272
|
+
},
|
|
273
|
+
null
|
|
274
|
+
);
|
|
275
|
+
return await response.json();
|
|
276
|
+
}
|
|
277
|
+
async createServerUserSession(userId, expiresInMillis, isImpersonation) {
|
|
278
|
+
const response = await this.sendServerRequest(
|
|
279
|
+
"/auth/sessions",
|
|
280
|
+
{
|
|
281
|
+
method: "POST",
|
|
282
|
+
headers: {
|
|
283
|
+
"content-type": "application/json"
|
|
284
|
+
},
|
|
285
|
+
body: JSON.stringify({
|
|
286
|
+
user_id: userId,
|
|
287
|
+
expires_in_millis: expiresInMillis,
|
|
288
|
+
is_impersonation: isImpersonation
|
|
289
|
+
})
|
|
290
|
+
},
|
|
291
|
+
null
|
|
292
|
+
);
|
|
293
|
+
const result = await response.json();
|
|
294
|
+
return {
|
|
295
|
+
accessToken: result.access_token,
|
|
296
|
+
refreshToken: result.refresh_token
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
async leaveServerTeam(options) {
|
|
300
|
+
await this.sendClientRequest(
|
|
301
|
+
urlString`/team-memberships/${options.teamId}/${options.userId}`,
|
|
302
|
+
{
|
|
303
|
+
method: "DELETE",
|
|
304
|
+
headers: {
|
|
305
|
+
"content-type": "application/json"
|
|
306
|
+
},
|
|
307
|
+
body: JSON.stringify({})
|
|
308
|
+
},
|
|
309
|
+
null
|
|
310
|
+
);
|
|
311
|
+
}
|
|
312
|
+
async updateServerTeamMemberProfile(options) {
|
|
313
|
+
await this.sendServerRequest(
|
|
314
|
+
urlString`/team-member-profiles/${options.teamId}/${options.userId}`,
|
|
315
|
+
{
|
|
316
|
+
method: "PATCH",
|
|
317
|
+
headers: {
|
|
318
|
+
"content-type": "application/json"
|
|
319
|
+
},
|
|
320
|
+
body: JSON.stringify(options.profile)
|
|
321
|
+
},
|
|
322
|
+
null
|
|
323
|
+
);
|
|
324
|
+
}
|
|
325
|
+
async grantServerTeamUserPermission(teamId, userId, permissionId) {
|
|
326
|
+
await this.sendServerRequest(
|
|
327
|
+
urlString`/team-permissions/${teamId}/${userId}/${permissionId}`,
|
|
328
|
+
{
|
|
329
|
+
method: "POST",
|
|
330
|
+
headers: {
|
|
331
|
+
"content-type": "application/json"
|
|
332
|
+
},
|
|
333
|
+
body: JSON.stringify({})
|
|
334
|
+
},
|
|
335
|
+
null
|
|
336
|
+
);
|
|
337
|
+
}
|
|
338
|
+
async revokeServerTeamUserPermission(teamId, userId, permissionId) {
|
|
339
|
+
await this.sendServerRequest(
|
|
340
|
+
urlString`/team-permissions/${teamId}/${userId}/${permissionId}`,
|
|
341
|
+
{
|
|
342
|
+
method: "DELETE",
|
|
343
|
+
headers: {
|
|
344
|
+
"content-type": "application/json"
|
|
345
|
+
},
|
|
346
|
+
body: JSON.stringify({})
|
|
347
|
+
},
|
|
348
|
+
null
|
|
349
|
+
);
|
|
350
|
+
}
|
|
351
|
+
async deleteServerUser(userId) {
|
|
352
|
+
await this.sendServerRequest(
|
|
353
|
+
urlString`/users/${userId}`,
|
|
354
|
+
{
|
|
355
|
+
method: "DELETE",
|
|
356
|
+
headers: {
|
|
357
|
+
"content-type": "application/json"
|
|
358
|
+
},
|
|
359
|
+
body: JSON.stringify({})
|
|
360
|
+
},
|
|
361
|
+
null
|
|
362
|
+
);
|
|
363
|
+
}
|
|
364
|
+
async createServerContactChannel(data) {
|
|
365
|
+
const response = await this.sendServerRequest(
|
|
366
|
+
"/contact-channels",
|
|
367
|
+
{
|
|
368
|
+
method: "POST",
|
|
369
|
+
headers: {
|
|
370
|
+
"content-type": "application/json"
|
|
371
|
+
},
|
|
372
|
+
body: JSON.stringify(data)
|
|
373
|
+
},
|
|
374
|
+
null
|
|
375
|
+
);
|
|
376
|
+
return await response.json();
|
|
377
|
+
}
|
|
378
|
+
async updateServerContactChannel(userId, contactChannelId, data) {
|
|
379
|
+
const response = await this.sendServerRequest(
|
|
380
|
+
urlString`/contact-channels/${userId}/${contactChannelId}`,
|
|
381
|
+
{
|
|
382
|
+
method: "PATCH",
|
|
383
|
+
headers: {
|
|
384
|
+
"content-type": "application/json"
|
|
385
|
+
},
|
|
386
|
+
body: JSON.stringify(data)
|
|
387
|
+
},
|
|
388
|
+
null
|
|
389
|
+
);
|
|
390
|
+
return await response.json();
|
|
391
|
+
}
|
|
392
|
+
async deleteServerContactChannel(userId, contactChannelId) {
|
|
393
|
+
await this.sendServerRequest(
|
|
394
|
+
urlString`/contact-channels/${userId}/${contactChannelId}`,
|
|
395
|
+
{
|
|
396
|
+
method: "DELETE"
|
|
397
|
+
},
|
|
398
|
+
null
|
|
399
|
+
);
|
|
400
|
+
}
|
|
401
|
+
async listServerContactChannels(userId) {
|
|
402
|
+
const response = await this.sendServerRequest(
|
|
403
|
+
urlString`/contact-channels?user_id=${userId}`,
|
|
404
|
+
{
|
|
405
|
+
method: "GET"
|
|
406
|
+
},
|
|
407
|
+
null
|
|
408
|
+
);
|
|
409
|
+
const json = await response.json();
|
|
410
|
+
return json.items;
|
|
411
|
+
}
|
|
412
|
+
async sendServerContactChannelVerificationEmail(userId, contactChannelId, callbackUrl) {
|
|
413
|
+
await this.sendServerRequest(
|
|
414
|
+
urlString`/contact-channels/${userId}/${contactChannelId}/send-verification-code`,
|
|
415
|
+
{
|
|
416
|
+
method: "POST",
|
|
417
|
+
headers: {
|
|
418
|
+
"content-type": "application/json"
|
|
419
|
+
},
|
|
420
|
+
body: JSON.stringify({ callback_url: callbackUrl })
|
|
421
|
+
},
|
|
422
|
+
null
|
|
423
|
+
);
|
|
424
|
+
}
|
|
425
|
+
async listServerSessions(userId) {
|
|
426
|
+
const response = await this.sendServerRequest(
|
|
427
|
+
urlString`/auth/sessions?user_id=${userId}`,
|
|
428
|
+
{
|
|
429
|
+
method: "GET"
|
|
430
|
+
},
|
|
431
|
+
null
|
|
432
|
+
);
|
|
433
|
+
return await response.json();
|
|
434
|
+
}
|
|
435
|
+
async deleteServerSession(sessionId) {
|
|
436
|
+
await this.sendServerRequest(
|
|
437
|
+
urlString`/auth/sessions/${sessionId}`,
|
|
438
|
+
{
|
|
439
|
+
method: "DELETE"
|
|
440
|
+
},
|
|
441
|
+
null
|
|
442
|
+
);
|
|
443
|
+
}
|
|
444
|
+
async sendServerTeamInvitation(options) {
|
|
445
|
+
await this.sendServerRequest(
|
|
446
|
+
"/team-invitations/send-code",
|
|
447
|
+
{
|
|
448
|
+
method: "POST",
|
|
449
|
+
headers: {
|
|
450
|
+
"Content-Type": "application/json"
|
|
451
|
+
},
|
|
452
|
+
body: JSON.stringify({
|
|
453
|
+
email: options.email,
|
|
454
|
+
team_id: options.teamId,
|
|
455
|
+
callback_url: options.callbackUrl
|
|
456
|
+
})
|
|
457
|
+
},
|
|
458
|
+
null
|
|
459
|
+
);
|
|
460
|
+
}
|
|
461
|
+
async updatePassword(options) {
|
|
462
|
+
const res = await this.sendServerRequestAndCatchKnownError(
|
|
463
|
+
"/auth/password/update",
|
|
464
|
+
{
|
|
465
|
+
method: "POST",
|
|
466
|
+
headers: {
|
|
467
|
+
"Content-Type": "application/json"
|
|
468
|
+
},
|
|
469
|
+
body: JSON.stringify({
|
|
470
|
+
old_password: options.oldPassword,
|
|
471
|
+
new_password: options.newPassword
|
|
472
|
+
})
|
|
473
|
+
},
|
|
474
|
+
null,
|
|
475
|
+
[KnownErrors.PasswordConfirmationMismatch, KnownErrors.PasswordRequirementsNotMet]
|
|
476
|
+
);
|
|
477
|
+
if (res.status === "error") {
|
|
478
|
+
return res.error;
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
};
|
|
482
|
+
export {
|
|
483
|
+
StackServerInterface
|
|
484
|
+
};
|
|
485
|
+
//# sourceMappingURL=serverInterface.js.map
|