@zyphr-dev/node-sdk 0.1.10 → 0.1.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zyphr-dev/node-sdk",
3
- "version": "0.1.10",
3
+ "version": "0.1.12",
4
4
  "description": "Official Zyphr SDK for Node.js, React, and React Native",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
package/src/client.ts CHANGED
@@ -50,6 +50,10 @@ export interface ZyphrOptions {
50
50
  apiKey: string;
51
51
  /** Override the base API URL (defaults to https://api.zyphr.dev/v1) */
52
52
  baseUrl?: string;
53
+ /** Application public key (za_pub_*) for Auth-as-a-Service endpoints */
54
+ applicationKey?: string;
55
+ /** Application secret key (za_sec_*) for Auth-as-a-Service endpoints */
56
+ applicationSecret?: string;
53
57
  }
54
58
 
55
59
  /**
@@ -102,7 +106,12 @@ export class Zyphr {
102
106
  constructor(options: ZyphrOptions) {
103
107
  const config = new Configuration({
104
108
  basePath: options.baseUrl,
105
- apiKey: () => options.apiKey,
109
+ apiKey: (name: string) => {
110
+ // Route application credential headers to the right keys
111
+ if (name === 'X-Application-Key' && options.applicationKey) return options.applicationKey;
112
+ if (name === 'X-Application-Secret' && options.applicationSecret) return options.applicationSecret;
113
+ return options.apiKey;
114
+ },
106
115
  middleware: [errorMiddleware],
107
116
  });
108
117