agent-messenger 2.6.3 → 2.8.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-plugin/plugin.json +1 -1
- package/.github/workflows/ci.yml +6 -0
- package/.oxfmtrc.json +13 -1
- package/.oxlintrc.json +10 -1
- package/README.md +1 -1
- package/dist/package.json +59 -58
- package/dist/src/platforms/channeltalk/client.d.ts.map +1 -1
- package/dist/src/platforms/channeltalk/client.js +2 -2
- package/dist/src/platforms/channeltalk/client.js.map +1 -1
- package/dist/src/platforms/channeltalk/commands/auth.d.ts.map +1 -1
- package/dist/src/platforms/channeltalk/commands/auth.js.map +1 -1
- package/dist/src/platforms/channeltalk/commands/message.d.ts.map +1 -1
- package/dist/src/platforms/channeltalk/commands/message.js.map +1 -1
- package/dist/src/platforms/channeltalk/commands/snapshot.d.ts.map +1 -1
- package/dist/src/platforms/channeltalk/commands/snapshot.js.map +1 -1
- package/dist/src/platforms/channeltalk/ensure-auth.d.ts.map +1 -1
- package/dist/src/platforms/channeltalk/ensure-auth.js.map +1 -1
- package/dist/src/platforms/channeltalk/token-extractor.d.ts +9 -23
- package/dist/src/platforms/channeltalk/token-extractor.d.ts.map +1 -1
- package/dist/src/platforms/channeltalk/token-extractor.js +109 -341
- package/dist/src/platforms/channeltalk/token-extractor.js.map +1 -1
- package/dist/src/platforms/channeltalkbot/client.d.ts +1 -1
- package/dist/src/platforms/channeltalkbot/client.d.ts.map +1 -1
- package/dist/src/platforms/channeltalkbot/client.js +4 -4
- package/dist/src/platforms/channeltalkbot/client.js.map +1 -1
- package/dist/src/platforms/channeltalkbot/commands/auth.d.ts.map +1 -1
- package/dist/src/platforms/channeltalkbot/commands/auth.js +4 -1
- package/dist/src/platforms/channeltalkbot/commands/auth.js.map +1 -1
- package/dist/src/platforms/channeltalkbot/commands/shared.d.ts.map +1 -1
- package/dist/src/platforms/channeltalkbot/commands/shared.js.map +1 -1
- package/dist/src/platforms/discord/commands/auth.js.map +1 -1
- package/dist/src/platforms/discord/commands/whoami.d.ts.map +1 -1
- package/dist/src/platforms/discord/commands/whoami.js.map +1 -1
- package/dist/src/platforms/discord/token-extractor.d.ts +2 -10
- package/dist/src/platforms/discord/token-extractor.d.ts.map +1 -1
- package/dist/src/platforms/discord/token-extractor.js +38 -172
- package/dist/src/platforms/discord/token-extractor.js.map +1 -1
- package/dist/src/platforms/discordbot/client.d.ts.map +1 -1
- package/dist/src/platforms/discordbot/client.js.map +1 -1
- package/dist/src/platforms/instagram/cli.d.ts.map +1 -1
- package/dist/src/platforms/instagram/cli.js +1 -4
- package/dist/src/platforms/instagram/cli.js.map +1 -1
- package/dist/src/platforms/instagram/client.d.ts.map +1 -1
- package/dist/src/platforms/instagram/client.js +8 -7
- package/dist/src/platforms/instagram/client.js.map +1 -1
- package/dist/src/platforms/instagram/commands/auth.d.ts.map +1 -1
- package/dist/src/platforms/instagram/commands/auth.js.map +1 -1
- package/dist/src/platforms/instagram/commands/chat.d.ts.map +1 -1
- package/dist/src/platforms/instagram/commands/chat.js.map +1 -1
- package/dist/src/platforms/instagram/commands/message.d.ts.map +1 -1
- package/dist/src/platforms/instagram/commands/message.js.map +1 -1
- package/dist/src/platforms/instagram/commands/shared.d.ts.map +1 -1
- package/dist/src/platforms/instagram/commands/shared.js.map +1 -1
- package/dist/src/platforms/instagram/credential-manager.d.ts.map +1 -1
- package/dist/src/platforms/instagram/credential-manager.js +1 -1
- package/dist/src/platforms/instagram/credential-manager.js.map +1 -1
- package/dist/src/platforms/instagram/ensure-auth.d.ts.map +1 -1
- package/dist/src/platforms/instagram/ensure-auth.js.map +1 -1
- package/dist/src/platforms/instagram/token-extractor.d.ts +7 -19
- package/dist/src/platforms/instagram/token-extractor.d.ts.map +1 -1
- package/dist/src/platforms/instagram/token-extractor.js +44 -270
- package/dist/src/platforms/instagram/token-extractor.js.map +1 -1
- package/dist/src/platforms/instagram/types.d.ts.map +1 -1
- package/dist/src/platforms/instagram/types.js +4 -2
- package/dist/src/platforms/instagram/types.js.map +1 -1
- package/dist/src/platforms/kakaotalk/auth/kakao-login.d.ts.map +1 -1
- package/dist/src/platforms/kakaotalk/auth/kakao-login.js +18 -4
- package/dist/src/platforms/kakaotalk/auth/kakao-login.js.map +1 -1
- package/dist/src/platforms/kakaotalk/client.d.ts.map +1 -1
- package/dist/src/platforms/kakaotalk/client.js +3 -3
- package/dist/src/platforms/kakaotalk/client.js.map +1 -1
- package/dist/src/platforms/kakaotalk/commands/auth.d.ts.map +1 -1
- package/dist/src/platforms/kakaotalk/commands/auth.js +15 -9
- package/dist/src/platforms/kakaotalk/commands/auth.js.map +1 -1
- package/dist/src/platforms/kakaotalk/commands/shared.d.ts.map +1 -1
- package/dist/src/platforms/kakaotalk/commands/shared.js.map +1 -1
- package/dist/src/platforms/kakaotalk/protocol/connection.d.ts.map +1 -1
- package/dist/src/platforms/kakaotalk/protocol/connection.js.map +1 -1
- package/dist/src/platforms/kakaotalk/protocol/crypto.js +1 -1
- package/dist/src/platforms/kakaotalk/protocol/crypto.js.map +1 -1
- package/dist/src/platforms/kakaotalk/protocol/session.d.ts.map +1 -1
- package/dist/src/platforms/kakaotalk/protocol/session.js +1 -3
- package/dist/src/platforms/kakaotalk/protocol/session.js.map +1 -1
- package/dist/src/platforms/kakaotalk/token-extractor.js +5 -2
- package/dist/src/platforms/kakaotalk/token-extractor.js.map +1 -1
- package/dist/src/platforms/kakaotalk/types.d.ts.map +1 -1
- package/dist/src/platforms/kakaotalk/types.js +4 -2
- package/dist/src/platforms/kakaotalk/types.js.map +1 -1
- package/dist/src/platforms/line/cli.d.ts.map +1 -1
- package/dist/src/platforms/line/cli.js +1 -4
- package/dist/src/platforms/line/cli.js.map +1 -1
- package/dist/src/platforms/line/client.d.ts.map +1 -1
- package/dist/src/platforms/line/client.js +5 -13
- package/dist/src/platforms/line/client.js.map +1 -1
- package/dist/src/platforms/line/commands/chat.d.ts.map +1 -1
- package/dist/src/platforms/line/commands/chat.js.map +1 -1
- package/dist/src/platforms/line/commands/message.d.ts.map +1 -1
- package/dist/src/platforms/line/commands/message.js.map +1 -1
- package/dist/src/platforms/line/listener.js +1 -1
- package/dist/src/platforms/line/listener.js.map +1 -1
- package/dist/src/platforms/slack/cli.d.ts.map +1 -1
- package/dist/src/platforms/slack/cli.js.map +1 -1
- package/dist/src/platforms/slack/client-mappers.d.ts +14 -0
- package/dist/src/platforms/slack/client-mappers.d.ts.map +1 -0
- package/dist/src/platforms/slack/client-mappers.js +245 -0
- package/dist/src/platforms/slack/client-mappers.js.map +1 -0
- package/dist/src/platforms/slack/client.d.ts +0 -1
- package/dist/src/platforms/slack/client.d.ts.map +1 -1
- package/dist/src/platforms/slack/client.js +41 -455
- package/dist/src/platforms/slack/client.js.map +1 -1
- package/dist/src/platforms/slack/commands/channel.d.ts.map +1 -1
- package/dist/src/platforms/slack/commands/channel.js.map +1 -1
- package/dist/src/platforms/slack/commands/emoji.d.ts.map +1 -1
- package/dist/src/platforms/slack/commands/emoji.js +1 -3
- package/dist/src/platforms/slack/commands/emoji.js.map +1 -1
- package/dist/src/platforms/slack/commands/message.d.ts.map +1 -1
- package/dist/src/platforms/slack/commands/message.js.map +1 -1
- package/dist/src/platforms/slack/commands/reminder.d.ts.map +1 -1
- package/dist/src/platforms/slack/commands/reminder.js.map +1 -1
- package/dist/src/platforms/slack/commands/user.d.ts.map +1 -1
- package/dist/src/platforms/slack/commands/user.js.map +1 -1
- package/dist/src/platforms/slack/commands/usergroup.d.ts.map +1 -1
- package/dist/src/platforms/slack/commands/usergroup.js.map +1 -1
- package/dist/src/platforms/slack/commands/whoami.d.ts.map +1 -1
- package/dist/src/platforms/slack/commands/whoami.js.map +1 -1
- package/dist/src/platforms/slack/token-extractor.d.ts +2 -6
- package/dist/src/platforms/slack/token-extractor.d.ts.map +1 -1
- package/dist/src/platforms/slack/token-extractor.js +35 -229
- package/dist/src/platforms/slack/token-extractor.js.map +1 -1
- package/dist/src/platforms/slackbot/cli.d.ts.map +1 -1
- package/dist/src/platforms/slackbot/cli.js +1 -1
- package/dist/src/platforms/slackbot/cli.js.map +1 -1
- package/dist/src/platforms/teams/client.d.ts.map +1 -1
- package/dist/src/platforms/teams/client.js +1 -1
- package/dist/src/platforms/teams/client.js.map +1 -1
- package/dist/src/platforms/teams/commands/auth.d.ts.map +1 -1
- package/dist/src/platforms/teams/commands/auth.js +4 -1
- package/dist/src/platforms/teams/commands/auth.js.map +1 -1
- package/dist/src/platforms/teams/commands/whoami.d.ts.map +1 -1
- package/dist/src/platforms/teams/commands/whoami.js.map +1 -1
- package/dist/src/platforms/teams/token-extractor.d.ts +6 -18
- package/dist/src/platforms/teams/token-extractor.d.ts.map +1 -1
- package/dist/src/platforms/teams/token-extractor.js +71 -324
- package/dist/src/platforms/teams/token-extractor.js.map +1 -1
- package/dist/src/platforms/telegram/cli.d.ts.map +1 -1
- package/dist/src/platforms/telegram/cli.js +1 -4
- package/dist/src/platforms/telegram/cli.js.map +1 -1
- package/dist/src/platforms/telegram/client.d.ts.map +1 -1
- package/dist/src/platforms/telegram/client.js.map +1 -1
- package/dist/src/platforms/telegram/commands/auth.d.ts.map +1 -1
- package/dist/src/platforms/telegram/commands/auth.js +1 -1
- package/dist/src/platforms/telegram/commands/auth.js.map +1 -1
- package/dist/src/platforms/telegram/commands/chat.d.ts.map +1 -1
- package/dist/src/platforms/telegram/commands/chat.js.map +1 -1
- package/dist/src/platforms/telegram/commands/message.d.ts.map +1 -1
- package/dist/src/platforms/telegram/commands/message.js.map +1 -1
- package/dist/src/platforms/telegram/commands/whoami.js +1 -1
- package/dist/src/platforms/telegram/commands/whoami.js.map +1 -1
- package/dist/src/platforms/telegram/credential-manager.d.ts.map +1 -1
- package/dist/src/platforms/telegram/credential-manager.js +6 -2
- package/dist/src/platforms/telegram/credential-manager.js.map +1 -1
- package/dist/src/platforms/telegram/my-telegram-org.js.map +1 -1
- package/dist/src/platforms/webex/cli.d.ts.map +1 -1
- package/dist/src/platforms/webex/cli.js +1 -4
- package/dist/src/platforms/webex/cli.js.map +1 -1
- package/dist/src/platforms/webex/client.d.ts.map +1 -1
- package/dist/src/platforms/webex/client.js +19 -15
- package/dist/src/platforms/webex/client.js.map +1 -1
- package/dist/src/platforms/webex/commands/auth.d.ts.map +1 -1
- package/dist/src/platforms/webex/commands/auth.js +1 -3
- package/dist/src/platforms/webex/commands/auth.js.map +1 -1
- package/dist/src/platforms/webex/commands/member.d.ts.map +1 -1
- package/dist/src/platforms/webex/commands/member.js +1 -3
- package/dist/src/platforms/webex/commands/member.js.map +1 -1
- package/dist/src/platforms/webex/commands/message.d.ts.map +1 -1
- package/dist/src/platforms/webex/commands/message.js.map +1 -1
- package/dist/src/platforms/webex/commands/snapshot.d.ts.map +1 -1
- package/dist/src/platforms/webex/commands/snapshot.js.map +1 -1
- package/dist/src/platforms/webex/commands/space.d.ts.map +1 -1
- package/dist/src/platforms/webex/commands/space.js.map +1 -1
- package/dist/src/platforms/webex/commands/whoami.d.ts.map +1 -1
- package/dist/src/platforms/webex/commands/whoami.js.map +1 -1
- package/dist/src/platforms/webex/credential-manager.d.ts.map +1 -1
- package/dist/src/platforms/webex/credential-manager.js.map +1 -1
- package/dist/src/platforms/webex/ensure-auth.d.ts.map +1 -1
- package/dist/src/platforms/webex/ensure-auth.js +1 -3
- package/dist/src/platforms/webex/ensure-auth.js.map +1 -1
- package/dist/src/platforms/webex/index.d.ts +1 -1
- package/dist/src/platforms/webex/index.d.ts.map +1 -1
- package/dist/src/platforms/webex/index.js.map +1 -1
- package/dist/src/platforms/webex/markdown-to-html.d.ts +3 -0
- package/dist/src/platforms/webex/markdown-to-html.d.ts.map +1 -0
- package/dist/src/platforms/webex/markdown-to-html.js +161 -0
- package/dist/src/platforms/webex/markdown-to-html.js.map +1 -0
- package/dist/src/platforms/webex/token-extractor.d.ts.map +1 -1
- package/dist/src/platforms/webex/token-extractor.js +5 -14
- package/dist/src/platforms/webex/token-extractor.js.map +1 -1
- package/dist/src/platforms/wechatbot/client.d.ts.map +1 -1
- package/dist/src/platforms/wechatbot/client.js.map +1 -1
- package/dist/src/platforms/wechatbot/commands/message.d.ts.map +1 -1
- package/dist/src/platforms/wechatbot/commands/message.js.map +1 -1
- package/dist/src/platforms/whatsapp/cli.d.ts.map +1 -1
- package/dist/src/platforms/whatsapp/cli.js +1 -4
- package/dist/src/platforms/whatsapp/cli.js.map +1 -1
- package/dist/src/platforms/whatsapp/commands/chat.d.ts.map +1 -1
- package/dist/src/platforms/whatsapp/commands/chat.js.map +1 -1
- package/dist/src/platforms/whatsapp/commands/message.d.ts.map +1 -1
- package/dist/src/platforms/whatsapp/commands/message.js.map +1 -1
- package/dist/src/platforms/whatsapp/commands/shared.d.ts.map +1 -1
- package/dist/src/platforms/whatsapp/commands/shared.js.map +1 -1
- package/dist/src/platforms/whatsapp/credential-manager.d.ts.map +1 -1
- package/dist/src/platforms/whatsapp/credential-manager.js +1 -1
- package/dist/src/platforms/whatsapp/credential-manager.js.map +1 -1
- package/dist/src/platforms/whatsapp/ensure-auth.d.ts.map +1 -1
- package/dist/src/platforms/whatsapp/ensure-auth.js.map +1 -1
- package/dist/src/platforms/whatsappbot/client.d.ts.map +1 -1
- package/dist/src/platforms/whatsappbot/client.js +2 -2
- package/dist/src/platforms/whatsappbot/client.js.map +1 -1
- package/dist/src/platforms/whatsappbot/commands/auth.d.ts.map +1 -1
- package/dist/src/platforms/whatsappbot/commands/auth.js +4 -1
- package/dist/src/platforms/whatsappbot/commands/auth.js.map +1 -1
- package/dist/src/platforms/whatsappbot/commands/message.d.ts.map +1 -1
- package/dist/src/platforms/whatsappbot/commands/message.js.map +1 -1
- package/dist/src/platforms/whatsappbot/commands/shared.d.ts.map +1 -1
- package/dist/src/platforms/whatsappbot/commands/shared.js.map +1 -1
- package/dist/src/shared/chromium/browsers.d.ts +7 -0
- package/dist/src/shared/chromium/browsers.d.ts.map +1 -0
- package/dist/src/shared/chromium/browsers.js +89 -0
- package/dist/src/shared/chromium/browsers.js.map +1 -0
- package/dist/src/shared/chromium/cookie-reader.d.ts +20 -0
- package/dist/src/shared/chromium/cookie-reader.d.ts.map +1 -0
- package/dist/src/shared/chromium/cookie-reader.js +99 -0
- package/dist/src/shared/chromium/cookie-reader.js.map +1 -0
- package/dist/src/shared/chromium/decryptor.d.ts +42 -0
- package/dist/src/shared/chromium/decryptor.d.ts.map +1 -0
- package/dist/src/shared/chromium/decryptor.js +205 -0
- package/dist/src/shared/chromium/decryptor.js.map +1 -0
- package/dist/src/shared/chromium/index.d.ts +6 -0
- package/dist/src/shared/chromium/index.d.ts.map +1 -0
- package/dist/src/shared/chromium/index.js +4 -0
- package/dist/src/shared/chromium/index.js.map +1 -0
- package/dist/src/shared/chromium/types.d.ts +11 -0
- package/dist/src/shared/chromium/types.d.ts.map +1 -0
- package/dist/src/shared/chromium/types.js +2 -0
- package/dist/src/shared/chromium/types.js.map +1 -0
- package/dist/src/shared/utils/derived-key-cache.d.ts +1 -1
- package/dist/src/shared/utils/derived-key-cache.d.ts.map +1 -1
- package/dist/src/shared/utils/linux-keyring.js +4 -1
- package/dist/src/shared/utils/linux-keyring.js.map +1 -1
- package/dist/src/tui/adapters/kakaotalk-adapter.d.ts.map +1 -1
- package/dist/src/tui/adapters/kakaotalk-adapter.js +6 -1
- package/dist/src/tui/adapters/kakaotalk-adapter.js.map +1 -1
- package/dist/src/tui/adapters/telegram-adapter.js +1 -1
- package/dist/src/tui/adapters/telegram-adapter.js.map +1 -1
- package/dist/src/tui/adapters/webex-adapter.js +1 -1
- package/dist/src/tui/adapters/webex-adapter.js.map +1 -1
- package/dist/src/tui/app.d.ts.map +1 -1
- package/dist/src/tui/app.js +112 -23
- package/dist/src/tui/app.js.map +1 -1
- package/dist/src/tui/utils.d.ts.map +1 -1
- package/dist/src/tui/utils.js +11 -13
- package/dist/src/tui/utils.js.map +1 -1
- package/dist/src/tui/views/channel-picker.d.ts.map +1 -1
- package/dist/src/tui/views/channel-picker.js.map +1 -1
- package/dist/src/tui/views/workspace-picker.d.ts.map +1 -1
- package/dist/src/tui/views/workspace-picker.js.map +1 -1
- package/docs/content/docs/cli/channeltalk.mdx +24 -22
- package/docs/content/docs/cli/channeltalkbot.mdx +7 -7
- package/docs/content/docs/cli/instagram.mdx +4 -4
- package/docs/content/docs/cli/kakaotalk.mdx +9 -8
- package/docs/content/docs/cli/line.mdx +14 -14
- package/docs/content/docs/cli/webex.mdx +19 -19
- package/docs/content/docs/cli/wechatbot.mdx +12 -11
- package/docs/content/docs/cli/whatsapp.mdx +5 -4
- package/docs/content/docs/cli/whatsappbot.mdx +11 -11
- package/docs/content/docs/index.mdx +7 -7
- package/docs/content/docs/meta.json +1 -9
- package/docs/content/docs/sdk/channeltalk.mdx +5 -6
- package/docs/content/docs/sdk/channeltalkbot.mdx +6 -12
- package/docs/content/docs/sdk/discord.mdx +36 -43
- package/docs/content/docs/sdk/instagram.mdx +18 -18
- package/docs/content/docs/sdk/kakaotalk.mdx +27 -18
- package/docs/content/docs/sdk/line.mdx +8 -13
- package/docs/content/docs/sdk/meta.json +14 -1
- package/docs/content/docs/sdk/slack.mdx +36 -42
- package/docs/content/docs/sdk/teams.mdx +2 -8
- package/docs/content/docs/sdk/webex.mdx +2 -12
- package/docs/content/docs/sdk/wechatbot.mdx +1 -5
- package/docs/content/docs/sdk/whatsapp.mdx +10 -19
- package/docs/content/docs/sdk/whatsappbot.mdx +2 -10
- package/docs/content/docs/tui.mdx +23 -23
- package/docs/src/app/page.tsx +353 -108
- package/e2e/channeltalkbot.e2e.test.ts +1 -5
- package/e2e/config.ts +6 -2
- package/package.json +59 -58
- package/scripts/prepublish.ts +1 -3
- package/skills/agent-channeltalk/SKILL.md +1 -1
- package/skills/agent-channeltalkbot/SKILL.md +1 -1
- package/skills/agent-discord/SKILL.md +1 -1
- package/skills/agent-discordbot/SKILL.md +1 -1
- package/skills/agent-instagram/SKILL.md +1 -1
- package/skills/agent-kakaotalk/SKILL.md +1 -1
- package/skills/agent-line/SKILL.md +1 -1
- package/skills/agent-slack/SKILL.md +1 -1
- package/skills/agent-slackbot/SKILL.md +1 -1
- package/skills/agent-teams/SKILL.md +1 -1
- package/skills/agent-telegram/SKILL.md +1 -1
- package/skills/agent-webex/SKILL.md +1 -1
- package/skills/agent-wechatbot/SKILL.md +1 -1
- package/skills/agent-whatsapp/SKILL.md +1 -1
- package/skills/agent-whatsappbot/SKILL.md +1 -1
- package/src/platforms/channeltalk/client.test.ts +116 -29
- package/src/platforms/channeltalk/client.ts +26 -6
- package/src/platforms/channeltalk/commands/auth.test.ts +5 -5
- package/src/platforms/channeltalk/commands/auth.ts +19 -5
- package/src/platforms/channeltalk/commands/message.test.ts +2 -6
- package/src/platforms/channeltalk/commands/message.ts +5 -1
- package/src/platforms/channeltalk/commands/snapshot.test.ts +19 -4
- package/src/platforms/channeltalk/commands/snapshot.ts +5 -1
- package/src/platforms/channeltalk/ensure-auth.test.ts +20 -17
- package/src/platforms/channeltalk/ensure-auth.ts +6 -7
- package/src/platforms/channeltalk/index.ts +0 -1
- package/src/platforms/channeltalk/token-extractor.test.ts +33 -25
- package/src/platforms/channeltalk/token-extractor.ts +120 -372
- package/src/platforms/channeltalkbot/client.test.ts +1 -3
- package/src/platforms/channeltalkbot/client.ts +39 -13
- package/src/platforms/channeltalkbot/commands/auth.test.ts +3 -1
- package/src/platforms/channeltalkbot/commands/auth.ts +4 -1
- package/src/platforms/channeltalkbot/commands/bot.test.ts +13 -5
- package/src/platforms/channeltalkbot/commands/message.test.ts +12 -6
- package/src/platforms/channeltalkbot/commands/shared.ts +6 -2
- package/src/platforms/channeltalkbot/commands/snapshot.test.ts +17 -5
- package/src/platforms/channeltalkbot/credential-manager.test.ts +1 -1
- package/src/platforms/channeltalkbot/index.test.ts +0 -2
- package/src/platforms/channeltalkbot/index.ts +0 -1
- package/src/platforms/discord/commands/auth.test.ts +6 -4
- package/src/platforms/discord/commands/auth.ts +14 -14
- package/src/platforms/discord/commands/whoami.test.ts +2 -4
- package/src/platforms/discord/commands/whoami.ts +2 -0
- package/src/platforms/discord/ensure-auth.test.ts +5 -3
- package/src/platforms/discord/index.ts +0 -1
- package/src/platforms/discord/listener.test.ts +7 -1
- package/src/platforms/discord/token-extractor.test.ts +18 -12
- package/src/platforms/discord/token-extractor.ts +46 -190
- package/src/platforms/discordbot/client.ts +1 -4
- package/src/platforms/discordbot/commands/auth.test.ts +3 -1
- package/src/platforms/discordbot/commands/channel.test.ts +3 -1
- package/src/platforms/discordbot/commands/message.test.ts +3 -1
- package/src/platforms/discordbot/commands/server.test.ts +3 -1
- package/src/platforms/discordbot/commands/snapshot.test.ts +3 -1
- package/src/platforms/discordbot/commands/thread.test.ts +3 -1
- package/src/platforms/discordbot/commands/user.test.ts +3 -1
- package/src/platforms/instagram/cli.ts +1 -4
- package/src/platforms/instagram/client.test.ts +3 -8
- package/src/platforms/instagram/client.ts +39 -34
- package/src/platforms/instagram/commands/auth.test.ts +13 -12
- package/src/platforms/instagram/commands/auth.ts +136 -71
- package/src/platforms/instagram/commands/chat.test.ts +21 -24
- package/src/platforms/instagram/commands/chat.ts +2 -0
- package/src/platforms/instagram/commands/message.test.ts +29 -24
- package/src/platforms/instagram/commands/message.ts +3 -4
- package/src/platforms/instagram/commands/shared.ts +2 -5
- package/src/platforms/instagram/commands/whoami.test.ts +4 -6
- package/src/platforms/instagram/credential-manager.ts +2 -6
- package/src/platforms/instagram/ensure-auth.test.ts +1 -4
- package/src/platforms/instagram/ensure-auth.ts +6 -3
- package/src/platforms/instagram/listener.test.ts +7 -3
- package/src/platforms/instagram/token-extractor.test.ts +4 -16
- package/src/platforms/instagram/token-extractor.ts +55 -309
- package/src/platforms/instagram/types.test.ts +2 -6
- package/src/platforms/instagram/types.ts +4 -2
- package/src/platforms/kakaotalk/auth/kakao-login.ts +30 -8
- package/src/platforms/kakaotalk/client.test.ts +37 -25
- package/src/platforms/kakaotalk/client.ts +23 -12
- package/src/platforms/kakaotalk/commands/auth.test.ts +6 -18
- package/src/platforms/kakaotalk/commands/auth.ts +101 -47
- package/src/platforms/kakaotalk/commands/chat.test.ts +8 -11
- package/src/platforms/kakaotalk/commands/message.test.ts +15 -24
- package/src/platforms/kakaotalk/commands/shared.ts +1 -0
- package/src/platforms/kakaotalk/commands/whoami.test.ts +6 -10
- package/src/platforms/kakaotalk/credential-manager.test.ts +1 -4
- package/src/platforms/kakaotalk/index.test.ts +1 -0
- package/src/platforms/kakaotalk/index.ts +0 -2
- package/src/platforms/kakaotalk/listener.test.ts +7 -1
- package/src/platforms/kakaotalk/protocol/connection.ts +4 -1
- package/src/platforms/kakaotalk/protocol/crypto.ts +1 -1
- package/src/platforms/kakaotalk/protocol/session.ts +12 -6
- package/src/platforms/kakaotalk/token-extractor.ts +5 -5
- package/src/platforms/kakaotalk/types.ts +8 -7
- package/src/platforms/line/cli.ts +1 -4
- package/src/platforms/line/client.ts +12 -20
- package/src/platforms/line/commands/auth.test.ts +2 -1
- package/src/platforms/line/commands/chat.test.ts +2 -1
- package/src/platforms/line/commands/chat.ts +1 -4
- package/src/platforms/line/commands/friend.test.ts +2 -1
- package/src/platforms/line/commands/message.test.ts +2 -1
- package/src/platforms/line/commands/message.ts +2 -9
- package/src/platforms/line/commands/whoami.test.ts +2 -1
- package/src/platforms/line/credential-manager.test.ts +1 -2
- package/src/platforms/line/index.test.ts +1 -0
- package/src/platforms/line/listener.ts +1 -1
- package/src/platforms/line/types.test.ts +1 -0
- package/src/platforms/slack/cli.ts +3 -1
- package/src/platforms/slack/client-mappers.ts +297 -0
- package/src/platforms/slack/client.test.ts +532 -17
- package/src/platforms/slack/client.ts +69 -458
- package/src/platforms/slack/commands/channel.ts +1 -4
- package/src/platforms/slack/commands/emoji.test.ts +6 -4
- package/src/platforms/slack/commands/emoji.ts +20 -22
- package/src/platforms/slack/commands/message.ts +6 -1
- package/src/platforms/slack/commands/pin.test.ts +14 -12
- package/src/platforms/slack/commands/reminder.ts +7 -6
- package/src/platforms/slack/commands/user.ts +6 -1
- package/src/platforms/slack/commands/usergroup.test.ts +3 -3
- package/src/platforms/slack/commands/usergroup.ts +10 -7
- package/src/platforms/slack/commands/whoami.test.ts +1 -1
- package/src/platforms/slack/commands/whoami.ts +2 -0
- package/src/platforms/slack/index.ts +0 -2
- package/src/platforms/slack/listener.test.ts +1 -0
- package/src/platforms/slack/token-extractor.test.ts +7 -12
- package/src/platforms/slack/token-extractor.ts +47 -255
- package/src/platforms/slackbot/cli.ts +8 -1
- package/src/platforms/slackbot/commands/auth.test.ts +3 -1
- package/src/platforms/teams/client.ts +1 -1
- package/src/platforms/teams/commands/auth.test.ts +1 -1
- package/src/platforms/teams/commands/auth.ts +4 -1
- package/src/platforms/teams/commands/whoami.test.ts +2 -4
- package/src/platforms/teams/commands/whoami.ts +2 -0
- package/src/platforms/teams/index.ts +0 -1
- package/src/platforms/teams/token-extractor.ts +82 -350
- package/src/platforms/telegram/app-config.test.ts +1 -0
- package/src/platforms/telegram/chat-utils.test.ts +5 -1
- package/src/platforms/telegram/cli.ts +2 -4
- package/src/platforms/telegram/client.test.ts +16 -3
- package/src/platforms/telegram/client.ts +14 -4
- package/src/platforms/telegram/commands/auth.test.ts +1 -0
- package/src/platforms/telegram/commands/auth.ts +3 -4
- package/src/platforms/telegram/commands/chat.test.ts +2 -5
- package/src/platforms/telegram/commands/chat.ts +1 -0
- package/src/platforms/telegram/commands/message.test.ts +2 -5
- package/src/platforms/telegram/commands/message.ts +1 -0
- package/src/platforms/telegram/commands/shared.test.ts +1 -0
- package/src/platforms/telegram/commands/whoami.test.ts +5 -7
- package/src/platforms/telegram/commands/whoami.ts +1 -1
- package/src/platforms/telegram/credential-manager.test.ts +1 -0
- package/src/platforms/telegram/credential-manager.ts +11 -2
- package/src/platforms/telegram/my-telegram-org.ts +6 -2
- package/src/platforms/telegram/types.test.ts +1 -0
- package/src/platforms/webex/app-config.test.ts +1 -0
- package/src/platforms/webex/cli.ts +1 -4
- package/src/platforms/webex/client.test.ts +39 -12
- package/src/platforms/webex/client.ts +30 -61
- package/src/platforms/webex/commands/auth.test.ts +7 -1
- package/src/platforms/webex/commands/auth.ts +12 -15
- package/src/platforms/webex/commands/member.test.ts +1 -3
- package/src/platforms/webex/commands/member.ts +14 -19
- package/src/platforms/webex/commands/message.ts +4 -15
- package/src/platforms/webex/commands/snapshot.test.ts +28 -3
- package/src/platforms/webex/commands/snapshot.ts +3 -3
- package/src/platforms/webex/commands/space.test.ts +3 -3
- package/src/platforms/webex/commands/space.ts +2 -9
- package/src/platforms/webex/commands/whoami.test.ts +12 -5
- package/src/platforms/webex/commands/whoami.ts +2 -0
- package/src/platforms/webex/credential-manager.ts +11 -2
- package/src/platforms/webex/ensure-auth.ts +1 -3
- package/src/platforms/webex/index.ts +1 -7
- package/src/platforms/webex/markdown-to-html.test.ts +141 -0
- package/src/platforms/webex/markdown-to-html.ts +194 -0
- package/src/platforms/webex/token-extractor.ts +6 -29
- package/src/platforms/wechatbot/cli.ts +0 -0
- package/src/platforms/wechatbot/client.test.ts +6 -2
- package/src/platforms/wechatbot/client.ts +6 -1
- package/src/platforms/wechatbot/commands/auth.test.ts +3 -7
- package/src/platforms/wechatbot/commands/message.test.ts +1 -4
- package/src/platforms/wechatbot/commands/message.ts +5 -1
- package/src/platforms/wechatbot/commands/template.test.ts +1 -4
- package/src/platforms/wechatbot/commands/user.test.ts +2 -7
- package/src/platforms/whatsapp/cli.ts +1 -4
- package/src/platforms/whatsapp/commands/auth.test.ts +19 -22
- package/src/platforms/whatsapp/commands/chat.test.ts +21 -24
- package/src/platforms/whatsapp/commands/chat.ts +2 -0
- package/src/platforms/whatsapp/commands/message.test.ts +22 -24
- package/src/platforms/whatsapp/commands/message.ts +3 -5
- package/src/platforms/whatsapp/commands/shared.ts +2 -5
- package/src/platforms/whatsapp/commands/whoami.test.ts +2 -2
- package/src/platforms/whatsapp/credential-manager.ts +2 -6
- package/src/platforms/whatsapp/ensure-auth.test.ts +1 -4
- package/src/platforms/whatsapp/ensure-auth.ts +14 -6
- package/src/platforms/whatsapp/index.ts +0 -2
- package/src/platforms/whatsappbot/client.test.ts +13 -7
- package/src/platforms/whatsappbot/client.ts +18 -4
- package/src/platforms/whatsappbot/commands/auth.ts +4 -1
- package/src/platforms/whatsappbot/commands/message.test.ts +12 -2
- package/src/platforms/whatsappbot/commands/message.ts +16 -3
- package/src/platforms/whatsappbot/commands/shared.ts +3 -1
- package/src/platforms/whatsappbot/commands/whoami.test.ts +1 -3
- package/src/platforms/whatsappbot/index.ts +0 -2
- package/src/shared/chromium/browsers.test.ts +274 -0
- package/src/shared/chromium/browsers.ts +86 -0
- package/src/shared/chromium/cookie-reader.test.ts +274 -0
- package/src/shared/chromium/cookie-reader.ts +111 -0
- package/src/shared/chromium/decryptor.test.ts +449 -0
- package/src/shared/chromium/decryptor.ts +227 -0
- package/src/shared/chromium/index.ts +11 -0
- package/src/shared/chromium/types.ts +11 -0
- package/src/shared/utils/derived-key-cache.ts +1 -1
- package/src/shared/utils/linux-keyring.ts +4 -4
- package/src/tui/adapters/kakaotalk-adapter.ts +6 -1
- package/src/tui/adapters/telegram-adapter.ts +1 -1
- package/src/tui/adapters/webex-adapter.ts +1 -1
- package/src/tui/app.ts +149 -59
- package/src/tui/utils.test.ts +144 -145
- package/src/tui/utils.ts +27 -29
- package/src/tui/views/channel-picker.ts +1 -1
- package/src/tui/views/workspace-picker.ts +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ChannelCredentialManager } from './credential-manager'
|
|
1
2
|
import type {
|
|
2
3
|
Channel,
|
|
3
4
|
ChannelAccount,
|
|
@@ -11,7 +12,6 @@ import type {
|
|
|
11
12
|
MessageBlock,
|
|
12
13
|
} from './types'
|
|
13
14
|
import { ChannelError } from './types'
|
|
14
|
-
import { ChannelCredentialManager } from './credential-manager'
|
|
15
15
|
|
|
16
16
|
const BASE_URL = 'https://desk-api.channel.io'
|
|
17
17
|
const MAX_RETRIES = 3
|
|
@@ -99,11 +99,21 @@ export class ChannelClient {
|
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
async getManagerRole(channelId: string): Promise<{ permissions: unknown[] }> {
|
|
102
|
-
return this.request<{ permissions: unknown[] }>(
|
|
102
|
+
return this.request<{ permissions: unknown[] }>(
|
|
103
|
+
'GET',
|
|
104
|
+
`/desk/channels/${channelId}/managers/me/role`,
|
|
105
|
+
undefined,
|
|
106
|
+
'role',
|
|
107
|
+
)
|
|
103
108
|
}
|
|
104
109
|
|
|
105
110
|
async listGroups(channelId: string, params?: { limit?: number }): Promise<ChannelGroup[]> {
|
|
106
|
-
return this.request<ChannelGroup[]>(
|
|
111
|
+
return this.request<ChannelGroup[]>(
|
|
112
|
+
'GET',
|
|
113
|
+
this.buildPath(`/desk/channels/${channelId}/groups`, params),
|
|
114
|
+
undefined,
|
|
115
|
+
'groups',
|
|
116
|
+
)
|
|
107
117
|
}
|
|
108
118
|
|
|
109
119
|
async getGroup(channelId: string, groupId: string): Promise<ChannelGroup> {
|
|
@@ -183,7 +193,12 @@ export class ChannelClient {
|
|
|
183
193
|
}
|
|
184
194
|
|
|
185
195
|
async getUserChat(channelId: string, chatId: string): Promise<ChannelUserChat> {
|
|
186
|
-
return this.request<ChannelUserChat>(
|
|
196
|
+
return this.request<ChannelUserChat>(
|
|
197
|
+
'GET',
|
|
198
|
+
`/desk/channels/${channelId}/user-chats/${chatId}`,
|
|
199
|
+
undefined,
|
|
200
|
+
'userChat',
|
|
201
|
+
)
|
|
187
202
|
}
|
|
188
203
|
|
|
189
204
|
async getUserChatMessages(
|
|
@@ -214,7 +229,12 @@ export class ChannelClient {
|
|
|
214
229
|
}
|
|
215
230
|
|
|
216
231
|
async listBots(channelId: string, params?: { limit?: number }): Promise<ChannelBot[]> {
|
|
217
|
-
return this.request<ChannelBot[]>(
|
|
232
|
+
return this.request<ChannelBot[]>(
|
|
233
|
+
'GET',
|
|
234
|
+
this.buildPath(`/desk/channels/${channelId}/bots`, params),
|
|
235
|
+
undefined,
|
|
236
|
+
'bots',
|
|
237
|
+
)
|
|
218
238
|
}
|
|
219
239
|
|
|
220
240
|
async searchTeamChatMessages(
|
|
@@ -344,7 +364,7 @@ export class ChannelClient {
|
|
|
344
364
|
}
|
|
345
365
|
|
|
346
366
|
private async createHttpError(response: Response): Promise<ChannelError> {
|
|
347
|
-
const errorBody = await response.json().catch(() => ({})) as ChannelApiErrorResponse
|
|
367
|
+
const errorBody = (await response.json().catch(() => ({}))) as ChannelApiErrorResponse
|
|
348
368
|
const message = errorBody.errors?.[0]?.message || `HTTP ${response.status}`
|
|
349
369
|
const code = errorBody.type || `http_${response.status}`
|
|
350
370
|
return new ChannelError(message, code)
|
|
@@ -19,9 +19,7 @@ const mockListChannels = mock(() =>
|
|
|
19
19
|
{ id: 'ws-2', name: 'Workspace 2' },
|
|
20
20
|
]),
|
|
21
21
|
)
|
|
22
|
-
const mockExtract = mock(() =>
|
|
23
|
-
Promise.resolve([{ accountCookie: 'fresh-account', sessionCookie: 'fresh-session' }]),
|
|
24
|
-
)
|
|
22
|
+
const mockExtract = mock(() => Promise.resolve([{ accountCookie: 'fresh-account', sessionCookie: 'fresh-session' }]))
|
|
25
23
|
|
|
26
24
|
import {
|
|
27
25
|
clearAction,
|
|
@@ -50,7 +48,7 @@ setChannelAuthCommandDependenciesForTesting({
|
|
|
50
48
|
createCredentialManager: () => ({
|
|
51
49
|
async getCredentials(workspaceId?: string): Promise<WorkspaceEntry | null> {
|
|
52
50
|
const targetId = workspaceId ?? currentWorkspaceId
|
|
53
|
-
return targetId ? workspaceStore.get(targetId) ?? null : null
|
|
51
|
+
return targetId ? (workspaceStore.get(targetId) ?? null) : null
|
|
54
52
|
},
|
|
55
53
|
|
|
56
54
|
async setCredentials(entry: WorkspaceEntry): Promise<void> {
|
|
@@ -115,7 +113,9 @@ describe('channel auth commands', () => {
|
|
|
115
113
|
{ id: 'ws-2', name: 'Workspace 2' },
|
|
116
114
|
]),
|
|
117
115
|
)
|
|
118
|
-
mockExtract.mockImplementation(() =>
|
|
116
|
+
mockExtract.mockImplementation(() =>
|
|
117
|
+
Promise.resolve([{ accountCookie: 'fresh-account', sessionCookie: 'fresh-session' }]),
|
|
118
|
+
)
|
|
119
119
|
})
|
|
120
120
|
|
|
121
121
|
describe('extractAction', () => {
|
|
@@ -50,7 +50,10 @@ type ChannelCredentialManagerLike = Pick<
|
|
|
50
50
|
>
|
|
51
51
|
type ChannelTokenExtractorLike = Pick<ChannelTokenExtractor, 'extract'>
|
|
52
52
|
|
|
53
|
-
let createChannelClient: (
|
|
53
|
+
let createChannelClient: (
|
|
54
|
+
accountCookie: string,
|
|
55
|
+
sessionCookie?: string,
|
|
56
|
+
) => ChannelClientLike | Promise<ChannelClientLike> = async (
|
|
54
57
|
accountCookie: string,
|
|
55
58
|
sessionCookie?: string,
|
|
56
59
|
): Promise<ChannelClientLike> => new ChannelClient().login({ accountCookie, sessionCookie })
|
|
@@ -60,7 +63,10 @@ let createCredentialManager = (): ChannelCredentialManagerLike => new ChannelCre
|
|
|
60
63
|
let createTokenExtractor = (): ChannelTokenExtractorLike => new ChannelTokenExtractor()
|
|
61
64
|
|
|
62
65
|
export function setChannelAuthCommandDependenciesForTesting(dependencies: {
|
|
63
|
-
createChannelClient?: (
|
|
66
|
+
createChannelClient?: (
|
|
67
|
+
accountCookie: string,
|
|
68
|
+
sessionCookie?: string,
|
|
69
|
+
) => ChannelClientLike | Promise<ChannelClientLike>
|
|
64
70
|
createCredentialManager?: () => ChannelCredentialManagerLike
|
|
65
71
|
createTokenExtractor?: () => ChannelTokenExtractorLike
|
|
66
72
|
}): void {
|
|
@@ -154,7 +160,9 @@ export async function statusAction(options: ActionOptions = {}): Promise<StatusR
|
|
|
154
160
|
}
|
|
155
161
|
}
|
|
156
162
|
|
|
157
|
-
const storedWorkspace = (await credManager.listAll()).find(
|
|
163
|
+
const storedWorkspace = (await credManager.listAll()).find(
|
|
164
|
+
(workspace) => workspace.workspace_id === creds.workspace_id,
|
|
165
|
+
)
|
|
158
166
|
|
|
159
167
|
try {
|
|
160
168
|
const client = await createChannelClient(creds.account_cookie, creds.session_cookie ?? undefined)
|
|
@@ -205,7 +213,10 @@ export async function listAction(options: ActionOptions = {}): Promise<Workspace
|
|
|
205
213
|
}
|
|
206
214
|
}
|
|
207
215
|
|
|
208
|
-
export async function useAction(
|
|
216
|
+
export async function useAction(
|
|
217
|
+
workspaceId: string,
|
|
218
|
+
options: ActionOptions = {},
|
|
219
|
+
): Promise<SuccessResult | ErrorResult> {
|
|
209
220
|
try {
|
|
210
221
|
const credManager = options._credManager ?? createCredentialManager()
|
|
211
222
|
const found = await credManager.setCurrent(workspaceId)
|
|
@@ -223,7 +234,10 @@ export async function useAction(workspaceId: string, options: ActionOptions = {}
|
|
|
223
234
|
}
|
|
224
235
|
}
|
|
225
236
|
|
|
226
|
-
export async function removeAction(
|
|
237
|
+
export async function removeAction(
|
|
238
|
+
workspaceId: string,
|
|
239
|
+
options: ActionOptions = {},
|
|
240
|
+
): Promise<SuccessResult | ErrorResult> {
|
|
227
241
|
try {
|
|
228
242
|
const credManager = options._credManager ?? createCredentialManager()
|
|
229
243
|
const removed = await credManager.removeWorkspace(workspaceId)
|
|
@@ -309,9 +309,7 @@ describe('message commands', () => {
|
|
|
309
309
|
test('sendAction sends a group message with wrapped blocks', async () => {
|
|
310
310
|
const result = await sendAction('group', 'grp-1', 'Hello group')
|
|
311
311
|
|
|
312
|
-
expect(mockSendGroupMessage).toHaveBeenCalledWith('ws-1', 'grp-1', [
|
|
313
|
-
{ type: 'text', value: 'Hello group' },
|
|
314
|
-
])
|
|
312
|
+
expect(mockSendGroupMessage).toHaveBeenCalledWith('ws-1', 'grp-1', [{ type: 'text', value: 'Hello group' }])
|
|
315
313
|
expect(result).toMatchObject({
|
|
316
314
|
id: 'msg-group-1',
|
|
317
315
|
channel_id: 'ws-1',
|
|
@@ -324,9 +322,7 @@ describe('message commands', () => {
|
|
|
324
322
|
test('sendAction sends a user chat message with wrapped blocks', async () => {
|
|
325
323
|
const result = await sendAction('user-chat', 'chat-1', 'Hello user chat')
|
|
326
324
|
|
|
327
|
-
expect(mockSendUserChatMessage).toHaveBeenCalledWith('ws-1', 'chat-1', [
|
|
328
|
-
{ type: 'text', value: 'Hello user chat' },
|
|
329
|
-
])
|
|
325
|
+
expect(mockSendUserChatMessage).toHaveBeenCalledWith('ws-1', 'chat-1', [{ type: 'text', value: 'Hello user chat' }])
|
|
330
326
|
expect(result).toMatchObject({
|
|
331
327
|
id: 'msg-user-1',
|
|
332
328
|
channel_id: 'ws-1',
|
|
@@ -70,7 +70,11 @@ export async function sendAction(
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
export async function listAction(
|
|
73
|
+
export async function listAction(
|
|
74
|
+
chatType: ChatType,
|
|
75
|
+
chatId: string,
|
|
76
|
+
options: MessageOptions = {},
|
|
77
|
+
): Promise<MessageResult> {
|
|
74
78
|
try {
|
|
75
79
|
const client = await getClient(options)
|
|
76
80
|
const channelId = await getCurrentWorkspaceId(options)
|
|
@@ -2,9 +2,20 @@ import { beforeEach, describe, expect, mock, test } from 'bun:test'
|
|
|
2
2
|
|
|
3
3
|
const mockGetChannel = mock(() => Promise.resolve({ id: 'ws-1', name: 'Workspace One' }))
|
|
4
4
|
const mockListManagers = mock(() =>
|
|
5
|
-
Promise.resolve([
|
|
5
|
+
Promise.resolve([
|
|
6
|
+
{
|
|
7
|
+
id: 'mgr-1',
|
|
8
|
+
channelId: 'ws-1',
|
|
9
|
+
accountId: 'acct-1',
|
|
10
|
+
name: 'Alice',
|
|
11
|
+
email: 'alice@example.com',
|
|
12
|
+
roleId: 'role-1',
|
|
13
|
+
},
|
|
14
|
+
]),
|
|
15
|
+
)
|
|
16
|
+
const mockListBots = mock(() =>
|
|
17
|
+
Promise.resolve([{ id: 'bot-1', channelId: 'ws-1', name: 'Support Bot', avatarUrl: 'https://example.com/bot.png' }]),
|
|
6
18
|
)
|
|
7
|
-
const mockListBots = mock(() => Promise.resolve([{ id: 'bot-1', channelId: 'ws-1', name: 'Support Bot', avatarUrl: 'https://example.com/bot.png' }]))
|
|
8
19
|
const mockListGroups = mock(() =>
|
|
9
20
|
Promise.resolve([
|
|
10
21
|
{ id: 'grp-1', channelId: 'ws-1', name: 'Support' },
|
|
@@ -34,9 +45,13 @@ const mockListUserChats = mock((_: string, params?: { state?: string; limit?: nu
|
|
|
34
45
|
{ id: 'chat-2', channelId: 'ws-1', state: 'opened', assigneeId: 'mgr-2', createdAt: 110, updatedAt: 210 },
|
|
35
46
|
])
|
|
36
47
|
case 'snoozed':
|
|
37
|
-
return Promise.resolve([
|
|
48
|
+
return Promise.resolve([
|
|
49
|
+
{ id: 'chat-3', channelId: 'ws-1', state: 'snoozed', assigneeId: 'mgr-1', createdAt: 120, updatedAt: 220 },
|
|
50
|
+
])
|
|
38
51
|
case 'closed':
|
|
39
|
-
return Promise.resolve([
|
|
52
|
+
return Promise.resolve([
|
|
53
|
+
{ id: 'chat-4', channelId: 'ws-1', state: 'closed', assigneeId: 'mgr-2', createdAt: 130, updatedAt: 230 },
|
|
54
|
+
])
|
|
40
55
|
default:
|
|
41
56
|
return Promise.resolve([])
|
|
42
57
|
}
|
|
@@ -141,7 +141,11 @@ async function buildGroupsSnapshot(client: Awaited<ReturnType<typeof getClient>>
|
|
|
141
141
|
)
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
-
async function buildUserChatsSnapshot(
|
|
144
|
+
async function buildUserChatsSnapshot(
|
|
145
|
+
client: Awaited<ReturnType<typeof getClient>>,
|
|
146
|
+
workspaceId: string,
|
|
147
|
+
limit: number,
|
|
148
|
+
) {
|
|
145
149
|
const [openedChats, snoozedChats, closedChats] = await Promise.all([
|
|
146
150
|
client.listUserChats(workspaceId, { state: 'opened', limit: 100 }),
|
|
147
151
|
client.listUserChats(workspaceId, { state: 'snoozed', limit: 100 }),
|
|
@@ -6,15 +6,14 @@ import {
|
|
|
6
6
|
setEnsureChannelAuthDependenciesForTesting,
|
|
7
7
|
} from './ensure-auth'
|
|
8
8
|
|
|
9
|
-
const mockGetCredentials = mock<
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
>>(() => Promise.resolve(null))
|
|
9
|
+
const mockGetCredentials = mock<
|
|
10
|
+
() => Promise<{
|
|
11
|
+
workspace_id: string
|
|
12
|
+
workspace_name: string
|
|
13
|
+
account_cookie: string
|
|
14
|
+
session_cookie: string
|
|
15
|
+
} | null>
|
|
16
|
+
>(() => Promise.resolve(null))
|
|
18
17
|
const mockSetCredentials = mock(() => Promise.resolve())
|
|
19
18
|
const mockSetCurrent = mock(() => Promise.resolve(true))
|
|
20
19
|
const mockExtract = mock(() => Promise.resolve([]))
|
|
@@ -65,10 +64,12 @@ describe('ensureChannelAuth', () => {
|
|
|
65
64
|
|
|
66
65
|
test('extracts and saves workspaces when no credentials exist', async () => {
|
|
67
66
|
mockExtract.mockImplementation(() =>
|
|
68
|
-
Promise.resolve([
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
67
|
+
Promise.resolve([
|
|
68
|
+
{
|
|
69
|
+
accountCookie: 'account-cookie',
|
|
70
|
+
sessionCookie: 'session-cookie',
|
|
71
|
+
},
|
|
72
|
+
]),
|
|
72
73
|
)
|
|
73
74
|
mockListChannels.mockImplementation(() =>
|
|
74
75
|
Promise.resolve([
|
|
@@ -128,10 +129,12 @@ describe('ensureChannelAuth', () => {
|
|
|
128
129
|
)
|
|
129
130
|
mockGetAccount.mockImplementationOnce(() => Promise.reject(new Error('Unauthorized')))
|
|
130
131
|
mockExtract.mockImplementation(() =>
|
|
131
|
-
Promise.resolve([
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
132
|
+
Promise.resolve([
|
|
133
|
+
{
|
|
134
|
+
accountCookie: 'fresh-account',
|
|
135
|
+
sessionCookie: 'fresh-session',
|
|
136
|
+
},
|
|
137
|
+
]),
|
|
135
138
|
)
|
|
136
139
|
|
|
137
140
|
await ensureChannelAuth()
|
|
@@ -3,13 +3,13 @@ import { ChannelCredentialManager } from './credential-manager'
|
|
|
3
3
|
import { ChannelTokenExtractor } from './token-extractor'
|
|
4
4
|
|
|
5
5
|
type ChannelClientLike = Pick<ChannelClient, 'getAccount' | 'listChannels'>
|
|
6
|
-
type ChannelCredentialManagerLike = Pick<
|
|
7
|
-
ChannelCredentialManager,
|
|
8
|
-
'getCredentials' | 'setCredentials' | 'setCurrent'
|
|
9
|
-
>
|
|
6
|
+
type ChannelCredentialManagerLike = Pick<ChannelCredentialManager, 'getCredentials' | 'setCredentials' | 'setCurrent'>
|
|
10
7
|
type ChannelTokenExtractorLike = Pick<ChannelTokenExtractor, 'extract'>
|
|
11
8
|
|
|
12
|
-
let createChannelClient: (
|
|
9
|
+
let createChannelClient: (
|
|
10
|
+
accountCookie: string,
|
|
11
|
+
sessionCookie?: string,
|
|
12
|
+
) => ChannelClientLike | Promise<ChannelClientLike> = async (
|
|
13
13
|
accountCookie: string,
|
|
14
14
|
sessionCookie?: string,
|
|
15
15
|
): Promise<ChannelClientLike> => new ChannelClient().login({ accountCookie, sessionCookie })
|
|
@@ -38,8 +38,7 @@ export const setEnsureChannelAuthClientFactoryForTesting = (
|
|
|
38
38
|
factory: (accountCookie: string, sessionCookie?: string) => ChannelClientLike | Promise<ChannelClientLike>,
|
|
39
39
|
): void => setEnsureChannelAuthDependenciesForTesting({ createClient: factory })
|
|
40
40
|
|
|
41
|
-
export const resetEnsureChannelAuthClientFactoryForTesting = (): void =>
|
|
42
|
-
resetEnsureChannelAuthDependenciesForTesting()
|
|
41
|
+
export const resetEnsureChannelAuthClientFactoryForTesting = (): void => resetEnsureChannelAuthDependenciesForTesting()
|
|
43
42
|
|
|
44
43
|
export async function ensureChannelAuth(): Promise<void> {
|
|
45
44
|
try {
|
|
@@ -62,13 +62,7 @@ describe('ChannelTokenExtractor', () => {
|
|
|
62
62
|
const extractor = new ChannelTokenExtractor('darwin')
|
|
63
63
|
const paths = extractor.getBrowserCookiesPaths()
|
|
64
64
|
|
|
65
|
-
const chromeBase = join(
|
|
66
|
-
process.env.HOME || '/tmp',
|
|
67
|
-
'Library',
|
|
68
|
-
'Application Support',
|
|
69
|
-
'Google',
|
|
70
|
-
'Chrome',
|
|
71
|
-
)
|
|
65
|
+
const chromeBase = join(process.env.HOME || '/tmp', 'Library', 'Application Support', 'Google', 'Chrome')
|
|
72
66
|
expect(paths).toContain(join(chromeBase, 'Default', 'Cookies'))
|
|
73
67
|
expect(paths).toContain(join(chromeBase, 'Default', 'Network', 'Cookies'))
|
|
74
68
|
})
|
|
@@ -132,10 +126,12 @@ describe('ChannelTokenExtractor', () => {
|
|
|
132
126
|
const extractor = new ChannelTokenExtractor('darwin')
|
|
133
127
|
|
|
134
128
|
const desktopSpy = spyOn(extractor as any, 'extractFromDesktopApp').mockResolvedValue(null)
|
|
135
|
-
const browserSpy = spyOn(extractor as any, 'extractAllFromBrowserPaths').mockResolvedValue([
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
129
|
+
const browserSpy = spyOn(extractor as any, 'extractAllFromBrowserPaths').mockResolvedValue([
|
|
130
|
+
{
|
|
131
|
+
accountCookie: 'browser-account',
|
|
132
|
+
sessionCookie: undefined,
|
|
133
|
+
},
|
|
134
|
+
])
|
|
139
135
|
|
|
140
136
|
const result = await extractor.extract()
|
|
141
137
|
|
|
@@ -169,10 +165,12 @@ describe('ChannelTokenExtractor', () => {
|
|
|
169
165
|
|
|
170
166
|
const extractor = new TestExtractor(dbPath)
|
|
171
167
|
|
|
172
|
-
expect(await extractor.extract()).toEqual([
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
168
|
+
expect(await extractor.extract()).toEqual([
|
|
169
|
+
{
|
|
170
|
+
accountCookie: 'account-jwt',
|
|
171
|
+
sessionCookie: 'session-jwt',
|
|
172
|
+
},
|
|
173
|
+
])
|
|
176
174
|
})
|
|
177
175
|
|
|
178
176
|
test('returns token with undefined sessionCookie when only x-account is present', async () => {
|
|
@@ -265,7 +263,10 @@ describe('ChannelTokenExtractor', () => {
|
|
|
265
263
|
|
|
266
264
|
const localStatePath = join(tempDir, 'Local State')
|
|
267
265
|
const fakeEncryptedKey = Buffer.concat([Buffer.from('DPAPI'), randomBytes(32)])
|
|
268
|
-
writeFileSync(
|
|
266
|
+
writeFileSync(
|
|
267
|
+
localStatePath,
|
|
268
|
+
JSON.stringify({ os_crypt: { encrypted_key: fakeEncryptedKey.toString('base64') } }),
|
|
269
|
+
)
|
|
269
270
|
|
|
270
271
|
const extractor = new TestWinExtractor(dbPath, masterKey)
|
|
271
272
|
const result = await extractor.extract()
|
|
@@ -283,10 +284,12 @@ describe('ChannelTokenExtractor', () => {
|
|
|
283
284
|
accountCookie: 'same-account-cookie',
|
|
284
285
|
sessionCookie: 'desktop-session',
|
|
285
286
|
})
|
|
286
|
-
const browserSpy = spyOn(extractor as any, 'extractAllFromBrowserPaths').mockResolvedValue([
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
287
|
+
const browserSpy = spyOn(extractor as any, 'extractAllFromBrowserPaths').mockResolvedValue([
|
|
288
|
+
{
|
|
289
|
+
accountCookie: 'same-account-cookie',
|
|
290
|
+
sessionCookie: 'browser-session',
|
|
291
|
+
},
|
|
292
|
+
])
|
|
290
293
|
|
|
291
294
|
const result = await extractor.extract()
|
|
292
295
|
expect(result).toHaveLength(1)
|
|
@@ -303,10 +306,12 @@ describe('ChannelTokenExtractor', () => {
|
|
|
303
306
|
accountCookie: 'desktop-account-cookie',
|
|
304
307
|
sessionCookie: 'desktop-session',
|
|
305
308
|
})
|
|
306
|
-
const browserSpy = spyOn(extractor as any, 'extractAllFromBrowserPaths').mockResolvedValue([
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
309
|
+
const browserSpy = spyOn(extractor as any, 'extractAllFromBrowserPaths').mockResolvedValue([
|
|
310
|
+
{
|
|
311
|
+
accountCookie: 'browser-account-cookie',
|
|
312
|
+
sessionCookie: 'browser-session',
|
|
313
|
+
},
|
|
314
|
+
])
|
|
310
315
|
|
|
311
316
|
const result = await extractor.extract()
|
|
312
317
|
expect(result).toHaveLength(2)
|
|
@@ -350,7 +355,10 @@ describe('ChannelTokenExtractor', () => {
|
|
|
350
355
|
|
|
351
356
|
const localStatePath = join(tempDir, 'Local State')
|
|
352
357
|
const fakeEncryptedKey = Buffer.concat([Buffer.from('DPAPI'), randomBytes(32)])
|
|
353
|
-
writeFileSync(
|
|
358
|
+
writeFileSync(
|
|
359
|
+
localStatePath,
|
|
360
|
+
JSON.stringify({ os_crypt: { encrypted_key: fakeEncryptedKey.toString('base64') } }),
|
|
361
|
+
)
|
|
354
362
|
|
|
355
363
|
const extractor = new FailingDPAPIExtractor(dbPath)
|
|
356
364
|
const result = await extractor.extract()
|