@sinch/functions-runtime 0.6.3 → 0.7.1
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/README.md +7 -7
- package/dist/bin/sinch-runtime.js +11 -3
- package/dist/bin/sinch-runtime.js.map +1 -1
- package/dist/{chunk-H2JZGXXT.js → chunk-5K5FDUEL.js} +1003 -192
- package/dist/chunk-5K5FDUEL.js.map +1 -0
- package/dist/index.d.ts +68 -2
- package/dist/index.js +13 -1
- package/dist/voice/v2.d.ts +5 -0
- package/dist/voice/v2.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-H2JZGXXT.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1977,12 +1977,15 @@ declare class PromptBuilder {
|
|
|
1977
1977
|
*
|
|
1978
1978
|
* @param text - Text to synthesise, or an SSML document when `format` is `SSML`
|
|
1979
1979
|
* @param options - Voice and format overrides
|
|
1980
|
+
* @throws If `text` is over 600 characters (prompts are never split), or the prompt would hold
|
|
1981
|
+
* more than 10 messages
|
|
1980
1982
|
*/
|
|
1981
1983
|
say(text: string, options?: SayOptions): this;
|
|
1982
1984
|
/**
|
|
1983
1985
|
* Play an audio file.
|
|
1984
1986
|
*
|
|
1985
1987
|
* @param url - Publicly reachable URL of the audio file
|
|
1988
|
+
* @throws If the prompt would hold more than 10 messages
|
|
1986
1989
|
*/
|
|
1987
1990
|
play(url: string): this;
|
|
1988
1991
|
/**
|
|
@@ -2006,12 +2009,14 @@ declare class MenuItemBuilder {
|
|
|
2006
2009
|
* Prompt played when the menu is entered.
|
|
2007
2010
|
*
|
|
2008
2011
|
* @param prompt - Plain text, a {@link PromptBuilder}, or a callback receiving one
|
|
2012
|
+
* @throws If any prompt text is over 600 characters, or a callback queues more than 10 messages
|
|
2009
2013
|
*/
|
|
2010
2014
|
prompt(prompt: PromptFlow): this;
|
|
2011
2015
|
/**
|
|
2012
2016
|
* Prompt played on each retry. Falls back to `prompt` when unset.
|
|
2013
2017
|
*
|
|
2014
2018
|
* @param prompt - Plain text, a {@link PromptBuilder}, or a callback receiving one
|
|
2019
|
+
* @throws If any prompt text is over 600 characters, or a callback queues more than 10 messages
|
|
2015
2020
|
*/
|
|
2016
2021
|
repeatPrompt(prompt: PromptFlow): this;
|
|
2017
2022
|
/**
|
|
@@ -2137,16 +2142,20 @@ export declare class CommandBuilder {
|
|
|
2137
2142
|
/** Set only on the builder `onCall` injects — see {@link FlowScope} */
|
|
2138
2143
|
private scope?;
|
|
2139
2144
|
/**
|
|
2140
|
-
* Speak text on the call.
|
|
2145
|
+
* Speak text on the call. `TEXT` over 600 characters is split between sentences into
|
|
2146
|
+
* consecutive messages.
|
|
2141
2147
|
*
|
|
2142
2148
|
* @param text - Text to synthesise, or an SSML document when `format` is `SSML`
|
|
2143
2149
|
* @param options - Voice and format overrides
|
|
2150
|
+
* @throws If a sentence, or any SSML document, is over 600 characters, or the pending
|
|
2151
|
+
* messages would pass 10 items
|
|
2144
2152
|
*/
|
|
2145
2153
|
say(text: string, options?: SayOptions): this;
|
|
2146
2154
|
/**
|
|
2147
2155
|
* Play an audio file on the call.
|
|
2148
2156
|
*
|
|
2149
2157
|
* @param url - Publicly reachable URL of the audio file
|
|
2158
|
+
* @throws If the pending messages would pass 10 items
|
|
2150
2159
|
*/
|
|
2151
2160
|
play(url: string): this;
|
|
2152
2161
|
/**
|
|
@@ -4638,7 +4647,8 @@ export interface AgentStreamEndpointOptions {
|
|
|
4638
4647
|
export declare function buildAgentStreamEndpoint(options: AgentStreamEndpointOptions): AgentStreamEndpoint;
|
|
4639
4648
|
/**
|
|
4640
4649
|
* Install `context.voice` on a context object, in place — and the `UniversalConfig` methods on
|
|
4641
|
-
* `context.config` (see `attachConfigAccessors`).
|
|
4650
|
+
* `context.config` (see `attachConfigAccessors`). First hides the context's credentials from
|
|
4651
|
+
* serialisation and logging (see `protectContext`).
|
|
4642
4652
|
*
|
|
4643
4653
|
* @param context - Context under construction, without its `voice` member
|
|
4644
4654
|
* @param v1 - The v1 SDK client to expose as `context.voice.v1`, if credentials produced one
|
|
@@ -5624,6 +5634,62 @@ export declare function sessionCookieHeader(user: string, password: string): str
|
|
|
5624
5634
|
export declare function clearedSessionCookieHeader(): string;
|
|
5625
5635
|
/** Whether the `Cookie` header carries a valid session for this credential pair. */
|
|
5626
5636
|
export declare function hasValidSessionCookie(cookieHeader: string | undefined, user: string, password: string): boolean;
|
|
5637
|
+
/**
|
|
5638
|
+
* Set the credential values to redact, from `env`. Call it once the environment is final, and
|
|
5639
|
+
* again whenever a credential in it changes. Calling it with no credentials (`{}`) turns
|
|
5640
|
+
* redaction off.
|
|
5641
|
+
*
|
|
5642
|
+
* Has no other effect: stdout and stderr are redacted only after {@link installStdioRedaction}.
|
|
5643
|
+
*
|
|
5644
|
+
* @param env - The environment, normally `process.env`
|
|
5645
|
+
*/
|
|
5646
|
+
export declare function configureSecretRedaction(env: Record<string, string | undefined>): void;
|
|
5647
|
+
/**
|
|
5648
|
+
* Replace every credential value in `text` with {@link REDACTED}. Overlapping or adjacent values
|
|
5649
|
+
* become one marker, so no fragment of either is left.
|
|
5650
|
+
*
|
|
5651
|
+
* Returns `text` itself when nothing matched, or before {@link configureSecretRedaction}.
|
|
5652
|
+
*
|
|
5653
|
+
* @param text - Any text about to leave the process
|
|
5654
|
+
*/
|
|
5655
|
+
export declare function redactSecrets(text: string): string;
|
|
5656
|
+
/**
|
|
5657
|
+
* Redact a value the runtime writes out as text, whatever its type. A string goes through
|
|
5658
|
+
* {@link redactSecrets}. Anything else, such as an object a handler threw as an error's message,
|
|
5659
|
+
* is redacted as its JSON, or as `String(value)` when it has none (circular, a symbol), so it
|
|
5660
|
+
* cannot pass through unredacted. `undefined` and `null` hold nothing and are returned as given.
|
|
5661
|
+
*
|
|
5662
|
+
* @param value - Any value about to be written into a response body or a log record
|
|
5663
|
+
* @returns The redacted text, or `value` when it is `undefined` or `null`
|
|
5664
|
+
*/
|
|
5665
|
+
export declare function redactAsText(value: unknown): string | null | undefined;
|
|
5666
|
+
/**
|
|
5667
|
+
* How many bytes past a cut point {@link safeCut} needs to see. 0 before
|
|
5668
|
+
* {@link configureSecretRedaction}.
|
|
5669
|
+
*/
|
|
5670
|
+
export declare function secretLookaheadBytes(): number;
|
|
5671
|
+
/**
|
|
5672
|
+
* Shorten `prefix` so that no credential value is cut in half at its end.
|
|
5673
|
+
*
|
|
5674
|
+
* Text cut to a size limit can end partway through a value, and the half left behind no longer
|
|
5675
|
+
* matches it, so {@link redactSecrets} would let it through. This moves the cut back to the start
|
|
5676
|
+
* of the value that crosses it, or of the run of overlapping values it belongs to. A value that
|
|
5677
|
+
* ends exactly at the cut is left for {@link redactSecrets}.
|
|
5678
|
+
*
|
|
5679
|
+
* @param prefix - The text up to the cut
|
|
5680
|
+
* @param continuation - The text right after the cut, at least {@link secretLookaheadBytes} long
|
|
5681
|
+
* when that much exists
|
|
5682
|
+
* @returns `prefix`, or a shorter start of it
|
|
5683
|
+
*/
|
|
5684
|
+
export declare function safeCut(prefix: string, continuation: string): string;
|
|
5685
|
+
/**
|
|
5686
|
+
* Redact the process's stdout and stderr. `console` writes through them, so this covers every
|
|
5687
|
+
* console method, `%o`, stack traces and the runtime's own debug output.
|
|
5688
|
+
*
|
|
5689
|
+
* Not covered: writes that bypass `stream.write` (`fs.writeSync(1, ...)`, a child process with
|
|
5690
|
+
* inherited stdio, Node's own print of an uncaught exception), and a value split across two writes.
|
|
5691
|
+
*/
|
|
5692
|
+
export declare function installStdioRedaction(): void;
|
|
5627
5693
|
/**
|
|
5628
5694
|
* Converts a phone number to local/national format.
|
|
5629
5695
|
*
|
package/dist/index.js
CHANGED
|
@@ -43,6 +43,7 @@ import {
|
|
|
43
43
|
clearedSessionCookieHeader,
|
|
44
44
|
collectCredentials,
|
|
45
45
|
commands,
|
|
46
|
+
configureSecretRedaction,
|
|
46
47
|
connectAgent,
|
|
47
48
|
createAceBuilder,
|
|
48
49
|
createApp,
|
|
@@ -101,6 +102,7 @@ import {
|
|
|
101
102
|
handleVoiceV1Callback,
|
|
102
103
|
handleVoiceWebhook,
|
|
103
104
|
hasValidSessionCookie,
|
|
105
|
+
installStdioRedaction,
|
|
104
106
|
installWebSocketHandlers,
|
|
105
107
|
isBrowserNavigation,
|
|
106
108
|
isGated,
|
|
@@ -115,10 +117,14 @@ import {
|
|
|
115
117
|
onCall,
|
|
116
118
|
parseJson,
|
|
117
119
|
realtimeAgent,
|
|
120
|
+
redactAsText,
|
|
121
|
+
redactSecrets,
|
|
118
122
|
renderLoginPage,
|
|
119
123
|
resetSinchClients,
|
|
120
124
|
resetVoiceSignatureWarning,
|
|
121
125
|
resolveAgentStreamUrl,
|
|
126
|
+
safeCut,
|
|
127
|
+
secretLookaheadBytes,
|
|
122
128
|
secretsLoader,
|
|
123
129
|
sendAuthChallenge,
|
|
124
130
|
sessionCookieHeader,
|
|
@@ -137,7 +143,7 @@ import {
|
|
|
137
143
|
validateVoiceV1Request,
|
|
138
144
|
verifyVoiceWebhook,
|
|
139
145
|
voiceRelay
|
|
140
|
-
} from "./chunk-
|
|
146
|
+
} from "./chunk-5K5FDUEL.js";
|
|
141
147
|
export {
|
|
142
148
|
AGENT_HEADER_TOKEN,
|
|
143
149
|
AGENT_STREAM_PATH,
|
|
@@ -179,6 +185,7 @@ export {
|
|
|
179
185
|
clearedSessionCookieHeader,
|
|
180
186
|
collectCredentials,
|
|
181
187
|
commands,
|
|
188
|
+
configureSecretRedaction,
|
|
182
189
|
connectAgent,
|
|
183
190
|
toCamelCase as convertToCamelCase,
|
|
184
191
|
createAceBuilder,
|
|
@@ -239,6 +246,7 @@ export {
|
|
|
239
246
|
handleVoiceV1Callback,
|
|
240
247
|
handleVoiceWebhook,
|
|
241
248
|
hasValidSessionCookie,
|
|
249
|
+
installStdioRedaction,
|
|
242
250
|
installWebSocketHandlers,
|
|
243
251
|
isBrowserNavigation,
|
|
244
252
|
isGated,
|
|
@@ -254,10 +262,14 @@ export {
|
|
|
254
262
|
parseJson,
|
|
255
263
|
parseJson as parseJsonLenient,
|
|
256
264
|
realtimeAgent,
|
|
265
|
+
redactAsText,
|
|
266
|
+
redactSecrets,
|
|
257
267
|
renderLoginPage,
|
|
258
268
|
resetSinchClients,
|
|
259
269
|
resetVoiceSignatureWarning,
|
|
260
270
|
resolveAgentStreamUrl,
|
|
271
|
+
safeCut,
|
|
272
|
+
secretLookaheadBytes,
|
|
261
273
|
secretsLoader,
|
|
262
274
|
sendAuthChallenge,
|
|
263
275
|
sessionCookieHeader,
|
package/dist/voice/v2.d.ts
CHANGED
|
@@ -1053,12 +1053,15 @@ export declare class PromptBuilder {
|
|
|
1053
1053
|
*
|
|
1054
1054
|
* @param text - Text to synthesise, or an SSML document when `format` is `SSML`
|
|
1055
1055
|
* @param options - Voice and format overrides
|
|
1056
|
+
* @throws If `text` is over 600 characters (prompts are never split), or the prompt would hold
|
|
1057
|
+
* more than 10 messages
|
|
1056
1058
|
*/
|
|
1057
1059
|
say(text: string, options?: SayOptions): this;
|
|
1058
1060
|
/**
|
|
1059
1061
|
* Play an audio file.
|
|
1060
1062
|
*
|
|
1061
1063
|
* @param url - Publicly reachable URL of the audio file
|
|
1064
|
+
* @throws If the prompt would hold more than 10 messages
|
|
1062
1065
|
*/
|
|
1063
1066
|
play(url: string): this;
|
|
1064
1067
|
/**
|
|
@@ -1088,12 +1091,14 @@ export declare class MenuItemBuilder {
|
|
|
1088
1091
|
* Prompt played when the menu is entered.
|
|
1089
1092
|
*
|
|
1090
1093
|
* @param prompt - Plain text, a {@link PromptBuilder}, or a callback receiving one
|
|
1094
|
+
* @throws If any prompt text is over 600 characters, or a callback queues more than 10 messages
|
|
1091
1095
|
*/
|
|
1092
1096
|
prompt(prompt: PromptFlow): this;
|
|
1093
1097
|
/**
|
|
1094
1098
|
* Prompt played on each retry. Falls back to `prompt` when unset.
|
|
1095
1099
|
*
|
|
1096
1100
|
* @param prompt - Plain text, a {@link PromptBuilder}, or a callback receiving one
|
|
1101
|
+
* @throws If any prompt text is over 600 characters, or a callback queues more than 10 messages
|
|
1097
1102
|
*/
|
|
1098
1103
|
repeatPrompt(prompt: PromptFlow): this;
|
|
1099
1104
|
/**
|
package/dist/voice/v2.js
CHANGED
package/package.json
CHANGED