@zyphr-dev/node-sdk 0.1.12 → 0.1.14

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.12",
3
+ "version": "0.1.14",
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
@@ -148,4 +148,25 @@ export class Zyphr {
148
148
  webauthn: new AuthWebAuthnApi(config),
149
149
  };
150
150
  }
151
+
152
+ /**
153
+ * Create request overrides that authenticate as an end user.
154
+ * Use this when calling profile, session, or MFA endpoints that
155
+ * require the end user's access token instead of the API key.
156
+ *
157
+ * @example
158
+ * ```ts
159
+ * const login = await zyphr.auth.login.loginEndUser({ ... });
160
+ * const token = login.data.tokens.access_token;
161
+ *
162
+ * const profile = await zyphr.auth.profile.getEndUser(
163
+ * zyphr.asEndUser(token)
164
+ * );
165
+ * ```
166
+ */
167
+ asEndUser(accessToken: string): RequestInit {
168
+ return {
169
+ headers: { Authorization: `Bearer ${accessToken}` },
170
+ };
171
+ }
151
172
  }