@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
|
@@ -1,341 +1,508 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/interface/serverInterface.ts
|
|
21
|
+
var serverInterface_exports = {};
|
|
22
|
+
__export(serverInterface_exports, {
|
|
23
|
+
StackServerInterface: () => StackServerInterface
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(serverInterface_exports);
|
|
26
|
+
var import_known_errors = require("../known-errors");
|
|
27
|
+
var import_errors = require("../utils/errors");
|
|
28
|
+
var import_objects = require("../utils/objects");
|
|
29
|
+
var import_results = require("../utils/results");
|
|
30
|
+
var import_urls = require("../utils/urls");
|
|
31
|
+
var import_clientInterface = require("./clientInterface");
|
|
32
|
+
var StackServerInterface = class extends import_clientInterface.StackClientInterface {
|
|
33
|
+
constructor(options) {
|
|
34
|
+
super(options);
|
|
35
|
+
this.options = options;
|
|
36
|
+
}
|
|
37
|
+
async sendServerRequest(path, options, session, requestType = "server") {
|
|
38
|
+
return await this.sendClientRequest(
|
|
39
|
+
path,
|
|
40
|
+
{
|
|
41
|
+
...options,
|
|
42
|
+
headers: {
|
|
43
|
+
"x-stack-secret-server-key": "secretServerKey" in this.options ? this.options.secretServerKey : "",
|
|
44
|
+
...options.headers
|
|
32
45
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const responseOrError = await this.sendServerRequestAndCatchKnownError("/users/me", {}, session, [KnownErrors.CannotGetOwnUserWithoutUser]);
|
|
46
|
-
if (responseOrError.status === "error") {
|
|
47
|
-
if (responseOrError.error instanceof KnownErrors.CannotGetOwnUserWithoutUser) {
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
throw new StackAssertionError("Unexpected uncaught error", { cause: responseOrError.error });
|
|
52
|
-
}
|
|
46
|
+
},
|
|
47
|
+
session,
|
|
48
|
+
requestType
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
async sendServerRequestAndCatchKnownError(path, requestOptions, tokenStoreOrNull, errorsToCatch) {
|
|
52
|
+
try {
|
|
53
|
+
return import_results.Result.ok(await this.sendServerRequest(path, requestOptions, tokenStoreOrNull));
|
|
54
|
+
} catch (e) {
|
|
55
|
+
for (const errorType of errorsToCatch) {
|
|
56
|
+
if (e instanceof errorType) {
|
|
57
|
+
return import_results.Result.error(e);
|
|
53
58
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
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
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
},
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
}
|
|
59
|
+
}
|
|
60
|
+
throw e;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
async createServerUser(data) {
|
|
64
|
+
const response = await this.sendServerRequest(
|
|
65
|
+
"/users",
|
|
66
|
+
{
|
|
67
|
+
method: "POST",
|
|
68
|
+
headers: {
|
|
69
|
+
"content-type": "application/json"
|
|
70
|
+
},
|
|
71
|
+
body: JSON.stringify(data)
|
|
72
|
+
},
|
|
73
|
+
null
|
|
74
|
+
);
|
|
75
|
+
return await response.json();
|
|
76
|
+
}
|
|
77
|
+
async getServerUserByToken(session) {
|
|
78
|
+
const responseOrError = await this.sendServerRequestAndCatchKnownError(
|
|
79
|
+
"/users/me",
|
|
80
|
+
{},
|
|
81
|
+
session,
|
|
82
|
+
[import_known_errors.KnownErrors.CannotGetOwnUserWithoutUser]
|
|
83
|
+
);
|
|
84
|
+
if (responseOrError.status === "error") {
|
|
85
|
+
if (responseOrError.error instanceof import_known_errors.KnownErrors.CannotGetOwnUserWithoutUser) {
|
|
86
|
+
return null;
|
|
87
|
+
} else {
|
|
88
|
+
throw new import_errors.StackAssertionError("Unexpected uncaught error", { cause: responseOrError.error });
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
const response = responseOrError.data;
|
|
92
|
+
const user = await response.json();
|
|
93
|
+
if (!user) throw new import_errors.StackAssertionError("User endpoint returned null; this should never happen");
|
|
94
|
+
return user;
|
|
95
|
+
}
|
|
96
|
+
async getServerUserById(userId) {
|
|
97
|
+
const responseOrError = await this.sendServerRequestAndCatchKnownError(
|
|
98
|
+
import_urls.urlString`/users/${userId}`,
|
|
99
|
+
{},
|
|
100
|
+
null,
|
|
101
|
+
[import_known_errors.KnownErrors.UserNotFound]
|
|
102
|
+
);
|
|
103
|
+
if (responseOrError.status === "error") {
|
|
104
|
+
return import_results.Result.error(responseOrError.error);
|
|
105
|
+
}
|
|
106
|
+
const user = await responseOrError.data.json();
|
|
107
|
+
return import_results.Result.ok(user);
|
|
108
|
+
}
|
|
109
|
+
async listServerTeamInvitations(options) {
|
|
110
|
+
const response = await this.sendServerRequest(
|
|
111
|
+
import_urls.urlString`/team-invitations?team_id=${options.teamId}`,
|
|
112
|
+
{},
|
|
113
|
+
null
|
|
114
|
+
);
|
|
115
|
+
const result = await response.json();
|
|
116
|
+
return result.items;
|
|
117
|
+
}
|
|
118
|
+
async revokeServerTeamInvitation(invitationId, teamId) {
|
|
119
|
+
await this.sendServerRequest(
|
|
120
|
+
import_urls.urlString`/team-invitations/${invitationId}?team_id=${teamId}`,
|
|
121
|
+
{ method: "DELETE" },
|
|
122
|
+
null
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
async listServerTeamMemberProfiles(options) {
|
|
126
|
+
const response = await this.sendServerRequest(
|
|
127
|
+
import_urls.urlString`/team-member-profiles?team_id=${options.teamId}`,
|
|
128
|
+
{},
|
|
129
|
+
null
|
|
130
|
+
);
|
|
131
|
+
const result = await response.json();
|
|
132
|
+
return result.items;
|
|
133
|
+
}
|
|
134
|
+
async getServerTeamMemberProfile(options) {
|
|
135
|
+
const response = await this.sendServerRequest(
|
|
136
|
+
import_urls.urlString`/team-member-profiles/${options.teamId}/${options.userId}`,
|
|
137
|
+
{},
|
|
138
|
+
null
|
|
139
|
+
);
|
|
140
|
+
return await response.json();
|
|
141
|
+
}
|
|
142
|
+
async listServerTeamPermissions(options, session) {
|
|
143
|
+
const response = await this.sendServerRequest(
|
|
144
|
+
`/team-permissions?${new URLSearchParams((0, import_objects.filterUndefined)({
|
|
145
|
+
user_id: options.userId,
|
|
146
|
+
team_id: options.teamId,
|
|
147
|
+
recursive: options.recursive.toString()
|
|
148
|
+
}))}`,
|
|
149
|
+
{},
|
|
150
|
+
session
|
|
151
|
+
);
|
|
152
|
+
const result = await response.json();
|
|
153
|
+
return result.items;
|
|
154
|
+
}
|
|
155
|
+
async listServerProjectPermissions(options, session) {
|
|
156
|
+
const response = await this.sendServerRequest(
|
|
157
|
+
`/project-permissions?${new URLSearchParams((0, import_objects.filterUndefined)({
|
|
158
|
+
user_id: options.userId,
|
|
159
|
+
recursive: options.recursive.toString()
|
|
160
|
+
}))}`,
|
|
161
|
+
{},
|
|
162
|
+
session
|
|
163
|
+
);
|
|
164
|
+
const result = await response.json();
|
|
165
|
+
return result.items;
|
|
166
|
+
}
|
|
167
|
+
async listServerUsers(options) {
|
|
168
|
+
const searchParams = new URLSearchParams((0, import_objects.filterUndefined)({
|
|
169
|
+
cursor: options.cursor,
|
|
170
|
+
limit: options.limit?.toString(),
|
|
171
|
+
desc: options.desc?.toString(),
|
|
172
|
+
...options.orderBy ? {
|
|
173
|
+
order_by: {
|
|
174
|
+
signedUpAt: "signed_up_at"
|
|
175
|
+
}[options.orderBy]
|
|
176
|
+
} : {},
|
|
177
|
+
...options.query ? {
|
|
178
|
+
query: options.query
|
|
179
|
+
} : {}
|
|
180
|
+
}));
|
|
181
|
+
const response = await this.sendServerRequest("/users?" + searchParams.toString(), {}, null);
|
|
182
|
+
return await response.json();
|
|
183
|
+
}
|
|
184
|
+
async listServerTeams(options) {
|
|
185
|
+
const response = await this.sendServerRequest(
|
|
186
|
+
`/teams?${new URLSearchParams((0, import_objects.filterUndefined)({
|
|
187
|
+
user_id: options?.userId
|
|
188
|
+
}))}`,
|
|
189
|
+
{},
|
|
190
|
+
null
|
|
191
|
+
);
|
|
192
|
+
const result = await response.json();
|
|
193
|
+
return result.items;
|
|
194
|
+
}
|
|
195
|
+
async getServerTeam(teamId) {
|
|
196
|
+
const response = await this.sendServerRequest(
|
|
197
|
+
`/teams/${teamId}`,
|
|
198
|
+
{},
|
|
199
|
+
null
|
|
200
|
+
);
|
|
201
|
+
return await response.json();
|
|
202
|
+
}
|
|
203
|
+
async listServerTeamUsers(teamId) {
|
|
204
|
+
const response = await this.sendServerRequest(`/users?team_id=${teamId}`, {}, null);
|
|
205
|
+
const result = await response.json();
|
|
206
|
+
return result.items;
|
|
207
|
+
}
|
|
208
|
+
/* when passing a session, the user will be added to the team */
|
|
209
|
+
async createServerTeam(data) {
|
|
210
|
+
const response = await this.sendServerRequest(
|
|
211
|
+
"/teams",
|
|
212
|
+
{
|
|
213
|
+
method: "POST",
|
|
214
|
+
headers: {
|
|
215
|
+
"content-type": "application/json"
|
|
216
|
+
},
|
|
217
|
+
body: JSON.stringify(data)
|
|
218
|
+
},
|
|
219
|
+
null
|
|
220
|
+
);
|
|
221
|
+
return await response.json();
|
|
222
|
+
}
|
|
223
|
+
async updateServerTeam(teamId, data) {
|
|
224
|
+
const response = await this.sendServerRequest(
|
|
225
|
+
import_urls.urlString`/teams/${teamId}`,
|
|
226
|
+
{
|
|
227
|
+
method: "PATCH",
|
|
228
|
+
headers: {
|
|
229
|
+
"content-type": "application/json"
|
|
230
|
+
},
|
|
231
|
+
body: JSON.stringify(data)
|
|
232
|
+
},
|
|
233
|
+
null
|
|
234
|
+
);
|
|
235
|
+
return await response.json();
|
|
236
|
+
}
|
|
237
|
+
async deleteServerTeam(teamId) {
|
|
238
|
+
await this.sendServerRequest(
|
|
239
|
+
import_urls.urlString`/teams/${teamId}`,
|
|
240
|
+
{ method: "DELETE" },
|
|
241
|
+
null
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
async addServerUserToTeam(options) {
|
|
245
|
+
const response = await this.sendServerRequest(
|
|
246
|
+
import_urls.urlString`/team-memberships/${options.teamId}/${options.userId}`,
|
|
247
|
+
{
|
|
248
|
+
method: "POST",
|
|
249
|
+
headers: {
|
|
250
|
+
"content-type": "application/json"
|
|
251
|
+
},
|
|
252
|
+
body: JSON.stringify({})
|
|
253
|
+
},
|
|
254
|
+
null
|
|
255
|
+
);
|
|
256
|
+
return await response.json();
|
|
257
|
+
}
|
|
258
|
+
async removeServerUserFromTeam(options) {
|
|
259
|
+
await this.sendServerRequest(
|
|
260
|
+
import_urls.urlString`/team-memberships/${options.teamId}/${options.userId}`,
|
|
261
|
+
{
|
|
262
|
+
method: "DELETE",
|
|
263
|
+
headers: {
|
|
264
|
+
"content-type": "application/json"
|
|
265
|
+
},
|
|
266
|
+
body: JSON.stringify({})
|
|
267
|
+
},
|
|
268
|
+
null
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
async updateServerUser(userId, update) {
|
|
272
|
+
const response = await this.sendServerRequest(
|
|
273
|
+
import_urls.urlString`/users/${userId}`,
|
|
274
|
+
{
|
|
275
|
+
method: "PATCH",
|
|
276
|
+
headers: {
|
|
277
|
+
"content-type": "application/json"
|
|
278
|
+
},
|
|
279
|
+
body: JSON.stringify(update)
|
|
280
|
+
},
|
|
281
|
+
null
|
|
282
|
+
);
|
|
283
|
+
return await response.json();
|
|
284
|
+
}
|
|
285
|
+
async createServerProviderAccessToken(userId, provider, scope) {
|
|
286
|
+
const response = await this.sendServerRequest(
|
|
287
|
+
import_urls.urlString`/connected-accounts/${userId}/${provider}/access-token`,
|
|
288
|
+
{
|
|
289
|
+
method: "POST",
|
|
290
|
+
headers: {
|
|
291
|
+
"content-type": "application/json"
|
|
292
|
+
},
|
|
293
|
+
body: JSON.stringify({ scope })
|
|
294
|
+
},
|
|
295
|
+
null
|
|
296
|
+
);
|
|
297
|
+
return await response.json();
|
|
298
|
+
}
|
|
299
|
+
async createServerUserSession(userId, expiresInMillis, isImpersonation) {
|
|
300
|
+
const response = await this.sendServerRequest(
|
|
301
|
+
"/auth/sessions",
|
|
302
|
+
{
|
|
303
|
+
method: "POST",
|
|
304
|
+
headers: {
|
|
305
|
+
"content-type": "application/json"
|
|
306
|
+
},
|
|
307
|
+
body: JSON.stringify({
|
|
308
|
+
user_id: userId,
|
|
309
|
+
expires_in_millis: expiresInMillis,
|
|
310
|
+
is_impersonation: isImpersonation
|
|
311
|
+
})
|
|
312
|
+
},
|
|
313
|
+
null
|
|
314
|
+
);
|
|
315
|
+
const result = await response.json();
|
|
316
|
+
return {
|
|
317
|
+
accessToken: result.access_token,
|
|
318
|
+
refreshToken: result.refresh_token
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
async leaveServerTeam(options) {
|
|
322
|
+
await this.sendClientRequest(
|
|
323
|
+
import_urls.urlString`/team-memberships/${options.teamId}/${options.userId}`,
|
|
324
|
+
{
|
|
325
|
+
method: "DELETE",
|
|
326
|
+
headers: {
|
|
327
|
+
"content-type": "application/json"
|
|
328
|
+
},
|
|
329
|
+
body: JSON.stringify({})
|
|
330
|
+
},
|
|
331
|
+
null
|
|
332
|
+
);
|
|
333
|
+
}
|
|
334
|
+
async updateServerTeamMemberProfile(options) {
|
|
335
|
+
await this.sendServerRequest(
|
|
336
|
+
import_urls.urlString`/team-member-profiles/${options.teamId}/${options.userId}`,
|
|
337
|
+
{
|
|
338
|
+
method: "PATCH",
|
|
339
|
+
headers: {
|
|
340
|
+
"content-type": "application/json"
|
|
341
|
+
},
|
|
342
|
+
body: JSON.stringify(options.profile)
|
|
343
|
+
},
|
|
344
|
+
null
|
|
345
|
+
);
|
|
346
|
+
}
|
|
347
|
+
async grantServerTeamUserPermission(teamId, userId, permissionId) {
|
|
348
|
+
await this.sendServerRequest(
|
|
349
|
+
import_urls.urlString`/team-permissions/${teamId}/${userId}/${permissionId}`,
|
|
350
|
+
{
|
|
351
|
+
method: "POST",
|
|
352
|
+
headers: {
|
|
353
|
+
"content-type": "application/json"
|
|
354
|
+
},
|
|
355
|
+
body: JSON.stringify({})
|
|
356
|
+
},
|
|
357
|
+
null
|
|
358
|
+
);
|
|
359
|
+
}
|
|
360
|
+
async revokeServerTeamUserPermission(teamId, userId, permissionId) {
|
|
361
|
+
await this.sendServerRequest(
|
|
362
|
+
import_urls.urlString`/team-permissions/${teamId}/${userId}/${permissionId}`,
|
|
363
|
+
{
|
|
364
|
+
method: "DELETE",
|
|
365
|
+
headers: {
|
|
366
|
+
"content-type": "application/json"
|
|
367
|
+
},
|
|
368
|
+
body: JSON.stringify({})
|
|
369
|
+
},
|
|
370
|
+
null
|
|
371
|
+
);
|
|
372
|
+
}
|
|
373
|
+
async deleteServerUser(userId) {
|
|
374
|
+
await this.sendServerRequest(
|
|
375
|
+
import_urls.urlString`/users/${userId}`,
|
|
376
|
+
{
|
|
377
|
+
method: "DELETE",
|
|
378
|
+
headers: {
|
|
379
|
+
"content-type": "application/json"
|
|
380
|
+
},
|
|
381
|
+
body: JSON.stringify({})
|
|
382
|
+
},
|
|
383
|
+
null
|
|
384
|
+
);
|
|
385
|
+
}
|
|
386
|
+
async createServerContactChannel(data) {
|
|
387
|
+
const response = await this.sendServerRequest(
|
|
388
|
+
"/contact-channels",
|
|
389
|
+
{
|
|
390
|
+
method: "POST",
|
|
391
|
+
headers: {
|
|
392
|
+
"content-type": "application/json"
|
|
393
|
+
},
|
|
394
|
+
body: JSON.stringify(data)
|
|
395
|
+
},
|
|
396
|
+
null
|
|
397
|
+
);
|
|
398
|
+
return await response.json();
|
|
399
|
+
}
|
|
400
|
+
async updateServerContactChannel(userId, contactChannelId, data) {
|
|
401
|
+
const response = await this.sendServerRequest(
|
|
402
|
+
import_urls.urlString`/contact-channels/${userId}/${contactChannelId}`,
|
|
403
|
+
{
|
|
404
|
+
method: "PATCH",
|
|
405
|
+
headers: {
|
|
406
|
+
"content-type": "application/json"
|
|
407
|
+
},
|
|
408
|
+
body: JSON.stringify(data)
|
|
409
|
+
},
|
|
410
|
+
null
|
|
411
|
+
);
|
|
412
|
+
return await response.json();
|
|
413
|
+
}
|
|
414
|
+
async deleteServerContactChannel(userId, contactChannelId) {
|
|
415
|
+
await this.sendServerRequest(
|
|
416
|
+
import_urls.urlString`/contact-channels/${userId}/${contactChannelId}`,
|
|
417
|
+
{
|
|
418
|
+
method: "DELETE"
|
|
419
|
+
},
|
|
420
|
+
null
|
|
421
|
+
);
|
|
422
|
+
}
|
|
423
|
+
async listServerContactChannels(userId) {
|
|
424
|
+
const response = await this.sendServerRequest(
|
|
425
|
+
import_urls.urlString`/contact-channels?user_id=${userId}`,
|
|
426
|
+
{
|
|
427
|
+
method: "GET"
|
|
428
|
+
},
|
|
429
|
+
null
|
|
430
|
+
);
|
|
431
|
+
const json = await response.json();
|
|
432
|
+
return json.items;
|
|
433
|
+
}
|
|
434
|
+
async sendServerContactChannelVerificationEmail(userId, contactChannelId, callbackUrl) {
|
|
435
|
+
await this.sendServerRequest(
|
|
436
|
+
import_urls.urlString`/contact-channels/${userId}/${contactChannelId}/send-verification-code`,
|
|
437
|
+
{
|
|
438
|
+
method: "POST",
|
|
439
|
+
headers: {
|
|
440
|
+
"content-type": "application/json"
|
|
441
|
+
},
|
|
442
|
+
body: JSON.stringify({ callback_url: callbackUrl })
|
|
443
|
+
},
|
|
444
|
+
null
|
|
445
|
+
);
|
|
446
|
+
}
|
|
447
|
+
async listServerSessions(userId) {
|
|
448
|
+
const response = await this.sendServerRequest(
|
|
449
|
+
import_urls.urlString`/auth/sessions?user_id=${userId}`,
|
|
450
|
+
{
|
|
451
|
+
method: "GET"
|
|
452
|
+
},
|
|
453
|
+
null
|
|
454
|
+
);
|
|
455
|
+
return await response.json();
|
|
456
|
+
}
|
|
457
|
+
async deleteServerSession(sessionId) {
|
|
458
|
+
await this.sendServerRequest(
|
|
459
|
+
import_urls.urlString`/auth/sessions/${sessionId}`,
|
|
460
|
+
{
|
|
461
|
+
method: "DELETE"
|
|
462
|
+
},
|
|
463
|
+
null
|
|
464
|
+
);
|
|
465
|
+
}
|
|
466
|
+
async sendServerTeamInvitation(options) {
|
|
467
|
+
await this.sendServerRequest(
|
|
468
|
+
"/team-invitations/send-code",
|
|
469
|
+
{
|
|
470
|
+
method: "POST",
|
|
471
|
+
headers: {
|
|
472
|
+
"Content-Type": "application/json"
|
|
473
|
+
},
|
|
474
|
+
body: JSON.stringify({
|
|
475
|
+
email: options.email,
|
|
476
|
+
team_id: options.teamId,
|
|
477
|
+
callback_url: options.callbackUrl
|
|
478
|
+
})
|
|
479
|
+
},
|
|
480
|
+
null
|
|
481
|
+
);
|
|
482
|
+
}
|
|
483
|
+
async updatePassword(options) {
|
|
484
|
+
const res = await this.sendServerRequestAndCatchKnownError(
|
|
485
|
+
"/auth/password/update",
|
|
486
|
+
{
|
|
487
|
+
method: "POST",
|
|
488
|
+
headers: {
|
|
489
|
+
"Content-Type": "application/json"
|
|
490
|
+
},
|
|
491
|
+
body: JSON.stringify({
|
|
492
|
+
old_password: options.oldPassword,
|
|
493
|
+
new_password: options.newPassword
|
|
494
|
+
})
|
|
495
|
+
},
|
|
496
|
+
null,
|
|
497
|
+
[import_known_errors.KnownErrors.PasswordConfirmationMismatch, import_known_errors.KnownErrors.PasswordRequirementsNotMet]
|
|
498
|
+
);
|
|
499
|
+
if (res.status === "error") {
|
|
500
|
+
return res.error;
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
};
|
|
504
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
505
|
+
0 && (module.exports = {
|
|
506
|
+
StackServerInterface
|
|
507
|
+
});
|
|
508
|
+
//# sourceMappingURL=serverInterface.js.map
|