@nocobase/sdk 2.0.31 → 2.0.33

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/lib/Auth.js CHANGED
@@ -30,6 +30,7 @@ __export(Auth_exports, {
30
30
  Auth: () => Auth
31
31
  });
32
32
  module.exports = __toCommonJS(Auth_exports);
33
+ var import_headers = require("./headers");
33
34
  const _Auth = class _Auth {
34
35
  api;
35
36
  get storagePrefix() {
@@ -150,10 +151,10 @@ const _Auth = class _Auth {
150
151
  if (this.role) {
151
152
  config.headers["X-Role"] = this.role;
152
153
  }
153
- if (this.authenticator && !config.headers["X-Authenticator"]) {
154
+ if (this.authenticator && !(0, import_headers.hasHeaderValue)(config.headers, "X-Authenticator")) {
154
155
  config.headers["X-Authenticator"] = this.authenticator;
155
156
  }
156
- if (this.token) {
157
+ if (this.token && !(0, import_headers.hasHeaderValue)(config.headers, "Authorization")) {
157
158
  config.headers["Authorization"] = `Bearer ${this.token}`;
158
159
  }
159
160
  return config;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ export declare const hasHeaderValue: (headers: any, headerName: string) => boolean;
package/lib/headers.js ADDED
@@ -0,0 +1,48 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ var __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
15
+ var __export = (target, all) => {
16
+ for (var name in all)
17
+ __defProp(target, name, { get: all[name], enumerable: true });
18
+ };
19
+ var __copyProps = (to, from, except, desc) => {
20
+ if (from && typeof from === "object" || typeof from === "function") {
21
+ for (let key of __getOwnPropNames(from))
22
+ if (!__hasOwnProp.call(to, key) && key !== except)
23
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
24
+ }
25
+ return to;
26
+ };
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var headers_exports = {};
29
+ __export(headers_exports, {
30
+ hasHeaderValue: () => hasHeaderValue
31
+ });
32
+ module.exports = __toCommonJS(headers_exports);
33
+ const getHeaderValue = /* @__PURE__ */ __name((headers, headerName) => {
34
+ if (!headers) {
35
+ return void 0;
36
+ }
37
+ const source = typeof headers.toJSON === "function" ? headers.toJSON() : headers;
38
+ const matchedKey = Object.keys(source || {}).find((key) => key.toLowerCase() === headerName.toLowerCase());
39
+ return matchedKey ? source[matchedKey] : void 0;
40
+ }, "getHeaderValue");
41
+ const hasHeaderValue = /* @__PURE__ */ __name((headers, headerName) => {
42
+ const value = getHeaderValue(headers, headerName);
43
+ return value !== void 0 && value !== null && value !== "";
44
+ }, "hasHeaderValue");
45
+ // Annotate the CommonJS export names for ESM import in node:
46
+ 0 && (module.exports = {
47
+ hasHeaderValue
48
+ });
package/lib/index.d.ts CHANGED
@@ -8,5 +8,6 @@
8
8
  */
9
9
  export * from './APIClient';
10
10
  export * from './Auth';
11
+ export * from './headers';
11
12
  export * from './Storage';
12
13
  export { default as getSubAppName } from './getSubAppName';
package/lib/index.js CHANGED
@@ -42,6 +42,7 @@ __export(src_exports, {
42
42
  module.exports = __toCommonJS(src_exports);
43
43
  __reExport(src_exports, require("./APIClient"), module.exports);
44
44
  __reExport(src_exports, require("./Auth"), module.exports);
45
+ __reExport(src_exports, require("./headers"), module.exports);
45
46
  __reExport(src_exports, require("./Storage"), module.exports);
46
47
  var import_getSubAppName = __toESM(require("./getSubAppName"));
47
48
  // Annotate the CommonJS export names for ESM import in node:
@@ -49,5 +50,6 @@ var import_getSubAppName = __toESM(require("./getSubAppName"));
49
50
  getSubAppName,
50
51
  ...require("./APIClient"),
51
52
  ...require("./Auth"),
53
+ ...require("./headers"),
52
54
  ...require("./Storage")
53
55
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/sdk",
3
- "version": "2.0.31",
3
+ "version": "2.0.33",
4
4
  "license": "Apache-2.0",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -11,5 +11,5 @@
11
11
  "devDependencies": {
12
12
  "axios-mock-adapter": "^1.20.0"
13
13
  },
14
- "gitHead": "085eec006c7be5fbc98dabfdab98ff358eab9d95"
14
+ "gitHead": "718994b7979f35ad7ab0ad86f49592b19048f948"
15
15
  }