@bytescale/sdk 3.0.0-alpha.20 → 3.0.0-alpha.21

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.
@@ -2702,7 +2702,8 @@ var AuthManagerImpl = /*#__PURE__*/function () {
2702
2702
  }, {
2703
2703
  key: "getAccessTokenUrl",
2704
2704
  value: function getAccessTokenUrl(params) {
2705
- var cdnUrl = BytescaleApiClientConfigUtils.getCdnUrl(params);
2705
+ var _a;
2706
+ var cdnUrl = BytescaleApiClientConfigUtils.getCdnUrl((_a = params.options) !== null && _a !== void 0 ? _a : {});
2706
2707
  return "".concat(cdnUrl, "/api/v1/access_tokens/").concat(params.accountId);
2707
2708
  }
2708
2709
  }, {
@@ -2710,13 +2711,14 @@ var AuthManagerImpl = /*#__PURE__*/function () {
2710
2711
  value: function deleteAccessToken(params) {
2711
2712
  try {
2712
2713
  var _this8 = this;
2714
+ var _a;
2713
2715
  return AuthManagerBrowser_awaitIgnored(BaseAPI.fetch(_this8.getAccessTokenUrl(params), {
2714
2716
  method: "DELETE",
2715
2717
  credentials: "include",
2716
2718
  headers: {}
2717
2719
  }, {
2718
2720
  isBytescaleApi: true,
2719
- fetchApi: params.fetchApi
2721
+ fetchApi: (_a = params.options) === null || _a === void 0 ? void 0 : _a.fetchApi
2720
2722
  }));
2721
2723
  } catch (e) {
2722
2724
  return Promise.reject(e);
@@ -2727,6 +2729,7 @@ var AuthManagerImpl = /*#__PURE__*/function () {
2727
2729
  value: function setAccessToken(params, jwt) {
2728
2730
  try {
2729
2731
  var _this10 = this;
2732
+ var _a;
2730
2733
  var request = {
2731
2734
  accessToken: jwt
2732
2735
  };
@@ -2737,7 +2740,7 @@ var AuthManagerImpl = /*#__PURE__*/function () {
2737
2740
  body: JSON.stringify(request)
2738
2741
  }, {
2739
2742
  isBytescaleApi: true,
2740
- fetchApi: params.fetchApi
2743
+ fetchApi: (_a = params.options) === null || _a === void 0 ? void 0 : _a.fetchApi
2741
2744
  }), function (response) {
2742
2745
  return AuthManagerBrowser_await(response.json());
2743
2746
  });
@@ -2750,7 +2753,7 @@ var AuthManagerImpl = /*#__PURE__*/function () {
2750
2753
  value: function getAccessToken(params, headers) {
2751
2754
  try {
2752
2755
  var _this12 = this;
2753
- var _a;
2756
+ var _a, _b;
2754
2757
  var endpointName = "Your auth API endpoint";
2755
2758
  var requiredContentType = _this12.contentTypeText;
2756
2759
  return AuthManagerBrowser_await(BaseAPI.fetch(params.authUrl, {
@@ -2758,9 +2761,9 @@ var AuthManagerImpl = /*#__PURE__*/function () {
2758
2761
  headers: headers
2759
2762
  }, {
2760
2763
  isBytescaleApi: false,
2761
- fetchApi: params.fetchApi
2764
+ fetchApi: (_a = params.options) === null || _a === void 0 ? void 0 : _a.fetchApi
2762
2765
  }), function (result) {
2763
- var actualContentType = (_a = result.headers.get(_this12.contentType)) !== null && _a !== void 0 ? _a : "";
2766
+ var actualContentType = (_b = result.headers.get(_this12.contentType)) !== null && _b !== void 0 ? _b : "";
2764
2767
  // Support content types like "text/plain; charset=utf-8" and "text/plain"
2765
2768
  if (actualContentType.split(";")[0] !== requiredContentType) {
2766
2769
  throw new Error("".concat(endpointName, " returned \"").concat(actualContentType, "\" for the ").concat(_this12.contentType, " response header, but the Bytescale SDK requires \"").concat(requiredContentType, "\"."));
@@ -1,5 +1,8 @@
1
1
  import { BytescaleApiClientConfig } from "../../public/shared";
2
- export interface BeginAuthSessionParams extends Pick<BytescaleApiClientConfig, "fetchApi" | "cdnUrl"> {
2
+ export interface BeginAuthSessionParams {
3
+ /**
4
+ * The account ID to authorize requests for.
5
+ */
3
6
  accountId: string;
4
7
  /**
5
8
  * Headers to send to your backend API.
@@ -11,6 +14,10 @@ export interface BeginAuthSessionParams extends Pick<BytescaleApiClientConfig, "
11
14
  * The fully-qualified URL for your backend API's auth endpoint.
12
15
  */
13
16
  authUrl: string;
17
+ /**
18
+ * Optional configuration.
19
+ */
20
+ options?: Pick<BytescaleApiClientConfig, "fetchApi" | "cdnUrl">;
14
21
  }
15
22
  export interface AuthManagerInterface {
16
23
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bytescale/sdk",
3
- "version": "3.0.0-alpha.20",
3
+ "version": "3.0.0-alpha.21",
4
4
  "description": "Bytescale JavaScript SDK",
5
5
  "author": "Bytescale <hello@bytescale.com> (https://www.bytescale.com)",
6
6
  "license": "MIT",