@zyphr-dev/node-sdk 0.1.14 → 0.1.16

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.14",
3
+ "version": "0.1.16",
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
@@ -103,7 +103,10 @@ export class Zyphr {
103
103
  readonly webauthn: AuthWebAuthnApi;
104
104
  };
105
105
 
106
+ private readonly options: ZyphrOptions;
107
+
106
108
  constructor(options: ZyphrOptions) {
109
+ this.options = options;
107
110
  const config = new Configuration({
108
111
  basePath: options.baseUrl,
109
112
  apiKey: (name: string) => {
@@ -154,6 +157,9 @@ export class Zyphr {
154
157
  * Use this when calling profile, session, or MFA endpoints that
155
158
  * require the end user's access token instead of the API key.
156
159
  *
160
+ * Includes both the end-user Bearer token and the application
161
+ * public key (X-Application-Key) required by user-scoped endpoints.
162
+ *
157
163
  * @example
158
164
  * ```ts
159
165
  * const login = await zyphr.auth.login.loginEndUser({ ... });
@@ -165,8 +171,12 @@ export class Zyphr {
165
171
  * ```
166
172
  */
167
173
  asEndUser(accessToken: string): RequestInit {
168
- return {
169
- headers: { Authorization: `Bearer ${accessToken}` },
174
+ const headers: Record<string, string> = {
175
+ Authorization: `Bearer ${accessToken}`,
170
176
  };
177
+ if (this.options.applicationKey) {
178
+ headers['X-Application-Key'] = this.options.applicationKey;
179
+ }
180
+ return { headers };
171
181
  }
172
182
  }