@zyphr-dev/node-sdk 0.1.9 → 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.9",
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",
@@ -119,6 +119,7 @@ src/models/MagicLinkVerifyResponseData.ts
119
119
  src/models/MarkAllInboxReadRequest.ts
120
120
  src/models/MarkAllReadData.ts
121
121
  src/models/MarkAllReadResponse.ts
122
+ src/models/MarkAllSubscriberNotificationsReadRequest.ts
122
123
  src/models/MarkInboxReadRequest.ts
123
124
  src/models/MfaBackupCodesResponse.ts
124
125
  src/models/MfaBackupCodesResponseData.ts
@@ -284,6 +285,8 @@ src/models/UnsubscribeRequest.ts
284
285
  src/models/UnsubscribeResponse.ts
285
286
  src/models/UpdateCategoryRequest.ts
286
287
  src/models/UpdateEndUserRequest.ts
288
+ src/models/UpdateSubscriberPreferencesRequest.ts
289
+ src/models/UpdateSubscriberPreferencesRequestPreferencesInner.ts
287
290
  src/models/UpdateSubscriberRequest.ts
288
291
  src/models/UpdateTemplateRequest.ts
289
292
  src/models/UpdateTopicRequest.ts
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