@zyphr-dev/node-sdk 0.1.45 → 0.1.46

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.d.cts CHANGED
@@ -23461,6 +23461,7 @@ declare const WebhookEventType: {
23461
23461
  readonly EMAIL_OPENED: "email.opened";
23462
23462
  readonly EMAIL_CLICKED: "email.clicked";
23463
23463
  readonly EMAIL_FAILED: "email.failed";
23464
+ readonly EMAIL_SUPPRESSED: "email.suppressed";
23464
23465
  readonly EMAIL_RECEIVED: "email.received";
23465
23466
  readonly PUSH_SENT: "push.sent";
23466
23467
  readonly PUSH_DELIVERED: "push.delivered";
@@ -33172,7 +33173,8 @@ declare class Zyphr {
33172
33173
  * const login = await zyphr.auth.login.loginEndUser({ ... });
33173
33174
  * zyphr.setAccessToken(login.data.tokens.access_token);
33174
33175
  *
33175
- * const me = await zyphr.auth.profile.getEndUser(zyphr.authedRequest());
33176
+ * // The stored token is applied automatically to user-scoped calls:
33177
+ * const me = await zyphr.auth.profile.getEndUser();
33176
33178
  * ```
33177
33179
  */
33178
33180
 
@@ -33184,7 +33186,14 @@ interface ZyphrClientOptions {
33184
33186
  applicationKey: string;
33185
33187
  /** Override the base API URL (defaults to https://api.zyphr.dev/v1). */
33186
33188
  baseUrl?: string;
33187
- /** Optional end-user access token, if you already have a session on construction. */
33189
+ /**
33190
+ * Optional end-user access token, if you already have a session on
33191
+ * construction. Once set (here or via {@link ZyphrClient.setAccessToken}), it
33192
+ * is applied automatically as `Authorization: Bearer` to every user-scoped
33193
+ * call — you no longer need to pass {@link ZyphrClient.authedRequest} for
33194
+ * authentication (though authedRequest still works and a token passed to it
33195
+ * overrides the stored one).
33196
+ */
33188
33197
  accessToken?: string;
33189
33198
  }
33190
33199
  /**
@@ -33215,18 +33224,24 @@ declare class ZyphrClient {
33215
33224
  private readonly applicationKey;
33216
33225
  private accessToken?;
33217
33226
  constructor(options: ZyphrClientOptions);
33218
- /** Store the end-user access token for subsequent authedRequest() calls. */
33227
+ /** Store the end-user access token; it is applied automatically to subsequent user-scoped calls. */
33219
33228
  setAccessToken(accessToken: string | undefined): void;
33220
33229
  /** True when an end-user access token is currently set. */
33221
33230
  get isAuthenticated(): boolean;
33222
33231
  /**
33223
33232
  * Build request overrides that authenticate as the current end user: the
33224
33233
  * stored Bearer token plus the publishable application key required by
33225
- * user-scoped endpoints. Pass an explicit token to override the stored one.
33234
+ * user-scoped endpoints.
33235
+ *
33236
+ * The stored token is now applied automatically to user-scoped calls, so this
33237
+ * is no longer required for authentication. It remains useful to authenticate
33238
+ * a single call with a different token — a token passed here sets the header
33239
+ * directly in RequestInit and overrides the stored token for that call.
33226
33240
  *
33227
33241
  * @example
33228
33242
  * ```ts
33229
- * const me = await zyphr.auth.profile.getEndUser(zyphr.authedRequest());
33243
+ * // Authenticate one call as a different user, without changing stored state:
33244
+ * const me = await zyphr.auth.profile.getEndUser(zyphr.authedRequest(otherToken));
33230
33245
  * ```
33231
33246
  */
33232
33247
  authedRequest(accessToken?: string): RequestInit;
package/dist/index.d.ts CHANGED
@@ -23461,6 +23461,7 @@ declare const WebhookEventType: {
23461
23461
  readonly EMAIL_OPENED: "email.opened";
23462
23462
  readonly EMAIL_CLICKED: "email.clicked";
23463
23463
  readonly EMAIL_FAILED: "email.failed";
23464
+ readonly EMAIL_SUPPRESSED: "email.suppressed";
23464
23465
  readonly EMAIL_RECEIVED: "email.received";
23465
23466
  readonly PUSH_SENT: "push.sent";
23466
23467
  readonly PUSH_DELIVERED: "push.delivered";
@@ -33172,7 +33173,8 @@ declare class Zyphr {
33172
33173
  * const login = await zyphr.auth.login.loginEndUser({ ... });
33173
33174
  * zyphr.setAccessToken(login.data.tokens.access_token);
33174
33175
  *
33175
- * const me = await zyphr.auth.profile.getEndUser(zyphr.authedRequest());
33176
+ * // The stored token is applied automatically to user-scoped calls:
33177
+ * const me = await zyphr.auth.profile.getEndUser();
33176
33178
  * ```
33177
33179
  */
33178
33180
 
@@ -33184,7 +33186,14 @@ interface ZyphrClientOptions {
33184
33186
  applicationKey: string;
33185
33187
  /** Override the base API URL (defaults to https://api.zyphr.dev/v1). */
33186
33188
  baseUrl?: string;
33187
- /** Optional end-user access token, if you already have a session on construction. */
33189
+ /**
33190
+ * Optional end-user access token, if you already have a session on
33191
+ * construction. Once set (here or via {@link ZyphrClient.setAccessToken}), it
33192
+ * is applied automatically as `Authorization: Bearer` to every user-scoped
33193
+ * call — you no longer need to pass {@link ZyphrClient.authedRequest} for
33194
+ * authentication (though authedRequest still works and a token passed to it
33195
+ * overrides the stored one).
33196
+ */
33188
33197
  accessToken?: string;
33189
33198
  }
33190
33199
  /**
@@ -33215,18 +33224,24 @@ declare class ZyphrClient {
33215
33224
  private readonly applicationKey;
33216
33225
  private accessToken?;
33217
33226
  constructor(options: ZyphrClientOptions);
33218
- /** Store the end-user access token for subsequent authedRequest() calls. */
33227
+ /** Store the end-user access token; it is applied automatically to subsequent user-scoped calls. */
33219
33228
  setAccessToken(accessToken: string | undefined): void;
33220
33229
  /** True when an end-user access token is currently set. */
33221
33230
  get isAuthenticated(): boolean;
33222
33231
  /**
33223
33232
  * Build request overrides that authenticate as the current end user: the
33224
33233
  * stored Bearer token plus the publishable application key required by
33225
- * user-scoped endpoints. Pass an explicit token to override the stored one.
33234
+ * user-scoped endpoints.
33235
+ *
33236
+ * The stored token is now applied automatically to user-scoped calls, so this
33237
+ * is no longer required for authentication. It remains useful to authenticate
33238
+ * a single call with a different token — a token passed here sets the header
33239
+ * directly in RequestInit and overrides the stored token for that call.
33226
33240
  *
33227
33241
  * @example
33228
33242
  * ```ts
33229
- * const me = await zyphr.auth.profile.getEndUser(zyphr.authedRequest());
33243
+ * // Authenticate one call as a different user, without changing stored state:
33244
+ * const me = await zyphr.auth.profile.getEndUser(zyphr.authedRequest(otherToken));
33230
33245
  * ```
33231
33246
  */
33232
33247
  authedRequest(accessToken?: string): RequestInit;
package/dist/index.js CHANGED
@@ -15864,6 +15864,7 @@ var WebhookEventType = {
15864
15864
  EMAIL_OPENED: "email.opened",
15865
15865
  EMAIL_CLICKED: "email.clicked",
15866
15866
  EMAIL_FAILED: "email.failed",
15867
+ EMAIL_SUPPRESSED: "email.suppressed",
15867
15868
  EMAIL_RECEIVED: "email.received",
15868
15869
  PUSH_SENT: "push.sent",
15869
15870
  PUSH_DELIVERED: "push.delivered",
@@ -26334,10 +26335,18 @@ var ZyphrClient = class {
26334
26335
  this.accessToken = options.accessToken;
26335
26336
  const config = new Configuration({
26336
26337
  basePath: options.baseUrl,
26337
- // The only credential this client sends automatically is the publishable
26338
- // application key. End-user Bearer tokens are attached per-request via
26339
- // authedRequest() so token rotation doesn't require rebuilding the client.
26338
+ // The publishable application key is sent automatically on every call.
26340
26339
  apiKey: (name) => name === "X-Application-Key" ? this.applicationKey : "",
26340
+ // The stored end-user access token is also applied automatically: any
26341
+ // user-scoped generated method (which authenticates the EndUserToken
26342
+ // scheme) invokes this callback and attaches `Authorization: Bearer`.
26343
+ // The callback reads `this.accessToken` at call time, so setAccessToken()
26344
+ // takes effect on subsequent calls without rebuilding the client. When no
26345
+ // token is set it returns '', and the generated code adds no header — so
26346
+ // anonymous endpoints (login, register, password-reset) stay unauthenticated.
26347
+ // An explicit token passed to authedRequest() sets the header directly in
26348
+ // RequestInit, which overrides this callback.
26349
+ accessToken: async () => this.accessToken ?? "",
26341
26350
  middleware: [errorMiddleware2]
26342
26351
  });
26343
26352
  this.auth = {
@@ -26357,7 +26366,7 @@ var ZyphrClient = class {
26357
26366
  };
26358
26367
  this.devices = new DevicesApi(config);
26359
26368
  }
26360
- /** Store the end-user access token for subsequent authedRequest() calls. */
26369
+ /** Store the end-user access token; it is applied automatically to subsequent user-scoped calls. */
26361
26370
  setAccessToken(accessToken) {
26362
26371
  this.accessToken = accessToken;
26363
26372
  }
@@ -26368,11 +26377,17 @@ var ZyphrClient = class {
26368
26377
  /**
26369
26378
  * Build request overrides that authenticate as the current end user: the
26370
26379
  * stored Bearer token plus the publishable application key required by
26371
- * user-scoped endpoints. Pass an explicit token to override the stored one.
26380
+ * user-scoped endpoints.
26381
+ *
26382
+ * The stored token is now applied automatically to user-scoped calls, so this
26383
+ * is no longer required for authentication. It remains useful to authenticate
26384
+ * a single call with a different token — a token passed here sets the header
26385
+ * directly in RequestInit and overrides the stored token for that call.
26372
26386
  *
26373
26387
  * @example
26374
26388
  * ```ts
26375
- * const me = await zyphr.auth.profile.getEndUser(zyphr.authedRequest());
26389
+ * // Authenticate one call as a different user, without changing stored state:
26390
+ * const me = await zyphr.auth.profile.getEndUser(zyphr.authedRequest(otherToken));
26376
26391
  * ```
26377
26392
  */
26378
26393
  authedRequest(accessToken) {