@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/dist/index.cjs +11 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +11 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +12 -2
package/package.json
CHANGED
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
|
-
|
|
169
|
-
|
|
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
|
}
|