hanbiro-react16-sdk 1.0.32 → 1.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.
@@ -1,6 +1,7 @@
1
1
  interface apiGetOptions {
2
2
  headers: any;
3
3
  }
4
+ export declare const getSigner: () => any;
4
5
  export declare const apiGet: (url: string, opts?: apiGetOptions) => Promise<{
5
6
  data: any;
6
7
  code: number;
package/dist/utils/api.js CHANGED
@@ -35,12 +35,24 @@ var __async = (__this, __arguments, generator) => {
35
35
  });
36
36
  };
37
37
  import { getBaseUrl } from "./url.js";
38
+ import { ClientSigner as W } from "../node_modules/@hanbiro/signer-core/dist/index.js";
39
+ const getSigner = () => {
40
+ const existed = window == null ? void 0 : window.HanSigCommon;
41
+ if (existed) {
42
+ return existed;
43
+ } else {
44
+ return new W({ baseUrl: getBaseUrl() });
45
+ }
46
+ };
38
47
  const apiGet = (url, opts) => __async(void 0, null, function* () {
48
+ var _a;
49
+ const sigConfig = { method: "POST", baseURL: getBaseUrl(), url };
50
+ const sigHeaders = yield (_a = getSigner()) == null ? void 0 : _a.generateHeaders(sigConfig);
39
51
  const response = yield fetch(getBaseUrl() + url, {
40
- headers: __spreadValues({
52
+ headers: __spreadValues(__spreadValues({
41
53
  Accept: "application/json, text/plain, */*",
42
54
  "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8"
43
- }, opts == null ? void 0 : opts.headers)
55
+ }, opts == null ? void 0 : opts.headers), sigHeaders)
44
56
  });
45
57
  let data = null;
46
58
  if (response.ok) {
@@ -51,5 +63,6 @@ const apiGet = (url, opts) => __async(void 0, null, function* () {
51
63
  return { data, code: response.status, ok: response.ok };
52
64
  });
53
65
  export {
54
- apiGet
66
+ apiGet,
67
+ getSigner
55
68
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hanbiro-react16-sdk",
3
- "version": "1.0.32",
3
+ "version": "1.0.33",
4
4
  "description": "React 16.2.0 compatible UI components for Hanbiro",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./dist/hanbiro-react16-sdk.umd.js",
@@ -75,7 +75,8 @@
75
75
  "sass-embedded": "^1.98.0",
76
76
  "typescript": "^5.5.0",
77
77
  "vite": "^5.4.0",
78
- "vite-plugin-dts": "^3.9.1"
78
+ "vite-plugin-dts": "^3.9.1",
79
+ "@hanbiro/signer-core": "git+ssh://git@git.hanbiro.com:2222/dev/groupware.client-api-sdk.git#main"
79
80
  },
80
81
  "dependencies": {
81
82
  "@tinymce/tinymce-react": "^4.3.0",