@sinch/functions-runtime 0.4.19 → 0.5.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/README.md +6 -2
- package/dist/bin/sinch-runtime.js +12 -22
- package/dist/bin/sinch-runtime.js.map +1 -1
- package/dist/index.d.ts +21 -1
- package/dist/index.js +12 -22
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -134,16 +134,20 @@ export async function ice(context, event) {
|
|
|
134
134
|
| `dice` | Disconnected Call Event - call ended | None |
|
|
135
135
|
| `notify` | Notification events | None |
|
|
136
136
|
|
|
137
|
+
`ace`, `pie`, `dice`, and `notify` are optional — the platform may call them even if your function doesn't implement a handler, and the runtime returns `200` for those unimplemented callbacks (only `ice` is required).
|
|
138
|
+
|
|
139
|
+
Type callback data with `IceCallback` / `AceCallback` / `PieCallback` / `DiceCallback` / `NotifyCallback` — these match what your handler receives (the runtime delivers `callId`, not the raw API's `callid`).
|
|
140
|
+
|
|
137
141
|
## TypeScript Support
|
|
138
142
|
|
|
139
143
|
Full TypeScript support with comprehensive types:
|
|
140
144
|
|
|
141
145
|
```typescript
|
|
142
|
-
import type { FunctionContext,
|
|
146
|
+
import type { FunctionContext, IceCallback, SvamletResponse } from '@sinch/functions-runtime';
|
|
143
147
|
|
|
144
148
|
export async function ice(
|
|
145
149
|
context: FunctionContext,
|
|
146
|
-
event:
|
|
150
|
+
event: IceCallback
|
|
147
151
|
): Promise<SvamletResponse> {
|
|
148
152
|
// Full type safety and IntelliSense!
|
|
149
153
|
}
|
|
@@ -1351,22 +1351,13 @@ var SecretsLoader = class {
|
|
|
1351
1351
|
secretsLoaded++;
|
|
1352
1352
|
}
|
|
1353
1353
|
}
|
|
1354
|
-
const
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
this.SERVICE_NAME,
|
|
1362
|
-
`${functionName}-${secretName}`
|
|
1363
|
-
);
|
|
1364
|
-
if (value) {
|
|
1365
|
-
process.env[secretName] = value;
|
|
1366
|
-
console.log(`\u2705 Loaded ${secretName} from secure storage`);
|
|
1367
|
-
secretsLoaded++;
|
|
1368
|
-
}
|
|
1369
|
-
}
|
|
1354
|
+
const customSecretNames = secretsToLoad.filter(
|
|
1355
|
+
(secretName) => secretName !== "PROJECT_ID_API_SECRET" && secretName !== "VOICE_APPLICATION_SECRET"
|
|
1356
|
+
);
|
|
1357
|
+
const customSecrets = await this.loadCustomSecrets(customSecretNames);
|
|
1358
|
+
for (const secretName of Object.keys(customSecrets)) {
|
|
1359
|
+
console.log(`\u2705 Loaded ${secretName} from secure storage`);
|
|
1360
|
+
secretsLoaded++;
|
|
1370
1361
|
}
|
|
1371
1362
|
if (secretsLoaded === 0) {
|
|
1372
1363
|
const probe = await this.probeKeychain();
|
|
@@ -1500,18 +1491,17 @@ var SecretsLoader = class {
|
|
|
1500
1491
|
console.warn(` ${this.platformHint()}`);
|
|
1501
1492
|
}
|
|
1502
1493
|
/**
|
|
1503
|
-
* Load custom secrets added via 'sinch
|
|
1494
|
+
* Load custom secrets added via the 'sinch secrets' command
|
|
1504
1495
|
*/
|
|
1505
1496
|
async loadCustomSecrets(secretNames = []) {
|
|
1506
1497
|
const secrets = {};
|
|
1498
|
+
if (process.env.NODE_ENV === "production") {
|
|
1499
|
+
return secrets;
|
|
1500
|
+
}
|
|
1507
1501
|
try {
|
|
1508
1502
|
const functionName = this.getFunctionNameFromConfig();
|
|
1509
|
-
if (!functionName) {
|
|
1510
|
-
console.debug("[Secrets] Could not determine function name for custom secrets");
|
|
1511
|
-
return secrets;
|
|
1512
|
-
}
|
|
1513
1503
|
for (const secretName of secretNames) {
|
|
1514
|
-
const value = await getPassword(this.SERVICE_NAME, `${functionName}-${secretName}`);
|
|
1504
|
+
const value = functionName && await getPassword(this.SERVICE_NAME, `${functionName}-${secretName}`) || await getPassword(this.SERVICE_NAME, `custom-${secretName}`);
|
|
1515
1505
|
if (value) {
|
|
1516
1506
|
secrets[secretName] = value;
|
|
1517
1507
|
process.env[secretName] = value;
|