@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/dist/index.d.ts CHANGED
@@ -2534,6 +2534,26 @@ export declare class DefaultEndpointHandler {
2534
2534
  * TypeScript projects compile to dist/function.js
2535
2535
  */
2536
2536
  export declare function findFunctionPath(): string;
2537
+ /** ICE callback payload as delivered to your handler (`callid` normalized to `callId`). */
2538
+ export type IceCallback = Omit<Voice.IceRequest, "callid"> & {
2539
+ callId?: string;
2540
+ };
2541
+ /** ACE callback payload as delivered to your handler. */
2542
+ export type AceCallback = Omit<Voice.AceRequest, "callid"> & {
2543
+ callId?: string;
2544
+ };
2545
+ /** PIE callback payload as delivered to your handler. */
2546
+ export type PieCallback = Omit<Voice.PieRequest, "callid"> & {
2547
+ callId?: string;
2548
+ };
2549
+ /** DICE callback payload as delivered to your handler. */
2550
+ export type DiceCallback = Omit<Voice.DiceRequest, "callid"> & {
2551
+ callId?: string;
2552
+ };
2553
+ /** NOTIFY callback payload as delivered to your handler. */
2554
+ export type NotifyCallback = Omit<Voice.NotifyRequest, "callid"> & {
2555
+ callId?: string;
2556
+ };
2537
2557
  /** @deprecated Import from '@sinch/voice' instead: `import type { Voice } from '@sinch/voice'` then use `Voice.IceRequest` @internal */
2538
2558
  export type IceCallbackData = Voice.IceRequest;
2539
2559
  /** @deprecated Import from '@sinch/voice' instead @internal */
@@ -2711,7 +2731,7 @@ export declare class SecretsLoader {
2711
2731
  private platformHint;
2712
2732
  private warnPlaintext;
2713
2733
  /**
2714
- * Load custom secrets added via 'sinch functions secrets' command
2734
+ * Load custom secrets added via the 'sinch secrets' command
2715
2735
  */
2716
2736
  loadCustomSecrets(secretNames?: string[]): Promise<Record<string, string>>;
2717
2737
  /**
package/dist/index.js CHANGED
@@ -3603,22 +3603,13 @@ var SecretsLoader = class {
3603
3603
  secretsLoaded++;
3604
3604
  }
3605
3605
  }
3606
- const functionName = this.getFunctionNameFromConfig();
3607
- for (const secretName of secretsToLoad) {
3608
- if (secretName === "PROJECT_ID_API_SECRET" || secretName === "VOICE_APPLICATION_SECRET") {
3609
- continue;
3610
- }
3611
- if (functionName) {
3612
- const value = await getPassword(
3613
- this.SERVICE_NAME,
3614
- `${functionName}-${secretName}`
3615
- );
3616
- if (value) {
3617
- process.env[secretName] = value;
3618
- console.log(`\u2705 Loaded ${secretName} from secure storage`);
3619
- secretsLoaded++;
3620
- }
3621
- }
3606
+ const customSecretNames = secretsToLoad.filter(
3607
+ (secretName) => secretName !== "PROJECT_ID_API_SECRET" && secretName !== "VOICE_APPLICATION_SECRET"
3608
+ );
3609
+ const customSecrets = await this.loadCustomSecrets(customSecretNames);
3610
+ for (const secretName of Object.keys(customSecrets)) {
3611
+ console.log(`\u2705 Loaded ${secretName} from secure storage`);
3612
+ secretsLoaded++;
3622
3613
  }
3623
3614
  if (secretsLoaded === 0) {
3624
3615
  const probe = await this.probeKeychain();
@@ -3752,18 +3743,17 @@ var SecretsLoader = class {
3752
3743
  console.warn(` ${this.platformHint()}`);
3753
3744
  }
3754
3745
  /**
3755
- * Load custom secrets added via 'sinch functions secrets' command
3746
+ * Load custom secrets added via the 'sinch secrets' command
3756
3747
  */
3757
3748
  async loadCustomSecrets(secretNames = []) {
3758
3749
  const secrets = {};
3750
+ if (process.env.NODE_ENV === "production") {
3751
+ return secrets;
3752
+ }
3759
3753
  try {
3760
3754
  const functionName = this.getFunctionNameFromConfig();
3761
- if (!functionName) {
3762
- console.debug("[Secrets] Could not determine function name for custom secrets");
3763
- return secrets;
3764
- }
3765
3755
  for (const secretName of secretNames) {
3766
- const value = await getPassword(this.SERVICE_NAME, `${functionName}-${secretName}`);
3756
+ const value = functionName && await getPassword(this.SERVICE_NAME, `${functionName}-${secretName}`) || await getPassword(this.SERVICE_NAME, `custom-${secretName}`);
3767
3757
  if (value) {
3768
3758
  secrets[secretName] = value;
3769
3759
  process.env[secretName] = value;