@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/README.md +10 -3
- package/dist/index.cjs +20 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +16 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +21 -0
package/README.md
CHANGED
|
@@ -412,10 +412,17 @@ const session = await zyphr.auth.login.loginEndUser({
|
|
|
412
412
|
});
|
|
413
413
|
|
|
414
414
|
// User profile (requires end-user access token)
|
|
415
|
-
|
|
416
|
-
await zyphr.auth.
|
|
417
|
-
|
|
415
|
+
// Use zyphr.asEndUser(token) to authenticate as the end user
|
|
416
|
+
const login = await zyphr.auth.login.loginEndUser({
|
|
417
|
+
loginRequest: { email: 'user@example.com', password: 'SecureP@ss123' },
|
|
418
418
|
});
|
|
419
|
+
const token = login.data.tokens.access_token;
|
|
420
|
+
|
|
421
|
+
const profile = await zyphr.auth.profile.getEndUser(zyphr.asEndUser(token));
|
|
422
|
+
await zyphr.auth.profile.updateEndUser(
|
|
423
|
+
{ updateEndUserRequest: { name: 'Updated Name' } },
|
|
424
|
+
zyphr.asEndUser(token),
|
|
425
|
+
);
|
|
419
426
|
|
|
420
427
|
// Email verification
|
|
421
428
|
await zyphr.auth.emailVerification.sendVerification('user@example.com');
|
package/dist/index.cjs
CHANGED
|
@@ -19716,6 +19716,26 @@ var Zyphr = class {
|
|
|
19716
19716
|
webauthn: new AuthWebAuthnApi(config)
|
|
19717
19717
|
};
|
|
19718
19718
|
}
|
|
19719
|
+
/**
|
|
19720
|
+
* Create request overrides that authenticate as an end user.
|
|
19721
|
+
* Use this when calling profile, session, or MFA endpoints that
|
|
19722
|
+
* require the end user's access token instead of the API key.
|
|
19723
|
+
*
|
|
19724
|
+
* @example
|
|
19725
|
+
* ```ts
|
|
19726
|
+
* const login = await zyphr.auth.login.loginEndUser({ ... });
|
|
19727
|
+
* const token = login.data.tokens.access_token;
|
|
19728
|
+
*
|
|
19729
|
+
* const profile = await zyphr.auth.profile.getEndUser(
|
|
19730
|
+
* zyphr.asEndUser(token)
|
|
19731
|
+
* );
|
|
19732
|
+
* ```
|
|
19733
|
+
*/
|
|
19734
|
+
asEndUser(accessToken) {
|
|
19735
|
+
return {
|
|
19736
|
+
headers: { Authorization: `Bearer ${accessToken}` }
|
|
19737
|
+
};
|
|
19738
|
+
}
|
|
19719
19739
|
};
|
|
19720
19740
|
|
|
19721
19741
|
// src/index.ts
|