szld-libs 0.2.49 → 0.2.51
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/szld-components.es.js +16091 -17681
- package/dist/szld-components.umd.js +56 -56
- package/es/components/CreateForm/index.d.ts +1 -0
- package/es/components/CreateForm/index.js +4 -3
- package/es/index.js +45 -3
- package/es/main.d.ts +1 -1
- package/es/main.js +1 -1
- package/es/utils/hmacSM3.d.ts +20 -0
- package/es/utils/hmacSM3.js +173 -0
- package/lib/components/CreateForm/index.d.ts +1 -0
- package/lib/components/CreateForm/index.js +4 -3
- package/lib/index.js +44 -2
- package/lib/main.d.ts +1 -1
- package/lib/main.js +2 -2
- package/lib/utils/hmacSM3.d.ts +20 -0
- package/lib/utils/hmacSM3.js +172 -0
- package/package.json +2 -3
- package/es/utils/hmacsm3.d.ts +0 -7
- package/es/utils/hmacsm3.js +0 -20
- package/lib/utils/hmacsm3.d.ts +0 -7
- package/lib/utils/hmacsm3.js +0 -19
|
@@ -50,6 +50,7 @@ interface FormFieldsProps extends Pick<CreateFormItemProps<ValueType>, "valueTyp
|
|
|
50
50
|
value?: any;
|
|
51
51
|
onBtnClick?: (e: React.MouseEvent<HTMLElement, MouseEvent>, item: ValueBtnProps) => void;
|
|
52
52
|
inputRef?: any;
|
|
53
|
+
formItemProps?: FormItemProps;
|
|
53
54
|
}
|
|
54
55
|
export declare const FormFields: (props: FormFieldsProps) => React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
55
56
|
export default CreateForm;
|
|
@@ -100,7 +100,8 @@ const CreateForm = (props) => {
|
|
|
100
100
|
},
|
|
101
101
|
valueType: item.valueType,
|
|
102
102
|
onBtnClick,
|
|
103
|
-
valueProps: item.valueProps
|
|
103
|
+
valueProps: item.valueProps,
|
|
104
|
+
formItemProps: item.formItemProps
|
|
104
105
|
}
|
|
105
106
|
)
|
|
106
107
|
}
|
|
@@ -112,7 +113,7 @@ const CreateForm = (props) => {
|
|
|
112
113
|
);
|
|
113
114
|
};
|
|
114
115
|
const FormFields = (props) => {
|
|
115
|
-
const { valueType, valueProps, value, onChange, onBtnClick, inputRef } = props;
|
|
116
|
+
const { valueType, valueProps, value, onChange, onBtnClick, inputRef, formItemProps } = props;
|
|
116
117
|
const children = useMemo(() => {
|
|
117
118
|
let result = /* @__PURE__ */ jsx(Input, { placeholder: "请输入", allowClear: true, ...valueProps });
|
|
118
119
|
switch (valueType) {
|
|
@@ -226,7 +227,7 @@ const FormFields = (props) => {
|
|
|
226
227
|
if (valueType === "custom") {
|
|
227
228
|
const params = valueProps;
|
|
228
229
|
return React.cloneElement(params.children, {
|
|
229
|
-
[getValuePropName(valueType || "input")]: value,
|
|
230
|
+
[(formItemProps == null ? void 0 : formItemProps.valuePropName) || getValuePropName(valueType || "input")]: value,
|
|
230
231
|
onChange,
|
|
231
232
|
ref: inputRef
|
|
232
233
|
});
|
package/es/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useEffect, useState } from "react";
|
|
3
3
|
import ReactDOM from "react-dom/client";
|
|
4
4
|
import { BrowserRouter } from "react-router-dom";
|
|
5
|
-
import { App, Form, Table,
|
|
5
|
+
import { App, Form, Table, Upload, Button, Flex, message } from "antd";
|
|
6
6
|
import useConfig from "./hooks/useConfig";
|
|
7
7
|
import { useRowSelection, useChangePwd, HmacSM3, BackHeader, SearchTable, CreateForm, CustomPagination } from "./main";
|
|
8
8
|
let key = "U2FsdGVkX1/dG1NSXNR9hnp3Ech/v6Gh8CDDJxgBm1EPFQel12ySIf84ARXCPwTae7TzwgPvjOyE3S5rAEzl/wAZmId6pbezpFeFcJqxdmIl3FeluYHFxJzQHDETTvrr3G/REvv00kHptOVwg6ecjPH6yk7PNit0sWTBLorROxLxMD8lVDmOA66p7Zp4QnYzqScYJGFbutmfHYXfBRBe1Q2UKummJ798svNY5SIwEwl4spzgyWmhARtuyq4zhysFrj/xODuNDjtwitA6XfX566WcZkj3F+2P+mkYzDYOhXXaomnlybjrZ2hEHfcczQhUfJd89O8PNIuEWo24wjYRgMdKlw5CWSeocFCqV7ZJ/CV/7vNRcaO4awKlFNobLikkwDznxpcX+4UEej+ED+pgfmPQLsKedcfEscStkSAZXaD5pBRTiFU9xGLfDt6seUrEnMBeXkpMIY9j1SZDDK18/G7lSHjDQMZYZP6sfLdBdwY=";
|
|
@@ -66,6 +66,29 @@ const Demo = () => {
|
|
|
66
66
|
]
|
|
67
67
|
}
|
|
68
68
|
];
|
|
69
|
+
const imgAccept = ".jpg,.png,.jpeg";
|
|
70
|
+
const imgUploadProps = {
|
|
71
|
+
maxCount: 1,
|
|
72
|
+
action: "uploadAction",
|
|
73
|
+
accept: imgAccept,
|
|
74
|
+
showUploadList: false,
|
|
75
|
+
beforeUpload(file) {
|
|
76
|
+
var _a;
|
|
77
|
+
const accepts = imgAccept.split(",");
|
|
78
|
+
const fileType = (_a = file.name.split(".").pop()) == null ? void 0 : _a.toLocaleLowerCase();
|
|
79
|
+
if (!accepts.includes(`.${fileType}`)) {
|
|
80
|
+
message.error(`只允许上传${accepts.join("、")}文件`);
|
|
81
|
+
return Upload.LIST_IGNORE;
|
|
82
|
+
}
|
|
83
|
+
return file;
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
const normFile = (e) => {
|
|
87
|
+
if (Array.isArray(e)) {
|
|
88
|
+
return e;
|
|
89
|
+
}
|
|
90
|
+
return e && e.fileList;
|
|
91
|
+
};
|
|
69
92
|
const formItems = [
|
|
70
93
|
{
|
|
71
94
|
dataIndex: "asctypeid",
|
|
@@ -122,14 +145,33 @@ const Demo = () => {
|
|
|
122
145
|
colProps: {
|
|
123
146
|
span: 11
|
|
124
147
|
}
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
dataIndex: "fileList",
|
|
151
|
+
title: "营业执照",
|
|
152
|
+
valueType: "custom",
|
|
153
|
+
valueProps: {
|
|
154
|
+
children: /* @__PURE__ */ jsx(Upload, { ...imgUploadProps, children: /* @__PURE__ */ jsx(Button, { children: "上传营业执照" }) }),
|
|
155
|
+
fileList: form.getFieldValue("fileList")
|
|
156
|
+
},
|
|
157
|
+
colProps: {
|
|
158
|
+
md: 24,
|
|
159
|
+
xl: 10
|
|
160
|
+
},
|
|
161
|
+
formItemProps: {
|
|
162
|
+
valuePropName: "fileList",
|
|
163
|
+
getValueFromEvent: normFile,
|
|
164
|
+
rules: [{ required: true, message: "请上传营业执照" }]
|
|
165
|
+
}
|
|
125
166
|
}
|
|
126
167
|
];
|
|
127
168
|
const totalText = "共@";
|
|
128
169
|
const unitText = "条@";
|
|
129
170
|
const jumpText = "跳至@";
|
|
130
171
|
const pageText = "页@";
|
|
131
|
-
const
|
|
132
|
-
|
|
172
|
+
const sm3key = "Aa123456#";
|
|
173
|
+
const msg = "username=admin×tamp=1758782465&modelid=19955BC7B61A43B3A982F0B2053ABC34";
|
|
174
|
+
HmacSM3.hmac(sm3key, msg);
|
|
133
175
|
return /* @__PURE__ */ jsxs("div", { style: { height: "100vh", display: "flex", flexDirection: "column", gap: 20 }, children: [
|
|
134
176
|
/* @__PURE__ */ jsx(BackHeader, { title: "页头组件", isBack: true }),
|
|
135
177
|
/* @__PURE__ */ jsxs(Flex, { gap: 20, align: "center", children: [
|
package/es/main.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ import * as utils from './utils/index';
|
|
|
16
16
|
import * as verfyCode from './utils/verify-code';
|
|
17
17
|
import AES from './utils/aes';
|
|
18
18
|
import HmacSHA512 from './utils/hmacSHA512';
|
|
19
|
-
import HmacSM3 from './utils/
|
|
19
|
+
import HmacSM3 from './utils/hmacSM3';
|
|
20
20
|
import useCaptcha from './hooks/useCaptcha';
|
|
21
21
|
import useChangePwd from './hooks/useChangePwd';
|
|
22
22
|
import useConfig from './hooks/useConfig';
|
package/es/main.js
CHANGED
|
@@ -16,7 +16,7 @@ import * as index from "./utils/index";
|
|
|
16
16
|
import * as verifyCode from "./utils/verify-code";
|
|
17
17
|
import { default as default13 } from "./utils/aes";
|
|
18
18
|
import { default as default14 } from "./utils/hmacSHA512";
|
|
19
|
-
import { default as default15 } from "./utils/
|
|
19
|
+
import { default as default15 } from "./utils/hmacSM3";
|
|
20
20
|
import { default as default16 } from "./hooks/useCaptcha";
|
|
21
21
|
import { default as default17 } from "./hooks/useChangePwd";
|
|
22
22
|
import { default as default18 } from "./hooks/useConfig";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HMAC-SM3 实现
|
|
3
|
+
*/
|
|
4
|
+
declare class HmacSM3 {
|
|
5
|
+
private key;
|
|
6
|
+
constructor(key: string | Uint8Array);
|
|
7
|
+
/**
|
|
8
|
+
* 计算HMAC-SM3值
|
|
9
|
+
*/
|
|
10
|
+
digest(message: string | Uint8Array): Uint8Array;
|
|
11
|
+
/**
|
|
12
|
+
* 计算HMAC-SM3值并返回十六进制字符串
|
|
13
|
+
*/
|
|
14
|
+
digestHex(message: string | Uint8Array): string;
|
|
15
|
+
/**
|
|
16
|
+
* 静态方法:快速计算HMAC-SM3
|
|
17
|
+
*/
|
|
18
|
+
static hmac(key: string | Uint8Array, message: string | Uint8Array): string;
|
|
19
|
+
}
|
|
20
|
+
export default HmacSM3;
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => {
|
|
4
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
return value;
|
|
6
|
+
};
|
|
7
|
+
const _SM3 = class {
|
|
8
|
+
static rotateLeft(x, n) {
|
|
9
|
+
return x << n | x >>> 32 - n;
|
|
10
|
+
}
|
|
11
|
+
static FFj(X, Y, Z, j) {
|
|
12
|
+
if (j >= 0 && j <= 15) {
|
|
13
|
+
return X ^ Y ^ Z;
|
|
14
|
+
} else {
|
|
15
|
+
return X & Y | X & Z | Y & Z;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
static GGj(X, Y, Z, j) {
|
|
19
|
+
if (j >= 0 && j <= 15) {
|
|
20
|
+
return X ^ Y ^ Z;
|
|
21
|
+
} else {
|
|
22
|
+
return X & Y | ~X & Z;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
static P0(X) {
|
|
26
|
+
return X ^ _SM3.rotateLeft(X, 9) ^ _SM3.rotateLeft(X, 17);
|
|
27
|
+
}
|
|
28
|
+
static P1(X) {
|
|
29
|
+
return X ^ _SM3.rotateLeft(X, 15) ^ _SM3.rotateLeft(X, 23);
|
|
30
|
+
}
|
|
31
|
+
static pad(message) {
|
|
32
|
+
const bitLength = message.length * 8;
|
|
33
|
+
const paddingLength = (448 - (bitLength + 1) % 512 + 512) % 512;
|
|
34
|
+
const totalLength = (bitLength + 1 + paddingLength + 64) / 8;
|
|
35
|
+
const padded = new Uint8Array(totalLength);
|
|
36
|
+
padded.set(message);
|
|
37
|
+
padded[message.length] = 128;
|
|
38
|
+
const lengthBytes = new Uint8Array(8);
|
|
39
|
+
const lengthView = new DataView(lengthBytes.buffer);
|
|
40
|
+
lengthView.setBigUint64(0, BigInt(bitLength), false);
|
|
41
|
+
padded.set(lengthBytes, totalLength - 8);
|
|
42
|
+
return padded;
|
|
43
|
+
}
|
|
44
|
+
static processBlock(block, state) {
|
|
45
|
+
const W = new Uint32Array(68);
|
|
46
|
+
const W1 = new Uint32Array(64);
|
|
47
|
+
for (let i = 0; i < 16; i++) {
|
|
48
|
+
const view = new DataView(block.buffer, block.byteOffset + i * 4, 4);
|
|
49
|
+
W[i] = view.getUint32(0, false);
|
|
50
|
+
}
|
|
51
|
+
for (let j = 16; j < 68; j++) {
|
|
52
|
+
W[j] = _SM3.P1(W[j - 16] ^ W[j - 9] ^ _SM3.rotateLeft(W[j - 3], 15)) ^ _SM3.rotateLeft(W[j - 13], 7) ^ W[j - 6];
|
|
53
|
+
}
|
|
54
|
+
for (let j = 0; j < 64; j++) {
|
|
55
|
+
W1[j] = W[j] ^ W[j + 4];
|
|
56
|
+
}
|
|
57
|
+
let A = state[0];
|
|
58
|
+
let B = state[1];
|
|
59
|
+
let C = state[2];
|
|
60
|
+
let D = state[3];
|
|
61
|
+
let E = state[4];
|
|
62
|
+
let F = state[5];
|
|
63
|
+
let G = state[6];
|
|
64
|
+
let H = state[7];
|
|
65
|
+
for (let j = 0; j < 64; j++) {
|
|
66
|
+
const SS1 = _SM3.rotateLeft(_SM3.rotateLeft(A, 12) + E + _SM3.rotateLeft(_SM3.T[j], j), 7);
|
|
67
|
+
const SS2 = SS1 ^ _SM3.rotateLeft(A, 12);
|
|
68
|
+
const TT1 = _SM3.FFj(A, B, C, j) + D + SS2 + W1[j];
|
|
69
|
+
const TT2 = _SM3.GGj(E, F, G, j) + H + SS1 + W[j];
|
|
70
|
+
D = C;
|
|
71
|
+
C = _SM3.rotateLeft(B, 9);
|
|
72
|
+
B = A;
|
|
73
|
+
A = TT1;
|
|
74
|
+
H = G;
|
|
75
|
+
G = _SM3.rotateLeft(F, 19);
|
|
76
|
+
F = E;
|
|
77
|
+
E = _SM3.P0(TT2);
|
|
78
|
+
}
|
|
79
|
+
state[0] ^= A;
|
|
80
|
+
state[1] ^= B;
|
|
81
|
+
state[2] ^= C;
|
|
82
|
+
state[3] ^= D;
|
|
83
|
+
state[4] ^= E;
|
|
84
|
+
state[5] ^= F;
|
|
85
|
+
state[6] ^= G;
|
|
86
|
+
state[7] ^= H;
|
|
87
|
+
}
|
|
88
|
+
static hash(message) {
|
|
89
|
+
const padded = _SM3.pad(message);
|
|
90
|
+
const state = new Uint32Array(_SM3.IV);
|
|
91
|
+
for (let i = 0; i < padded.length; i += 64) {
|
|
92
|
+
const block = padded.slice(i, i + 64);
|
|
93
|
+
_SM3.processBlock(block, state);
|
|
94
|
+
}
|
|
95
|
+
const result = new Uint8Array(32);
|
|
96
|
+
const resultView = new DataView(result.buffer);
|
|
97
|
+
for (let i = 0; i < 8; i++) {
|
|
98
|
+
resultView.setUint32(i * 4, state[i], false);
|
|
99
|
+
}
|
|
100
|
+
return result;
|
|
101
|
+
}
|
|
102
|
+
static hashHex(message) {
|
|
103
|
+
const msgArray = typeof message === "string" ? new TextEncoder().encode(message) : message;
|
|
104
|
+
const hashBytes = _SM3.hash(msgArray);
|
|
105
|
+
return Array.from(hashBytes).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
let SM3 = _SM3;
|
|
109
|
+
__publicField(SM3, "IV", new Uint32Array([
|
|
110
|
+
1937774191,
|
|
111
|
+
1226093241,
|
|
112
|
+
388252375,
|
|
113
|
+
3666478592,
|
|
114
|
+
2842636476,
|
|
115
|
+
372324522,
|
|
116
|
+
3817729613,
|
|
117
|
+
2969243214
|
|
118
|
+
]));
|
|
119
|
+
__publicField(SM3, "T", new Uint32Array(64));
|
|
120
|
+
(() => {
|
|
121
|
+
for (let j = 0; j < 16; j++) {
|
|
122
|
+
_SM3.T[j] = 2043430169;
|
|
123
|
+
}
|
|
124
|
+
for (let j = 16; j < 64; j++) {
|
|
125
|
+
_SM3.T[j] = 2055708042;
|
|
126
|
+
}
|
|
127
|
+
})();
|
|
128
|
+
class HmacSM3 {
|
|
129
|
+
constructor(key) {
|
|
130
|
+
__publicField(this, "key");
|
|
131
|
+
this.key = typeof key === "string" ? new TextEncoder().encode(key) : key;
|
|
132
|
+
}
|
|
133
|
+
digest(message) {
|
|
134
|
+
const msgArray = typeof message === "string" ? new TextEncoder().encode(message) : message;
|
|
135
|
+
const blockSize = 64;
|
|
136
|
+
let keyBuffer;
|
|
137
|
+
if (this.key.length > blockSize) {
|
|
138
|
+
keyBuffer = SM3.hash(this.key);
|
|
139
|
+
} else {
|
|
140
|
+
keyBuffer = new Uint8Array(blockSize);
|
|
141
|
+
keyBuffer.set(this.key);
|
|
142
|
+
for (let i = this.key.length; i < blockSize; i++) {
|
|
143
|
+
keyBuffer[i] = 0;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
const ipadKey = new Uint8Array(blockSize);
|
|
147
|
+
const opadKey = new Uint8Array(blockSize);
|
|
148
|
+
for (let i = 0; i < blockSize; i++) {
|
|
149
|
+
ipadKey[i] = keyBuffer[i] ^ 54;
|
|
150
|
+
opadKey[i] = keyBuffer[i] ^ 92;
|
|
151
|
+
}
|
|
152
|
+
const innerData = new Uint8Array(ipadKey.length + msgArray.length);
|
|
153
|
+
innerData.set(ipadKey);
|
|
154
|
+
innerData.set(msgArray, ipadKey.length);
|
|
155
|
+
const innerHash = SM3.hash(innerData);
|
|
156
|
+
const outerData = new Uint8Array(opadKey.length + innerHash.length);
|
|
157
|
+
outerData.set(opadKey);
|
|
158
|
+
outerData.set(innerHash, opadKey.length);
|
|
159
|
+
const finalHash = SM3.hash(outerData);
|
|
160
|
+
return finalHash;
|
|
161
|
+
}
|
|
162
|
+
digestHex(message) {
|
|
163
|
+
const hashBytes = this.digest(message);
|
|
164
|
+
return Array.from(hashBytes).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
165
|
+
}
|
|
166
|
+
static hmac(key, message) {
|
|
167
|
+
const hmac = new HmacSM3(key);
|
|
168
|
+
return hmac.digestHex(message);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
export {
|
|
172
|
+
HmacSM3 as default
|
|
173
|
+
};
|
|
@@ -50,6 +50,7 @@ interface FormFieldsProps extends Pick<CreateFormItemProps<ValueType>, "valueTyp
|
|
|
50
50
|
value?: any;
|
|
51
51
|
onBtnClick?: (e: React.MouseEvent<HTMLElement, MouseEvent>, item: ValueBtnProps) => void;
|
|
52
52
|
inputRef?: any;
|
|
53
|
+
formItemProps?: FormItemProps;
|
|
53
54
|
}
|
|
54
55
|
export declare const FormFields: (props: FormFieldsProps) => React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
55
56
|
export default CreateForm;
|
|
@@ -102,7 +102,8 @@ const CreateForm = (props) => {
|
|
|
102
102
|
},
|
|
103
103
|
valueType: item.valueType,
|
|
104
104
|
onBtnClick,
|
|
105
|
-
valueProps: item.valueProps
|
|
105
|
+
valueProps: item.valueProps,
|
|
106
|
+
formItemProps: item.formItemProps
|
|
106
107
|
}
|
|
107
108
|
)
|
|
108
109
|
}
|
|
@@ -114,7 +115,7 @@ const CreateForm = (props) => {
|
|
|
114
115
|
);
|
|
115
116
|
};
|
|
116
117
|
const FormFields = (props) => {
|
|
117
|
-
const { valueType, valueProps, value, onChange, onBtnClick, inputRef } = props;
|
|
118
|
+
const { valueType, valueProps, value, onChange, onBtnClick, inputRef, formItemProps } = props;
|
|
118
119
|
const children = React.useMemo(() => {
|
|
119
120
|
let result = /* @__PURE__ */ jsxRuntime.jsx(antd.Input, { placeholder: "请输入", allowClear: true, ...valueProps });
|
|
120
121
|
switch (valueType) {
|
|
@@ -228,7 +229,7 @@ const FormFields = (props) => {
|
|
|
228
229
|
if (valueType === "custom") {
|
|
229
230
|
const params = valueProps;
|
|
230
231
|
return React.cloneElement(params.children, {
|
|
231
|
-
[getValuePropName(valueType || "input")]: value,
|
|
232
|
+
[(formItemProps == null ? void 0 : formItemProps.valuePropName) || getValuePropName(valueType || "input")]: value,
|
|
232
233
|
onChange,
|
|
233
234
|
ref: inputRef
|
|
234
235
|
});
|
package/lib/index.js
CHANGED
|
@@ -67,6 +67,29 @@ const Demo = () => {
|
|
|
67
67
|
]
|
|
68
68
|
}
|
|
69
69
|
];
|
|
70
|
+
const imgAccept = ".jpg,.png,.jpeg";
|
|
71
|
+
const imgUploadProps = {
|
|
72
|
+
maxCount: 1,
|
|
73
|
+
action: "uploadAction",
|
|
74
|
+
accept: imgAccept,
|
|
75
|
+
showUploadList: false,
|
|
76
|
+
beforeUpload(file) {
|
|
77
|
+
var _a;
|
|
78
|
+
const accepts = imgAccept.split(",");
|
|
79
|
+
const fileType = (_a = file.name.split(".").pop()) == null ? void 0 : _a.toLocaleLowerCase();
|
|
80
|
+
if (!accepts.includes(`.${fileType}`)) {
|
|
81
|
+
antd.message.error(`只允许上传${accepts.join("、")}文件`);
|
|
82
|
+
return antd.Upload.LIST_IGNORE;
|
|
83
|
+
}
|
|
84
|
+
return file;
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
const normFile = (e) => {
|
|
88
|
+
if (Array.isArray(e)) {
|
|
89
|
+
return e;
|
|
90
|
+
}
|
|
91
|
+
return e && e.fileList;
|
|
92
|
+
};
|
|
70
93
|
const formItems = [
|
|
71
94
|
{
|
|
72
95
|
dataIndex: "asctypeid",
|
|
@@ -123,14 +146,33 @@ const Demo = () => {
|
|
|
123
146
|
colProps: {
|
|
124
147
|
span: 11
|
|
125
148
|
}
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
dataIndex: "fileList",
|
|
152
|
+
title: "营业执照",
|
|
153
|
+
valueType: "custom",
|
|
154
|
+
valueProps: {
|
|
155
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(antd.Upload, { ...imgUploadProps, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { children: "上传营业执照" }) }),
|
|
156
|
+
fileList: form.getFieldValue("fileList")
|
|
157
|
+
},
|
|
158
|
+
colProps: {
|
|
159
|
+
md: 24,
|
|
160
|
+
xl: 10
|
|
161
|
+
},
|
|
162
|
+
formItemProps: {
|
|
163
|
+
valuePropName: "fileList",
|
|
164
|
+
getValueFromEvent: normFile,
|
|
165
|
+
rules: [{ required: true, message: "请上传营业执照" }]
|
|
166
|
+
}
|
|
126
167
|
}
|
|
127
168
|
];
|
|
128
169
|
const totalText = "共@";
|
|
129
170
|
const unitText = "条@";
|
|
130
171
|
const jumpText = "跳至@";
|
|
131
172
|
const pageText = "页@";
|
|
132
|
-
const
|
|
133
|
-
|
|
173
|
+
const sm3key = "Aa123456#";
|
|
174
|
+
const msg = "username=admin×tamp=1758782465&modelid=19955BC7B61A43B3A982F0B2053ABC34";
|
|
175
|
+
main.HmacSM3.hmac(sm3key, msg);
|
|
134
176
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { height: "100vh", display: "flex", flexDirection: "column", gap: 20 }, children: [
|
|
135
177
|
/* @__PURE__ */ jsxRuntime.jsx(main.BackHeader, { title: "页头组件", isBack: true }),
|
|
136
178
|
/* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { gap: 20, align: "center", children: [
|
package/lib/main.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ import * as utils from './utils/index';
|
|
|
16
16
|
import * as verfyCode from './utils/verify-code';
|
|
17
17
|
import AES from './utils/aes';
|
|
18
18
|
import HmacSHA512 from './utils/hmacSHA512';
|
|
19
|
-
import HmacSM3 from './utils/
|
|
19
|
+
import HmacSM3 from './utils/hmacSM3';
|
|
20
20
|
import useCaptcha from './hooks/useCaptcha';
|
|
21
21
|
import useChangePwd from './hooks/useChangePwd';
|
|
22
22
|
import useConfig from './hooks/useConfig';
|
package/lib/main.js
CHANGED
|
@@ -18,7 +18,7 @@ const index = require("./utils/index");
|
|
|
18
18
|
const verifyCode = require("./utils/verify-code");
|
|
19
19
|
const aes = require("./utils/aes");
|
|
20
20
|
const hmacSHA512 = require("./utils/hmacSHA512");
|
|
21
|
-
const
|
|
21
|
+
const hmacSM3 = require("./utils/hmacSM3");
|
|
22
22
|
const useCaptcha = require("./hooks/useCaptcha");
|
|
23
23
|
const useChangePwd = require("./hooks/useChangePwd");
|
|
24
24
|
const useConfig = require("./hooks/useConfig");
|
|
@@ -67,7 +67,7 @@ exports.utils = index__namespace;
|
|
|
67
67
|
exports.verfyCode = verifyCode__namespace;
|
|
68
68
|
exports.AES = aes;
|
|
69
69
|
exports.HmacSHA512 = hmacSHA512;
|
|
70
|
-
exports.HmacSM3 =
|
|
70
|
+
exports.HmacSM3 = hmacSM3;
|
|
71
71
|
exports.useCaptcha = useCaptcha;
|
|
72
72
|
exports.useChangePwd = useChangePwd;
|
|
73
73
|
exports.useConfig = useConfig;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HMAC-SM3 实现
|
|
3
|
+
*/
|
|
4
|
+
declare class HmacSM3 {
|
|
5
|
+
private key;
|
|
6
|
+
constructor(key: string | Uint8Array);
|
|
7
|
+
/**
|
|
8
|
+
* 计算HMAC-SM3值
|
|
9
|
+
*/
|
|
10
|
+
digest(message: string | Uint8Array): Uint8Array;
|
|
11
|
+
/**
|
|
12
|
+
* 计算HMAC-SM3值并返回十六进制字符串
|
|
13
|
+
*/
|
|
14
|
+
digestHex(message: string | Uint8Array): string;
|
|
15
|
+
/**
|
|
16
|
+
* 静态方法:快速计算HMAC-SM3
|
|
17
|
+
*/
|
|
18
|
+
static hmac(key: string | Uint8Array, message: string | Uint8Array): string;
|
|
19
|
+
}
|
|
20
|
+
export default HmacSM3;
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
|
+
var __publicField = (obj, key, value) => {
|
|
5
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
6
|
+
return value;
|
|
7
|
+
};
|
|
8
|
+
const _SM3 = class {
|
|
9
|
+
static rotateLeft(x, n) {
|
|
10
|
+
return x << n | x >>> 32 - n;
|
|
11
|
+
}
|
|
12
|
+
static FFj(X, Y, Z, j) {
|
|
13
|
+
if (j >= 0 && j <= 15) {
|
|
14
|
+
return X ^ Y ^ Z;
|
|
15
|
+
} else {
|
|
16
|
+
return X & Y | X & Z | Y & Z;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
static GGj(X, Y, Z, j) {
|
|
20
|
+
if (j >= 0 && j <= 15) {
|
|
21
|
+
return X ^ Y ^ Z;
|
|
22
|
+
} else {
|
|
23
|
+
return X & Y | ~X & Z;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
static P0(X) {
|
|
27
|
+
return X ^ _SM3.rotateLeft(X, 9) ^ _SM3.rotateLeft(X, 17);
|
|
28
|
+
}
|
|
29
|
+
static P1(X) {
|
|
30
|
+
return X ^ _SM3.rotateLeft(X, 15) ^ _SM3.rotateLeft(X, 23);
|
|
31
|
+
}
|
|
32
|
+
static pad(message) {
|
|
33
|
+
const bitLength = message.length * 8;
|
|
34
|
+
const paddingLength = (448 - (bitLength + 1) % 512 + 512) % 512;
|
|
35
|
+
const totalLength = (bitLength + 1 + paddingLength + 64) / 8;
|
|
36
|
+
const padded = new Uint8Array(totalLength);
|
|
37
|
+
padded.set(message);
|
|
38
|
+
padded[message.length] = 128;
|
|
39
|
+
const lengthBytes = new Uint8Array(8);
|
|
40
|
+
const lengthView = new DataView(lengthBytes.buffer);
|
|
41
|
+
lengthView.setBigUint64(0, BigInt(bitLength), false);
|
|
42
|
+
padded.set(lengthBytes, totalLength - 8);
|
|
43
|
+
return padded;
|
|
44
|
+
}
|
|
45
|
+
static processBlock(block, state) {
|
|
46
|
+
const W = new Uint32Array(68);
|
|
47
|
+
const W1 = new Uint32Array(64);
|
|
48
|
+
for (let i = 0; i < 16; i++) {
|
|
49
|
+
const view = new DataView(block.buffer, block.byteOffset + i * 4, 4);
|
|
50
|
+
W[i] = view.getUint32(0, false);
|
|
51
|
+
}
|
|
52
|
+
for (let j = 16; j < 68; j++) {
|
|
53
|
+
W[j] = _SM3.P1(W[j - 16] ^ W[j - 9] ^ _SM3.rotateLeft(W[j - 3], 15)) ^ _SM3.rotateLeft(W[j - 13], 7) ^ W[j - 6];
|
|
54
|
+
}
|
|
55
|
+
for (let j = 0; j < 64; j++) {
|
|
56
|
+
W1[j] = W[j] ^ W[j + 4];
|
|
57
|
+
}
|
|
58
|
+
let A = state[0];
|
|
59
|
+
let B = state[1];
|
|
60
|
+
let C = state[2];
|
|
61
|
+
let D = state[3];
|
|
62
|
+
let E = state[4];
|
|
63
|
+
let F = state[5];
|
|
64
|
+
let G = state[6];
|
|
65
|
+
let H = state[7];
|
|
66
|
+
for (let j = 0; j < 64; j++) {
|
|
67
|
+
const SS1 = _SM3.rotateLeft(_SM3.rotateLeft(A, 12) + E + _SM3.rotateLeft(_SM3.T[j], j), 7);
|
|
68
|
+
const SS2 = SS1 ^ _SM3.rotateLeft(A, 12);
|
|
69
|
+
const TT1 = _SM3.FFj(A, B, C, j) + D + SS2 + W1[j];
|
|
70
|
+
const TT2 = _SM3.GGj(E, F, G, j) + H + SS1 + W[j];
|
|
71
|
+
D = C;
|
|
72
|
+
C = _SM3.rotateLeft(B, 9);
|
|
73
|
+
B = A;
|
|
74
|
+
A = TT1;
|
|
75
|
+
H = G;
|
|
76
|
+
G = _SM3.rotateLeft(F, 19);
|
|
77
|
+
F = E;
|
|
78
|
+
E = _SM3.P0(TT2);
|
|
79
|
+
}
|
|
80
|
+
state[0] ^= A;
|
|
81
|
+
state[1] ^= B;
|
|
82
|
+
state[2] ^= C;
|
|
83
|
+
state[3] ^= D;
|
|
84
|
+
state[4] ^= E;
|
|
85
|
+
state[5] ^= F;
|
|
86
|
+
state[6] ^= G;
|
|
87
|
+
state[7] ^= H;
|
|
88
|
+
}
|
|
89
|
+
static hash(message) {
|
|
90
|
+
const padded = _SM3.pad(message);
|
|
91
|
+
const state = new Uint32Array(_SM3.IV);
|
|
92
|
+
for (let i = 0; i < padded.length; i += 64) {
|
|
93
|
+
const block = padded.slice(i, i + 64);
|
|
94
|
+
_SM3.processBlock(block, state);
|
|
95
|
+
}
|
|
96
|
+
const result = new Uint8Array(32);
|
|
97
|
+
const resultView = new DataView(result.buffer);
|
|
98
|
+
for (let i = 0; i < 8; i++) {
|
|
99
|
+
resultView.setUint32(i * 4, state[i], false);
|
|
100
|
+
}
|
|
101
|
+
return result;
|
|
102
|
+
}
|
|
103
|
+
static hashHex(message) {
|
|
104
|
+
const msgArray = typeof message === "string" ? new TextEncoder().encode(message) : message;
|
|
105
|
+
const hashBytes = _SM3.hash(msgArray);
|
|
106
|
+
return Array.from(hashBytes).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
let SM3 = _SM3;
|
|
110
|
+
__publicField(SM3, "IV", new Uint32Array([
|
|
111
|
+
1937774191,
|
|
112
|
+
1226093241,
|
|
113
|
+
388252375,
|
|
114
|
+
3666478592,
|
|
115
|
+
2842636476,
|
|
116
|
+
372324522,
|
|
117
|
+
3817729613,
|
|
118
|
+
2969243214
|
|
119
|
+
]));
|
|
120
|
+
__publicField(SM3, "T", new Uint32Array(64));
|
|
121
|
+
(() => {
|
|
122
|
+
for (let j = 0; j < 16; j++) {
|
|
123
|
+
_SM3.T[j] = 2043430169;
|
|
124
|
+
}
|
|
125
|
+
for (let j = 16; j < 64; j++) {
|
|
126
|
+
_SM3.T[j] = 2055708042;
|
|
127
|
+
}
|
|
128
|
+
})();
|
|
129
|
+
class HmacSM3 {
|
|
130
|
+
constructor(key) {
|
|
131
|
+
__publicField(this, "key");
|
|
132
|
+
this.key = typeof key === "string" ? new TextEncoder().encode(key) : key;
|
|
133
|
+
}
|
|
134
|
+
digest(message) {
|
|
135
|
+
const msgArray = typeof message === "string" ? new TextEncoder().encode(message) : message;
|
|
136
|
+
const blockSize = 64;
|
|
137
|
+
let keyBuffer;
|
|
138
|
+
if (this.key.length > blockSize) {
|
|
139
|
+
keyBuffer = SM3.hash(this.key);
|
|
140
|
+
} else {
|
|
141
|
+
keyBuffer = new Uint8Array(blockSize);
|
|
142
|
+
keyBuffer.set(this.key);
|
|
143
|
+
for (let i = this.key.length; i < blockSize; i++) {
|
|
144
|
+
keyBuffer[i] = 0;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
const ipadKey = new Uint8Array(blockSize);
|
|
148
|
+
const opadKey = new Uint8Array(blockSize);
|
|
149
|
+
for (let i = 0; i < blockSize; i++) {
|
|
150
|
+
ipadKey[i] = keyBuffer[i] ^ 54;
|
|
151
|
+
opadKey[i] = keyBuffer[i] ^ 92;
|
|
152
|
+
}
|
|
153
|
+
const innerData = new Uint8Array(ipadKey.length + msgArray.length);
|
|
154
|
+
innerData.set(ipadKey);
|
|
155
|
+
innerData.set(msgArray, ipadKey.length);
|
|
156
|
+
const innerHash = SM3.hash(innerData);
|
|
157
|
+
const outerData = new Uint8Array(opadKey.length + innerHash.length);
|
|
158
|
+
outerData.set(opadKey);
|
|
159
|
+
outerData.set(innerHash, opadKey.length);
|
|
160
|
+
const finalHash = SM3.hash(outerData);
|
|
161
|
+
return finalHash;
|
|
162
|
+
}
|
|
163
|
+
digestHex(message) {
|
|
164
|
+
const hashBytes = this.digest(message);
|
|
165
|
+
return Array.from(hashBytes).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
166
|
+
}
|
|
167
|
+
static hmac(key, message) {
|
|
168
|
+
const hmac = new HmacSM3(key);
|
|
169
|
+
return hmac.digestHex(message);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
module.exports = HmacSM3;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "szld-libs",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.51",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"dev": "vite",
|
|
@@ -18,8 +18,7 @@
|
|
|
18
18
|
"react-dom": "^18.2.0",
|
|
19
19
|
"react-resizable": "^3.0.5",
|
|
20
20
|
"react-router-dom": "^6.6.1",
|
|
21
|
-
"react-window": "^1.8.9"
|
|
22
|
-
"sm-crypto": "^0.3.13"
|
|
21
|
+
"react-window": "^1.8.9"
|
|
23
22
|
},
|
|
24
23
|
"devDependencies": {
|
|
25
24
|
"@types/crypto-js": "^4.2.1",
|