@seamapi/http 1.20.0 → 1.21.0

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/connect.cjs CHANGED
@@ -2784,6 +2784,93 @@ var SeamHttpActionAttempts = class _SeamHttpActionAttempts {
2784
2784
  }
2785
2785
  };
2786
2786
 
2787
+ // src/lib/seam/connect/routes/bridges.ts
2788
+ var SeamHttpBridges = class _SeamHttpBridges {
2789
+ constructor(apiKeyOrOptions = {}) {
2790
+ const options = parseOptions(apiKeyOrOptions);
2791
+ this.client = "client" in options ? options.client : createClient(options);
2792
+ this.defaults = limitToSeamHttpRequestOptions(options);
2793
+ }
2794
+ static fromClient(client, options = {}) {
2795
+ const constructorOptions = { ...options, client };
2796
+ if (!isSeamHttpOptionsWithClient(constructorOptions)) {
2797
+ throw new SeamHttpInvalidOptionsError("Missing client");
2798
+ }
2799
+ return new _SeamHttpBridges(constructorOptions);
2800
+ }
2801
+ static fromApiKey(apiKey, options = {}) {
2802
+ const constructorOptions = { ...options, apiKey };
2803
+ if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
2804
+ throw new SeamHttpInvalidOptionsError("Missing apiKey");
2805
+ }
2806
+ return new _SeamHttpBridges(constructorOptions);
2807
+ }
2808
+ static fromClientSessionToken(clientSessionToken, options = {}) {
2809
+ const constructorOptions = { ...options, clientSessionToken };
2810
+ if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
2811
+ throw new SeamHttpInvalidOptionsError("Missing clientSessionToken");
2812
+ }
2813
+ return new _SeamHttpBridges(constructorOptions);
2814
+ }
2815
+ static async fromPublishableKey(publishableKey, userIdentifierKey, options = {}) {
2816
+ warnOnInsecureuserIdentifierKey(userIdentifierKey);
2817
+ const clientOptions = parseOptions({ ...options, publishableKey });
2818
+ if (isSeamHttpOptionsWithClient(clientOptions)) {
2819
+ throw new SeamHttpInvalidOptionsError(
2820
+ "The client option cannot be used with SeamHttp.fromPublishableKey"
2821
+ );
2822
+ }
2823
+ const client = createClient(clientOptions);
2824
+ const clientSessions = SeamHttpClientSessions.fromClient(client);
2825
+ const { token } = await clientSessions.getOrCreate({
2826
+ user_identifier_key: userIdentifierKey
2827
+ });
2828
+ return _SeamHttpBridges.fromClientSessionToken(token, options);
2829
+ }
2830
+ static fromConsoleSessionToken(consoleSessionToken, workspaceId, options = {}) {
2831
+ const constructorOptions = { ...options, consoleSessionToken, workspaceId };
2832
+ if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) {
2833
+ throw new SeamHttpInvalidOptionsError(
2834
+ "Missing consoleSessionToken or workspaceId"
2835
+ );
2836
+ }
2837
+ return new _SeamHttpBridges(constructorOptions);
2838
+ }
2839
+ static fromPersonalAccessToken(personalAccessToken, workspaceId, options = {}) {
2840
+ const constructorOptions = { ...options, personalAccessToken, workspaceId };
2841
+ if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) {
2842
+ throw new SeamHttpInvalidOptionsError(
2843
+ "Missing personalAccessToken or workspaceId"
2844
+ );
2845
+ }
2846
+ return new _SeamHttpBridges(constructorOptions);
2847
+ }
2848
+ async updateClientSessionToken(clientSessionToken) {
2849
+ const { headers } = this.client.defaults;
2850
+ const authHeaders = getAuthHeadersForClientSessionToken({
2851
+ clientSessionToken
2852
+ });
2853
+ for (const key of Object.keys(authHeaders)) {
2854
+ if (headers[key] == null) {
2855
+ throw new Error(
2856
+ "Cannot update a clientSessionToken on a client created without a clientSessionToken"
2857
+ );
2858
+ }
2859
+ }
2860
+ this.client.defaults.headers = { ...headers, ...authHeaders };
2861
+ const clientSessions = SeamHttpClientSessions.fromClient(this.client);
2862
+ await clientSessions.get();
2863
+ }
2864
+ get(body) {
2865
+ return new SeamHttpRequest(this, {
2866
+ path: "/bridges/get",
2867
+ method: "post",
2868
+ body,
2869
+ responseKey: "bridge"
2870
+ });
2871
+ }
2872
+ };
2873
+
2787
2874
  // src/lib/seam/connect/routes/connect-webviews.ts
2788
2875
  var SeamHttpConnectWebviews = class _SeamHttpConnectWebviews {
2789
2876
  constructor(apiKeyOrOptions = {}) {
@@ -5267,6 +5354,7 @@ exports.SeamHttpAcsUsers = SeamHttpAcsUsers;
5267
5354
  exports.SeamHttpAcsUsersUnmanaged = SeamHttpAcsUsersUnmanaged;
5268
5355
  exports.SeamHttpActionAttempts = SeamHttpActionAttempts;
5269
5356
  exports.SeamHttpApiError = SeamHttpApiError;
5357
+ exports.SeamHttpBridges = SeamHttpBridges;
5270
5358
  exports.SeamHttpClientSessions = SeamHttpClientSessions;
5271
5359
  exports.SeamHttpConnectWebviews = SeamHttpConnectWebviews;
5272
5360
  exports.SeamHttpConnectedAccounts = SeamHttpConnectedAccounts;