@neontechspace/fluxerly 1000.0.0-nightly.12
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 +833 -0
- package/LICENSE +201 -0
- package/README.md +129 -0
- package/agents/AGENTS.md +195 -0
- package/dist/api/default/application.d.ts +34 -0
- package/dist/api/default/application.d.ts.map +1 -0
- package/dist/api/default/application.js +2 -0
- package/dist/api/default/application.js.map +1 -0
- package/dist/api/default/attachments.d.ts +89 -0
- package/dist/api/default/attachments.d.ts.map +1 -0
- package/dist/api/default/attachments.js +2 -0
- package/dist/api/default/attachments.js.map +1 -0
- package/dist/api/default/audit-logs.d.ts +48 -0
- package/dist/api/default/audit-logs.d.ts.map +1 -0
- package/dist/api/default/audit-logs.js +2 -0
- package/dist/api/default/audit-logs.js.map +1 -0
- package/dist/api/default/bot.d.ts +200 -0
- package/dist/api/default/bot.d.ts.map +1 -0
- package/dist/api/default/bot.js +309 -0
- package/dist/api/default/bot.js.map +1 -0
- package/dist/api/default/cache.d.ts +105 -0
- package/dist/api/default/cache.d.ts.map +1 -0
- package/dist/api/default/cache.js +2 -0
- package/dist/api/default/cache.js.map +1 -0
- package/dist/api/default/channels.d.ts +249 -0
- package/dist/api/default/channels.d.ts.map +1 -0
- package/dist/api/default/channels.js +2 -0
- package/dist/api/default/channels.js.map +1 -0
- package/dist/api/default/client.d.ts +528 -0
- package/dist/api/default/client.d.ts.map +1 -0
- package/dist/api/default/client.js +301 -0
- package/dist/api/default/client.js.map +1 -0
- package/dist/api/default/collectors.d.ts +76 -0
- package/dist/api/default/collectors.d.ts.map +1 -0
- package/dist/api/default/collectors.js +2 -0
- package/dist/api/default/collectors.js.map +1 -0
- package/dist/api/default/commands.d.ts +91 -0
- package/dist/api/default/commands.d.ts.map +1 -0
- package/dist/api/default/commands.js +92 -0
- package/dist/api/default/commands.js.map +1 -0
- package/dist/api/default/direct-messages.d.ts +111 -0
- package/dist/api/default/direct-messages.d.ts.map +1 -0
- package/dist/api/default/direct-messages.js +2 -0
- package/dist/api/default/direct-messages.js.map +1 -0
- package/dist/api/default/discovery.d.ts +76 -0
- package/dist/api/default/discovery.d.ts.map +1 -0
- package/dist/api/default/discovery.js +2 -0
- package/dist/api/default/discovery.js.map +1 -0
- package/dist/api/default/emojis.d.ts +88 -0
- package/dist/api/default/emojis.d.ts.map +1 -0
- package/dist/api/default/emojis.js +2 -0
- package/dist/api/default/emojis.js.map +1 -0
- package/dist/api/default/events.d.ts +127 -0
- package/dist/api/default/events.d.ts.map +1 -0
- package/dist/api/default/events.js +2 -0
- package/dist/api/default/events.js.map +1 -0
- package/dist/api/default/gateway.d.ts +62 -0
- package/dist/api/default/gateway.d.ts.map +1 -0
- package/dist/api/default/gateway.js +2 -0
- package/dist/api/default/gateway.js.map +1 -0
- package/dist/api/default/guards.d.ts +87 -0
- package/dist/api/default/guards.d.ts.map +1 -0
- package/dist/api/default/guards.js +78 -0
- package/dist/api/default/guards.js.map +1 -0
- package/dist/api/default/guilds.d.ts +230 -0
- package/dist/api/default/guilds.d.ts.map +1 -0
- package/dist/api/default/guilds.js +2 -0
- package/dist/api/default/guilds.js.map +1 -0
- package/dist/api/default/helpers.d.ts +79 -0
- package/dist/api/default/helpers.d.ts.map +1 -0
- package/dist/api/default/helpers.js +79 -0
- package/dist/api/default/helpers.js.map +1 -0
- package/dist/api/default/instance.d.ts +47 -0
- package/dist/api/default/instance.d.ts.map +1 -0
- package/dist/api/default/instance.js +2 -0
- package/dist/api/default/instance.js.map +1 -0
- package/dist/api/default/invites.d.ts +57 -0
- package/dist/api/default/invites.d.ts.map +1 -0
- package/dist/api/default/invites.js +2 -0
- package/dist/api/default/invites.js.map +1 -0
- package/dist/api/default/logging.d.ts +37 -0
- package/dist/api/default/logging.d.ts.map +1 -0
- package/dist/api/default/logging.js +2 -0
- package/dist/api/default/logging.js.map +1 -0
- package/dist/api/default/members.d.ts +442 -0
- package/dist/api/default/members.d.ts.map +1 -0
- package/dist/api/default/members.js +2 -0
- package/dist/api/default/members.js.map +1 -0
- package/dist/api/default/messages.d.ts +898 -0
- package/dist/api/default/messages.d.ts.map +1 -0
- package/dist/api/default/messages.js +2 -0
- package/dist/api/default/messages.js.map +1 -0
- package/dist/api/default/oauth.d.ts +168 -0
- package/dist/api/default/oauth.d.ts.map +1 -0
- package/dist/api/default/oauth.js +84 -0
- package/dist/api/default/oauth.js.map +1 -0
- package/dist/api/default/permissions.d.ts +44 -0
- package/dist/api/default/permissions.d.ts.map +1 -0
- package/dist/api/default/permissions.js +2 -0
- package/dist/api/default/permissions.js.map +1 -0
- package/dist/api/default/presence.d.ts +88 -0
- package/dist/api/default/presence.d.ts.map +1 -0
- package/dist/api/default/presence.js +2 -0
- package/dist/api/default/presence.js.map +1 -0
- package/dist/api/default/rest.d.ts +28 -0
- package/dist/api/default/rest.d.ts.map +1 -0
- package/dist/api/default/rest.js +2 -0
- package/dist/api/default/rest.js.map +1 -0
- package/dist/api/default/results.d.ts +31 -0
- package/dist/api/default/results.d.ts.map +1 -0
- package/dist/api/default/results.js +14 -0
- package/dist/api/default/results.js.map +1 -0
- package/dist/api/default/roles.d.ts +119 -0
- package/dist/api/default/roles.d.ts.map +1 -0
- package/dist/api/default/roles.js +2 -0
- package/dist/api/default/roles.js.map +1 -0
- package/dist/api/default/stickers.d.ts +92 -0
- package/dist/api/default/stickers.d.ts.map +1 -0
- package/dist/api/default/stickers.js +2 -0
- package/dist/api/default/stickers.js.map +1 -0
- package/dist/api/default/supervisor.d.ts +51 -0
- package/dist/api/default/supervisor.d.ts.map +1 -0
- package/dist/api/default/supervisor.js +53 -0
- package/dist/api/default/supervisor.js.map +1 -0
- package/dist/api/default/threads.d.ts +158 -0
- package/dist/api/default/threads.d.ts.map +1 -0
- package/dist/api/default/threads.js +2 -0
- package/dist/api/default/threads.js.map +1 -0
- package/dist/api/default/users.d.ts +73 -0
- package/dist/api/default/users.d.ts.map +1 -0
- package/dist/api/default/users.js +2 -0
- package/dist/api/default/users.js.map +1 -0
- package/dist/api/default/webhook-client.d.ts +149 -0
- package/dist/api/default/webhook-client.d.ts.map +1 -0
- package/dist/api/default/webhook-client.js +69 -0
- package/dist/api/default/webhook-client.js.map +1 -0
- package/dist/api/default/webhooks.d.ts +62 -0
- package/dist/api/default/webhooks.d.ts.map +1 -0
- package/dist/api/default/webhooks.js +2 -0
- package/dist/api/default/webhooks.js.map +1 -0
- package/dist/api/effect/application.d.ts +29 -0
- package/dist/api/effect/application.d.ts.map +1 -0
- package/dist/api/effect/application.js +2 -0
- package/dist/api/effect/application.js.map +1 -0
- package/dist/api/effect/attachments.d.ts +84 -0
- package/dist/api/effect/attachments.d.ts.map +1 -0
- package/dist/api/effect/attachments.js +2 -0
- package/dist/api/effect/attachments.js.map +1 -0
- package/dist/api/effect/audit-logs.d.ts +42 -0
- package/dist/api/effect/audit-logs.d.ts.map +1 -0
- package/dist/api/effect/audit-logs.js +2 -0
- package/dist/api/effect/audit-logs.js.map +1 -0
- package/dist/api/effect/bot.d.ts +233 -0
- package/dist/api/effect/bot.d.ts.map +1 -0
- package/dist/api/effect/bot.js +230 -0
- package/dist/api/effect/bot.js.map +1 -0
- package/dist/api/effect/cache.d.ts +103 -0
- package/dist/api/effect/cache.d.ts.map +1 -0
- package/dist/api/effect/cache.js +2 -0
- package/dist/api/effect/cache.js.map +1 -0
- package/dist/api/effect/channels.d.ts +231 -0
- package/dist/api/effect/channels.d.ts.map +1 -0
- package/dist/api/effect/channels.js +2 -0
- package/dist/api/effect/channels.js.map +1 -0
- package/dist/api/effect/client.d.ts +622 -0
- package/dist/api/effect/client.d.ts.map +1 -0
- package/dist/api/effect/client.js +191 -0
- package/dist/api/effect/client.js.map +1 -0
- package/dist/api/effect/collectors.d.ts +90 -0
- package/dist/api/effect/collectors.d.ts.map +1 -0
- package/dist/api/effect/collectors.js +2 -0
- package/dist/api/effect/collectors.js.map +1 -0
- package/dist/api/effect/commands.d.ts +86 -0
- package/dist/api/effect/commands.d.ts.map +1 -0
- package/dist/api/effect/commands.js +87 -0
- package/dist/api/effect/commands.js.map +1 -0
- package/dist/api/effect/direct-messages.d.ts +102 -0
- package/dist/api/effect/direct-messages.d.ts.map +1 -0
- package/dist/api/effect/direct-messages.js +2 -0
- package/dist/api/effect/direct-messages.js.map +1 -0
- package/dist/api/effect/discovery.d.ts +68 -0
- package/dist/api/effect/discovery.d.ts.map +1 -0
- package/dist/api/effect/discovery.js +2 -0
- package/dist/api/effect/discovery.js.map +1 -0
- package/dist/api/effect/emojis.d.ts +77 -0
- package/dist/api/effect/emojis.d.ts.map +1 -0
- package/dist/api/effect/emojis.js +2 -0
- package/dist/api/effect/emojis.js.map +1 -0
- package/dist/api/effect/events.d.ts +78 -0
- package/dist/api/effect/events.d.ts.map +1 -0
- package/dist/api/effect/events.js +12 -0
- package/dist/api/effect/events.js.map +1 -0
- package/dist/api/effect/failures.d.ts +14 -0
- package/dist/api/effect/failures.d.ts.map +1 -0
- package/dist/api/effect/failures.js +2 -0
- package/dist/api/effect/failures.js.map +1 -0
- package/dist/api/effect/gateway.d.ts +63 -0
- package/dist/api/effect/gateway.d.ts.map +1 -0
- package/dist/api/effect/gateway.js +2 -0
- package/dist/api/effect/gateway.js.map +1 -0
- package/dist/api/effect/guards.d.ts +91 -0
- package/dist/api/effect/guards.d.ts.map +1 -0
- package/dist/api/effect/guards.js +94 -0
- package/dist/api/effect/guards.js.map +1 -0
- package/dist/api/effect/guilds.d.ts +221 -0
- package/dist/api/effect/guilds.d.ts.map +1 -0
- package/dist/api/effect/guilds.js +2 -0
- package/dist/api/effect/guilds.js.map +1 -0
- package/dist/api/effect/helpers.d.ts +300 -0
- package/dist/api/effect/helpers.d.ts.map +1 -0
- package/dist/api/effect/helpers.js +156 -0
- package/dist/api/effect/helpers.js.map +1 -0
- package/dist/api/effect/hierarchy.d.ts +26 -0
- package/dist/api/effect/hierarchy.d.ts.map +1 -0
- package/dist/api/effect/hierarchy.js +26 -0
- package/dist/api/effect/hierarchy.js.map +1 -0
- package/dist/api/effect/instance.d.ts +46 -0
- package/dist/api/effect/instance.d.ts.map +1 -0
- package/dist/api/effect/instance.js +8 -0
- package/dist/api/effect/instance.js.map +1 -0
- package/dist/api/effect/invites.d.ts +49 -0
- package/dist/api/effect/invites.d.ts.map +1 -0
- package/dist/api/effect/invites.js +2 -0
- package/dist/api/effect/invites.js.map +1 -0
- package/dist/api/effect/logging.d.ts +37 -0
- package/dist/api/effect/logging.d.ts.map +1 -0
- package/dist/api/effect/logging.js +2 -0
- package/dist/api/effect/logging.js.map +1 -0
- package/dist/api/effect/members.d.ts +433 -0
- package/dist/api/effect/members.d.ts.map +1 -0
- package/dist/api/effect/members.js +2 -0
- package/dist/api/effect/members.js.map +1 -0
- package/dist/api/effect/messages.d.ts +877 -0
- package/dist/api/effect/messages.d.ts.map +1 -0
- package/dist/api/effect/messages.js +2 -0
- package/dist/api/effect/messages.js.map +1 -0
- package/dist/api/effect/oauth.d.ts +148 -0
- package/dist/api/effect/oauth.d.ts.map +1 -0
- package/dist/api/effect/oauth.js +51 -0
- package/dist/api/effect/oauth.js.map +1 -0
- package/dist/api/effect/permissions.d.ts +41 -0
- package/dist/api/effect/permissions.d.ts.map +1 -0
- package/dist/api/effect/permissions.js +2 -0
- package/dist/api/effect/permissions.js.map +1 -0
- package/dist/api/effect/presence.d.ts +83 -0
- package/dist/api/effect/presence.d.ts.map +1 -0
- package/dist/api/effect/presence.js +2 -0
- package/dist/api/effect/presence.js.map +1 -0
- package/dist/api/effect/rest.d.ts +27 -0
- package/dist/api/effect/rest.d.ts.map +1 -0
- package/dist/api/effect/rest.js +2 -0
- package/dist/api/effect/rest.js.map +1 -0
- package/dist/api/effect/roles.d.ts +104 -0
- package/dist/api/effect/roles.d.ts.map +1 -0
- package/dist/api/effect/roles.js +2 -0
- package/dist/api/effect/roles.js.map +1 -0
- package/dist/api/effect/service.d.ts +76 -0
- package/dist/api/effect/service.d.ts.map +1 -0
- package/dist/api/effect/service.js +79 -0
- package/dist/api/effect/service.js.map +1 -0
- package/dist/api/effect/stickers.d.ts +81 -0
- package/dist/api/effect/stickers.d.ts.map +1 -0
- package/dist/api/effect/stickers.js +2 -0
- package/dist/api/effect/stickers.js.map +1 -0
- package/dist/api/effect/supervisor.d.ts +56 -0
- package/dist/api/effect/supervisor.d.ts.map +1 -0
- package/dist/api/effect/supervisor.js +58 -0
- package/dist/api/effect/supervisor.js.map +1 -0
- package/dist/api/effect/threads.d.ts +154 -0
- package/dist/api/effect/threads.d.ts.map +1 -0
- package/dist/api/effect/threads.js +2 -0
- package/dist/api/effect/threads.js.map +1 -0
- package/dist/api/effect/users.d.ts +62 -0
- package/dist/api/effect/users.d.ts.map +1 -0
- package/dist/api/effect/users.js +2 -0
- package/dist/api/effect/users.js.map +1 -0
- package/dist/api/effect/webhook-client.d.ts +140 -0
- package/dist/api/effect/webhook-client.d.ts.map +1 -0
- package/dist/api/effect/webhook-client.js +50 -0
- package/dist/api/effect/webhook-client.js.map +1 -0
- package/dist/api/effect/webhooks.d.ts +54 -0
- package/dist/api/effect/webhooks.d.ts.map +1 -0
- package/dist/api/effect/webhooks.js +2 -0
- package/dist/api/effect/webhooks.js.map +1 -0
- package/dist/api-errors.d.ts +609 -0
- package/dist/api-errors.d.ts.map +1 -0
- package/dist/api-errors.js +589 -0
- package/dist/api-errors.js.map +1 -0
- package/dist/application.d.ts +85 -0
- package/dist/application.d.ts.map +1 -0
- package/dist/application.js +44 -0
- package/dist/application.js.map +1 -0
- package/dist/assets.d.ts +197 -0
- package/dist/assets.d.ts.map +1 -0
- package/dist/assets.js +419 -0
- package/dist/assets.js.map +1 -0
- package/dist/attachments.d.ts +400 -0
- package/dist/attachments.d.ts.map +1 -0
- package/dist/attachments.js +88 -0
- package/dist/attachments.js.map +1 -0
- package/dist/audit-logs.d.ts +292 -0
- package/dist/audit-logs.d.ts.map +1 -0
- package/dist/audit-logs.js +46 -0
- package/dist/audit-logs.js.map +1 -0
- package/dist/bot-runner.d.ts +69 -0
- package/dist/bot-runner.d.ts.map +1 -0
- package/dist/bot-runner.js +41 -0
- package/dist/bot-runner.js.map +1 -0
- package/dist/builders.d.ts +153 -0
- package/dist/builders.d.ts.map +1 -0
- package/dist/builders.js +326 -0
- package/dist/builders.js.map +1 -0
- package/dist/cache.d.ts +187 -0
- package/dist/cache.d.ts.map +1 -0
- package/dist/cache.js +2 -0
- package/dist/cache.js.map +1 -0
- package/dist/channels.d.ts +903 -0
- package/dist/channels.d.ts.map +1 -0
- package/dist/channels.js +125 -0
- package/dist/channels.js.map +1 -0
- package/dist/cli.d.ts +9 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +65 -0
- package/dist/cli.js.map +1 -0
- package/dist/client.d.ts +645 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +2 -0
- package/dist/client.js.map +1 -0
- package/dist/collectors.d.ts +205 -0
- package/dist/collectors.d.ts.map +1 -0
- package/dist/collectors.js +71 -0
- package/dist/collectors.js.map +1 -0
- package/dist/colors.d.ts +55 -0
- package/dist/colors.d.ts.map +1 -0
- package/dist/colors.js +40 -0
- package/dist/colors.js.map +1 -0
- package/dist/command-arguments.d.ts +353 -0
- package/dist/command-arguments.d.ts.map +1 -0
- package/dist/command-arguments.js +2 -0
- package/dist/command-arguments.js.map +1 -0
- package/dist/command-help.d.ts +54 -0
- package/dist/command-help.d.ts.map +1 -0
- package/dist/command-help.js +2 -0
- package/dist/command-help.js.map +1 -0
- package/dist/commands.d.ts +328 -0
- package/dist/commands.d.ts.map +1 -0
- package/dist/commands.js +62 -0
- package/dist/commands.js.map +1 -0
- package/dist/counts.d.ts +124 -0
- package/dist/counts.d.ts.map +1 -0
- package/dist/counts.js +52 -0
- package/dist/counts.js.map +1 -0
- package/dist/default-commands.d.ts +400 -0
- package/dist/default-commands.d.ts.map +1 -0
- package/dist/default-commands.js +488 -0
- package/dist/default-commands.js.map +1 -0
- package/dist/default-supervisor.d.ts +111 -0
- package/dist/default-supervisor.d.ts.map +1 -0
- package/dist/default-supervisor.js +277 -0
- package/dist/default-supervisor.js.map +1 -0
- package/dist/discovery.d.ts +223 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +18 -0
- package/dist/discovery.js.map +1 -0
- package/dist/effect-testing.d.ts +388 -0
- package/dist/effect-testing.d.ts.map +1 -0
- package/dist/effect-testing.js +261 -0
- package/dist/effect-testing.js.map +1 -0
- package/dist/effect.d.ts +220 -0
- package/dist/effect.d.ts.map +1 -0
- package/dist/effect.js +101 -0
- package/dist/effect.js.map +1 -0
- package/dist/embeds.d.ts +243 -0
- package/dist/embeds.d.ts.map +1 -0
- package/dist/embeds.js +2 -0
- package/dist/embeds.js.map +1 -0
- package/dist/error-tools.d.ts +101 -0
- package/dist/error-tools.d.ts.map +1 -0
- package/dist/error-tools.js +125 -0
- package/dist/error-tools.js.map +1 -0
- package/dist/errors.d.ts +386 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +440 -0
- package/dist/errors.js.map +1 -0
- package/dist/events.d.ts +798 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +2 -0
- package/dist/events.js.map +1 -0
- package/dist/expressions.d.ts +188 -0
- package/dist/expressions.d.ts.map +1 -0
- package/dist/expressions.js +2 -0
- package/dist/expressions.js.map +1 -0
- package/dist/failures.d.ts +53 -0
- package/dist/failures.d.ts.map +1 -0
- package/dist/failures.js +2 -0
- package/dist/failures.js.map +1 -0
- package/dist/gateway.d.ts +48 -0
- package/dist/gateway.d.ts.map +1 -0
- package/dist/gateway.js +60 -0
- package/dist/gateway.js.map +1 -0
- package/dist/guilds.d.ts +923 -0
- package/dist/guilds.d.ts.map +1 -0
- package/dist/guilds.js +204 -0
- package/dist/guilds.js.map +1 -0
- package/dist/helpers.d.ts +423 -0
- package/dist/helpers.d.ts.map +1 -0
- package/dist/helpers.js +434 -0
- package/dist/helpers.js.map +1 -0
- package/dist/index.d.ts +228 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +109 -0
- package/dist/index.js.map +1 -0
- package/dist/input-validation.d.ts +51 -0
- package/dist/input-validation.d.ts.map +1 -0
- package/dist/input-validation.js +34 -0
- package/dist/input-validation.js.map +1 -0
- package/dist/instance.d.ts +101 -0
- package/dist/instance.d.ts.map +1 -0
- package/dist/instance.js +2 -0
- package/dist/instance.js.map +1 -0
- package/dist/internal/agents-section.d.ts +22 -0
- package/dist/internal/agents-section.d.ts.map +1 -0
- package/dist/internal/agents-section.js +101 -0
- package/dist/internal/agents-section.js.map +1 -0
- package/dist/internal/application.d.ts +16 -0
- package/dist/internal/application.d.ts.map +1 -0
- package/dist/internal/application.js +33 -0
- package/dist/internal/application.js.map +1 -0
- package/dist/internal/attachment-refresh.d.ts +18 -0
- package/dist/internal/attachment-refresh.d.ts.map +1 -0
- package/dist/internal/attachment-refresh.js +39 -0
- package/dist/internal/attachment-refresh.js.map +1 -0
- package/dist/internal/attachments.d.ts +45 -0
- package/dist/internal/attachments.d.ts.map +1 -0
- package/dist/internal/attachments.js +230 -0
- package/dist/internal/attachments.js.map +1 -0
- package/dist/internal/audit-logs.d.ts +13 -0
- package/dist/internal/audit-logs.d.ts.map +1 -0
- package/dist/internal/audit-logs.js +295 -0
- package/dist/internal/audit-logs.js.map +1 -0
- package/dist/internal/audit.d.ts +12 -0
- package/dist/internal/audit.d.ts.map +1 -0
- package/dist/internal/audit.js +22 -0
- package/dist/internal/audit.js.map +1 -0
- package/dist/internal/binding/default-adapters.d.ts +22 -0
- package/dist/internal/binding/default-adapters.d.ts.map +1 -0
- package/dist/internal/binding/default-adapters.js +304 -0
- package/dist/internal/binding/default-adapters.js.map +1 -0
- package/dist/internal/binding/default.d.ts +45 -0
- package/dist/internal/binding/default.d.ts.map +1 -0
- package/dist/internal/binding/default.js +86 -0
- package/dist/internal/binding/default.js.map +1 -0
- package/dist/internal/binding/execute.d.ts +51 -0
- package/dist/internal/binding/execute.d.ts.map +1 -0
- package/dist/internal/binding/execute.js +123 -0
- package/dist/internal/binding/execute.js.map +1 -0
- package/dist/internal/binding/native-adapters.d.ts +23 -0
- package/dist/internal/binding/native-adapters.d.ts.map +1 -0
- package/dist/internal/binding/native-adapters.js +90 -0
- package/dist/internal/binding/native-adapters.js.map +1 -0
- package/dist/internal/binding/native.d.ts +41 -0
- package/dist/internal/binding/native.d.ts.map +1 -0
- package/dist/internal/binding/native.js +34 -0
- package/dist/internal/binding/native.js.map +1 -0
- package/dist/internal/binding/operations.d.ts +361 -0
- package/dist/internal/binding/operations.d.ts.map +1 -0
- package/dist/internal/binding/operations.js +272 -0
- package/dist/internal/binding/operations.js.map +1 -0
- package/dist/internal/bot-runner.d.ts +65 -0
- package/dist/internal/bot-runner.d.ts.map +1 -0
- package/dist/internal/bot-runner.js +363 -0
- package/dist/internal/bot-runner.js.map +1 -0
- package/dist/internal/cache-changes.d.ts +43 -0
- package/dist/internal/cache-changes.d.ts.map +1 -0
- package/dist/internal/cache-changes.js +320 -0
- package/dist/internal/cache-changes.js.map +1 -0
- package/dist/internal/cache.d.ts +57 -0
- package/dist/internal/cache.d.ts.map +1 -0
- package/dist/internal/cache.js +318 -0
- package/dist/internal/cache.js.map +1 -0
- package/dist/internal/calls.d.ts +16 -0
- package/dist/internal/calls.d.ts.map +1 -0
- package/dist/internal/calls.js +108 -0
- package/dist/internal/calls.js.map +1 -0
- package/dist/internal/channel-cache.d.ts +69 -0
- package/dist/internal/channel-cache.d.ts.map +1 -0
- package/dist/internal/channel-cache.js +413 -0
- package/dist/internal/channel-cache.js.map +1 -0
- package/dist/internal/channel-decode.d.ts +44 -0
- package/dist/internal/channel-decode.d.ts.map +1 -0
- package/dist/internal/channel-decode.js +377 -0
- package/dist/internal/channel-decode.js.map +1 -0
- package/dist/internal/channels.d.ts +60 -0
- package/dist/internal/channels.d.ts.map +1 -0
- package/dist/internal/channels.js +605 -0
- package/dist/internal/channels.js.map +1 -0
- package/dist/internal/client/backoff.d.ts +42 -0
- package/dist/internal/client/backoff.d.ts.map +1 -0
- package/dist/internal/client/backoff.js +36 -0
- package/dist/internal/client/backoff.js.map +1 -0
- package/dist/internal/client/configuration-fields.d.ts +14 -0
- package/dist/internal/client/configuration-fields.d.ts.map +1 -0
- package/dist/internal/client/configuration-fields.js +11 -0
- package/dist/internal/client/configuration-fields.js.map +1 -0
- package/dist/internal/client/drain.d.ts +33 -0
- package/dist/internal/client/drain.d.ts.map +1 -0
- package/dist/internal/client/drain.js +109 -0
- package/dist/internal/client/drain.js.map +1 -0
- package/dist/internal/client/intake.d.ts +27 -0
- package/dist/internal/client/intake.d.ts.map +1 -0
- package/dist/internal/client/intake.js +198 -0
- package/dist/internal/client/intake.js.map +1 -0
- package/dist/internal/client/lifetime.d.ts +35 -0
- package/dist/internal/client/lifetime.d.ts.map +1 -0
- package/dist/internal/client/lifetime.js +109 -0
- package/dist/internal/client/lifetime.js.map +1 -0
- package/dist/internal/client/shard-loop.d.ts +93 -0
- package/dist/internal/client/shard-loop.d.ts.map +1 -0
- package/dist/internal/client/shard-loop.js +452 -0
- package/dist/internal/client/shard-loop.js.map +1 -0
- package/dist/internal/client-registry.d.ts +26 -0
- package/dist/internal/client-registry.d.ts.map +1 -0
- package/dist/internal/client-registry.js +11 -0
- package/dist/internal/client-registry.js.map +1 -0
- package/dist/internal/client.d.ts +189 -0
- package/dist/internal/client.d.ts.map +1 -0
- package/dist/internal/client.js +1935 -0
- package/dist/internal/client.js.map +1 -0
- package/dist/internal/clock.d.ts +9 -0
- package/dist/internal/clock.d.ts.map +1 -0
- package/dist/internal/clock.js +5 -0
- package/dist/internal/clock.js.map +1 -0
- package/dist/internal/code-catalogue.d.ts +712 -0
- package/dist/internal/code-catalogue.d.ts.map +1 -0
- package/dist/internal/code-catalogue.js +655 -0
- package/dist/internal/code-catalogue.js.map +1 -0
- package/dist/internal/collector.d.ts +34 -0
- package/dist/internal/collector.d.ts.map +1 -0
- package/dist/internal/collector.js +400 -0
- package/dist/internal/collector.js.map +1 -0
- package/dist/internal/command-arguments.d.ts +29 -0
- package/dist/internal/command-arguments.d.ts.map +1 -0
- package/dist/internal/command-arguments.js +484 -0
- package/dist/internal/command-arguments.js.map +1 -0
- package/dist/internal/command-guards.d.ts +57 -0
- package/dist/internal/command-guards.d.ts.map +1 -0
- package/dist/internal/command-guards.js +81 -0
- package/dist/internal/command-guards.js.map +1 -0
- package/dist/internal/command-help.d.ts +15 -0
- package/dist/internal/command-help.d.ts.map +1 -0
- package/dist/internal/command-help.js +121 -0
- package/dist/internal/command-help.js.map +1 -0
- package/dist/internal/commands.d.ts +212 -0
- package/dist/internal/commands.d.ts.map +1 -0
- package/dist/internal/commands.js +1004 -0
- package/dist/internal/commands.js.map +1 -0
- package/dist/internal/configuration.d.ts +86 -0
- package/dist/internal/configuration.d.ts.map +1 -0
- package/dist/internal/configuration.js +401 -0
- package/dist/internal/configuration.js.map +1 -0
- package/dist/internal/counts.d.ts +33 -0
- package/dist/internal/counts.d.ts.map +1 -0
- package/dist/internal/counts.js +348 -0
- package/dist/internal/counts.js.map +1 -0
- package/dist/internal/decode/primitives.d.ts +30 -0
- package/dist/internal/decode/primitives.d.ts.map +1 -0
- package/dist/internal/decode/primitives.js +56 -0
- package/dist/internal/decode/primitives.js.map +1 -0
- package/dist/internal/decode/timestamp.d.ts +13 -0
- package/dist/internal/decode/timestamp.d.ts.map +1 -0
- package/dist/internal/decode/timestamp.js +27 -0
- package/dist/internal/decode/timestamp.js.map +1 -0
- package/dist/internal/decode/trace.d.ts +11 -0
- package/dist/internal/decode/trace.d.ts.map +1 -0
- package/dist/internal/decode/trace.js +69 -0
- package/dist/internal/decode/trace.js.map +1 -0
- package/dist/internal/defects.d.ts +48 -0
- package/dist/internal/defects.d.ts.map +1 -0
- package/dist/internal/defects.js +100 -0
- package/dist/internal/defects.js.map +1 -0
- package/dist/internal/effect-failures.d.ts +12 -0
- package/dist/internal/effect-failures.d.ts.map +1 -0
- package/dist/internal/effect-failures.js +45 -0
- package/dist/internal/effect-failures.js.map +1 -0
- package/dist/internal/embeds.d.ts +12 -0
- package/dist/internal/embeds.d.ts.map +1 -0
- package/dist/internal/embeds.js +308 -0
- package/dist/internal/embeds.js.map +1 -0
- package/dist/internal/events.d.ts +156 -0
- package/dist/internal/events.d.ts.map +1 -0
- package/dist/internal/events.js +1071 -0
- package/dist/internal/events.js.map +1 -0
- package/dist/internal/expiry-queue.d.ts +42 -0
- package/dist/internal/expiry-queue.d.ts.map +1 -0
- package/dist/internal/expiry-queue.js +138 -0
- package/dist/internal/expiry-queue.js.map +1 -0
- package/dist/internal/expressions.d.ts +35 -0
- package/dist/internal/expressions.d.ts.map +1 -0
- package/dist/internal/expressions.js +311 -0
- package/dist/internal/expressions.js.map +1 -0
- package/dist/internal/failures.d.ts +107 -0
- package/dist/internal/failures.d.ts.map +1 -0
- package/dist/internal/failures.js +416 -0
- package/dist/internal/failures.js.map +1 -0
- package/dist/internal/field-text.d.ts +10 -0
- package/dist/internal/field-text.d.ts.map +1 -0
- package/dist/internal/field-text.js +37 -0
- package/dist/internal/field-text.js.map +1 -0
- package/dist/internal/gateway/commands.d.ts +92 -0
- package/dist/internal/gateway/commands.d.ts.map +1 -0
- package/dist/internal/gateway/commands.js +223 -0
- package/dist/internal/gateway/commands.js.map +1 -0
- package/dist/internal/gateway/dispatch-table.d.ts +42 -0
- package/dist/internal/gateway/dispatch-table.d.ts.map +1 -0
- package/dist/internal/gateway/dispatch-table.js +288 -0
- package/dist/internal/gateway/dispatch-table.js.map +1 -0
- package/dist/internal/gateway/event-dispatches.d.ts +97 -0
- package/dist/internal/gateway/event-dispatches.d.ts.map +1 -0
- package/dist/internal/gateway/event-dispatches.js +172 -0
- package/dist/internal/gateway/event-dispatches.js.map +1 -0
- package/dist/internal/gateway/frames.d.ts +45 -0
- package/dist/internal/gateway/frames.d.ts.map +1 -0
- package/dist/internal/gateway/frames.js +121 -0
- package/dist/internal/gateway/frames.js.map +1 -0
- package/dist/internal/gateway/options.d.ts +24 -0
- package/dist/internal/gateway/options.d.ts.map +1 -0
- package/dist/internal/gateway/options.js +103 -0
- package/dist/internal/gateway/options.js.map +1 -0
- package/dist/internal/gateway/session.d.ts +104 -0
- package/dist/internal/gateway/session.d.ts.map +1 -0
- package/dist/internal/gateway/session.js +420 -0
- package/dist/internal/gateway/session.js.map +1 -0
- package/dist/internal/gateway-requests.d.ts +10 -0
- package/dist/internal/gateway-requests.d.ts.map +1 -0
- package/dist/internal/gateway-requests.js +26 -0
- package/dist/internal/gateway-requests.js.map +1 -0
- package/dist/internal/gateway.d.ts +19 -0
- package/dist/internal/gateway.d.ts.map +1 -0
- package/dist/internal/gateway.js +11 -0
- package/dist/internal/gateway.js.map +1 -0
- package/dist/internal/guild-cache.d.ts +69 -0
- package/dist/internal/guild-cache.d.ts.map +1 -0
- package/dist/internal/guild-cache.js +402 -0
- package/dist/internal/guild-cache.js.map +1 -0
- package/dist/internal/guild-discovery.d.ts +15 -0
- package/dist/internal/guild-discovery.d.ts.map +1 -0
- package/dist/internal/guild-discovery.js +258 -0
- package/dist/internal/guild-discovery.js.map +1 -0
- package/dist/internal/guild-lifecycle.d.ts +18 -0
- package/dist/internal/guild-lifecycle.d.ts.map +1 -0
- package/dist/internal/guild-lifecycle.js +119 -0
- package/dist/internal/guild-lifecycle.js.map +1 -0
- package/dist/internal/guild-settings.d.ts +11 -0
- package/dist/internal/guild-settings.d.ts.map +1 -0
- package/dist/internal/guild-settings.js +150 -0
- package/dist/internal/guild-settings.js.map +1 -0
- package/dist/internal/guilds.d.ts +94 -0
- package/dist/internal/guilds.d.ts.map +1 -0
- package/dist/internal/guilds.js +785 -0
- package/dist/internal/guilds.js.map +1 -0
- package/dist/internal/init-command.d.ts +54 -0
- package/dist/internal/init-command.d.ts.map +1 -0
- package/dist/internal/init-command.js +248 -0
- package/dist/internal/init-command.js.map +1 -0
- package/dist/internal/instance.d.ts +69 -0
- package/dist/internal/instance.d.ts.map +1 -0
- package/dist/internal/instance.js +455 -0
- package/dist/internal/instance.js.map +1 -0
- package/dist/internal/invalid-callback-return.d.ts +3 -0
- package/dist/internal/invalid-callback-return.d.ts.map +1 -0
- package/dist/internal/invalid-callback-return.js +26 -0
- package/dist/internal/invalid-callback-return.js.map +1 -0
- package/dist/internal/invites.d.ts +19 -0
- package/dist/internal/invites.d.ts.map +1 -0
- package/dist/internal/invites.js +182 -0
- package/dist/internal/invites.js.map +1 -0
- package/dist/internal/logging.d.ts +129 -0
- package/dist/internal/logging.d.ts.map +1 -0
- package/dist/internal/logging.js +868 -0
- package/dist/internal/logging.js.map +1 -0
- package/dist/internal/logical-scheduler.d.ts +27 -0
- package/dist/internal/logical-scheduler.d.ts.map +1 -0
- package/dist/internal/logical-scheduler.js +102 -0
- package/dist/internal/logical-scheduler.js.map +1 -0
- package/dist/internal/masking.d.ts +13 -0
- package/dist/internal/masking.d.ts.map +1 -0
- package/dist/internal/masking.js +235 -0
- package/dist/internal/masking.js.map +1 -0
- package/dist/internal/member-chunks.d.ts +96 -0
- package/dist/internal/member-chunks.d.ts.map +1 -0
- package/dist/internal/member-chunks.js +557 -0
- package/dist/internal/member-chunks.js.map +1 -0
- package/dist/internal/member-search-workflow.d.ts +19 -0
- package/dist/internal/member-search-workflow.d.ts.map +1 -0
- package/dist/internal/member-search-workflow.js +143 -0
- package/dist/internal/member-search-workflow.js.map +1 -0
- package/dist/internal/member-search.d.ts +20 -0
- package/dist/internal/member-search.d.ts.map +1 -0
- package/dist/internal/member-search.js +201 -0
- package/dist/internal/member-search.js.map +1 -0
- package/dist/internal/message-cleanup.d.ts +9 -0
- package/dist/internal/message-cleanup.d.ts.map +1 -0
- package/dist/internal/message-cleanup.js +368 -0
- package/dist/internal/message-cleanup.js.map +1 -0
- package/dist/internal/message-fields.d.ts +9 -0
- package/dist/internal/message-fields.d.ts.map +1 -0
- package/dist/internal/message-fields.js +55 -0
- package/dist/internal/message-fields.js.map +1 -0
- package/dist/internal/message-search-workflow.d.ts +14 -0
- package/dist/internal/message-search-workflow.d.ts.map +1 -0
- package/dist/internal/message-search-workflow.js +101 -0
- package/dist/internal/message-search-workflow.js.map +1 -0
- package/dist/internal/message-search.d.ts +19 -0
- package/dist/internal/message-search.d.ts.map +1 -0
- package/dist/internal/message-search.js +317 -0
- package/dist/internal/message-search.js.map +1 -0
- package/dist/internal/message.d.ts +34 -0
- package/dist/internal/message.d.ts.map +1 -0
- package/dist/internal/message.js +723 -0
- package/dist/internal/message.js.map +1 -0
- package/dist/internal/metrics.d.ts +16 -0
- package/dist/internal/metrics.d.ts.map +1 -0
- package/dist/internal/metrics.js +49 -0
- package/dist/internal/metrics.js.map +1 -0
- package/dist/internal/moderation.d.ts +20 -0
- package/dist/internal/moderation.d.ts.map +1 -0
- package/dist/internal/moderation.js +219 -0
- package/dist/internal/moderation.js.map +1 -0
- package/dist/internal/multipart.d.ts +10 -0
- package/dist/internal/multipart.d.ts.map +1 -0
- package/dist/internal/multipart.js +156 -0
- package/dist/internal/multipart.js.map +1 -0
- package/dist/internal/node-version.d.ts +10 -0
- package/dist/internal/node-version.d.ts.map +1 -0
- package/dist/internal/node-version.js +21 -0
- package/dist/internal/node-version.js.map +1 -0
- package/dist/internal/oauth.d.ts +29 -0
- package/dist/internal/oauth.d.ts.map +1 -0
- package/dist/internal/oauth.js +721 -0
- package/dist/internal/oauth.js.map +1 -0
- package/dist/internal/observer.d.ts +21 -0
- package/dist/internal/observer.d.ts.map +1 -0
- package/dist/internal/observer.js +48 -0
- package/dist/internal/observer.js.map +1 -0
- package/dist/internal/operation-signal.d.ts +9 -0
- package/dist/internal/operation-signal.d.ts.map +1 -0
- package/dist/internal/operation-signal.js +19 -0
- package/dist/internal/operation-signal.js.map +1 -0
- package/dist/internal/pagination.d.ts +67 -0
- package/dist/internal/pagination.d.ts.map +1 -0
- package/dist/internal/pagination.js +306 -0
- package/dist/internal/pagination.js.map +1 -0
- package/dist/internal/permission-requirements.d.ts +34 -0
- package/dist/internal/permission-requirements.d.ts.map +1 -0
- package/dist/internal/permission-requirements.js +204 -0
- package/dist/internal/permission-requirements.js.map +1 -0
- package/dist/internal/permissions.d.ts +28 -0
- package/dist/internal/permissions.d.ts.map +1 -0
- package/dist/internal/permissions.js +314 -0
- package/dist/internal/permissions.js.map +1 -0
- package/dist/internal/pins.d.ts +24 -0
- package/dist/internal/pins.d.ts.map +1 -0
- package/dist/internal/pins.js +83 -0
- package/dist/internal/pins.js.map +1 -0
- package/dist/internal/presence.d.ts +101 -0
- package/dist/internal/presence.d.ts.map +1 -0
- package/dist/internal/presence.js +581 -0
- package/dist/internal/presence.js.map +1 -0
- package/dist/internal/protocol/gateway.d.ts +116 -0
- package/dist/internal/protocol/gateway.d.ts.map +1 -0
- package/dist/internal/protocol/gateway.js +258 -0
- package/dist/internal/protocol/gateway.js.map +1 -0
- package/dist/internal/rate-limit-templates.d.ts +2 -0
- package/dist/internal/rate-limit-templates.d.ts.map +1 -0
- package/dist/internal/rate-limit-templates.js +132 -0
- package/dist/internal/rate-limit-templates.js.map +1 -0
- package/dist/internal/rate-limits.d.ts +32 -0
- package/dist/internal/rate-limits.d.ts.map +1 -0
- package/dist/internal/rate-limits.js +306 -0
- package/dist/internal/rate-limits.js.map +1 -0
- package/dist/internal/reaction-collector.d.ts +39 -0
- package/dist/internal/reaction-collector.d.ts.map +1 -0
- package/dist/internal/reaction-collector.js +441 -0
- package/dist/internal/reaction-collector.js.map +1 -0
- package/dist/internal/reaction-pages.d.ts +18 -0
- package/dist/internal/reaction-pages.d.ts.map +1 -0
- package/dist/internal/reaction-pages.js +213 -0
- package/dist/internal/reaction-pages.js.map +1 -0
- package/dist/internal/reactions.d.ts +30 -0
- package/dist/internal/reactions.d.ts.map +1 -0
- package/dist/internal/reactions.js +160 -0
- package/dist/internal/reactions.js.map +1 -0
- package/dist/internal/rejection-scope.d.ts +25 -0
- package/dist/internal/rejection-scope.d.ts.map +1 -0
- package/dist/internal/rejection-scope.js +103 -0
- package/dist/internal/rejection-scope.js.map +1 -0
- package/dist/internal/response-json.d.ts +12 -0
- package/dist/internal/response-json.d.ts.map +1 -0
- package/dist/internal/response-json.js +74 -0
- package/dist/internal/response-json.js.map +1 -0
- package/dist/internal/rest/admission.d.ts +77 -0
- package/dist/internal/rest/admission.d.ts.map +1 -0
- package/dist/internal/rest/admission.js +178 -0
- package/dist/internal/rest/admission.js.map +1 -0
- package/dist/internal/rest/attempt.d.ts +124 -0
- package/dist/internal/rest/attempt.d.ts.map +1 -0
- package/dist/internal/rest/attempt.js +410 -0
- package/dist/internal/rest/attempt.js.map +1 -0
- package/dist/internal/rest/classify.d.ts +93 -0
- package/dist/internal/rest/classify.d.ts.map +1 -0
- package/dist/internal/rest/classify.js +304 -0
- package/dist/internal/rest/classify.js.map +1 -0
- package/dist/internal/rest/download.d.ts +66 -0
- package/dist/internal/rest/download.d.ts.map +1 -0
- package/dist/internal/rest/download.js +552 -0
- package/dist/internal/rest/download.js.map +1 -0
- package/dist/internal/rest/options.d.ts +42 -0
- package/dist/internal/rest/options.d.ts.map +1 -0
- package/dist/internal/rest/options.js +99 -0
- package/dist/internal/rest/options.js.map +1 -0
- package/dist/internal/rest/owner.d.ts +154 -0
- package/dist/internal/rest/owner.d.ts.map +1 -0
- package/dist/internal/rest/owner.js +1292 -0
- package/dist/internal/rest/owner.js.map +1 -0
- package/dist/internal/rest/request.d.ts +31 -0
- package/dist/internal/rest/request.d.ts.map +1 -0
- package/dist/internal/rest/request.js +227 -0
- package/dist/internal/rest/request.js.map +1 -0
- package/dist/internal/rest.d.ts +10 -0
- package/dist/internal/rest.d.ts.map +1 -0
- package/dist/internal/rest.js +9 -0
- package/dist/internal/rest.js.map +1 -0
- package/dist/internal/retention-age.d.ts +11 -0
- package/dist/internal/retention-age.d.ts.map +1 -0
- package/dist/internal/retention-age.js +29 -0
- package/dist/internal/retention-age.js.map +1 -0
- package/dist/internal/role-hierarchy-workflow.d.ts +15 -0
- package/dist/internal/role-hierarchy-workflow.d.ts.map +1 -0
- package/dist/internal/role-hierarchy-workflow.js +122 -0
- package/dist/internal/role-hierarchy-workflow.js.map +1 -0
- package/dist/internal/role-hierarchy.d.ts +11 -0
- package/dist/internal/role-hierarchy.d.ts.map +1 -0
- package/dist/internal/role-hierarchy.js +87 -0
- package/dist/internal/role-hierarchy.js.map +1 -0
- package/dist/internal/scheduled-tasks.d.ts +46 -0
- package/dist/internal/scheduled-tasks.d.ts.map +1 -0
- package/dist/internal/scheduled-tasks.js +190 -0
- package/dist/internal/scheduled-tasks.js.map +1 -0
- package/dist/internal/sharding.d.ts +62 -0
- package/dist/internal/sharding.d.ts.map +1 -0
- package/dist/internal/sharding.js +205 -0
- package/dist/internal/sharding.js.map +1 -0
- package/dist/internal/starter-project.d.ts +27 -0
- package/dist/internal/starter-project.d.ts.map +1 -0
- package/dist/internal/starter-project.js +224 -0
- package/dist/internal/starter-project.js.map +1 -0
- package/dist/internal/suggest.d.ts +12 -0
- package/dist/internal/suggest.d.ts.map +1 -0
- package/dist/internal/suggest.js +51 -0
- package/dist/internal/suggest.js.map +1 -0
- package/dist/internal/supervisor.d.ts +95 -0
- package/dist/internal/supervisor.d.ts.map +1 -0
- package/dist/internal/supervisor.js +1829 -0
- package/dist/internal/supervisor.js.map +1 -0
- package/dist/internal/testing/discovery.d.ts +24 -0
- package/dist/internal/testing/discovery.d.ts.map +1 -0
- package/dist/internal/testing/discovery.js +22 -0
- package/dist/internal/testing/discovery.js.map +1 -0
- package/dist/internal/testing/errors.d.ts +43 -0
- package/dist/internal/testing/errors.d.ts.map +1 -0
- package/dist/internal/testing/errors.js +63 -0
- package/dist/internal/testing/errors.js.map +1 -0
- package/dist/internal/testing/fixtures.d.ts +477 -0
- package/dist/internal/testing/fixtures.d.ts.map +1 -0
- package/dist/internal/testing/fixtures.js +233 -0
- package/dist/internal/testing/fixtures.js.map +1 -0
- package/dist/internal/testing/gateway.d.ts +51 -0
- package/dist/internal/testing/gateway.d.ts.map +1 -0
- package/dist/internal/testing/gateway.js +265 -0
- package/dist/internal/testing/gateway.js.map +1 -0
- package/dist/internal/testing/harness.d.ts +60 -0
- package/dist/internal/testing/harness.d.ts.map +1 -0
- package/dist/internal/testing/harness.js +280 -0
- package/dist/internal/testing/harness.js.map +1 -0
- package/dist/internal/testing/http.d.ts +31 -0
- package/dist/internal/testing/http.d.ts.map +1 -0
- package/dist/internal/testing/http.js +347 -0
- package/dist/internal/testing/http.js.map +1 -0
- package/dist/internal/testing/types.d.ts +222 -0
- package/dist/internal/testing/types.d.ts.map +1 -0
- package/dist/internal/testing/types.js +2 -0
- package/dist/internal/testing/types.js.map +1 -0
- package/dist/internal/testing/wait.d.ts +16 -0
- package/dist/internal/testing/wait.d.ts.map +1 -0
- package/dist/internal/testing/wait.js +55 -0
- package/dist/internal/testing/wait.js.map +1 -0
- package/dist/internal/thread-events.d.ts +40 -0
- package/dist/internal/thread-events.d.ts.map +1 -0
- package/dist/internal/thread-events.js +121 -0
- package/dist/internal/thread-events.js.map +1 -0
- package/dist/internal/threads.d.ts +47 -0
- package/dist/internal/threads.d.ts.map +1 -0
- package/dist/internal/threads.js +587 -0
- package/dist/internal/threads.js.map +1 -0
- package/dist/internal/transfer-source.d.ts +29 -0
- package/dist/internal/transfer-source.d.ts.map +1 -0
- package/dist/internal/transfer-source.js +347 -0
- package/dist/internal/transfer-source.js.map +1 -0
- package/dist/internal/transport/http.d.ts +12 -0
- package/dist/internal/transport/http.d.ts.map +1 -0
- package/dist/internal/transport/http.js +44 -0
- package/dist/internal/transport/http.js.map +1 -0
- package/dist/internal/transport/index.d.ts +21 -0
- package/dist/internal/transport/index.d.ts.map +1 -0
- package/dist/internal/transport/index.js +15 -0
- package/dist/internal/transport/index.js.map +1 -0
- package/dist/internal/transport/socket.d.ts +51 -0
- package/dist/internal/transport/socket.d.ts.map +1 -0
- package/dist/internal/transport/socket.js +27 -0
- package/dist/internal/transport/socket.js.map +1 -0
- package/dist/internal/transport/user-agent.d.ts +7 -0
- package/dist/internal/transport/user-agent.d.ts.map +1 -0
- package/dist/internal/transport/user-agent.js +42 -0
- package/dist/internal/transport/user-agent.js.map +1 -0
- package/dist/internal/uploads.d.ts +23 -0
- package/dist/internal/uploads.d.ts.map +1 -0
- package/dist/internal/uploads.js +89 -0
- package/dist/internal/uploads.js.map +1 -0
- package/dist/internal/user-cache.d.ts +50 -0
- package/dist/internal/user-cache.d.ts.map +1 -0
- package/dist/internal/user-cache.js +273 -0
- package/dist/internal/user-cache.js.map +1 -0
- package/dist/internal/users.d.ts +41 -0
- package/dist/internal/users.d.ts.map +1 -0
- package/dist/internal/users.js +333 -0
- package/dist/internal/users.js.map +1 -0
- package/dist/internal/vanity-url.d.ts +11 -0
- package/dist/internal/vanity-url.d.ts.map +1 -0
- package/dist/internal/vanity-url.js +58 -0
- package/dist/internal/vanity-url.js.map +1 -0
- package/dist/internal/webhooks.d.ts +58 -0
- package/dist/internal/webhooks.d.ts.map +1 -0
- package/dist/internal/webhooks.js +490 -0
- package/dist/internal/webhooks.js.map +1 -0
- package/dist/invites.d.ts +86 -0
- package/dist/invites.d.ts.map +1 -0
- package/dist/invites.js +2 -0
- package/dist/invites.js.map +1 -0
- package/dist/logging.d.ts +228 -0
- package/dist/logging.d.ts.map +1 -0
- package/dist/logging.js +2 -0
- package/dist/logging.js.map +1 -0
- package/dist/member-chunks.d.ts +145 -0
- package/dist/member-chunks.d.ts.map +1 -0
- package/dist/member-chunks.js +68 -0
- package/dist/member-chunks.js.map +1 -0
- package/dist/member-search.d.ts +140 -0
- package/dist/member-search.d.ts.map +1 -0
- package/dist/member-search.js +14 -0
- package/dist/member-search.js.map +1 -0
- package/dist/message-cleanup.d.ts +227 -0
- package/dist/message-cleanup.d.ts.map +1 -0
- package/dist/message-cleanup.js +101 -0
- package/dist/message-cleanup.js.map +1 -0
- package/dist/message-errors.d.ts +172 -0
- package/dist/message-errors.d.ts.map +1 -0
- package/dist/message-errors.js +173 -0
- package/dist/message-errors.js.map +1 -0
- package/dist/message-search.d.ts +201 -0
- package/dist/message-search.d.ts.map +1 -0
- package/dist/message-search.js +2 -0
- package/dist/message-search.js.map +1 -0
- package/dist/messages.d.ts +694 -0
- package/dist/messages.d.ts.map +1 -0
- package/dist/messages.js +37 -0
- package/dist/messages.js.map +1 -0
- package/dist/native-commands.d.ts +451 -0
- package/dist/native-commands.d.ts.map +1 -0
- package/dist/native-commands.js +432 -0
- package/dist/native-commands.js.map +1 -0
- package/dist/native-supervisor.d.ts +125 -0
- package/dist/native-supervisor.d.ts.map +1 -0
- package/dist/native-supervisor.js +126 -0
- package/dist/native-supervisor.js.map +1 -0
- package/dist/oauth.d.ts +298 -0
- package/dist/oauth.d.ts.map +1 -0
- package/dist/oauth.js +128 -0
- package/dist/oauth.js.map +1 -0
- package/dist/observer.d.ts +111 -0
- package/dist/observer.d.ts.map +1 -0
- package/dist/observer.js +2 -0
- package/dist/observer.js.map +1 -0
- package/dist/pagination.d.ts +117 -0
- package/dist/pagination.d.ts.map +1 -0
- package/dist/pagination.js +61 -0
- package/dist/pagination.js.map +1 -0
- package/dist/permissions.d.ts +73 -0
- package/dist/permissions.d.ts.map +1 -0
- package/dist/permissions.js +2 -0
- package/dist/permissions.js.map +1 -0
- package/dist/pins.d.ts +62 -0
- package/dist/pins.d.ts.map +1 -0
- package/dist/pins.js +2 -0
- package/dist/pins.js.map +1 -0
- package/dist/presence.d.ts +84 -0
- package/dist/presence.d.ts.map +1 -0
- package/dist/presence.js +46 -0
- package/dist/presence.js.map +1 -0
- package/dist/reaction-pages.d.ts +99 -0
- package/dist/reaction-pages.d.ts.map +1 -0
- package/dist/reaction-pages.js +2 -0
- package/dist/reaction-pages.js.map +1 -0
- package/dist/reactions.d.ts +118 -0
- package/dist/reactions.d.ts.map +1 -0
- package/dist/reactions.js +2 -0
- package/dist/reactions.js.map +1 -0
- package/dist/rest.d.ts +260 -0
- package/dist/rest.d.ts.map +1 -0
- package/dist/rest.js +46 -0
- package/dist/rest.js.map +1 -0
- package/dist/role-hierarchy.d.ts +81 -0
- package/dist/role-hierarchy.d.ts.map +1 -0
- package/dist/role-hierarchy.js +53 -0
- package/dist/role-hierarchy.js.map +1 -0
- package/dist/sharding.d.ts +219 -0
- package/dist/sharding.d.ts.map +1 -0
- package/dist/sharding.js +86 -0
- package/dist/sharding.js.map +1 -0
- package/dist/supervisor.d.ts +392 -0
- package/dist/supervisor.d.ts.map +1 -0
- package/dist/supervisor.js +101 -0
- package/dist/supervisor.js.map +1 -0
- package/dist/testing.d.ts +258 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +202 -0
- package/dist/testing.js.map +1 -0
- package/dist/text.d.ts +38 -0
- package/dist/text.d.ts.map +1 -0
- package/dist/text.js +46 -0
- package/dist/text.js.map +1 -0
- package/dist/threads.d.ts +258 -0
- package/dist/threads.d.ts.map +1 -0
- package/dist/threads.js +2 -0
- package/dist/threads.js.map +1 -0
- package/dist/users.d.ts +204 -0
- package/dist/users.d.ts.map +1 -0
- package/dist/users.js +44 -0
- package/dist/users.js.map +1 -0
- package/dist/webhooks.d.ts +423 -0
- package/dist/webhooks.d.ts.map +1 -0
- package/dist/webhooks.js +68 -0
- package/dist/webhooks.js.map +1 -0
- package/esm-only.cjs +3 -0
- package/examples/starter/bot-effect.ts +17 -0
- package/examples/starter/bot.js +13 -0
- package/examples/starter/bot.ts +13 -0
- package/package.json +82 -0
- package/src/api/default/application.ts +40 -0
- package/src/api/default/attachments.ts +106 -0
- package/src/api/default/audit-logs.ts +58 -0
- package/src/api/default/bot.ts +586 -0
- package/src/api/default/cache.ts +106 -0
- package/src/api/default/channels.ts +317 -0
- package/src/api/default/client.ts +829 -0
- package/src/api/default/collectors.ts +81 -0
- package/src/api/default/commands.ts +92 -0
- package/src/api/default/direct-messages.ts +143 -0
- package/src/api/default/discovery.ts +103 -0
- package/src/api/default/emojis.ts +125 -0
- package/src/api/default/events.ts +144 -0
- package/src/api/default/gateway.ts +67 -0
- package/src/api/default/guards.ts +173 -0
- package/src/api/default/guilds.ts +271 -0
- package/src/api/default/helpers.ts +97 -0
- package/src/api/default/instance.ts +49 -0
- package/src/api/default/invites.ts +73 -0
- package/src/api/default/logging.ts +37 -0
- package/src/api/default/members.ts +550 -0
- package/src/api/default/messages.ts +1053 -0
- package/src/api/default/oauth.ts +293 -0
- package/src/api/default/permissions.ts +47 -0
- package/src/api/default/presence.ts +88 -0
- package/src/api/default/rest.ts +30 -0
- package/src/api/default/results.ts +44 -0
- package/src/api/default/roles.ts +154 -0
- package/src/api/default/stickers.ts +129 -0
- package/src/api/default/supervisor.ts +53 -0
- package/src/api/default/threads.ts +233 -0
- package/src/api/default/users.ts +82 -0
- package/src/api/default/webhook-client.ts +266 -0
- package/src/api/default/webhooks.ts +89 -0
- package/src/api/effect/application.ts +29 -0
- package/src/api/effect/attachments.ts +100 -0
- package/src/api/effect/audit-logs.ts +50 -0
- package/src/api/effect/bot.ts +546 -0
- package/src/api/effect/cache.ts +110 -0
- package/src/api/effect/channels.ts +293 -0
- package/src/api/effect/client.ts +792 -0
- package/src/api/effect/collectors.ts +103 -0
- package/src/api/effect/commands.ts +87 -0
- package/src/api/effect/direct-messages.ts +119 -0
- package/src/api/effect/discovery.ts +87 -0
- package/src/api/effect/emojis.ts +108 -0
- package/src/api/effect/events.ts +92 -0
- package/src/api/effect/failures.ts +14 -0
- package/src/api/effect/gateway.ts +63 -0
- package/src/api/effect/guards.ts +194 -0
- package/src/api/effect/guilds.ts +247 -0
- package/src/api/effect/helpers.ts +359 -0
- package/src/api/effect/hierarchy.ts +26 -0
- package/src/api/effect/instance.ts +50 -0
- package/src/api/effect/invites.ts +59 -0
- package/src/api/effect/logging.ts +37 -0
- package/src/api/effect/members.ts +521 -0
- package/src/api/effect/messages.ts +1003 -0
- package/src/api/effect/oauth.ts +208 -0
- package/src/api/effect/permissions.ts +44 -0
- package/src/api/effect/presence.ts +83 -0
- package/src/api/effect/rest.ts +27 -0
- package/src/api/effect/roles.ts +136 -0
- package/src/api/effect/service.ts +104 -0
- package/src/api/effect/stickers.ts +112 -0
- package/src/api/effect/supervisor.ts +58 -0
- package/src/api/effect/threads.ts +221 -0
- package/src/api/effect/users.ts +66 -0
- package/src/api/effect/webhook-client.ts +206 -0
- package/src/api/effect/webhooks.ts +75 -0
- package/src/api-errors.ts +985 -0
- package/src/application.ts +103 -0
- package/src/assets.ts +731 -0
- package/src/attachments.ts +469 -0
- package/src/audit-logs.ts +355 -0
- package/src/bot-runner.ts +91 -0
- package/src/builders.ts +390 -0
- package/src/cache.ts +190 -0
- package/src/channels.ts +1051 -0
- package/src/cli.ts +60 -0
- package/src/client.ts +663 -0
- package/src/collectors.ts +248 -0
- package/src/colors.ts +91 -0
- package/src/command-arguments.ts +432 -0
- package/src/command-help.ts +55 -0
- package/src/commands.ts +403 -0
- package/src/counts.ts +160 -0
- package/src/default-commands.ts +1147 -0
- package/src/default-supervisor.ts +484 -0
- package/src/discovery.ts +241 -0
- package/src/effect-testing.ts +603 -0
- package/src/effect.ts +751 -0
- package/src/embeds.ts +253 -0
- package/src/error-tools.ts +191 -0
- package/src/errors.ts +849 -0
- package/src/events.ts +830 -0
- package/src/expressions.ts +198 -0
- package/src/failures.ts +55 -0
- package/src/gateway.ts +86 -0
- package/src/guilds.ts +1108 -0
- package/src/helpers.ts +836 -0
- package/src/index.ts +796 -0
- package/src/input-validation.ts +94 -0
- package/src/instance.ts +111 -0
- package/src/internal/agents-section.ts +114 -0
- package/src/internal/application.ts +51 -0
- package/src/internal/attachment-refresh.ts +57 -0
- package/src/internal/attachments.ts +313 -0
- package/src/internal/audit-logs.ts +336 -0
- package/src/internal/audit.ts +33 -0
- package/src/internal/binding/default-adapters.ts +482 -0
- package/src/internal/binding/default.ts +155 -0
- package/src/internal/binding/execute.ts +221 -0
- package/src/internal/binding/native-adapters.ts +199 -0
- package/src/internal/binding/native.ts +72 -0
- package/src/internal/binding/operations.ts +1171 -0
- package/src/internal/bot-runner.ts +480 -0
- package/src/internal/cache-changes.ts +363 -0
- package/src/internal/cache.ts +323 -0
- package/src/internal/calls.ts +119 -0
- package/src/internal/channel-cache.ts +435 -0
- package/src/internal/channel-decode.ts +399 -0
- package/src/internal/channels.ts +874 -0
- package/src/internal/client/backoff.ts +69 -0
- package/src/internal/client/configuration-fields.ts +18 -0
- package/src/internal/client/drain.ts +150 -0
- package/src/internal/client/intake.ts +228 -0
- package/src/internal/client/lifetime.ts +165 -0
- package/src/internal/client/shard-loop.ts +586 -0
- package/src/internal/client-registry.ts +35 -0
- package/src/internal/client.ts +2448 -0
- package/src/internal/clock.ts +11 -0
- package/src/internal/code-catalogue.ts +739 -0
- package/src/internal/collector.ts +452 -0
- package/src/internal/command-arguments.ts +585 -0
- package/src/internal/command-guards.ts +96 -0
- package/src/internal/command-help.ts +156 -0
- package/src/internal/commands.ts +1319 -0
- package/src/internal/configuration.ts +529 -0
- package/src/internal/counts.ts +471 -0
- package/src/internal/decode/primitives.ts +67 -0
- package/src/internal/decode/timestamp.ts +29 -0
- package/src/internal/decode/trace.ts +65 -0
- package/src/internal/defects.ts +115 -0
- package/src/internal/effect-failures.ts +65 -0
- package/src/internal/embeds.ts +355 -0
- package/src/internal/events.ts +1345 -0
- package/src/internal/expiry-queue.ts +148 -0
- package/src/internal/expressions.ts +415 -0
- package/src/internal/failures.ts +492 -0
- package/src/internal/field-text.ts +40 -0
- package/src/internal/gateway/commands.ts +328 -0
- package/src/internal/gateway/dispatch-table.ts +383 -0
- package/src/internal/gateway/event-dispatches.ts +201 -0
- package/src/internal/gateway/frames.ts +176 -0
- package/src/internal/gateway/options.ts +144 -0
- package/src/internal/gateway/session.ts +625 -0
- package/src/internal/gateway-requests.ts +26 -0
- package/src/internal/gateway.ts +22 -0
- package/src/internal/guild-cache.ts +424 -0
- package/src/internal/guild-discovery.ts +332 -0
- package/src/internal/guild-lifecycle.ts +128 -0
- package/src/internal/guild-settings.ts +209 -0
- package/src/internal/guilds.ts +949 -0
- package/src/internal/init-command.ts +305 -0
- package/src/internal/instance.ts +645 -0
- package/src/internal/invalid-callback-return.ts +28 -0
- package/src/internal/invites.ts +234 -0
- package/src/internal/logging.ts +1007 -0
- package/src/internal/logical-scheduler.ts +139 -0
- package/src/internal/masking.ts +224 -0
- package/src/internal/member-chunks.ts +649 -0
- package/src/internal/member-search-workflow.ts +237 -0
- package/src/internal/member-search.ts +272 -0
- package/src/internal/message-cleanup.ts +515 -0
- package/src/internal/message-fields.ts +71 -0
- package/src/internal/message-search-workflow.ts +166 -0
- package/src/internal/message-search.ts +476 -0
- package/src/internal/message.ts +879 -0
- package/src/internal/metrics.ts +55 -0
- package/src/internal/moderation.ts +288 -0
- package/src/internal/multipart.ts +171 -0
- package/src/internal/node-version.ts +22 -0
- package/src/internal/oauth.ts +1146 -0
- package/src/internal/observer.ts +62 -0
- package/src/internal/operation-signal.ts +26 -0
- package/src/internal/pagination.ts +494 -0
- package/src/internal/permission-requirements.ts +359 -0
- package/src/internal/permissions.ts +417 -0
- package/src/internal/pins.ts +115 -0
- package/src/internal/presence.ts +745 -0
- package/src/internal/protocol/gateway.ts +299 -0
- package/src/internal/rate-limit-templates.ts +138 -0
- package/src/internal/rate-limits.ts +346 -0
- package/src/internal/reaction-collector.ts +499 -0
- package/src/internal/reaction-pages.ts +260 -0
- package/src/internal/reactions.ts +174 -0
- package/src/internal/rejection-scope.ts +119 -0
- package/src/internal/response-json.ts +76 -0
- package/src/internal/rest/admission.ts +210 -0
- package/src/internal/rest/attempt.ts +617 -0
- package/src/internal/rest/classify.ts +391 -0
- package/src/internal/rest/download.ts +658 -0
- package/src/internal/rest/options.ts +145 -0
- package/src/internal/rest/owner.ts +1828 -0
- package/src/internal/rest/request.ts +289 -0
- package/src/internal/rest.ts +9 -0
- package/src/internal/retention-age.ts +33 -0
- package/src/internal/role-hierarchy-workflow.ts +150 -0
- package/src/internal/role-hierarchy.ts +93 -0
- package/src/internal/scheduled-tasks.ts +217 -0
- package/src/internal/sharding.ts +270 -0
- package/src/internal/starter-project.ts +251 -0
- package/src/internal/suggest.ts +50 -0
- package/src/internal/supervisor.ts +2253 -0
- package/src/internal/testing/discovery.ts +23 -0
- package/src/internal/testing/errors.ts +67 -0
- package/src/internal/testing/fixtures.ts +714 -0
- package/src/internal/testing/gateway.ts +305 -0
- package/src/internal/testing/harness.ts +328 -0
- package/src/internal/testing/http.ts +395 -0
- package/src/internal/testing/types.ts +240 -0
- package/src/internal/testing/wait.ts +63 -0
- package/src/internal/thread-events.ts +128 -0
- package/src/internal/threads.ts +718 -0
- package/src/internal/transfer-source.ts +359 -0
- package/src/internal/transport/http.ts +46 -0
- package/src/internal/transport/index.ts +23 -0
- package/src/internal/transport/socket.ts +71 -0
- package/src/internal/transport/user-agent.ts +46 -0
- package/src/internal/uploads.ts +111 -0
- package/src/internal/user-cache.ts +294 -0
- package/src/internal/users.ts +402 -0
- package/src/internal/vanity-url.ts +80 -0
- package/src/internal/webhooks.ts +690 -0
- package/src/invites.ts +87 -0
- package/src/logging.ts +247 -0
- package/src/member-chunks.ts +195 -0
- package/src/member-search.ts +152 -0
- package/src/message-cleanup.ts +308 -0
- package/src/message-errors.ts +245 -0
- package/src/message-search.ts +213 -0
- package/src/messages.ts +768 -0
- package/src/native-commands.ts +1249 -0
- package/src/native-supervisor.ts +345 -0
- package/src/oauth.ts +413 -0
- package/src/observer.ts +118 -0
- package/src/pagination.ts +172 -0
- package/src/permissions.ts +74 -0
- package/src/pins.ts +65 -0
- package/src/presence.ts +124 -0
- package/src/reaction-pages.ts +106 -0
- package/src/reactions.ts +126 -0
- package/src/rest.ts +282 -0
- package/src/role-hierarchy.ts +127 -0
- package/src/sharding.ts +272 -0
- package/src/supervisor.ts +460 -0
- package/src/testing.ts +424 -0
- package/src/text.ts +76 -0
- package/src/threads.ts +274 -0
- package/src/users.ts +237 -0
- package/src/webhooks.ts +512 -0
|
@@ -0,0 +1,1146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OAuth client operations: Authorization URLs, code exchange, refresh, revocation, introspection and authorized reads.
|
|
3
|
+
* Invariant: Consent, storage and refresh coordination stay application-owned, credentials never appear in errors or logs, and
|
|
4
|
+
* every request goes through the HTTP transport seam. Implements [SDK contracts: Results and failures](/docs/SDK-CONTRACTS.md#results-and-failures)
|
|
5
|
+
*/
|
|
6
|
+
import * as Clock from "effect/Clock"
|
|
7
|
+
import * as Deferred from "effect/Deferred"
|
|
8
|
+
import * as Effect from "effect/Effect"
|
|
9
|
+
import * as Scope from "effect/Scope"
|
|
10
|
+
import type {
|
|
11
|
+
OAuthAuthorizationInput,
|
|
12
|
+
OAuthCodeExchangeInput,
|
|
13
|
+
OAuthConfig,
|
|
14
|
+
OAuthConnection,
|
|
15
|
+
OAuthIdentity,
|
|
16
|
+
OAuthIntrospection,
|
|
17
|
+
OAuthOperation,
|
|
18
|
+
OAuthOperationError,
|
|
19
|
+
OAuthOperationOptions,
|
|
20
|
+
OAuthTokens,
|
|
21
|
+
} from "#sdk/oauth"
|
|
22
|
+
import { OAuthOperationError as OAuthError, oauthCredential } from "#sdk/oauth"
|
|
23
|
+
import { loggingConfiguration, type ClientLogger } from "#sdk/internal/logging"
|
|
24
|
+
import type * as Context from "effect/Context"
|
|
25
|
+
import { apiErrorDetail, unrecognizedProviderCode } from "#sdk/api-errors"
|
|
26
|
+
import { ClientClosedError, ConfigurationError, RateLimitError } from "#sdk/errors"
|
|
27
|
+
import { mapFailureCause, TransportError, withDeadline } from "#sdk/internal/effect-failures"
|
|
28
|
+
import { nowMs } from "#sdk/internal/clock"
|
|
29
|
+
import { defaultHttpTransport, type HttpTransport } from "#sdk/internal/transport/index"
|
|
30
|
+
import { InstanceResolver, instanceConfiguration } from "#sdk/internal/instance"
|
|
31
|
+
import { guildList } from "#sdk/internal/guild-lifecycle"
|
|
32
|
+
import { identifier, record } from "#sdk/internal/decode/primitives"
|
|
33
|
+
import { readCaller, suspendInput, suspendMarked } from "#sdk/internal/defects"
|
|
34
|
+
import type { GuildListQuery, GuildListSummary } from "#sdk/guilds"
|
|
35
|
+
import {
|
|
36
|
+
InputValidationFailure,
|
|
37
|
+
inputValidationFailure,
|
|
38
|
+
unsupportedKeyFailure,
|
|
39
|
+
type InputValidationConstraint,
|
|
40
|
+
} from "#sdk/input-validation"
|
|
41
|
+
|
|
42
|
+
const maximumResponseBytes = 1_048_576
|
|
43
|
+
const maximumConcurrentRequests = 8
|
|
44
|
+
const defaultTimeoutMs = 30_000
|
|
45
|
+
const maximumPermissionBits = (1n << 64n) - 1n
|
|
46
|
+
const maximumInt32 = 2_147_483_647
|
|
47
|
+
|
|
48
|
+
function text(value: unknown): value is string {
|
|
49
|
+
return typeof value === "string" && value.length > 0
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Fluxer OAuth form/query strings use createStringType(1), capped at 256 UTF-16 units.
|
|
53
|
+
// Reject normalization changes rather than changing opaque state, credentials or redirects
|
|
54
|
+
function canonicalText(value: unknown): value is string {
|
|
55
|
+
return (
|
|
56
|
+
text(value) &&
|
|
57
|
+
value.length <= 256 &&
|
|
58
|
+
value.isWellFormed() &&
|
|
59
|
+
// oxlint-disable-next-line no-control-regex -- the provider strips form feed before validating text
|
|
60
|
+
value === value.replace(/[\u000c\u202e]/g, "").trim()
|
|
61
|
+
)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const oauthScopeInputCapacity = 256
|
|
65
|
+
|
|
66
|
+
function redirectUri(value: unknown): value is string {
|
|
67
|
+
if (!canonicalText(value)) return false
|
|
68
|
+
try {
|
|
69
|
+
const url = new URL(value)
|
|
70
|
+
const loopback =
|
|
71
|
+
url.hostname === "localhost" ||
|
|
72
|
+
url.hostname === "127.0.0.1" ||
|
|
73
|
+
url.hostname === "[::1]" ||
|
|
74
|
+
url.hostname.endsWith(".localhost")
|
|
75
|
+
return (
|
|
76
|
+
!url.username &&
|
|
77
|
+
!url.password &&
|
|
78
|
+
!url.hash &&
|
|
79
|
+
(url.protocol === "https:" || (url.protocol === "http:" && loopback))
|
|
80
|
+
)
|
|
81
|
+
} catch {
|
|
82
|
+
return false
|
|
83
|
+
// allow-silent: An unparsable redirect URI is rejected as invalid input
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function timeout(value: unknown): number | undefined {
|
|
88
|
+
return value === undefined ||
|
|
89
|
+
(typeof value === "number" && Number.isSafeInteger(value) && value > 0 && value <= 2_147_483_647)
|
|
90
|
+
? value
|
|
91
|
+
: undefined
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function retryAfter(response: Response): number | null {
|
|
95
|
+
const value = response.headers.get("retry-after")
|
|
96
|
+
const milliseconds = value === null ? NaN : Number(value) * 1_000
|
|
97
|
+
return Number.isFinite(milliseconds) && milliseconds >= 0 ? Math.ceil(milliseconds) : null
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function token(value: unknown): OAuthTokens | undefined {
|
|
101
|
+
if (
|
|
102
|
+
!record(value) ||
|
|
103
|
+
!text(value.access_token) ||
|
|
104
|
+
!text(value.refresh_token) ||
|
|
105
|
+
value.token_type !== "Bearer" ||
|
|
106
|
+
!text(value.scope)
|
|
107
|
+
)
|
|
108
|
+
return undefined
|
|
109
|
+
if (typeof value.expires_in !== "number" || !Number.isSafeInteger(value.expires_in) || value.expires_in < 0)
|
|
110
|
+
return undefined
|
|
111
|
+
return Object.freeze({
|
|
112
|
+
accessToken: value.access_token,
|
|
113
|
+
refreshToken: value.refresh_token,
|
|
114
|
+
tokenType: "Bearer",
|
|
115
|
+
expiresInSeconds: value.expires_in,
|
|
116
|
+
scopes: Object.freeze(value.scope.split(/[\s+]+/).filter(Boolean)),
|
|
117
|
+
})
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function identity(value: unknown): OAuthIdentity | undefined {
|
|
121
|
+
if (!record(value) || !identifier(value.id) || !text(value.username) || typeof value.discriminator !== "string")
|
|
122
|
+
return undefined
|
|
123
|
+
if (
|
|
124
|
+
(value.global_name !== null && typeof value.global_name !== "string") ||
|
|
125
|
+
(value.avatar !== null && typeof value.avatar !== "string")
|
|
126
|
+
)
|
|
127
|
+
return undefined
|
|
128
|
+
if (value.email !== undefined && value.email !== null && typeof value.email !== "string") return undefined
|
|
129
|
+
if (value.verified !== undefined && value.verified !== null && typeof value.verified !== "boolean") return undefined
|
|
130
|
+
return Object.freeze({
|
|
131
|
+
id: value.id,
|
|
132
|
+
username: value.username,
|
|
133
|
+
discriminator: value.discriminator,
|
|
134
|
+
displayName: value.global_name,
|
|
135
|
+
avatar: value.avatar,
|
|
136
|
+
...(value.email === undefined ? {} : { email: value.email }),
|
|
137
|
+
...(value.verified === undefined ? {} : { verified: value.verified }),
|
|
138
|
+
})
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function connections(value: unknown): readonly OAuthConnection[] | undefined {
|
|
142
|
+
if (!Array.isArray(value)) return undefined
|
|
143
|
+
const result: OAuthConnection[] = []
|
|
144
|
+
for (const item of value) {
|
|
145
|
+
if (
|
|
146
|
+
!record(item) ||
|
|
147
|
+
typeof item.id !== "string" ||
|
|
148
|
+
(item.type !== "bsky" && item.type !== "domain") ||
|
|
149
|
+
typeof item.name !== "string" ||
|
|
150
|
+
typeof item.verified !== "boolean" ||
|
|
151
|
+
typeof item.visibility_flags !== "number" ||
|
|
152
|
+
!Number.isSafeInteger(item.visibility_flags) ||
|
|
153
|
+
item.visibility_flags < 0 ||
|
|
154
|
+
item.visibility_flags > maximumInt32 ||
|
|
155
|
+
typeof item.sort_order !== "number" ||
|
|
156
|
+
!Number.isSafeInteger(item.sort_order) ||
|
|
157
|
+
item.sort_order < 0 ||
|
|
158
|
+
item.sort_order > maximumInt32
|
|
159
|
+
)
|
|
160
|
+
return undefined
|
|
161
|
+
result.push(
|
|
162
|
+
Object.freeze({
|
|
163
|
+
id: item.id,
|
|
164
|
+
type: item.type,
|
|
165
|
+
name: item.name,
|
|
166
|
+
verified: item.verified,
|
|
167
|
+
visibilityFlags: item.visibility_flags,
|
|
168
|
+
sortOrder: item.sort_order,
|
|
169
|
+
}),
|
|
170
|
+
)
|
|
171
|
+
}
|
|
172
|
+
return Object.freeze(result)
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function introspection(value: unknown): OAuthIntrospection | undefined {
|
|
176
|
+
if (!record(value) || typeof value.active !== "boolean") return undefined
|
|
177
|
+
if (!value.active) return Object.freeze({ active: false })
|
|
178
|
+
if (
|
|
179
|
+
!identifier(value.client_id) ||
|
|
180
|
+
(value.sub !== undefined && !identifier(value.sub)) ||
|
|
181
|
+
typeof value.scope !== "string" ||
|
|
182
|
+
(value.token_type !== "Bearer" && value.token_type !== "refresh_token") ||
|
|
183
|
+
typeof value.iat !== "number" ||
|
|
184
|
+
!Number.isSafeInteger(value.iat) ||
|
|
185
|
+
value.iat < 0 ||
|
|
186
|
+
(value.exp !== undefined &&
|
|
187
|
+
(typeof value.exp !== "number" || !Number.isSafeInteger(value.exp) || value.exp < 0))
|
|
188
|
+
)
|
|
189
|
+
return undefined
|
|
190
|
+
return Object.freeze({
|
|
191
|
+
active: true,
|
|
192
|
+
clientId: value.client_id,
|
|
193
|
+
...(value.sub === undefined ? {} : { subjectId: value.sub }),
|
|
194
|
+
tokenType: value.token_type,
|
|
195
|
+
scopes: Object.freeze(value.scope.split(/[\s+]+/).filter(Boolean)),
|
|
196
|
+
issuedAtUnixSeconds: value.iat,
|
|
197
|
+
...(value.exp === undefined ? {} : { expiresAtUnixSeconds: value.exp }),
|
|
198
|
+
})
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/** The input failure for an unsupported key in an OAuth input object */
|
|
202
|
+
function unsupportedInput(operation: OAuthOperation, failure: InputValidationFailure): OAuthOperationError {
|
|
203
|
+
return new OAuthError({ operation, reason: "input", outcome: "notDispatched", inputValidation: failure.detail })
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function inputError(
|
|
207
|
+
operation: OAuthOperation,
|
|
208
|
+
path: string,
|
|
209
|
+
constraint: InputValidationConstraint,
|
|
210
|
+
explanation: string,
|
|
211
|
+
): OAuthOperationError {
|
|
212
|
+
return new OAuthError({
|
|
213
|
+
operation,
|
|
214
|
+
reason: "input",
|
|
215
|
+
outcome: "notDispatched",
|
|
216
|
+
inputValidation: inputValidationFailure(path, constraint, explanation).detail,
|
|
217
|
+
})
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function responseError(operation: OAuthOperation, status: number): OAuthOperationError {
|
|
221
|
+
const mutation = operation === "oauth.exchangeCode" || operation === "oauth.refresh" || operation === "oauth.revoke"
|
|
222
|
+
return new OAuthError({ operation, reason: "response", outcome: mutation ? "unknown" : "rejected", status })
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
function operationError(
|
|
226
|
+
operation: OAuthOperation,
|
|
227
|
+
response: Response | undefined,
|
|
228
|
+
cause: "notDispatched" | "unknown",
|
|
229
|
+
details: { readonly body?: unknown; readonly cause?: unknown } = {},
|
|
230
|
+
): OAuthOperationError {
|
|
231
|
+
const { body, cause: networkCause } = details
|
|
232
|
+
const apiError = apiErrorDetail(body)
|
|
233
|
+
const providerCode = unrecognizedProviderCode(body)
|
|
234
|
+
const oauthError =
|
|
235
|
+
record(body) &&
|
|
236
|
+
typeof body.error === "string" &&
|
|
237
|
+
[
|
|
238
|
+
"invalid_grant",
|
|
239
|
+
"invalid_client",
|
|
240
|
+
"invalid_request",
|
|
241
|
+
"invalid_scope",
|
|
242
|
+
"unauthorized_client",
|
|
243
|
+
"unsupported_grant_type",
|
|
244
|
+
].includes(body.error)
|
|
245
|
+
? body.error
|
|
246
|
+
: null
|
|
247
|
+
if (!response)
|
|
248
|
+
return new OAuthError({ operation, reason: "network", outcome: cause, cause: new TransportError(networkCause) })
|
|
249
|
+
if (response.status === 429)
|
|
250
|
+
return new OAuthError({
|
|
251
|
+
operation,
|
|
252
|
+
reason: "rateLimit",
|
|
253
|
+
outcome: "rejected",
|
|
254
|
+
status: response.status,
|
|
255
|
+
retryAfterMs: retryAfter(response),
|
|
256
|
+
oauthError,
|
|
257
|
+
apiError,
|
|
258
|
+
providerCode,
|
|
259
|
+
})
|
|
260
|
+
const mutation = operation === "oauth.exchangeCode" || operation === "oauth.refresh" || operation === "oauth.revoke"
|
|
261
|
+
return new OAuthError({
|
|
262
|
+
operation,
|
|
263
|
+
reason: "rejected",
|
|
264
|
+
outcome: mutation && response.status >= 500 ? "unknown" : "rejected",
|
|
265
|
+
status: response.status,
|
|
266
|
+
oauthError,
|
|
267
|
+
apiError,
|
|
268
|
+
providerCode,
|
|
269
|
+
})
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
async function body(
|
|
273
|
+
response: Response,
|
|
274
|
+
state: { reader: ReadableStreamDefaultReader<Uint8Array> | undefined; done: boolean },
|
|
275
|
+
): Promise<Uint8Array> {
|
|
276
|
+
const reader = response.body?.getReader()
|
|
277
|
+
if (!reader) throw new Error("missing response body")
|
|
278
|
+
state.reader = reader
|
|
279
|
+
const chunks: Uint8Array[] = []
|
|
280
|
+
let length = 0
|
|
281
|
+
for (;;) {
|
|
282
|
+
const item = await reader.read()
|
|
283
|
+
if (item.done) {
|
|
284
|
+
state.done = true
|
|
285
|
+
break
|
|
286
|
+
}
|
|
287
|
+
length += item.value.byteLength
|
|
288
|
+
if (length > maximumResponseBytes) throw new Error("response too large")
|
|
289
|
+
chunks.push(item.value)
|
|
290
|
+
}
|
|
291
|
+
const bytes = new Uint8Array(length)
|
|
292
|
+
let offset = 0
|
|
293
|
+
for (const chunk of chunks) {
|
|
294
|
+
bytes.set(chunk, offset)
|
|
295
|
+
offset += chunk.byteLength
|
|
296
|
+
}
|
|
297
|
+
return bytes
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
async function json(
|
|
301
|
+
response: Response,
|
|
302
|
+
state: { reader: ReadableStreamDefaultReader<Uint8Array> | undefined; done: boolean },
|
|
303
|
+
): Promise<unknown> {
|
|
304
|
+
return JSON.parse(new TextDecoder().decode(await body(response, state)))
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
export class OAuthOwner {
|
|
308
|
+
#closed = false
|
|
309
|
+
#active = 0
|
|
310
|
+
#secret: string | undefined
|
|
311
|
+
readonly #controllers = new Set<AbortController>()
|
|
312
|
+
readonly #operations = new Set<Deferred.Deferred<void>>()
|
|
313
|
+
readonly #http: HttpTransport
|
|
314
|
+
readonly instance: InstanceResolver
|
|
315
|
+
|
|
316
|
+
constructor(
|
|
317
|
+
readonly clientId: string,
|
|
318
|
+
secret: string,
|
|
319
|
+
configuration: ReturnType<typeof instanceConfiguration>,
|
|
320
|
+
scope: Scope.Scope,
|
|
321
|
+
readonly logging: ClientLogger,
|
|
322
|
+
http: HttpTransport = defaultHttpTransport,
|
|
323
|
+
) {
|
|
324
|
+
this.#secret = secret
|
|
325
|
+
this.#http = http
|
|
326
|
+
this.instance = new InstanceResolver(
|
|
327
|
+
configuration as Exclude<typeof configuration, ConfigurationError>,
|
|
328
|
+
scope,
|
|
329
|
+
{
|
|
330
|
+
http,
|
|
331
|
+
},
|
|
332
|
+
)
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
shutdown(): Effect.Effect<void> {
|
|
336
|
+
return Effect.uninterruptible(
|
|
337
|
+
Effect.suspend(() => {
|
|
338
|
+
this.#closed = true
|
|
339
|
+
this.#secret = undefined
|
|
340
|
+
for (const controller of this.#controllers) controller.abort()
|
|
341
|
+
const operations = [...this.#operations]
|
|
342
|
+
return Effect.all(
|
|
343
|
+
[
|
|
344
|
+
this.instance.shutdown(),
|
|
345
|
+
Effect.forEach(operations, (operation) => Deferred.await(operation), {
|
|
346
|
+
discard: true,
|
|
347
|
+
concurrency: "unbounded",
|
|
348
|
+
}),
|
|
349
|
+
],
|
|
350
|
+
{ concurrency: "unbounded", discard: true },
|
|
351
|
+
).pipe(
|
|
352
|
+
Effect.ensuring(Effect.withFiber((fiber) => Effect.sync(() => this.logging.flush(fiber.context)))),
|
|
353
|
+
)
|
|
354
|
+
}),
|
|
355
|
+
)
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* Log a rejected client ID and secret once per operation and code, even when the application handles the failure,
|
|
360
|
+
* because it persists until someone changes the configuration. A rejected user access token concerns one user, so
|
|
361
|
+
* it is only returned
|
|
362
|
+
*/
|
|
363
|
+
#logRejection(error: unknown, context: Context.Context<never>) {
|
|
364
|
+
if (
|
|
365
|
+
!(error instanceof OAuthError) ||
|
|
366
|
+
error.reason !== "rejected" ||
|
|
367
|
+
!(error.status === 401 || error.status === 403 || error.oauthError === "invalid_client") ||
|
|
368
|
+
oauthCredential(error.operation, error.oauthError) !== "oauthClient"
|
|
369
|
+
)
|
|
370
|
+
return
|
|
371
|
+
this.logging.log(
|
|
372
|
+
{
|
|
373
|
+
level: "warn",
|
|
374
|
+
category: "rest",
|
|
375
|
+
code: "rest.rejected",
|
|
376
|
+
message: error.message,
|
|
377
|
+
...(error.status === null ? {} : { status: error.status }),
|
|
378
|
+
fields: {
|
|
379
|
+
operation: error.operation,
|
|
380
|
+
oauthError: error.oauthError ?? undefined,
|
|
381
|
+
apiError: error.apiError?.providerCode,
|
|
382
|
+
hint: error.hint,
|
|
383
|
+
},
|
|
384
|
+
},
|
|
385
|
+
context,
|
|
386
|
+
)
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
#run<A>(
|
|
390
|
+
operation: OAuthOperation,
|
|
391
|
+
options: OAuthOperationOptions | undefined,
|
|
392
|
+
task: (
|
|
393
|
+
api: string,
|
|
394
|
+
webapp: string,
|
|
395
|
+
secret: string,
|
|
396
|
+
progress: { knownResponseFailure: OAuthOperationError | undefined },
|
|
397
|
+
) => Effect.Effect<A, OAuthOperationError>,
|
|
398
|
+
): Effect.Effect<A, OAuthOperationError | ClientClosedError> {
|
|
399
|
+
return Clock.clockWith((clock) =>
|
|
400
|
+
suspendMarked<A, OAuthOperationError | ClientClosedError, never>(() => {
|
|
401
|
+
// Only reading the caller options is marked, so a throw from their getters is an application fault
|
|
402
|
+
const limit = readCaller(() => {
|
|
403
|
+
if (
|
|
404
|
+
options !== undefined &&
|
|
405
|
+
(typeof options !== "object" || options === null || Array.isArray(options))
|
|
406
|
+
)
|
|
407
|
+
return "invalid"
|
|
408
|
+
const unsupported =
|
|
409
|
+
options === undefined
|
|
410
|
+
? undefined
|
|
411
|
+
: unsupportedKeyFailure(options, ["timeoutMs"], "options", "the OAuth operation options")
|
|
412
|
+
if (unsupported) return unsupported
|
|
413
|
+
const timeoutMs = options?.timeoutMs
|
|
414
|
+
const limit = timeout(timeoutMs)
|
|
415
|
+
return timeoutMs !== undefined && limit === undefined ? "invalid" : limit
|
|
416
|
+
})
|
|
417
|
+
if (limit instanceof InputValidationFailure)
|
|
418
|
+
return Effect.fail(
|
|
419
|
+
new OAuthError({
|
|
420
|
+
operation,
|
|
421
|
+
reason: "input",
|
|
422
|
+
outcome: "notDispatched",
|
|
423
|
+
inputValidation: limit.detail,
|
|
424
|
+
}),
|
|
425
|
+
)
|
|
426
|
+
if (limit === "invalid")
|
|
427
|
+
return Effect.fail(
|
|
428
|
+
inputError(
|
|
429
|
+
operation,
|
|
430
|
+
"options",
|
|
431
|
+
"format",
|
|
432
|
+
"OAuth operation options may contain only a timeoutMs integer from 1 through 2,147,483,647",
|
|
433
|
+
),
|
|
434
|
+
)
|
|
435
|
+
if (this.#closed || !this.#secret) return Effect.fail(new ClientClosedError())
|
|
436
|
+
if (this.#active >= maximumConcurrentRequests)
|
|
437
|
+
return Effect.fail(new OAuthError({ operation, reason: "busy", outcome: "notDispatched" }))
|
|
438
|
+
this.#active += 1
|
|
439
|
+
const completed = Deferred.makeUnsafe<void>()
|
|
440
|
+
this.#operations.add(completed)
|
|
441
|
+
const deadline = limit ?? defaultTimeoutMs
|
|
442
|
+
const started = nowMs(clock)
|
|
443
|
+
const progress: { knownResponseFailure: OAuthOperationError | undefined } = {
|
|
444
|
+
knownResponseFailure: undefined,
|
|
445
|
+
}
|
|
446
|
+
return this.instance.resolve().pipe(
|
|
447
|
+
withDeadline(
|
|
448
|
+
deadline,
|
|
449
|
+
() => new OAuthError({ operation, reason: "timeout", outcome: "notDispatched" }),
|
|
450
|
+
),
|
|
451
|
+
mapFailureCause((error) =>
|
|
452
|
+
error instanceof OAuthError || error instanceof ClientClosedError
|
|
453
|
+
? error
|
|
454
|
+
: this.#closed
|
|
455
|
+
? new ClientClosedError()
|
|
456
|
+
: error instanceof RateLimitError
|
|
457
|
+
? new OAuthError({
|
|
458
|
+
operation,
|
|
459
|
+
reason: "rateLimit",
|
|
460
|
+
outcome: "notDispatched",
|
|
461
|
+
status: 429,
|
|
462
|
+
retryAfterMs: error.retryAfterMs,
|
|
463
|
+
})
|
|
464
|
+
: new OAuthError({
|
|
465
|
+
operation,
|
|
466
|
+
reason: "network",
|
|
467
|
+
outcome: "notDispatched",
|
|
468
|
+
cause: new TransportError(error),
|
|
469
|
+
}),
|
|
470
|
+
),
|
|
471
|
+
Effect.flatMap((endpoints): Effect.Effect<A, OAuthOperationError | ClientClosedError> =>
|
|
472
|
+
this.#closed || !this.#secret
|
|
473
|
+
? Effect.fail(new ClientClosedError())
|
|
474
|
+
: task(endpoints.apiPublic, endpoints.webapp, this.#secret, progress).pipe(
|
|
475
|
+
withDeadline(
|
|
476
|
+
Math.max(1, deadline - (nowMs(clock) - started)),
|
|
477
|
+
() =>
|
|
478
|
+
progress.knownResponseFailure ??
|
|
479
|
+
new OAuthError({ operation, reason: "timeout", outcome: "unknown" }),
|
|
480
|
+
),
|
|
481
|
+
),
|
|
482
|
+
),
|
|
483
|
+
Effect.tapError((error) =>
|
|
484
|
+
Effect.withFiber((fiber) => Effect.sync(() => this.#logRejection(error, fiber.context))),
|
|
485
|
+
),
|
|
486
|
+
Effect.ensuring(
|
|
487
|
+
Effect.sync(() => {
|
|
488
|
+
this.#active -= 1
|
|
489
|
+
this.#operations.delete(completed)
|
|
490
|
+
Deferred.doneUnsafe(completed, Effect.void)
|
|
491
|
+
}),
|
|
492
|
+
),
|
|
493
|
+
) as Effect.Effect<A, OAuthOperationError | ClientClosedError>
|
|
494
|
+
}),
|
|
495
|
+
)
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
authorizationUrl(
|
|
499
|
+
input: OAuthAuthorizationInput,
|
|
500
|
+
options?: OAuthOperationOptions,
|
|
501
|
+
): Effect.Effect<string, OAuthOperationError | ClientClosedError> {
|
|
502
|
+
return suspendInput(() => {
|
|
503
|
+
if (!record(input))
|
|
504
|
+
return Effect.fail(
|
|
505
|
+
inputError(
|
|
506
|
+
"oauth.authorizationUrl",
|
|
507
|
+
"input",
|
|
508
|
+
"type",
|
|
509
|
+
"OAuth authorization input must be an object",
|
|
510
|
+
),
|
|
511
|
+
)
|
|
512
|
+
const unsupported = unsupportedKeyFailure(
|
|
513
|
+
input,
|
|
514
|
+
[
|
|
515
|
+
"redirectUri",
|
|
516
|
+
"scopes",
|
|
517
|
+
"state",
|
|
518
|
+
"codeChallenge",
|
|
519
|
+
"guildId",
|
|
520
|
+
"channelId",
|
|
521
|
+
"permissions",
|
|
522
|
+
"disableGuildSelect",
|
|
523
|
+
],
|
|
524
|
+
"input",
|
|
525
|
+
"the OAuth authorization input",
|
|
526
|
+
)
|
|
527
|
+
if (unsupported) return Effect.fail(unsupportedInput("oauth.authorizationUrl", unsupported))
|
|
528
|
+
const redirectUriValue = input.redirectUri
|
|
529
|
+
if (!redirectUri(redirectUriValue))
|
|
530
|
+
return Effect.fail(
|
|
531
|
+
inputError(
|
|
532
|
+
"oauth.authorizationUrl",
|
|
533
|
+
"redirectUri",
|
|
534
|
+
"format",
|
|
535
|
+
"Redirect URI must be HTTPS or loopback HTTP without credentials or a fragment",
|
|
536
|
+
),
|
|
537
|
+
)
|
|
538
|
+
const state = input.state
|
|
539
|
+
if (!canonicalText(state))
|
|
540
|
+
return Effect.fail(
|
|
541
|
+
inputError(
|
|
542
|
+
"oauth.authorizationUrl",
|
|
543
|
+
"state",
|
|
544
|
+
"format",
|
|
545
|
+
"OAuth state must contain 1 through 256 UTF-16 code units without leading or trailing whitespace",
|
|
546
|
+
),
|
|
547
|
+
)
|
|
548
|
+
const codeChallenge = input.codeChallenge
|
|
549
|
+
if (typeof codeChallenge !== "string" || !/^[A-Za-z0-9_-]{43}$/.test(codeChallenge))
|
|
550
|
+
return Effect.fail(
|
|
551
|
+
inputError(
|
|
552
|
+
"oauth.authorizationUrl",
|
|
553
|
+
"codeChallenge",
|
|
554
|
+
"format",
|
|
555
|
+
"PKCE code challenge must contain exactly 43 base64url characters",
|
|
556
|
+
),
|
|
557
|
+
)
|
|
558
|
+
const scopeInput = input.scopes
|
|
559
|
+
if (!Array.isArray(scopeInput))
|
|
560
|
+
return Effect.fail(
|
|
561
|
+
inputError("oauth.authorizationUrl", "scopes", "length", "OAuth scopes must be a non-empty array"),
|
|
562
|
+
)
|
|
563
|
+
const scopeLength = scopeInput.length
|
|
564
|
+
if (scopeLength === 0 || scopeLength > oauthScopeInputCapacity)
|
|
565
|
+
return Effect.fail(
|
|
566
|
+
inputError(
|
|
567
|
+
"oauth.authorizationUrl",
|
|
568
|
+
"scopes",
|
|
569
|
+
"length",
|
|
570
|
+
"OAuth scopes must contain 1 through 256 entries",
|
|
571
|
+
),
|
|
572
|
+
)
|
|
573
|
+
const scopes = [...new Set(Array.from({ length: scopeLength }, (_, index) => scopeInput[index]))]
|
|
574
|
+
if (scopes.some((scope) => !["identify", "email", "guilds", "connections", "bot"].includes(scope)))
|
|
575
|
+
return Effect.fail(
|
|
576
|
+
inputError(
|
|
577
|
+
"oauth.authorizationUrl",
|
|
578
|
+
"scopes[]",
|
|
579
|
+
"allowedValue",
|
|
580
|
+
"OAuth scopes must be identify, email, guilds, connections, or bot",
|
|
581
|
+
),
|
|
582
|
+
)
|
|
583
|
+
const botScope = scopes.includes("bot")
|
|
584
|
+
const guildId = input.guildId
|
|
585
|
+
const channelId = input.channelId
|
|
586
|
+
const permissions = input.permissions
|
|
587
|
+
const disableGuildSelect = input.disableGuildSelect
|
|
588
|
+
const installationInput =
|
|
589
|
+
guildId !== undefined ||
|
|
590
|
+
channelId !== undefined ||
|
|
591
|
+
permissions !== undefined ||
|
|
592
|
+
disableGuildSelect !== undefined
|
|
593
|
+
if (installationInput && !botScope)
|
|
594
|
+
return Effect.fail(
|
|
595
|
+
inputError(
|
|
596
|
+
"oauth.authorizationUrl",
|
|
597
|
+
"botInstallation",
|
|
598
|
+
"required",
|
|
599
|
+
"Bot installation options require the bot scope",
|
|
600
|
+
),
|
|
601
|
+
)
|
|
602
|
+
if (guildId !== undefined && !identifier(guildId))
|
|
603
|
+
return Effect.fail(
|
|
604
|
+
inputError("oauth.authorizationUrl", "guildId", "format", "Guild target must be a decimal ID"),
|
|
605
|
+
)
|
|
606
|
+
if (channelId !== undefined && !identifier(channelId))
|
|
607
|
+
return Effect.fail(
|
|
608
|
+
inputError("oauth.authorizationUrl", "channelId", "format", "Channel target must be a decimal ID"),
|
|
609
|
+
)
|
|
610
|
+
if (guildId !== undefined && channelId !== undefined)
|
|
611
|
+
return Effect.fail(
|
|
612
|
+
inputError(
|
|
613
|
+
"oauth.authorizationUrl",
|
|
614
|
+
"channelId",
|
|
615
|
+
"relationship",
|
|
616
|
+
"Channel target cannot be used with guild target",
|
|
617
|
+
),
|
|
618
|
+
)
|
|
619
|
+
if (
|
|
620
|
+
permissions !== undefined &&
|
|
621
|
+
(typeof permissions !== "bigint" || permissions < 0n || permissions > maximumPermissionBits)
|
|
622
|
+
)
|
|
623
|
+
return Effect.fail(
|
|
624
|
+
inputError(
|
|
625
|
+
"oauth.authorizationUrl",
|
|
626
|
+
"permissions",
|
|
627
|
+
"range",
|
|
628
|
+
"Bot permissions must be an unsigned 64-bit bitfield",
|
|
629
|
+
),
|
|
630
|
+
)
|
|
631
|
+
if (disableGuildSelect !== undefined && typeof disableGuildSelect !== "boolean")
|
|
632
|
+
return Effect.fail(
|
|
633
|
+
inputError(
|
|
634
|
+
"oauth.authorizationUrl",
|
|
635
|
+
"disableGuildSelect",
|
|
636
|
+
"type",
|
|
637
|
+
"The option disableGuildSelect must be a boolean",
|
|
638
|
+
),
|
|
639
|
+
)
|
|
640
|
+
const request = {
|
|
641
|
+
redirectUri: redirectUriValue,
|
|
642
|
+
scopes: Object.freeze(scopes),
|
|
643
|
+
state,
|
|
644
|
+
codeChallenge,
|
|
645
|
+
guildId,
|
|
646
|
+
channelId,
|
|
647
|
+
permissions,
|
|
648
|
+
disableGuildSelect,
|
|
649
|
+
}
|
|
650
|
+
return this.#run("oauth.authorizationUrl", options, (_api, webapp) =>
|
|
651
|
+
Effect.sync(() => {
|
|
652
|
+
const url = new URL("oauth2/authorize", `${webapp}/`)
|
|
653
|
+
const query = new URLSearchParams({
|
|
654
|
+
client_id: this.clientId,
|
|
655
|
+
response_type: "code",
|
|
656
|
+
redirect_uri: request.redirectUri,
|
|
657
|
+
scope: request.scopes.join(" "),
|
|
658
|
+
state: request.state,
|
|
659
|
+
code_challenge: request.codeChallenge,
|
|
660
|
+
code_challenge_method: "S256",
|
|
661
|
+
})
|
|
662
|
+
if (request.guildId !== undefined) query.set("guild_id", request.guildId)
|
|
663
|
+
if (request.channelId !== undefined) query.set("channel_id", request.channelId)
|
|
664
|
+
if (request.permissions !== undefined) query.set("permissions", request.permissions.toString())
|
|
665
|
+
if (request.disableGuildSelect !== undefined)
|
|
666
|
+
query.set("disable_guild_select", String(request.disableGuildSelect))
|
|
667
|
+
url.search = query.toString()
|
|
668
|
+
return url.toString()
|
|
669
|
+
}),
|
|
670
|
+
)
|
|
671
|
+
})
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
#request<A>(
|
|
675
|
+
operation: OAuthOperation,
|
|
676
|
+
api: string,
|
|
677
|
+
path: string,
|
|
678
|
+
init: RequestInit,
|
|
679
|
+
decode: (body: unknown) => A | undefined,
|
|
680
|
+
progress: { knownResponseFailure: OAuthOperationError | undefined },
|
|
681
|
+
emptyResponse = false,
|
|
682
|
+
): Effect.Effect<A, OAuthOperationError> {
|
|
683
|
+
return Effect.acquireUseRelease(
|
|
684
|
+
Effect.sync(
|
|
685
|
+
(): {
|
|
686
|
+
controller: AbortController
|
|
687
|
+
settled: Promise<void>
|
|
688
|
+
responseSettled: Promise<void>
|
|
689
|
+
settleResponse: () => void
|
|
690
|
+
response: Response | undefined
|
|
691
|
+
dispatched: boolean
|
|
692
|
+
knownResponseFailure: OAuthOperationError | undefined
|
|
693
|
+
reader: ReadableStreamDefaultReader<Uint8Array> | undefined
|
|
694
|
+
done: boolean
|
|
695
|
+
} => {
|
|
696
|
+
const controller = new AbortController()
|
|
697
|
+
let settleResponse = () => {}
|
|
698
|
+
const responseSettled = new Promise<void>((resolve) => {
|
|
699
|
+
settleResponse = resolve
|
|
700
|
+
})
|
|
701
|
+
this.#controllers.add(controller)
|
|
702
|
+
return {
|
|
703
|
+
controller,
|
|
704
|
+
settled: Promise.resolve(),
|
|
705
|
+
responseSettled,
|
|
706
|
+
settleResponse,
|
|
707
|
+
response: undefined,
|
|
708
|
+
dispatched: false,
|
|
709
|
+
knownResponseFailure: undefined,
|
|
710
|
+
reader: undefined,
|
|
711
|
+
done: false,
|
|
712
|
+
}
|
|
713
|
+
},
|
|
714
|
+
),
|
|
715
|
+
(state) =>
|
|
716
|
+
Effect.tryPromise({
|
|
717
|
+
try: () => {
|
|
718
|
+
const work = (async () => {
|
|
719
|
+
let response: Response | undefined
|
|
720
|
+
try {
|
|
721
|
+
state.dispatched = true
|
|
722
|
+
response = await this.#http(`${api}${path}`, {
|
|
723
|
+
...init,
|
|
724
|
+
redirect: "error",
|
|
725
|
+
signal: state.controller.signal,
|
|
726
|
+
})
|
|
727
|
+
state.response = response
|
|
728
|
+
if (!response.ok)
|
|
729
|
+
state.knownResponseFailure = progress.knownResponseFailure = operationError(
|
|
730
|
+
operation,
|
|
731
|
+
response,
|
|
732
|
+
"unknown",
|
|
733
|
+
)
|
|
734
|
+
state.settleResponse()
|
|
735
|
+
if (state.controller.signal.aborted)
|
|
736
|
+
throw operationError(operation, response, "unknown")
|
|
737
|
+
const decoded =
|
|
738
|
+
response.status === 204
|
|
739
|
+
? undefined
|
|
740
|
+
: emptyResponse && response.ok
|
|
741
|
+
? (await body(response, state), undefined)
|
|
742
|
+
: await json(response, state)
|
|
743
|
+
if (!response.ok)
|
|
744
|
+
throw operationError(operation, response, "unknown", { body: decoded })
|
|
745
|
+
if (emptyResponse) return true as A
|
|
746
|
+
const result = decode(decoded)
|
|
747
|
+
if (result === undefined) throw responseError(operation, response.status)
|
|
748
|
+
return result
|
|
749
|
+
} catch (error) {
|
|
750
|
+
if (error instanceof OAuthError) throw error
|
|
751
|
+
if (response?.ok) throw responseError(operation, response.status)
|
|
752
|
+
throw operationError(
|
|
753
|
+
operation,
|
|
754
|
+
response,
|
|
755
|
+
state.dispatched ? "unknown" : "notDispatched",
|
|
756
|
+
{ cause: error },
|
|
757
|
+
)
|
|
758
|
+
} finally {
|
|
759
|
+
state.settleResponse()
|
|
760
|
+
}
|
|
761
|
+
})()
|
|
762
|
+
// allow-silent: The work promise itself is returned and its rejection observed by the caller, so this only records settlement
|
|
763
|
+
state.settled = work.then(
|
|
764
|
+
() => undefined,
|
|
765
|
+
() => undefined,
|
|
766
|
+
)
|
|
767
|
+
return Promise.race([
|
|
768
|
+
work,
|
|
769
|
+
new Promise<never>((_resolve, reject) => {
|
|
770
|
+
const abort = () =>
|
|
771
|
+
reject(state.knownResponseFailure ?? new Error("OAuth request aborted"))
|
|
772
|
+
if (state.controller.signal.aborted) abort()
|
|
773
|
+
else state.controller.signal.addEventListener("abort", abort, { once: true })
|
|
774
|
+
// allow-silent: The work promise is raced and returned below, so its rejection reaches the caller. This only removes the listener
|
|
775
|
+
void work.then(
|
|
776
|
+
() => state.controller.signal.removeEventListener("abort", abort),
|
|
777
|
+
() => state.controller.signal.removeEventListener("abort", abort),
|
|
778
|
+
)
|
|
779
|
+
}),
|
|
780
|
+
])
|
|
781
|
+
},
|
|
782
|
+
catch: (error) =>
|
|
783
|
+
error instanceof OAuthError
|
|
784
|
+
? error
|
|
785
|
+
: new OAuthError({
|
|
786
|
+
operation,
|
|
787
|
+
reason: "network",
|
|
788
|
+
outcome: "unknown",
|
|
789
|
+
cause: new TransportError(error),
|
|
790
|
+
}),
|
|
791
|
+
}),
|
|
792
|
+
(state) =>
|
|
793
|
+
Effect.promise(async () => {
|
|
794
|
+
state.controller.abort()
|
|
795
|
+
this.#controllers.delete(state.controller)
|
|
796
|
+
const failures: unknown[] = []
|
|
797
|
+
await state.responseSettled
|
|
798
|
+
if (state.reader) {
|
|
799
|
+
if (!state.done)
|
|
800
|
+
try {
|
|
801
|
+
await state.reader.cancel()
|
|
802
|
+
} catch (error) {
|
|
803
|
+
if (!(state.controller.signal.aborted && error === state.controller.signal.reason))
|
|
804
|
+
failures.push(error)
|
|
805
|
+
}
|
|
806
|
+
try {
|
|
807
|
+
state.reader.releaseLock()
|
|
808
|
+
} catch (error) {
|
|
809
|
+
failures.push(error)
|
|
810
|
+
}
|
|
811
|
+
} else if (state.response && !state.response.bodyUsed) {
|
|
812
|
+
try {
|
|
813
|
+
await state.response.body?.cancel()
|
|
814
|
+
} catch (error) {
|
|
815
|
+
if (!(state.controller.signal.aborted && error === state.controller.signal.reason))
|
|
816
|
+
failures.push(error)
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
await state.settled
|
|
820
|
+
// Cleanup faults keep their original values, as REST and discovery cleanup faults do. Error rendering
|
|
821
|
+
// masks credentials, and the response body never becomes part of a cleanup fault
|
|
822
|
+
if (failures.length === 1) throw failures[0]
|
|
823
|
+
if (failures.length > 1) throw new AggregateError(failures, "OAuth response cleanup failed")
|
|
824
|
+
}),
|
|
825
|
+
)
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
exchangeCode(
|
|
829
|
+
input: OAuthCodeExchangeInput,
|
|
830
|
+
options?: OAuthOperationOptions,
|
|
831
|
+
): Effect.Effect<OAuthTokens, OAuthOperationError | ClientClosedError> {
|
|
832
|
+
return suspendInput(() => {
|
|
833
|
+
if (!record(input))
|
|
834
|
+
return Effect.fail(
|
|
835
|
+
inputError("oauth.exchangeCode", "input", "type", "OAuth code exchange input must be an object"),
|
|
836
|
+
)
|
|
837
|
+
const unsupported = unsupportedKeyFailure(
|
|
838
|
+
input,
|
|
839
|
+
["code", "redirectUri", "codeVerifier"],
|
|
840
|
+
"input",
|
|
841
|
+
"the OAuth code exchange input",
|
|
842
|
+
)
|
|
843
|
+
if (unsupported) return Effect.fail(unsupportedInput("oauth.exchangeCode", unsupported))
|
|
844
|
+
const code = input.code
|
|
845
|
+
if (!canonicalText(code))
|
|
846
|
+
return Effect.fail(
|
|
847
|
+
inputError(
|
|
848
|
+
"oauth.exchangeCode",
|
|
849
|
+
"code",
|
|
850
|
+
"format",
|
|
851
|
+
"Authorization code must contain 1 through 256 UTF-16 code units without leading or trailing whitespace",
|
|
852
|
+
),
|
|
853
|
+
)
|
|
854
|
+
const redirectUriValue = input.redirectUri
|
|
855
|
+
if (!redirectUri(redirectUriValue))
|
|
856
|
+
return Effect.fail(
|
|
857
|
+
inputError(
|
|
858
|
+
"oauth.exchangeCode",
|
|
859
|
+
"redirectUri",
|
|
860
|
+
"format",
|
|
861
|
+
"Redirect URI must be HTTPS or loopback HTTP without credentials or a fragment",
|
|
862
|
+
),
|
|
863
|
+
)
|
|
864
|
+
const codeVerifier = input.codeVerifier
|
|
865
|
+
if (typeof codeVerifier !== "string" || !/^[A-Za-z0-9._~-]{43,128}$/.test(codeVerifier))
|
|
866
|
+
return Effect.fail(
|
|
867
|
+
inputError(
|
|
868
|
+
"oauth.exchangeCode",
|
|
869
|
+
"codeVerifier",
|
|
870
|
+
"format",
|
|
871
|
+
"PKCE code verifier must contain 43 through 128 unreserved characters",
|
|
872
|
+
),
|
|
873
|
+
)
|
|
874
|
+
const request = { code, redirectUri: redirectUriValue, codeVerifier }
|
|
875
|
+
return this.#run("oauth.exchangeCode", options, (api, _webapp, secret, progress) =>
|
|
876
|
+
this.#request(
|
|
877
|
+
"oauth.exchangeCode",
|
|
878
|
+
api,
|
|
879
|
+
"/oauth2/token",
|
|
880
|
+
{
|
|
881
|
+
method: "POST",
|
|
882
|
+
headers: {
|
|
883
|
+
authorization: `Basic ${Buffer.from(`${this.clientId}:${secret}`).toString("base64")}`,
|
|
884
|
+
"content-type": "application/x-www-form-urlencoded",
|
|
885
|
+
},
|
|
886
|
+
body: new URLSearchParams({
|
|
887
|
+
grant_type: "authorization_code",
|
|
888
|
+
code: request.code,
|
|
889
|
+
redirect_uri: request.redirectUri,
|
|
890
|
+
code_verifier: request.codeVerifier,
|
|
891
|
+
}).toString(),
|
|
892
|
+
},
|
|
893
|
+
token,
|
|
894
|
+
progress,
|
|
895
|
+
),
|
|
896
|
+
)
|
|
897
|
+
})
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
refresh(
|
|
901
|
+
refreshToken: string,
|
|
902
|
+
options?: OAuthOperationOptions,
|
|
903
|
+
): Effect.Effect<OAuthTokens, OAuthOperationError | ClientClosedError> {
|
|
904
|
+
if (!canonicalText(refreshToken))
|
|
905
|
+
return Effect.fail(
|
|
906
|
+
inputError(
|
|
907
|
+
"oauth.refresh",
|
|
908
|
+
"refreshToken",
|
|
909
|
+
"format",
|
|
910
|
+
"Refresh token must contain 1 through 256 UTF-16 code units without leading or trailing whitespace",
|
|
911
|
+
),
|
|
912
|
+
)
|
|
913
|
+
return this.#run("oauth.refresh", options, (api, _webapp, secret, progress) =>
|
|
914
|
+
this.#request(
|
|
915
|
+
"oauth.refresh",
|
|
916
|
+
api,
|
|
917
|
+
"/oauth2/token",
|
|
918
|
+
{
|
|
919
|
+
method: "POST",
|
|
920
|
+
headers: {
|
|
921
|
+
authorization: `Basic ${Buffer.from(`${this.clientId}:${secret}`).toString("base64")}`,
|
|
922
|
+
"content-type": "application/x-www-form-urlencoded",
|
|
923
|
+
},
|
|
924
|
+
body: new URLSearchParams({
|
|
925
|
+
grant_type: "refresh_token",
|
|
926
|
+
refresh_token: refreshToken,
|
|
927
|
+
}).toString(),
|
|
928
|
+
},
|
|
929
|
+
token,
|
|
930
|
+
progress,
|
|
931
|
+
),
|
|
932
|
+
)
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
revoke(
|
|
936
|
+
value: { readonly token: string; readonly tokenTypeHint?: "access_token" | "refresh_token" },
|
|
937
|
+
options?: OAuthOperationOptions,
|
|
938
|
+
): Effect.Effect<void, OAuthOperationError | ClientClosedError> {
|
|
939
|
+
return suspendInput(() => {
|
|
940
|
+
if (!record(value))
|
|
941
|
+
return Effect.fail(inputError("oauth.revoke", "input", "type", "OAuth revoke input must be an object"))
|
|
942
|
+
const unsupported = unsupportedKeyFailure(
|
|
943
|
+
value,
|
|
944
|
+
["token", "tokenTypeHint"],
|
|
945
|
+
"input",
|
|
946
|
+
"the OAuth revoke input",
|
|
947
|
+
)
|
|
948
|
+
if (unsupported) return Effect.fail(unsupportedInput("oauth.revoke", unsupported))
|
|
949
|
+
const token = value.token
|
|
950
|
+
if (!canonicalText(token))
|
|
951
|
+
return Effect.fail(
|
|
952
|
+
inputError(
|
|
953
|
+
"oauth.revoke",
|
|
954
|
+
"token",
|
|
955
|
+
"format",
|
|
956
|
+
"Revoked token must contain 1 through 256 UTF-16 code units without leading or trailing whitespace",
|
|
957
|
+
),
|
|
958
|
+
)
|
|
959
|
+
const tokenTypeHint = value.tokenTypeHint
|
|
960
|
+
if (tokenTypeHint !== undefined && tokenTypeHint !== "access_token" && tokenTypeHint !== "refresh_token")
|
|
961
|
+
return Effect.fail(
|
|
962
|
+
inputError(
|
|
963
|
+
"oauth.revoke",
|
|
964
|
+
"tokenTypeHint",
|
|
965
|
+
"allowedValue",
|
|
966
|
+
"Token type hint must be access_token or refresh_token",
|
|
967
|
+
),
|
|
968
|
+
)
|
|
969
|
+
const request = { token, tokenTypeHint }
|
|
970
|
+
return this.#run("oauth.revoke", options, (api, _webapp, secret, progress) =>
|
|
971
|
+
this.#request(
|
|
972
|
+
"oauth.revoke",
|
|
973
|
+
api,
|
|
974
|
+
"/oauth2/token/revoke",
|
|
975
|
+
{
|
|
976
|
+
method: "POST",
|
|
977
|
+
headers: {
|
|
978
|
+
authorization: `Basic ${Buffer.from(`${this.clientId}:${secret}`).toString("base64")}`,
|
|
979
|
+
"content-type": "application/x-www-form-urlencoded",
|
|
980
|
+
},
|
|
981
|
+
body: new URLSearchParams({
|
|
982
|
+
token: request.token,
|
|
983
|
+
...(request.tokenTypeHint === undefined ? {} : { token_type_hint: request.tokenTypeHint }),
|
|
984
|
+
}).toString(),
|
|
985
|
+
},
|
|
986
|
+
() => true,
|
|
987
|
+
progress,
|
|
988
|
+
true,
|
|
989
|
+
).pipe(Effect.asVoid),
|
|
990
|
+
)
|
|
991
|
+
})
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
fetchIdentity(
|
|
995
|
+
accessToken: string,
|
|
996
|
+
options?: OAuthOperationOptions,
|
|
997
|
+
): Effect.Effect<OAuthIdentity, OAuthOperationError | ClientClosedError> {
|
|
998
|
+
if (!text(accessToken))
|
|
999
|
+
return Effect.fail(
|
|
1000
|
+
inputError("oauth.fetchIdentity", "accessToken", "required", "Access token must be a non-empty string"),
|
|
1001
|
+
)
|
|
1002
|
+
return this.#run("oauth.fetchIdentity", options, (api, _webapp, _secret, progress) =>
|
|
1003
|
+
this.#request(
|
|
1004
|
+
"oauth.fetchIdentity",
|
|
1005
|
+
api,
|
|
1006
|
+
"/oauth2/userinfo",
|
|
1007
|
+
{ method: "GET", headers: { authorization: `Bearer ${accessToken}` } },
|
|
1008
|
+
identity,
|
|
1009
|
+
progress,
|
|
1010
|
+
),
|
|
1011
|
+
)
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
fetchGuilds(
|
|
1015
|
+
accessToken: string,
|
|
1016
|
+
query: GuildListQuery = {},
|
|
1017
|
+
options?: OAuthOperationOptions,
|
|
1018
|
+
): Effect.Effect<readonly GuildListSummary[], OAuthOperationError | ClientClosedError> {
|
|
1019
|
+
return suspendInput(() => {
|
|
1020
|
+
const request = guildList(query)
|
|
1021
|
+
if (!text(accessToken))
|
|
1022
|
+
return Effect.fail(
|
|
1023
|
+
inputError(
|
|
1024
|
+
"oauth.fetchGuilds",
|
|
1025
|
+
"accessToken",
|
|
1026
|
+
"required",
|
|
1027
|
+
"Access token must be a non-empty string",
|
|
1028
|
+
),
|
|
1029
|
+
)
|
|
1030
|
+
if (request instanceof InputValidationFailure)
|
|
1031
|
+
return Effect.fail(
|
|
1032
|
+
new OAuthError({
|
|
1033
|
+
operation: "oauth.fetchGuilds",
|
|
1034
|
+
reason: "input",
|
|
1035
|
+
outcome: "notDispatched",
|
|
1036
|
+
inputValidation: request.detail,
|
|
1037
|
+
}),
|
|
1038
|
+
)
|
|
1039
|
+
return this.#run("oauth.fetchGuilds", options, (api, _webapp, _secret, progress) =>
|
|
1040
|
+
this.#request(
|
|
1041
|
+
"oauth.fetchGuilds",
|
|
1042
|
+
api,
|
|
1043
|
+
request.path,
|
|
1044
|
+
{ method: "GET", headers: { authorization: `Bearer ${accessToken}` } },
|
|
1045
|
+
request.decode,
|
|
1046
|
+
progress,
|
|
1047
|
+
),
|
|
1048
|
+
)
|
|
1049
|
+
})
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
fetchConnections(
|
|
1053
|
+
accessToken: string,
|
|
1054
|
+
options?: OAuthOperationOptions,
|
|
1055
|
+
): Effect.Effect<readonly OAuthConnection[], OAuthOperationError | ClientClosedError> {
|
|
1056
|
+
if (!text(accessToken))
|
|
1057
|
+
return Effect.fail(
|
|
1058
|
+
inputError(
|
|
1059
|
+
"oauth.fetchConnections",
|
|
1060
|
+
"accessToken",
|
|
1061
|
+
"required",
|
|
1062
|
+
"Access token must be a non-empty string",
|
|
1063
|
+
),
|
|
1064
|
+
)
|
|
1065
|
+
return this.#run("oauth.fetchConnections", options, (api, _webapp, _secret, progress) =>
|
|
1066
|
+
this.#request(
|
|
1067
|
+
"oauth.fetchConnections",
|
|
1068
|
+
api,
|
|
1069
|
+
"/users/@me/connections",
|
|
1070
|
+
{ method: "GET", headers: { authorization: `Bearer ${accessToken}` } },
|
|
1071
|
+
connections,
|
|
1072
|
+
progress,
|
|
1073
|
+
),
|
|
1074
|
+
)
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
introspect(
|
|
1078
|
+
token: string,
|
|
1079
|
+
options?: OAuthOperationOptions,
|
|
1080
|
+
): Effect.Effect<OAuthIntrospection, OAuthOperationError | ClientClosedError> {
|
|
1081
|
+
if (!canonicalText(token))
|
|
1082
|
+
return Effect.fail(
|
|
1083
|
+
inputError(
|
|
1084
|
+
"oauth.introspect",
|
|
1085
|
+
"token",
|
|
1086
|
+
"format",
|
|
1087
|
+
"Inspected token must contain 1 through 256 UTF-16 code units without leading or trailing whitespace",
|
|
1088
|
+
),
|
|
1089
|
+
)
|
|
1090
|
+
return this.#run("oauth.introspect", options, (api, _webapp, secret, progress) =>
|
|
1091
|
+
this.#request(
|
|
1092
|
+
"oauth.introspect",
|
|
1093
|
+
api,
|
|
1094
|
+
"/oauth2/introspect",
|
|
1095
|
+
{
|
|
1096
|
+
method: "POST",
|
|
1097
|
+
headers: {
|
|
1098
|
+
authorization: `Basic ${Buffer.from(`${this.clientId}:${secret}`).toString("base64")}`,
|
|
1099
|
+
"content-type": "application/x-www-form-urlencoded",
|
|
1100
|
+
},
|
|
1101
|
+
body: new URLSearchParams({ token }).toString(),
|
|
1102
|
+
},
|
|
1103
|
+
introspection,
|
|
1104
|
+
progress,
|
|
1105
|
+
),
|
|
1106
|
+
)
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
|
|
1110
|
+
const oauthConfigKeys = ["clientId", "clientSecret", "instance", "logging"]
|
|
1111
|
+
|
|
1112
|
+
export function makeOAuthOwner(
|
|
1113
|
+
config: OAuthConfig,
|
|
1114
|
+
scope: Scope.Scope,
|
|
1115
|
+
native = false,
|
|
1116
|
+
): Effect.Effect<OAuthOwner, ConfigurationError> {
|
|
1117
|
+
return suspendInput(() => {
|
|
1118
|
+
if (!record(config) || Object.keys(config).some((key) => !oauthConfigKeys.includes(key)))
|
|
1119
|
+
return Effect.fail(
|
|
1120
|
+
new ConfigurationError(
|
|
1121
|
+
"configuration",
|
|
1122
|
+
"OAuth configuration must be an object with only clientId, clientSecret, instance, and logging",
|
|
1123
|
+
),
|
|
1124
|
+
)
|
|
1125
|
+
const clientId = config.clientId
|
|
1126
|
+
const clientSecret = config.clientSecret
|
|
1127
|
+
if (!identifier(clientId) || !text(clientSecret))
|
|
1128
|
+
return Effect.fail(
|
|
1129
|
+
new ConfigurationError(
|
|
1130
|
+
"configuration",
|
|
1131
|
+
"OAuth configuration requires a decimal clientId and nonempty clientSecret",
|
|
1132
|
+
),
|
|
1133
|
+
)
|
|
1134
|
+
const instance = config.instance
|
|
1135
|
+
const configuration = instanceConfiguration(instance)
|
|
1136
|
+
if (configuration instanceof ConfigurationError) return Effect.fail(configuration)
|
|
1137
|
+
const logging = loggingConfiguration(config.logging, native)
|
|
1138
|
+
if (logging instanceof ConfigurationError) return Effect.fail(logging)
|
|
1139
|
+
logging.addSecret(clientSecret)
|
|
1140
|
+
return Effect.withFiber((fiber) => {
|
|
1141
|
+
// Native records outside an operation use the creating fiber's logger and annotations
|
|
1142
|
+
if (native) logging.context = fiber.context
|
|
1143
|
+
return Effect.succeed(new OAuthOwner(clientId, clientSecret, configuration, scope, logging))
|
|
1144
|
+
})
|
|
1145
|
+
})
|
|
1146
|
+
}
|