namirasoft-site-react 1.4.477 → 1.4.479
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/App.d.ts +1 -1
- package/dist/App.js +16 -45
- package/dist/App.js.map +1 -1
- package/dist/EncryptionOperation.d.ts +6 -0
- package/dist/EncryptionOperation.js +67 -0
- package/dist/EncryptionOperation.js.map +1 -0
- package/dist/components/NSDialogBoxString.d.ts +10 -0
- package/dist/components/NSDialogBoxString.js +14 -0
- package/dist/components/NSDialogBoxString.js.map +1 -0
- package/dist/main.d.ts +2 -0
- package/dist/main.js +2 -0
- package/dist/main.js.map +1 -1
- package/package.json +3 -3
- package/src/App.tsx +25 -46
- package/src/EncryptionOperation.ts +101 -0
- package/src/components/NSDialogBoxString.tsx +28 -0
- package/src/main.ts +2 -0
package/dist/App.d.ts
CHANGED
package/dist/App.js
CHANGED
|
@@ -1,22 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
2
|
import 'bootstrap/dist/css/bootstrap.min.css';
|
|
12
3
|
import { Component } from 'react';
|
|
13
4
|
import './App.css';
|
|
14
5
|
import { NSLayout } from './components/NSLayout';
|
|
15
|
-
import {
|
|
6
|
+
import { NSButtonBlue, NSDialogBoxString, NSRow } from './main';
|
|
16
7
|
export class App extends Component {
|
|
17
8
|
constructor(props) {
|
|
18
9
|
super(props);
|
|
19
|
-
this.state = {
|
|
10
|
+
this.state = { show_dialog: false };
|
|
20
11
|
}
|
|
21
12
|
render() {
|
|
22
13
|
return (_jsx(NSLayout, { header: {
|
|
@@ -29,40 +20,20 @@ export class App extends Component {
|
|
|
29
20
|
}
|
|
30
21
|
],
|
|
31
22
|
}
|
|
32
|
-
}, isLoggedIn: () => true, logo: 'https://static.namirasoft.com/image/namirasoft/access/logo/base.png', background: { image: "https://static.namirasoft.com/image/namirasoft/access/background/base.svg" }, notifications: [], notifier: {}, scope: '', children: _jsxs(NSRow, { children: [_jsx(
|
|
23
|
+
}, isLoggedIn: () => true, logo: 'https://static.namirasoft.com/image/namirasoft/access/logo/base.png', background: { image: "https://static.namirasoft.com/image/namirasoft/access/background/base.svg" }, notifications: [], notifier: {}, scope: '', children: _jsxs(NSRow, { children: [_jsx(NSButtonBlue, { title: "Show NSDialogBoxString", onClick: {
|
|
33
24
|
showLoading: false,
|
|
34
|
-
action: () => this.setState((prev) => (Object.assign(Object.assign({}, prev), {
|
|
35
|
-
} }),
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
{ id: "a8", first_name: "Fatemeh", last_name: "Jafari", gender: "Female", age: 30, phone: "09361234589", email: "fatemeh.jafari@example.com", bio: "Interested in psychology and self-development, spends." },
|
|
47
|
-
{ id: "a9", first_name: "Mohammad", last_name: "Esfandiari", gender: "Male", age: 33, phone: "09162348752", email: "mohammad.esfandiari@example.com", bio: "Specialized in marketing strategies, creative thinker." },
|
|
48
|
-
{ id: "b1", first_name: "Elham", last_name: "Khosravi", gender: "Female", age: 25, phone: "09203456781", email: "elham.khosravi@example.com", bio: "Graphic designer with a flair for modern art." },
|
|
49
|
-
{ id: "b2", first_name: "Mohammad", last_name: "Esfandiari", gender: "Male", age: 33, phone: "09162348752", email: "mohammad.esfandiari@example.com", bio: "Specialized in marketing strategies, creative thinker." },
|
|
50
|
-
{ id: "b3", first_name: "Elham", last_name: "Khosravi", gender: "Female", age: 25, phone: "09203456781", email: "elham.khosravi@example.com", bio: "Graphic designer with a flair for modern art." },
|
|
51
|
-
]
|
|
52
|
-
});
|
|
53
|
-
}), getRowKey: (item) => item.value.id, columns: [
|
|
54
|
-
{ index: 0, name: "id", text: "ID", table: { name: "users", text: "users" }, formatter: new StringFormatter(StringFormatterSizeType.Word) },
|
|
55
|
-
{ index: 1, name: "first_name", text: "First Name", table: { name: "users", text: "users" }, formatter: new StringFormatter(StringFormatterSizeType.TwoWords) },
|
|
56
|
-
{ index: 2, name: "last_name", text: "Last Name", table: { name: "users", text: "users" }, formatter: new StringFormatter(StringFormatterSizeType.TwoWords) },
|
|
57
|
-
{ index: 3, name: "gender", text: "Gender", table: { name: "users", text: "users" }, formatter: new StringFormatter(StringFormatterSizeType.TwoWords) },
|
|
58
|
-
{ index: 4, name: "age", text: "Age", table: { name: "users", text: "users" }, formatter: new IntegerFormatter() },
|
|
59
|
-
{ index: 5, name: "phone", text: "Phone Number", table: { name: "users", text: "users" }, formatter: new PhoneFormatter() },
|
|
60
|
-
{ index: 6, name: "email", text: "Email Address", table: { name: "users", text: "users" }, formatter: new EmailFormatter() },
|
|
61
|
-
{ index: 7, name: "bio", text: "Bio", table: { name: "users", text: "users" }, formatter: new StringFormatter(StringFormatterSizeType.Description) },
|
|
62
|
-
], ui: {
|
|
63
|
-
pagination: this.state.hide_footer,
|
|
64
|
-
button_panel: this.state.hide_footer,
|
|
65
|
-
} }) })] }) }));
|
|
25
|
+
action: () => this.setState((prev) => (Object.assign(Object.assign({}, prev), { show_dialog: true }))),
|
|
26
|
+
} }), this.state.show_dialog &&
|
|
27
|
+
_jsx(NSDialogBoxString, { box: {
|
|
28
|
+
required: true,
|
|
29
|
+
title: "Title"
|
|
30
|
+
}, onClose: () => this.setState((prev) => (Object.assign(Object.assign({}, prev), { show_dialog: false }))), button: {
|
|
31
|
+
title: "Apply",
|
|
32
|
+
onClick: {
|
|
33
|
+
showLoading: false,
|
|
34
|
+
action: () => { }
|
|
35
|
+
}
|
|
36
|
+
}, children: _jsx(_Fragment, {}) })] }) }));
|
|
66
37
|
}
|
|
67
38
|
}
|
|
68
39
|
//# sourceMappingURL=App.js.map
|
package/dist/App.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"App.js","sourceRoot":"","sources":["../src/App.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"App.js","sourceRoot":"","sources":["../src/App.tsx"],"names":[],"mappings":";AAAA,OAAO,sCAAsC,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,WAAW,CAAC;AACnB,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAShE,MAAM,OAAO,GAAI,SAAQ,SAA6B;IAElD,YAAY,KAAe;QAEvB,KAAK,CAAC,KAAK,CAAC,CAAC;QACb,IAAI,CAAC,KAAK,GAAG,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC;IACxC,CAAC;IAEQ,MAAM;QAEX,OAAO,CACH,KAAC,QAAQ,IACL,MAAM,EAAE;gBACJ,KAAK,EAAE;oBACH,KAAK,EAAE;wBACH;4BACI,SAAS,EAAE,GAAG,EAAE,GAAG,CAAC;4BACpB,GAAG,EAAE,qEAAqE;4BAC1E,KAAK,EAAE,CAAC;yBACX;qBACJ;iBACJ;aACJ,EACD,UAAU,EAAE,GAAG,EAAE,CAAC,IAAI,EACtB,IAAI,EAAC,qEAAqE,EAC1E,UAAU,EAAE,EAAE,KAAK,EAAE,2EAA2E,EAAE,EAClG,aAAa,EAAE,EAAE,EACjB,QAAQ,EAAE,EAAS,EACnB,KAAK,EAAC,EAAE,YAER,MAAC,KAAK,eACF,KAAC,YAAY,IACT,KAAK,EAAC,wBAAwB,EAC9B,OAAO,EAAE;4BACL,WAAW,EAAE,KAAK;4BAClB,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,iCAAM,IAAI,KAAE,WAAW,EAAE,IAAI,IAAG,CAAC;yBAC1E,GACH,EAEE,IAAI,CAAC,KAAK,CAAC,WAAW;wBACtB,KAAC,iBAAiB,IACd,GAAG,EAAE;gCACD,QAAQ,EAAE,IAAI;gCACd,KAAK,EAAE,OAAO;6BACjB,EACD,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,iCAAM,IAAI,KAAE,WAAW,EAAE,KAAK,IAAG,CAAC,EACzE,MAAM,EAAE;gCACJ,KAAK,EAAE,OAAO;gCACd,OAAO,EAAE;oCACL,WAAW,EAAE,KAAK;oCAClB,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC;iCACpB;6BACJ,YAED,mBAAK,GACW,IAEpB,GACD,CACd,CAAC;IACN,CAAC;CACJ"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import * as crypto from 'node:crypto';
|
|
11
|
+
export class EncryptionOperation {
|
|
12
|
+
static encrypt(algorithm, secret, message) {
|
|
13
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
14
|
+
if (secret.length != 32)
|
|
15
|
+
throw new Error("Secret length must be exactly 32");
|
|
16
|
+
const enc = new TextEncoder();
|
|
17
|
+
const salt = crypto.getRandomValues(new Uint8Array(16));
|
|
18
|
+
const keyMaterial = yield crypto.subtle.importKey("raw", enc.encode(secret), { name: "PBKDF2" }, false, ["deriveKey"]);
|
|
19
|
+
const key = yield crypto.subtle.deriveKey({
|
|
20
|
+
name: "PBKDF2",
|
|
21
|
+
salt,
|
|
22
|
+
iterations: 100000,
|
|
23
|
+
hash: "SHA-256",
|
|
24
|
+
}, keyMaterial, { name: algorithm, length: 256 }, true, ["encrypt"]);
|
|
25
|
+
const iv = crypto.getRandomValues(new Uint8Array(12));
|
|
26
|
+
const cipherText = yield crypto.subtle.encrypt({
|
|
27
|
+
name: algorithm,
|
|
28
|
+
iv,
|
|
29
|
+
}, key, enc.encode(JSON.stringify(message)));
|
|
30
|
+
const combined = new Uint8Array([...salt, ...iv, ...new Uint8Array(cipherText)]);
|
|
31
|
+
return btoa(String.fromCharCode(...combined));
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
static decrypt(algorithm, secret, message) {
|
|
35
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
+
const data = Uint8Array.from(atob(message), c => c.charCodeAt(0));
|
|
37
|
+
const salt = data.slice(0, 16);
|
|
38
|
+
const iv = data.slice(16, 28);
|
|
39
|
+
const cipherText = data.slice(28);
|
|
40
|
+
const enc = new TextEncoder();
|
|
41
|
+
const dec = new TextDecoder();
|
|
42
|
+
const keyMaterial = yield crypto.subtle.importKey("raw", enc.encode(secret), { name: "PBKDF2" }, false, ["deriveKey"]);
|
|
43
|
+
const key = yield crypto.subtle.deriveKey({
|
|
44
|
+
name: "PBKDF2",
|
|
45
|
+
salt,
|
|
46
|
+
iterations: 100000,
|
|
47
|
+
hash: "SHA-256",
|
|
48
|
+
}, keyMaterial, { name: algorithm, length: 256 }, true, ["decrypt"]);
|
|
49
|
+
const decrypted = yield crypto.subtle.decrypt({
|
|
50
|
+
name: algorithm,
|
|
51
|
+
iv,
|
|
52
|
+
}, key, cipherText);
|
|
53
|
+
return JSON.parse(dec.decode(decrypted));
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
static AES256GCMEncrypt(secret, message) {
|
|
57
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
58
|
+
return EncryptionOperation.encrypt("AES-GCM", secret, message);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
static AES256GCMDecrypt(secret, message) {
|
|
62
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
return EncryptionOperation.decrypt("AES-GCM", secret, message);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=EncryptionOperation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EncryptionOperation.js","sourceRoot":"","sources":["../src/EncryptionOperation.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAEtC,MAAM,OAAO,mBAAmB;IAEpB,MAAM,CAAO,OAAO,CAAI,SAAiB,EAAE,MAAc,EAAE,OAAU;;YAEzE,IAAI,MAAM,CAAC,MAAM,IAAI,EAAE;gBACnB,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;YACxD,MAAM,GAAG,GAAG,IAAI,WAAW,EAAE,CAAC;YAG9B,MAAM,IAAI,GAAG,MAAM,CAAC,eAAe,CAAC,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC;YACxD,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,SAAS,CAC7C,KAAK,EACL,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,EAClB,EAAE,IAAI,EAAE,QAAQ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
import { Component } from 'react';
|
|
2
|
+
import { INSDialogBoxBaseProps } from "./NSDialogBox";
|
|
3
|
+
import { NSBoxString, NSBoxStringProps } from './NSBoxString';
|
|
4
|
+
export interface NSDialogBoxStringProps extends INSDialogBoxBaseProps<NSBoxString> {
|
|
5
|
+
box: NSBoxStringProps;
|
|
6
|
+
}
|
|
7
|
+
export declare class NSDialogBoxString extends Component<NSDialogBoxStringProps> {
|
|
8
|
+
private NSBoxString_Ref;
|
|
9
|
+
render(): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Component, createRef } from 'react';
|
|
3
|
+
import { NSDialogBox } from "./NSDialogBox";
|
|
4
|
+
import { NSBoxString } from './NSBoxString';
|
|
5
|
+
export class NSDialogBoxString extends Component {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(...arguments);
|
|
8
|
+
this.NSBoxString_Ref = createRef();
|
|
9
|
+
}
|
|
10
|
+
render() {
|
|
11
|
+
return (_jsx(NSDialogBox, Object.assign({}, this.props, { children_ref: this.NSBoxString_Ref, children: _jsx(NSBoxString, Object.assign({}, this.props.box, { ref: this.NSBoxString_Ref })) })));
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=NSDialogBoxString.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NSDialogBoxString.js","sourceRoot":"","sources":["../../src/components/NSDialogBoxString.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAyB,WAAW,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,EAAE,WAAW,EAAoB,MAAM,eAAe,CAAC;AAO9D,MAAM,OAAO,iBAAkB,SAAQ,SAAiC;IAAxE;;QAEY,oBAAe,GAAG,SAAS,EAAe,CAAC;IAgBvD,CAAC;IAdY,MAAM;QAEX,OAAO,CACH,KAAC,WAAW,oBACJ,IAAI,CAAC,KAAK,IACd,YAAY,EAAE,IAAI,CAAC,eAAe,YAElC,KAAC,WAAW,oBACJ,IAAI,CAAC,KAAK,CAAC,GAAG,IAClB,GAAG,EAAE,IAAI,CAAC,eAAe,IAC3B,IACQ,CACjB,CAAC;IACN,CAAC;CACJ"}
|
package/dist/main.d.ts
CHANGED
|
@@ -59,6 +59,7 @@ export * from "./components/NSDialogBox";
|
|
|
59
59
|
export * from "./components/NSDialogBoxDate";
|
|
60
60
|
export * from "./components/NSDialogBoxDateTime";
|
|
61
61
|
export * from "./components/NSDialogBoxPhone";
|
|
62
|
+
export * from "./components/NSDialogBoxString";
|
|
62
63
|
export * from "./components/NSDownTimer";
|
|
63
64
|
export * from "./components/NSTile";
|
|
64
65
|
export * from "./components/NSFilterBox";
|
|
@@ -147,3 +148,4 @@ export * from "./Validator";
|
|
|
147
148
|
export * from "./NSBoxBuilder";
|
|
148
149
|
export * from "./ProductCacheService";
|
|
149
150
|
export * from "./CopyToClipboard";
|
|
151
|
+
export * from "./EncryptionOperation";
|
package/dist/main.js
CHANGED
|
@@ -61,6 +61,7 @@ export * from "./components/NSDialogBox";
|
|
|
61
61
|
export * from "./components/NSDialogBoxDate";
|
|
62
62
|
export * from "./components/NSDialogBoxDateTime";
|
|
63
63
|
export * from "./components/NSDialogBoxPhone";
|
|
64
|
+
export * from "./components/NSDialogBoxString";
|
|
64
65
|
export * from "./components/NSDownTimer";
|
|
65
66
|
export * from "./components/NSTile";
|
|
66
67
|
export * from "./components/NSFilterBox";
|
|
@@ -149,6 +150,7 @@ export * from "./Validator";
|
|
|
149
150
|
export * from "./NSBoxBuilder";
|
|
150
151
|
export * from "./ProductCacheService";
|
|
151
152
|
export * from "./CopyToClipboard";
|
|
153
|
+
export * from "./EncryptionOperation";
|
|
152
154
|
function main() {
|
|
153
155
|
NSBaseMetaDatabase.getServerBaseURL = function (name) {
|
|
154
156
|
name = name.replace("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,CAAC;AAEtC,SAAS,IAAI;IAET,kBAAkB,CAAC,gBAAgB,GAAG,UAAU,IAAY;QAExD,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QAC7C,IAAI,GAAG,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,gBAAgB,CAAC,qBAAqB,CAAC,CAAC;QACnF,OAAO,sBAAsB,IAAI,EAAE,CAAC;IACxC,CAAC,CAAA;AACL,CAAC;AAED,IAAI,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"framework": "npm",
|
|
9
9
|
"application": "package",
|
|
10
10
|
"private": false,
|
|
11
|
-
"version": "1.4.
|
|
11
|
+
"version": "1.4.479",
|
|
12
12
|
"author": "Amir Abolhasani",
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"main": "./dist/main.js",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@ant-design/charts": "^2.6.5",
|
|
25
25
|
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
|
|
26
|
-
"@types/node": "^24.
|
|
26
|
+
"@types/node": "^24.7.0",
|
|
27
27
|
"@types/react": "^18.3.12",
|
|
28
28
|
"@types/react-bootstrap": "^1.1.0",
|
|
29
29
|
"@types/react-dom": "^18.3.1",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"link-react": "^3.0.0",
|
|
37
37
|
"namirasoft-api-link": "^1.4.20",
|
|
38
38
|
"namirasoft-api-product": "^1.4.40",
|
|
39
|
-
"namirasoft-core": "^1.4.
|
|
39
|
+
"namirasoft-core": "^1.4.95",
|
|
40
40
|
"namirasoft-schema": "^1.4.25",
|
|
41
41
|
"namirasoft-site": "^1.4.41",
|
|
42
42
|
"namirasoft-site-map": "^1.4.36",
|
package/src/App.tsx
CHANGED
|
@@ -2,13 +2,13 @@ import 'bootstrap/dist/css/bootstrap.min.css';
|
|
|
2
2
|
import { Component } from 'react';
|
|
3
3
|
import './App.css';
|
|
4
4
|
import { NSLayout } from './components/NSLayout';
|
|
5
|
-
import {
|
|
5
|
+
import { NSButtonBlue, NSDialogBoxString, NSRow } from './main';
|
|
6
6
|
|
|
7
7
|
interface AppProps { }
|
|
8
8
|
|
|
9
9
|
interface AppState
|
|
10
10
|
{
|
|
11
|
-
|
|
11
|
+
show_dialog: boolean;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export class App extends Component<AppProps, AppState>
|
|
@@ -16,7 +16,7 @@ export class App extends Component<AppProps, AppState>
|
|
|
16
16
|
constructor(props: AppProps)
|
|
17
17
|
{
|
|
18
18
|
super(props);
|
|
19
|
-
this.state = {
|
|
19
|
+
this.state = { show_dialog: false };
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
override render()
|
|
@@ -42,53 +42,32 @@ export class App extends Component<AppProps, AppState>
|
|
|
42
42
|
scope=''
|
|
43
43
|
>
|
|
44
44
|
<NSRow>
|
|
45
|
-
<
|
|
46
|
-
title="
|
|
45
|
+
<NSButtonBlue
|
|
46
|
+
title="Show NSDialogBoxString"
|
|
47
47
|
onClick={{
|
|
48
48
|
showLoading: false,
|
|
49
|
-
action: () => this.setState((prev) => ({ ...prev,
|
|
49
|
+
action: () => this.setState((prev) => ({ ...prev, show_dialog: true })),
|
|
50
50
|
}}
|
|
51
51
|
/>
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
{ id: "b3", first_name: "Elham", last_name: "Khosravi", gender: "Female", age: 25, phone: "09203456781", email: "elham.khosravi@example.com", bio: "Graphic designer with a flair for modern art." },
|
|
72
|
-
]
|
|
73
|
-
})}
|
|
74
|
-
getRowKey={(item) => item.value.id}
|
|
75
|
-
columns={[
|
|
76
|
-
{ index: 0, name: "id", text: "ID", table: { name: "users", text: "users" }, formatter: new StringFormatter(StringFormatterSizeType.Word) },
|
|
77
|
-
{ index: 1, name: "first_name", text: "First Name", table: { name: "users", text: "users" }, formatter: new StringFormatter(StringFormatterSizeType.TwoWords) },
|
|
78
|
-
{ index: 2, name: "last_name", text: "Last Name", table: { name: "users", text: "users" }, formatter: new StringFormatter(StringFormatterSizeType.TwoWords) },
|
|
79
|
-
{ index: 3, name: "gender", text: "Gender", table: { name: "users", text: "users" }, formatter: new StringFormatter(StringFormatterSizeType.TwoWords) },
|
|
80
|
-
{ index: 4, name: "age", text: "Age", table: { name: "users", text: "users" }, formatter: new IntegerFormatter() },
|
|
81
|
-
{ index: 5, name: "phone", text: "Phone Number", table: { name: "users", text: "users" }, formatter: new PhoneFormatter() },
|
|
82
|
-
{ index: 6, name: "email", text: "Email Address", table: { name: "users", text: "users" }, formatter: new EmailFormatter() },
|
|
83
|
-
{ index: 7, name: "bio", text: "Bio", table: { name: "users", text: "users" }, formatter: new StringFormatter(StringFormatterSizeType.Description) },
|
|
84
|
-
]}
|
|
85
|
-
ui={{
|
|
86
|
-
pagination: this.state.hide_footer,
|
|
87
|
-
button_panel: this.state.hide_footer,
|
|
88
|
-
}}
|
|
89
|
-
/>
|
|
90
|
-
}
|
|
91
|
-
/>
|
|
52
|
+
{
|
|
53
|
+
this.state.show_dialog &&
|
|
54
|
+
<NSDialogBoxString
|
|
55
|
+
box={{
|
|
56
|
+
required: true,
|
|
57
|
+
title: "Title"
|
|
58
|
+
}}
|
|
59
|
+
onClose={() => this.setState((prev) => ({ ...prev, show_dialog: false }))}
|
|
60
|
+
button={{
|
|
61
|
+
title: "Apply",
|
|
62
|
+
onClick: {
|
|
63
|
+
showLoading: false,
|
|
64
|
+
action: () => { }
|
|
65
|
+
}
|
|
66
|
+
}}
|
|
67
|
+
>
|
|
68
|
+
<></>
|
|
69
|
+
</NSDialogBoxString>
|
|
70
|
+
}
|
|
92
71
|
</NSRow>
|
|
93
72
|
</NSLayout>
|
|
94
73
|
);
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import * as crypto from 'node:crypto';
|
|
2
|
+
|
|
3
|
+
export class EncryptionOperation
|
|
4
|
+
{
|
|
5
|
+
private static async encrypt<T>(algorithm: string, secret: string, message: T): Promise<string>
|
|
6
|
+
{
|
|
7
|
+
if (secret.length != 32)
|
|
8
|
+
throw new Error("Secret length must be exactly 32");
|
|
9
|
+
const enc = new TextEncoder();
|
|
10
|
+
|
|
11
|
+
// Derive a key from the password using PBKDF2
|
|
12
|
+
const salt = crypto.getRandomValues(new Uint8Array(16));
|
|
13
|
+
const keyMaterial = await crypto.subtle.importKey(
|
|
14
|
+
"raw",
|
|
15
|
+
enc.encode(secret),
|
|
16
|
+
{ name: "PBKDF2" },
|
|
17
|
+
false,
|
|
18
|
+
["deriveKey"]
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
const key = await crypto.subtle.deriveKey(
|
|
22
|
+
{
|
|
23
|
+
name: "PBKDF2",
|
|
24
|
+
salt,
|
|
25
|
+
iterations: 100000,
|
|
26
|
+
hash: "SHA-256",
|
|
27
|
+
},
|
|
28
|
+
keyMaterial,
|
|
29
|
+
{ name: algorithm, length: 256 },
|
|
30
|
+
true,
|
|
31
|
+
["encrypt"]
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
// Generate random IV
|
|
35
|
+
const iv = crypto.getRandomValues(new Uint8Array(12));
|
|
36
|
+
|
|
37
|
+
const cipherText = await crypto.subtle.encrypt(
|
|
38
|
+
{
|
|
39
|
+
name: algorithm,
|
|
40
|
+
iv,
|
|
41
|
+
},
|
|
42
|
+
key,
|
|
43
|
+
enc.encode(JSON.stringify(message))
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
// Combine salt, iv, and cipherText for storage
|
|
47
|
+
const combined = new Uint8Array([...salt, ...iv, ...new Uint8Array(cipherText)]);
|
|
48
|
+
return btoa(String.fromCharCode(...combined));
|
|
49
|
+
}
|
|
50
|
+
private static async decrypt<T>(algorithm: string, secret: string, message: string): Promise<T>
|
|
51
|
+
{
|
|
52
|
+
const data = Uint8Array.from(atob(message), c => c.charCodeAt(0));
|
|
53
|
+
|
|
54
|
+
const salt = data.slice(0, 16);
|
|
55
|
+
const iv = data.slice(16, 28);
|
|
56
|
+
const cipherText = data.slice(28);
|
|
57
|
+
|
|
58
|
+
const enc = new TextEncoder();
|
|
59
|
+
const dec = new TextDecoder();
|
|
60
|
+
|
|
61
|
+
const keyMaterial = await crypto.subtle.importKey(
|
|
62
|
+
"raw",
|
|
63
|
+
enc.encode(secret),
|
|
64
|
+
{ name: "PBKDF2" },
|
|
65
|
+
false,
|
|
66
|
+
["deriveKey"]
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
const key = await crypto.subtle.deriveKey(
|
|
70
|
+
{
|
|
71
|
+
name: "PBKDF2",
|
|
72
|
+
salt,
|
|
73
|
+
iterations: 100000,
|
|
74
|
+
hash: "SHA-256",
|
|
75
|
+
},
|
|
76
|
+
keyMaterial,
|
|
77
|
+
{ name: algorithm, length: 256 },
|
|
78
|
+
true,
|
|
79
|
+
["decrypt"]
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
const decrypted = await crypto.subtle.decrypt(
|
|
83
|
+
{
|
|
84
|
+
name: algorithm,
|
|
85
|
+
iv,
|
|
86
|
+
},
|
|
87
|
+
key,
|
|
88
|
+
cipherText
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
return JSON.parse(dec.decode(decrypted));
|
|
92
|
+
}
|
|
93
|
+
static async AES256GCMEncrypt<T>(secret: string, message: T): Promise<string>
|
|
94
|
+
{
|
|
95
|
+
return EncryptionOperation.encrypt("AES-GCM", secret, message);
|
|
96
|
+
}
|
|
97
|
+
static async AES256GCMDecrypt<T>(secret: string, message: string): Promise<T>
|
|
98
|
+
{
|
|
99
|
+
return EncryptionOperation.decrypt("AES-GCM", secret, message);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Component, createRef } from 'react';
|
|
2
|
+
import { INSDialogBoxBaseProps, NSDialogBox } from "./NSDialogBox";
|
|
3
|
+
import { NSBoxString, NSBoxStringProps } from './NSBoxString';
|
|
4
|
+
|
|
5
|
+
export interface NSDialogBoxStringProps extends INSDialogBoxBaseProps<NSBoxString>
|
|
6
|
+
{
|
|
7
|
+
box: NSBoxStringProps;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export class NSDialogBoxString extends Component<NSDialogBoxStringProps>
|
|
11
|
+
{
|
|
12
|
+
private NSBoxString_Ref = createRef<NSBoxString>();
|
|
13
|
+
|
|
14
|
+
override render()
|
|
15
|
+
{
|
|
16
|
+
return (
|
|
17
|
+
<NSDialogBox
|
|
18
|
+
{...this.props}
|
|
19
|
+
children_ref={this.NSBoxString_Ref}
|
|
20
|
+
>
|
|
21
|
+
<NSBoxString
|
|
22
|
+
{...this.props.box}
|
|
23
|
+
ref={this.NSBoxString_Ref}
|
|
24
|
+
/>
|
|
25
|
+
</NSDialogBox>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
}
|
package/src/main.ts
CHANGED
|
@@ -81,6 +81,7 @@ export * from "./components/NSDialogBox";
|
|
|
81
81
|
export * from "./components/NSDialogBoxDate";
|
|
82
82
|
export * from "./components/NSDialogBoxDateTime";
|
|
83
83
|
export * from "./components/NSDialogBoxPhone";
|
|
84
|
+
export * from "./components/NSDialogBoxString";
|
|
84
85
|
|
|
85
86
|
// DownTimer
|
|
86
87
|
export * from "./components/NSDownTimer";
|
|
@@ -230,6 +231,7 @@ export * from "./Validator";
|
|
|
230
231
|
export * from "./NSBoxBuilder";
|
|
231
232
|
export * from "./ProductCacheService";
|
|
232
233
|
export * from "./CopyToClipboard";
|
|
234
|
+
export * from "./EncryptionOperation";
|
|
233
235
|
|
|
234
236
|
function main()
|
|
235
237
|
{
|