@hraness/ghostget 0.17.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +458 -0
- package/LICENSE +21 -0
- package/README.md +1359 -0
- package/bunfig.toml +2 -0
- package/dist/apple-photos-client.js +704 -0
- package/dist/beeper-client.js +4602 -0
- package/dist/client.js +1605 -0
- package/dist/index-26yq8q16.js +31 -0
- package/dist/index-9t13b4k7.js +508 -0
- package/dist/index-axwm9b3v.js +5 -0
- package/dist/index-gwk7rbyj.js +30 -0
- package/dist/index.js +701 -0
- package/dist/messaging.js +1130 -0
- package/dist/omni-client.js +1406 -0
- package/dist/whatsapp-client.js +355 -0
- package/docs/imessage-direct-provider.md +106 -0
- package/docs/rental-listings.md +94 -0
- package/package.json +600 -0
- package/skills/ghostget/SKILL.md +251 -0
- package/skills/ghostget/agents/openai.yaml +4 -0
- package/skills/ghostget/references/adapter-contract.md +181 -0
- package/skills/ghostget/references/apple-photos.md +115 -0
- package/skills/ghostget/references/article-drafts.md +235 -0
- package/skills/ghostget/references/code-owned-provider-scaffold.md +134 -0
- package/skills/ghostget/references/cross-posting-video.md +139 -0
- package/skills/ghostget/references/cross-posting.md +82 -0
- package/skills/ghostget/references/derivation.md +390 -0
- package/skills/ghostget/references/hraness-social-profile-stats.json +269 -0
- package/skills/ghostget/references/install.md +66 -0
- package/skills/ghostget/references/linkedin-adapter.md +442 -0
- package/skills/ghostget/references/messaging.md +168 -0
- package/skills/ghostget/references/meta-comet-contract.md +153 -0
- package/skills/ghostget/references/platform-patterns.md +122 -0
- package/skills/ghostget/references/provider-plugins.md +496 -0
- package/skills/ghostget/references/reddit-flair.md +78 -0
- package/skills/ghostget/references/safety-and-state.md +214 -0
- package/skills/ghostget/references/settlement-and-duplicate-cleanup.md +79 -0
- package/skills/ghostget/references/social-platform-routing.md +66 -0
- package/skills/ghostget/references/social-profile-stats.md +195 -0
- package/skills/ghostget/references/social-video-platform-routing.md +89 -0
- package/skills/ghostget/references/whatsapp-adapter.md +101 -0
- package/skills/ghostget/references/x-adapter.md +332 -0
- package/skills/ghostget/references/x-ai-disclosure.md +71 -0
- package/src/apple-photos-cli.ts +639 -0
- package/src/apple-photos-client-types.ts +168 -0
- package/src/apple-photos-client.ts +201 -0
- package/src/apple-photos-contact-evidence.ts +838 -0
- package/src/apple-photos-local-source.ts +1131 -0
- package/src/args.ts +2053 -0
- package/src/article-draft-document.ts +417 -0
- package/src/article-draft-embeds.ts +123 -0
- package/src/article-draft-images.ts +214 -0
- package/src/assets/adapter-template/wrench-adapter.json +40 -0
- package/src/assets/adapters/beeper/wrench-web-adapter.json +1500 -0
- package/src/assets/adapters/beeper/wrench-web-adapter.v1.0.0.json +129 -0
- package/src/assets/adapters/beeper/wrench-web-adapter.v1.1.0.json +207 -0
- package/src/assets/adapters/beeper/wrench-web-adapter.v2.0.0.json +1463 -0
- package/src/assets/adapters/beeper/wrench-web-adapter.v2.1.0.json +1463 -0
- package/src/assets/adapters/beeper/wrench-web-adapter.v2.2.0.json +1475 -0
- package/src/assets/adapters/beeper/wrench-web-adapter.v2.3.0.json +1488 -0
- package/src/assets/adapters/bluesky/wrench-web-adapter.json +684 -0
- package/src/assets/adapters/bluesky/wrench-web-adapter.v1.0.0.json +581 -0
- package/src/assets/adapters/bluesky/wrench-web-adapter.v1.1.0.json +581 -0
- package/src/assets/adapters/bluesky/wrench-web-adapter.v1.2.0.json +581 -0
- package/src/assets/adapters/bluesky/wrench-web-adapter.v1.3.0.json +615 -0
- package/src/assets/adapters/bluesky/wrench-web-adapter.v1.4.0.json +684 -0
- package/src/assets/adapters/bluesky/wrench-web-adapter.v1.5.0.json +684 -0
- package/src/assets/adapters/bluesky/wrench-web-adapter.v1.6.0.json +684 -0
- package/src/assets/adapters/clasificados/wrench-web-adapter.json +54 -0
- package/src/assets/adapters/facebook/wrench-web-adapter.json +750 -0
- package/src/assets/adapters/facebook/wrench-web-adapter.v1.0.0.json +706 -0
- package/src/assets/adapters/facebook/wrench-web-adapter.v1.1.0.json +703 -0
- package/src/assets/adapters/facebook/wrench-web-adapter.v1.2.0.json +750 -0
- package/src/assets/adapters/facebook-group/wrench-web-adapter.json +682 -0
- package/src/assets/adapters/facebook-group/wrench-web-adapter.v1.0.0.json +583 -0
- package/src/assets/adapters/facebook-group/wrench-web-adapter.v1.1.0.json +682 -0
- package/src/assets/adapters/facebook-marketplace/wrench-web-adapter.json +437 -0
- package/src/assets/adapters/facebook-marketplace/wrench-web-adapter.v1.0.0.json +383 -0
- package/src/assets/adapters/facebook-marketplace/wrench-web-adapter.v1.1.0.json +437 -0
- package/src/assets/adapters/facebook-marketplace/wrench-web-adapter.v1.1.1.json +437 -0
- package/src/assets/adapters/facebook-page/wrench-web-adapter.json +880 -0
- package/src/assets/adapters/facebook-page/wrench-web-adapter.v1.0.0.json +740 -0
- package/src/assets/adapters/facebook-page/wrench-web-adapter.v1.1.0.json +880 -0
- package/src/assets/adapters/github/wrench-web-adapter.json +69 -0
- package/src/assets/adapters/github/wrench-web-adapter.v1.0.0.json +42 -0
- package/src/assets/adapters/github/wrench-web-adapter.v1.1.0.json +69 -0
- package/src/assets/adapters/gmail/wrench-adapter.json +161 -0
- package/src/assets/adapters/gmail/wrench-adapter.v1.2.0.json +157 -0
- package/src/assets/adapters/hacker-news/wrench-web-adapter.json +315 -0
- package/src/assets/adapters/hacker-news/wrench-web-adapter.v1.0.0.json +315 -0
- package/src/assets/adapters/imessage/wrench-web-adapter.json +236 -0
- package/src/assets/adapters/instagram/wrench-web-adapter.json +719 -0
- package/src/assets/adapters/instagram/wrench-web-adapter.v1.0.0.json +627 -0
- package/src/assets/adapters/instagram/wrench-web-adapter.v1.1.0.json +609 -0
- package/src/assets/adapters/instagram/wrench-web-adapter.v1.2.0.json +640 -0
- package/src/assets/adapters/instagram/wrench-web-adapter.v1.3.0.json +671 -0
- package/src/assets/adapters/instagram/wrench-web-adapter.v1.4.0.json +710 -0
- package/src/assets/adapters/instagram/wrench-web-adapter.v1.5.0.json +710 -0
- package/src/assets/adapters/instagram/wrench-web-adapter.v1.6.0.json +719 -0
- package/src/assets/adapters/instagram/wrench-web-adapter.v1.7.0.json +719 -0
- package/src/assets/adapters/linkedin/wrench-adapter.json +442 -0
- package/src/assets/adapters/linkedin/wrench-adapter.v0.4.0.json +124 -0
- package/src/assets/adapters/linkedin/wrench-adapter.v1.0.0.json +411 -0
- package/src/assets/adapters/linkedin/wrench-web-adapter.json +914 -0
- package/src/assets/adapters/linkedin/wrench-web-adapter.v1.0.0.json +604 -0
- package/src/assets/adapters/linkedin/wrench-web-adapter.v1.1.0.json +604 -0
- package/src/assets/adapters/linkedin/wrench-web-adapter.v1.10.0.json +809 -0
- package/src/assets/adapters/linkedin/wrench-web-adapter.v1.11.0.json +809 -0
- package/src/assets/adapters/linkedin/wrench-web-adapter.v1.12.0.json +820 -0
- package/src/assets/adapters/linkedin/wrench-web-adapter.v1.13.0.json +819 -0
- package/src/assets/adapters/linkedin/wrench-web-adapter.v1.14.0.json +819 -0
- package/src/assets/adapters/linkedin/wrench-web-adapter.v1.15.0.json +819 -0
- package/src/assets/adapters/linkedin/wrench-web-adapter.v1.16.0.json +874 -0
- package/src/assets/adapters/linkedin/wrench-web-adapter.v1.17.0.json +874 -0
- package/src/assets/adapters/linkedin/wrench-web-adapter.v1.18.0.json +874 -0
- package/src/assets/adapters/linkedin/wrench-web-adapter.v1.19.0.json +874 -0
- package/src/assets/adapters/linkedin/wrench-web-adapter.v1.2.0.json +731 -0
- package/src/assets/adapters/linkedin/wrench-web-adapter.v1.3.0.json +768 -0
- package/src/assets/adapters/linkedin/wrench-web-adapter.v1.4.0.json +808 -0
- package/src/assets/adapters/linkedin/wrench-web-adapter.v1.5.0.json +808 -0
- package/src/assets/adapters/linkedin/wrench-web-adapter.v1.6.0.json +808 -0
- package/src/assets/adapters/linkedin/wrench-web-adapter.v1.7.0.json +825 -0
- package/src/assets/adapters/linkedin/wrench-web-adapter.v1.8.0.json +792 -0
- package/src/assets/adapters/linkedin/wrench-web-adapter.v1.9.0.json +809 -0
- package/src/assets/adapters/reddit/wrench-web-adapter.json +855 -0
- package/src/assets/adapters/reddit/wrench-web-adapter.v1.0.0.json +577 -0
- package/src/assets/adapters/reddit/wrench-web-adapter.v1.1.0.json +604 -0
- package/src/assets/adapters/reddit/wrench-web-adapter.v1.10.0.json +712 -0
- package/src/assets/adapters/reddit/wrench-web-adapter.v1.11.0.json +712 -0
- package/src/assets/adapters/reddit/wrench-web-adapter.v1.12.0.json +712 -0
- package/src/assets/adapters/reddit/wrench-web-adapter.v1.2.0.json +653 -0
- package/src/assets/adapters/reddit/wrench-web-adapter.v1.3.0.json +712 -0
- package/src/assets/adapters/reddit/wrench-web-adapter.v1.4.0.json +713 -0
- package/src/assets/adapters/reddit/wrench-web-adapter.v1.5.0.json +712 -0
- package/src/assets/adapters/reddit/wrench-web-adapter.v1.6.0.json +713 -0
- package/src/assets/adapters/reddit/wrench-web-adapter.v1.7.0.json +713 -0
- package/src/assets/adapters/reddit/wrench-web-adapter.v1.8.0.json +713 -0
- package/src/assets/adapters/reddit/wrench-web-adapter.v1.9.0.json +713 -0
- package/src/assets/adapters/substack/wrench-web-adapter.json +936 -0
- package/src/assets/adapters/substack/wrench-web-adapter.v1.0.0.json +817 -0
- package/src/assets/adapters/substack/wrench-web-adapter.v1.1.0.json +812 -0
- package/src/assets/adapters/substack/wrench-web-adapter.v1.2.0.json +812 -0
- package/src/assets/adapters/substack/wrench-web-adapter.v1.3.0.json +902 -0
- package/src/assets/adapters/substack/wrench-web-adapter.v1.4.0.json +936 -0
- package/src/assets/adapters/substack/wrench-web-adapter.v1.5.0.json +936 -0
- package/src/assets/adapters/substack/wrench-web-adapter.v1.6.0.json +936 -0
- package/src/assets/adapters/threads/wrench-web-adapter.json +692 -0
- package/src/assets/adapters/threads/wrench-web-adapter.v1.0.0.json +629 -0
- package/src/assets/adapters/threads/wrench-web-adapter.v1.1.0.json +623 -0
- package/src/assets/adapters/threads/wrench-web-adapter.v1.2.0.json +622 -0
- package/src/assets/adapters/threads/wrench-web-adapter.v1.3.0.json +622 -0
- package/src/assets/adapters/threads/wrench-web-adapter.v1.4.0.json +622 -0
- package/src/assets/adapters/threads/wrench-web-adapter.v1.5.0.json +699 -0
- package/src/assets/adapters/threads/wrench-web-adapter.v1.6.0.json +693 -0
- package/src/assets/adapters/threads/wrench-web-adapter.v1.7.0.json +692 -0
- package/src/assets/adapters/tiktok/wrench-web-adapter.json +762 -0
- package/src/assets/adapters/tiktok/wrench-web-adapter.v1.0.0.json +681 -0
- package/src/assets/adapters/tiktok/wrench-web-adapter.v1.1.0.json +708 -0
- package/src/assets/adapters/tiktok/wrench-web-adapter.v1.2.0.json +762 -0
- package/src/assets/adapters/tiktok/wrench-web-adapter.v1.3.0.json +762 -0
- package/src/assets/adapters/twitch/wrench-web-adapter.json +42 -0
- package/src/assets/adapters/twitch/wrench-web-adapter.v1.0.0.json +42 -0
- package/src/assets/adapters/whatsapp/wrench-web-adapter.json +400 -0
- package/src/assets/adapters/whatsapp/wrench-web-adapter.v1.0.0.json +355 -0
- package/src/assets/adapters/whatsapp/wrench-web-adapter.v1.1.0.json +386 -0
- package/src/assets/adapters/whatsapp/wrench-web-adapter.v1.2.0.json +386 -0
- package/src/assets/adapters/whatsapp/wrench-web-adapter.v1.3.0.json +400 -0
- package/src/assets/adapters/x/wrench-adapter.json +749 -0
- package/src/assets/adapters/x/wrench-adapter.v1.0.0.json +700 -0
- package/src/assets/adapters/x/wrench-adapter.v1.1.0.json +707 -0
- package/src/assets/adapters/x/wrench-web-adapter.json +712 -0
- package/src/assets/adapters/x/wrench-web-adapter.v1.1.0.json +579 -0
- package/src/assets/adapters/x/wrench-web-adapter.v1.10.0.json +685 -0
- package/src/assets/adapters/x/wrench-web-adapter.v1.11.0.json +712 -0
- package/src/assets/adapters/x/wrench-web-adapter.v1.12.0.json +712 -0
- package/src/assets/adapters/x/wrench-web-adapter.v1.13.0.json +712 -0
- package/src/assets/adapters/x/wrench-web-adapter.v1.2.0.json +578 -0
- package/src/assets/adapters/x/wrench-web-adapter.v1.3.0.json +610 -0
- package/src/assets/adapters/x/wrench-web-adapter.v1.4.0.json +617 -0
- package/src/assets/adapters/x/wrench-web-adapter.v1.5.0.json +634 -0
- package/src/assets/adapters/x/wrench-web-adapter.v1.6.0.json +632 -0
- package/src/assets/adapters/x/wrench-web-adapter.v1.7.0.json +649 -0
- package/src/assets/adapters/x/wrench-web-adapter.v1.8.0.json +649 -0
- package/src/assets/adapters/x/wrench-web-adapter.v1.9.0.json +683 -0
- package/src/assets/adapters/youtube/wrench-web-adapter.json +561 -0
- package/src/assets/adapters/youtube/wrench-web-adapter.v1.0.0.json +465 -0
- package/src/assets/adapters/youtube/wrench-web-adapter.v1.1.0.json +519 -0
- package/src/assets/adapters/youtube/wrench-web-adapter.v1.2.0.json +561 -0
- package/src/assets/adapters/youtube/wrench-web-adapter.v1.3.0.json +561 -0
- package/src/assets/code-owned-provider-template/plugin.test.ts.template +54 -0
- package/src/assets/code-owned-provider-template/plugin.ts.template +102 -0
- package/src/assets/code-owned-provider-template/runtime.internal.test.ts.template +44 -0
- package/src/assets/code-owned-provider-template/runtime.ts.template +59 -0
- package/src/assets/code-owned-provider-template/wrench-adapter.json.template +33 -0
- package/src/assets/fonts/nebula-sans/LICENSE.txt +96 -0
- package/src/assets/fonts/nebula-sans/NebulaSans-Book.woff2 +0 -0
- package/src/assets/fonts/nebula-sans/PROVENANCE.md +14 -0
- package/src/assets.d.ts +4 -0
- package/src/auth.ts +1157 -0
- package/src/beeper-client-types.ts +169 -0
- package/src/beeper-client.ts +250 -0
- package/src/beeper-contact-interactions-cli.ts +180 -0
- package/src/beeper-contact-interactions.ts +1612 -0
- package/src/beeper-message-bundle-v1.ts +257 -0
- package/src/beeper-message-like-me-cli.ts +84 -0
- package/src/beeper-message-like-me-export.ts +2274 -0
- package/src/beeper-message-like-me-recovery.ts +931 -0
- package/src/beeper-message-like-me-source.ts +4034 -0
- package/src/browser-admission.ts +928 -0
- package/src/browser-snapshots.ts +260 -0
- package/src/browser.ts +3873 -0
- package/src/canonical-json.ts +60 -0
- package/src/catalog-cli.ts +638 -0
- package/src/cli.ts +208 -0
- package/src/client-types.ts +301 -0
- package/src/client.ts +2726 -0
- package/src/confirmed-write-failure.ts +44 -0
- package/src/confirmed-write-model.ts +72 -0
- package/src/confirmed-write-platform.ts +1055 -0
- package/src/confirmed-write-program.ts +224 -0
- package/src/confirmed-write-runtime.ts +16 -0
- package/src/cursor-token.ts +228 -0
- package/src/derivation-dnr-readiness.ts +367 -0
- package/src/derivation-file-chooser.ts +384 -0
- package/src/derivation-network-boundary.ts +835 -0
- package/src/derivation-network-guard.ts +782 -0
- package/src/derivation-network-proxy-helper.ts +440 -0
- package/src/derivation-network-proxy.ts +385 -0
- package/src/derive-command-helper.ts +693 -0
- package/src/derive-fixtures.ts +343 -0
- package/src/derive-review.ts +980 -0
- package/src/derive.ts +4754 -0
- package/src/fixtures/beeper-message-like-me-v1/accounts.ndjson +2 -0
- package/src/fixtures/beeper-message-like-me-v1/conversations.ndjson +1 -0
- package/src/fixtures/beeper-message-like-me-v1/manifest.json +1 -0
- package/src/fixtures/beeper-message-like-me-v1/messages.ndjson +2 -0
- package/src/fixtures/beeper-message-like-me-v1/participants.ndjson +3 -0
- package/src/fixtures/beeper-message-like-me-v1/reactions.ndjson +1 -0
- package/src/fixtures/beeper-message-like-me-v1/tombstones.ndjson +1 -0
- package/src/ghostget.ts +3672 -0
- package/src/gmail-capture.ts +1244 -0
- package/src/har-internal.ts +1242 -0
- package/src/har.ts +743 -0
- package/src/index.ts +218 -0
- package/src/invocation-read-platform.ts +55 -0
- package/src/invocation-read-program.ts +93 -0
- package/src/invocation-read-runtime.ts +11 -0
- package/src/linked-device-lifecycle-admission.ts +450 -0
- package/src/linked-device-lifecycle-journal.ts +1560 -0
- package/src/linked-device-lifecycle-runtime.ts +1602 -0
- package/src/local-cli-admission.ts +135 -0
- package/src/local-cli-contracts.ts +271 -0
- package/src/local-cli-execution.ts +98 -0
- package/src/local-cli-surface-contract.ts +1510 -0
- package/src/local-cli-tool-identity.ts +336 -0
- package/src/media/archive.ts +2325 -0
- package/src/media/args.ts +303 -0
- package/src/media/cli.ts +287 -0
- package/src/media/doctor.ts +475 -0
- package/src/media/ffmpeg.ts +1330 -0
- package/src/media/http-capture.ts +711 -0
- package/src/media/http-probe.ts +593 -0
- package/src/media/http.ts +387 -0
- package/src/media/index.ts +10 -0
- package/src/media/local-transcription.ts +613 -0
- package/src/media/lock.ts +321 -0
- package/src/media/manifest.ts +1712 -0
- package/src/media/metadata.ts +906 -0
- package/src/media/process.ts +723 -0
- package/src/media/revision.ts +166 -0
- package/src/media/runtime-closure.ts +1063 -0
- package/src/media/source-router.ts +187 -0
- package/src/media/transcriber-config.ts +1122 -0
- package/src/media/transcript-persistence-model.ts +15 -0
- package/src/media/transcript-persistence-platform.ts +89 -0
- package/src/media/transcript-persistence-program.ts +39 -0
- package/src/media/transcript-persistence-runtime.ts +24 -0
- package/src/media/transcript.ts +616 -0
- package/src/media/utf8-order.ts +30 -0
- package/src/media/whisper-cpp.ts +464 -0
- package/src/media/whisper-language.ts +58 -0
- package/src/media/yt-dlp.ts +439 -0
- package/src/message-like-me-agentic-messaging.ts +882 -0
- package/src/messaging-action-store.ts +793 -0
- package/src/messaging-runtime.ts +2136 -0
- package/src/messaging-store.ts +539 -0
- package/src/messaging-types.ts +1663 -0
- package/src/messaging.ts +334 -0
- package/src/model.ts +2671 -0
- package/src/oauth-google.ts +888 -0
- package/src/omni-client-types.ts +306 -0
- package/src/omni-client.ts +2225 -0
- package/src/omni-limits.ts +34 -0
- package/src/omni-model.ts +1614 -0
- package/src/omni-request.ts +379 -0
- package/src/omni-runtime.ts +1632 -0
- package/src/operation-deadline.ts +189 -0
- package/src/path-helper.ts +1656 -0
- package/src/pinned-https.ts +194 -0
- package/src/plan-assets.ts +832 -0
- package/src/platform-catalog.ts +1832 -0
- package/src/plugins/beeper-linked-device/plugin.ts +310 -0
- package/src/plugins/bluesky-web/plugin.ts +178 -0
- package/src/plugins/clasificados-web/plugin.ts +66 -0
- package/src/plugins/github-web/plugin.ts +80 -0
- package/src/plugins/gmail-official/plugin.ts +110 -0
- package/src/plugins/hacker-news-web/plugin.ts +52 -0
- package/src/plugins/imessage-direct/plugin.ts +195 -0
- package/src/plugins/imessage-direct/vendor/0001-fix-keep-AppleScript-send-payloads-out-of-child-argv.patch +1430 -0
- package/src/plugins/imessage-direct/vendor/0002-feat-rpc-add-exact-chat-lookup.patch +225 -0
- package/src/plugins/imessage-direct/vendor/provenance.json +80 -0
- package/src/plugins/linkedin-official/plugin.ts +84 -0
- package/src/plugins/linkedin-web/plugin.ts +412 -0
- package/src/plugins/meta-web/plugin.ts +317 -0
- package/src/plugins/reddit-web/flair.ts +492 -0
- package/src/plugins/reddit-web/plugin.ts +477 -0
- package/src/plugins/substack-web/plugin.ts +124 -0
- package/src/plugins/tiktok-web/plugin.ts +67 -0
- package/src/plugins/twitch-web/plugin.ts +54 -0
- package/src/plugins/whatsapp-linked-device/plugin.ts +105 -0
- package/src/plugins/x-official/plugin.ts +64 -0
- package/src/plugins/x-web/plugin.ts +488 -0
- package/src/plugins/youtube-web/plugin.ts +101 -0
- package/src/portable-run-recovery.ts +466 -0
- package/src/process-identity.ts +501 -0
- package/src/profile-clone-helper.ts +104 -0
- package/src/provider-catalog-views.ts +51 -0
- package/src/provider-context.ts +69 -0
- package/src/provider-contract-definitions-x.ts +45 -0
- package/src/provider-contract-definitions.ts +948 -0
- package/src/provider-contract-input-gmail.ts +176 -0
- package/src/provider-contract-input-linkedin.ts +77 -0
- package/src/provider-contract-input-x.ts +304 -0
- package/src/provider-contract-planning.ts +23 -0
- package/src/provider-contract-semantic-identity.ts +54 -0
- package/src/provider-contracts.ts +251 -0
- package/src/provider-http.ts +723 -0
- package/src/provider-plugin-auth.ts +36 -0
- package/src/provider-plugin-builtins.ts +229 -0
- package/src/provider-plugin-cleanup-barrier.ts +229 -0
- package/src/provider-plugin-cleanup-execution.ts +79 -0
- package/src/provider-plugin-cleanup-resource.ts +470 -0
- package/src/provider-plugin-contract-identity.ts +707 -0
- package/src/provider-plugin-host.ts +1972 -0
- package/src/provider-plugin-identifiers.ts +60 -0
- package/src/provider-plugin-invocation-lease.ts +889 -0
- package/src/provider-plugin-lifecycle-kernel.ts +566 -0
- package/src/provider-plugin-lifecycle.ts +1455 -0
- package/src/provider-plugin-module-analysis.ts +336 -0
- package/src/provider-plugin-package.ts +2530 -0
- package/src/provider-plugin-portable-authority.ts +106 -0
- package/src/provider-plugin-portable-catalog.ts +94 -0
- package/src/provider-plugin-portable-identity.ts +315 -0
- package/src/provider-plugin-portable-runtime.ts +2057 -0
- package/src/provider-plugin-protocol.ts +1625 -0
- package/src/provider-plugin-registry.ts +3342 -0
- package/src/provider-plugin-store.ts +2155 -0
- package/src/provider-plugin-test-fixture.ts +5 -0
- package/src/provider-plugin.ts +4907 -0
- package/src/provider-plugins.generated.ts +43 -0
- package/src/provider-plugins.ts +8 -0
- package/src/provider-subject.ts +41 -0
- package/src/provider.ts +315 -0
- package/src/providers/beeper-local-runtime.ts +5426 -0
- package/src/providers/beeper-local.ts +2739 -0
- package/src/providers/beeper-messaging.ts +462 -0
- package/src/providers/beeper-omni.ts +1159 -0
- package/src/providers/bluesky-web-runtime.ts +2895 -0
- package/src/providers/bluesky-web.ts +1614 -0
- package/src/providers/clasificados-web-runtime.ts +255 -0
- package/src/providers/clasificados-web.ts +503 -0
- package/src/providers/contact-projection.ts +301 -0
- package/src/providers/github-read-model.ts +94 -0
- package/src/providers/github-read-platform.ts +165 -0
- package/src/providers/github-read-program.ts +97 -0
- package/src/providers/github-web-runtime.ts +320 -0
- package/src/providers/github-web.ts +403 -0
- package/src/providers/gmail-api.ts +2834 -0
- package/src/providers/gmail-omni.ts +830 -0
- package/src/providers/gmail.ts +1130 -0
- package/src/providers/hacker-news-web-runtime.ts +220 -0
- package/src/providers/hacker-news-web.ts +809 -0
- package/src/providers/imessage-direct-install.ts +354 -0
- package/src/providers/imessage-direct-messaging.ts +532 -0
- package/src/providers/imessage-direct-omni.ts +400 -0
- package/src/providers/imessage-direct-runtime.ts +1498 -0
- package/src/providers/imessage-direct.ts +351 -0
- package/src/providers/instagram-video-foundations.ts +913 -0
- package/src/providers/instagram-web-profile-browser.ts +600 -0
- package/src/providers/iso-bmff.ts +338 -0
- package/src/providers/linkedin-company-platform.ts +42 -0
- package/src/providers/linkedin-company-program.ts +88 -0
- package/src/providers/linkedin-contact-failure.ts +84 -0
- package/src/providers/linkedin-contact-platform.ts +45 -0
- package/src/providers/linkedin-contact-program.ts +91 -0
- package/src/providers/linkedin-profile-activity-failure.ts +76 -0
- package/src/providers/linkedin-profile-activity-platform.ts +41 -0
- package/src/providers/linkedin-profile-activity-program.ts +67 -0
- package/src/providers/linkedin-read-failure.ts +52 -0
- package/src/providers/linkedin-self-platform.ts +53 -0
- package/src/providers/linkedin-self-program.ts +122 -0
- package/src/providers/linkedin-web-article-browser.ts +794 -0
- package/src/providers/linkedin-web-bootstrap.ts +146 -0
- package/src/providers/linkedin-web-contact.ts +830 -0
- package/src/providers/linkedin-web-feed-browser.ts +832 -0
- package/src/providers/linkedin-web-feed.ts +864 -0
- package/src/providers/linkedin-web-post-browser.ts +653 -0
- package/src/providers/linkedin-web-profile-browser.ts +683 -0
- package/src/providers/linkedin-web-runtime.ts +2388 -0
- package/src/providers/linkedin-web.ts +3305 -0
- package/src/providers/linkedin.ts +1885 -0
- package/src/providers/meta-bootstrap.ts +1043 -0
- package/src/providers/meta-facebook-group.ts +690 -0
- package/src/providers/meta-marketplace-relay.ts +747 -0
- package/src/providers/meta-omni.ts +373 -0
- package/src/providers/meta-relay-bundle.ts +1049 -0
- package/src/providers/meta-web-descriptors.ts +1740 -0
- package/src/providers/meta-web-runtime.ts +3388 -0
- package/src/providers/meta-web.ts +2931 -0
- package/src/providers/read-failure.ts +139 -0
- package/src/providers/reddit-omni.ts +462 -0
- package/src/providers/reddit-web-runtime.ts +1929 -0
- package/src/providers/reddit-web.ts +1611 -0
- package/src/providers/rental-listings.ts +460 -0
- package/src/providers/substack-omni.ts +406 -0
- package/src/providers/substack-video-mp4.ts +33 -0
- package/src/providers/substack-web-runtime.ts +2812 -0
- package/src/providers/substack-web.ts +1502 -0
- package/src/providers/tiktok-video-mp4.ts +33 -0
- package/src/providers/tiktok-web-runtime.ts +770 -0
- package/src/providers/tiktok-web.ts +2786 -0
- package/src/providers/twitch-web-runtime.ts +226 -0
- package/src/providers/twitch-web.ts +274 -0
- package/src/providers/whatsapp-account-identity.ts +55 -0
- package/src/providers/whatsapp-contact-projection-helper.ts +874 -0
- package/src/providers/whatsapp-contact-projection-protocol.ts +403 -0
- package/src/providers/whatsapp-interaction-projection-helper.ts +1452 -0
- package/src/providers/whatsapp-interaction-projection-protocol.ts +462 -0
- package/src/providers/whatsapp-message-export-projection-protocol.ts +532 -0
- package/src/providers/whatsapp-messaging.ts +132 -0
- package/src/providers/whatsapp-omni.ts +586 -0
- package/src/providers/whatsapp-web-runtime.ts +3108 -0
- package/src/providers/whatsapp-web.ts +1037 -0
- package/src/providers/x-image-provenance.ts +523 -0
- package/src/providers/x-made-with-ai.ts +106 -0
- package/src/providers/x-transaction-id.ts +413 -0
- package/src/providers/x-web-runtime.ts +3485 -0
- package/src/providers/x-web.ts +2332 -0
- package/src/providers/x.ts +1889 -0
- package/src/providers/youtube-web-runtime.ts +1400 -0
- package/src/providers/youtube-web.ts +1221 -0
- package/src/read-admission-runtime.ts +91 -0
- package/src/read-client.ts +521 -0
- package/src/read-effect-platform.ts +7 -0
- package/src/read-effect-runtime.ts +14 -0
- package/src/read-effect.ts +52 -0
- package/src/read-projection-admission.ts +866 -0
- package/src/read-projections.ts +3151 -0
- package/src/recovery.ts +1492 -0
- package/src/reviewed-template.ts +146 -0
- package/src/run-journal.ts +1272 -0
- package/src/runtime.ts +5116 -0
- package/src/scripts/generate-provider-plugin-catalog.ts +121 -0
- package/src/scripts/install-whatsapp-protocol.sh +232 -0
- package/src/scripts/recover-install-stages.ts +1491 -0
- package/src/scripts/resolve-state-home.ts +30 -0
- package/src/scripts/scaffold-web-provider.ts +973 -0
- package/src/scripts/sync-bundled-adapters.ts +695 -0
- package/src/session-secrets.ts +1183 -0
- package/src/state-helper.bunfig.toml +2 -0
- package/src/state-helper.ts +2914 -0
- package/src/storage.ts +3842 -0
- package/src/transport-policy.ts +2 -0
- package/src/usage.ts +182 -0
- package/src/version.ts +2 -0
- package/src/web-session-authentication-policy.ts +136 -0
- package/src/web-session-cleanup-admission.ts +2344 -0
- package/src/web-session-cleanup-join.ts +99 -0
- package/src/web-session-client.ts +996 -0
- package/src/web-session-contract-definitions.ts +820 -0
- package/src/web-session-contract-planning.ts +42 -0
- package/src/web-session-contracts.ts +228 -0
- package/src/web-session-cookies.ts +500 -0
- package/src/web-session-execution.ts +385 -0
- package/src/web-session-http.ts +373 -0
- package/src/web-session-read-errors.ts +19 -0
- package/src/web-session-read-runtime.ts +124 -0
- package/src/web-session-recovery.ts +818 -0
- package/src/web-session-sites.ts +58 -0
- package/src/web-session-template.ts +994 -0
- package/src/web-session.ts +93 -0
- package/src/whatsapp-client-binding.ts +21 -0
- package/src/whatsapp-client-types.ts +75 -0
- package/src/whatsapp-client.ts +395 -0
- package/src/whatsapp-export-coordinate.ts +17 -0
- package/src/whatsapp-message-bundle-v2.ts +195 -0
- package/src/whatsapp-message-like-me-cli.ts +195 -0
- package/src/whatsapp-message-like-me-export.ts +1072 -0
- package/src/whatsapp-message-like-me-source.ts +1012 -0
- package/tsconfig.json +67 -0
|
@@ -0,0 +1,462 @@
|
|
|
1
|
+
import { types as nodeTypes } from "node:util";
|
|
2
|
+
|
|
3
|
+
export const WHATSAPP_INTERACTION_PROJECTION_PROTOCOL_VERSION = 1 as const;
|
|
4
|
+
export const WHATSAPP_INTERACTION_PROJECTION_MAX_LIMIT = 1_000;
|
|
5
|
+
export const WHATSAPP_INTERACTION_PROJECTION_MAX_STDIN_BYTES = 8 * 1024;
|
|
6
|
+
export const WHATSAPP_INTERACTION_PROJECTION_MAX_STDOUT_BYTES = 1024 * 1024;
|
|
7
|
+
export const WHATSAPP_INTERACTION_PROJECTION_SCHEMA_FINGERPRINT =
|
|
8
|
+
"sha256:994b5024bc2479a269866060ea14a06230532b5aba8365d31b1f94113df3bc57" as const;
|
|
9
|
+
|
|
10
|
+
const MAX_ROWID = 9_223_372_036_854_775_807n;
|
|
11
|
+
const ROWID_PATTERN = /^(?:0|[1-9][0-9]{0,18})$/u;
|
|
12
|
+
// Read-only compatibility keeps historic local auth subjects parseable. New
|
|
13
|
+
// pairings use whatsapp-account-identity's narrower export-compatible grammar.
|
|
14
|
+
const PN_SUBJECT_PATTERN = /^whatsapp:pn:[0-9]{5,20}$/u;
|
|
15
|
+
const LID_SUBJECT_PATTERN = /^whatsapp:lid:[0-9]{5,32}$/u;
|
|
16
|
+
const JID_PATTERNS = [
|
|
17
|
+
/^0@s\.whatsapp\.net$/u,
|
|
18
|
+
/^[0-9]{5,20}(?::[0-9]{1,5})?@s\.whatsapp\.net$/u,
|
|
19
|
+
/^[0-9]{5,32}(?::[0-9]{1,5})?@lid$/u,
|
|
20
|
+
/^[0-9]{5,32}(?:-[0-9]{5,20})?@g\.us$/u,
|
|
21
|
+
/^[0-9]{5,32}@newsletter$/u,
|
|
22
|
+
/^(?:status|[0-9]{5,32})@broadcast$/u,
|
|
23
|
+
] as const;
|
|
24
|
+
const MESSAGE_ID_PATTERN = /^[A-Za-z0-9._~:-]{1,256}$/u;
|
|
25
|
+
const SHA256_PATTERN = /^[a-f0-9]{64}$/u;
|
|
26
|
+
const CHAT_KINDS = new Set(["dm", "group", "broadcast", "newsletter", "unknown"]);
|
|
27
|
+
|
|
28
|
+
export type WhatsAppInteractionProjectionFileIdentity = Readonly<{
|
|
29
|
+
dev: string;
|
|
30
|
+
ino: string;
|
|
31
|
+
}>;
|
|
32
|
+
|
|
33
|
+
export type WhatsAppInteractionProjectionRequest = Readonly<{
|
|
34
|
+
schemaVersion: typeof WHATSAPP_INTERACTION_PROJECTION_PROTOCOL_VERSION;
|
|
35
|
+
operation: "contacts.interactions.list";
|
|
36
|
+
accountSubject: string;
|
|
37
|
+
cursor: string;
|
|
38
|
+
cursorAnchor: string | null;
|
|
39
|
+
limit: number;
|
|
40
|
+
storeIdentity: WhatsAppInteractionProjectionFileIdentity;
|
|
41
|
+
sessionIdentity: WhatsAppInteractionProjectionFileIdentity;
|
|
42
|
+
messageStoreIdentity: WhatsAppInteractionProjectionFileIdentity;
|
|
43
|
+
}>;
|
|
44
|
+
|
|
45
|
+
export type WhatsAppInteractionProjectionItem = Readonly<{
|
|
46
|
+
rowid: string;
|
|
47
|
+
chatJid: string;
|
|
48
|
+
messageId: string;
|
|
49
|
+
senderJid: string | null;
|
|
50
|
+
timestamp: string;
|
|
51
|
+
fromMe: boolean;
|
|
52
|
+
chatKind: "dm" | "group" | "broadcast" | "newsletter" | "unknown";
|
|
53
|
+
}>;
|
|
54
|
+
|
|
55
|
+
export type WhatsAppInteractionAccountJidAliases = Readonly<{
|
|
56
|
+
pnJid: string;
|
|
57
|
+
lidJid: string | null;
|
|
58
|
+
}>;
|
|
59
|
+
|
|
60
|
+
export const WHATSAPP_INTERACTION_PROJECTION_ERROR_CODES = Object.freeze([
|
|
61
|
+
"request-invalid",
|
|
62
|
+
"store-binding-invalid",
|
|
63
|
+
"session-binding-invalid",
|
|
64
|
+
"message-store-file-invalid",
|
|
65
|
+
"message-store-file-too-large",
|
|
66
|
+
"message-store-sidecar-present",
|
|
67
|
+
"message-store-sidecar-state-unverified",
|
|
68
|
+
"database-invalid",
|
|
69
|
+
"database-integrity-failed",
|
|
70
|
+
"schema-mismatch",
|
|
71
|
+
"owner-mismatch",
|
|
72
|
+
"generation-mismatch",
|
|
73
|
+
"projection-invalid",
|
|
74
|
+
"output-too-large",
|
|
75
|
+
] as const);
|
|
76
|
+
|
|
77
|
+
export type WhatsAppInteractionProjectionErrorCode =
|
|
78
|
+
(typeof WHATSAPP_INTERACTION_PROJECTION_ERROR_CODES)[number];
|
|
79
|
+
|
|
80
|
+
export type WhatsAppInteractionProjectionSuccess = Readonly<{
|
|
81
|
+
schemaVersion: typeof WHATSAPP_INTERACTION_PROJECTION_PROTOCOL_VERSION;
|
|
82
|
+
status: "succeeded";
|
|
83
|
+
projectionGeneration: Readonly<{
|
|
84
|
+
messageStoreIdentity: WhatsAppInteractionProjectionFileIdentity;
|
|
85
|
+
schemaFingerprint: typeof WHATSAPP_INTERACTION_PROJECTION_SCHEMA_FINGERPRINT;
|
|
86
|
+
}>;
|
|
87
|
+
accountJidAliases: WhatsAppInteractionAccountJidAliases;
|
|
88
|
+
interactions: readonly WhatsAppInteractionProjectionItem[];
|
|
89
|
+
nextCursor: string | null;
|
|
90
|
+
localInsertPageComplete: boolean;
|
|
91
|
+
checkpoint: Readonly<{
|
|
92
|
+
cursor: string;
|
|
93
|
+
anchor: string | null;
|
|
94
|
+
}>;
|
|
95
|
+
}>;
|
|
96
|
+
|
|
97
|
+
export type WhatsAppInteractionProjectionFailure = Readonly<{
|
|
98
|
+
schemaVersion: typeof WHATSAPP_INTERACTION_PROJECTION_PROTOCOL_VERSION;
|
|
99
|
+
status: "failed";
|
|
100
|
+
errorCode: WhatsAppInteractionProjectionErrorCode;
|
|
101
|
+
}>;
|
|
102
|
+
|
|
103
|
+
export type WhatsAppInteractionProjectionResponse =
|
|
104
|
+
| WhatsAppInteractionProjectionSuccess
|
|
105
|
+
| WhatsAppInteractionProjectionFailure;
|
|
106
|
+
|
|
107
|
+
type JsonRecord = Readonly<Record<string, unknown>>;
|
|
108
|
+
|
|
109
|
+
function fail(label: string): never {
|
|
110
|
+
throw new Error(`${label} did not match the WhatsApp interaction projection protocol`);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function record(value: unknown, label: string): JsonRecord {
|
|
114
|
+
if (
|
|
115
|
+
typeof value !== "object"
|
|
116
|
+
|| value === null
|
|
117
|
+
|| Array.isArray(value)
|
|
118
|
+
|| nodeTypes.isProxy(value)
|
|
119
|
+
|| (Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== null)
|
|
120
|
+
) return fail(label);
|
|
121
|
+
const descriptors = Object.getOwnPropertyDescriptors(value);
|
|
122
|
+
for (const key of Reflect.ownKeys(descriptors)) {
|
|
123
|
+
if (typeof key !== "string") return fail(label);
|
|
124
|
+
const descriptor = descriptors[key];
|
|
125
|
+
if (descriptor === undefined || !("value" in descriptor) || !descriptor.enumerable) {
|
|
126
|
+
return fail(label);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return value as JsonRecord;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function denseArray(value: unknown, label: string, maximum: number): readonly unknown[] {
|
|
133
|
+
if (
|
|
134
|
+
!Array.isArray(value)
|
|
135
|
+
|| nodeTypes.isProxy(value)
|
|
136
|
+
|| Object.getPrototypeOf(value) !== Array.prototype
|
|
137
|
+
|| value.length > maximum
|
|
138
|
+
) return fail(label);
|
|
139
|
+
const keys = Reflect.ownKeys(value);
|
|
140
|
+
if (keys.length !== value.length + 1 || keys.some((key) => typeof key !== "string")) {
|
|
141
|
+
return fail(label);
|
|
142
|
+
}
|
|
143
|
+
const lengthDescriptor = Object.getOwnPropertyDescriptor(value, "length");
|
|
144
|
+
if (
|
|
145
|
+
lengthDescriptor === undefined
|
|
146
|
+
|| lengthDescriptor.enumerable
|
|
147
|
+
|| !("value" in lengthDescriptor)
|
|
148
|
+
|| lengthDescriptor.value !== value.length
|
|
149
|
+
) return fail(label);
|
|
150
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
151
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, String(index));
|
|
152
|
+
if (descriptor === undefined || !descriptor.enumerable || !("value" in descriptor)) {
|
|
153
|
+
return fail(label);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return value;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function exactKeys(value: JsonRecord, expected: readonly string[], label: string): void {
|
|
160
|
+
const actual = Object.keys(value).sort();
|
|
161
|
+
const wanted = [...expected].sort();
|
|
162
|
+
if (actual.length !== wanted.length || actual.some((key, index) => key !== wanted[index])) {
|
|
163
|
+
fail(label);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function fileIdentity(value: unknown, label: string): WhatsAppInteractionProjectionFileIdentity {
|
|
168
|
+
const parsed = record(value, label);
|
|
169
|
+
exactKeys(parsed, ["dev", "ino"], label);
|
|
170
|
+
if (
|
|
171
|
+
typeof parsed.dev !== "string"
|
|
172
|
+
|| !ROWID_PATTERN.test(parsed.dev)
|
|
173
|
+
|| typeof parsed.ino !== "string"
|
|
174
|
+
|| !ROWID_PATTERN.test(parsed.ino)
|
|
175
|
+
|| BigInt(parsed.ino) === 0n
|
|
176
|
+
) fail(label);
|
|
177
|
+
return Object.freeze({ dev: parsed.dev, ino: parsed.ino });
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export function parseWhatsAppInteractionRowid(value: unknown, label = "rowid"): string {
|
|
181
|
+
if (typeof value !== "string" || !ROWID_PATTERN.test(value) || BigInt(value) > MAX_ROWID) {
|
|
182
|
+
return fail(label);
|
|
183
|
+
}
|
|
184
|
+
return value;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function accountSubject(value: unknown): string {
|
|
188
|
+
if (typeof value !== "string" || (!PN_SUBJECT_PATTERN.test(value) && !LID_SUBJECT_PATTERN.test(value))) {
|
|
189
|
+
return fail("accountSubject");
|
|
190
|
+
}
|
|
191
|
+
return value;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function legacyInteractionAccountSubjectJid(subject: string): string {
|
|
195
|
+
const match = /^whatsapp:(pn|lid):([0-9]+)$/u.exec(subject);
|
|
196
|
+
if (match?.[1] === undefined || match[2] === undefined) return fail("accountSubject");
|
|
197
|
+
return match[1] === "pn"
|
|
198
|
+
? `${match[2]}@s.whatsapp.net`
|
|
199
|
+
: `${match[2]}@lid`;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function legacyInteractionParticipantJid(value: string): string {
|
|
203
|
+
const match = /^([0-9]{5,32})(?::[0-9]{1,5})?@(s\.whatsapp\.net|lid)$/u.exec(value);
|
|
204
|
+
if (match?.[1] === undefined || match[2] === undefined) {
|
|
205
|
+
return fail("response.interactions sender direction");
|
|
206
|
+
}
|
|
207
|
+
return `${match[1]}@${match[2]}`;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function jid(
|
|
211
|
+
value: unknown,
|
|
212
|
+
label: string,
|
|
213
|
+
nullable = false,
|
|
214
|
+
allowDevice = false,
|
|
215
|
+
): string | null {
|
|
216
|
+
if (nullable && (value === null || value === "")) return null;
|
|
217
|
+
if (
|
|
218
|
+
typeof value !== "string"
|
|
219
|
+
|| value.length > 96
|
|
220
|
+
|| (!allowDevice && value.includes(":"))
|
|
221
|
+
) return fail(label);
|
|
222
|
+
if (!JID_PATTERNS.some((pattern) => pattern.test(value))) return fail(label);
|
|
223
|
+
return value;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
function timestamp(value: unknown, label: string): string {
|
|
227
|
+
if (
|
|
228
|
+
typeof value !== "string"
|
|
229
|
+
|| !/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.000Z$/u.test(value)
|
|
230
|
+
|| !Number.isFinite(Date.parse(value))
|
|
231
|
+
) return fail(label);
|
|
232
|
+
return value;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export function parseWhatsAppInteractionProjectionRequest(
|
|
236
|
+
value: unknown,
|
|
237
|
+
): WhatsAppInteractionProjectionRequest {
|
|
238
|
+
const parsed = record(value, "request");
|
|
239
|
+
exactKeys(parsed, [
|
|
240
|
+
"schemaVersion", "operation", "accountSubject", "cursor", "limit",
|
|
241
|
+
"cursorAnchor", "storeIdentity", "sessionIdentity", "messageStoreIdentity",
|
|
242
|
+
], "request");
|
|
243
|
+
if (
|
|
244
|
+
parsed.schemaVersion !== WHATSAPP_INTERACTION_PROJECTION_PROTOCOL_VERSION
|
|
245
|
+
|| parsed.operation !== "contacts.interactions.list"
|
|
246
|
+
|| typeof parsed.limit !== "number"
|
|
247
|
+
|| !Number.isSafeInteger(parsed.limit)
|
|
248
|
+
|| parsed.limit < 1
|
|
249
|
+
|| parsed.limit > WHATSAPP_INTERACTION_PROJECTION_MAX_LIMIT
|
|
250
|
+
) fail("request");
|
|
251
|
+
const cursor = parseWhatsAppInteractionRowid(parsed.cursor, "request.cursor");
|
|
252
|
+
const cursorAnchor = parsed.cursorAnchor === null
|
|
253
|
+
? null
|
|
254
|
+
: typeof parsed.cursorAnchor === "string" && SHA256_PATTERN.test(parsed.cursorAnchor)
|
|
255
|
+
? parsed.cursorAnchor
|
|
256
|
+
: fail("request.cursorAnchor");
|
|
257
|
+
if ((cursor === "0") !== (cursorAnchor === null)) fail("request.cursorAnchor");
|
|
258
|
+
return Object.freeze({
|
|
259
|
+
schemaVersion: WHATSAPP_INTERACTION_PROJECTION_PROTOCOL_VERSION,
|
|
260
|
+
operation: "contacts.interactions.list",
|
|
261
|
+
accountSubject: accountSubject(parsed.accountSubject),
|
|
262
|
+
cursor,
|
|
263
|
+
cursorAnchor,
|
|
264
|
+
limit: parsed.limit,
|
|
265
|
+
storeIdentity: fileIdentity(parsed.storeIdentity, "request.storeIdentity"),
|
|
266
|
+
sessionIdentity: fileIdentity(parsed.sessionIdentity, "request.sessionIdentity"),
|
|
267
|
+
messageStoreIdentity: fileIdentity(
|
|
268
|
+
parsed.messageStoreIdentity,
|
|
269
|
+
"request.messageStoreIdentity",
|
|
270
|
+
),
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
function interaction(value: unknown, label: string): WhatsAppInteractionProjectionItem {
|
|
275
|
+
const parsed = record(value, label);
|
|
276
|
+
exactKeys(parsed, [
|
|
277
|
+
"rowid", "chatJid", "messageId", "senderJid", "timestamp", "fromMe", "chatKind",
|
|
278
|
+
], label);
|
|
279
|
+
const rowid = parseWhatsAppInteractionRowid(parsed.rowid, `${label}.rowid`);
|
|
280
|
+
if (BigInt(rowid) < 1n) fail(`${label}.rowid`);
|
|
281
|
+
const messageId = parsed.messageId;
|
|
282
|
+
if (
|
|
283
|
+
typeof messageId !== "string"
|
|
284
|
+
|| !MESSAGE_ID_PATTERN.test(messageId)
|
|
285
|
+
|| typeof parsed.fromMe !== "boolean"
|
|
286
|
+
|| typeof parsed.chatKind !== "string"
|
|
287
|
+
|| !CHAT_KINDS.has(parsed.chatKind)
|
|
288
|
+
) fail(label);
|
|
289
|
+
const chatJid = jid(parsed.chatJid, `${label}.chatJid`)! as string;
|
|
290
|
+
const senderJid = jid(parsed.senderJid, `${label}.senderJid`, true, true);
|
|
291
|
+
if (
|
|
292
|
+
(parsed.chatKind === "dm" && !chatJid.endsWith("@s.whatsapp.net") && !chatJid.endsWith("@lid"))
|
|
293
|
+
|| (parsed.chatKind === "group" && !chatJid.endsWith("@g.us"))
|
|
294
|
+
) fail(`${label}.chatKind`);
|
|
295
|
+
return Object.freeze({
|
|
296
|
+
rowid,
|
|
297
|
+
chatJid,
|
|
298
|
+
messageId,
|
|
299
|
+
senderJid,
|
|
300
|
+
timestamp: timestamp(parsed.timestamp, `${label}.timestamp`),
|
|
301
|
+
fromMe: parsed.fromMe,
|
|
302
|
+
chatKind: parsed.chatKind as WhatsAppInteractionProjectionItem["chatKind"],
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
function accountJidAliases(
|
|
307
|
+
value: unknown,
|
|
308
|
+
subject: string | undefined,
|
|
309
|
+
): WhatsAppInteractionAccountJidAliases {
|
|
310
|
+
const parsed = record(value, "response.accountJidAliases");
|
|
311
|
+
exactKeys(parsed, ["pnJid", "lidJid"], "response.accountJidAliases");
|
|
312
|
+
const pnJid = typeof parsed.pnJid === "string"
|
|
313
|
+
&& /^[1-9][0-9]{4,14}@s\.whatsapp\.net$/u.test(parsed.pnJid)
|
|
314
|
+
? parsed.pnJid
|
|
315
|
+
: fail("response.accountJidAliases.pnJid");
|
|
316
|
+
const lidJid = parsed.lidJid === null
|
|
317
|
+
? null
|
|
318
|
+
: typeof parsed.lidJid === "string" && /^[1-9][0-9]{4,19}@lid$/u.test(parsed.lidJid)
|
|
319
|
+
? parsed.lidJid
|
|
320
|
+
: fail("response.accountJidAliases.lidJid");
|
|
321
|
+
if (subject !== undefined) {
|
|
322
|
+
const bound = legacyInteractionAccountSubjectJid(subject);
|
|
323
|
+
if (bound !== pnJid && bound !== lidJid) fail("response.accountJidAliases binding");
|
|
324
|
+
}
|
|
325
|
+
return Object.freeze({ pnJid, lidJid });
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
export function parseWhatsAppInteractionProjectionResponse(
|
|
329
|
+
value: unknown,
|
|
330
|
+
request?: Pick<
|
|
331
|
+
WhatsAppInteractionProjectionRequest,
|
|
332
|
+
"cursor" | "cursorAnchor" | "limit" | "messageStoreIdentity"
|
|
333
|
+
> & Partial<Pick<WhatsAppInteractionProjectionRequest, "accountSubject">>,
|
|
334
|
+
): WhatsAppInteractionProjectionResponse {
|
|
335
|
+
const parsed = record(value, "response");
|
|
336
|
+
if (parsed.status === "failed") {
|
|
337
|
+
exactKeys(parsed, ["schemaVersion", "status", "errorCode"], "response");
|
|
338
|
+
if (
|
|
339
|
+
parsed.schemaVersion !== WHATSAPP_INTERACTION_PROJECTION_PROTOCOL_VERSION
|
|
340
|
+
|| typeof parsed.errorCode !== "string"
|
|
341
|
+
|| !(WHATSAPP_INTERACTION_PROJECTION_ERROR_CODES as readonly string[]).includes(parsed.errorCode)
|
|
342
|
+
) fail("response");
|
|
343
|
+
return Object.freeze({
|
|
344
|
+
schemaVersion: WHATSAPP_INTERACTION_PROJECTION_PROTOCOL_VERSION,
|
|
345
|
+
status: "failed",
|
|
346
|
+
errorCode: parsed.errorCode as WhatsAppInteractionProjectionErrorCode,
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
exactKeys(parsed, [
|
|
350
|
+
"schemaVersion", "status", "projectionGeneration", "interactions", "nextCursor",
|
|
351
|
+
"localInsertPageComplete", "checkpoint", "accountJidAliases",
|
|
352
|
+
], "response");
|
|
353
|
+
if (
|
|
354
|
+
parsed.schemaVersion !== WHATSAPP_INTERACTION_PROJECTION_PROTOCOL_VERSION
|
|
355
|
+
|| parsed.status !== "succeeded"
|
|
356
|
+
|| typeof parsed.localInsertPageComplete !== "boolean"
|
|
357
|
+
) fail("response");
|
|
358
|
+
const rawInteractions = denseArray(
|
|
359
|
+
parsed.interactions,
|
|
360
|
+
"response.interactions",
|
|
361
|
+
WHATSAPP_INTERACTION_PROJECTION_MAX_LIMIT,
|
|
362
|
+
);
|
|
363
|
+
const projectionGeneration = record(
|
|
364
|
+
parsed.projectionGeneration,
|
|
365
|
+
"response.projectionGeneration",
|
|
366
|
+
);
|
|
367
|
+
exactKeys(projectionGeneration, [
|
|
368
|
+
"messageStoreIdentity", "schemaFingerprint",
|
|
369
|
+
], "response.projectionGeneration");
|
|
370
|
+
const messageStoreIdentity = fileIdentity(
|
|
371
|
+
projectionGeneration.messageStoreIdentity,
|
|
372
|
+
"response.projectionGeneration.messageStoreIdentity",
|
|
373
|
+
);
|
|
374
|
+
if (
|
|
375
|
+
projectionGeneration.schemaFingerprint
|
|
376
|
+
!== WHATSAPP_INTERACTION_PROJECTION_SCHEMA_FINGERPRINT
|
|
377
|
+
|| (request !== undefined
|
|
378
|
+
&& (messageStoreIdentity.dev !== request.messageStoreIdentity.dev
|
|
379
|
+
|| messageStoreIdentity.ino !== request.messageStoreIdentity.ino))
|
|
380
|
+
) fail("response.projectionGeneration");
|
|
381
|
+
if (request !== undefined && (
|
|
382
|
+
rawInteractions.length > request.limit
|
|
383
|
+
|| (!parsed.localInsertPageComplete && rawInteractions.length !== request.limit)
|
|
384
|
+
)) fail("response.interactions");
|
|
385
|
+
const interactions = rawInteractions.map((item, index) =>
|
|
386
|
+
interaction(item, `response.interactions[${index}]`));
|
|
387
|
+
const aliases = accountJidAliases(parsed.accountJidAliases, request?.accountSubject);
|
|
388
|
+
if (request?.accountSubject !== undefined) {
|
|
389
|
+
const selfJids = new Set([aliases.pnJid, aliases.lidJid].filter(
|
|
390
|
+
(value): value is string => value !== null,
|
|
391
|
+
));
|
|
392
|
+
for (const item of interactions) {
|
|
393
|
+
if (item.chatKind !== "dm" && item.chatKind !== "group") continue;
|
|
394
|
+
const senderJid = item.senderJid === null
|
|
395
|
+
? null
|
|
396
|
+
: legacyInteractionParticipantJid(item.senderJid);
|
|
397
|
+
const valid = item.chatKind === "dm"
|
|
398
|
+
? senderJid === null || (item.fromMe ? selfJids.has(senderJid) : senderJid === item.chatJid)
|
|
399
|
+
: senderJid === null || (item.fromMe ? selfJids.has(senderJid) : !selfJids.has(senderJid));
|
|
400
|
+
if (!valid) fail("response.interactions sender direction");
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
for (let index = 0; index < interactions.length; index += 1) {
|
|
404
|
+
const previous = index === 0 ? request?.cursor : interactions[index - 1]?.rowid;
|
|
405
|
+
if (previous !== undefined && BigInt(interactions[index]!.rowid) <= BigInt(previous)) {
|
|
406
|
+
fail("response.interactions ordering");
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
const nextCursor = parsed.nextCursor === null
|
|
410
|
+
? null
|
|
411
|
+
: parseWhatsAppInteractionRowid(parsed.nextCursor, "response.nextCursor");
|
|
412
|
+
if (
|
|
413
|
+
(parsed.localInsertPageComplete && nextCursor !== null)
|
|
414
|
+
|| (!parsed.localInsertPageComplete
|
|
415
|
+
&& (interactions.length === 0 || nextCursor !== interactions.at(-1)?.rowid))
|
|
416
|
+
) fail("response.nextCursor");
|
|
417
|
+
const checkpoint = record(parsed.checkpoint, "response.checkpoint");
|
|
418
|
+
exactKeys(checkpoint, ["cursor", "anchor"], "response.checkpoint");
|
|
419
|
+
const checkpointCursor = parseWhatsAppInteractionRowid(
|
|
420
|
+
checkpoint.cursor,
|
|
421
|
+
"response.checkpoint.cursor",
|
|
422
|
+
);
|
|
423
|
+
const checkpointAnchor = checkpoint.anchor === null
|
|
424
|
+
? null
|
|
425
|
+
: typeof checkpoint.anchor === "string" && SHA256_PATTERN.test(checkpoint.anchor)
|
|
426
|
+
? checkpoint.anchor
|
|
427
|
+
: fail("response.checkpoint.anchor");
|
|
428
|
+
if (
|
|
429
|
+
(checkpointCursor === "0") !== (checkpointAnchor === null)
|
|
430
|
+
|| (interactions.length > 0
|
|
431
|
+
&& checkpointCursor !== interactions.at(-1)?.rowid)
|
|
432
|
+
|| (interactions.length === 0 && request !== undefined
|
|
433
|
+
&& (checkpointCursor !== request.cursor || checkpointAnchor !== request.cursorAnchor))
|
|
434
|
+
|| (!parsed.localInsertPageComplete && nextCursor !== checkpointCursor)
|
|
435
|
+
) fail("response.checkpoint");
|
|
436
|
+
return Object.freeze({
|
|
437
|
+
schemaVersion: WHATSAPP_INTERACTION_PROJECTION_PROTOCOL_VERSION,
|
|
438
|
+
status: "succeeded",
|
|
439
|
+
projectionGeneration: Object.freeze({
|
|
440
|
+
messageStoreIdentity,
|
|
441
|
+
schemaFingerprint: WHATSAPP_INTERACTION_PROJECTION_SCHEMA_FINGERPRINT,
|
|
442
|
+
}),
|
|
443
|
+
accountJidAliases: aliases,
|
|
444
|
+
interactions: Object.freeze(interactions),
|
|
445
|
+
nextCursor,
|
|
446
|
+
localInsertPageComplete: parsed.localInsertPageComplete,
|
|
447
|
+
checkpoint: Object.freeze({ cursor: checkpointCursor, anchor: checkpointAnchor }),
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
export function createWhatsAppInteractionProjectionFailure(
|
|
452
|
+
errorCode: WhatsAppInteractionProjectionErrorCode,
|
|
453
|
+
): WhatsAppInteractionProjectionFailure {
|
|
454
|
+
if (!(WHATSAPP_INTERACTION_PROJECTION_ERROR_CODES as readonly string[]).includes(errorCode)) {
|
|
455
|
+
return fail("errorCode");
|
|
456
|
+
}
|
|
457
|
+
return Object.freeze({
|
|
458
|
+
schemaVersion: WHATSAPP_INTERACTION_PROJECTION_PROTOCOL_VERSION,
|
|
459
|
+
status: "failed",
|
|
460
|
+
errorCode,
|
|
461
|
+
});
|
|
462
|
+
}
|