agenttwin 0.3.21 → 0.3.23
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/dist/api.js +2113 -609
- package/dist/dashboard/assets/dashboard/agent-home.css +7 -7
- package/dist/dashboard/assets/dashboard/bay-morning.webp +0 -0
- package/dist/dashboard/assets/dashboard/golden-gate-afternoon.webp +0 -0
- package/dist/dashboard/assets/dashboard/golden-gate-portrait.webp +0 -0
- package/dist/dashboard/assets/dashboard/moonlit-coast.webp +0 -0
- package/dist/dashboard/assets/next/static/chunks/{1250-7571b1a697f6bb4a.js → 1250-a3c859fd20517500.js} +1 -1
- package/dist/dashboard/assets/next/static/chunks/{2743-a0efd6f4aeb11cc5.js → 2743-72610a5d5a3f8462.js} +1 -1
- package/dist/dashboard/assets/next/static/chunks/5663-403316746afad10e.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/dashboard/{page-9c11295678539a5f.js → page-0e0392368e0a891e.js} +1 -1
- package/dist/dashboard/assets/next/static/chunks/app/docs/[[...slug]]/page-4981ea4966b19e3e.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/onboarding/page-dd4ac0f5f36e6bfa.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/v2/dashboard/{page-34574448d210c775.js → page-de0fe6d84be21e6a.js} +1 -1
- package/dist/dashboard/assets/next/static/chunks/app/v2/onboarding/page-360cbffc57981f6b.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/v2/page-fc4df4912ce3af44.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/{webpack-40324749d289e4a5.js → webpack-9e40ef55e5f2fb53.js} +1 -1
- package/dist/dashboard/assets/next/static/css/{42045de5f39b50ca.css → 37d81e1d2804cc5f.css} +1 -1
- package/dist/dashboard/assets/next/static/css/69ec1bae997c3bb0.css +1 -0
- package/dist/dashboard/assets/next/static/css/ad85402a1595e56e.css +1 -0
- package/dist/dashboard/assets/next/static/css/{4bbe78c2fe206b92.css → da981fb878a02b8c.css} +1 -1
- package/dist/dashboard/assets/next/static/media/bay-morning.82669113.webp +0 -0
- package/dist/dashboard/assets/next/static/media/golden-gate-afternoon.0aa49492.webp +0 -0
- package/dist/dashboard/assets/next/static/media/golden-gate-portrait.89fc667a.webp +0 -0
- package/dist/dashboard/assets/next/static/media/moonlit-coast.09739ef4.webp +0 -0
- package/dist/dashboard/index.html +2 -2
- package/dist/engine.js +6386 -4974
- package/dist/gateway.js +2194 -604
- package/dist/twins/catalog.json +6020 -0
- package/dist/twins/engine/v2/THIRD-PARTY.txt +25 -0
- package/dist/twins/engine/v2/chunks/2CHBP57N.mjs +8 -0
- package/dist/twins/engine/v2/chunks/4CPL6MPF.mjs +30 -0
- package/dist/twins/engine/v2/chunks/OYLYKZGD.mjs +2 -0
- package/dist/twins/engine/v2/chunks/SQSP35HM.mjs +38 -0
- package/dist/twins/engine/v2/chunks/YSJQQVUM.mjs +2 -0
- package/dist/twins/engine/v2/react-dom_client.mjs +272 -0
- package/dist/twins/engine/v2/react-dom_server.mjs +263 -0
- package/dist/twins/engine/v2/react.mjs +2 -0
- package/dist/twins/engine/v2/react_jsx-runtime.mjs +31 -0
- package/dist/twins/engine/v2/volter_world-core.mjs +195 -0
- package/dist/twins/engine/v2/volter_world-core_app-route.mjs +2 -0
- package/dist/twins/engine/v2/volter_world-core_network-policy.mjs +2 -0
- package/dist/twins/engine/v3/THIRD-PARTY.txt +65 -0
- package/dist/twins/engine/v3/chunks/2CHBP57N.mjs +8 -0
- package/dist/twins/engine/v3/chunks/2YSSPA5O.mjs +65 -0
- package/dist/twins/engine/v3/chunks/5PWRY4UK.mjs +154 -0
- package/dist/twins/engine/v3/chunks/7XRKSFFJ.mjs +2 -0
- package/dist/twins/engine/v3/chunks/AWOWH2H5.mjs +2 -0
- package/dist/twins/engine/v3/chunks/C46M5U3Q.mjs +2 -0
- package/dist/twins/engine/v3/chunks/MFH2VZPP.mjs +2 -0
- package/dist/twins/engine/v3/chunks/MWCO5UV3.mjs +2 -0
- package/dist/twins/engine/v3/chunks/N5BL5RDF.mjs +313 -0
- package/dist/twins/engine/v3/chunks/O7HGPMXG.mjs +2 -0
- package/dist/twins/engine/v3/chunks/OYLYKZGD.mjs +2 -0
- package/dist/twins/engine/v3/chunks/PLB7HTON.mjs +8 -0
- package/dist/twins/engine/v3/chunks/TY4LDBVH.mjs +7 -0
- package/dist/twins/engine/v3/chunks/VDIRUSCM.mjs +2 -0
- package/dist/twins/engine/v3/chunks/WGUCFQK6.mjs +2 -0
- package/dist/twins/engine/v3/chunks/WPATONSC.mjs +2 -0
- package/dist/twins/engine/v3/react_jsx-runtime.mjs +2 -0
- package/dist/twins/engine/v3/volter_world-core.mjs +2 -0
- package/dist/twins/engine/v3/volter_world-ui.mjs +559 -0
- package/dist/twins/packs/ahrefs/LICENSE +202 -0
- package/dist/twins/packs/ahrefs/NOTICE +7 -0
- package/dist/twins/packs/ahrefs/index.mjs +2 -0
- package/dist/twins/packs/ai-gateway/LICENSE +202 -0
- package/dist/twins/packs/ai-gateway/NOTICE +7 -0
- package/dist/twins/packs/ai-gateway/index.mjs +14 -0
- package/dist/twins/packs/airtable/LICENSE +202 -0
- package/dist/twins/packs/airtable/NOTICE +7 -0
- package/dist/twins/packs/airtable/index.mjs +2 -0
- package/dist/twins/packs/algolia/LICENSE +202 -0
- package/dist/twins/packs/algolia/NOTICE +7 -0
- package/dist/twins/packs/algolia/index.mjs +2 -0
- package/dist/twins/packs/ambientcg/LICENSE +202 -0
- package/dist/twins/packs/ambientcg/NOTICE +7 -0
- package/dist/twins/packs/ambientcg/index.mjs +2 -0
- package/dist/twins/packs/anthropic/LICENSE +202 -0
- package/dist/twins/packs/anthropic/NOTICE +7 -0
- package/dist/twins/packs/anthropic/index.mjs +18 -0
- package/dist/twins/packs/assemblyai/LICENSE +202 -0
- package/dist/twins/packs/assemblyai/NOTICE +7 -0
- package/dist/twins/packs/assemblyai/index.mjs +11 -0
- package/dist/twins/packs/aws/LICENSE +202 -0
- package/dist/twins/packs/aws/NOTICE +7 -0
- package/dist/twins/packs/aws/index.mjs +2 -0
- package/dist/twins/packs/azure/LICENSE +202 -0
- package/dist/twins/packs/azure/NOTICE +7 -0
- package/dist/twins/packs/azure/index.mjs +38 -0
- package/dist/twins/packs/azureformrecognizer/LICENSE +202 -0
- package/dist/twins/packs/azureformrecognizer/NOTICE +7 -0
- package/dist/twins/packs/azureformrecognizer/index.mjs +3 -0
- package/dist/twins/packs/bitly/LICENSE +202 -0
- package/dist/twins/packs/bitly/NOTICE +7 -0
- package/dist/twins/packs/bitly/index.mjs +2 -0
- package/dist/twins/packs/bluesky/LICENSE +202 -0
- package/dist/twins/packs/bluesky/NOTICE +7 -0
- package/dist/twins/packs/bluesky/index.mjs +30 -0
- package/dist/twins/packs/calcom/LICENSE +202 -0
- package/dist/twins/packs/calcom/NOTICE +7 -0
- package/dist/twins/packs/calcom/index.mjs +2 -0
- package/dist/twins/packs/clerk/LICENSE +202 -0
- package/dist/twins/packs/clerk/NOTICE +7 -0
- package/dist/twins/packs/clerk/index.mjs +5 -0
- package/dist/twins/packs/cloudflare/LICENSE +202 -0
- package/dist/twins/packs/cloudflare/NOTICE +7 -0
- package/dist/twins/packs/cloudflare/index.mjs +79 -0
- package/dist/twins/packs/cohere/LICENSE +202 -0
- package/dist/twins/packs/cohere/NOTICE +7 -0
- package/dist/twins/packs/cohere/index.mjs +2 -0
- package/dist/twins/packs/datadog/LICENSE +202 -0
- package/dist/twins/packs/datadog/NOTICE +7 -0
- package/dist/twins/packs/datadog/index.mjs +3 -0
- package/dist/twins/packs/deepinfra/LICENSE +202 -0
- package/dist/twins/packs/deepinfra/NOTICE +7 -0
- package/dist/twins/packs/deepinfra/index.mjs +13 -0
- package/dist/twins/packs/deepseek/LICENSE +202 -0
- package/dist/twins/packs/deepseek/NOTICE +7 -0
- package/dist/twins/packs/deepseek/index.mjs +12 -0
- package/dist/twins/packs/discord/LICENSE +202 -0
- package/dist/twins/packs/discord/NOTICE +7 -0
- package/dist/twins/packs/discord/index.mjs +2 -0
- package/dist/twins/packs/duckduckgo/LICENSE +202 -0
- package/dist/twins/packs/duckduckgo/NOTICE +7 -0
- package/dist/twins/packs/duckduckgo/index.mjs +532 -0
- package/dist/twins/packs/dynadot/LICENSE +202 -0
- package/dist/twins/packs/dynadot/NOTICE +7 -0
- package/dist/twins/packs/dynadot/index.mjs +2 -0
- package/dist/twins/packs/e2b/LICENSE +202 -0
- package/dist/twins/packs/e2b/NOTICE +7 -0
- package/dist/twins/packs/e2b/index.mjs +2 -0
- package/dist/twins/packs/elevenlabs/LICENSE +202 -0
- package/dist/twins/packs/elevenlabs/NOTICE +7 -0
- package/dist/twins/packs/elevenlabs/index.mjs +4 -0
- package/dist/twins/packs/expo/LICENSE +202 -0
- package/dist/twins/packs/expo/NOTICE +7 -0
- package/dist/twins/packs/expo/index.mjs +2 -0
- package/dist/twins/packs/fal/LICENSE +202 -0
- package/dist/twins/packs/fal/NOTICE +7 -0
- package/dist/twins/packs/fal/index.mjs +2 -0
- package/dist/twins/packs/figma/LICENSE +202 -0
- package/dist/twins/packs/figma/NOTICE +7 -0
- package/dist/twins/packs/figma/index.mjs +2 -0
- package/dist/twins/packs/firecrawl/LICENSE +202 -0
- package/dist/twins/packs/firecrawl/NOTICE +7 -0
- package/dist/twins/packs/firecrawl/index.mjs +9 -0
- package/dist/twins/packs/fireworks/LICENSE +202 -0
- package/dist/twins/packs/fireworks/NOTICE +7 -0
- package/dist/twins/packs/fireworks/index.mjs +13 -0
- package/dist/twins/packs/fly/LICENSE +202 -0
- package/dist/twins/packs/fly/NOTICE +7 -0
- package/dist/twins/packs/fly/index.mjs +2 -0
- package/dist/twins/packs/gcs/LICENSE +202 -0
- package/dist/twins/packs/gcs/NOTICE +7 -0
- package/dist/twins/packs/gcs/index.mjs +8 -0
- package/dist/twins/packs/gemini/LICENSE +202 -0
- package/dist/twins/packs/gemini/NOTICE +7 -0
- package/dist/twins/packs/gemini/index.mjs +7 -0
- package/dist/twins/packs/github/LICENSE +202 -0
- package/dist/twins/packs/github/NOTICE +7 -0
- package/dist/twins/packs/github/index.mjs +75153 -0
- package/dist/twins/packs/googleads/LICENSE +202 -0
- package/dist/twins/packs/googleads/NOTICE +7 -0
- package/dist/twins/packs/googleads/index.mjs +3 -0
- package/dist/twins/packs/googlemaps/LICENSE +202 -0
- package/dist/twins/packs/googlemaps/NOTICE +7 -0
- package/dist/twins/packs/googlemaps/index.mjs +2 -0
- package/dist/twins/packs/googleoauth/LICENSE +202 -0
- package/dist/twins/packs/googleoauth/NOTICE +7 -0
- package/dist/twins/packs/googleoauth/index.mjs +2 -0
- package/dist/twins/packs/hackernews/LICENSE +202 -0
- package/dist/twins/packs/hackernews/NOTICE +7 -0
- package/dist/twins/packs/hackernews/index.mjs +35 -0
- package/dist/twins/packs/huggingface/LICENSE +202 -0
- package/dist/twins/packs/huggingface/NOTICE +7 -0
- package/dist/twins/packs/huggingface/index.mjs +9 -0
- package/dist/twins/packs/inngest/LICENSE +202 -0
- package/dist/twins/packs/inngest/NOTICE +7 -0
- package/dist/twins/packs/inngest/index.mjs +2 -0
- package/dist/twins/packs/instagram/LICENSE +202 -0
- package/dist/twins/packs/instagram/NOTICE +7 -0
- package/dist/twins/packs/instagram/index.mjs +2 -0
- package/dist/twins/packs/jira/LICENSE +202 -0
- package/dist/twins/packs/jira/NOTICE +7 -0
- package/dist/twins/packs/jira/index.mjs +2 -0
- package/dist/twins/packs/langfuse/LICENSE +202 -0
- package/dist/twins/packs/langfuse/NOTICE +7 -0
- package/dist/twins/packs/langfuse/index.mjs +2 -0
- package/dist/twins/packs/linear/LICENSE +202 -0
- package/dist/twins/packs/linear/NOTICE +7 -0
- package/dist/twins/packs/linear/index.mjs +52866 -0
- package/dist/twins/packs/linkedin/LICENSE +202 -0
- package/dist/twins/packs/linkedin/NOTICE +7 -0
- package/dist/twins/packs/linkedin/index.mjs +78 -0
- package/dist/twins/packs/livekit/LICENSE +202 -0
- package/dist/twins/packs/livekit/NOTICE +7 -0
- package/dist/twins/packs/livekit/index.mjs +2 -0
- package/dist/twins/packs/mailgun/LICENSE +202 -0
- package/dist/twins/packs/mailgun/NOTICE +7 -0
- package/dist/twins/packs/mailgun/index.mjs +13 -0
- package/dist/twins/packs/mapbox/LICENSE +202 -0
- package/dist/twins/packs/mapbox/NOTICE +7 -0
- package/dist/twins/packs/mapbox/index.mjs +2 -0
- package/dist/twins/packs/merge/LICENSE +202 -0
- package/dist/twins/packs/merge/NOTICE +7 -0
- package/dist/twins/packs/merge/index.mjs +4 -0
- package/dist/twins/packs/mistral/LICENSE +202 -0
- package/dist/twins/packs/mistral/NOTICE +7 -0
- package/dist/twins/packs/mistral/index.mjs +6 -0
- package/dist/twins/packs/mixpanel/LICENSE +202 -0
- package/dist/twins/packs/mixpanel/NOTICE +8 -0
- package/dist/twins/packs/mixpanel/index.mjs +2 -0
- package/dist/twins/packs/mongodb/LICENSE +202 -0
- package/dist/twins/packs/mongodb/NOTICE +7 -0
- package/dist/twins/packs/mongodb/index.mjs +8 -0
- package/dist/twins/packs/moonshot/LICENSE +202 -0
- package/dist/twins/packs/moonshot/NOTICE +7 -0
- package/dist/twins/packs/moonshot/index.mjs +18 -0
- package/dist/twins/packs/notion/LICENSE +202 -0
- package/dist/twins/packs/notion/NOTICE +7 -0
- package/dist/twins/packs/notion/index.mjs +2 -0
- package/dist/twins/packs/npm-registry/LICENSE +202 -0
- package/dist/twins/packs/npm-registry/NOTICE +7 -0
- package/dist/twins/packs/npm-registry/index.mjs +2 -0
- package/dist/twins/packs/oa-treasury/LICENSE +202 -0
- package/dist/twins/packs/oa-treasury/NOTICE +8 -0
- package/dist/twins/packs/oa-treasury/index.mjs +16 -0
- package/dist/twins/packs/openai/LICENSE +202 -0
- package/dist/twins/packs/openai/NOTICE +7 -0
- package/dist/twins/packs/openai/index.mjs +3473 -0
- package/dist/twins/packs/openrouter/LICENSE +202 -0
- package/dist/twins/packs/openrouter/NOTICE +7 -0
- package/dist/twins/packs/openrouter/index.mjs +2 -0
- package/dist/twins/packs/openweather/LICENSE +202 -0
- package/dist/twins/packs/openweather/NOTICE +7 -0
- package/dist/twins/packs/openweather/index.mjs +2 -0
- package/dist/twins/packs/paypal/LICENSE +202 -0
- package/dist/twins/packs/paypal/NOTICE +7 -0
- package/dist/twins/packs/paypal/index.mjs +51 -0
- package/dist/twins/packs/pinecone/LICENSE +202 -0
- package/dist/twins/packs/pinecone/NOTICE +7 -0
- package/dist/twins/packs/pinecone/index.mjs +2 -0
- package/dist/twins/packs/plain/LICENSE +202 -0
- package/dist/twins/packs/plain/NOTICE +8 -0
- package/dist/twins/packs/plain/index.mjs +18426 -0
- package/dist/twins/packs/planetscale/LICENSE +202 -0
- package/dist/twins/packs/planetscale/NOTICE +7 -0
- package/dist/twins/packs/planetscale/index.mjs +18 -0
- package/dist/twins/packs/polar/LICENSE +202 -0
- package/dist/twins/packs/polar/NOTICE +7 -0
- package/dist/twins/packs/polar/index.mjs +2 -0
- package/dist/twins/packs/polyhaven/LICENSE +202 -0
- package/dist/twins/packs/polyhaven/NOTICE +7 -0
- package/dist/twins/packs/polyhaven/index.mjs +3 -0
- package/dist/twins/packs/postmark/LICENSE +202 -0
- package/dist/twins/packs/postmark/NOTICE +7 -0
- package/dist/twins/packs/postmark/index.mjs +12 -0
- package/dist/twins/packs/reddit/LICENSE +202 -0
- package/dist/twins/packs/reddit/NOTICE +7 -0
- package/dist/twins/packs/reddit/index.mjs +324 -0
- package/dist/twins/packs/redis/LICENSE +202 -0
- package/dist/twins/packs/redis/NOTICE +7 -0
- package/dist/twins/packs/redis/index.mjs +2 -0
- package/dist/twins/packs/replicate/LICENSE +202 -0
- package/dist/twins/packs/replicate/NOTICE +7 -0
- package/dist/twins/packs/replicate/index.mjs +2 -0
- package/dist/twins/packs/resend/LICENSE +202 -0
- package/dist/twins/packs/resend/NOTICE +7 -0
- package/dist/twins/packs/resend/index.mjs +139 -0
- package/dist/twins/packs/runhuman/LICENSE +202 -0
- package/dist/twins/packs/runhuman/NOTICE +7 -0
- package/dist/twins/packs/runhuman/index.mjs +3 -0
- package/dist/twins/packs/scrapecreators/LICENSE +202 -0
- package/dist/twins/packs/scrapecreators/NOTICE +7 -0
- package/dist/twins/packs/scrapecreators/index.mjs +2 -0
- package/dist/twins/packs/segment/LICENSE +202 -0
- package/dist/twins/packs/segment/NOTICE +8 -0
- package/dist/twins/packs/segment/index.mjs +2 -0
- package/dist/twins/packs/sendblue/LICENSE +202 -0
- package/dist/twins/packs/sendblue/NOTICE +7 -0
- package/dist/twins/packs/sendblue/index.mjs +2 -0
- package/dist/twins/packs/sendgrid/LICENSE +202 -0
- package/dist/twins/packs/sendgrid/NOTICE +8 -0
- package/dist/twins/packs/sendgrid/index.mjs +4 -0
- package/dist/twins/packs/sentry/LICENSE +202 -0
- package/dist/twins/packs/sentry/NOTICE +7 -0
- package/dist/twins/packs/sentry/index.mjs +5 -0
- package/dist/twins/packs/sigstore/LICENSE +202 -0
- package/dist/twins/packs/sigstore/NOTICE +7 -0
- package/dist/twins/packs/sigstore/index.mjs +12 -0
- package/dist/twins/packs/slack/LICENSE +202 -0
- package/dist/twins/packs/slack/NOTICE +7 -0
- package/dist/twins/packs/slack/index.mjs +66 -0
- package/dist/twins/packs/smtp/LICENSE +202 -0
- package/dist/twins/packs/smtp/NOTICE +7 -0
- package/dist/twins/packs/smtp/index.mjs +3 -0
- package/dist/twins/packs/snowflake/LICENSE +202 -0
- package/dist/twins/packs/snowflake/NOTICE +8 -0
- package/dist/twins/packs/snowflake/index.mjs +30 -0
- package/dist/twins/packs/stigg/LICENSE +202 -0
- package/dist/twins/packs/stigg/NOTICE +8 -0
- package/dist/twins/packs/stigg/index.mjs +22194 -0
- package/dist/twins/packs/stream/LICENSE +202 -0
- package/dist/twins/packs/stream/NOTICE +7 -0
- package/dist/twins/packs/stream/index.mjs +2 -0
- package/dist/twins/packs/stripe/LICENSE +202 -0
- package/dist/twins/packs/stripe/NOTICE +7 -0
- package/dist/twins/packs/stripe/index.mjs +211 -0
- package/dist/twins/packs/supabase/LICENSE +202 -0
- package/dist/twins/packs/supabase/NOTICE +7 -0
- package/dist/twins/packs/supabase/index.mjs +2 -0
- package/dist/twins/packs/supermemory/LICENSE +202 -0
- package/dist/twins/packs/supermemory/NOTICE +7 -0
- package/dist/twins/packs/supermemory/index.mjs +2 -0
- package/dist/twins/packs/svix/LICENSE +202 -0
- package/dist/twins/packs/svix/NOTICE +7 -0
- package/dist/twins/packs/svix/index.mjs +2 -0
- package/dist/twins/packs/tavily/LICENSE +202 -0
- package/dist/twins/packs/tavily/NOTICE +7 -0
- package/dist/twins/packs/tavily/index.mjs +2 -0
- package/dist/twins/packs/telegram/LICENSE +202 -0
- package/dist/twins/packs/telegram/NOTICE +7 -0
- package/dist/twins/packs/telegram/index.mjs +11 -0
- package/dist/twins/packs/temporal/LICENSE +202 -0
- package/dist/twins/packs/temporal/NOTICE +7 -0
- package/dist/twins/packs/temporal/index.mjs +44 -0
- package/dist/twins/packs/tiktok/LICENSE +202 -0
- package/dist/twins/packs/tiktok/NOTICE +7 -0
- package/dist/twins/packs/tiktok/index.mjs +2 -0
- package/dist/twins/packs/tinybird/LICENSE +202 -0
- package/dist/twins/packs/tinybird/NOTICE +7 -0
- package/dist/twins/packs/tinybird/index.mjs +50 -0
- package/dist/twins/packs/togetherai/LICENSE +202 -0
- package/dist/twins/packs/togetherai/NOTICE +7 -0
- package/dist/twins/packs/togetherai/index.mjs +11 -0
- package/dist/twins/packs/tremendous/LICENSE +202 -0
- package/dist/twins/packs/tremendous/NOTICE +7 -0
- package/dist/twins/packs/tremendous/index.mjs +2 -0
- package/dist/twins/packs/tripo/LICENSE +202 -0
- package/dist/twins/packs/tripo/NOTICE +7 -0
- package/dist/twins/packs/tripo/index.mjs +9 -0
- package/dist/twins/packs/tunnel/LICENSE +202 -0
- package/dist/twins/packs/tunnel/NOTICE +7 -0
- package/dist/twins/packs/tunnel/index.mjs +2 -0
- package/dist/twins/packs/twelvelabs/LICENSE +202 -0
- package/dist/twins/packs/twelvelabs/NOTICE +7 -0
- package/dist/twins/packs/twelvelabs/index.mjs +5 -0
- package/dist/twins/packs/twilio/LICENSE +202 -0
- package/dist/twins/packs/twilio/NOTICE +7 -0
- package/dist/twins/packs/twilio/index.mjs +2 -0
- package/dist/twins/packs/twitch/LICENSE +202 -0
- package/dist/twins/packs/twitch/NOTICE +7 -0
- package/dist/twins/packs/twitch/index.mjs +68 -0
- package/dist/twins/packs/upstash/LICENSE +202 -0
- package/dist/twins/packs/upstash/NOTICE +7 -0
- package/dist/twins/packs/upstash/index.mjs +14 -0
- package/dist/twins/packs/upstashvector/LICENSE +202 -0
- package/dist/twins/packs/upstashvector/NOTICE +7 -0
- package/dist/twins/packs/upstashvector/index.mjs +3 -0
- package/dist/twins/packs/vercel/LICENSE +202 -0
- package/dist/twins/packs/vercel/NOTICE +7 -0
- package/dist/twins/packs/vercel/index.mjs +10 -0
- package/dist/twins/packs/veriff/LICENSE +202 -0
- package/dist/twins/packs/veriff/NOTICE +7 -0
- package/dist/twins/packs/veriff/index.mjs +2 -0
- package/dist/twins/packs/vgauth/LICENSE +202 -0
- package/dist/twins/packs/vgauth/NOTICE +7 -0
- package/dist/twins/packs/vgauth/index.mjs +2 -0
- package/dist/twins/packs/vital/LICENSE +202 -0
- package/dist/twins/packs/vital/NOTICE +7 -0
- package/dist/twins/packs/vital/index.mjs +2 -0
- package/dist/twins/packs/volteridentity/LICENSE +202 -0
- package/dist/twins/packs/volteridentity/NOTICE +7 -0
- package/dist/twins/packs/volteridentity/index.mjs +2 -0
- package/dist/twins/packs/webrisk/LICENSE +202 -0
- package/dist/twins/packs/webrisk/NOTICE +7 -0
- package/dist/twins/packs/webrisk/index.mjs +2 -0
- package/dist/twins/packs/worldlabs/LICENSE +202 -0
- package/dist/twins/packs/worldlabs/NOTICE +7 -0
- package/dist/twins/packs/worldlabs/index.mjs +2 -0
- package/dist/twins/packs/x/LICENSE +202 -0
- package/dist/twins/packs/x/NOTICE +7 -0
- package/dist/twins/packs/x/index.mjs +63 -0
- package/dist/twins/packs/xai/LICENSE +202 -0
- package/dist/twins/packs/xai/NOTICE +7 -0
- package/dist/twins/packs/xai/index.mjs +4 -0
- package/dist/twins/packs/xidentity/LICENSE +202 -0
- package/dist/twins/packs/xidentity/NOTICE +8 -0
- package/dist/twins/packs/xidentity/index.mjs +209 -0
- package/dist/twins/packs/youtube/LICENSE +202 -0
- package/dist/twins/packs/youtube/NOTICE +7 -0
- package/dist/twins/packs/youtube/index.mjs +5 -0
- package/dist/worker.js +442 -18
- package/dist/world-host.js +928 -91
- package/package.json +6 -5
- package/dist/dashboard/assets/dashboard/bay-morning.png +0 -0
- package/dist/dashboard/assets/dashboard/golden-gate-afternoon.png +0 -0
- package/dist/dashboard/assets/dashboard/golden-gate-portrait.png +0 -0
- package/dist/dashboard/assets/dashboard/moonlit-coast.png +0 -0
- package/dist/dashboard/assets/next/static/chunks/2868-424d32cfc8ae81c9.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/docs/[[...slug]]/page-f9fca2c08f779fa0.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/onboarding/page-bc480c9258e5cc4d.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/v2/onboarding/page-f04c0b236abaead3.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/v2/page-07c8054d57c9089b.js +0 -1
- package/dist/dashboard/assets/next/static/css/4af3c8ca0da0f48b.css +0 -1
- package/dist/dashboard/assets/next/static/css/6b8edde77e493a51.css +0 -1
- package/dist/dashboard/assets/next/static/media/bay-morning.1a9f358c.png +0 -0
- package/dist/dashboard/assets/next/static/media/golden-gate-afternoon.3e7cea58.png +0 -0
- package/dist/dashboard/assets/next/static/media/golden-gate-portrait.7941528f.png +0 -0
- package/dist/dashboard/assets/next/static/media/moonlit-coast.bbe901a1.png +0 -0
- /package/dist/dashboard/assets/next/static/{5ub3D2yzS8DE7w2qZd1nv → GTd0IQ6HYyhE_2HqcgFno}/_buildManifest.js +0 -0
- /package/dist/dashboard/assets/next/static/{5ub3D2yzS8DE7w2qZd1nv → GTd0IQ6HYyhE_2HqcgFno}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import{createRequire as __atReq}from'node:module';const require=__atReq(import.meta.url);
|
|
2
|
+
import{worldNow as Lo}from"../../engine/v2/volter_world-core.mjs";import{applyTwinWrite as ot,applyTwinWriteAtomic as nt,projectResources as eo}from"../../engine/v2/volter_world-core.mjs";var V="paypal";function W(e){return eo(V,e)}function A(e,t){return W(e).filter(o=>o.type===t)}function f(e,t,o){return W(e).find(n=>n.type===t&&n.id===o)}function to(e,t,o){let n=e.find(r=>r.type===t&&r.id===o);return(typeof n?.rev=="number"?n.rev:0)+1}async function b(e,t,o,n,r){let{resource:i}=await ot(V,{operation:o,subjectType:e,subjectId:t,fields:n,...r.occurredAt?{occurredAt:r.occurredAt}:{},actor:{kind:"agent"}},r.root);return i}async function g(e,t,o,n,r){return await nt(V,i=>({kind:"write",value:void 0,write:{operation:o,subjectType:e,subjectId:t,fields:{...n(i),rev:to(i,e,t)},...r.occurredAt?{occurredAt:r.occurredAt}:{},actor:{kind:"agent"}}}),r.root),f(r.root,e,t)}async function rt(e,t,o,n){let{resource:r}=await ot(V,{operation:o,subjectType:e.type,subjectId:e.id,fields:e.fields,projection:{creates:t.map(i=>({type:i.type,id:i.id,fields:i.fields}))},...n.occurredAt?{occurredAt:n.occurredAt}:{},actor:{kind:"agent"}},n.root);return r}function ie(e,t){let o="";for(let n=0;o.length<t;n+=1){let r=2166136261,i=`${n}:${e}`;for(let a=0;a<i.length;a+=1)r^=i.charCodeAt(a),r=Math.imul(r,16777619)>>>0;o+=r.toString(16).padStart(8,"0")}return o.slice(0,t)}var oo="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";function R(e,t){let o=ie(e,t*2),n="";for(let r=0;r<t;r+=1)n+=oo[parseInt(o.slice(r*2,r*2+2),16)%36];return n}function be(e,t,o,n){return`${t}:${o}:${A(e,t).length}:${n}`}function it(e,t,o,n){return`${t}:${o}:${e.filter(r=>r.type===t).length}:${n}`}var at=(e,t,o)=>R(be(e,"payout_batch",t,o),13),st=(e,t,o)=>R(it(e,"payout_item",t,o),13),ve=(e,t)=>R(`${t}:${e}`,17),ct=(e,t,o)=>R(be(e,"webhook",t,o),17),ut=(e,t,o)=>{let n=it(e,"webhook_event",t,o);return`WH-${R(`a:${n}`,17)}-${R(`b:${n}`,17)}`},ae=e=>R(`payer:${e}`,13),no={access_token:"A21AA",refresh_token:"R21AA",authorization_code:"C21AA"},x=(e,t,o,n)=>`${no[t]}${R(be(e,t,o,n),75)}`,ro=["clientId","redirectUri","scope","state","accountId","flowEntry"];function tt(e){return ro.map(t=>`${t}=${String(e[t]??"")}`).join("")}function pt(e,t,o){let n=A(e,"auth_request"),r=tt(o),i=n.find(a=>a.settled!==!0&&tt(a)===r);return i?String(i.id):`ar_${ie(`auth_request:${t}:${n.length}`,32)}`}var re="AeA1QIZXifBoJ3pOFrOSpAM0pFPOWFn3TwesXgkerlIx0X1PhCfYQGoZOQEZPPXEWvtMvNUEyNuEmpCg",dt="EGnHDxD_qRPdaLdHCKfqSPNzaJHkzSkKnBl3BAcfHfNmbLQeXHFiAgYAcgqIRLVWXPOqVLmjpLDMxIuc",z="APP-80W284485P519543T",Se="A21AATWINTESTTOKENDONOTUSEINPRODUCTIONAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",io=["https://uri.paypal.com/payments/payouts","https://uri.paypal.com/services/payments/payouts-item/reverse","https://uri.paypal.com/services/payments/payout-applications/status","https://uri.paypal.com/services/payments/payout-applications/update-status","https://uri.paypal.com/services/applications/webhooks","openid"].join(" "),Te=[{id:"TWINPERSONA0001",email:"ada@twin.example",emailVerified:!0,givenName:"Ada",familyName:"Lovelace",accountType:"PERSONAL",verifiedAccount:!0,locale:"en_US",zoneinfo:"America/Los_Angeles",address:{street_address:"1 Analytical Way",locality:"San Jose",region:"CA",postal_code:"95131",country:"US"}},{id:"TWINPERSONA0002",email:"grace@twin.example",emailVerified:!1,givenName:"Grace",familyName:"Hopper",accountType:"BUSINESS",verifiedAccount:!1,locale:"en_US",zoneinfo:"America/New_York",address:{street_address:"2 Compiler Row",locality:"Arlington",region:"VA",postal_code:"22202",country:"US"}}],ao="/api/paypal/callback";function so(e){let t=(e??"").trim().replace(/\/+$/,"");if(!t)return[];let o;try{o=new URL(t)}catch{return[t]}if(o.protocol!=="http:")return[t];let n=o.port?`:${o.port}`:"";return o.hostname==="localhost"?[t,`http://127.0.0.1${n}`]:o.hostname==="127.0.0.1"?[t,`http://localhost${n}`]:[t]}function lt(e){return so(e).map(t=>`${t}${ao}`)}async function ft(e){await nt(V,t=>{let o=(a,s)=>t.some(c=>c.type===a&&c.id===s),n=[];o("oauth_client",re)||n.push({type:"oauth_client",id:re,fields:{name:"Twin Demo App",secret:dt,appId:z,redirectUris:lt(e.origin),rev:1}});for(let a of Te)o("account",a.id)||n.push({type:"account",id:a.id,fields:{email:a.email,emailVerified:a.emailVerified,givenName:a.givenName,familyName:a.familyName,accountType:a.accountType,verifiedAccount:a.verifiedAccount,locale:a.locale,zoneinfo:a.zoneinfo,address:a.address,rev:1}});if(o("session","current")||n.push({type:"session",id:"current",fields:{accountId:Te[0].id,rev:1}}),o("access_token",Se)||n.push({type:"access_token",id:Se,fields:{clientId:re,grantType:"client_credentials",scope:io,expiresAt:null,seeded:!0,rev:1}}),n.length===0)return{kind:"skip",value:void 0};let[r,...i]=n;return{kind:"write",value:void 0,write:{operation:"seed.ensure",subjectType:r.type,subjectId:r.id,fields:r.fields,projection:{creates:i.map(a=>({type:a.type,id:a.id,fields:a.fields}))},...e.occurredAt?{occurredAt:e.occurredAt}:{},actor:{kind:"system"}}}},e.root)}function j(e){let t=f(e,"session","current"),o=typeof t?.accountId=="string"?t.accountId:void 0;return o?f(e,"account",o):void 0}function Ie(e,t){let o=Array.isArray(e.redirectUris)?e.redirectUris:[];return t.includes("#")?!1:o.includes(t)}function Pe(e){return ie(`debug:${e}`,16)}function v(e,t,o,n){let r={name:t,message:o,debug_id:Pe(`${e}:${t}:${n.seed}`)};return n.details&&n.details.length>0&&(r.details=n.details),n.links&&n.links.length>0&&(r.links=n.links),{status:e,body:r}}var h=(e,t)=>v(400,"INVALID_REQUEST","Request is not well-formed, syntactically incorrect, or violates schema.",{seed:e,details:t}),_=(e,t=[{issue:"INVALID_RESOURCE_ID",description:"Specified resource ID does not exist. Please check the resource ID and try again."}])=>v(404,"RESOURCE_NOT_FOUND","The specified resource does not exist.",{seed:e,details:t}),yt=(e,t=[{issue:"PERMISSION_DENIED",description:"You do not have permission to access or perform operations on this resource."}])=>v(403,"NOT_AUTHORIZED","Authorization failed due to insufficient permissions.",{seed:e,details:t}),k=e=>v(401,"AUTHENTICATION_FAILURE","Authentication failed due to invalid authentication credentials or a missing Authorization header.",{seed:e,links:[{href:"https://developer.paypal.com/docs/api/overview/#error",rel:"information_link",method:"GET"}]}),I=e=>v(405,"METHOD_NOT_ALLOWED","This PayPal twin is mounted read-only; writes are refused.",{seed:e}),S=(e,t)=>v(404,"RESOURCE_NOT_FOUND","The specified resource does not exist.",{seed:`${e} ${t}`,details:[{issue:"INVALID_RESOURCE_ID",description:`[twin gap] ${e} ${t.split("?")[0]} is not a modeled PayPal operation in this twin yet \u2014 see the paypal capability manifest for what is built.`}]}),D=(e,t,o)=>({status:e,body:{error:t,error_description:o}});var se=["SUCCESS","FAILED","PENDING","UNCLAIMED","RETURNED","ONHOLD","BLOCKED","REFUNDED","REVERSED"],we=["EMAIL","PHONE","PAYPAL_ID"],Re=["PAYPAL","VENMO"],Ne=["AWARDS","PRIZES","DONATIONS","GOODS","SERVICES","REBATES","CASHBACK","DISCOUNTS","NON_GOODS_OR_SERVICES"];var K=new Set(["SUCCESS","FAILED","BLOCKED","RETURNED","REFUNDED","REVERSED"]),Oe={SUCCESS:"PAYMENT.PAYOUTS-ITEM.SUCCEEDED",FAILED:"PAYMENT.PAYOUTS-ITEM.FAILED",BLOCKED:"PAYMENT.PAYOUTS-ITEM.BLOCKED",RETURNED:"PAYMENT.PAYOUTS-ITEM.RETURNED",REFUNDED:"PAYMENT.PAYOUTS-ITEM.REFUNDED",UNCLAIMED:"PAYMENT.PAYOUTS-ITEM.UNCLAIMED",ONHOLD:"PAYMENT.PAYOUTS-ITEM.HELD"},ke={PROCESSING:"PAYMENT.PAYOUTSBATCH.PROCESSING",SUCCESS:"PAYMENT.PAYOUTSBATCH.SUCCESS",DENIED:"PAYMENT.PAYOUTSBATCH.DENIED"},q="0.25",mt=["api.paypal.com","api-m.paypal.com","api.sandbox.paypal.com","api-m.sandbox.paypal.com"],co="https://api.sandbox.paypal.com";function De(e){let t=(e?.host??"").split(":")[0].toLowerCase();return mt.includes(t)?`https://${t}`:co}var uo=/^-?\d+(\.\d{1,2})?$/;function Ce(e){let t=[];if(e===null||typeof e!="object"||Array.isArray(e))return{issues:[{issue:"MALFORMED_REQUEST_JSON",location:"body",description:"The request JSON is not well formed."}]};let o=e,n=o.sender_batch_header;(n==null||typeof n!="object")&&t.push({field:"/sender_batch_header",location:"body",issue:"MISSING_REQUIRED_PARAMETER",description:"A required field / parameter is missing."});let r=o.items;return!Array.isArray(r)||r.length===0?t.push({field:"/items",location:"body",issue:"MISSING_REQUIRED_PARAMETER",description:"A required field / parameter is missing."}):r.forEach((i,a)=>{let s=i??{},c=s.amount;!c||typeof c!="object"||typeof c.value!="string"||typeof c.currency!="string"?t.push({field:`/items/${a}/amount`,location:"body",issue:"MISSING_REQUIRED_PARAMETER",description:"A required field / parameter is missing."}):(uo.test(c.value)?Number(c.value)<=0&&t.push({field:`/items/${a}/amount/value`,value:c.value,location:"body",issue:"INVALID_PARAMETER_VALUE",description:"The value of a field is invalid."}):t.push({field:`/items/${a}/amount/value`,value:c.value,location:"body",issue:"INVALID_PARAMETER_SYNTAX",description:"The value of a field does not conform to the expected format."}),/^[A-Z]{3}$/.test(c.currency)||t.push({field:`/items/${a}/amount/currency`,value:String(c.currency),location:"body",issue:"INVALID_PARAMETER_VALUE",description:"The value of a field is invalid."})),(typeof s.receiver!="string"||s.receiver.length===0)&&t.push({field:`/items/${a}/receiver`,location:"body",issue:"MISSING_REQUIRED_PARAMETER",description:"A required field / parameter is missing."});let p=s.recipient_type??n?.recipient_type??"EMAIL";we.includes(String(p))||t.push({field:`/items/${a}/recipient_type`,value:String(p),location:"body",issue:"INVALID_PARAMETER_VALUE",description:`The value of a field is invalid. Supported values are ${we.join(", ")}.`}),s.recipient_wallet!==void 0&&!Re.includes(String(s.recipient_wallet))&&t.push({field:`/items/${a}/recipient_wallet`,value:String(s.recipient_wallet),location:"body",issue:"INVALID_PARAMETER_VALUE",description:`The value of a field is invalid. Supported values are ${Re.join(", ")}.`}),s.purpose!==void 0&&!Ne.includes(String(s.purpose))&&t.push({field:`/items/${a}/purpose`,value:String(s.purpose),location:"body",issue:"INVALID_PARAMETER_VALUE",description:`The value of a field is invalid. Supported values are ${Ne.join(", ")}.`})}),t.length>0?{issues:t}:{issues:[],request:{sender_batch_header:n??{},items:r.map(i=>i)}}}function ht(e,t){let o={recipient_type:e.recipient_type??t.recipient_type??"EMAIL",amount:{currency:e.amount.currency,value:e.amount.value},receiver:e.receiver};return e.note!==void 0&&(o.note=e.note),e.sender_item_id!==void 0&&(o.sender_item_id=e.sender_item_id),e.recipient_wallet!==void 0&&(o.recipient_wallet=e.recipient_wallet),e.purpose!==void 0&&(o.purpose=e.purpose),e.notification_language!==void 0&&(o.notification_language=e.notification_language),o}function _t(e,t){return((Math.round(Number(e)*100)+Math.round(Number(t)*100))/100).toFixed(2)}function ce(e){return e.reduce((t,o)=>_t(t,o),"0.00")}function Et(e,t){return{batch_header:{payout_batch_id:e.id,batch_status:e.batchStatus,time_created:e.timeCreated,sender_batch_header:e.senderBatchHeader},links:[{href:`${t}/v1/payments/payouts/${e.id}`,rel:"self",method:"GET"}]}}function N(e,t,o,n={}){let r=n.pageSize&&n.pageSize>0?n.pageSize:1e3,i=n.page&&n.page>0?n.page:1,a=t.slice((i-1)*r,i*r),s={payout_batch_id:e.id,batch_status:e.batchStatus,time_created:e.timeCreated,sender_batch_header:e.senderBatchHeader,amount:e.amount};e.timeCompleted&&(s.time_completed=e.timeCompleted),e.timeClosed&&(s.time_closed=e.timeClosed),e.fundingSource&&(s.funding_source=e.fundingSource),e.fees&&(s.fees=e.fees);let c={batch_header:s,items:a.map(p=>C(p,o)),links:[{href:`${o}/v1/payments/payouts/${e.id}?page_size=${r}&page=${i}`,rel:"self",method:"GET"}]};return n.totalRequired&&(c.total_items=t.length,c.total_pages=Math.max(1,Math.ceil(t.length/r))),c}function C(e,t){let o={payout_item_id:e.id,transaction_status:e.transactionStatus,payout_item_fee:e.payoutItemFee,payout_batch_id:e.payoutBatchId,payout_item:e.payoutItem,links:[{href:`${t}/v1/payments/payouts-item/${e.id}`,rel:"self",method:"GET"},{href:`${t}/v1/payments/payouts/${e.payoutBatchId}`,rel:"batch",method:"GET"}]};return e.transactionId&&(o.transaction_id=e.transactionId),e.activityId&&(o.activity_id=e.activityId),e.senderBatchId!==void 0&&(o.sender_batch_id=e.senderBatchId),e.timeProcessed&&(o.time_processed=e.timeProcessed),e.errors&&(o.errors=e.errors),o}function $e(e,t){return e==="DENIED"||e==="CANCELED"||e==="PENDING"?e:t.length>0&&t.every(n=>K.has(n.transactionStatus))?"SUCCESS":"PROCESSING"}function Ue(e){return e==="PENDING"?"process":e==="PROCESSING"?"settle":null}function Le(e,t){return!se.includes(t)||t==="PENDING"?!1:!K.has(e)}var Me={FAILED:{name:"TRANSACTION_LIMIT_EXCEEDED",message:"Transaction limit exceeded."},BLOCKED:{name:"RECEIVER_UNREGISTERED",message:"Receiver is unregistered."},RETURNED:{name:"RECEIVER_UNCONFIRMED",message:"Receiver is unconfirmed."},REFUNDED:{name:"REFUNDED",message:"The recipient refunded the payout."}};import{applyTwinWrite as po,nodeBuiltin as lo,projectResources as fo}from"../../engine/v2/volter_world-core.mjs";function J(){return lo("node:crypto")}var At="paypal",gt="_keypair",St="paypal_webhook_signing_key",Be="SHA256withRSA",It="api.sandbox.paypal.com",Q="/v1/notifications/certs/";function yo(){let{generateKeyPairSync:e}=J(),{publicKey:t,privateKey:o}=e("rsa",{modulusLength:2048,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});return{publicKeyPem:t,privateKeyPem:o}}var mo={current:yo};function ho(e){if(e<128)return Buffer.from([e]);let t=[],o=e;for(;o>0;)t.unshift(o&255),o>>>=8;return Buffer.from([128|t.length,...t])}function w(e,t){return Buffer.concat([Buffer.from([e]),ho(t.length),t])}var Y=(...e)=>w(48,Buffer.concat(e)),_o=(...e)=>w(49,Buffer.concat(e)),Eo=e=>w(2,e[0]&128?Buffer.concat([Buffer.from([0]),e]):e),Pt=e=>w(6,Buffer.from(e)),Ao=()=>Buffer.from([5,0]),go=e=>w(19,Buffer.from(e,"ascii")),Tt=e=>w(23,Buffer.from(e,"ascii")),So=e=>w(3,Buffer.concat([Buffer.from([0]),e])),To=(e,t)=>w(160|e,t),bo=[42,134,72,134,247,13,1,1,11],vo=[85,4,3],bt=()=>Y(Pt(bo),Ao()),Io=e=>Y(_o(Y(Pt(vo),go(e))));function vt(e){let t=new Date(e),o=n=>String(n).padStart(2,"0");return`${o(t.getUTCFullYear()%100)}${o(t.getUTCMonth()+1)}${o(t.getUTCDate())}${o(t.getUTCHours())}${o(t.getUTCMinutes())}${o(t.getUTCSeconds())}Z`}function Po(e,t){let o=t.toString("base64").replace(/(.{64})/g,`$1
|
|
3
|
+
`).replace(/\n$/,"");return`-----BEGIN ${e}-----
|
|
4
|
+
${o}
|
|
5
|
+
-----END ${e}-----
|
|
6
|
+
`}function wt(e){let{createPublicKey:t,createSign:o}=J(),n=t(e.publicKeyPem).export({type:"spki",format:"der"}),r=Io("messageverificationcerts.paypal.com"),i=Y(To(0,w(2,Buffer.from([2]))),Eo(Buffer.from(e.serialHex,"hex")),bt(),r,Y(Tt(vt(e.notBefore)),Tt(vt(e.notAfter))),r,n),a=o("SHA256").update(new Uint8Array(i)).sign(e.privateKeyPem);return Po("CERTIFICATE",Y(i,bt(),So(a)))}function Rt(e){let{createHash:t,createPublicKey:o}=J(),n=o(e).export({type:"spki",format:"der"}),r=t("sha256").update(new Uint8Array(n)).digest("hex");return`CERT-${r.slice(0,8)}-${r.slice(8,16)}-${r.slice(16,24)}`}var xe=e=>`https://${It}${Q}${e}`;async function $(e={}){let t=fo(At,e.root).find(c=>c.type===gt&&c.id===St);if(t&&typeof t._privateKeyPem=="string"&&typeof t._certPem=="string")return{certId:String(t._certId),publicKeyPem:String(t._publicKeyPem),privateKeyPem:String(t._privateKeyPem),certPem:String(t._certPem)};if(e.mint===!1)return;let{publicKeyPem:o,privateKeyPem:n}=mo.current(),r=Rt(o),i=e.occurredAt??"1970-01-01T00:00:00.000Z",a=new Date(new Date(i).getTime()+10*365*24*36e5).toISOString(),s=wt({publicKeyPem:o,privateKeyPem:n,serialHex:r.replace(/^CERT-/,"").replace(/-/g,""),notBefore:i,notAfter:a});return await po(At,{operation:"_keypair.create",subjectType:gt,subjectId:St,fields:{_certId:r,_publicKeyPem:o,_privateKeyPem:n,_certPem:s},...e.occurredAt?{occurredAt:e.occurredAt}:{},actor:{kind:"system"}},e.root),{certId:r,publicKeyPem:o,privateKeyPem:n,certPem:s}}var ue;function wo(){if(!ue){ue=new Uint32Array(256);for(let e=0;e<256;e+=1){let t=e;for(let o=0;o<8;o+=1)t=t&1?3988292384^t>>>1:t>>>1;ue[e]=t>>>0}}return ue}function Nt(e){let t=typeof e=="string"?Buffer.from(e,"utf8"):e,o=wo(),n=4294967295;for(let r=0;r<t.length;r+=1)n=o[(n^t[r])&255]^n>>>8;return(n^4294967295)>>>0}function Ye(e){return`${e.transmissionId}|${e.transmissionTime}|${e.webhookId}|${Nt(e.rawBody)}`}function Fe(e){let{createSign:t}=J();return t("SHA256").update(Ye(e),"utf8").sign(e.privateKeyPem).toString("base64")}function He(e){let{createVerify:t}=J(),o;try{o=Buffer.from(e.signature,"base64")}catch{return!1}if(o.length===0)return!1;try{return t("SHA256").update(Ye(e),"utf8").verify(e.certPem,new Uint8Array(o))}catch{return!1}}function Ge(e,t){let o=`${e}:${t}`,n="";for(let i=0;n.length<32;i+=1){let a=2166136261,s=`${i}:${o}`;for(let c=0;c<s.length;c+=1)a^=s.charCodeAt(c),a=Math.imul(a,16777619)>>>0;n+=a.toString(16).padStart(8,"0")}let r=n.slice(0,32);return`${r.slice(0,8)}-${r.slice(8,12)}-${r.slice(12,16)}-${r.slice(16,20)}-${r.slice(20,32)}`}import{deliveryTraceHeaders as Ro}from"../../engine/v2/volter_world-core.mjs";import{appDestination as No,appFetch as Oo}from"../../engine/v2/volter_world-core_app-route.mjs";import{worldEgressRefusal as ko}from"../../engine/v2/volter_world-core_network-policy.mjs";var U=[{name:"PAYMENT.PAYOUTSBATCH.DENIED",description:"A batch payout payment is denied."},{name:"PAYMENT.PAYOUTSBATCH.PROCESSING",description:"The state of a batch payout payment changes to processing."},{name:"PAYMENT.PAYOUTSBATCH.SUCCESS",description:"A batch payout payment completes successfully."},{name:"PAYMENT.PAYOUTS-ITEM.BLOCKED",description:"A payouts item is blocked."},{name:"PAYMENT.PAYOUTS-ITEM.CANCELED",description:"A payouts item is canceled."},{name:"PAYMENT.PAYOUTS-ITEM.DENIED",description:"A payouts item is denied."},{name:"PAYMENT.PAYOUTS-ITEM.FAILED",description:"A payouts item fails."},{name:"PAYMENT.PAYOUTS-ITEM.HELD",description:"A payouts item is held."},{name:"PAYMENT.PAYOUTS-ITEM.REFUNDED",description:"A payouts item is refunded."},{name:"PAYMENT.PAYOUTS-ITEM.RETURNED",description:"A payouts item is returned."},{name:"PAYMENT.PAYOUTS-ITEM.SUCCEEDED",description:"A payouts item succeeds."},{name:"PAYMENT.PAYOUTS-ITEM.UNCLAIMED",description:"A payouts item is unclaimed."},{name:"IDENTITY.AUTHORIZATION-CONSENT.GRANTED",description:"A customer grants consent to share their account information."},{name:"IDENTITY.AUTHORIZATION-CONSENT.REVOKED",description:"A customer revokes consent to share their account information."}],X=new Set(U.map(e=>e.name));function kt(e){return e.startsWith("PAYMENT.PAYOUTS-ITEM.")?"payouts_item":e.startsWith("PAYMENT.PAYOUTSBATCH.")?"payouts":e.startsWith("IDENTITY.")?"authorization-consent":"unknown"}function Dt(e){return U.find(t=>t.name===e)?.description??e}function Ve(e,t){return e.includes("*")||e.includes(t)}function Z(e){let t=[{href:`${e.origin}/v1/notifications/webhooks-events/${e.id}`,rel:"self",method:"GET"},{href:`${e.origin}/v1/notifications/webhooks-events/${e.id}/resend`,rel:"resend",method:"POST"}];return{id:e.id,create_time:e.createTime,resource_type:kt(e.eventType),event_version:"1.0",event_type:e.eventType,summary:Dt(e.eventType),resource:e.resource,links:t}}var Ot=3,Do=async e=>{let t=No(e.url)?null:ko(e.url);if(t!==null){console.error(`[twin:paypal] webhook delivery DROPPED \u2014 ${e.eventId} -> ${e.url}: ${t}`);return}let o="";for(let n=1;n<=Ot;n+=1)try{let r=await Oo(e.url,{method:"POST",headers:{"content-type":"application/json",...e.headers,...Ro()},body:e.body});if(r.ok)return;o=`HTTP ${r.status}`}catch(r){o=r instanceof Error?r.message:String(r)}console.error(`[twin:paypal] webhook delivery DROPPED after ${Ot} attempts \u2014 ${e.eventId} -> ${e.url}: ${o}`)},Co={current:null};function pe(){return Co.current??Do}async function de(e){let t=await $({root:e.root,occurredAt:e.occurredAt});if(!t)throw new Error("paypal: no webhook signing keypair for this root \u2014 a delivery cannot be signed before the world has been written to");let{certId:o,privateKeyPem:n}=t,r=JSON.stringify(e.notification),i=Ge(e.notification.id,e.webhookId),a=e.occurredAt.replace(/\.\d+Z$/,"Z"),s=Fe({transmissionId:i,transmissionTime:a,webhookId:e.webhookId,rawBody:r,privateKeyPem:n});return{url:e.url,webhookId:e.webhookId,eventId:e.notification.id,headers:{"paypal-transmission-id":i,"paypal-transmission-time":a,"paypal-transmission-sig":s,"paypal-cert-url":xe(o),"paypal-auth-algo":Be,"correlation-id":i.slice(0,13)},body:r}}var le={openid:{label:"Sign you in with PayPal",detail:"Confirms who you are to the app without sharing your password."},profile:{label:"Full name, date of birth, gender, locale, time zone and language",detail:"Your basic profile information."},email:{label:"Email address",detail:"The email address on your PayPal account, and whether it is confirmed."},address:{label:"Street address",detail:"The address on your PayPal account."},phone:{label:"Phone number",detail:"The phone number on your PayPal account."},"https://uri.paypal.com/services/paypalattributes":{label:"Account type, account status, account creation date, payer ID, account verification status and age range",detail:"PayPal-specific attributes about your account."}};function ee(e){return e.split(/[\s+]+/).map(t=>t.trim()).filter(t=>t.length>0)}function fe(e){return e.join(" ")}function We(e){let t=Object.keys(le),o=[...new Set(e)],n=t.filter(i=>o.includes(i)).map(i=>({scope:i,...le[i],known:!0})),r=o.filter(i=>!(i in le)).sort().map(i=>({scope:i,label:i,detail:"This app asked for a permission PayPal does not recognise.",known:!1}));return[...n,...r]}var ye=["https://uri.paypal.com/payments/payouts","https://uri.paypal.com/services/payments/payouts-item/reverse","https://uri.paypal.com/services/payments/payout-applications/status","https://uri.paypal.com/services/payments/payout-applications/update-status","https://uri.paypal.com/services/applications/webhooks","openid"];function ze(e){let t=f(e.root,"auth_request",e.requestId);if(!t||t.settled===!0)return null;let o=f(e.root,"oauth_client",String(t.clientId));if(!o)return null;let n=String(t.accountId??""),r=n?f(e.root,"account",n):j(e.root);if(!r)return null;let i="";try{i=new URL(String(t.redirectUri)).host}catch{i=String(t.redirectUri??"")}return{requestId:e.requestId,origin:e.origin,app:{clientId:String(o.id),name:String(o.name??"")},account:$o(r),scopes:We(ee(String(t.scope??""))),redirectHost:i}}function $o(e){let t=String(e.givenName??""),o=String(e.familyName??"");return{id:String(e.id),email:String(e.email??""),emailVerified:e.emailVerified===!0,fullName:[t,o].filter(Boolean).join(" ")}}function E(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}var Uo=`
|
|
7
|
+
:root{--pp-blue:#003087;--pp-lightblue:#009cde;--pp-ink:#2c2e2f;--pp-grey:#687173;--pp-line:#cbd2d6}
|
|
8
|
+
*{box-sizing:border-box}
|
|
9
|
+
body{margin:0;background:#f7f9fa;color:var(--pp-ink);font:16px/1.5 -apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif}
|
|
10
|
+
.pp-shell{max-width:460px;margin:56px auto;background:#fff;border:1px solid var(--pp-line);border-radius:12px;padding:32px}
|
|
11
|
+
.pp-wordmark{font-weight:700;font-size:26px;letter-spacing:-.5px;margin-bottom:28px}
|
|
12
|
+
.pp-wordmark .pp-pay{color:var(--pp-blue)}
|
|
13
|
+
.pp-wordmark .pp-pal{color:var(--pp-lightblue)}
|
|
14
|
+
.pp-title{font-size:20px;font-weight:600;margin:0 0 8px}
|
|
15
|
+
.pp-sub{color:var(--pp-grey);margin:0 0 24px;font-size:14px}
|
|
16
|
+
.pp-account{display:flex;flex-direction:column;gap:2px;border:1px solid var(--pp-line);border-radius:8px;padding:12px 14px;margin-bottom:20px}
|
|
17
|
+
.pp-account-name{font-weight:600}
|
|
18
|
+
.pp-account-email{color:var(--pp-grey);font-size:14px}
|
|
19
|
+
.pp-account-unverified{color:#b35309;font-size:13px}
|
|
20
|
+
.pp-scopes{list-style:none;margin:0 0 24px;padding:0;border-top:1px solid var(--pp-line)}
|
|
21
|
+
.pp-scope{border-bottom:1px solid var(--pp-line);padding:12px 0}
|
|
22
|
+
.pp-scope-label{font-weight:600;font-size:15px}
|
|
23
|
+
.pp-scope-detail{color:var(--pp-grey);font-size:13px}
|
|
24
|
+
.pp-scope-unknown .pp-scope-label{color:#b35309}
|
|
25
|
+
.pp-actions{display:flex;flex-direction:column;gap:10px}
|
|
26
|
+
.pp-button{display:block;width:100%;padding:12px 16px;border-radius:999px;border:1px solid var(--pp-blue);font-size:16px;font-weight:600;cursor:pointer}
|
|
27
|
+
.pp-agree{background:var(--pp-blue);color:#fff}
|
|
28
|
+
.pp-cancel{background:#fff;color:var(--pp-blue)}
|
|
29
|
+
.pp-footer{color:var(--pp-grey);font-size:12px;margin-top:20px;text-align:center}
|
|
30
|
+
.pp-error-code{color:#b35309;font-weight:600}
|
|
31
|
+
`;function Ct(e,t){return`<!doctype html>
|
|
32
|
+
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
|
33
|
+
<title>${E(e)}</title><style>${Uo}</style></head>
|
|
34
|
+
<body><div id="root">${t}</div></body></html>`}var $t='<div class="pp-wordmark"><span class="pp-pay">Pay</span><span class="pp-pal">Pal</span></div>';function je(e){let t=e.scopes.map(r=>`<li class="pp-scope${r.known?"":" pp-scope-unknown"}"><div class="pp-scope-label">${E(r.label)}</div><div class="pp-scope-detail">${E(r.detail)}</div></li>`).join(""),o=e.account.emailVerified?"":'<div class="pp-account-unverified">Email address not confirmed</div>',n=`<div class="pp-shell">
|
|
35
|
+
${$t}
|
|
36
|
+
<h1 class="pp-title">${E(e.app.name)} wants to access your PayPal account</h1>
|
|
37
|
+
<p class="pp-sub">You are giving ${E(e.app.name)} permission to see the information below. You can remove access at any time in your PayPal settings.</p>
|
|
38
|
+
<div class="pp-account"><div class="pp-account-name">${E(e.account.fullName)}</div><div class="pp-account-email">${E(e.account.email)}</div>${o}</div>
|
|
39
|
+
<ul class="pp-scopes">${t}</ul>
|
|
40
|
+
<div class="pp-actions">
|
|
41
|
+
<form method="post" action="${E(e.origin)}/_twin/consent"><input type="hidden" name="request_id" value="${E(e.requestId)}"><input type="hidden" name="decision" value="allow"><button class="pp-button pp-agree" type="submit">Agree and Continue</button></form>
|
|
42
|
+
<form method="post" action="${E(e.origin)}/_twin/consent"><input type="hidden" name="request_id" value="${E(e.requestId)}"><input type="hidden" name="decision" value="deny"><button class="pp-button pp-cancel" type="submit">Cancel</button></form>
|
|
43
|
+
</div>
|
|
44
|
+
<p class="pp-footer">You will return to ${E(e.redirectHost)}</p>
|
|
45
|
+
</div>`;return Ct(`Log in with PayPal \u2014 ${e.app.name}`,n)}function L(e){let t=`<div class="pp-shell">
|
|
46
|
+
${$t}
|
|
47
|
+
<h1 class="pp-title">Something went wrong</h1>
|
|
48
|
+
<p class="pp-sub">${E(e.detail)}</p>
|
|
49
|
+
<p class="pp-error-code">Error ${e.status}: ${E(e.code)}</p>
|
|
50
|
+
${e.requestOrigin?`<p class="pp-footer">Request from ${E(e.requestOrigin)}</p>`:""}
|
|
51
|
+
</div>`;return Ct(`Error ${e.status}: ${e.code} \u2014 PayPal`,t)}var Ke=31668,te=28800,Mt=300,Mo={"content-type":"application/json"},Bo={"content-type":"text/html; charset=utf-8"};function B(e){if(e===void 0||e.trim()==="")return{ok:!0,value:void 0};try{return{ok:!0,value:JSON.parse(e)}}catch{return{ok:!1}}}function Bt(e){let t={};if(!e)return t;let o=e.trim();if(o.startsWith("{"))try{let n=JSON.parse(o);for(let[r,i]of Object.entries(n))t[r]=String(i);return t}catch{return t}for(let[n,r]of new URLSearchParams(o))t[n]=r;return t}function xo(e){let t=new URL(e,"http://twin.invalid");return{pathname:t.pathname.replace(/\/+$/,"")||"/",query:t.searchParams}}var m=(e,t)=>({status:e,body:t,headers:Mo}),F=(e,t)=>({status:e,body:t,headers:Bo}),oe=e=>({status:302,body:"",headers:{location:e}});function Ut(e){let t=e?.authorization??e?.Authorization;if(typeof t!="string")return;let o=/^Bearer\s+(.+)$/i.exec(t.trim());return o?o[1].trim():void 0}function Yo(e){let t=e?.authorization??e?.Authorization;if(typeof t!="string")return;let o=/^Basic\s+(.+)$/i.exec(t.trim());if(!o)return;let n;try{n=Buffer.from(o[1].trim(),"base64").toString("utf8")}catch{return}let r=n.indexOf(":");if(r!==-1)return{clientId:n.slice(0,r),secret:n.slice(r+1)}}function xt(e,t,o){if(!t)return;let n=f(e,"access_token",t);if(!n||n.revoked===!0)return;let r=typeof n.expiresAt=="string"?Date.parse(n.expiresAt):Number.NaN;if(!(Number.isFinite(r)&&Date.parse(o)>=r))return n}async function qe(e){let t=e.occurredAt??Lo(),o=e.root,n=e.readOnly===!0,r=e.origin??"http://twin.invalid",{pathname:i,query:a}=xo(e.path),s=e.method.toUpperCase(),c=De(e.headers);if(n||(await ft({root:o,occurredAt:t,origin:e.callbackOrigin??r}),await $({root:o,occurredAt:t})),i==="/v1/oauth2/token"||i==="/v1/identity/openidconnect/tokenservice")return s!=="POST"?S(s,i):n?I(i):Fo(e,{root:o,at:t,origin:r});if(i==="/connect"){if(s!=="GET")return S(s,i);let y=e.path.includes("?")?e.path.slice(e.path.indexOf("?")):"";return oe(`${r}/signin/authorize${y}`)}if(i==="/signin/authorize")return s!=="GET"?S(s,i):n?I(i):Go(a,{root:o,at:t,origin:r});if(i==="/_twin/consent")return s!=="POST"?S(s,i):n?I(i):Vo(Bt(e.body),{root:o,at:t,origin:r});if(i==="/v1/identity/openidconnect/userinfo")return s!=="GET"?S(s,i):Wo(a,Ut(e.headers),{root:o,at:t});if(i.startsWith(Q)){if(s!=="GET")return S(s,i);let y=i.slice(Q.length),T=await $({root:o,occurredAt:t,mint:!n});return T?y!==T.certId?_(i):{status:200,body:T.certPem,headers:{"content-type":"application/pkix-cert"}}:I(i)}if(i.startsWith("/_twin/"))return n?I(i):rn(s,i,e,{root:o,at:t,origin:r,apiOrigin:c});let p=xt(o,Ut(e.headers),t);if(i==="/v1/payments/payouts"&&s==="POST")return n?I(i):p?zo(e,{root:o,at:t,apiOrigin:c}):k(i);let u=/^\/v1\/payments\/payouts\/([^/]+)$/.exec(i);if(u&&s==="GET")return p?jo(decodeURIComponent(u[1]),a,{root:o,apiOrigin:c}):k(i);let d=/^\/v1\/payments\/payouts-item\/([^/]+)$/.exec(i);if(d&&s==="GET")return p?Ko(decodeURIComponent(d[1]),{root:o,apiOrigin:c}):k(i);let l=/^\/v1\/payments\/payouts-item\/([^/]+)\/cancel$/.exec(i);return l&&s==="POST"?n?I(i):p?qo(decodeURIComponent(l[1]),{root:o,at:t,apiOrigin:c,origin:r}):k(i):i.startsWith("/v1/notifications/")?p?Qo(s,i,a,e,{root:o,at:t,apiOrigin:c,origin:r,readOnly:n}):k(i):S(s,i)}async function Fo(e,t){let o=Bt(e.body),n=Yo(e.headers);if(!n)return D(401,"invalid_client","Client Authentication failed");let r=f(t.root,"oauth_client",n.clientId);if(!r||String(r.secret??"")!==n.secret)return D(401,"invalid_client","Client Authentication failed");let i=o.grant_type??"";if(i==="client_credentials"){let a=x(t.root,"access_token",t.at,n.clientId),s=new Date(Date.parse(t.at)+Ke*1e3).toISOString();return await b("access_token",a,"oauth2.token.client_credentials",{clientId:n.clientId,grantType:"client_credentials",scope:fe(ye),expiresAt:s,rev:1},{root:t.root,occurredAt:t.at}),m(200,{scope:fe(ye),access_token:a,token_type:"Bearer",app_id:String(r.appId??z),expires_in:Ke,nonce:`${t.at.replace(/\.\d+Z$/,"Z")}${a.slice(-45)}`})}if(i==="authorization_code"){let a=o.code??"",s=a?f(t.root,"authorization_code",a):void 0;if(!s||s.consumed===!0||String(s.clientId)!==n.clientId)return D(400,"invalid_grant","the provided authorization grant code, refresh token, resource owner credentials, or the extension parameters are not valid");let c=typeof s.expiresAt=="string"?Date.parse(s.expiresAt):Number.NaN;return Number.isFinite(c)&&Date.parse(t.at)>=c?D(400,"invalid_grant","the provided authorization grant code, refresh token, resource owner credentials, or the extension parameters are not valid"):(await g("authorization_code",a,"oauth2.code.consume",()=>({consumed:!0}),{root:t.root,occurredAt:t.at}),m(200,await Ho({clientId:n.clientId,accountId:String(s.accountId),scope:String(s.scope??""),ctx:t,subject:a})))}if(i==="refresh_token"){let a=o.refresh_token??"",s=a?f(t.root,"refresh_token",a):void 0;if(!s||s.revoked===!0||String(s.clientId)!==n.clientId)return D(400,"invalid_grant","the provided authorization grant code, refresh token, resource owner credentials, or the extension parameters are not valid");let c=x(t.root,"access_token",t.at,a),p=new Date(Date.parse(t.at)+te*1e3).toISOString();return await b("access_token",c,"oauth2.token.refresh",{clientId:n.clientId,accountId:s.accountId,grantType:"refresh_token",scope:String(s.scope??""),expiresAt:p,rev:1},{root:t.root,occurredAt:t.at}),m(200,{scope:String(s.scope??""),access_token:c,token_type:"Bearer",expires_in:te,nonce:`${t.at.replace(/\.\d+Z$/,"Z")}${c.slice(-45)}`})}return D(400,"unsupported_grant_type","the authorization grant type is not supported by the authorization server")}async function Ho(e){let{ctx:t}=e,o=x(t.root,"access_token",t.at,e.subject),n=x(t.root,"refresh_token",t.at,e.subject),r=new Date(Date.parse(t.at)+te*1e3).toISOString();return await b("access_token",o,"oauth2.token.authorization_code",{clientId:e.clientId,accountId:e.accountId,grantType:"authorization_code",scope:e.scope,expiresAt:r,rev:1},{root:t.root,occurredAt:t.at}),await b("refresh_token",n,"oauth2.refresh_token.create",{clientId:e.clientId,accountId:e.accountId,scope:e.scope,rev:1},{root:t.root,occurredAt:t.at}),{token_type:"Bearer",expires_in:te,refresh_token:n,access_token:o,scope:e.scope,nonce:`${t.at.replace(/\.\d+Z$/,"Z")}${o.slice(-45)}`}}async function Go(e,t){let o=e.get("client_id")??"",n=e.get("redirect_uri")??"",r=e.get("response_type")??"",i=e.get("scope")??"",a=e.get("state")??"",s=o?f(t.root,"oauth_client",o):void 0;if(!s)return F(400,L({status:400,code:"invalid_client_id",detail:"The app you are trying to sign in to could not be found. Its client ID is not recognised."}));if(!n||!Ie(s,n))return F(400,L({status:400,code:"redirect_uri_mismatch",detail:"The return URL this app sent is not one of the return URLs configured for it.",requestOrigin:String(s.name??"")}));if(r!=="code")return oe(`${n}${n.includes("?")?"&":"?"}error=unsupported_response_type&error_description=${encodeURIComponent("response_type must be code")}${a?`&state=${encodeURIComponent(a)}`:""}`);if(i.trim()==="")return oe(`${n}${n.includes("?")?"&":"?"}error=invalid_scope&error_description=${encodeURIComponent("scope is required")}${a?`&state=${encodeURIComponent(a)}`:""}`);let c=j(t.root);if(!c)return F(400,L({status:400,code:"no_session",detail:"No PayPal account is signed in on this browser. Sign in first."}));let p={clientId:o,redirectUri:n,scope:i,state:a,accountId:String(c.id),flowEntry:e.get("flowEntry")??"",settled:!1,rev:1},u=pt(t.root,t.at,p);f(t.root,"auth_request",u)||await b("auth_request",u,"authorize.request",p,{root:t.root,occurredAt:t.at});let d=ze({root:t.root,requestId:u,origin:t.origin});return d?F(200,je(d)):F(400,L({status:400,code:"invalid_request",detail:"This authorization request can no longer be shown."}))}async function Vo(e,t){let o=e.request_id??"",n=o?f(t.root,"auth_request",o):void 0;if(!n||n.settled===!0)return F(400,L({status:400,code:"invalid_request",detail:"This authorization request is unknown or has already been answered."}));let r=String(n.redirectUri),i=String(n.state??""),a=r.includes("?")?"&":"?";if((e.decision??"")!=="allow")return await g("auth_request",o,"authorize.deny",()=>({settled:!0,decision:"deny"}),{root:t.root,occurredAt:t.at}),oe(`${r}${a}error=access_denied${i?`&state=${encodeURIComponent(i)}`:""}`);let s=x(t.root,"authorization_code",t.at,o);return await b("authorization_code",s,"authorize.grant",{clientId:String(n.clientId),accountId:String(n.accountId),scope:String(n.scope??""),redirectUri:r,consumed:!1,expiresAt:new Date(Date.parse(t.at)+Mt*1e3).toISOString(),rev:1},{root:t.root,occurredAt:t.at}),await g("auth_request",o,"authorize.allow",()=>({settled:!0,decision:"allow",code:s}),{root:t.root,occurredAt:t.at}),oe(`${r}${a}code=${encodeURIComponent(s)}${i?`&state=${encodeURIComponent(i)}`:""}`)}function Wo(e,t,o){let n=xt(o.root,t,o.at);if(!n)return k("/v1/identity/openidconnect/userinfo");let r=typeof n.accountId=="string"?n.accountId:"";if(!r)return yt("/v1/identity/openidconnect/userinfo",[{issue:"PERMISSION_DENIED",description:"This access token does not represent a PayPal account holder. Use a token obtained through the Log in with PayPal authorization-code flow."}]);let i=e.get("schema");if(i!=="openid")return h("/v1/identity/openidconnect/userinfo",[{field:"schema",location:"query",value:i??"",issue:"MISSING_REQUIRED_PARAMETER",description:"The schema query parameter is required and must be openid."}]);let a=f(o.root,"account",r);if(!a)return _("/v1/identity/openidconnect/userinfo");let s=new Set(ee(String(n.scope??""))),c={},p=ae(String(a.id)),u=`https://www.paypal.com/webapps/auth/identity/user/${p}`;c.user_id=u,c.sub=u;let d=(l,y)=>{s.has(l)&&y()};return d("profile",()=>{let l=String(a.givenName??""),y=String(a.familyName??"");c.name=[l,y].filter(Boolean).join(" "),c.given_name=l,c.family_name=y,c.locale=String(a.locale??"en_US"),c.zoneinfo=String(a.zoneinfo??"America/Los_Angeles")}),d("email",()=>{c.email=String(a.email??""),c.email_verified=a.emailVerified===!0}),d("address",()=>{c.address=a.address??{}}),d("phone",()=>{typeof a.phoneNumber=="string"&&(c.phone_number=a.phoneNumber)}),d("https://uri.paypal.com/services/paypalattributes",()=>{c.payer_id=p,c.verified_account=a.verifiedAccount===!0,c.account_type=String(a.accountType??"PERSONAL")}),m(200,c)}function O(e){return{id:String(e.id),batchStatus:String(e.batchStatus),senderBatchHeader:e.senderBatchHeader??{},timeCreated:String(e.timeCreated),...e.timeCompleted?{timeCompleted:String(e.timeCompleted)}:{},...e.timeClosed?{timeClosed:String(e.timeClosed)}:{},amount:e.amount,...e.fees?{fees:e.fees}:{},...e.fundingSource?{fundingSource:String(e.fundingSource)}:{}}}function H(e){return{id:String(e.id),payoutBatchId:String(e.payoutBatchId),ordinal:typeof e.ordinal=="number"?e.ordinal:0,...e.senderBatchId!==void 0&&e.senderBatchId!==null?{senderBatchId:String(e.senderBatchId)}:{},transactionStatus:String(e.transactionStatus),payoutItem:e.payoutItem??{},payoutItemFee:e.payoutItemFee,...e.transactionId?{transactionId:String(e.transactionId)}:{},...e.activityId?{activityId:String(e.activityId)}:{},...e.timeProcessed?{timeProcessed:String(e.timeProcessed)}:{},...e.errors?{errors:e.errors}:{}}}function P(e,t){return A(e,"payout_item").filter(o=>String(o.payoutBatchId)===t).map(H).sort((o,n)=>o.ordinal-n.ordinal||o.id.localeCompare(n.id))}async function zo(e,t){let o=B(e.body);if(!o.ok)return h("/v1/payments/payouts",[{location:"body",issue:"MALFORMED_REQUEST_JSON",description:"The request JSON is not well formed."}]);let{issues:n,request:r}=Ce(o.value);if(!r)return h("/v1/payments/payouts",n);let i=r.sender_batch_header.sender_batch_id;if(typeof i=="string"&&i.length>0){let l=A(t.root,"payout_batch").find(y=>String(y.senderBatchHeader?.sender_batch_id??"")===i);if(l)return v(400,"INVALID_REQUEST","Request is not well-formed, syntactically incorrect, or violates schema.",{seed:`/v1/payments/payouts:${i}`,details:[{field:"sender_batch_id",value:i,location:"body",issue:"DUPLICATE_SENDER_BATCH_ID",description:`A payout with sender_batch_id ${i} was already submitted. PayPal does not process duplicate payouts.`}],links:[{href:`${t.apiOrigin}/v1/payments/payouts/${String(l.id)}`,rel:"self",method:"GET"}]})}let a=at(t.root,t.at,i??"batch"),s=r.items[0].amount.currency,c=ce(r.items.map(l=>l.amount.value)),p=W(t.root),u=r.items.map((l,y)=>({type:"payout_item",id:st([...p,...Array.from({length:y},(ge,Zt)=>({type:"payout_item",id:`pending-${Zt}`,updatedAt:t.at}))],t.at,`${a}:${y}`),fields:{payoutBatchId:a,ordinal:y,...i!==void 0?{senderBatchId:i}:{},transactionStatus:"PENDING",payoutItem:ht(l,r.sender_batch_header),payoutItemFee:{currency:s,value:"0.00"},rev:1}}));await rt({type:"payout_batch",id:a,fields:{batchStatus:"PENDING",senderBatchHeader:r.sender_batch_header,timeCreated:t.at,amount:{currency:s,value:c},fundingSource:"BALANCE",rev:1}},u,"payouts.create",{root:t.root,occurredAt:t.at});let d=f(t.root,"payout_batch",a);return m(201,Et(O(d),t.apiOrigin))}function jo(e,t,o){let n=f(o.root,"payout_batch",e);if(!n)return _(`/v1/payments/payouts/${e}`);let r=Number(t.get("page")??""),i=Number(t.get("page_size")??"");return m(200,N(O(n),P(o.root,e),o.apiOrigin,{...Number.isFinite(r)&&r>0?{page:r}:{},...Number.isFinite(i)&&i>0?{pageSize:i}:{},totalRequired:t.get("total_required")==="true"}))}function Ko(e,t){let o=f(t.root,"payout_item",e);return o?m(200,C(H(o),t.apiOrigin)):_(`/v1/payments/payouts-item/${e}`)}async function qo(e,t){let o=f(t.root,"payout_item",e);if(!o)return _(`/v1/payments/payouts-item/${e}/cancel`);let n=String(o.transactionStatus);if(n!=="UNCLAIMED")return h(`/v1/payments/payouts-item/${e}/cancel`,[{field:"transaction_status",value:n,issue:"PAYOUT_ITEM_NOT_CANCELLABLE",description:"Only an UNCLAIMED payout item can be cancelled."}]);await Je(e,"RETURNED",{root:t.root,at:t.at,apiOrigin:t.apiOrigin,origin:t.origin},{errors:null});let r=f(t.root,"payout_item",e);return m(200,C(H(r),t.apiOrigin))}async function Je(e,t,o,n={}){let r=f(o.root,"payout_item",e),i=n.errors===void 0?Me[t]:n.errors,a=i?{...i,debug_id:Pe(`item:${e}:${i.name}`)}:void 0;await g("payout_item",e,`payouts.item.${t.toLowerCase()}`,()=>({transactionStatus:t,timeProcessed:o.at,transactionId:ve(e,"txn"),activityId:ve(e,"activity"),payoutItemFee:{currency:String(r.payoutItemFee?.currency??"USD"),value:q},...a?{errors:a}:{errors:null}}),{root:o.root,occurredAt:o.at});let s=Oe[t];if(s){let c=f(o.root,"payout_item",e);await ne(s,C(H(c),o.apiOrigin),o)}await Yt(String(r.payoutBatchId),o)}async function Yt(e,t){let o=f(t.root,"payout_batch",e);if(!o)return;let n=String(o.batchStatus),r=$e(n,P(t.root,e));if(r===n)return;await g("payout_batch",e,`payouts.batch.${r.toLowerCase()}`,()=>({batchStatus:r,...r==="SUCCESS"?{timeCompleted:t.at,timeClosed:t.at}:{}}),{root:t.root,occurredAt:t.at});let i=ke[r];if(i){let a=f(t.root,"payout_batch",e);await ne(i,N(O(a),P(t.root,e),t.apiOrigin),t)}}async function Jo(e,t){let o=f(t.root,"payout_batch",e);if(!o)return _(`/_twin/payouts/${e}/advance`);let n=String(o.batchStatus),r=Ue(n);if(!r)return h(`/_twin/payouts/${e}/advance`,[{field:"batch_status",value:n,issue:"BATCH_ALREADY_SETTLED",description:`A batch in ${n} has no further transition.`}]);if(r==="process"){let a=P(t.root,e),s=a[0]?.payoutItemFee.currency??String(o.amount?.currency??"USD");await g("payout_batch",e,"payouts.batch.processing",()=>({batchStatus:"PROCESSING",fees:{currency:s,value:ce(a.map(()=>q))}}),{root:t.root,occurredAt:t.at});for(let p of a)await g("payout_item",p.id,"payouts.item.fee_estimated",()=>({payoutItemFee:{currency:p.payoutItemFee.currency,value:q}}),{root:t.root,occurredAt:t.at});let c=f(t.root,"payout_batch",e);await ne("PAYMENT.PAYOUTSBATCH.PROCESSING",N(O(c),P(t.root,e),t.apiOrigin),t)}else{for(let a of P(t.root,e))K.has(a.transactionStatus)||await Je(a.id,"SUCCESS",t);await Yt(e,t)}let i=f(t.root,"payout_batch",e);return m(200,N(O(i),P(t.root,e),t.apiOrigin))}async function ne(e,t,o){let n=A(o.root,"webhook").filter(c=>c.deleted!==!0&&Ve(M(c.eventTypes),e));if(n.length===0)return;let r=pe(),i=ut(W(o.root),o.at,e),a=Z({id:i,createTime:o.at,eventType:e,resource:t,origin:o.apiOrigin}),s=[];for(let c of n)s.push(await de({notification:a,webhookId:String(c.id),url:String(c.url),root:o.root,occurredAt:o.at}));await b("webhook_event",i,"notifications.event.raise",{eventType:e,createTime:o.at,resourceType:a.resource_type,summary:a.summary,resource:t,webhookIds:n.map(c=>String(c.id)),transmissions:s.map(c=>({webhookId:c.webhookId,transmissionId:c.headers["paypal-transmission-id"]})),rawBody:a&&s[0]?s[0].body:JSON.stringify(a),rev:1},{root:o.root,occurredAt:o.at});for(let c of s)try{await r(c)}catch(p){console.error(`[twin:paypal] webhook delivery threw for ${i} -> ${c.url}: ${p instanceof Error?p.message:String(p)}`)}}function M(e){return Array.isArray(e)?e.map(t=>String(t)):[]}function me(e,t){return{id:String(e.id),url:String(e.url),event_types:M(e.eventTypes).map(o=>({name:o,description:U.find(n=>n.name===o)?.description??"A webhook event.",status:"ENABLED"})),links:[{href:`${t}/v1/notifications/webhooks/${String(e.id)}`,rel:"self",method:"GET"},{href:`${t}/v1/notifications/webhooks/${String(e.id)}`,rel:"update",method:"PATCH"},{href:`${t}/v1/notifications/webhooks/${String(e.id)}`,rel:"delete",method:"DELETE"}]}}function he(e,t){return Z({id:String(e.id),createTime:String(e.createTime),eventType:String(e.eventType),resource:e.resource??{},origin:t})}async function Qo(e,t,o,n,r){let i=()=>r.readOnly?I(t):void 0;if(t==="/v1/notifications/webhooks"){if(e==="GET")return m(200,{webhooks:A(r.root,"webhook").filter(u=>u.deleted!==!0).map(u=>me(u,r.apiOrigin))});if(e==="POST"){let u=i();return u||Xo(n,r)}return S(e,t)}if(t==="/v1/notifications/webhooks-event-types"&&e==="GET")return m(200,{event_types:U.map(u=>({name:u.name,description:u.description,status:"ENABLED"}))});if(t==="/v1/notifications/verify-webhook-signature"&&e==="POST")return en(n,r);if(t==="/v1/notifications/simulate-event"&&e==="POST"){let u=i();return u||tn(n,r)}if(t==="/v1/notifications/webhooks-events"&&e==="GET"){let u=o.get("event_type"),d=Number(o.get("page_size")??"10"),y=A(r.root,"webhook_event").filter(T=>u?String(T.eventType)===u:!0).sort((T,ge)=>String(T.createTime).localeCompare(String(ge.createTime))||String(T.id).localeCompare(String(ge.id))).slice(0,Number.isFinite(d)&&d>0?d:10);return m(200,{events:y.map(T=>he(T,r.apiOrigin)),count:y.length,links:[{href:`${r.apiOrigin}/v1/notifications/webhooks-events?page_size=${Number.isFinite(d)&&d>0?d:10}`,rel:"self",method:"GET"}]})}let a=/^\/v1\/notifications\/webhooks-events\/([^/]+)$/.exec(t);if(a&&e==="GET"){let u=f(r.root,"webhook_event",decodeURIComponent(a[1]));return u?m(200,he(u,r.apiOrigin)):_(t)}let s=/^\/v1\/notifications\/webhooks-events\/([^/]+)\/resend$/.exec(t);if(s&&e==="POST"){let u=i();return u||nn(decodeURIComponent(s[1]),n,r)}let c=/^\/v1\/notifications\/webhooks\/([^/]+)\/event-types$/.exec(t);if(c&&e==="GET"){let u=A(r.root,"webhook").find(d=>d.deleted!==!0&&String(d.id)===decodeURIComponent(c[1]));return u?m(200,{event_types:M(u.eventTypes).map(d=>({name:d,description:U.find(l=>l.name===d)?.description??"A webhook event.",status:"ENABLED"}))}):_(t)}let p=/^\/v1\/notifications\/webhooks\/([^/]+)$/.exec(t);if(p){let u=decodeURIComponent(p[1]),d=f(r.root,"webhook",u),l=d&&d.deleted!==!0?d:void 0;if(e==="GET")return l?m(200,me(l,r.apiOrigin)):_(t);if(e==="PATCH"){let y=i();return y||(l?Zo(l,n,r):_(t))}if(e==="DELETE"){let y=i();return y||(l?(await g("webhook",u,"notifications.webhook.delete",()=>({deleted:!0,url:null,eventTypes:[]}),{root:r.root,occurredAt:r.at}),{status:204,body:""}):_(t))}return S(e,t)}return S(e,t)}async function Xo(e,t){let o=B(e.body);if(!o.ok||o.value===void 0||typeof o.value!="object"||o.value===null)return h("/v1/notifications/webhooks",[{location:"body",issue:"MALFORMED_REQUEST_JSON",description:"The request JSON is not well formed."}]);let n=o.value,r=[],i=typeof n.url=="string"?n.url:"";i?/^https?:\/\//.test(i)||r.push({field:"/url",value:i,location:"body",issue:"INVALID_PARAMETER_SYNTAX",description:"The value of a field does not conform to the expected format."}):r.push({field:"/url",location:"body",issue:"MISSING_REQUIRED_PARAMETER",description:"A required field / parameter is missing."});let a=Array.isArray(n.event_types)?n.event_types.map(c=>String(c?.name??"")):[];a.length===0&&r.push({field:"/event_types",location:"body",issue:"MISSING_REQUIRED_PARAMETER",description:"A required field / parameter is missing."});for(let c of a)c!=="*"&&!X.has(c)&&r.push({field:"/event_types/name",value:c,location:"body",issue:"INVALID_PARAMETER_VALUE",description:"The value of a field is invalid. It is not a webhook event name this twin models."});if(r.length===0&&A(t.root,"webhook").some(c=>c.deleted!==!0&&String(c.url)===i))return v(400,"WEBHOOK_URL_ALREADY_EXISTS","The webhook URL is already subscribed.",{seed:`/v1/notifications/webhooks:${i}`,details:[{field:"/url",value:i,location:"body",issue:"WEBHOOK_URL_ALREADY_EXISTS",description:"A webhook with this URL already exists for this app."}]});if(r.length>0)return h("/v1/notifications/webhooks",r);let s=ct(t.root,t.at,i);return await b("webhook",s,"notifications.webhook.create",{url:i,eventTypes:a,deleted:!1,rev:1},{root:t.root,occurredAt:t.at}),m(201,me(f(t.root,"webhook",s),t.apiOrigin))}async function Zo(e,t,o){let n=B(t.body);if(!n.ok||!Array.isArray(n.value))return h(`/v1/notifications/webhooks/${String(e.id)}`,[{location:"body",issue:"MALFORMED_REQUEST_JSON",description:"The request body must be a JSON Patch array."}]);let r=n.value,i={};for(let a of r){let s=String(a.op??""),c=String(a.path??"");if(s!=="replace")return h(`/v1/notifications/webhooks/${String(e.id)}`,[{field:"op",value:s,location:"body",issue:"INVALID_PARAMETER_VALUE",description:"Only the replace operation is modeled by this twin for webhook patches."}]);if(c==="/url"){if(typeof a.value!="string"||!/^https?:\/\//.test(a.value))return h(`/v1/notifications/webhooks/${String(e.id)}`,[{field:"/url",location:"body",issue:"INVALID_PARAMETER_SYNTAX",description:"The value of a field does not conform to the expected format."}]);i.url=a.value}else if(c==="/event_types"){let p=Array.isArray(a.value)?a.value.map(u=>String(u?.name??"")):[];for(let u of p)if(u!=="*"&&!X.has(u))return h(`/v1/notifications/webhooks/${String(e.id)}`,[{field:"/event_types/name",value:u,location:"body",issue:"INVALID_PARAMETER_VALUE",description:"The value of a field is invalid."}]);i.eventTypes=p}else return h(`/v1/notifications/webhooks/${String(e.id)}`,[{field:"path",value:c,location:"body",issue:"INVALID_PARAMETER_VALUE",description:"Only /url and /event_types are patchable in this twin."}])}return await g("webhook",String(e.id),"notifications.webhook.update",()=>i,{root:o.root,occurredAt:o.at}),m(200,me(f(o.root,"webhook",String(e.id)),o.apiOrigin))}async function en(e,t){let o=B(e.body);if(!o.ok||o.value===null||typeof o.value!="object")return h("/v1/notifications/verify-webhook-signature",[{location:"body",issue:"MALFORMED_REQUEST_JSON",description:"The request JSON is not well formed."}]);let n=o.value,i=["auth_algo","cert_url","transmission_id","transmission_sig","transmission_time","webhook_id","webhook_event"].filter(d=>n[d]===void 0||n[d]===null||n[d]==="");if(i.length>0)return h("/v1/notifications/verify-webhook-signature",i.map(d=>({field:`/${d}`,location:"body",issue:"MISSING_REQUIRED_PARAMETER",description:"A required field / parameter is missing."})));let a=await $({root:t.root,occurredAt:t.at,mint:!t.readOnly});if(!a)return I("/v1/notifications/verify-webhook-signature");let s=n.webhook_event,c=typeof s.id=="string"?f(t.root,"webhook_event",s.id):void 0,p=typeof c?.rawBody=="string"?c.rawBody:JSON.stringify(s),u=He({transmissionId:String(n.transmission_id),transmissionTime:String(n.transmission_time),webhookId:String(n.webhook_id),rawBody:p,signature:String(n.transmission_sig),certPem:a.certPem});return m(200,{verification_status:u?"SUCCESS":"FAILURE"})}async function tn(e,t){let o=B(e.body);if(!o.ok||o.value===null||typeof o.value!="object")return h("/v1/notifications/simulate-event",[{location:"body",issue:"MALFORMED_REQUEST_JSON",description:"The request JSON is not well formed."}]);let n=o.value,r=typeof n.event_type=="string"?n.event_type:"";if(!r)return h("/v1/notifications/simulate-event",[{field:"/event_type",location:"body",issue:"MISSING_REQUIRED_PARAMETER",description:"A required field / parameter is missing."}]);if(!X.has(r))return h("/v1/notifications/simulate-event",[{field:"/event_type",value:r,location:"body",issue:"INVALID_PARAMETER_VALUE",description:"The value of a field is invalid. It is not a webhook event name this twin models."}]);let i=typeof n.webhook_id=="string"?n.webhook_id:"",a=typeof n.url=="string"?n.url:"";if(!i&&!a)return h("/v1/notifications/simulate-event",[{field:"/webhook_id",location:"body",issue:"MISSING_REQUIRED_PARAMETER",description:"Either webhook_id or url is required."}]);if(!A(t.root,"webhook").find(l=>l.deleted!==!0&&(i?String(l.id)===i:String(l.url)===a)))return _("/v1/notifications/simulate-event");let c=on(r,t),p={root:t.root,at:t.at,apiOrigin:t.apiOrigin,origin:t.origin},u=new Set(A(t.root,"webhook_event").map(l=>String(l.id)));await ne(r,c,p);let d=A(t.root,"webhook_event").find(l=>!u.has(String(l.id)));return d?m(202,he(d,t.apiOrigin)):_("/v1/notifications/simulate-event")}function Lt(e){return[...e].sort((t,o)=>String(t.updatedAt??"").localeCompare(String(o.updatedAt??""))||String(t.id).localeCompare(String(o.id))).at(-1)}function on(e,t){if(e.startsWith("PAYMENT.PAYOUTS-ITEM.")){let o=Lt(A(t.root,"payout_item"));if(o)return C(H(o),t.apiOrigin)}if(e.startsWith("PAYMENT.PAYOUTSBATCH.")){let o=Lt(A(t.root,"payout_batch"));if(o)return N(O(o),P(t.root,String(o.id)),t.apiOrigin)}return{simulated:!0,event_type:e,note:"This twin holds no subject of the kind this event describes, so the simulated notification carries a marker rather than a fabricated PayPal resource."}}async function nn(e,t,o){let n=f(o.root,"webhook_event",e);if(!n)return _(`/v1/notifications/webhooks-events/${e}/resend`);let r=B(t.body),i=r.ok&&r.value!==null&&typeof r.value=="object"?M(r.value.webhook_ids):[],a=(i.length>0?i:M(n.webhookIds)).map(p=>f(o.root,"webhook",p)).filter(p=>p!==void 0&&p.deleted!==!0);if(a.length===0)return _(`/v1/notifications/webhooks-events/${e}/resend`);let s=pe(),c=Z({id:e,createTime:String(n.createTime),eventType:String(n.eventType),resource:n.resource??{},origin:o.apiOrigin});for(let p of a){let u=await de({notification:c,webhookId:String(p.id),url:String(p.url),root:o.root,occurredAt:o.at});try{await s(u)}catch(d){console.error(`[twin:paypal] resend threw for ${e}: ${d instanceof Error?d.message:String(d)}`)}}return m(202,he(n,o.apiOrigin))}async function rn(e,t,o,n){let r={root:n.root,at:n.at,apiOrigin:n.apiOrigin,origin:n.origin},i=B(o.body),a=i.ok&&i.value!==null&&typeof i.value=="object"?i.value:{};if(t==="/_twin/clients"&&e==="POST"){let u=String(a.client_id??"");return u?(await b("oauth_client",u,"twin.client.register",{name:String(a.name??"Twin App"),secret:String(a.client_secret??""),appId:String(a.app_id??z),redirectUris:M(a.redirect_uris),rev:1},{root:n.root,occurredAt:n.at}),m(201,{client_id:u,name:String(a.name??"Twin App"),redirect_uris:M(a.redirect_uris)})):h(t,[{field:"client_id",issue:"MISSING_REQUIRED_PARAMETER"}])}if(t==="/_twin/accounts"&&e==="POST"){let u=String(a.id??"");return u?(await b("account",u,"twin.account.register",{email:String(a.email??""),emailVerified:a.email_verified===!0,givenName:String(a.given_name??""),familyName:String(a.family_name??""),accountType:String(a.account_type??"PERSONAL"),verifiedAccount:a.verified_account===!0,locale:String(a.locale??"en_US"),zoneinfo:String(a.zoneinfo??"America/Los_Angeles"),address:a.address??{},rev:1},{root:n.root,occurredAt:n.at}),m(201,{id:u,email:String(a.email??""),payer_id:ae(u)})):h(t,[{field:"id",issue:"MISSING_REQUIRED_PARAMETER"}])}if(t==="/_twin/session"&&e==="POST"){let u=String(a.account_id??"");return f(n.root,"account",u)?(await g("session","current","twin.session.switch",()=>({accountId:u}),{root:n.root,occurredAt:n.at}),m(200,{account_id:u})):_(t)}let s=/^\/_twin\/payouts\/([^/]+)\/advance$/.exec(t);if(s&&e==="POST")return Jo(decodeURIComponent(s[1]),r);let c=/^\/_twin\/payouts\/([^/]+)\/deny$/.exec(t);if(c&&e==="POST"){let u=decodeURIComponent(c[1]),d=f(n.root,"payout_batch",u);if(!d)return _(t);if(String(d.batchStatus)!=="PENDING")return h(t,[{field:"batch_status",value:String(d.batchStatus),issue:"BATCH_ALREADY_SETTLED",description:"Only a PENDING batch can be denied."}]);await g("payout_batch",u,"payouts.batch.denied",()=>({batchStatus:"DENIED",timeCompleted:n.at}),{root:n.root,occurredAt:n.at});let l=f(n.root,"payout_batch",u);return await ne("PAYMENT.PAYOUTSBATCH.DENIED",N(O(l),P(n.root,u),n.apiOrigin),r),m(200,N(O(l),P(n.root,u),n.apiOrigin))}let p=/^\/_twin\/payouts-item\/([^/]+)\/transition$/.exec(t);if(p&&e==="POST"){let u=decodeURIComponent(p[1]),d=f(n.root,"payout_item",u);if(!d)return _(t);let l=String(a.transaction_status??""),y=String(d.transactionStatus);return!se.includes(l)||!Le(y,l)?h(t,[{field:"transaction_status",value:l,issue:"INVALID_PARAMETER_VALUE",description:`An item in ${y} cannot move to ${l||"(missing)"}.`}]):(await Je(u,l,r),m(200,C(H(f(n.root,"payout_item",u)),n.apiOrigin)))}return S(e,t)}import{isReadOnlyRequest as an,serveHttp as qn,statefulTwinManifest as sn,twinPublicBase as cn,withRequestScopes as un,worldNow as pn}from"../../engine/v2/volter_world-core.mjs";function Ft(e={}){return un(async function(o){let n=(e.readOnly??!1)||an(o),r=new URL(o.url);if(o.method==="GET"&&(r.pathname.replace(/\/+$/,"")||"/")==="/twin")return Response.json(sn({vendor:"paypal",twinOf:"the PayPal REST API \u2014 batch payouts, webhooks and Log in with PayPal",stores:"REST apps, PayPal account personas, the Log-in-with-PayPal round trip, batch payouts and their items, webhook subscriptions and the notifications delivered for them"}));let i=o.method==="GET"||o.method==="HEAD"?"":await o.text(),a={};o.headers.forEach((p,u)=>{a[u.toLowerCase()]=p});let s;try{s=await qe({method:o.method,path:r.pathname+(r.search||""),body:i,headers:a,readOnly:n,occurredAt:pn(),origin:cn(o),callbackOrigin:r.origin,...e.root!==void 0?{root:e.root}:{}})}catch(p){let u=p instanceof Error?p.message:String(p);return Response.json({name:"INTERNAL_SERVER_ERROR",message:"An internal server error has occurred.",debug_id:"twin-handler-threw",details:[{issue:"INTERNAL_SERVER_ERROR",description:u}]},{status:500,headers:{"content-type":"application/json"}})}let c={...s.headers??{}};return s.status===204||s.status===205||s.status===304?new Response(null,{status:s.status,headers:c}):typeof s.body=="string"?(!c["content-type"]&&s.body&&(c["content-type"]="text/html; charset=utf-8"),new Response(s.body,{status:s.status,headers:c})):(c["content-type"]=c["content-type"]??"application/json",new Response(JSON.stringify(s.body),{status:s.status,headers:c}))},{refuse:t=>{let o=v(405,"METHOD_NOT_ALLOWED","This request is read-only; writes are refused.",{seed:new URL(t.url).pathname});return Response.json(o.body,{status:o.status})}})}import{assertBudgetGuardIntact as ar,deployableEntries as sr,observeResources as hn,projectResources as _n}from"../../engine/v2/volter_world-core.mjs";import{declareRateBudget as dn,rateBudgetPath as er,rateBudgetWeight as tr,RateBudget as or}from"../../engine/v2/volter_world-core.mjs";import{RateBudgetError as Wt}from"../../engine/v2/volter_world-core.mjs";var ln="paypal",Ht=6e4,Gt=60,Vt=300,G={createPayout:12,cancelItem:6,webhookWrite:4,token:3,other:2},_e={windowMs:Ht,ceiling:Gt,defaultWeight:G.other,maxRetryAfterSeconds:Vt,rules:[{match:"^POST /v1/payments/payouts$",weight:G.createPayout},{match:"^POST /v1/payments/payouts-item/[^/]+/cancel$",weight:G.cancelItem},{match:"^(POST|PATCH|DELETE) /v1/notifications/webhooks",weight:G.webhookWrite},{match:"^POST /v1/oauth2/token$",weight:G.token}],reason:`PayPal publishes NO scalar rate limit. Its own rate-limiting page (https://developer.paypal.com/api/rest/reference/rate-limiting/, fetched 2026-09-13) says "While we do not publish a rate limiting policy, we might temporarily rate limit if we identify traffic that appears to be abusive", documents HTTP 429 with RATE_LIMIT_REACHED as the throttled answer, and documents no requests-per-second figure, no daily quota, and no Retry-After or X-RateLimit-* header. So this declaration stays AT the kernel fallback (60s window, ceiling 60, default weight 2 = 30 calls a minute) and only redistributes weight within it \u2014 the figma/openai/sentry shape for a vendor that publishes nothing. The weights encode BLAST RADIUS, which is a fact about the operation rather than about the limit: POST /v1/payments/payouts moves real money to real recipients and costs 12 (a fifth of the window), a payout-item cancel costs 6, a webhook-registry write costs 4, and the token endpoint costs 3 because PayPal's own page advises caching the token rather than minting one per transaction \u2014 pricing it above a read makes a per-call minter visible before the vendor notices it. Nothing here is more permissive than the fallback, so no VENDOR_BURST_ANCHOR entry is required.`};dn(ln,_e);var Qe="paypal";function zt(e){return{type:"webhook",id:String(e.id??""),fields:{...typeof e.url=="string"?{url:e.url}:{},...Array.isArray(e.event_types)?{eventTypes:e.event_types.map(t=>String(t?.name??""))}:{},deleted:!1,pulled:!0}}}function jt(e){return{type:"webhook_event",id:String(e.id??""),fields:{...typeof e.event_type=="string"?{eventType:e.event_type}:{},...typeof e.create_time=="string"?{createTime:e.create_time}:{},...typeof e.resource_type=="string"?{resourceType:e.resource_type}:{},...typeof e.summary=="string"?{summary:e.summary}:{},...e.resource&&typeof e.resource=="object"?{resource:e.resource}:{},pulled:!0}}}function Kt(e){let t=e.batch_header??{};return{type:"payout_batch",id:String(t.payout_batch_id??""),fields:{...typeof t.batch_status=="string"?{batchStatus:t.batch_status}:{},...t.sender_batch_header&&typeof t.sender_batch_header=="object"?{senderBatchHeader:t.sender_batch_header}:{},...typeof t.time_created=="string"?{timeCreated:t.time_created}:{},...typeof t.time_completed=="string"?{timeCompleted:t.time_completed}:{},...typeof t.time_closed=="string"?{timeClosed:t.time_closed}:{},...t.amount&&typeof t.amount=="object"?{amount:t.amount}:{},...t.fees&&typeof t.fees=="object"?{fees:t.fees}:{},...typeof t.funding_source=="string"?{fundingSource:t.funding_source}:{},pulled:!0}}}function qt(e){return{type:"payout_item",id:String(e.payout_item_id??""),fields:{...typeof e.payout_batch_id=="string"?{payoutBatchId:e.payout_batch_id}:{},...typeof e.sender_batch_id=="string"?{senderBatchId:e.sender_batch_id}:{},...typeof e.transaction_status=="string"?{transactionStatus:e.transaction_status}:{},...e.payout_item&&typeof e.payout_item=="object"?{payoutItem:e.payout_item}:{},...e.payout_item_fee&&typeof e.payout_item_fee=="object"?{payoutItemFee:e.payout_item_fee}:{},...typeof e.transaction_id=="string"?{transactionId:e.transaction_id}:{},...typeof e.activity_id=="string"?{activityId:e.activity_id}:{},...typeof e.time_processed=="string"?{timeProcessed:e.time_processed}:{},...e.errors&&typeof e.errors=="object"?{errors:e.errors}:{},pulled:!0}}}var Ee=0;function En(){let e=Date.now();return Ee=e>Ee?e:Ee+1,new Date(Ee).toISOString()}function An(e,t){let o=_n(Qe,t);for(let n of e){let r=o.find(i=>i.type===n.type&&i.id===n.id);if(r&&r.pulled!==!0)throw new Error(`paypal pull: refusing to fold vendor ${n.type} "${n.id}" over a LOCALLY created subject of the same id \u2014 two distinct subjects would merge and one would be lost. Resolve it deliberately rather than letting a sync decide.`)}}async function gn(e,t){let o=[],n=await e("GET","/v1/notifications/webhooks");if(!n||typeof n!="object"||!Array.isArray(n.webhooks))throw new Error(`paypal pull refused or malformed at GET /v1/notifications/webhooks: ${JSON.stringify(n).slice(0,200)}`);for(let i of n.webhooks)typeof i?.id=="string"&&i.id.length>0&&o.push(zt(i));let r=await e("GET","/v1/notifications/webhooks-events?page_size=20");if(!r||typeof r!="object"||!Array.isArray(r.events))throw new Error(`paypal pull refused or malformed at GET /v1/notifications/webhooks-events: ${JSON.stringify(r).slice(0,200)}`);for(let i of r.events)typeof i?.id=="string"&&i.id.length>0&&o.push(jt(i));for(let i of t.payoutBatchIds??[]){let a=await e("GET",`/v1/payments/payouts/${encodeURIComponent(i)}`),s=a?.batch_header??{};if(typeof s.payout_batch_id!="string"||s.payout_batch_id.length===0)throw new Error(`paypal pull refused or malformed at GET /v1/payments/payouts/${i}: ${JSON.stringify(a).slice(0,200)}`);o.push(Kt(a));for(let c of Array.isArray(a.items)?a.items:[])typeof c?.payout_item_id=="string"&&c.payout_item_id.length>0&&o.push(qt(c))}return o}async function Jt(e,t={}){let o=t.occurredAt??En(),n=await gn(e,t);An(n,t.root);let r=hn(Qe,n,{...t.root!==void 0?{root:t.root}:{},at:o,batch:`obs:${Qe}:${o}`});return{observed:n.length,deltasAppended:r.appended}}var Xe=class extends Error{status;constructor(t,o,n,r){super(`paypal refresh: the remote answered ${n} at ${t} ${o} \u2014 no usable credential (${r.slice(0,160)})`),this.name="PaypalUnauthenticatedRefresh",this.status=n}};function Qt(e){return async(t,o,n)=>{let r=await e({method:t,path:o,headers:{accept:"application/json",...n?.headers??{}},...n?.body===void 0?{}:{body:n.body}}),i=r.body||"";if(r.status===401||r.status===403)throw new Xe(t,o,r.status,i);if(r.status>=400)throw new Error(`paypal refused ${t} ${o}: HTTP ${r.status} ${i.slice(0,300)}`);try{return JSON.parse(i||"{}")}catch{throw new Error(`paypal returned non-JSON for ${t} ${o}: HTTP ${r.status}`)}}}async function Ze(e,t={}){return Jt(Qt(e),{...t.root!==void 0?{root:t.root}:{},...t.payoutBatchIds!==void 0?{payoutBatchIds:t.payoutBatchIds}:{},occurredAt:t.occurredAt??new Date().toISOString()})}async function et(e,t,o){let n=t.operation??`${t.subject.type}.update`,r=t.subject.type==="payout_batch"||t.subject.type==="payout_item"?`${n} would create or alter a REAL PayPal payout - money leaving a real account for real recipients. This twin never performs that implicitly; do it deliberately with the vendor's own client.`:`${n} has no safe upstream home: a world's webhook URL is a loopback address PayPal could never deliver to, and a REST app's identity lives in the developer dashboard, which publishes no API.`;throw new Error(`paypal perform refused: ${r}`)}import{registerPack as Sn}from"../../engine/v2/volter_world-core.mjs";var Ae="^/v1/(?:oauth2/token/?$|identity/openidconnect/|payments/payouts(?:-item)?(?:/|$)|notifications/)|^/_twin/",Xt="^/signin/authorize/?$|^/connect/?$|^/webapps/auth/protocol/openidconnect/|^/_twin/",Tn={refreshRefusal:{refusal:"no usable credential",reason:"every PayPal read needs an OAuth access token the parity gate never mints"},protocol:"2",refresh:{every:"30m",webhook:!0,onDemand:{atMost:"60s"}},stateSystem:{perform:et,refresh:Ze},roundTrip:{method:"POST",path:"/_twin/clients",body:{client_id:"AeRoundTripApp000000000000000000000000",client_secret:"ERoundTripSecret00000000000000000000",name:"Round Trip",redirect_uris:["https://round.trip.test/api/paypal/callback"]}},parityOrigin:"http://twin",vendor:"paypal",rateBudget:_e,transport:"rest",archetype:"crud",bin:"world-paypal",resources:["oauth_client","account","session","auth_request","authorization_code","access_token","refresh_token","payout_batch","payout_item","webhook","webhook_event"],specSource:`PayPal's first-party OpenAPI documents (github.com/paypal/paypal-rest-api-specifications, openapi/payments_payouts_batch_v1.json "Payouts" 1.9 and openapi/notifications_webhooks_v1.json "Webhooks Management" 1.11, both OpenAPI 3.0.3, fetched 2026-09-13 \u2014 20 operations between them) for the payouts and webhooks halves; developer.paypal.com for the halves PayPal publishes no spec for \u2014 the OAuth 2.0 token endpoint (api/rest/authentication/), the Identity userinfo read (docs/api/identity/v1/), Log in with PayPal (docs/log-in-with-paypal/integrate/), the webhook signature scheme and event catalogue (api/rest/webhooks/rest/, api/rest/webhooks/event-names/) and the rate-limiting page \u2014 cross-checked against a real consumer: dub's apps/web/lib/paypal/* and apps/web/app/(ee)/api/paypal/* call sites.`,description:"PayPal REST twin \u2014 batch payouts with a deterministic offline PENDING/PROCESSING/SUCCESS lifecycle and per-item transaction statuses, REALLY SIGNED webhook notifications (X.509 cert + SHA256withRSA over PayPal\u2019s own transmission message) with both the offline and the verify-webhook-signature checks, the OAuth 2.0 token endpoint, the Identity userinfo read, and the Log in with PayPal consent screen served as HTML at www.paypal.com\u2019s own path. No real money moves and no live call happens outside the guarded connector.",adoption:{sdks:["paypal-rest-sdk"],pypi:["paypalrestsdk"],envStems:["PAYPAL"]},hosts:[{host:"api.paypal.com",pathPattern:Ae},{host:"api-m.paypal.com",pathPattern:Ae},{host:"api.sandbox.paypal.com",pathPattern:Ae},{host:"api-m.sandbox.paypal.com",pathPattern:Ae},{host:"www.paypal.com",pathPattern:Xt},{host:"www.sandbox.paypal.com",pathPattern:Xt}],endpointEnvNone:"no PayPal client reads a base-URL env var \u2014 paypal-rest-sdk takes mode: sandbox|live, the current @paypal server SDK takes an Environment enum, and the motivating app computes its host from NODE_ENV \u2014 so interception is the host entries above.",browserRouting:{apiPathPrefix:"/signin/",loaderHost:"https://www.paypal.com"}};Sn(Tn);export{Ft as createTwinFetch};
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
@agenttwin/twin-pinecone
|
|
2
|
+
|
|
3
|
+
Contains @volter/twin-pinecone 0.1.37 by Volter (https://github.com/volter-ai),
|
|
4
|
+
licensed under the Apache License, Version 2.0 (see LICENSE).
|
|
5
|
+
|
|
6
|
+
Modified by AgentTwin: bundled and minified into one file; only code reachable from the pack's
|
|
7
|
+
fetch factory is included; shared modules are imported from the AgentTwin twin engine.
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{createRequire as __atReq}from'node:module';const require=__atReq(import.meta.url);
|
|
2
|
+
import{createHash as ue}from"node:crypto";import{applyTwinWrite as le,projectResources as q,worldNow as Pe}from"../../engine/v2/volter_world-core.mjs";var ie=new Set(["$eq","$ne","$gt","$gte","$lt","$lte","$in","$nin"]);function se(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function P(e,t){return Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((n,i)=>P(n,t[i])):e===t}function ce(e,t,n){switch(e){case"$eq":return P(t,n);case"$ne":return!P(t,n);case"$in":return Array.isArray(n)&&n.some(i=>P(t,i));case"$nin":return Array.isArray(n)&&!n.some(i=>P(t,i));case"$gt":case"$gte":case"$lt":case"$lte":return typeof t!="number"||typeof n!="number"?!1:e==="$gt"?t>n:e==="$gte"?t>=n:e==="$lt"?t<n:t<=n;default:return!1}}function ae(e,t){if(se(t)){let n=Object.keys(t);if(n.length>0&&n.every(i=>ie.has(i)))return n.every(i=>ce(i,e,t[i]))}return P(e,t)}function _(e,t){if(!t||Object.keys(t).length===0)return!0;let n=e??{};for(let[i,c]of Object.entries(t)){if(i==="$and"){if(!Array.isArray(c)||!c.every(l=>_(n,l)))return!1;continue}if(i==="$or"){if(!Array.isArray(c)||c.length===0||!c.some(l=>_(n,l)))return!1;continue}if(!ae(n[i],c))return!1}return!0}function G(e,t){let n=Math.min(e.length,t.length),i=0;for(let c=0;c<n;c++)i+=e[c]*t[c];return i}function X(e){let t=0;for(let n of e)t+=n*n;return Math.sqrt(t)}function J(e,t){let n=X(e),i=X(t);return n===0||i===0?0:G(e,t)/(n*i)}function Q(e,t){let n=Math.max(e.length,t.length),i=0;for(let c=0;c<n;c++){let l=(e[c]??0)-(t[c]??0);i+=l*l}return i}function U(e,t,n){return e==="cosine"?J(t,n):e==="dotproduct"?G(t,n):Q(t,n)}function de(e){return e!=="euclidean"}function F(e,t){let n=!de(e);return[...t].sort((i,c)=>n?i.score-c.score:c.score-i.score)}var j="pinecone",A="";var M=".svc.twin.pinecone.io";function W(e){let t=ue("sha256").update(`pinecone-twin-host:${e}`).digest("hex").slice(0,8);return`${e}-${t}${M}`}function V(e){if(!e)return;let t=e.replace(/^https?:\/\//,"").split(":")[0];if(!t.endsWith(M))return;let i=t.slice(0,-M.length).match(/^(.*)-([0-9a-f]{8})$/);return i?i[1]:void 0}function ee(e){let t=e.host,n=e.path.split("?")[0]??"/";return t==="api.pinecone.io"||t!==void 0&&t.startsWith("api.pinecone.io:")?"control":t!==void 0&&V(t)?"data":n.startsWith("/indexes")||n.startsWith("/collections")||n==="/"?"control":"data"}function N(e,t,n){return{status:e,body:{code:t,message:n,details:[]}}}function h(e,t,n){return{status:e,body:{error:{code:t,message:n},status:e}}}function v(){return{status:405,body:{message:"twin is read-only; omit readOnly to accept writes"}}}function fe(e){if(!e)return{};try{let t=JSON.parse(e);return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}catch{return{}}}function g(e){return`index:${e}`}function S(e){return`collection:${e}`}function w(e,t,n){return`vector:${e}::${t}::${n}`}function Z(e){let t=e.split("::");if(t.length===3)return{index:t[0],namespace:t[1],id:t[2]}}function C(e,t){let n=`${e}:`;return q(j,t).filter(i=>i.type===e&&i.id.startsWith(n)&&i._deleted!==!0)}function y(e,t,n){return q(j,n).find(i=>i.type===e&&i.id===t&&i._deleted!==!0)}async function x(e,t,n,i,c){let{resource:l}=await le(j,{operation:i,subjectType:e,subjectId:t,fields:n,...c.occurredAt?{occurredAt:c.occurredAt}:{},actor:{kind:"agent"}},c.root);return l}function D(e){return{name:e.name,dimension:e.dimension??null,metric:e.metric,host:e.host,spec:e.spec,status:{ready:e.ready??!0,state:e.state??"Ready"},deletion_protection:e.deletionProtection??"disabled",tags:e.tags??{},vector_type:e.vectorType??"dense"}}function L(e){return{name:e.name,size:e.size??0,status:e.status??"Ready",dimension:e.dimension??null,vector_count:e.vectorCount??0,environment:e.environment??"twin-local"}}function pe(e,t,n,i){return{id:n,values:i.values??[],metadata:i.metadata??{}}}async function k(e){let t=e.method.toUpperCase(),[n,i]=e.path.split("?"),c=(n??"/").replace(/\/+$/,"")||"/",l=new URLSearchParams(i??""),r=fe(e.body),d=c.replace(/^\/+/,"").split("/").filter(Boolean),f=o=>decodeURIComponent(d[o]??""),R=ee({host:e.host,path:c});if(c==="/"||d.length===0)return{status:200,body:{service:"pinecone",object:"twin"}};if(R==="control"){if(d[0]==="indexes"){if(d.length===1&&t==="POST"){if(e.readOnly)return v();let o=typeof r.name=="string"?r.name:void 0,s=typeof r.dimension=="number"?r.dimension:void 0;if(!o||!s)return h(400,"INVALID_ARGUMENT","name and dimension are required to create an index");if(y("index",g(o),e.root))return h(409,"ALREADY_EXISTS",`Resource ${o} already exists`);let a=typeof r.metric=="string"?r.metric:"cosine",u=typeof r.vector_type=="string"?r.vector_type:"dense",E=r.spec??{serverless:{cloud:"aws",region:"us-east-1"}},O=typeof r.deletion_protection=="string"?r.deletion_protection:"disabled",$=r.tags??{},B=W(o);await x("index",g(o),{name:o,dimension:s,metric:a,vectorType:u,spec:E,deletionProtection:O,tags:$,host:B,ready:!0,state:"Ready"},"index.create",e);let z=y("index",g(o),e.root);return{status:201,body:D(z)}}if(d.length===1&&t==="GET")return{status:200,body:{indexes:C("index",e.root).map(D)}};if(d.length===2&&t==="GET"){let o=y("index",g(f(1)),e.root);return o?{status:200,body:D(o)}:h(404,"NOT_FOUND",`Index ${f(1)} not found`)}if(d.length===2&&t==="PATCH"){if(e.readOnly)return v();let o=y("index",g(f(1)),e.root);if(!o)return h(404,"NOT_FOUND",`Index ${f(1)} not found`);if(typeof r.dimension=="number"&&r.dimension!==o.dimension)return h(400,"INVALID_ARGUMENT","dimension cannot be changed after index creation");let s={};r.deletion_protection!==void 0&&(s.deletionProtection=r.deletion_protection),r.tags!==void 0&&(s.tags={...o.tags??{},...r.tags}),r.spec!==void 0&&(s.spec={...o.spec??{},...r.spec}),await x("index",g(f(1)),s,"index.configure",e);let a=y("index",g(f(1)),e.root);return{status:200,body:D(a)}}if(d.length===2&&t==="DELETE")return e.readOnly?v():y("index",g(f(1)),e.root)?(await x("index",g(f(1)),{_deleted:!0},"index.delete",e),{status:202,body:null}):h(404,"NOT_FOUND",`Index ${f(1)} not found`)}if(d[0]==="collections"){if(d.length===1&&t==="POST"){if(e.readOnly)return v();let o=typeof r.name=="string"?r.name:void 0,s=typeof r.source=="string"?r.source:void 0;if(!o||!s)return h(400,"INVALID_ARGUMENT","name and source (an existing index name) are required to create a collection");let a=y("index",g(s),e.root);if(!a)return h(404,"NOT_FOUND",`Index ${s} not found`);if(y("collection",S(o),e.root))return h(409,"ALREADY_EXISTS",`Resource ${o} already exists`);await x("collection",S(o),{name:o,dimension:a.dimension,vectorCount:0,size:0,status:"Ready",environment:"twin-local"},"collection.create",e);let u=y("collection",S(o),e.root);return{status:201,body:L(u)}}if(d.length===1&&t==="GET")return{status:200,body:{collections:C("collection",e.root).map(L)}};if(d.length===2&&t==="GET"){let o=y("collection",S(f(1)),e.root);return o?{status:200,body:L(o)}:h(404,"NOT_FOUND",`Collection ${f(1)} not found`)}if(d.length===2&&t==="DELETE")return e.readOnly?v():y("collection",S(f(1)),e.root)?(await x("collection",S(f(1)),{_deleted:!0},"collection.delete",e),{status:202,body:null}):h(404,"NOT_FOUND",`Collection ${f(1)} not found`)}return h(404,"NOT_FOUND",`Unrecognized control-plane route: ${t} ${c}`)}let p=e.index??V(e.host);if(!p)return N(404,5,"Could not resolve an index for this request host");let T=y("index",g(p),e.root);if(!T)return N(404,5,`Index ${p} not found`);let b=typeof T.dimension=="number"?T.dimension:void 0,Y=T.metric??"cosine";function I(o){let s=`vector:${p}::${o}::`;return C("vector",e.root).filter(a=>a.id.startsWith(s)).map(a=>({id:Z(a.id.slice(7)).id,values:a.values??[],metadata:a.metadata??{}}))}if(d[0]==="vectors"&&d[1]==="upsert"&&d.length===2&&t==="POST"){if(e.readOnly)return v();let o=Array.isArray(r.vectors)?r.vectors:[],s=typeof r.namespace=="string"?r.namespace:A;for(let a of o){let u=Array.isArray(a.values)?a.values:[];if(b!==void 0&&u.length!==b)return N(400,3,`Vector dimension ${u.length} does not match the dimension of the index ${b}`)}for(let a of o){let u=String(a.id??"");u&&await x("vector",w(p,s,u),{values:a.values??[],metadata:a.metadata??{}},"vector.upsert",e)}return{status:200,body:{upsertedCount:o.length}}}if(d[0]==="vectors"&&d[1]==="fetch"&&d.length===2&&t==="GET"){let o=(l.get("ids")??"").split(",").map(u=>u.trim()).filter(Boolean),s=l.get("namespace")??A,a={};for(let u of o){let E=y("vector",w(p,s,u),e.root);E&&(a[u]=pe(p,s,u,E))}return{status:200,body:{vectors:a,namespace:s}}}if(d[0]==="vectors"&&d[1]==="update"&&d.length===2&&t==="POST"){if(e.readOnly)return v();let o=String(r.id??""),s=typeof r.namespace=="string"?r.namespace:A;if(!o)return N(400,3,"id is required");let a=y("vector",w(p,s,o),e.root);if(a){let u={};r.values!==void 0&&(u.values=r.values),r.setMetadata!==void 0&&(u.metadata={...a.metadata??{},...r.setMetadata}),await x("vector",w(p,s,o),u,"vector.update",e)}return{status:200,body:{}}}if(d[0]==="vectors"&&d[1]==="delete"&&d.length===2&&t==="POST"){if(e.readOnly)return v();let o=typeof r.namespace=="string"?r.namespace:A;if(r.deleteAll===!0)for(let s of I(o))await x("vector",w(p,o,s.id),{_deleted:!0},"vector.delete",e);else if(Array.isArray(r.ids))for(let s of r.ids)await x("vector",w(p,o,s),{_deleted:!0},"vector.delete",e);else if(r.filter!==void 0)for(let s of I(o))_(s.metadata,r.filter)&&await x("vector",w(p,o,s.id),{_deleted:!0},"vector.delete",e);return{status:200,body:{}}}if(d[0]==="vectors"&&d[1]==="list"&&d.length===2&&t==="GET"){let o=l.get("namespace")??A,s=l.get("prefix")??"",a=Number(l.get("limit")??"100")||100;return{status:200,body:{vectors:I(o).filter(E=>E.id.startsWith(s)).slice(0,a).map(E=>({id:E.id})),namespace:o,pagination:{next:null}}}}if(c==="/query"&&t==="POST"){let o=typeof r.namespace=="string"?r.namespace:A,s=typeof r.topK=="number"?r.topK:10,a=r.includeValues===!0,u=r.includeMetadata===!0,E=r.filter,O,$;if(Array.isArray(r.vector))O=r.vector;else if(typeof r.id=="string"){$=r.id;let m=y("vector",w(p,o,r.id),e.root);O=m?m.values??[]:void 0}if(!O)return{status:200,body:{matches:[],namespace:o}};let B=I(o).filter(m=>m.id!==$).filter(m=>_(m.metadata,E)).map(m=>({id:m.id,score:U(Y,O,m.values),values:m.values,metadata:m.metadata}));return{status:200,body:{matches:F(Y,B).slice(0,Math.max(0,s)).map(m=>({id:m.id,score:m.score,...a?{values:m.values}:{},...u?{metadata:m.metadata}:{}})),namespace:o}}}if(c==="/describe_index_stats"&&t==="POST"){let o=C("vector",e.root).filter(a=>a.id.startsWith(`vector:${p}::`)),s={};for(let a of o){let u=Z(a.id.slice(7));u&&(s[u.namespace]={vectorCount:(s[u.namespace]?.vectorCount??0)+1})}return{status:200,body:{namespaces:s,dimension:b??null,indexFullness:0,totalVectorCount:o.length}}}return N(404,5,`Unrecognized data-plane route: ${t} ${c}`)}import{serveHttp as Re}from"../../engine/v2/volter_world-core.mjs";import{worldNow as me,statefulTwinManifest as ye}from"../../engine/v2/volter_world-core.mjs";function te(e){let t=e.readOnly??!1;return async function(i){let c=new URL(i.url);if(i.method==="GET"&&c.pathname.replace(/\/+$/,"")==="/twin")return Response.json(ye({vendor:"pinecone",twinOf:"the Pinecone vector database",stores:"indexes, collections and vectors, searched by a real brute-force scorer"}));let l={};i.headers.forEach((T,b)=>{l[b.toLowerCase()]=T});let r=l["x-pinecone-target-host"]||l.host||c.host,d=i.method!=="GET"&&i.method!=="HEAD"?await i.text():"",{status:f,body:R,headers:p}=await k({method:i.method,path:c.pathname+(c.search||""),body:d,headers:l,host:r,readOnly:t,occurredAt:me(),...e.root!==void 0?{root:e.root}:{}});return f===202||f===204||R===null?new Response(null,{status:f,headers:{...p??{}}}):new Response(JSON.stringify(R),{status:f,headers:{"content-type":"application/json",...p??{}}})}}import{syncPull as Ve}from"../../engine/v2/volter_world-core.mjs";import{declareRateBudget as he,rateBudgetPath as Be,rateBudgetWeight as Ge,RateBudget as Ue,RateBudgetError as Fe}from"../../engine/v2/volter_world-core.mjs";import{RateBudgetError as Ee}from"../../engine/v2/volter_world-core.mjs";var ge="pinecone",ne=6e4,oe=60,re=300,H={fanout:4,other:2};var K={windowMs:ne,ceiling:oe,defaultWeight:H.other,maxRetryAfterSeconds:re,rules:[{match:"(^|\\.)listVectors$",weight:H.fanout}],reason:"Pinecone publishes a detailed DATA-plane limits table (per namespace/s: query/upsert/delete/update 100, by-metadata mutations only 5; per index/s: List 200, Fetch 100) but NO limit at all for the CONTROL-plane listIndexes/describeIndex this connector calls. With no documented figure for the endpoint actually used, this ceiling is pinned to the kernel's conservative fallback (60 units / 60s at weight 2 = 30 calls/min) rather than borrowed from the looser data-plane rows \u2014 no more permissive than an undeclared vendor already gets. listVectors costs 4 because it is this pack's own cross-index, per-namespace paginated aggregation, not a single vendor endpoint \u2014 a judgement call, not a published cost. Pinecone's limits page does not document Retry-After; the 429/exhaustion cooldown is the backstop."};he(ge,K);export{te as createTwinFetch};
|