@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.cjs CHANGED
@@ -18529,6 +18529,7 @@ var WebhookEventType = {
18529
18529
  EMAIL_OPENED: "email.opened",
18530
18530
  EMAIL_CLICKED: "email.clicked",
18531
18531
  EMAIL_FAILED: "email.failed",
18532
+ EMAIL_SUPPRESSED: "email.suppressed",
18532
18533
  EMAIL_RECEIVED: "email.received",
18533
18534
  PUSH_SENT: "push.sent",
18534
18535
  PUSH_DELIVERED: "push.delivered",
@@ -28999,10 +29000,18 @@ var ZyphrClient = class {
28999
29000
  this.accessToken = options.accessToken;
29000
29001
  const config = new Configuration({
29001
29002
  basePath: options.baseUrl,
29002
- // The only credential this client sends automatically is the publishable
29003
- // application key. End-user Bearer tokens are attached per-request via
29004
- // authedRequest() so token rotation doesn't require rebuilding the client.
29003
+ // The publishable application key is sent automatically on every call.
29005
29004
  apiKey: (name) => name === "X-Application-Key" ? this.applicationKey : "",
29005
+ // The stored end-user access token is also applied automatically: any
29006
+ // user-scoped generated method (which authenticates the EndUserToken
29007
+ // scheme) invokes this callback and attaches `Authorization: Bearer`.
29008
+ // The callback reads `this.accessToken` at call time, so setAccessToken()
29009
+ // takes effect on subsequent calls without rebuilding the client. When no
29010
+ // token is set it returns '', and the generated code adds no header — so
29011
+ // anonymous endpoints (login, register, password-reset) stay unauthenticated.
29012
+ // An explicit token passed to authedRequest() sets the header directly in
29013
+ // RequestInit, which overrides this callback.
29014
+ accessToken: async () => this.accessToken ?? "",
29006
29015
  middleware: [errorMiddleware2]
29007
29016
  });
29008
29017
  this.auth = {
@@ -29022,7 +29031,7 @@ var ZyphrClient = class {
29022
29031
  };
29023
29032
  this.devices = new DevicesApi(config);
29024
29033
  }
29025
- /** Store the end-user access token for subsequent authedRequest() calls. */
29034
+ /** Store the end-user access token; it is applied automatically to subsequent user-scoped calls. */
29026
29035
  setAccessToken(accessToken) {
29027
29036
  this.accessToken = accessToken;
29028
29037
  }
@@ -29033,11 +29042,17 @@ var ZyphrClient = class {
29033
29042
  /**
29034
29043
  * Build request overrides that authenticate as the current end user: the
29035
29044
  * stored Bearer token plus the publishable application key required by
29036
- * user-scoped endpoints. Pass an explicit token to override the stored one.
29045
+ * user-scoped endpoints.
29046
+ *
29047
+ * The stored token is now applied automatically to user-scoped calls, so this
29048
+ * is no longer required for authentication. It remains useful to authenticate
29049
+ * a single call with a different token — a token passed here sets the header
29050
+ * directly in RequestInit and overrides the stored token for that call.
29037
29051
  *
29038
29052
  * @example
29039
29053
  * ```ts
29040
- * const me = await zyphr.auth.profile.getEndUser(zyphr.authedRequest());
29054
+ * // Authenticate one call as a different user, without changing stored state:
29055
+ * const me = await zyphr.auth.profile.getEndUser(zyphr.authedRequest(otherToken));
29041
29056
  * ```
29042
29057
  */
29043
29058
  authedRequest(accessToken) {