@zyphr-dev/node-sdk 0.1.10 → 0.1.12
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 +34 -12
- package/dist/index.cjs +5 -1
- 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 +5 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +10 -1
package/README.md
CHANGED
|
@@ -377,20 +377,44 @@ await zyphr.devices.deleteUserDevices('user_123');
|
|
|
377
377
|
|
|
378
378
|
### Authentication — `zyphr.auth.*`
|
|
379
379
|
|
|
380
|
-
Full
|
|
380
|
+
Full Auth-as-a-Service API for end-user authentication: registration, login, MFA, magic links, OAuth, and more.
|
|
381
|
+
|
|
382
|
+
> **Important:** Auth endpoints require application credentials, not just an API key. Create an application in the Zyphr dashboard first, then pass the credentials when constructing the client:
|
|
383
|
+
|
|
384
|
+
```ts
|
|
385
|
+
const zyphr = new Zyphr({
|
|
386
|
+
apiKey: process.env.ZYPHR_API_KEY!,
|
|
387
|
+
applicationKey: process.env.ZYPHR_APP_PUBLIC_KEY!, // za_pub_*
|
|
388
|
+
applicationSecret: process.env.ZYPHR_APP_SECRET_KEY!, // za_sec_*
|
|
389
|
+
});
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
> **Common mistake:** `POST /v1/auth/register` creates a **platform account** (for the Zyphr dashboard). To register **end users** in your application, use `POST /v1/auth/users/register` via `zyphr.auth.registration.registerEndUser()`.
|
|
381
393
|
|
|
382
394
|
```ts
|
|
395
|
+
// Register an end user
|
|
396
|
+
const result = await zyphr.auth.registration.registerEndUser({
|
|
397
|
+
registerRequest: {
|
|
398
|
+
email: 'new@example.com',
|
|
399
|
+
password: 'SecureP@ss123',
|
|
400
|
+
name: 'New User',
|
|
401
|
+
},
|
|
402
|
+
});
|
|
403
|
+
// result.data.user — the new user
|
|
404
|
+
// result.data.tokens — { access_token, refresh_token, expires_in }
|
|
405
|
+
|
|
383
406
|
// Login
|
|
384
407
|
const session = await zyphr.auth.login.loginEndUser({
|
|
385
|
-
|
|
386
|
-
|
|
408
|
+
loginRequest: {
|
|
409
|
+
email: 'user@example.com',
|
|
410
|
+
password: 'SecureP@ss123',
|
|
411
|
+
},
|
|
387
412
|
});
|
|
388
413
|
|
|
389
|
-
//
|
|
390
|
-
await zyphr.auth.
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
name: 'New User',
|
|
414
|
+
// User profile (requires end-user access token)
|
|
415
|
+
const profile = await zyphr.auth.profile.getEndUser();
|
|
416
|
+
await zyphr.auth.profile.updateEndUser({
|
|
417
|
+
updateEndUserRequest: { name: 'Updated Name' },
|
|
394
418
|
});
|
|
395
419
|
|
|
396
420
|
// Email verification
|
|
@@ -405,14 +429,12 @@ await zyphr.auth.magicLinks.sendMagicLink('user@example.com');
|
|
|
405
429
|
// MFA
|
|
406
430
|
const mfaStatus = await zyphr.auth.mfa.getMfaStatus();
|
|
407
431
|
await zyphr.auth.mfa.enrollMfa({ method: 'totp' });
|
|
408
|
-
|
|
409
|
-
// User profile
|
|
410
|
-
const profile = await zyphr.auth.profile.getProfile();
|
|
411
|
-
await zyphr.auth.profile.updateProfile({ name: 'Updated Name' });
|
|
412
432
|
```
|
|
413
433
|
|
|
414
434
|
**Available auth modules:** `login`, `registration`, `sessions`, `emailVerification`, `passwordReset`, `magicLinks`, `mfa`, `oauth`, `phone`, `webauthn`, `profile`.
|
|
415
435
|
|
|
436
|
+
See the [Auth-as-a-Service guide](https://zyphr.dev/docs/guides/auth-as-a-service) for the full setup walkthrough.
|
|
437
|
+
|
|
416
438
|
### WaaS — `zyphr.waas.*`
|
|
417
439
|
|
|
418
440
|
Webhooks-as-a-Service: multi-tenant webhook delivery infrastructure for your customers.
|
package/dist/index.cjs
CHANGED
|
@@ -19678,7 +19678,11 @@ var Zyphr = class {
|
|
|
19678
19678
|
constructor(options) {
|
|
19679
19679
|
const config = new Configuration({
|
|
19680
19680
|
basePath: options.baseUrl,
|
|
19681
|
-
apiKey: () =>
|
|
19681
|
+
apiKey: (name) => {
|
|
19682
|
+
if (name === "X-Application-Key" && options.applicationKey) return options.applicationKey;
|
|
19683
|
+
if (name === "X-Application-Secret" && options.applicationSecret) return options.applicationSecret;
|
|
19684
|
+
return options.apiKey;
|
|
19685
|
+
},
|
|
19682
19686
|
middleware: [errorMiddleware]
|
|
19683
19687
|
});
|
|
19684
19688
|
this.emails = new EmailsApi(config);
|