@notificationapi/node 0.0.2-alpha.7 → 0.0.2-alpha.8

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.
@@ -12,6 +12,7 @@ import { HealthApi } from '../generated/src';
12
12
  import { InsightsApi } from '../generated/src';
13
13
  import { KeysApi } from '../generated/src';
14
14
  import { LogsApi } from '../generated/src';
15
+ import { MembersApi } from '../generated/src';
15
16
  import { SenderApi } from '../generated/src';
16
17
  import { TemplatesApi } from '../generated/src';
17
18
  import { TypesApi } from '../generated/src';
@@ -39,7 +40,20 @@ export interface NotificationAPIClientConfig {
39
40
  */
40
41
  baseUrl?: string;
41
42
  /**
42
- * API Key - Secret key (pingram_sk_...) for server-side authentication
43
+ * API Key or JWT Token - Required. Can be either:
44
+ * - A string starting with 'pingram_sk_' for server-side API key authentication
45
+ * - A JWT token string (any other string) for JWT authentication
46
+ *
47
+ * @example
48
+ * // API Key authentication
49
+ * const client = new NotificationAPIClient({
50
+ * apiKey: 'pingram_sk_...'
51
+ * });
52
+ *
53
+ * // JWT token authentication
54
+ * const client = new NotificationAPIClient({
55
+ * apiKey: 'eyJraWQiOiJJM0tuNitTVnp5K0lzam9TeXVvYlJKcFpCcDd...'
56
+ * });
43
57
  */
44
58
  apiKey: string;
45
59
  /**
@@ -93,6 +107,7 @@ export declare class NotificationAPIClient {
93
107
  insights: InsightsApi;
94
108
  keys: KeysApi;
95
109
  logs: LogsApi;
110
+ members: MembersApi;
96
111
  sender: SenderApi;
97
112
  templates: TemplatesApi;
98
113
  types: TypesApi;
@@ -30,6 +30,7 @@ const src_13 = require("../generated/src");
30
30
  const src_14 = require("../generated/src");
31
31
  const src_15 = require("../generated/src");
32
32
  const src_16 = require("../generated/src");
33
+ const src_17 = require("../generated/src");
33
34
  const testing_1 = require("./testing");
34
35
  /**
35
36
  * Get the base URL for a given region
@@ -83,21 +84,26 @@ class NotificationAPIClient {
83
84
  constructor(config) {
84
85
  // Use explicit baseUrl if provided, otherwise derive from region
85
86
  const baseUrl = config.baseUrl || getRegionBaseUrl(config.region);
86
- // Build the authorization header
87
- const authHeader = buildAuthorizationHeader(config.apiKey);
87
+ // Validate that apiKey is provided
88
+ if (!config.apiKey) {
89
+ throw new Error('apiKey must be provided in NotificationAPIClientConfig');
90
+ }
88
91
  // Auto-detect: if mock is set, use it!
89
92
  let fetchApi = config.fetchApi;
90
93
  if (!fetchApi && (0, testing_1.hasMock)()) {
91
94
  fetchApi = (0, testing_1.createMockFetch)();
92
95
  }
96
+ // Build headers
97
+ // Both API keys and JWT tokens use the same Bearer token format
98
+ const headers = {
99
+ 'Content-Type': 'application/json',
100
+ 'User-Agent': USER_AGENT,
101
+ Authorization: buildAuthorizationHeader(config.apiKey),
102
+ ...config.headers
103
+ };
93
104
  this.config = new src_1.Configuration({
94
105
  basePath: baseUrl,
95
- headers: {
96
- Authorization: authHeader,
97
- 'Content-Type': 'application/json',
98
- 'User-Agent': USER_AGENT,
99
- ...config.headers
100
- },
106
+ headers,
101
107
  fetchApi: fetchApi
102
108
  });
103
109
  this.account = new src_2.AccountApi(this.config);
@@ -109,12 +115,13 @@ class NotificationAPIClient {
109
115
  this.insights = new src_8.InsightsApi(this.config);
110
116
  this.keys = new src_9.KeysApi(this.config);
111
117
  this.logs = new src_10.LogsApi(this.config);
112
- this.sender = new src_11.SenderApi(this.config);
113
- this.templates = new src_12.TemplatesApi(this.config);
114
- this.types = new src_13.TypesApi(this.config);
115
- this.user = new src_14.UserApi(this.config);
116
- this.users = new src_15.UsersApi(this.config);
117
- this.defaultApi = new src_16.DefaultApi(this.config);
118
+ this.members = new src_11.MembersApi(this.config);
119
+ this.sender = new src_12.SenderApi(this.config);
120
+ this.templates = new src_13.TemplatesApi(this.config);
121
+ this.types = new src_14.TypesApi(this.config);
122
+ this.user = new src_15.UserApi(this.config);
123
+ this.users = new src_16.UsersApi(this.config);
124
+ this.defaultApi = new src_17.DefaultApi(this.config);
118
125
  }
119
126
  /**
120
127
  * Update the base URL (overrides region)
@@ -133,12 +140,13 @@ class NotificationAPIClient {
133
140
  this.insights = new src_8.InsightsApi(this.config);
134
141
  this.keys = new src_9.KeysApi(this.config);
135
142
  this.logs = new src_10.LogsApi(this.config);
136
- this.sender = new src_11.SenderApi(this.config);
137
- this.templates = new src_12.TemplatesApi(this.config);
138
- this.types = new src_13.TypesApi(this.config);
139
- this.user = new src_14.UserApi(this.config);
140
- this.users = new src_15.UsersApi(this.config);
141
- this.defaultApi = new src_16.DefaultApi(this.config);
143
+ this.members = new src_11.MembersApi(this.config);
144
+ this.sender = new src_12.SenderApi(this.config);
145
+ this.templates = new src_13.TemplatesApi(this.config);
146
+ this.types = new src_14.TypesApi(this.config);
147
+ this.user = new src_15.UserApi(this.config);
148
+ this.users = new src_16.UsersApi(this.config);
149
+ this.defaultApi = new src_17.DefaultApi(this.config);
142
150
  }
143
151
  /**
144
152
  * send
@@ -114,7 +114,9 @@ function createMockFetch() {
114
114
  });
115
115
  }
116
116
  catch (error) {
117
- return new Response(JSON.stringify({ error: error.message }), {
117
+ // Pass through the full error body if available, otherwise create one from message
118
+ const errorBody = error.body || { error: error.message };
119
+ return new Response(JSON.stringify(errorBody), {
118
120
  status: error.statusCode || 500,
119
121
  headers: { 'Content-Type': 'application/json' }
120
122
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@notificationapi/node",
3
- "version": "0.0.2-alpha.7",
3
+ "version": "0.0.2-alpha.8",
4
4
  "description": "Official Node.js SDK for NotificationAPI - Send notifications via Email, SMS, Push, In-App, and more",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",