@zyphr-dev/node-sdk 0.1.10 → 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/dist/index.d.cts CHANGED
@@ -22469,6 +22469,10 @@ interface ZyphrOptions {
22469
22469
  apiKey: string;
22470
22470
  /** Override the base API URL (defaults to https://api.zyphr.dev/v1) */
22471
22471
  baseUrl?: string;
22472
+ /** Application public key (za_pub_*) for Auth-as-a-Service endpoints */
22473
+ applicationKey?: string;
22474
+ /** Application secret key (za_sec_*) for Auth-as-a-Service endpoints */
22475
+ applicationSecret?: string;
22472
22476
  }
22473
22477
  declare class Zyphr {
22474
22478
  readonly emails: EmailsApi;
@@ -22502,6 +22506,22 @@ declare class Zyphr {
22502
22506
  readonly webauthn: AuthWebAuthnApi;
22503
22507
  };
22504
22508
  constructor(options: ZyphrOptions);
22509
+ /**
22510
+ * Create request overrides that authenticate as an end user.
22511
+ * Use this when calling profile, session, or MFA endpoints that
22512
+ * require the end user's access token instead of the API key.
22513
+ *
22514
+ * @example
22515
+ * ```ts
22516
+ * const login = await zyphr.auth.login.loginEndUser({ ... });
22517
+ * const token = login.data.tokens.access_token;
22518
+ *
22519
+ * const profile = await zyphr.auth.profile.getEndUser(
22520
+ * zyphr.asEndUser(token)
22521
+ * );
22522
+ * ```
22523
+ */
22524
+ asEndUser(accessToken: string): RequestInit;
22505
22525
  }
22506
22526
 
22507
22527
  /**
package/dist/index.d.ts CHANGED
@@ -22469,6 +22469,10 @@ interface ZyphrOptions {
22469
22469
  apiKey: string;
22470
22470
  /** Override the base API URL (defaults to https://api.zyphr.dev/v1) */
22471
22471
  baseUrl?: string;
22472
+ /** Application public key (za_pub_*) for Auth-as-a-Service endpoints */
22473
+ applicationKey?: string;
22474
+ /** Application secret key (za_sec_*) for Auth-as-a-Service endpoints */
22475
+ applicationSecret?: string;
22472
22476
  }
22473
22477
  declare class Zyphr {
22474
22478
  readonly emails: EmailsApi;
@@ -22502,6 +22506,22 @@ declare class Zyphr {
22502
22506
  readonly webauthn: AuthWebAuthnApi;
22503
22507
  };
22504
22508
  constructor(options: ZyphrOptions);
22509
+ /**
22510
+ * Create request overrides that authenticate as an end user.
22511
+ * Use this when calling profile, session, or MFA endpoints that
22512
+ * require the end user's access token instead of the API key.
22513
+ *
22514
+ * @example
22515
+ * ```ts
22516
+ * const login = await zyphr.auth.login.loginEndUser({ ... });
22517
+ * const token = login.data.tokens.access_token;
22518
+ *
22519
+ * const profile = await zyphr.auth.profile.getEndUser(
22520
+ * zyphr.asEndUser(token)
22521
+ * );
22522
+ * ```
22523
+ */
22524
+ asEndUser(accessToken: string): RequestInit;
22505
22525
  }
22506
22526
 
22507
22527
  /**
package/dist/index.js CHANGED
@@ -17881,7 +17881,11 @@ var Zyphr = class {
17881
17881
  constructor(options) {
17882
17882
  const config = new Configuration({
17883
17883
  basePath: options.baseUrl,
17884
- apiKey: () => options.apiKey,
17884
+ apiKey: (name) => {
17885
+ if (name === "X-Application-Key" && options.applicationKey) return options.applicationKey;
17886
+ if (name === "X-Application-Secret" && options.applicationSecret) return options.applicationSecret;
17887
+ return options.apiKey;
17888
+ },
17885
17889
  middleware: [errorMiddleware]
17886
17890
  });
17887
17891
  this.emails = new EmailsApi(config);
@@ -17915,6 +17919,26 @@ var Zyphr = class {
17915
17919
  webauthn: new AuthWebAuthnApi(config)
17916
17920
  };
17917
17921
  }
17922
+ /**
17923
+ * Create request overrides that authenticate as an end user.
17924
+ * Use this when calling profile, session, or MFA endpoints that
17925
+ * require the end user's access token instead of the API key.
17926
+ *
17927
+ * @example
17928
+ * ```ts
17929
+ * const login = await zyphr.auth.login.loginEndUser({ ... });
17930
+ * const token = login.data.tokens.access_token;
17931
+ *
17932
+ * const profile = await zyphr.auth.profile.getEndUser(
17933
+ * zyphr.asEndUser(token)
17934
+ * );
17935
+ * ```
17936
+ */
17937
+ asEndUser(accessToken) {
17938
+ return {
17939
+ headers: { Authorization: `Bearer ${accessToken}` }
17940
+ };
17941
+ }
17918
17942
  };
17919
17943
 
17920
17944
  // src/index.ts