agent-messenger 1.0.0
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/.claude/commands/release.md +92 -0
- package/.claude-plugin/README.md +144 -0
- package/.claude-plugin/marketplace.json +37 -0
- package/.claude-plugin/plugin.json +17 -0
- package/.github/workflows/ci.yml +30 -0
- package/CLAUDE.md +106 -0
- package/CONTRIBUTING.md +131 -0
- package/README.md +140 -0
- package/biome.json +34 -0
- package/bun.lock +252 -0
- package/dist/cli.d.ts +5 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +21 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/auth.d.ts +3 -0
- package/dist/commands/auth.d.ts.map +1 -0
- package/dist/commands/auth.js +140 -0
- package/dist/commands/auth.js.map +1 -0
- package/dist/commands/channel.d.ts +3 -0
- package/dist/commands/channel.d.ts.map +1 -0
- package/dist/commands/channel.js +118 -0
- package/dist/commands/channel.js.map +1 -0
- package/dist/commands/file.d.ts +3 -0
- package/dist/commands/file.d.ts.map +1 -0
- package/dist/commands/file.js +113 -0
- package/dist/commands/file.js.map +1 -0
- package/dist/commands/index.d.ts +9 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +9 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/message.d.ts +3 -0
- package/dist/commands/message.d.ts.map +1 -0
- package/dist/commands/message.js +214 -0
- package/dist/commands/message.js.map +1 -0
- package/dist/commands/reaction.d.ts +3 -0
- package/dist/commands/reaction.d.ts.map +1 -0
- package/dist/commands/reaction.js +100 -0
- package/dist/commands/reaction.js.map +1 -0
- package/dist/commands/snapshot.d.ts +3 -0
- package/dist/commands/snapshot.d.ts.map +1 -0
- package/dist/commands/snapshot.js +88 -0
- package/dist/commands/snapshot.js.map +1 -0
- package/dist/commands/user.d.ts +3 -0
- package/dist/commands/user.d.ts.map +1 -0
- package/dist/commands/user.js +96 -0
- package/dist/commands/user.js.map +1 -0
- package/dist/commands/workspace.d.ts +3 -0
- package/dist/commands/workspace.d.ts.map +1 -0
- package/dist/commands/workspace.js +89 -0
- package/dist/commands/workspace.js.map +1 -0
- package/dist/lib/credential-manager.d.ts +13 -0
- package/dist/lib/credential-manager.d.ts.map +1 -0
- package/dist/lib/credential-manager.js +58 -0
- package/dist/lib/credential-manager.js.map +1 -0
- package/dist/lib/index.d.ts +3 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +3 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/ref-manager.d.ts +26 -0
- package/dist/lib/ref-manager.d.ts.map +1 -0
- package/dist/lib/ref-manager.js +92 -0
- package/dist/lib/ref-manager.js.map +1 -0
- package/dist/lib/slack-client.d.ts +37 -0
- package/dist/lib/slack-client.d.ts.map +1 -0
- package/dist/lib/slack-client.js +379 -0
- package/dist/lib/slack-client.js.map +1 -0
- package/dist/lib/token-extractor.d.ts +28 -0
- package/dist/lib/token-extractor.d.ts.map +1 -0
- package/dist/lib/token-extractor.js +401 -0
- package/dist/lib/token-extractor.js.map +1 -0
- package/dist/package.json +37 -0
- package/dist/src/cli.d.ts +5 -0
- package/dist/src/cli.d.ts.map +1 -0
- package/dist/src/cli.js +22 -0
- package/dist/src/cli.js.map +1 -0
- package/dist/src/platforms/discord/cli.d.ts +5 -0
- package/dist/src/platforms/discord/cli.d.ts.map +1 -0
- package/dist/src/platforms/discord/cli.js +22 -0
- package/dist/src/platforms/discord/cli.js.map +1 -0
- package/dist/src/platforms/discord/client.d.ts +34 -0
- package/dist/src/platforms/discord/client.d.ts.map +1 -0
- package/dist/src/platforms/discord/client.js +187 -0
- package/dist/src/platforms/discord/client.js.map +1 -0
- package/dist/src/platforms/discord/client.test.d.ts +2 -0
- package/dist/src/platforms/discord/client.test.d.ts.map +1 -0
- package/dist/src/platforms/discord/client.test.js +367 -0
- package/dist/src/platforms/discord/client.test.js.map +1 -0
- package/dist/src/platforms/discord/commands/auth.d.ts +13 -0
- package/dist/src/platforms/discord/commands/auth.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/auth.js +155 -0
- package/dist/src/platforms/discord/commands/auth.js.map +1 -0
- package/dist/src/platforms/discord/commands/auth.test.d.ts +2 -0
- package/dist/src/platforms/discord/commands/auth.test.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/auth.test.js +65 -0
- package/dist/src/platforms/discord/commands/auth.test.js.map +1 -0
- package/dist/src/platforms/discord/commands/channel.d.ts +13 -0
- package/dist/src/platforms/discord/commands/channel.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/channel.js +99 -0
- package/dist/src/platforms/discord/commands/channel.js.map +1 -0
- package/dist/src/platforms/discord/commands/channel.test.d.ts +2 -0
- package/dist/src/platforms/discord/commands/channel.test.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/channel.test.js +136 -0
- package/dist/src/platforms/discord/commands/channel.test.js.map +1 -0
- package/dist/src/platforms/discord/commands/file.d.ts +13 -0
- package/dist/src/platforms/discord/commands/file.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/file.js +99 -0
- package/dist/src/platforms/discord/commands/file.js.map +1 -0
- package/dist/src/platforms/discord/commands/file.test.d.ts +2 -0
- package/dist/src/platforms/discord/commands/file.test.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/file.test.js +83 -0
- package/dist/src/platforms/discord/commands/file.test.js.map +1 -0
- package/dist/src/platforms/discord/commands/guild.d.ts +15 -0
- package/dist/src/platforms/discord/commands/guild.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/guild.js +102 -0
- package/dist/src/platforms/discord/commands/guild.js.map +1 -0
- package/dist/src/platforms/discord/commands/guild.test.d.ts +2 -0
- package/dist/src/platforms/discord/commands/guild.test.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/guild.test.js +100 -0
- package/dist/src/platforms/discord/commands/guild.test.js.map +1 -0
- package/dist/src/platforms/discord/commands/index.d.ts +9 -0
- package/dist/src/platforms/discord/commands/index.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/index.js +9 -0
- package/dist/src/platforms/discord/commands/index.js.map +1 -0
- package/dist/src/platforms/discord/commands/message.d.ts +17 -0
- package/dist/src/platforms/discord/commands/message.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/message.js +131 -0
- package/dist/src/platforms/discord/commands/message.js.map +1 -0
- package/dist/src/platforms/discord/commands/message.test.d.ts +2 -0
- package/dist/src/platforms/discord/commands/message.test.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/message.test.js +91 -0
- package/dist/src/platforms/discord/commands/message.test.js.map +1 -0
- package/dist/src/platforms/discord/commands/reaction.d.ts +12 -0
- package/dist/src/platforms/discord/commands/reaction.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/reaction.js +99 -0
- package/dist/src/platforms/discord/commands/reaction.js.map +1 -0
- package/dist/src/platforms/discord/commands/reaction.test.d.ts +2 -0
- package/dist/src/platforms/discord/commands/reaction.test.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/reaction.test.js +115 -0
- package/dist/src/platforms/discord/commands/reaction.test.js.map +1 -0
- package/dist/src/platforms/discord/commands/snapshot.d.ts +9 -0
- package/dist/src/platforms/discord/commands/snapshot.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/snapshot.js +80 -0
- package/dist/src/platforms/discord/commands/snapshot.js.map +1 -0
- package/dist/src/platforms/discord/commands/snapshot.test.d.ts +2 -0
- package/dist/src/platforms/discord/commands/snapshot.test.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/snapshot.test.js +25 -0
- package/dist/src/platforms/discord/commands/snapshot.test.js.map +1 -0
- package/dist/src/platforms/discord/commands/user.d.ts +3 -0
- package/dist/src/platforms/discord/commands/user.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/user.js +94 -0
- package/dist/src/platforms/discord/commands/user.js.map +1 -0
- package/dist/src/platforms/discord/commands/user.test.d.ts +2 -0
- package/dist/src/platforms/discord/commands/user.test.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/user.test.js +103 -0
- package/dist/src/platforms/discord/commands/user.test.js.map +1 -0
- package/dist/src/platforms/discord/credential-manager.d.ts +33 -0
- package/dist/src/platforms/discord/credential-manager.d.ts.map +1 -0
- package/dist/src/platforms/discord/credential-manager.js +73 -0
- package/dist/src/platforms/discord/credential-manager.js.map +1 -0
- package/dist/src/platforms/discord/credential-manager.test.d.ts +2 -0
- package/dist/src/platforms/discord/credential-manager.test.d.ts.map +1 -0
- package/dist/src/platforms/discord/credential-manager.test.js +136 -0
- package/dist/src/platforms/discord/credential-manager.test.js.map +1 -0
- package/dist/src/platforms/discord/token-extractor.d.ts +55 -0
- package/dist/src/platforms/discord/token-extractor.d.ts.map +1 -0
- package/dist/src/platforms/discord/token-extractor.js +462 -0
- package/dist/src/platforms/discord/token-extractor.js.map +1 -0
- package/dist/src/platforms/discord/token-extractor.test.d.ts +2 -0
- package/dist/src/platforms/discord/token-extractor.test.d.ts.map +1 -0
- package/dist/src/platforms/discord/token-extractor.test.js +789 -0
- package/dist/src/platforms/discord/token-extractor.test.js.map +1 -0
- package/dist/src/platforms/discord/types.d.ts +251 -0
- package/dist/src/platforms/discord/types.d.ts.map +1 -0
- package/dist/src/platforms/discord/types.js +74 -0
- package/dist/src/platforms/discord/types.js.map +1 -0
- package/dist/src/platforms/discord/types.test.d.ts +2 -0
- package/dist/src/platforms/discord/types.test.d.ts.map +1 -0
- package/dist/src/platforms/discord/types.test.js +211 -0
- package/dist/src/platforms/discord/types.test.js.map +1 -0
- package/dist/src/platforms/slack/cli.d.ts +5 -0
- package/dist/src/platforms/slack/cli.d.ts.map +1 -0
- package/dist/src/platforms/slack/cli.js +22 -0
- package/dist/src/platforms/slack/cli.js.map +1 -0
- package/dist/src/platforms/slack/client.d.ts +47 -0
- package/dist/src/platforms/slack/client.d.ts.map +1 -0
- package/dist/src/platforms/slack/client.js +412 -0
- package/dist/src/platforms/slack/client.js.map +1 -0
- package/dist/src/platforms/slack/commands/auth.d.ts +3 -0
- package/dist/src/platforms/slack/commands/auth.d.ts.map +1 -0
- package/dist/src/platforms/slack/commands/auth.js +156 -0
- package/dist/src/platforms/slack/commands/auth.js.map +1 -0
- package/dist/src/platforms/slack/commands/channel.d.ts +3 -0
- package/dist/src/platforms/slack/commands/channel.d.ts.map +1 -0
- package/dist/src/platforms/slack/commands/channel.js +118 -0
- package/dist/src/platforms/slack/commands/channel.js.map +1 -0
- package/dist/src/platforms/slack/commands/file.d.ts +3 -0
- package/dist/src/platforms/slack/commands/file.d.ts.map +1 -0
- package/dist/src/platforms/slack/commands/file.js +113 -0
- package/dist/src/platforms/slack/commands/file.js.map +1 -0
- package/dist/src/platforms/slack/commands/index.d.ts +9 -0
- package/dist/src/platforms/slack/commands/index.d.ts.map +1 -0
- package/dist/src/platforms/slack/commands/index.js +9 -0
- package/dist/src/platforms/slack/commands/index.js.map +1 -0
- package/dist/src/platforms/slack/commands/message.d.ts +3 -0
- package/dist/src/platforms/slack/commands/message.d.ts.map +1 -0
- package/dist/src/platforms/slack/commands/message.js +263 -0
- package/dist/src/platforms/slack/commands/message.js.map +1 -0
- package/dist/src/platforms/slack/commands/reaction.d.ts +3 -0
- package/dist/src/platforms/slack/commands/reaction.d.ts.map +1 -0
- package/dist/src/platforms/slack/commands/reaction.js +100 -0
- package/dist/src/platforms/slack/commands/reaction.js.map +1 -0
- package/dist/src/platforms/slack/commands/snapshot.d.ts +3 -0
- package/dist/src/platforms/slack/commands/snapshot.d.ts.map +1 -0
- package/dist/src/platforms/slack/commands/snapshot.js +87 -0
- package/dist/src/platforms/slack/commands/snapshot.js.map +1 -0
- package/dist/src/platforms/slack/commands/user.d.ts +3 -0
- package/dist/src/platforms/slack/commands/user.d.ts.map +1 -0
- package/dist/src/platforms/slack/commands/user.js +96 -0
- package/dist/src/platforms/slack/commands/user.js.map +1 -0
- package/dist/src/platforms/slack/commands/workspace.d.ts +3 -0
- package/dist/src/platforms/slack/commands/workspace.d.ts.map +1 -0
- package/dist/src/platforms/slack/commands/workspace.js +89 -0
- package/dist/src/platforms/slack/commands/workspace.js.map +1 -0
- package/dist/src/platforms/slack/credential-manager.d.ts +13 -0
- package/dist/src/platforms/slack/credential-manager.d.ts.map +1 -0
- package/dist/src/platforms/slack/credential-manager.js +58 -0
- package/dist/src/platforms/slack/credential-manager.js.map +1 -0
- package/dist/src/platforms/slack/index.d.ts +3 -0
- package/dist/src/platforms/slack/index.d.ts.map +1 -0
- package/dist/src/platforms/slack/index.js +3 -0
- package/dist/src/platforms/slack/index.js.map +1 -0
- package/dist/src/platforms/slack/token-extractor.d.ts +28 -0
- package/dist/src/platforms/slack/token-extractor.d.ts.map +1 -0
- package/dist/src/platforms/slack/token-extractor.js +401 -0
- package/dist/src/platforms/slack/token-extractor.js.map +1 -0
- package/dist/src/platforms/slack/types.d.ts +369 -0
- package/dist/src/platforms/slack/types.d.ts.map +1 -0
- package/dist/src/platforms/slack/types.js +92 -0
- package/dist/src/platforms/slack/types.js.map +1 -0
- package/dist/src/shared/utils/concurrency.d.ts +2 -0
- package/dist/src/shared/utils/concurrency.d.ts.map +1 -0
- package/dist/src/shared/utils/concurrency.js +14 -0
- package/dist/src/shared/utils/concurrency.js.map +1 -0
- package/dist/src/shared/utils/concurrency.test.d.ts +2 -0
- package/dist/src/shared/utils/concurrency.test.d.ts.map +1 -0
- package/dist/src/shared/utils/concurrency.test.js +39 -0
- package/dist/src/shared/utils/concurrency.test.js.map +1 -0
- package/dist/src/shared/utils/error-handler.d.ts +2 -0
- package/dist/src/shared/utils/error-handler.d.ts.map +1 -0
- package/dist/src/shared/utils/error-handler.js +5 -0
- package/dist/src/shared/utils/error-handler.js.map +1 -0
- package/dist/src/shared/utils/output.d.ts +2 -0
- package/dist/src/shared/utils/output.d.ts.map +1 -0
- package/dist/src/shared/utils/output.js +4 -0
- package/dist/src/shared/utils/output.js.map +1 -0
- package/dist/tests/cli.test.d.ts +2 -0
- package/dist/tests/cli.test.d.ts.map +1 -0
- package/dist/tests/cli.test.js +83 -0
- package/dist/tests/cli.test.js.map +1 -0
- package/dist/tests/commands/.test-slack-data/Local Storage/leveldb/CURRENT +1 -0
- package/dist/tests/commands/.test-slack-data/Local Storage/leveldb/LOCK +0 -0
- package/dist/tests/commands/.test-slack-data/Local Storage/leveldb/LOG +3 -0
- package/dist/tests/commands/.test-slack-data/Local Storage/leveldb/LOG.old +1 -0
- package/dist/tests/commands/.test-slack-data/Local Storage/leveldb/MANIFEST-000004 +0 -0
- package/dist/tests/commands/auth.test.d.ts +2 -0
- package/dist/tests/commands/auth.test.d.ts.map +1 -0
- package/dist/tests/commands/auth.test.js +304 -0
- package/dist/tests/commands/auth.test.js.map +1 -0
- package/dist/tests/commands/channel.test.d.ts +2 -0
- package/dist/tests/commands/channel.test.d.ts.map +1 -0
- package/dist/tests/commands/channel.test.js +166 -0
- package/dist/tests/commands/channel.test.js.map +1 -0
- package/dist/tests/commands/file.test.d.ts +2 -0
- package/dist/tests/commands/file.test.d.ts.map +1 -0
- package/dist/tests/commands/file.test.js +175 -0
- package/dist/tests/commands/file.test.js.map +1 -0
- package/dist/tests/commands/message.test.d.ts +2 -0
- package/dist/tests/commands/message.test.d.ts.map +1 -0
- package/dist/tests/commands/message.test.js +293 -0
- package/dist/tests/commands/message.test.js.map +1 -0
- package/dist/tests/commands/reaction.test.d.ts +2 -0
- package/dist/tests/commands/reaction.test.d.ts.map +1 -0
- package/dist/tests/commands/reaction.test.js +84 -0
- package/dist/tests/commands/reaction.test.js.map +1 -0
- package/dist/tests/commands/snapshot.test.d.ts +2 -0
- package/dist/tests/commands/snapshot.test.d.ts.map +1 -0
- package/dist/tests/commands/snapshot.test.js +280 -0
- package/dist/tests/commands/snapshot.test.js.map +1 -0
- package/dist/tests/commands/user.test.d.ts +2 -0
- package/dist/tests/commands/user.test.d.ts.map +1 -0
- package/dist/tests/commands/user.test.js +117 -0
- package/dist/tests/commands/user.test.js.map +1 -0
- package/dist/tests/commands/workspace.test.d.ts +2 -0
- package/dist/tests/commands/workspace.test.d.ts.map +1 -0
- package/dist/tests/commands/workspace.test.js +453 -0
- package/dist/tests/commands/workspace.test.js.map +1 -0
- package/dist/tests/credential-manager.test.d.ts +2 -0
- package/dist/tests/credential-manager.test.d.ts.map +1 -0
- package/dist/tests/credential-manager.test.js +199 -0
- package/dist/tests/credential-manager.test.js.map +1 -0
- package/dist/tests/slack-client.test.d.ts +2 -0
- package/dist/tests/slack-client.test.d.ts.map +1 -0
- package/dist/tests/slack-client.test.js +741 -0
- package/dist/tests/slack-client.test.js.map +1 -0
- package/dist/tests/types.test.d.ts +2 -0
- package/dist/tests/types.test.d.ts.map +1 -0
- package/dist/tests/types.test.js +215 -0
- package/dist/tests/types.test.js.map +1 -0
- package/dist/types/index.d.ts +369 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +92 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/error-handler.d.ts +2 -0
- package/dist/utils/error-handler.d.ts.map +1 -0
- package/dist/utils/error-handler.js +5 -0
- package/dist/utils/error-handler.js.map +1 -0
- package/dist/utils/output.d.ts +2 -0
- package/dist/utils/output.d.ts.map +1 -0
- package/dist/utils/output.js +4 -0
- package/dist/utils/output.js.map +1 -0
- package/docs/discord.md +182 -0
- package/docs/slack.md +160 -0
- package/package.json +37 -0
- package/skills/agent-discord/SKILL.md +273 -0
- package/skills/agent-discord/references/authentication.md +294 -0
- package/skills/agent-discord/references/common-patterns.md +455 -0
- package/skills/agent-discord/templates/guild-summary.sh +167 -0
- package/skills/agent-discord/templates/monitor-channel.sh +180 -0
- package/skills/agent-discord/templates/post-message.sh +173 -0
- package/skills/agent-slack/SKILL.md +268 -0
- package/skills/agent-slack/references/authentication.md +332 -0
- package/skills/agent-slack/references/common-patterns.md +527 -0
- package/skills/agent-slack/templates/monitor-channel.sh +186 -0
- package/skills/agent-slack/templates/post-message.sh +130 -0
- package/skills/agent-slack/templates/workspace-summary.sh +149 -0
- package/src/cli.ts +29 -0
- package/src/platforms/discord/cli.ts +36 -0
- package/src/platforms/discord/client.test.ts +456 -0
- package/src/platforms/discord/client.ts +281 -0
- package/src/platforms/discord/commands/auth.test.ts +72 -0
- package/src/platforms/discord/commands/auth.ts +206 -0
- package/src/platforms/discord/commands/channel.test.ts +153 -0
- package/src/platforms/discord/commands/channel.ts +127 -0
- package/src/platforms/discord/commands/file.test.ts +98 -0
- package/src/platforms/discord/commands/file.ts +134 -0
- package/src/platforms/discord/commands/guild.test.ts +117 -0
- package/src/platforms/discord/commands/guild.ts +129 -0
- package/src/platforms/discord/commands/index.ts +8 -0
- package/src/platforms/discord/commands/message.test.ts +107 -0
- package/src/platforms/discord/commands/message.ts +182 -0
- package/src/platforms/discord/commands/reaction.test.ts +123 -0
- package/src/platforms/discord/commands/reaction.ts +156 -0
- package/src/platforms/discord/commands/snapshot.test.ts +29 -0
- package/src/platforms/discord/commands/snapshot.ts +104 -0
- package/src/platforms/discord/commands/user.test.ts +115 -0
- package/src/platforms/discord/commands/user.ts +124 -0
- package/src/platforms/discord/credential-manager.test.ts +173 -0
- package/src/platforms/discord/credential-manager.ts +95 -0
- package/src/platforms/discord/token-extractor.test.ts +918 -0
- package/src/platforms/discord/token-extractor.ts +549 -0
- package/src/platforms/discord/types.test.ts +245 -0
- package/src/platforms/discord/types.ts +158 -0
- package/src/platforms/slack/cli.ts +36 -0
- package/src/platforms/slack/client.ts +466 -0
- package/src/platforms/slack/commands/auth.ts +211 -0
- package/src/platforms/slack/commands/channel.ts +158 -0
- package/src/platforms/slack/commands/file.ts +153 -0
- package/src/platforms/slack/commands/index.ts +8 -0
- package/src/platforms/slack/commands/message.ts +369 -0
- package/src/platforms/slack/commands/reaction.ts +166 -0
- package/src/platforms/slack/commands/snapshot.ts +114 -0
- package/src/platforms/slack/commands/user.ts +110 -0
- package/src/platforms/slack/commands/workspace.ts +111 -0
- package/src/platforms/slack/credential-manager.ts +74 -0
- package/src/platforms/slack/index.ts +2 -0
- package/src/platforms/slack/token-extractor.ts +496 -0
- package/src/platforms/slack/types.ts +193 -0
- package/src/shared/utils/concurrency.test.ts +53 -0
- package/src/shared/utils/concurrency.ts +20 -0
- package/src/shared/utils/error-handler.ts +4 -0
- package/src/shared/utils/output.ts +3 -0
- package/tests/cli.test.ts +94 -0
- package/tests/commands/auth.test.ts +383 -0
- package/tests/commands/channel.test.ts +185 -0
- package/tests/commands/file.test.ts +204 -0
- package/tests/commands/message.test.ts +344 -0
- package/tests/commands/reaction.test.ts +101 -0
- package/tests/commands/snapshot.test.ts +308 -0
- package/tests/commands/user.test.ts +138 -0
- package/tests/commands/workspace.test.ts +528 -0
- package/tests/credential-manager.test.ts +241 -0
- package/tests/slack-client.test.ts +916 -0
- package/tests/types.test.ts +241 -0
- package/tsconfig.json +36 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { expect, mock, test } from 'bun:test';
|
|
2
|
+
// Mock DiscordClient
|
|
3
|
+
const mockClient = {
|
|
4
|
+
testAuth: mock(async () => ({
|
|
5
|
+
id: 'user123',
|
|
6
|
+
username: 'testuser',
|
|
7
|
+
global_name: 'Test User',
|
|
8
|
+
avatar: 'avatar_hash',
|
|
9
|
+
bot: false,
|
|
10
|
+
})),
|
|
11
|
+
getUser: mock(async (userId) => ({
|
|
12
|
+
id: userId,
|
|
13
|
+
username: 'testuser',
|
|
14
|
+
global_name: 'Test User',
|
|
15
|
+
avatar: 'avatar_hash',
|
|
16
|
+
bot: false,
|
|
17
|
+
})),
|
|
18
|
+
listUsers: mock(async (_guildId) => [
|
|
19
|
+
{
|
|
20
|
+
id: 'user1',
|
|
21
|
+
username: 'alice',
|
|
22
|
+
global_name: 'Alice',
|
|
23
|
+
avatar: 'avatar1',
|
|
24
|
+
bot: false,
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
id: 'user2',
|
|
28
|
+
username: 'bot_user',
|
|
29
|
+
global_name: 'Bot User',
|
|
30
|
+
avatar: 'avatar2',
|
|
31
|
+
bot: true,
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
id: 'user3',
|
|
35
|
+
username: 'bob',
|
|
36
|
+
global_name: 'Bob',
|
|
37
|
+
avatar: 'avatar3',
|
|
38
|
+
bot: false,
|
|
39
|
+
},
|
|
40
|
+
]),
|
|
41
|
+
};
|
|
42
|
+
test('me returns current user info', async () => {
|
|
43
|
+
// given: authenticated user
|
|
44
|
+
const user = await mockClient.testAuth();
|
|
45
|
+
// when: getting current user
|
|
46
|
+
const result = {
|
|
47
|
+
id: user.id,
|
|
48
|
+
username: user.username,
|
|
49
|
+
global_name: user.global_name,
|
|
50
|
+
avatar: user.avatar,
|
|
51
|
+
bot: user.bot,
|
|
52
|
+
};
|
|
53
|
+
// then: returns user object
|
|
54
|
+
expect(result.id).toBe('user123');
|
|
55
|
+
expect(result.username).toBe('testuser');
|
|
56
|
+
expect(result.global_name).toBe('Test User');
|
|
57
|
+
expect(result.bot).toBe(false);
|
|
58
|
+
});
|
|
59
|
+
test('info returns user details by id', async () => {
|
|
60
|
+
// given: user id
|
|
61
|
+
const userId = 'user123';
|
|
62
|
+
// when: getting user info
|
|
63
|
+
const user = await mockClient.getUser(userId);
|
|
64
|
+
const result = {
|
|
65
|
+
id: user.id,
|
|
66
|
+
username: user.username,
|
|
67
|
+
global_name: user.global_name,
|
|
68
|
+
avatar: user.avatar,
|
|
69
|
+
bot: user.bot,
|
|
70
|
+
};
|
|
71
|
+
// then: returns user object
|
|
72
|
+
expect(result.id).toBe('user123');
|
|
73
|
+
expect(result.username).toBe('testuser');
|
|
74
|
+
});
|
|
75
|
+
test('list returns guild members', async () => {
|
|
76
|
+
// given: guild id
|
|
77
|
+
const guildId = 'guild123';
|
|
78
|
+
// when: listing users
|
|
79
|
+
const users = await mockClient.listUsers(guildId);
|
|
80
|
+
const result = users.map((u) => ({
|
|
81
|
+
id: u.id,
|
|
82
|
+
username: u.username,
|
|
83
|
+
global_name: u.global_name,
|
|
84
|
+
avatar: u.avatar,
|
|
85
|
+
bot: u.bot,
|
|
86
|
+
}));
|
|
87
|
+
// then: returns array of users
|
|
88
|
+
expect(result).toHaveLength(3);
|
|
89
|
+
expect(result[0].username).toBe('alice');
|
|
90
|
+
expect(result[1].bot).toBe(true);
|
|
91
|
+
expect(result[2].username).toBe('bob');
|
|
92
|
+
});
|
|
93
|
+
test('list filters out bots when flag not set', async () => {
|
|
94
|
+
// given: guild id and users with bots
|
|
95
|
+
const guildId = 'guild123';
|
|
96
|
+
const users = await mockClient.listUsers(guildId);
|
|
97
|
+
// when: filtering out bots
|
|
98
|
+
const filtered = users.filter((u) => !u.bot);
|
|
99
|
+
// then: returns only non-bot users
|
|
100
|
+
expect(filtered).toHaveLength(2);
|
|
101
|
+
expect(filtered.every((u) => !u.bot)).toBe(true);
|
|
102
|
+
});
|
|
103
|
+
//# sourceMappingURL=user.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user.test.js","sourceRoot":"","sources":["../../../../../src/platforms/discord/commands/user.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAE7C,qBAAqB;AACrB,MAAM,UAAU,GAAG;IACjB,QAAQ,EAAE,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;QAC1B,EAAE,EAAE,SAAS;QACb,QAAQ,EAAE,UAAU;QACpB,WAAW,EAAE,WAAW;QACxB,MAAM,EAAE,aAAa;QACrB,GAAG,EAAE,KAAK;KACX,CAAC,CAAC;IACH,OAAO,EAAE,IAAI,CAAC,KAAK,EAAE,MAAc,EAAE,EAAE,CAAC,CAAC;QACvC,EAAE,EAAE,MAAM;QACV,QAAQ,EAAE,UAAU;QACpB,WAAW,EAAE,WAAW;QACxB,MAAM,EAAE,aAAa;QACrB,GAAG,EAAE,KAAK;KACX,CAAC,CAAC;IACH,SAAS,EAAE,IAAI,CAAC,KAAK,EAAE,QAAgB,EAAE,EAAE,CAAC;QAC1C;YACE,EAAE,EAAE,OAAO;YACX,QAAQ,EAAE,OAAO;YAC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CAAC,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;AACxC,CAAC,CAAC,CAAA;AAEF,IAAI,CAAC,yCAAyC,EAAE,KAAK,IAAI,EAAE;IACzD,sCAAsC;IACtC,MAAM,OAAO,GAAG,UAAU,CAAA;IAC1B,MAAM,KAAK,GAAG,MAAM,UAAU,CAAC,SAAS,CAAC,OAAO,CAAC,CAAA;IAEjD,2BAA2B;IAC3B,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;IAE5C,mCAAmC;IACnC,MAAM,CAAC,QAAQ,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAA;IAChC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAClD,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export interface DiscordConfig {
|
|
2
|
+
token: string | null;
|
|
3
|
+
current_guild: string | null;
|
|
4
|
+
guilds: Record<string, {
|
|
5
|
+
guild_id: string;
|
|
6
|
+
guild_name: string;
|
|
7
|
+
}>;
|
|
8
|
+
}
|
|
9
|
+
export declare class DiscordCredentialManager {
|
|
10
|
+
private configDir;
|
|
11
|
+
private credentialsPath;
|
|
12
|
+
constructor(configDir?: string);
|
|
13
|
+
load(): Promise<DiscordConfig>;
|
|
14
|
+
save(config: DiscordConfig): Promise<void>;
|
|
15
|
+
getToken(): Promise<string | null>;
|
|
16
|
+
setToken(token: string): Promise<void>;
|
|
17
|
+
clearToken(): Promise<void>;
|
|
18
|
+
getCurrentGuild(): Promise<string | null>;
|
|
19
|
+
setCurrentGuild(guildId: string): Promise<void>;
|
|
20
|
+
getGuilds(): Promise<Record<string, {
|
|
21
|
+
guild_id: string;
|
|
22
|
+
guild_name: string;
|
|
23
|
+
}>>;
|
|
24
|
+
setGuilds(guilds: Record<string, {
|
|
25
|
+
guild_id: string;
|
|
26
|
+
guild_name: string;
|
|
27
|
+
}>): Promise<void>;
|
|
28
|
+
getCredentials(): Promise<{
|
|
29
|
+
token: string;
|
|
30
|
+
guildId: string;
|
|
31
|
+
} | null>;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=credential-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credential-manager.d.ts","sourceRoot":"","sources":["../../../../src/platforms/discord/credential-manager.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CACjE;AAED,qBAAa,wBAAwB;IACnC,OAAO,CAAC,SAAS,CAAQ;IACzB,OAAO,CAAC,eAAe,CAAQ;gBAEnB,SAAS,CAAC,EAAE,MAAM;IAKxB,IAAI,IAAI,OAAO,CAAC,aAAa,CAAC;IAc9B,IAAI,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAS1C,QAAQ,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAKlC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAMtC,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAM3B,eAAe,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAKzC,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAM/C,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAK9E,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAM1F,cAAc,IAAI,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;CAY3E"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { mkdir } from 'node:fs/promises';
|
|
3
|
+
import { homedir } from 'node:os';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
export class DiscordCredentialManager {
|
|
6
|
+
configDir;
|
|
7
|
+
credentialsPath;
|
|
8
|
+
constructor(configDir) {
|
|
9
|
+
this.configDir = configDir ?? join(homedir(), '.config', 'agent-messenger');
|
|
10
|
+
this.credentialsPath = join(this.configDir, 'discord-credentials.json');
|
|
11
|
+
}
|
|
12
|
+
async load() {
|
|
13
|
+
if (!existsSync(this.credentialsPath)) {
|
|
14
|
+
return {
|
|
15
|
+
token: null,
|
|
16
|
+
current_guild: null,
|
|
17
|
+
guilds: {},
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
const file = Bun.file(this.credentialsPath);
|
|
21
|
+
const content = await file.text();
|
|
22
|
+
return JSON.parse(content);
|
|
23
|
+
}
|
|
24
|
+
async save(config) {
|
|
25
|
+
await mkdir(this.configDir, { recursive: true });
|
|
26
|
+
const file = Bun.file(this.credentialsPath);
|
|
27
|
+
await Bun.write(file, JSON.stringify(config, null, 2));
|
|
28
|
+
await Bun.spawn(['chmod', '0600', this.credentialsPath]).exited;
|
|
29
|
+
}
|
|
30
|
+
async getToken() {
|
|
31
|
+
const config = await this.load();
|
|
32
|
+
return config.token;
|
|
33
|
+
}
|
|
34
|
+
async setToken(token) {
|
|
35
|
+
const config = await this.load();
|
|
36
|
+
config.token = token;
|
|
37
|
+
await this.save(config);
|
|
38
|
+
}
|
|
39
|
+
async clearToken() {
|
|
40
|
+
const config = await this.load();
|
|
41
|
+
config.token = null;
|
|
42
|
+
await this.save(config);
|
|
43
|
+
}
|
|
44
|
+
async getCurrentGuild() {
|
|
45
|
+
const config = await this.load();
|
|
46
|
+
return config.current_guild;
|
|
47
|
+
}
|
|
48
|
+
async setCurrentGuild(guildId) {
|
|
49
|
+
const config = await this.load();
|
|
50
|
+
config.current_guild = guildId;
|
|
51
|
+
await this.save(config);
|
|
52
|
+
}
|
|
53
|
+
async getGuilds() {
|
|
54
|
+
const config = await this.load();
|
|
55
|
+
return config.guilds;
|
|
56
|
+
}
|
|
57
|
+
async setGuilds(guilds) {
|
|
58
|
+
const config = await this.load();
|
|
59
|
+
config.guilds = guilds;
|
|
60
|
+
await this.save(config);
|
|
61
|
+
}
|
|
62
|
+
async getCredentials() {
|
|
63
|
+
const config = await this.load();
|
|
64
|
+
if (!config.token || !config.current_guild) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
token: config.token,
|
|
69
|
+
guildId: config.current_guild,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=credential-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credential-manager.js","sourceRoot":"","sources":["../../../../src/platforms/discord/credential-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAQhC,MAAM,OAAO,wBAAwB;IAC3B,SAAS,CAAQ;IACjB,eAAe,CAAQ;IAE/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AA;QACb,CAAC;QAED,OAAO;YACL,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,OAAO,EAAE,MAAM,CAAC,aAAa;SAC9B,CAAA;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credential-manager.test.d.ts","sourceRoot":"","sources":["../../../../src/platforms/discord/credential-manager.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { afterEach, beforeEach, expect, test } from 'bun:test';
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
|
+
import { rm } from 'node:fs/promises';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
import { DiscordCredentialManager } from './credential-manager';
|
|
6
|
+
const TEST_CONFIG_DIR = '/tmp/discord-test-config';
|
|
7
|
+
beforeEach(async () => {
|
|
8
|
+
if (existsSync(TEST_CONFIG_DIR)) {
|
|
9
|
+
await rm(TEST_CONFIG_DIR, { recursive: true });
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
afterEach(async () => {
|
|
13
|
+
if (existsSync(TEST_CONFIG_DIR)) {
|
|
14
|
+
await rm(TEST_CONFIG_DIR, { recursive: true });
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
test('load returns default config when file does not exist', async () => {
|
|
18
|
+
const manager = new DiscordCredentialManager(TEST_CONFIG_DIR);
|
|
19
|
+
const config = await manager.load();
|
|
20
|
+
expect(config).toEqual({
|
|
21
|
+
token: null,
|
|
22
|
+
current_guild: null,
|
|
23
|
+
guilds: {},
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
test('save creates config file with correct permissions', async () => {
|
|
27
|
+
const manager = new DiscordCredentialManager(TEST_CONFIG_DIR);
|
|
28
|
+
const config = {
|
|
29
|
+
token: 'test-token',
|
|
30
|
+
current_guild: 'guild-123',
|
|
31
|
+
guilds: {
|
|
32
|
+
'guild-123': { guild_id: 'guild-123', guild_name: 'Test Guild' },
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
await manager.save(config);
|
|
36
|
+
const credentialsPath = join(TEST_CONFIG_DIR, 'discord-credentials.json');
|
|
37
|
+
expect(existsSync(credentialsPath)).toBe(true);
|
|
38
|
+
const file = Bun.file(credentialsPath);
|
|
39
|
+
const content = await file.text();
|
|
40
|
+
const loaded = JSON.parse(content);
|
|
41
|
+
expect(loaded).toEqual(config);
|
|
42
|
+
});
|
|
43
|
+
test('getToken returns null when not authenticated', async () => {
|
|
44
|
+
const manager = new DiscordCredentialManager(TEST_CONFIG_DIR);
|
|
45
|
+
const token = await manager.getToken();
|
|
46
|
+
expect(token).toBeNull();
|
|
47
|
+
});
|
|
48
|
+
test('setToken saves token to config', async () => {
|
|
49
|
+
const manager = new DiscordCredentialManager(TEST_CONFIG_DIR);
|
|
50
|
+
await manager.setToken('test-token-123');
|
|
51
|
+
const token = await manager.getToken();
|
|
52
|
+
expect(token).toBe('test-token-123');
|
|
53
|
+
});
|
|
54
|
+
test('getToken returns previously set token', async () => {
|
|
55
|
+
const manager = new DiscordCredentialManager(TEST_CONFIG_DIR);
|
|
56
|
+
await manager.setToken('my-token');
|
|
57
|
+
const token = await manager.getToken();
|
|
58
|
+
expect(token).toBe('my-token');
|
|
59
|
+
});
|
|
60
|
+
test('clearToken removes token from config', async () => {
|
|
61
|
+
const manager = new DiscordCredentialManager(TEST_CONFIG_DIR);
|
|
62
|
+
await manager.setToken('test-token');
|
|
63
|
+
await manager.clearToken();
|
|
64
|
+
const token = await manager.getToken();
|
|
65
|
+
expect(token).toBeNull();
|
|
66
|
+
});
|
|
67
|
+
test('getCurrentGuild returns null when not set', async () => {
|
|
68
|
+
const manager = new DiscordCredentialManager(TEST_CONFIG_DIR);
|
|
69
|
+
const guild = await manager.getCurrentGuild();
|
|
70
|
+
expect(guild).toBeNull();
|
|
71
|
+
});
|
|
72
|
+
test('setCurrentGuild saves guild id', async () => {
|
|
73
|
+
const manager = new DiscordCredentialManager(TEST_CONFIG_DIR);
|
|
74
|
+
await manager.setCurrentGuild('guild-456');
|
|
75
|
+
const guild = await manager.getCurrentGuild();
|
|
76
|
+
expect(guild).toBe('guild-456');
|
|
77
|
+
});
|
|
78
|
+
test('getGuilds returns empty object when no guilds set', async () => {
|
|
79
|
+
const manager = new DiscordCredentialManager(TEST_CONFIG_DIR);
|
|
80
|
+
const guilds = await manager.getGuilds();
|
|
81
|
+
expect(guilds).toEqual({});
|
|
82
|
+
});
|
|
83
|
+
test('setGuilds saves guilds to config', async () => {
|
|
84
|
+
const manager = new DiscordCredentialManager(TEST_CONFIG_DIR);
|
|
85
|
+
const guilds = {
|
|
86
|
+
'guild-1': { guild_id: 'guild-1', guild_name: 'Guild One' },
|
|
87
|
+
'guild-2': { guild_id: 'guild-2', guild_name: 'Guild Two' },
|
|
88
|
+
};
|
|
89
|
+
await manager.setGuilds(guilds);
|
|
90
|
+
const loaded = await manager.getGuilds();
|
|
91
|
+
expect(loaded).toEqual(guilds);
|
|
92
|
+
});
|
|
93
|
+
test('getCredentials returns null when not authenticated', async () => {
|
|
94
|
+
const manager = new DiscordCredentialManager(TEST_CONFIG_DIR);
|
|
95
|
+
const creds = await manager.getCredentials();
|
|
96
|
+
expect(creds).toBeNull();
|
|
97
|
+
});
|
|
98
|
+
test('getCredentials returns null when token exists but no guild selected', async () => {
|
|
99
|
+
const manager = new DiscordCredentialManager(TEST_CONFIG_DIR);
|
|
100
|
+
await manager.setToken('test-token');
|
|
101
|
+
const creds = await manager.getCredentials();
|
|
102
|
+
expect(creds).toBeNull();
|
|
103
|
+
});
|
|
104
|
+
test('getCredentials returns null when guild selected but no token', async () => {
|
|
105
|
+
const manager = new DiscordCredentialManager(TEST_CONFIG_DIR);
|
|
106
|
+
await manager.setCurrentGuild('guild-123');
|
|
107
|
+
const creds = await manager.getCredentials();
|
|
108
|
+
expect(creds).toBeNull();
|
|
109
|
+
});
|
|
110
|
+
test('getCredentials returns token and guildId when both are set', async () => {
|
|
111
|
+
const manager = new DiscordCredentialManager(TEST_CONFIG_DIR);
|
|
112
|
+
await manager.setToken('test-token-xyz');
|
|
113
|
+
await manager.setCurrentGuild('guild-789');
|
|
114
|
+
const creds = await manager.getCredentials();
|
|
115
|
+
expect(creds).toEqual({
|
|
116
|
+
token: 'test-token-xyz',
|
|
117
|
+
guildId: 'guild-789',
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
test('multiple operations preserve existing data', async () => {
|
|
121
|
+
const manager = new DiscordCredentialManager(TEST_CONFIG_DIR);
|
|
122
|
+
// Set initial data
|
|
123
|
+
await manager.setToken('token-1');
|
|
124
|
+
await manager.setCurrentGuild('guild-1');
|
|
125
|
+
const guilds = {
|
|
126
|
+
'guild-1': { guild_id: 'guild-1', guild_name: 'Guild One' },
|
|
127
|
+
};
|
|
128
|
+
await manager.setGuilds(guilds);
|
|
129
|
+
// Update token
|
|
130
|
+
await manager.setToken('token-2');
|
|
131
|
+
// Verify all data is preserved
|
|
132
|
+
expect(await manager.getToken()).toBe('token-2');
|
|
133
|
+
expect(await manager.getCurrentGuild()).toBe('guild-1');
|
|
134
|
+
expect(await manager.getGuilds()).toEqual(guilds);
|
|
135
|
+
});
|
|
136
|
+
//# sourceMappingURL=credential-manager.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credential-manager.test.js","sourceRoot":"","sources":["../../../../src/platforms/discord/credential-manager.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAA;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAA;AAE/D,MAAM,eAAe,GAAG,0BAA0B,CAAA;AAElD,UAAU,CAAC,KAAK,IAA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CAAA;AACnD,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export interface ExtractedDiscordToken {
|
|
2
|
+
token: string;
|
|
3
|
+
}
|
|
4
|
+
export type DiscordVariant = 'stable' | 'canary' | 'ptb';
|
|
5
|
+
interface KeychainVariant {
|
|
6
|
+
service: string;
|
|
7
|
+
account: string;
|
|
8
|
+
}
|
|
9
|
+
interface CDPTarget {
|
|
10
|
+
id: string;
|
|
11
|
+
type: string;
|
|
12
|
+
title: string;
|
|
13
|
+
url: string;
|
|
14
|
+
webSocketDebuggerUrl: string;
|
|
15
|
+
}
|
|
16
|
+
export declare const CDP_PORT = 9222;
|
|
17
|
+
export declare const CDP_TIMEOUT = 5000;
|
|
18
|
+
export declare const DISCORD_STARTUP_WAIT = 4000;
|
|
19
|
+
export declare const TOKEN_EXTRACTION_JS = "(webpackChunkdiscord_app.push([[''], {}, e => { m = []; for (let c in e.c) m.push(e.c[c]); }]), m).find(m => m?.exports?.default?.getToken !== void 0).exports.default.getToken()";
|
|
20
|
+
export declare class DiscordTokenExtractor {
|
|
21
|
+
private platform;
|
|
22
|
+
private startupWait;
|
|
23
|
+
private killWait;
|
|
24
|
+
constructor(platform?: NodeJS.Platform, startupWait?: number, killWait?: number);
|
|
25
|
+
getDiscordDirs(): string[];
|
|
26
|
+
getKeychainVariants(): KeychainVariant[];
|
|
27
|
+
getVariantFromPath(path: string): DiscordVariant;
|
|
28
|
+
isValidToken(token: string): boolean;
|
|
29
|
+
isEncryptedToken(token: string): boolean;
|
|
30
|
+
extract(): Promise<ExtractedDiscordToken | null>;
|
|
31
|
+
private tryExtractViaCDP;
|
|
32
|
+
private extractFromLevelDB;
|
|
33
|
+
private extractFromDir;
|
|
34
|
+
private extractTokensFromLDBFiles;
|
|
35
|
+
private extractTokensFromBuffer;
|
|
36
|
+
private decryptToken;
|
|
37
|
+
private decryptWindowsToken;
|
|
38
|
+
private decryptDPAPI;
|
|
39
|
+
private decryptMacToken;
|
|
40
|
+
private decryptAESCBC;
|
|
41
|
+
private decryptAESGCM;
|
|
42
|
+
isDiscordRunning(variant?: DiscordVariant): Promise<boolean>;
|
|
43
|
+
private getProcessName;
|
|
44
|
+
private checkProcessRunning;
|
|
45
|
+
killDiscord(variant?: DiscordVariant): Promise<void>;
|
|
46
|
+
private killProcess;
|
|
47
|
+
launchDiscordWithDebug(variant: DiscordVariant, port?: number): Promise<void>;
|
|
48
|
+
private getAppPath;
|
|
49
|
+
discoverCDPTargets(port?: number): Promise<CDPTarget[]>;
|
|
50
|
+
findDiscordPageTarget(targets: CDPTarget[]): CDPTarget | null;
|
|
51
|
+
executeJSViaCDP(webSocketUrl: string, expression: string): Promise<unknown>;
|
|
52
|
+
extractViaCDP(port?: number): Promise<string | null>;
|
|
53
|
+
}
|
|
54
|
+
export {};
|
|
55
|
+
//# sourceMappingURL=token-extractor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token-extractor.d.ts","sourceRoot":"","sources":["../../../../src/platforms/discord/token-extractor.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,MAAM,CAAA;CACd;AAED,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,QAAQ,GAAG,KAAK,CAAA;AAExD,UAAU,eAAe;IACvB,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,UAAU,SAAS;IACjB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;IACX,oBAAoB,EAAE,MAAM,CAAA;CAC7B;AAcD,eAAO,MAAM,QAAQ,OAAO,CAAA;AAC5B,eAAO,MAAM,WAAW,OAAO,CAAA;AAC/B,eAAO,MAAM,oBAAoB,OAAO,CAAA;AACxC,eAAO,MAAM,mBAAmB,sLAAsL,CAAA;AAiBtN,qBAAa,qBAAq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