telnyx 7.28.0 → 7.30.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/README.md +27 -0
- package/client.d.mts +37 -6
- package/client.d.mts.map +1 -1
- package/client.d.ts +37 -6
- package/client.d.ts.map +1 -1
- package/client.js +31 -0
- package/client.js.map +1 -1
- package/client.mjs +31 -0
- package/client.mjs.map +1 -1
- package/lib/login-token.d.mts +87 -0
- package/lib/login-token.d.mts.map +1 -0
- package/lib/login-token.d.ts +87 -0
- package/lib/login-token.d.ts.map +1 -0
- package/lib/login-token.js +190 -0
- package/lib/login-token.js.map +1 -0
- package/lib/login-token.mjs +151 -0
- package/lib/login-token.mjs.map +1 -0
- package/package.json +1 -1
- package/resources/addresses/actions.d.mts +19 -4
- package/resources/addresses/actions.d.mts.map +1 -1
- package/resources/addresses/actions.d.ts +19 -4
- package/resources/addresses/actions.d.ts.map +1 -1
- package/resources/ai/ai.d.mts +4 -0
- package/resources/ai/ai.d.mts.map +1 -1
- package/resources/ai/ai.d.ts +4 -0
- package/resources/ai/ai.d.ts.map +1 -1
- package/resources/ai/ai.js +4 -0
- package/resources/ai/ai.js.map +1 -1
- package/resources/ai/ai.mjs +4 -0
- package/resources/ai/ai.mjs.map +1 -1
- package/resources/ai/assistants/assistants.d.mts +31 -27
- package/resources/ai/assistants/assistants.d.mts.map +1 -1
- package/resources/ai/assistants/assistants.d.ts +31 -27
- package/resources/ai/assistants/assistants.d.ts.map +1 -1
- package/resources/ai/assistants/assistants.js.map +1 -1
- package/resources/ai/assistants/assistants.mjs.map +1 -1
- package/resources/ai/avatars.d.mts +9 -9
- package/resources/ai/avatars.d.ts +9 -9
- package/resources/ai/avatars.js +9 -9
- package/resources/ai/avatars.mjs +9 -9
- package/resources/ai/index.d.mts +1 -0
- package/resources/ai/index.d.mts.map +1 -1
- package/resources/ai/index.d.ts +1 -0
- package/resources/ai/index.d.ts.map +1 -1
- package/resources/ai/index.js +5 -3
- package/resources/ai/index.js.map +1 -1
- package/resources/ai/index.mjs +1 -0
- package/resources/ai/index.mjs.map +1 -1
- package/resources/ai/tests/index.d.mts +4 -0
- package/resources/ai/tests/index.d.mts.map +1 -0
- package/resources/ai/tests/index.d.ts +4 -0
- package/resources/ai/tests/index.d.ts.map +1 -0
- package/resources/ai/tests/index.js +11 -0
- package/resources/ai/tests/index.js.map +1 -0
- package/resources/ai/tests/index.mjs +5 -0
- package/resources/ai/tests/index.mjs.map +1 -0
- package/resources/ai/tests/schedules/index.d.mts +3 -0
- package/resources/ai/tests/schedules/index.d.mts.map +1 -0
- package/resources/ai/tests/schedules/index.d.ts +3 -0
- package/resources/ai/tests/schedules/index.d.ts.map +1 -0
- package/resources/ai/tests/schedules/index.js +9 -0
- package/resources/ai/tests/schedules/index.js.map +1 -0
- package/resources/ai/tests/schedules/index.mjs +4 -0
- package/resources/ai/tests/schedules/index.mjs.map +1 -0
- package/resources/ai/tests/schedules/schedules.d.mts +10 -0
- package/resources/ai/tests/schedules/schedules.d.mts.map +1 -0
- package/resources/ai/tests/schedules/schedules.d.ts +10 -0
- package/resources/ai/tests/schedules/schedules.d.ts.map +1 -0
- package/resources/ai/tests/schedules/schedules.js +17 -0
- package/resources/ai/tests/schedules/schedules.js.map +1 -0
- package/resources/ai/tests/schedules/schedules.mjs +12 -0
- package/resources/ai/tests/schedules/schedules.mjs.map +1 -0
- package/resources/ai/tests/schedules/v1/cron-jobs.d.mts +171 -0
- package/resources/ai/tests/schedules/v1/cron-jobs.d.mts.map +1 -0
- package/resources/ai/tests/schedules/v1/cron-jobs.d.ts +171 -0
- package/resources/ai/tests/schedules/v1/cron-jobs.d.ts.map +1 -0
- package/resources/ai/tests/schedules/v1/cron-jobs.js +88 -0
- package/resources/ai/tests/schedules/v1/cron-jobs.js.map +1 -0
- package/resources/ai/tests/schedules/v1/cron-jobs.mjs +84 -0
- package/resources/ai/tests/schedules/v1/cron-jobs.mjs.map +1 -0
- package/resources/ai/tests/schedules/v1/index.d.mts +3 -0
- package/resources/ai/tests/schedules/v1/index.d.mts.map +1 -0
- package/resources/ai/tests/schedules/v1/index.d.ts +3 -0
- package/resources/ai/tests/schedules/v1/index.d.ts.map +1 -0
- package/resources/ai/tests/schedules/v1/index.js +9 -0
- package/resources/ai/tests/schedules/v1/index.js.map +1 -0
- package/resources/ai/tests/schedules/v1/index.mjs +4 -0
- package/resources/ai/tests/schedules/v1/index.mjs.map +1 -0
- package/resources/ai/tests/schedules/v1/v1.d.mts +10 -0
- package/resources/ai/tests/schedules/v1/v1.d.mts.map +1 -0
- package/resources/ai/tests/schedules/v1/v1.d.ts +10 -0
- package/resources/ai/tests/schedules/v1/v1.d.ts.map +1 -0
- package/resources/ai/tests/schedules/v1/v1.js +17 -0
- package/resources/ai/tests/schedules/v1/v1.js.map +1 -0
- package/resources/ai/tests/schedules/v1/v1.mjs +12 -0
- package/resources/ai/tests/schedules/v1/v1.mjs.map +1 -0
- package/resources/ai/tests/schedules/v1.d.mts +2 -0
- package/resources/ai/tests/schedules/v1.d.mts.map +1 -0
- package/resources/ai/tests/schedules/v1.d.ts +2 -0
- package/resources/ai/tests/schedules/v1.d.ts.map +1 -0
- package/resources/ai/tests/schedules/v1.js +6 -0
- package/resources/ai/tests/schedules/v1.js.map +1 -0
- package/resources/ai/tests/schedules/v1.mjs +3 -0
- package/resources/ai/tests/schedules/v1.mjs.map +1 -0
- package/resources/ai/tests/schedules.d.mts +2 -0
- package/resources/ai/tests/schedules.d.mts.map +1 -0
- package/resources/ai/tests/schedules.d.ts +2 -0
- package/resources/ai/tests/schedules.d.ts.map +1 -0
- package/resources/ai/tests/schedules.js +6 -0
- package/resources/ai/tests/schedules.js.map +1 -0
- package/resources/ai/tests/schedules.mjs +3 -0
- package/resources/ai/tests/schedules.mjs.map +1 -0
- package/resources/ai/tests/test-framework/index.d.mts +3 -0
- package/resources/ai/tests/test-framework/index.d.mts.map +1 -0
- package/resources/ai/tests/test-framework/index.d.ts +3 -0
- package/resources/ai/tests/test-framework/index.d.ts.map +1 -0
- package/resources/ai/tests/test-framework/index.js +9 -0
- package/resources/ai/tests/test-framework/index.js.map +1 -0
- package/resources/ai/tests/test-framework/index.mjs +4 -0
- package/resources/ai/tests/test-framework/index.mjs.map +1 -0
- package/resources/ai/tests/test-framework/test-framework.d.mts +10 -0
- package/resources/ai/tests/test-framework/test-framework.d.mts.map +1 -0
- package/resources/ai/tests/test-framework/test-framework.d.ts +10 -0
- package/resources/ai/tests/test-framework/test-framework.d.ts.map +1 -0
- package/resources/ai/tests/test-framework/test-framework.js +17 -0
- package/resources/ai/tests/test-framework/test-framework.js.map +1 -0
- package/resources/ai/tests/test-framework/test-framework.mjs +12 -0
- package/resources/ai/tests/test-framework/test-framework.mjs.map +1 -0
- package/resources/ai/tests/test-framework/v1/aiagents.d.mts +216 -0
- package/resources/ai/tests/test-framework/v1/aiagents.d.mts.map +1 -0
- package/resources/ai/tests/test-framework/v1/aiagents.d.ts +216 -0
- package/resources/ai/tests/test-framework/v1/aiagents.d.ts.map +1 -0
- package/resources/ai/tests/test-framework/v1/aiagents.js +93 -0
- package/resources/ai/tests/test-framework/v1/aiagents.js.map +1 -0
- package/resources/ai/tests/test-framework/v1/aiagents.mjs +89 -0
- package/resources/ai/tests/test-framework/v1/aiagents.mjs.map +1 -0
- package/resources/ai/tests/test-framework/v1/index.d.mts +6 -0
- package/resources/ai/tests/test-framework/v1/index.d.mts.map +1 -0
- package/resources/ai/tests/test-framework/v1/index.d.ts +6 -0
- package/resources/ai/tests/test-framework/v1/index.d.ts.map +1 -0
- package/resources/ai/tests/test-framework/v1/index.js +15 -0
- package/resources/ai/tests/test-framework/v1/index.js.map +1 -0
- package/resources/ai/tests/test-framework/v1/index.mjs +7 -0
- package/resources/ai/tests/test-framework/v1/index.mjs.map +1 -0
- package/resources/ai/tests/test-framework/v1/metrics.d.mts +339 -0
- package/resources/ai/tests/test-framework/v1/metrics.d.mts.map +1 -0
- package/resources/ai/tests/test-framework/v1/metrics.d.ts +339 -0
- package/resources/ai/tests/test-framework/v1/metrics.d.ts.map +1 -0
- package/resources/ai/tests/test-framework/v1/metrics.js +145 -0
- package/resources/ai/tests/test-framework/v1/metrics.js.map +1 -0
- package/resources/ai/tests/test-framework/v1/metrics.mjs +141 -0
- package/resources/ai/tests/test-framework/v1/metrics.mjs.map +1 -0
- package/resources/ai/tests/test-framework/v1/results.d.mts +207 -0
- package/resources/ai/tests/test-framework/v1/results.d.mts.map +1 -0
- package/resources/ai/tests/test-framework/v1/results.d.ts +207 -0
- package/resources/ai/tests/test-framework/v1/results.d.ts.map +1 -0
- package/resources/ai/tests/test-framework/v1/results.js +65 -0
- package/resources/ai/tests/test-framework/v1/results.js.map +1 -0
- package/resources/ai/tests/test-framework/v1/results.mjs +61 -0
- package/resources/ai/tests/test-framework/v1/results.mjs.map +1 -0
- package/resources/ai/tests/test-framework/v1/scenarios.d.mts +528 -0
- package/resources/ai/tests/test-framework/v1/scenarios.d.mts.map +1 -0
- package/resources/ai/tests/test-framework/v1/scenarios.d.ts +528 -0
- package/resources/ai/tests/test-framework/v1/scenarios.d.ts.map +1 -0
- package/resources/ai/tests/test-framework/v1/scenarios.js +222 -0
- package/resources/ai/tests/test-framework/v1/scenarios.js.map +1 -0
- package/resources/ai/tests/test-framework/v1/scenarios.mjs +218 -0
- package/resources/ai/tests/test-framework/v1/scenarios.mjs.map +1 -0
- package/resources/ai/tests/test-framework/v1/v1.d.mts +83 -0
- package/resources/ai/tests/test-framework/v1/v1.d.mts.map +1 -0
- package/resources/ai/tests/test-framework/v1/v1.d.ts +83 -0
- package/resources/ai/tests/test-framework/v1/v1.d.ts.map +1 -0
- package/resources/ai/tests/test-framework/v1/v1.js +46 -0
- package/resources/ai/tests/test-framework/v1/v1.js.map +1 -0
- package/resources/ai/tests/test-framework/v1/v1.mjs +41 -0
- package/resources/ai/tests/test-framework/v1/v1.mjs.map +1 -0
- package/resources/ai/tests/test-framework/v1.d.mts +2 -0
- package/resources/ai/tests/test-framework/v1.d.mts.map +1 -0
- package/resources/ai/tests/test-framework/v1.d.ts +2 -0
- package/resources/ai/tests/test-framework/v1.d.ts.map +1 -0
- package/resources/ai/tests/test-framework/v1.js +6 -0
- package/resources/ai/tests/test-framework/v1.js.map +1 -0
- package/resources/ai/tests/test-framework/v1.mjs +3 -0
- package/resources/ai/tests/test-framework/v1.mjs.map +1 -0
- package/resources/ai/tests/test-framework.d.mts +2 -0
- package/resources/ai/tests/test-framework.d.mts.map +1 -0
- package/resources/ai/tests/test-framework.d.ts +2 -0
- package/resources/ai/tests/test-framework.d.ts.map +1 -0
- package/resources/ai/tests/test-framework.js +6 -0
- package/resources/ai/tests/test-framework.js.map +1 -0
- package/resources/ai/tests/test-framework.mjs +3 -0
- package/resources/ai/tests/test-framework.mjs.map +1 -0
- package/resources/ai/tests/tests.d.mts +14 -0
- package/resources/ai/tests/tests.d.mts.map +1 -0
- package/resources/ai/tests/tests.d.ts +14 -0
- package/resources/ai/tests/tests.d.ts.map +1 -0
- package/resources/ai/tests/tests.js +21 -0
- package/resources/ai/tests/tests.js.map +1 -0
- package/resources/ai/tests/tests.mjs +16 -0
- package/resources/ai/tests/tests.mjs.map +1 -0
- package/resources/ai/tests.d.mts +2 -0
- package/resources/ai/tests.d.mts.map +1 -0
- package/resources/ai/tests.d.ts +2 -0
- package/resources/ai/tests.d.ts.map +1 -0
- package/resources/ai/tests.js +6 -0
- package/resources/ai/tests.js.map +1 -0
- package/resources/ai/tests.mjs +3 -0
- package/resources/ai/tests.mjs.map +1 -0
- package/resources/artifact-downloads.d.mts +21 -0
- package/resources/artifact-downloads.d.mts.map +1 -0
- package/resources/artifact-downloads.d.ts +21 -0
- package/resources/artifact-downloads.d.ts.map +1 -0
- package/resources/artifact-downloads.js +26 -0
- package/resources/artifact-downloads.js.map +1 -0
- package/resources/artifact-downloads.mjs +22 -0
- package/resources/artifact-downloads.mjs.map +1 -0
- package/resources/bot-challenge.js +1 -1
- package/resources/bot-challenge.js.map +1 -1
- package/resources/bot-challenge.mjs +1 -1
- package/resources/bot-challenge.mjs.map +1 -1
- package/resources/bot-sessions.js +1 -1
- package/resources/bot-sessions.js.map +1 -1
- package/resources/bot-sessions.mjs +1 -1
- package/resources/bot-sessions.mjs.map +1 -1
- package/resources/bot-signup.js +2 -2
- package/resources/bot-signup.js.map +1 -1
- package/resources/bot-signup.mjs +2 -2
- package/resources/bot-signup.mjs.map +1 -1
- package/resources/browser-sessions/actions.d.mts +542 -0
- package/resources/browser-sessions/actions.d.mts.map +1 -0
- package/resources/browser-sessions/actions.d.ts +542 -0
- package/resources/browser-sessions/actions.d.ts.map +1 -0
- package/resources/browser-sessions/actions.js +55 -0
- package/resources/browser-sessions/actions.js.map +1 -0
- package/resources/browser-sessions/actions.mjs +51 -0
- package/resources/browser-sessions/actions.mjs.map +1 -0
- package/resources/browser-sessions/browser-sessions.d.mts +165 -0
- package/resources/browser-sessions/browser-sessions.d.mts.map +1 -0
- package/resources/browser-sessions/browser-sessions.d.ts +165 -0
- package/resources/browser-sessions/browser-sessions.d.ts.map +1 -0
- package/resources/browser-sessions/browser-sessions.js +87 -0
- package/resources/browser-sessions/browser-sessions.js.map +1 -0
- package/resources/browser-sessions/browser-sessions.mjs +82 -0
- package/resources/browser-sessions/browser-sessions.mjs.map +1 -0
- package/resources/browser-sessions/index.d.mts +3 -0
- package/resources/browser-sessions/index.d.mts.map +1 -0
- package/resources/browser-sessions/index.d.ts +3 -0
- package/resources/browser-sessions/index.d.ts.map +1 -0
- package/resources/browser-sessions/index.js +9 -0
- package/resources/browser-sessions/index.js.map +1 -0
- package/resources/browser-sessions/index.mjs +4 -0
- package/resources/browser-sessions/index.mjs.map +1 -0
- package/resources/browser-sessions.d.mts +2 -0
- package/resources/browser-sessions.d.mts.map +1 -0
- package/resources/browser-sessions.d.ts +2 -0
- package/resources/browser-sessions.d.ts.map +1 -0
- package/resources/browser-sessions.js +6 -0
- package/resources/browser-sessions.js.map +1 -0
- package/resources/browser-sessions.mjs +3 -0
- package/resources/browser-sessions.mjs.map +1 -0
- package/resources/call-control-applications.d.mts +2 -2
- package/resources/call-control-applications.d.ts +2 -2
- package/resources/calls/actions.d.mts +35 -28
- package/resources/calls/actions.d.mts.map +1 -1
- package/resources/calls/actions.d.ts +35 -28
- package/resources/calls/actions.d.ts.map +1 -1
- package/resources/conferences/actions.d.mts +3 -2
- package/resources/conferences/actions.d.mts.map +1 -1
- package/resources/conferences/actions.d.ts +3 -2
- package/resources/conferences/actions.d.ts.map +1 -1
- package/resources/email/dedicated-ips/actions.d.mts +73 -0
- package/resources/email/dedicated-ips/actions.d.mts.map +1 -0
- package/resources/email/dedicated-ips/actions.d.ts +73 -0
- package/resources/email/dedicated-ips/actions.d.ts.map +1 -0
- package/resources/email/dedicated-ips/actions.js +84 -0
- package/resources/email/dedicated-ips/actions.js.map +1 -0
- package/resources/email/dedicated-ips/actions.mjs +80 -0
- package/resources/email/dedicated-ips/actions.mjs.map +1 -0
- package/resources/email/dedicated-ips/dedicated-ips.d.mts +444 -0
- package/resources/email/dedicated-ips/dedicated-ips.d.mts.map +1 -0
- package/resources/email/dedicated-ips/dedicated-ips.d.ts +444 -0
- package/resources/email/dedicated-ips/dedicated-ips.d.ts.map +1 -0
- package/resources/email/dedicated-ips/dedicated-ips.js +142 -0
- package/resources/email/dedicated-ips/dedicated-ips.js.map +1 -0
- package/resources/email/dedicated-ips/dedicated-ips.mjs +137 -0
- package/resources/email/dedicated-ips/dedicated-ips.mjs.map +1 -0
- package/resources/email/dedicated-ips/index.d.mts +3 -0
- package/resources/email/dedicated-ips/index.d.mts.map +1 -0
- package/resources/email/dedicated-ips/index.d.ts +3 -0
- package/resources/email/dedicated-ips/index.d.ts.map +1 -0
- package/resources/email/dedicated-ips/index.js +9 -0
- package/resources/email/dedicated-ips/index.js.map +1 -0
- package/resources/email/dedicated-ips/index.mjs +4 -0
- package/resources/email/dedicated-ips/index.mjs.map +1 -0
- package/resources/email/dedicated-ips.d.mts +2 -0
- package/resources/email/dedicated-ips.d.mts.map +1 -0
- package/resources/email/dedicated-ips.d.ts +2 -0
- package/resources/email/dedicated-ips.d.ts.map +1 -0
- package/resources/email/dedicated-ips.js +6 -0
- package/resources/email/dedicated-ips.js.map +1 -0
- package/resources/email/dedicated-ips.mjs +3 -0
- package/resources/email/dedicated-ips.mjs.map +1 -0
- package/resources/email/email.d.mts +14 -0
- package/resources/email/email.d.mts.map +1 -0
- package/resources/email/email.d.ts +14 -0
- package/resources/email/email.d.ts.map +1 -0
- package/resources/email/email.js +21 -0
- package/resources/email/email.js.map +1 -0
- package/resources/email/email.mjs +16 -0
- package/resources/email/email.mjs.map +1 -0
- package/resources/email/index.d.mts +4 -0
- package/resources/email/index.d.mts.map +1 -0
- package/resources/email/index.d.ts +4 -0
- package/resources/email/index.d.ts.map +1 -0
- package/resources/email/index.js +11 -0
- package/resources/email/index.js.map +1 -0
- package/resources/email/index.mjs +5 -0
- package/resources/email/index.mjs.map +1 -0
- package/resources/email/ip-pools/index.d.mts +3 -0
- package/resources/email/ip-pools/index.d.mts.map +1 -0
- package/resources/email/ip-pools/index.d.ts +3 -0
- package/resources/email/ip-pools/index.d.ts.map +1 -0
- package/resources/email/ip-pools/index.js +9 -0
- package/resources/email/ip-pools/index.js.map +1 -0
- package/resources/email/ip-pools/index.mjs +4 -0
- package/resources/email/ip-pools/index.mjs.map +1 -0
- package/resources/email/ip-pools/ip-pools.d.mts +184 -0
- package/resources/email/ip-pools/ip-pools.d.mts.map +1 -0
- package/resources/email/ip-pools/ip-pools.d.ts +184 -0
- package/resources/email/ip-pools/ip-pools.d.ts.map +1 -0
- package/resources/email/ip-pools/ip-pools.js +102 -0
- package/resources/email/ip-pools/ip-pools.js.map +1 -0
- package/resources/email/ip-pools/ip-pools.mjs +97 -0
- package/resources/email/ip-pools/ip-pools.mjs.map +1 -0
- package/resources/email/ip-pools/ips.d.mts +83 -0
- package/resources/email/ip-pools/ips.d.mts.map +1 -0
- package/resources/email/ip-pools/ips.d.ts +83 -0
- package/resources/email/ip-pools/ips.d.ts.map +1 -0
- package/resources/email/ip-pools/ips.js +54 -0
- package/resources/email/ip-pools/ips.js.map +1 -0
- package/resources/email/ip-pools/ips.mjs +50 -0
- package/resources/email/ip-pools/ips.mjs.map +1 -0
- package/resources/email/ip-pools.d.mts +2 -0
- package/resources/email/ip-pools.d.mts.map +1 -0
- package/resources/email/ip-pools.d.ts +2 -0
- package/resources/email/ip-pools.d.ts.map +1 -0
- package/resources/email/ip-pools.js +6 -0
- package/resources/email/ip-pools.js.map +1 -0
- package/resources/email/ip-pools.mjs +3 -0
- package/resources/email/ip-pools.mjs.map +1 -0
- package/resources/email.d.mts +2 -0
- package/resources/email.d.mts.map +1 -0
- package/resources/email.d.ts +2 -0
- package/resources/email.d.ts.map +1 -0
- package/resources/email.js +6 -0
- package/resources/email.js.map +1 -0
- package/resources/email.mjs +3 -0
- package/resources/email.mjs.map +1 -0
- package/resources/fax-applications.d.mts +6 -6
- package/resources/fax-applications.d.ts +6 -6
- package/resources/fqdn-connections/fqdn-connections.d.mts +2 -2
- package/resources/fqdn-connections/fqdn-connections.d.ts +2 -2
- package/resources/index.d.mts +8 -2
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +8 -2
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +16 -4
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +6 -0
- package/resources/index.mjs.map +1 -1
- package/resources/ip-connections.d.mts +4 -4
- package/resources/ip-connections.d.ts +4 -4
- package/resources/messaging-profiles/index.d.mts +1 -1
- package/resources/messaging-profiles/index.d.mts.map +1 -1
- package/resources/messaging-profiles/index.d.ts +1 -1
- package/resources/messaging-profiles/index.d.ts.map +1 -1
- package/resources/messaging-profiles/index.js.map +1 -1
- package/resources/messaging-profiles/index.mjs.map +1 -1
- package/resources/messaging-profiles/messaging-profiles.d.mts +26 -1
- package/resources/messaging-profiles/messaging-profiles.d.mts.map +1 -1
- package/resources/messaging-profiles/messaging-profiles.d.ts +26 -1
- package/resources/messaging-profiles/messaging-profiles.d.ts.map +1 -1
- package/resources/messaging-profiles/messaging-profiles.js.map +1 -1
- package/resources/messaging-profiles/messaging-profiles.mjs.map +1 -1
- package/resources/network-routes.d.mts +257 -0
- package/resources/network-routes.d.mts.map +1 -0
- package/resources/network-routes.d.ts +257 -0
- package/resources/network-routes.d.ts.map +1 -0
- package/resources/network-routes.js +83 -0
- package/resources/network-routes.js.map +1 -0
- package/resources/network-routes.mjs +79 -0
- package/resources/network-routes.mjs.map +1 -0
- package/resources/pay-connectors.d.mts +378 -0
- package/resources/pay-connectors.d.mts.map +1 -0
- package/resources/pay-connectors.d.ts +378 -0
- package/resources/pay-connectors.d.ts.map +1 -0
- package/resources/pay-connectors.js +116 -0
- package/resources/pay-connectors.js.map +1 -0
- package/resources/pay-connectors.mjs +112 -0
- package/resources/pay-connectors.mjs.map +1 -0
- package/resources/public-internet-gateways.d.mts +0 -8
- package/resources/public-internet-gateways.d.mts.map +1 -1
- package/resources/public-internet-gateways.d.ts +0 -8
- package/resources/public-internet-gateways.d.ts.map +1 -1
- package/resources/spend-limits.d.mts +150 -32
- package/resources/spend-limits.d.mts.map +1 -1
- package/resources/spend-limits.d.ts +150 -32
- package/resources/spend-limits.d.ts.map +1 -1
- package/resources/spend-limits.js +26 -7
- package/resources/spend-limits.js.map +1 -1
- package/resources/spend-limits.mjs +26 -7
- package/resources/spend-limits.mjs.map +1 -1
- package/resources/telephony-credentials.d.mts +48 -2
- package/resources/telephony-credentials.d.mts.map +1 -1
- package/resources/telephony-credentials.d.ts +48 -2
- package/resources/telephony-credentials.d.ts.map +1 -1
- package/resources/telephony-credentials.js +46 -2
- package/resources/telephony-credentials.js.map +1 -1
- package/resources/telephony-credentials.mjs +46 -2
- package/resources/telephony-credentials.mjs.map +1 -1
- package/resources/texml-applications.d.mts +6 -6
- package/resources/texml-applications.d.ts +6 -6
- package/resources/text-to-speech/text-to-speech.d.mts +1 -6
- package/resources/text-to-speech/text-to-speech.d.mts.map +1 -1
- package/resources/text-to-speech/text-to-speech.d.ts +1 -6
- package/resources/text-to-speech/text-to-speech.d.ts.map +1 -1
- package/resources/text-to-speech/text-to-speech.js +1 -2
- package/resources/text-to-speech/text-to-speech.js.map +1 -1
- package/resources/text-to-speech/text-to-speech.mjs +1 -2
- package/resources/text-to-speech/text-to-speech.mjs.map +1 -1
- package/resources/tunnels/actions.d.mts +29 -0
- package/resources/tunnels/actions.d.mts.map +1 -0
- package/resources/tunnels/actions.d.ts +29 -0
- package/resources/tunnels/actions.d.ts.map +1 -0
- package/resources/tunnels/actions.js +28 -0
- package/resources/tunnels/actions.js.map +1 -0
- package/resources/tunnels/actions.mjs +24 -0
- package/resources/tunnels/actions.mjs.map +1 -0
- package/resources/tunnels/index.d.mts +3 -0
- package/resources/tunnels/index.d.mts.map +1 -0
- package/resources/tunnels/index.d.ts +3 -0
- package/resources/tunnels/index.d.ts.map +1 -0
- package/resources/tunnels/index.js +9 -0
- package/resources/tunnels/index.js.map +1 -0
- package/resources/tunnels/index.mjs +4 -0
- package/resources/tunnels/index.mjs.map +1 -0
- package/resources/tunnels/tunnels.d.mts +194 -0
- package/resources/tunnels/tunnels.d.mts.map +1 -0
- package/resources/tunnels/tunnels.d.ts +194 -0
- package/resources/tunnels/tunnels.d.ts.map +1 -0
- package/resources/tunnels/tunnels.js +82 -0
- package/resources/tunnels/tunnels.js.map +1 -0
- package/resources/tunnels/tunnels.mjs +77 -0
- package/resources/tunnels/tunnels.mjs.map +1 -0
- package/resources/tunnels.d.mts +2 -0
- package/resources/tunnels.d.mts.map +1 -0
- package/resources/tunnels.d.ts +2 -0
- package/resources/tunnels.d.ts.map +1 -0
- package/resources/tunnels.js +6 -0
- package/resources/tunnels.js.map +1 -0
- package/resources/tunnels.mjs +3 -0
- package/resources/tunnels.mjs.map +1 -0
- package/resources/voice-clones.d.mts +54 -8
- package/resources/voice-clones.d.mts.map +1 -1
- package/resources/voice-clones.d.ts +54 -8
- package/resources/voice-clones.d.ts.map +1 -1
- package/resources/voice-clones.js +6 -5
- package/resources/voice-clones.js.map +1 -1
- package/resources/voice-clones.mjs +6 -5
- package/resources/voice-clones.mjs.map +1 -1
- package/resources/whatsapp/hosted-signups.d.mts +2 -1
- package/resources/whatsapp/hosted-signups.d.mts.map +1 -1
- package/resources/whatsapp/hosted-signups.d.ts +2 -1
- package/resources/whatsapp/hosted-signups.d.ts.map +1 -1
- package/resources/wireguard-interfaces.d.mts +0 -8
- package/resources/wireguard-interfaces.d.mts.map +1 -1
- package/resources/wireguard-interfaces.d.ts +0 -8
- package/resources/wireguard-interfaces.d.ts.map +1 -1
- package/src/client.ts +130 -0
- package/src/lib/login-token.ts +219 -0
- package/src/resources/addresses/actions.ts +23 -4
- package/src/resources/ai/ai.ts +6 -0
- package/src/resources/ai/assistants/assistants.ts +31 -24
- package/src/resources/ai/avatars.ts +9 -9
- package/src/resources/ai/index.ts +1 -0
- package/src/resources/ai/tests/index.ts +5 -0
- package/src/resources/ai/tests/schedules/index.ts +4 -0
- package/src/resources/ai/tests/schedules/schedules.ts +15 -0
- package/src/resources/ai/tests/schedules/v1/cron-jobs.ts +248 -0
- package/src/resources/ai/tests/schedules/v1/index.ts +12 -0
- package/src/resources/ai/tests/schedules/v1/v1.ts +31 -0
- package/src/resources/ai/tests/schedules/v1.ts +3 -0
- package/src/resources/ai/tests/schedules.ts +3 -0
- package/src/resources/ai/tests/test-framework/index.ts +4 -0
- package/src/resources/ai/tests/test-framework/test-framework.ts +15 -0
- package/src/resources/ai/tests/test-framework/v1/aiagents.ts +304 -0
- package/src/resources/ai/tests/test-framework/v1/index.ts +54 -0
- package/src/resources/ai/tests/test-framework/v1/metrics.ts +491 -0
- package/src/resources/ai/tests/test-framework/v1/results.ts +304 -0
- package/src/resources/ai/tests/test-framework/v1/scenarios.ts +774 -0
- package/src/resources/ai/tests/test-framework/v1/v1.ts +214 -0
- package/src/resources/ai/tests/test-framework/v1.ts +3 -0
- package/src/resources/ai/tests/test-framework.ts +3 -0
- package/src/resources/ai/tests/tests.ts +21 -0
- package/src/resources/ai/tests.ts +3 -0
- package/src/resources/artifact-downloads.ts +39 -0
- package/src/resources/bot-challenge.ts +1 -1
- package/src/resources/bot-sessions.ts +1 -1
- package/src/resources/bot-signup.ts +2 -2
- package/src/resources/browser-sessions/actions.ts +778 -0
- package/src/resources/browser-sessions/browser-sessions.ts +278 -0
- package/src/resources/browser-sessions/index.ts +31 -0
- package/src/resources/browser-sessions.ts +3 -0
- package/src/resources/call-control-applications.ts +2 -2
- package/src/resources/calls/actions.ts +38 -27
- package/src/resources/conferences/actions.ts +3 -2
- package/src/resources/email/dedicated-ips/actions.ts +87 -0
- package/src/resources/email/dedicated-ips/dedicated-ips.ts +563 -0
- package/src/resources/email/dedicated-ips/index.ts +13 -0
- package/src/resources/email/dedicated-ips.ts +3 -0
- package/src/resources/email/email.ts +55 -0
- package/src/resources/email/index.ts +22 -0
- package/src/resources/email/ip-pools/index.ts +12 -0
- package/src/resources/email/ip-pools/ip-pools.ts +247 -0
- package/src/resources/email/ip-pools/ips.ts +112 -0
- package/src/resources/email/ip-pools.ts +3 -0
- package/src/resources/email.ts +3 -0
- package/src/resources/fax-applications.ts +6 -6
- package/src/resources/fqdn-connections/fqdn-connections.ts +2 -2
- package/src/resources/index.ts +46 -0
- package/src/resources/ip-connections.ts +4 -4
- package/src/resources/messaging-profiles/index.ts +1 -0
- package/src/resources/messaging-profiles/messaging-profiles.ts +31 -0
- package/src/resources/network-routes.ts +332 -0
- package/src/resources/pay-connectors.ts +482 -0
- package/src/resources/public-internet-gateways.ts +0 -10
- package/src/resources/spend-limits.ts +179 -36
- package/src/resources/telephony-credentials.ts +75 -2
- package/src/resources/texml-applications.ts +6 -6
- package/src/resources/text-to-speech/text-to-speech.ts +1 -7
- package/src/resources/tunnels/actions.ts +36 -0
- package/src/resources/tunnels/index.ts +13 -0
- package/src/resources/tunnels/tunnels.ts +260 -0
- package/src/resources/tunnels.ts +3 -0
- package/src/resources/voice-clones.ts +88 -8
- package/src/resources/whatsapp/hosted-signups.ts +2 -1
- package/src/resources/wireguard-interfaces.ts +0 -10
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.mts.map +1 -1
- package/version.d.ts +1 -1
- package/version.d.ts.map +1 -1
- package/version.js +1 -1
- package/version.js.map +1 -1
- package/version.mjs +1 -1
- package/version.mjs.map +1 -1
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WebRTC login tokens minted locally, with no request to Telnyx.
|
|
3
|
+
*
|
|
4
|
+
* The token has the same shape as the one
|
|
5
|
+
* `POST /v2/telephony_credentials/{id}/token` returns, so it is used the same
|
|
6
|
+
* way: pass it to the WebRTC SDK as `login_token`. Telnyx verifies it on login.
|
|
7
|
+
* It is the same computation as `TelephonyCredential#to_jwt` in telnyx-ruby.
|
|
8
|
+
*
|
|
9
|
+
* The signing material comes from the credential: `token_material` is in the
|
|
10
|
+
* response of `POST /v2/telephony_credentials` and of
|
|
11
|
+
* `GET /v2/telephony_credentials/{id}/token_material`. It is as sensitive as
|
|
12
|
+
* the SIP password, so keep it on the server; never ship it to a browser.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* const { data: credential } = await client.telephonyCredentials.create({
|
|
16
|
+
* connection_id: '123',
|
|
17
|
+
* include: 'token_material', // the API returns the material only when asked
|
|
18
|
+
* });
|
|
19
|
+
* const loginToken = await client.telephonyCredentials.toJwt(credential); // 1 hour
|
|
20
|
+
* const shortLived = await client.telephonyCredentials.toJwt(credential, { ttl: 600 });
|
|
21
|
+
*
|
|
22
|
+
* To mint later with no request at all, store these with the user the credential
|
|
23
|
+
* belongs to, server side: `id`, `user_id`, `sip_username`, `expires_at` and
|
|
24
|
+
* `token_material`. The token is built from all of them.
|
|
25
|
+
*
|
|
26
|
+
* @example From stored values, without a request at all
|
|
27
|
+
* import { createLoginToken } from 'telnyx/lib/login-token';
|
|
28
|
+
* const loginToken = await createLoginToken({
|
|
29
|
+
* id: '...', user_id: '...', sip_username: 'gencred...', expires_at: '2027-01-01T00:00:00Z',
|
|
30
|
+
* token_material: { kid: 'v1', tel_token: '...', signing_secret: '...' },
|
|
31
|
+
* });
|
|
32
|
+
*/
|
|
33
|
+
import { TelnyxError } from "../core/error.mjs";
|
|
34
|
+
/** Token lifetime when `ttl` is not given: one hour. */
|
|
35
|
+
export declare const LOGIN_TOKEN_DEFAULT_TTL = 3600;
|
|
36
|
+
/** Longest lifetime a login token can have: one day, the same as API-minted tokens. */
|
|
37
|
+
export declare const LOGIN_TOKEN_MAX_TTL = 86400;
|
|
38
|
+
/** `cty` header of a locally minted token; voice-sdk-proxy selects the verification path by it. */
|
|
39
|
+
export declare const LOGIN_TOKEN_CONTENT_TYPE = "telnyx-webrtc;v=1";
|
|
40
|
+
/**
|
|
41
|
+
* What the API returns as `token_material`. `signing_secret` is base64url
|
|
42
|
+
* (unpadded) bytes of the HS256 key; `tel_token` goes into the token as is.
|
|
43
|
+
*/
|
|
44
|
+
export interface TokenMaterial {
|
|
45
|
+
/** Which key the material was derived with (`v1` today). Goes in the JWT header. */
|
|
46
|
+
kid: string;
|
|
47
|
+
/** The SIP credential encrypted for the gateway, the same value `/token` puts in the `tel_token` claim. */
|
|
48
|
+
tel_token: string;
|
|
49
|
+
/** The HS256 key the token is signed with, base64url. */
|
|
50
|
+
signing_secret: string;
|
|
51
|
+
}
|
|
52
|
+
/** The fields of a telephony credential that a login token is built from. */
|
|
53
|
+
export interface LoginTokenCredential {
|
|
54
|
+
/** The telephony credential `id`. */
|
|
55
|
+
id?: string | undefined;
|
|
56
|
+
/** The credential's `user_id`. */
|
|
57
|
+
user_id?: string | undefined;
|
|
58
|
+
/** The credential's `sip_username`; the token's `identity`. */
|
|
59
|
+
sip_username?: string | undefined;
|
|
60
|
+
/** The credential's `expires_at`, as the API returns it, or null. */
|
|
61
|
+
expires_at?: string | null | undefined;
|
|
62
|
+
/** `kid`, `tel_token`, `signing_secret`; present on a credential from `create`. */
|
|
63
|
+
token_material?: TokenMaterial | undefined;
|
|
64
|
+
}
|
|
65
|
+
export interface LoginTokenOptions {
|
|
66
|
+
/** Token lifetime in seconds, 1..86400. Default one hour. */
|
|
67
|
+
ttl?: number | undefined;
|
|
68
|
+
/** Signing material to use instead of `credential.token_material`. */
|
|
69
|
+
tokenMaterial?: TokenMaterial | undefined;
|
|
70
|
+
/** The token's issue time; defaults to now. */
|
|
71
|
+
now?: Date | number | undefined;
|
|
72
|
+
}
|
|
73
|
+
export declare class TelnyxLoginTokenError extends TelnyxError {
|
|
74
|
+
constructor(message: string);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Mints a login token for `credential`, valid from `now` for `ttl` seconds.
|
|
78
|
+
* Pure computation: HMAC-SHA256 over the token with `token_material.signing_secret`.
|
|
79
|
+
*/
|
|
80
|
+
export declare function createLoginToken(credential: LoginTokenCredential, options?: LoginTokenOptions): Promise<string>;
|
|
81
|
+
/**
|
|
82
|
+
* Checks a token minted by `createLoginToken` against `signingSecret` and
|
|
83
|
+
* returns its claims. For tests and debugging: Telnyx does the real
|
|
84
|
+
* verification on login.
|
|
85
|
+
*/
|
|
86
|
+
export declare function decodeLoginToken(jwt: string, signingSecret: string): Promise<Record<string, unknown>>;
|
|
87
|
+
//# sourceMappingURL=login-token.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"login-token.d.mts","sourceRoot":"","sources":["../src/lib/login-token.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAAE,WAAW,EAAE,0BAAsB;AAI5C,wDAAwD;AACxD,eAAO,MAAM,uBAAuB,OAAO,CAAC;AAC5C,uFAAuF;AACvF,eAAO,MAAM,mBAAmB,QAAQ,CAAC;AACzC,mGAAmG;AACnG,eAAO,MAAM,wBAAwB,sBAAsB,CAAC;AAE5D;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,oFAAoF;IACpF,GAAG,EAAE,MAAM,CAAC;IACZ,2GAA2G;IAC3G,SAAS,EAAE,MAAM,CAAC;IAClB,yDAAyD;IACzD,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,6EAA6E;AAC7E,MAAM,WAAW,oBAAoB;IACnC,qCAAqC;IACrC,EAAE,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,kCAAkC;IAClC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,+DAA+D;IAC/D,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,qEAAqE;IACrE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACvC,mFAAmF;IACnF,cAAc,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;CAC5C;AAED,MAAM,WAAW,iBAAiB;IAChC,6DAA6D;IAC7D,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,sEAAsE;IACtE,aAAa,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;IAC1C,+CAA+C;IAC/C,GAAG,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,SAAS,CAAC;CACjC;AAED,qBAAa,qBAAsB,SAAQ,WAAW;gBACxC,OAAO,EAAE,MAAM;CAI5B;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CACpC,UAAU,EAAE,oBAAoB,EAChC,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,MAAM,CAAC,CAyBjB;AAED;;;;GAIG;AACH,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAW3G"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WebRTC login tokens minted locally, with no request to Telnyx.
|
|
3
|
+
*
|
|
4
|
+
* The token has the same shape as the one
|
|
5
|
+
* `POST /v2/telephony_credentials/{id}/token` returns, so it is used the same
|
|
6
|
+
* way: pass it to the WebRTC SDK as `login_token`. Telnyx verifies it on login.
|
|
7
|
+
* It is the same computation as `TelephonyCredential#to_jwt` in telnyx-ruby.
|
|
8
|
+
*
|
|
9
|
+
* The signing material comes from the credential: `token_material` is in the
|
|
10
|
+
* response of `POST /v2/telephony_credentials` and of
|
|
11
|
+
* `GET /v2/telephony_credentials/{id}/token_material`. It is as sensitive as
|
|
12
|
+
* the SIP password, so keep it on the server; never ship it to a browser.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* const { data: credential } = await client.telephonyCredentials.create({
|
|
16
|
+
* connection_id: '123',
|
|
17
|
+
* include: 'token_material', // the API returns the material only when asked
|
|
18
|
+
* });
|
|
19
|
+
* const loginToken = await client.telephonyCredentials.toJwt(credential); // 1 hour
|
|
20
|
+
* const shortLived = await client.telephonyCredentials.toJwt(credential, { ttl: 600 });
|
|
21
|
+
*
|
|
22
|
+
* To mint later with no request at all, store these with the user the credential
|
|
23
|
+
* belongs to, server side: `id`, `user_id`, `sip_username`, `expires_at` and
|
|
24
|
+
* `token_material`. The token is built from all of them.
|
|
25
|
+
*
|
|
26
|
+
* @example From stored values, without a request at all
|
|
27
|
+
* import { createLoginToken } from 'telnyx/lib/login-token';
|
|
28
|
+
* const loginToken = await createLoginToken({
|
|
29
|
+
* id: '...', user_id: '...', sip_username: 'gencred...', expires_at: '2027-01-01T00:00:00Z',
|
|
30
|
+
* token_material: { kid: 'v1', tel_token: '...', signing_secret: '...' },
|
|
31
|
+
* });
|
|
32
|
+
*/
|
|
33
|
+
import { TelnyxError } from "../core/error.js";
|
|
34
|
+
/** Token lifetime when `ttl` is not given: one hour. */
|
|
35
|
+
export declare const LOGIN_TOKEN_DEFAULT_TTL = 3600;
|
|
36
|
+
/** Longest lifetime a login token can have: one day, the same as API-minted tokens. */
|
|
37
|
+
export declare const LOGIN_TOKEN_MAX_TTL = 86400;
|
|
38
|
+
/** `cty` header of a locally minted token; voice-sdk-proxy selects the verification path by it. */
|
|
39
|
+
export declare const LOGIN_TOKEN_CONTENT_TYPE = "telnyx-webrtc;v=1";
|
|
40
|
+
/**
|
|
41
|
+
* What the API returns as `token_material`. `signing_secret` is base64url
|
|
42
|
+
* (unpadded) bytes of the HS256 key; `tel_token` goes into the token as is.
|
|
43
|
+
*/
|
|
44
|
+
export interface TokenMaterial {
|
|
45
|
+
/** Which key the material was derived with (`v1` today). Goes in the JWT header. */
|
|
46
|
+
kid: string;
|
|
47
|
+
/** The SIP credential encrypted for the gateway, the same value `/token` puts in the `tel_token` claim. */
|
|
48
|
+
tel_token: string;
|
|
49
|
+
/** The HS256 key the token is signed with, base64url. */
|
|
50
|
+
signing_secret: string;
|
|
51
|
+
}
|
|
52
|
+
/** The fields of a telephony credential that a login token is built from. */
|
|
53
|
+
export interface LoginTokenCredential {
|
|
54
|
+
/** The telephony credential `id`. */
|
|
55
|
+
id?: string | undefined;
|
|
56
|
+
/** The credential's `user_id`. */
|
|
57
|
+
user_id?: string | undefined;
|
|
58
|
+
/** The credential's `sip_username`; the token's `identity`. */
|
|
59
|
+
sip_username?: string | undefined;
|
|
60
|
+
/** The credential's `expires_at`, as the API returns it, or null. */
|
|
61
|
+
expires_at?: string | null | undefined;
|
|
62
|
+
/** `kid`, `tel_token`, `signing_secret`; present on a credential from `create`. */
|
|
63
|
+
token_material?: TokenMaterial | undefined;
|
|
64
|
+
}
|
|
65
|
+
export interface LoginTokenOptions {
|
|
66
|
+
/** Token lifetime in seconds, 1..86400. Default one hour. */
|
|
67
|
+
ttl?: number | undefined;
|
|
68
|
+
/** Signing material to use instead of `credential.token_material`. */
|
|
69
|
+
tokenMaterial?: TokenMaterial | undefined;
|
|
70
|
+
/** The token's issue time; defaults to now. */
|
|
71
|
+
now?: Date | number | undefined;
|
|
72
|
+
}
|
|
73
|
+
export declare class TelnyxLoginTokenError extends TelnyxError {
|
|
74
|
+
constructor(message: string);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Mints a login token for `credential`, valid from `now` for `ttl` seconds.
|
|
78
|
+
* Pure computation: HMAC-SHA256 over the token with `token_material.signing_secret`.
|
|
79
|
+
*/
|
|
80
|
+
export declare function createLoginToken(credential: LoginTokenCredential, options?: LoginTokenOptions): Promise<string>;
|
|
81
|
+
/**
|
|
82
|
+
* Checks a token minted by `createLoginToken` against `signingSecret` and
|
|
83
|
+
* returns its claims. For tests and debugging: Telnyx does the real
|
|
84
|
+
* verification on login.
|
|
85
|
+
*/
|
|
86
|
+
export declare function decodeLoginToken(jwt: string, signingSecret: string): Promise<Record<string, unknown>>;
|
|
87
|
+
//# sourceMappingURL=login-token.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"login-token.d.ts","sourceRoot":"","sources":["../src/lib/login-token.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAAE,WAAW,EAAE,yBAAsB;AAI5C,wDAAwD;AACxD,eAAO,MAAM,uBAAuB,OAAO,CAAC;AAC5C,uFAAuF;AACvF,eAAO,MAAM,mBAAmB,QAAQ,CAAC;AACzC,mGAAmG;AACnG,eAAO,MAAM,wBAAwB,sBAAsB,CAAC;AAE5D;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,oFAAoF;IACpF,GAAG,EAAE,MAAM,CAAC;IACZ,2GAA2G;IAC3G,SAAS,EAAE,MAAM,CAAC;IAClB,yDAAyD;IACzD,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,6EAA6E;AAC7E,MAAM,WAAW,oBAAoB;IACnC,qCAAqC;IACrC,EAAE,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,kCAAkC;IAClC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,+DAA+D;IAC/D,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,qEAAqE;IACrE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACvC,mFAAmF;IACnF,cAAc,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;CAC5C;AAED,MAAM,WAAW,iBAAiB;IAChC,6DAA6D;IAC7D,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,sEAAsE;IACtE,aAAa,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;IAC1C,+CAA+C;IAC/C,GAAG,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,SAAS,CAAC;CACjC;AAED,qBAAa,qBAAsB,SAAQ,WAAW;gBACxC,OAAO,EAAE,MAAM;CAI5B;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CACpC,UAAU,EAAE,oBAAoB,EAChC,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,MAAM,CAAC,CAyBjB;AAED;;;;GAIG;AACH,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAW3G"}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* WebRTC login tokens minted locally, with no request to Telnyx.
|
|
4
|
+
*
|
|
5
|
+
* The token has the same shape as the one
|
|
6
|
+
* `POST /v2/telephony_credentials/{id}/token` returns, so it is used the same
|
|
7
|
+
* way: pass it to the WebRTC SDK as `login_token`. Telnyx verifies it on login.
|
|
8
|
+
* It is the same computation as `TelephonyCredential#to_jwt` in telnyx-ruby.
|
|
9
|
+
*
|
|
10
|
+
* The signing material comes from the credential: `token_material` is in the
|
|
11
|
+
* response of `POST /v2/telephony_credentials` and of
|
|
12
|
+
* `GET /v2/telephony_credentials/{id}/token_material`. It is as sensitive as
|
|
13
|
+
* the SIP password, so keep it on the server; never ship it to a browser.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* const { data: credential } = await client.telephonyCredentials.create({
|
|
17
|
+
* connection_id: '123',
|
|
18
|
+
* include: 'token_material', // the API returns the material only when asked
|
|
19
|
+
* });
|
|
20
|
+
* const loginToken = await client.telephonyCredentials.toJwt(credential); // 1 hour
|
|
21
|
+
* const shortLived = await client.telephonyCredentials.toJwt(credential, { ttl: 600 });
|
|
22
|
+
*
|
|
23
|
+
* To mint later with no request at all, store these with the user the credential
|
|
24
|
+
* belongs to, server side: `id`, `user_id`, `sip_username`, `expires_at` and
|
|
25
|
+
* `token_material`. The token is built from all of them.
|
|
26
|
+
*
|
|
27
|
+
* @example From stored values, without a request at all
|
|
28
|
+
* import { createLoginToken } from 'telnyx/lib/login-token';
|
|
29
|
+
* const loginToken = await createLoginToken({
|
|
30
|
+
* id: '...', user_id: '...', sip_username: 'gencred...', expires_at: '2027-01-01T00:00:00Z',
|
|
31
|
+
* token_material: { kid: 'v1', tel_token: '...', signing_secret: '...' },
|
|
32
|
+
* });
|
|
33
|
+
*/
|
|
34
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
35
|
+
if (k2 === undefined) k2 = k;
|
|
36
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
37
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
38
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
39
|
+
}
|
|
40
|
+
Object.defineProperty(o, k2, desc);
|
|
41
|
+
}) : (function(o, m, k, k2) {
|
|
42
|
+
if (k2 === undefined) k2 = k;
|
|
43
|
+
o[k2] = m[k];
|
|
44
|
+
}));
|
|
45
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
46
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
47
|
+
}) : function(o, v) {
|
|
48
|
+
o["default"] = v;
|
|
49
|
+
});
|
|
50
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
51
|
+
var ownKeys = function(o) {
|
|
52
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
53
|
+
var ar = [];
|
|
54
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
55
|
+
return ar;
|
|
56
|
+
};
|
|
57
|
+
return ownKeys(o);
|
|
58
|
+
};
|
|
59
|
+
return function (mod) {
|
|
60
|
+
if (mod && mod.__esModule) return mod;
|
|
61
|
+
var result = {};
|
|
62
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
63
|
+
__setModuleDefault(result, mod);
|
|
64
|
+
return result;
|
|
65
|
+
};
|
|
66
|
+
})();
|
|
67
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
68
|
+
exports.TelnyxLoginTokenError = exports.LOGIN_TOKEN_CONTENT_TYPE = exports.LOGIN_TOKEN_MAX_TTL = exports.LOGIN_TOKEN_DEFAULT_TTL = void 0;
|
|
69
|
+
exports.createLoginToken = createLoginToken;
|
|
70
|
+
exports.decodeLoginToken = decodeLoginToken;
|
|
71
|
+
const error_1 = require("../core/error.js");
|
|
72
|
+
const base64_1 = require("../internal/utils/base64.js");
|
|
73
|
+
const bytes_1 = require("../internal/utils/bytes.js");
|
|
74
|
+
/** Token lifetime when `ttl` is not given: one hour. */
|
|
75
|
+
exports.LOGIN_TOKEN_DEFAULT_TTL = 3600;
|
|
76
|
+
/** Longest lifetime a login token can have: one day, the same as API-minted tokens. */
|
|
77
|
+
exports.LOGIN_TOKEN_MAX_TTL = 86400;
|
|
78
|
+
/** `cty` header of a locally minted token; voice-sdk-proxy selects the verification path by it. */
|
|
79
|
+
exports.LOGIN_TOKEN_CONTENT_TYPE = 'telnyx-webrtc;v=1';
|
|
80
|
+
class TelnyxLoginTokenError extends error_1.TelnyxError {
|
|
81
|
+
constructor(message) {
|
|
82
|
+
super(message);
|
|
83
|
+
this.name = 'TelnyxLoginTokenError';
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
exports.TelnyxLoginTokenError = TelnyxLoginTokenError;
|
|
87
|
+
/**
|
|
88
|
+
* Mints a login token for `credential`, valid from `now` for `ttl` seconds.
|
|
89
|
+
* Pure computation: HMAC-SHA256 over the token with `token_material.signing_secret`.
|
|
90
|
+
*/
|
|
91
|
+
async function createLoginToken(credential, options = {}) {
|
|
92
|
+
const credentialId = required(credential.id, 'id');
|
|
93
|
+
const userId = required(credential.user_id, 'user_id');
|
|
94
|
+
const identity = required(credential.sip_username, 'sip_username');
|
|
95
|
+
const material = normalizeMaterial(options.tokenMaterial ?? credential.token_material);
|
|
96
|
+
const ttl = clampTtl(options.ttl);
|
|
97
|
+
const now = options.now === undefined ? Date.now() : Number(options.now);
|
|
98
|
+
const iat = Math.floor(now / 1000);
|
|
99
|
+
// Same field order as the Ruby SDK, so the two produce the same bytes.
|
|
100
|
+
const header = { alg: 'HS256', typ: 'JWT', cty: exports.LOGIN_TOKEN_CONTENT_TYPE, kid: material.kid };
|
|
101
|
+
const payload = {
|
|
102
|
+
sub: credentialId,
|
|
103
|
+
user_id: userId,
|
|
104
|
+
identity,
|
|
105
|
+
cred_exp: credential.expires_at ?? null,
|
|
106
|
+
tel_token: material.tel_token,
|
|
107
|
+
iat,
|
|
108
|
+
nbf: iat,
|
|
109
|
+
exp: iat + ttl,
|
|
110
|
+
jti: `${credentialId}-${iat}`,
|
|
111
|
+
};
|
|
112
|
+
const signingInput = `${base64url(JSON.stringify(header))}.${base64url(JSON.stringify(payload))}`;
|
|
113
|
+
return `${signingInput}.${base64url(await sign(signingInput, material.signing_secret))}`;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Checks a token minted by `createLoginToken` against `signingSecret` and
|
|
117
|
+
* returns its claims. For tests and debugging: Telnyx does the real
|
|
118
|
+
* verification on login.
|
|
119
|
+
*/
|
|
120
|
+
async function decodeLoginToken(jwt, signingSecret) {
|
|
121
|
+
const [head, body, sig, ...rest] = String(jwt).split('.');
|
|
122
|
+
if (!head || !body || sig === undefined || rest.length) {
|
|
123
|
+
throw new TelnyxLoginTokenError('not a JWT');
|
|
124
|
+
}
|
|
125
|
+
const expected = await sign(`${head}.${body}`, signingSecret);
|
|
126
|
+
const given = fromBase64url(sig);
|
|
127
|
+
if (!bytesEqual(given, expected)) {
|
|
128
|
+
throw new TelnyxLoginTokenError('Signature is invalid and does not match the payload');
|
|
129
|
+
}
|
|
130
|
+
return JSON.parse((0, bytes_1.decodeUTF8)(fromBase64url(body)));
|
|
131
|
+
}
|
|
132
|
+
function required(value, name) {
|
|
133
|
+
if (value === undefined || value === null || String(value) === '') {
|
|
134
|
+
throw new TelnyxLoginTokenError(`${name} is required to mint a token`);
|
|
135
|
+
}
|
|
136
|
+
return String(value);
|
|
137
|
+
}
|
|
138
|
+
function normalizeMaterial(material) {
|
|
139
|
+
if (!material || typeof material !== 'object') {
|
|
140
|
+
throw new TelnyxLoginTokenError('token_material is required to mint a token');
|
|
141
|
+
}
|
|
142
|
+
const out = {};
|
|
143
|
+
for (const field of ['kid', 'tel_token', 'signing_secret']) {
|
|
144
|
+
const value = material[field];
|
|
145
|
+
if (value === undefined || value === null || String(value) === '') {
|
|
146
|
+
throw new TelnyxLoginTokenError(`token_material.${field} is missing`);
|
|
147
|
+
}
|
|
148
|
+
out[field] = String(value);
|
|
149
|
+
}
|
|
150
|
+
return out;
|
|
151
|
+
}
|
|
152
|
+
function clampTtl(ttl) {
|
|
153
|
+
const n = ttl === undefined ? exports.LOGIN_TOKEN_DEFAULT_TTL : Math.trunc(Number(ttl));
|
|
154
|
+
if (!Number.isFinite(n))
|
|
155
|
+
return exports.LOGIN_TOKEN_DEFAULT_TTL;
|
|
156
|
+
return Math.min(exports.LOGIN_TOKEN_MAX_TTL, Math.max(1, n));
|
|
157
|
+
}
|
|
158
|
+
function base64url(data) {
|
|
159
|
+
// Base64 pads with at most two '=': a bounded match keeps this linear on any input.
|
|
160
|
+
return (0, base64_1.toBase64)(data)
|
|
161
|
+
.replace(/\+/g, '-')
|
|
162
|
+
.replace(/\//g, '_')
|
|
163
|
+
.replace(/={1,2}$/, '');
|
|
164
|
+
}
|
|
165
|
+
function fromBase64url(str) {
|
|
166
|
+
const b64 = str.replace(/-/g, '+').replace(/_/g, '/');
|
|
167
|
+
return (0, base64_1.fromBase64)(b64 + '='.repeat((4 - (b64.length % 4)) % 4));
|
|
168
|
+
}
|
|
169
|
+
function bytesEqual(a, b) {
|
|
170
|
+
if (a.length !== b.length)
|
|
171
|
+
return false;
|
|
172
|
+
let diff = 0;
|
|
173
|
+
for (let i = 0; i < a.length; i++)
|
|
174
|
+
diff |= a[i] ^ b[i];
|
|
175
|
+
return diff === 0;
|
|
176
|
+
}
|
|
177
|
+
async function getSubtle() {
|
|
178
|
+
if (typeof globalThis.crypto !== 'undefined' && globalThis.crypto.subtle) {
|
|
179
|
+
return globalThis.crypto.subtle;
|
|
180
|
+
}
|
|
181
|
+
// Node.js < 19 may need webcrypto from crypto module
|
|
182
|
+
const nodeCrypto = await Promise.resolve().then(() => __importStar(require('crypto')));
|
|
183
|
+
return nodeCrypto.webcrypto.subtle;
|
|
184
|
+
}
|
|
185
|
+
async function sign(signingInput, signingSecret) {
|
|
186
|
+
const subtle = await getSubtle();
|
|
187
|
+
const key = await subtle.importKey('raw', fromBase64url(signingSecret), { name: 'HMAC', hash: 'SHA-256' }, false, ['sign']);
|
|
188
|
+
return new Uint8Array(await subtle.sign('HMAC', key, (0, bytes_1.encodeUTF8)(signingInput)));
|
|
189
|
+
}
|
|
190
|
+
//# sourceMappingURL=login-token.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"login-token.js","sourceRoot":"","sources":["../src/lib/login-token.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4DH,4CA4BC;AAOD,4CAWC;AAxGD,4CAA4C;AAC5C,wDAAgE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;QACzE,OAAO,UAAU,CAAC,MAAM,CAAC,MAAqC,CAAC;IACjE,CAAC;IACD,qDAAqD;IACrD,MAAM,UAAU,GAAG,wDAAa,QAAQ,GAAC,CAAC;IAC1C,OAAQ,UAAU,CAAC,SAAqD,CAAC,MAAM,CAAC;AAClF,CAAC;AAED,KAAK,UAAU,IAAI,CAAC,YAAoB,EAAE,aAAqB;IAC7D,MAAM,MAAM,GAAG,MAAM,SAAS,EAAE,CAAC;IACjC,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,SAAS,CAChC,KAAK,EACL,aAAa,CAAC,aAAa,CAAC,EAC5B,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,EACjC,KAAK,EACL,CAAC,MAAM,CAAC,CACT,CAAC;IACF,OAAO,IAAI,UAAU,CAAC,MAAM,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,IAAA,kBAAU,EAAC,YAAY,CAAC,CAAC,CAAC,CAAC;AAClF,CAAC"}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WebRTC login tokens minted locally, with no request to Telnyx.
|
|
3
|
+
*
|
|
4
|
+
* The token has the same shape as the one
|
|
5
|
+
* `POST /v2/telephony_credentials/{id}/token` returns, so it is used the same
|
|
6
|
+
* way: pass it to the WebRTC SDK as `login_token`. Telnyx verifies it on login.
|
|
7
|
+
* It is the same computation as `TelephonyCredential#to_jwt` in telnyx-ruby.
|
|
8
|
+
*
|
|
9
|
+
* The signing material comes from the credential: `token_material` is in the
|
|
10
|
+
* response of `POST /v2/telephony_credentials` and of
|
|
11
|
+
* `GET /v2/telephony_credentials/{id}/token_material`. It is as sensitive as
|
|
12
|
+
* the SIP password, so keep it on the server; never ship it to a browser.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* const { data: credential } = await client.telephonyCredentials.create({
|
|
16
|
+
* connection_id: '123',
|
|
17
|
+
* include: 'token_material', // the API returns the material only when asked
|
|
18
|
+
* });
|
|
19
|
+
* const loginToken = await client.telephonyCredentials.toJwt(credential); // 1 hour
|
|
20
|
+
* const shortLived = await client.telephonyCredentials.toJwt(credential, { ttl: 600 });
|
|
21
|
+
*
|
|
22
|
+
* To mint later with no request at all, store these with the user the credential
|
|
23
|
+
* belongs to, server side: `id`, `user_id`, `sip_username`, `expires_at` and
|
|
24
|
+
* `token_material`. The token is built from all of them.
|
|
25
|
+
*
|
|
26
|
+
* @example From stored values, without a request at all
|
|
27
|
+
* import { createLoginToken } from 'telnyx/lib/login-token';
|
|
28
|
+
* const loginToken = await createLoginToken({
|
|
29
|
+
* id: '...', user_id: '...', sip_username: 'gencred...', expires_at: '2027-01-01T00:00:00Z',
|
|
30
|
+
* token_material: { kid: 'v1', tel_token: '...', signing_secret: '...' },
|
|
31
|
+
* });
|
|
32
|
+
*/
|
|
33
|
+
import { TelnyxError } from "../core/error.mjs";
|
|
34
|
+
import { fromBase64, toBase64 } from "../internal/utils/base64.mjs";
|
|
35
|
+
import { decodeUTF8, encodeUTF8 } from "../internal/utils/bytes.mjs";
|
|
36
|
+
/** Token lifetime when `ttl` is not given: one hour. */
|
|
37
|
+
export const LOGIN_TOKEN_DEFAULT_TTL = 3600;
|
|
38
|
+
/** Longest lifetime a login token can have: one day, the same as API-minted tokens. */
|
|
39
|
+
export const LOGIN_TOKEN_MAX_TTL = 86400;
|
|
40
|
+
/** `cty` header of a locally minted token; voice-sdk-proxy selects the verification path by it. */
|
|
41
|
+
export const LOGIN_TOKEN_CONTENT_TYPE = 'telnyx-webrtc;v=1';
|
|
42
|
+
export class TelnyxLoginTokenError extends TelnyxError {
|
|
43
|
+
constructor(message) {
|
|
44
|
+
super(message);
|
|
45
|
+
this.name = 'TelnyxLoginTokenError';
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Mints a login token for `credential`, valid from `now` for `ttl` seconds.
|
|
50
|
+
* Pure computation: HMAC-SHA256 over the token with `token_material.signing_secret`.
|
|
51
|
+
*/
|
|
52
|
+
export async function createLoginToken(credential, options = {}) {
|
|
53
|
+
const credentialId = required(credential.id, 'id');
|
|
54
|
+
const userId = required(credential.user_id, 'user_id');
|
|
55
|
+
const identity = required(credential.sip_username, 'sip_username');
|
|
56
|
+
const material = normalizeMaterial(options.tokenMaterial ?? credential.token_material);
|
|
57
|
+
const ttl = clampTtl(options.ttl);
|
|
58
|
+
const now = options.now === undefined ? Date.now() : Number(options.now);
|
|
59
|
+
const iat = Math.floor(now / 1000);
|
|
60
|
+
// Same field order as the Ruby SDK, so the two produce the same bytes.
|
|
61
|
+
const header = { alg: 'HS256', typ: 'JWT', cty: LOGIN_TOKEN_CONTENT_TYPE, kid: material.kid };
|
|
62
|
+
const payload = {
|
|
63
|
+
sub: credentialId,
|
|
64
|
+
user_id: userId,
|
|
65
|
+
identity,
|
|
66
|
+
cred_exp: credential.expires_at ?? null,
|
|
67
|
+
tel_token: material.tel_token,
|
|
68
|
+
iat,
|
|
69
|
+
nbf: iat,
|
|
70
|
+
exp: iat + ttl,
|
|
71
|
+
jti: `${credentialId}-${iat}`,
|
|
72
|
+
};
|
|
73
|
+
const signingInput = `${base64url(JSON.stringify(header))}.${base64url(JSON.stringify(payload))}`;
|
|
74
|
+
return `${signingInput}.${base64url(await sign(signingInput, material.signing_secret))}`;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Checks a token minted by `createLoginToken` against `signingSecret` and
|
|
78
|
+
* returns its claims. For tests and debugging: Telnyx does the real
|
|
79
|
+
* verification on login.
|
|
80
|
+
*/
|
|
81
|
+
export async function decodeLoginToken(jwt, signingSecret) {
|
|
82
|
+
const [head, body, sig, ...rest] = String(jwt).split('.');
|
|
83
|
+
if (!head || !body || sig === undefined || rest.length) {
|
|
84
|
+
throw new TelnyxLoginTokenError('not a JWT');
|
|
85
|
+
}
|
|
86
|
+
const expected = await sign(`${head}.${body}`, signingSecret);
|
|
87
|
+
const given = fromBase64url(sig);
|
|
88
|
+
if (!bytesEqual(given, expected)) {
|
|
89
|
+
throw new TelnyxLoginTokenError('Signature is invalid and does not match the payload');
|
|
90
|
+
}
|
|
91
|
+
return JSON.parse(decodeUTF8(fromBase64url(body)));
|
|
92
|
+
}
|
|
93
|
+
function required(value, name) {
|
|
94
|
+
if (value === undefined || value === null || String(value) === '') {
|
|
95
|
+
throw new TelnyxLoginTokenError(`${name} is required to mint a token`);
|
|
96
|
+
}
|
|
97
|
+
return String(value);
|
|
98
|
+
}
|
|
99
|
+
function normalizeMaterial(material) {
|
|
100
|
+
if (!material || typeof material !== 'object') {
|
|
101
|
+
throw new TelnyxLoginTokenError('token_material is required to mint a token');
|
|
102
|
+
}
|
|
103
|
+
const out = {};
|
|
104
|
+
for (const field of ['kid', 'tel_token', 'signing_secret']) {
|
|
105
|
+
const value = material[field];
|
|
106
|
+
if (value === undefined || value === null || String(value) === '') {
|
|
107
|
+
throw new TelnyxLoginTokenError(`token_material.${field} is missing`);
|
|
108
|
+
}
|
|
109
|
+
out[field] = String(value);
|
|
110
|
+
}
|
|
111
|
+
return out;
|
|
112
|
+
}
|
|
113
|
+
function clampTtl(ttl) {
|
|
114
|
+
const n = ttl === undefined ? LOGIN_TOKEN_DEFAULT_TTL : Math.trunc(Number(ttl));
|
|
115
|
+
if (!Number.isFinite(n))
|
|
116
|
+
return LOGIN_TOKEN_DEFAULT_TTL;
|
|
117
|
+
return Math.min(LOGIN_TOKEN_MAX_TTL, Math.max(1, n));
|
|
118
|
+
}
|
|
119
|
+
function base64url(data) {
|
|
120
|
+
// Base64 pads with at most two '=': a bounded match keeps this linear on any input.
|
|
121
|
+
return toBase64(data)
|
|
122
|
+
.replace(/\+/g, '-')
|
|
123
|
+
.replace(/\//g, '_')
|
|
124
|
+
.replace(/={1,2}$/, '');
|
|
125
|
+
}
|
|
126
|
+
function fromBase64url(str) {
|
|
127
|
+
const b64 = str.replace(/-/g, '+').replace(/_/g, '/');
|
|
128
|
+
return fromBase64(b64 + '='.repeat((4 - (b64.length % 4)) % 4));
|
|
129
|
+
}
|
|
130
|
+
function bytesEqual(a, b) {
|
|
131
|
+
if (a.length !== b.length)
|
|
132
|
+
return false;
|
|
133
|
+
let diff = 0;
|
|
134
|
+
for (let i = 0; i < a.length; i++)
|
|
135
|
+
diff |= a[i] ^ b[i];
|
|
136
|
+
return diff === 0;
|
|
137
|
+
}
|
|
138
|
+
async function getSubtle() {
|
|
139
|
+
if (typeof globalThis.crypto !== 'undefined' && globalThis.crypto.subtle) {
|
|
140
|
+
return globalThis.crypto.subtle;
|
|
141
|
+
}
|
|
142
|
+
// Node.js < 19 may need webcrypto from crypto module
|
|
143
|
+
const nodeCrypto = await import('crypto');
|
|
144
|
+
return nodeCrypto.webcrypto.subtle;
|
|
145
|
+
}
|
|
146
|
+
async function sign(signingInput, signingSecret) {
|
|
147
|
+
const subtle = await getSubtle();
|
|
148
|
+
const key = await subtle.importKey('raw', fromBase64url(signingSecret), { name: 'HMAC', hash: 'SHA-256' }, false, ['sign']);
|
|
149
|
+
return new Uint8Array(await subtle.sign('HMAC', key, encodeUTF8(signingInput)));
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=login-token.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"login-token.mjs","sourceRoot":"","sources":["../src/lib/login-token.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAAE,WAAW,EAAE,0BAAsB;AAC5C,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,qCAAiC;AAChE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,oCAAgC;AAEjE,wDAAwD;AACxD,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,CAAC;AAC5C,uFAAuF;AACvF,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,CAAC;AACzC,mGAAmG;AACnG,MAAM,CAAC,MAAM,wBAAwB,GAAG,mBAAmB,CAAC;AAs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AClF,CAAC;AAED,KAAK,UAAU,IAAI,CAAC,YAAoB,EAAE,aAAqB;IAC7D,MAAM,MAAM,GAAG,MAAM,SAAS,EAAE,CAAC;IACjC,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,SAAS,CAChC,KAAK,EACL,aAAa,CAAC,aAAa,CAAC,EAC5B,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,EACjC,KAAK,EACL,CAAC,MAAM,CAAC,CACT,CAAC;IACF,OAAO,IAAI,UAAU,CAAC,MAAM,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;AAClF,CAAC"}
|
package/package.json
CHANGED
|
@@ -56,10 +56,7 @@ export interface ActionValidateResponse {
|
|
|
56
56
|
}
|
|
57
57
|
export declare namespace ActionValidateResponse {
|
|
58
58
|
interface Data {
|
|
59
|
-
|
|
60
|
-
* Indicates whether an address is valid or invalid.
|
|
61
|
-
*/
|
|
62
|
-
result: 'valid' | 'invalid';
|
|
59
|
+
result: 'valid';
|
|
63
60
|
/**
|
|
64
61
|
* Provides normalized address when available.
|
|
65
62
|
*/
|
|
@@ -80,6 +77,11 @@ export declare namespace ActionValidateResponse {
|
|
|
80
77
|
* the address.
|
|
81
78
|
*/
|
|
82
79
|
administrative_area?: string;
|
|
80
|
+
/**
|
|
81
|
+
* The borough of the address. This field is not used for addresses in the US but
|
|
82
|
+
* is used for some international addresses.
|
|
83
|
+
*/
|
|
84
|
+
borough?: string;
|
|
83
85
|
/**
|
|
84
86
|
* The two-character (ISO 3166-1 alpha-2) country code of the address.
|
|
85
87
|
*/
|
|
@@ -89,11 +91,24 @@ export declare namespace ActionValidateResponse {
|
|
|
89
91
|
* to, unit number or apartment number.
|
|
90
92
|
*/
|
|
91
93
|
extended_address?: string;
|
|
94
|
+
/**
|
|
95
|
+
* Latitude of the suggested address, when available.
|
|
96
|
+
*/
|
|
97
|
+
latitude?: number | null;
|
|
92
98
|
/**
|
|
93
99
|
* The locality of the address. For US addresses, this corresponds to the city of
|
|
94
100
|
* the address.
|
|
95
101
|
*/
|
|
96
102
|
locality?: string;
|
|
103
|
+
/**
|
|
104
|
+
* Longitude of the suggested address, when available.
|
|
105
|
+
*/
|
|
106
|
+
longitude?: number | null;
|
|
107
|
+
/**
|
|
108
|
+
* The neighborhood of the address. This field is not used for addresses in the US
|
|
109
|
+
* but is used for some international addresses.
|
|
110
|
+
*/
|
|
111
|
+
neighborhood?: string;
|
|
97
112
|
/**
|
|
98
113
|
* The postal code of the address.
|
|
99
114
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.d.mts","sourceRoot":"","sources":["../../src/resources/addresses/actions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,gCAA4B;AAClD,OAAO,KAAK,MAAM,sBAAkB;AACpC,OAAO,EAAE,UAAU,EAAE,mCAA+B;AACpD,OAAO,EAAE,cAAc,EAAE,2CAAuC;AAGhE;;GAEG;AACH,qBAAa,OAAQ,SAAQ,WAAW;IACtC;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,IAAI,EAAE,oBAAoB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,sBAAsB,CAAC;IAIlG;;;;;;;;;;;;;OAaG;IACH,iBAAiB,CACf,WAAW,EAAE,MAAM,EACnB,IAAI,GAAE,6BAA6B,GAAG,IAAI,GAAG,SAAc,EAC3D,OAAO,CAAC,EAAE,cAAc,GACvB,UAAU,CAAC,+BAA+B,CAAC;CAM/C;AAED,MAAM,WAAW,+BAA+B;IAC9C,IAAI,CAAC,EAAE,+BAA+B,CAAC,IAAI,CAAC;CAC7C;AAED,yBAAiB,+BAA+B,CAAC;IAC/C,UAAiB,IAAI;QACnB;;WAEG;QACH,EAAE,CAAC,EAAE,MAAM,CAAC;QAEZ;;WAEG;QACH,QAAQ,CAAC,EAAE,OAAO,CAAC;QAEnB,WA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