namirasoft-account-react 1.4.430 → 1.4.431

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.
Files changed (124) hide show
  1. package/.env.template +15 -15
  2. package/SKILLS.md +514 -514
  3. package/config-overrides.js +72 -72
  4. package/dist/App.css +32 -0
  5. package/dist/App.d.ts +1 -1
  6. package/dist/UseParams.d.ts +1 -1
  7. package/dist/components/NSAAccessListDialog.d.ts +2 -2
  8. package/dist/components/NSAAccessListDialog.module.css +71 -71
  9. package/dist/components/NSAMasterMenu.d.ts +1 -1
  10. package/dist/components/NSAMasterMenu.module.css +248 -248
  11. package/dist/components/NSAMasterMenuItem.d.ts +1 -1
  12. package/dist/components/NSAMessageListDialog.d.ts +1 -1
  13. package/dist/components/NSAMessageListDialog.module.css +99 -99
  14. package/dist/components/NSAProductListDialog.d.ts +1 -1
  15. package/dist/components/NSAProductListDialog.module.css +44 -44
  16. package/dist/components/NSAReorderDialog.d.ts +1 -1
  17. package/dist/components/NSAReorderDialog.module.css +49 -49
  18. package/dist/components/NSASortDialog.d.ts +1 -1
  19. package/dist/components/NSAUserDialog.d.ts +1 -1
  20. package/dist/components/NSAUserDialog.module.css +67 -67
  21. package/dist/components/NSAWorkspaceListDialog.d.ts +1 -1
  22. package/dist/components/NSAWorkspaceListDialog.module.css +41 -41
  23. package/dist/components/NSBoxSecret.d.ts +1 -1
  24. package/dist/components/NSBoxSecret.module.css +23 -23
  25. package/dist/components/NSLabelSecret.d.ts +1 -1
  26. package/dist/components/quickfilter/NSAFilterBoxEnum.module.css +45 -0
  27. package/dist/components/quickfilter/NSAQuickFilterBar.d.ts +1 -1
  28. package/dist/components/quickfilter/NSAQuickFilterBar.module.css +20 -0
  29. package/dist/components/quickfilter/NSAQuickFilterDialog.d.ts +1 -1
  30. package/dist/components/quickfilter/NSAQuickFilterDialog.module.css +75 -0
  31. package/dist/index.css +0 -0
  32. package/dist/layouts/NSALayout.d.ts +1 -1
  33. package/dist/layouts/NSASectionEdit.d.ts +1 -1
  34. package/dist/layouts/NSASectionEditTabPage.d.ts +1 -1
  35. package/dist/layouts/NSASectionEditTabPage.module.css +4 -4
  36. package/dist/layouts/NSASectionList.d.ts +1 -1
  37. package/dist/layouts/NSASectionList.module.css +31 -31
  38. package/dist/layouts/NSASectionView.d.ts +1 -1
  39. package/dist/layouts/NSASectionViewTabMore.d.ts +1 -1
  40. package/dist/layouts/NSASectionViewTabPage.d.ts +1 -1
  41. package/dist/layouts/NSASectionViewTabPage.module.css +47 -47
  42. package/dist/pages/NSAConsentPage.module.css +26 -26
  43. package/dist/pages/NSAEmailVerificationPage.d.ts +1 -1
  44. package/dist/pages/NSAHomePage.d.ts +1 -1
  45. package/dist/pages/NSAHomePage.module.css +41 -41
  46. package/dist/pages/NSALoginPage.d.ts +1 -1
  47. package/dist/pages/NSALoginPage.module.css +26 -26
  48. package/dist/pages/NSAPhoneVerificationPage.d.ts +1 -1
  49. package/dist/pages/NSAVerificationPage.d.ts +1 -1
  50. package/dist/pages/NSAVerificationPage.module.css +31 -31
  51. package/package.json +94 -94
  52. package/public/index.html +21 -21
  53. package/src/App.css +31 -31
  54. package/src/App.tsx +19 -19
  55. package/src/CTFRow.ts +7 -7
  56. package/src/IEntityInfo.ts +33 -33
  57. package/src/NSACacheService.ts +120 -120
  58. package/src/NSAFilterOperators.ts +92 -92
  59. package/src/NSARouterMaker.tsx +139 -139
  60. package/src/NSARouterMakerConfig.ts +15 -15
  61. package/src/NSARouterMakerProps.ts +22 -22
  62. package/src/Router.tsx +45 -45
  63. package/src/UseParams.tsx +18 -18
  64. package/src/components/NSAAccessListDialog.module.css +71 -71
  65. package/src/components/NSAAccessListDialog.tsx +178 -178
  66. package/src/components/NSAMasterMenu.module.css +248 -248
  67. package/src/components/NSAMasterMenu.tsx +169 -169
  68. package/src/components/NSAMasterMenuItem.tsx +250 -250
  69. package/src/components/NSAMessageListDialog.module.css +99 -99
  70. package/src/components/NSAMessageListDialog.tsx +141 -141
  71. package/src/components/NSAProductListDialog.module.css +44 -44
  72. package/src/components/NSAProductListDialog.tsx +88 -88
  73. package/src/components/NSAReorderDialog.module.css +49 -49
  74. package/src/components/NSAReorderDialog.tsx +149 -149
  75. package/src/components/NSASortDialog.tsx +117 -117
  76. package/src/components/NSATable.tsx +489 -489
  77. package/src/components/NSAUserDialog.module.css +67 -67
  78. package/src/components/NSAUserDialog.tsx +122 -122
  79. package/src/components/NSAWorkspaceListDialog.module.css +41 -41
  80. package/src/components/NSAWorkspaceListDialog.tsx +147 -147
  81. package/src/components/NSBoxSecret.module.css +23 -23
  82. package/src/components/NSBoxSecret.tsx +258 -258
  83. package/src/components/NSLabelSecret.tsx +37 -37
  84. package/src/components/quickfilter/NSAFilterBoxBase.tsx +55 -55
  85. package/src/components/quickfilter/NSAFilterBoxBoolean.tsx +54 -54
  86. package/src/components/quickfilter/NSAFilterBoxDate.tsx +104 -104
  87. package/src/components/quickfilter/NSAFilterBoxDateTime.tsx +105 -105
  88. package/src/components/quickfilter/NSAFilterBoxEnum.module.css +44 -44
  89. package/src/components/quickfilter/NSAFilterBoxEnum.tsx +79 -79
  90. package/src/components/quickfilter/NSAFilterBoxNumber.tsx +136 -136
  91. package/src/components/quickfilter/NSAFilterBoxString.tsx +81 -81
  92. package/src/components/quickfilter/NSAFilterBoxTime.tsx +101 -101
  93. package/src/components/quickfilter/NSAQuickFilterBar.module.css +19 -19
  94. package/src/components/quickfilter/NSAQuickFilterBar.tsx +114 -114
  95. package/src/components/quickfilter/NSAQuickFilterDialog.module.css +74 -74
  96. package/src/components/quickfilter/NSAQuickFilterDialog.tsx +260 -260
  97. package/src/css.d.ts +13 -13
  98. package/src/formatters/SecretFormatter.tsx +24 -24
  99. package/src/index.tsx +24 -24
  100. package/src/layouts/Actions.ts +145 -145
  101. package/src/layouts/CFTUtil.ts +18 -18
  102. package/src/layouts/NSALayout.tsx +841 -841
  103. package/src/layouts/NSASectionEdit.tsx +260 -260
  104. package/src/layouts/NSASectionEditTabPage.module.css +4 -4
  105. package/src/layouts/NSASectionEditTabPage.tsx +250 -250
  106. package/src/layouts/NSASectionList.module.css +31 -31
  107. package/src/layouts/NSASectionList.tsx +149 -149
  108. package/src/layouts/NSASectionView.tsx +100 -100
  109. package/src/layouts/NSASectionViewTabMore.tsx +77 -77
  110. package/src/layouts/NSASectionViewTabPage.module.css +47 -47
  111. package/src/layouts/NSASectionViewTabPage.tsx +419 -419
  112. package/src/main.ts +46 -46
  113. package/src/pages/NSAConsentPage.module.css +26 -26
  114. package/src/pages/NSAConsentPage.tsx +120 -120
  115. package/src/pages/NSAEmailVerificationPage.tsx +30 -30
  116. package/src/pages/NSAHomePage.module.css +41 -41
  117. package/src/pages/NSAHomePage.tsx +102 -102
  118. package/src/pages/NSALoginPage.module.css +26 -26
  119. package/src/pages/NSALoginPage.tsx +87 -87
  120. package/src/pages/NSAPhoneVerificationPage.tsx +94 -94
  121. package/src/pages/NSAVerificationPage.module.css +31 -31
  122. package/src/pages/NSAVerificationPage.tsx +186 -186
  123. package/src/pages/PaymentRequired.tsx +74 -74
  124. package/tsconfig.json +43 -43
@@ -1,259 +1,259 @@
1
- import { BaseUUID, EnvService } from "namirasoft-core";
2
- import { NamirasoftSecretMetaDatabase, NamirasoftSecretServer } from "namirasoft-secret";
3
- import { IBaseComponentProps, INSBox, INSBoxBaseLayoutProps, IValidationProps, IValidationStringProps, NSBoxBoolean, NSBoxSensitive, NSBoxString, NSColumn, safeMenuMenuItem } from "namirasoft-site-react";
4
- import React, { createRef, HTMLInputAutoCompleteAttribute } from "react";
5
- import { NSARouterMakerProps } from "../NSARouterMakerProps";
6
- import Styles from "./NSBoxSecret.module.css";
7
- export interface NSBoxSecretProps extends IBaseComponentProps, IValidationProps, IValidationStringProps, NSARouterMakerProps, INSBoxBaseLayoutProps<NSBoxSecret | NSBoxString, string>
8
- {
9
- input?: IBaseComponentProps;
10
- auto_complete?: HTMLInputAutoCompleteAttribute | undefined;
11
- sensitive_enabled?: boolean;
12
- encryption?: {
13
- encryptor: (value: string) => Promise<string>;
14
- decryptor: (value: string) => Promise<string>;
15
- }
16
- }
17
- interface NSBoxSecretState
18
- {
19
- secret_id: string | null;
20
- value: string | null;
21
- is_sensitive: boolean;
22
- is_loading: boolean;
23
- }
24
-
25
- export class NSBoxSecret extends React.Component<NSBoxSecretProps, NSBoxSecretState> implements INSBox
26
- {
27
- private NSBoxSensitive_Main = createRef<NSBoxSensitive>();
28
- private NSBoxString_Main = createRef<NSBoxString>();
29
- private NSBoxBoolean_Sensitive = createRef<NSBoxBoolean>();
30
-
31
- constructor(props: NSBoxSecretProps)
32
- {
33
- super(props);
34
- this.state = {
35
- secret_id: null,
36
- value: null,
37
- is_sensitive: true,
38
- is_loading: false,
39
- };
40
- this.isEmpty = this.isEmpty.bind(this);
41
- this.getError = this.getError.bind(this);
42
- this.isSensitive = this.isSensitive.bind(this);
43
- this.setSensitive = this.setSensitive.bind(this);
44
- this.getValue = this.getValue.bind(this);
45
- this.setValue = this.setValue.bind(this);
46
- this.getEncryptedValue = this.getEncryptedValue.bind(this);
47
- this.setEncryptedValue = this.setEncryptedValue.bind(this);
48
- this.onChanged = this.onChanged.bind(this);
49
- }
50
-
51
- isEmpty(value: string)
52
- {
53
- return this.getCurrentBox()?.isEmpty(value) ?? true;
54
- }
55
- getError(): string | null
56
- {
57
- if (this.isSensitive() && this.state.secret_id && !this.state.value)
58
- return null;
59
- return this.getCurrentBox()?.getError() ?? null;
60
- }
61
- isSensitive(): boolean
62
- {
63
- return this.NSBoxBoolean_Sensitive.current?.getValueNull() ?? this.state.is_sensitive;
64
- }
65
- async setSensitive(value: boolean, callback?: (() => void))
66
- {
67
- await this.handleSensitiveChange(value);
68
- this.NSBoxBoolean_Sensitive.current?.setValue(value, callback);
69
- }
70
- private async handleSensitiveChange(enabled: boolean)
71
- {
72
- if (!enabled && this.state.secret_id && !this.state.value)
73
- {
74
- this.setState({ is_loading: true });
75
- const value = await this.getSecretValue();
76
- this.setState(
77
- () => ({ value, secret_id: null, is_loading: false, is_sensitive: false }),
78
- () => this.NSBoxString_Main.current?.setValue(value)
79
- );
80
- return;
81
- }
82
- this.setState({ is_sensitive: enabled });
83
- }
84
- getValue(checkError: boolean = true): string | null
85
- {
86
- if (this.isSensitive() && this.state.secret_id && !this.state.value)
87
- return "";
88
- return this.getCurrentBox()?.getValue(checkError) ?? null;
89
- }
90
- setValue(value: string | null, callback?: () => void): void
91
- {
92
- if (!this.isSensitive())
93
- this.NSBoxString_Main.current?.setValue(value, callback);
94
- else
95
- {
96
- let meta = new NamirasoftSecretMetaDatabase();
97
- let short = meta.tables.secret.uuid.short;
98
- if (BaseUUID.isValidShort(value ?? "", short))
99
- this.setState({ secret_id: value, value: null });
100
- else
101
- {
102
- this.setState({ secret_id: null, value });
103
- this.NSBoxSensitive_Main.current?.setValue(value, callback);
104
- }
105
- }
106
- }
107
- async getEncryptedValue(checkError: boolean = true): Promise<string | null>
108
- {
109
- let value = this.getValue(checkError);
110
-
111
- if (!this.isSensitive())
112
- return value;
113
-
114
- if (!value)
115
- if (this.state.secret_id)
116
- return await this.getSecretValue(false);
117
- else
118
- return value;
119
-
120
- return await this.props.encryption?.encryptor(value) ?? value;
121
- }
122
- async setEncryptedValue(value: string | null, callback?: () => void)
123
- {
124
- if (!this.isSensitive())
125
- this.setValue(value, callback);
126
- else
127
- {
128
- if (value)
129
- {
130
- let encrypted_value = await this.props.encryption?.decryptor(value) ?? value;
131
- this.setValue(encrypted_value, callback);
132
- }
133
- else
134
- {
135
- this.setValue(value, callback);
136
- }
137
- }
138
- }
139
- async getSecretValue(decode: boolean = true)
140
- {
141
- if (!this.state.secret_id)
142
- return null;
143
-
144
- let REACT_APP_BASE_URL_SECRET = new EnvService("REACT_APP_BASE_URL_SECRET", true).getString();
145
- let server = new NamirasoftSecretServer(REACT_APP_BASE_URL_SECRET, this.props.account.token_manager, this.props.notifier.onError);
146
-
147
- try
148
- {
149
- let res = await server.secret.GetValue(this.state.secret_id);
150
- if (decode)
151
- return await this.props.encryption?.decryptor?.(res) ?? res;
152
- return res;
153
- }
154
- catch (error)
155
- {
156
- return null;
157
- }
158
- }
159
- setDisabled(disabled: boolean): void
160
- {
161
- this.NSBoxString_Main.current?.setDisabled(disabled);
162
- }
163
- onChanged(box: NSBoxSensitive | NSBoxString)
164
- {
165
- let value = box.getValue(false);
166
- this.setState({ value });
167
- this.props.onChanged?.(this);
168
- }
169
- getCurrentBox()
170
- {
171
- if (this.isSensitive())
172
- return this.NSBoxSensitive_Main.current
173
- return this.NSBoxString_Main.current
174
- }
175
-
176
- override render()
177
- {
178
- let input_style: React.CSSProperties = {};
179
- let placeholder = undefined;
180
- if (this.state.secret_id && !this.state.value)
181
- {
182
- input_style.backgroundColor = "#00000030";
183
- input_style.textAlign = "center";
184
- placeholder = this.state.secret_id;
185
- }
186
- let secret_enabled = this.state.secret_id && !this.state.value;
187
- let menu = safeMenuMenuItem(this.props, (items) =>
188
- {
189
- if (secret_enabled && !this.state.is_loading)
190
- if (this.isSensitive())
191
- items.push({
192
- title: "Load From Secret",
193
- icon: "https://static.namirasoft.com/image/namirasoft/secret/logo/base.png",
194
- onClick: async () =>
195
- {
196
- this.setState({ is_loading: true });
197
- let res = await this.getSecretValue();
198
- this.setState({ is_loading: false });
199
- if (res)
200
- this.NSBoxSensitive_Main.current?.setValue(res);
201
- }
202
- });
203
- });
204
-
205
- return (
206
- <NSColumn style={{ width: "auto", gap: "0.5rem" }}>
207
- {
208
- this.isSensitive()
209
- ?
210
- <NSBoxSensitive
211
- ref={this.NSBoxSensitive_Main}
212
- {...this.props}
213
- defaultValue={this.state.value ?? ""}
214
- onChanged={this.onChanged}
215
- onClicked={() => this.props.onClicked?.(this)}
216
- placeholder={placeholder}
217
- input={{ style: input_style }}
218
- menu={{
219
- ...menu,
220
- builtin: {
221
- ...menu.builtin,
222
- show_hide_password: {
223
- enabled: !secret_enabled
224
- }
225
- }
226
- }}
227
- />
228
- :
229
- <NSBoxString
230
- {...this.props}
231
- ref={this.NSBoxString_Main}
232
- defaultValue={this.state.value ?? ""}
233
- onChanged={this.onChanged}
234
- />
235
- }
236
- <div className="d-flex gap-2">
237
- {
238
- this.state.is_loading &&
239
- <div className="spinner-border spinner-border-sm text-primary"></div>
240
- }
241
- {
242
- this.props.sensitive_enabled &&
243
- <NSBoxBoolean
244
- ref={this.NSBoxBoolean_Sensitive}
245
- title="Sensitive"
246
- required={false}
247
- hideHeader
248
- onChanged={async (box) =>
249
- {
250
- await this.handleSensitiveChange(box.getValue() ?? false);
251
- }}
252
- classList={[Styles.ns_checkbox, this.state.is_loading ? Styles.disabled : ""]}
253
- />
254
- }
255
- </div>
256
- </NSColumn>
257
- );
258
- }
1
+ import { BaseUUID, EnvService } from "namirasoft-core";
2
+ import { NamirasoftSecretMetaDatabase, NamirasoftSecretServer } from "namirasoft-secret";
3
+ import { IBaseComponentProps, INSBox, INSBoxBaseLayoutProps, IValidationProps, IValidationStringProps, NSBoxBoolean, NSBoxSensitive, NSBoxString, NSColumn, safeMenuMenuItem } from "namirasoft-site-react";
4
+ import React, { createRef, HTMLInputAutoCompleteAttribute } from "react";
5
+ import { NSARouterMakerProps } from "../NSARouterMakerProps";
6
+ import Styles from "./NSBoxSecret.module.css";
7
+ export interface NSBoxSecretProps extends IBaseComponentProps, IValidationProps, IValidationStringProps, NSARouterMakerProps, INSBoxBaseLayoutProps<NSBoxSecret | NSBoxString, string>
8
+ {
9
+ input?: IBaseComponentProps;
10
+ auto_complete?: HTMLInputAutoCompleteAttribute | undefined;
11
+ sensitive_enabled?: boolean;
12
+ encryption?: {
13
+ encryptor: (value: string) => Promise<string>;
14
+ decryptor: (value: string) => Promise<string>;
15
+ }
16
+ }
17
+ interface NSBoxSecretState
18
+ {
19
+ secret_id: string | null;
20
+ value: string | null;
21
+ is_sensitive: boolean;
22
+ is_loading: boolean;
23
+ }
24
+
25
+ export class NSBoxSecret extends React.Component<NSBoxSecretProps, NSBoxSecretState> implements INSBox
26
+ {
27
+ private NSBoxSensitive_Main = createRef<NSBoxSensitive>();
28
+ private NSBoxString_Main = createRef<NSBoxString>();
29
+ private NSBoxBoolean_Sensitive = createRef<NSBoxBoolean>();
30
+
31
+ constructor(props: NSBoxSecretProps)
32
+ {
33
+ super(props);
34
+ this.state = {
35
+ secret_id: null,
36
+ value: null,
37
+ is_sensitive: true,
38
+ is_loading: false,
39
+ };
40
+ this.isEmpty = this.isEmpty.bind(this);
41
+ this.getError = this.getError.bind(this);
42
+ this.isSensitive = this.isSensitive.bind(this);
43
+ this.setSensitive = this.setSensitive.bind(this);
44
+ this.getValue = this.getValue.bind(this);
45
+ this.setValue = this.setValue.bind(this);
46
+ this.getEncryptedValue = this.getEncryptedValue.bind(this);
47
+ this.setEncryptedValue = this.setEncryptedValue.bind(this);
48
+ this.onChanged = this.onChanged.bind(this);
49
+ }
50
+
51
+ isEmpty(value: string)
52
+ {
53
+ return this.getCurrentBox()?.isEmpty(value) ?? true;
54
+ }
55
+ getError(): string | null
56
+ {
57
+ if (this.isSensitive() && this.state.secret_id && !this.state.value)
58
+ return null;
59
+ return this.getCurrentBox()?.getError() ?? null;
60
+ }
61
+ isSensitive(): boolean
62
+ {
63
+ return this.NSBoxBoolean_Sensitive.current?.getValueNull() ?? this.state.is_sensitive;
64
+ }
65
+ async setSensitive(value: boolean, callback?: (() => void))
66
+ {
67
+ await this.handleSensitiveChange(value);
68
+ this.NSBoxBoolean_Sensitive.current?.setValue(value, callback);
69
+ }
70
+ private async handleSensitiveChange(enabled: boolean)
71
+ {
72
+ if (!enabled && this.state.secret_id && !this.state.value)
73
+ {
74
+ this.setState({ is_loading: true });
75
+ const value = await this.getSecretValue();
76
+ this.setState(
77
+ () => ({ value, secret_id: null, is_loading: false, is_sensitive: false }),
78
+ () => this.NSBoxString_Main.current?.setValue(value)
79
+ );
80
+ return;
81
+ }
82
+ this.setState({ is_sensitive: enabled });
83
+ }
84
+ getValue(checkError: boolean = true): string | null
85
+ {
86
+ if (this.isSensitive() && this.state.secret_id && !this.state.value)
87
+ return "";
88
+ return this.getCurrentBox()?.getValue(checkError) ?? null;
89
+ }
90
+ setValue(value: string | null, callback?: () => void): void
91
+ {
92
+ if (!this.isSensitive())
93
+ this.NSBoxString_Main.current?.setValue(value, callback);
94
+ else
95
+ {
96
+ let meta = new NamirasoftSecretMetaDatabase();
97
+ let short = meta.tables.secret.uuid.short;
98
+ if (BaseUUID.isValidShort(value ?? "", short))
99
+ this.setState({ secret_id: value, value: null });
100
+ else
101
+ {
102
+ this.setState({ secret_id: null, value });
103
+ this.NSBoxSensitive_Main.current?.setValue(value, callback);
104
+ }
105
+ }
106
+ }
107
+ async getEncryptedValue(checkError: boolean = true): Promise<string | null>
108
+ {
109
+ let value = this.getValue(checkError);
110
+
111
+ if (!this.isSensitive())
112
+ return value;
113
+
114
+ if (!value)
115
+ if (this.state.secret_id)
116
+ return await this.getSecretValue(false);
117
+ else
118
+ return value;
119
+
120
+ return await this.props.encryption?.encryptor(value) ?? value;
121
+ }
122
+ async setEncryptedValue(value: string | null, callback?: () => void)
123
+ {
124
+ if (!this.isSensitive())
125
+ this.setValue(value, callback);
126
+ else
127
+ {
128
+ if (value)
129
+ {
130
+ let encrypted_value = await this.props.encryption?.decryptor(value) ?? value;
131
+ this.setValue(encrypted_value, callback);
132
+ }
133
+ else
134
+ {
135
+ this.setValue(value, callback);
136
+ }
137
+ }
138
+ }
139
+ async getSecretValue(decode: boolean = true)
140
+ {
141
+ if (!this.state.secret_id)
142
+ return null;
143
+
144
+ let REACT_APP_BASE_URL_SECRET = new EnvService("REACT_APP_BASE_URL_SECRET", true).getString();
145
+ let server = new NamirasoftSecretServer(REACT_APP_BASE_URL_SECRET, this.props.account.token_manager, this.props.notifier.onError);
146
+
147
+ try
148
+ {
149
+ let res = await server.secret.GetValue(this.state.secret_id);
150
+ if (decode)
151
+ return await this.props.encryption?.decryptor?.(res) ?? res;
152
+ return res;
153
+ }
154
+ catch (error)
155
+ {
156
+ return null;
157
+ }
158
+ }
159
+ setDisabled(disabled: boolean): void
160
+ {
161
+ this.NSBoxString_Main.current?.setDisabled(disabled);
162
+ }
163
+ onChanged(box: NSBoxSensitive | NSBoxString)
164
+ {
165
+ let value = box.getValue(false);
166
+ this.setState({ value });
167
+ this.props.onChanged?.(this);
168
+ }
169
+ getCurrentBox()
170
+ {
171
+ if (this.isSensitive())
172
+ return this.NSBoxSensitive_Main.current
173
+ return this.NSBoxString_Main.current
174
+ }
175
+
176
+ override render()
177
+ {
178
+ let input_style: React.CSSProperties = {};
179
+ let placeholder = undefined;
180
+ if (this.state.secret_id && !this.state.value)
181
+ {
182
+ input_style.backgroundColor = "#00000030";
183
+ input_style.textAlign = "center";
184
+ placeholder = this.state.secret_id;
185
+ }
186
+ let secret_enabled = this.state.secret_id && !this.state.value;
187
+ let menu = safeMenuMenuItem(this.props, (items) =>
188
+ {
189
+ if (secret_enabled && !this.state.is_loading)
190
+ if (this.isSensitive())
191
+ items.push({
192
+ title: "Load From Secret",
193
+ icon: "https://static.namirasoft.com/image/namirasoft/secret/logo/base.png",
194
+ onClick: async () =>
195
+ {
196
+ this.setState({ is_loading: true });
197
+ let res = await this.getSecretValue();
198
+ this.setState({ is_loading: false });
199
+ if (res)
200
+ this.NSBoxSensitive_Main.current?.setValue(res);
201
+ }
202
+ });
203
+ });
204
+
205
+ return (
206
+ <NSColumn style={{ width: "auto", gap: "0.5rem" }}>
207
+ {
208
+ this.isSensitive()
209
+ ?
210
+ <NSBoxSensitive
211
+ ref={this.NSBoxSensitive_Main}
212
+ {...this.props}
213
+ defaultValue={this.state.value ?? ""}
214
+ onChanged={this.onChanged}
215
+ onClicked={() => this.props.onClicked?.(this)}
216
+ placeholder={placeholder}
217
+ input={{ style: input_style }}
218
+ menu={{
219
+ ...menu,
220
+ builtin: {
221
+ ...menu.builtin,
222
+ show_hide_password: {
223
+ enabled: !secret_enabled
224
+ }
225
+ }
226
+ }}
227
+ />
228
+ :
229
+ <NSBoxString
230
+ {...this.props}
231
+ ref={this.NSBoxString_Main}
232
+ defaultValue={this.state.value ?? ""}
233
+ onChanged={this.onChanged}
234
+ />
235
+ }
236
+ <div className="d-flex gap-2">
237
+ {
238
+ this.state.is_loading &&
239
+ <div className="spinner-border spinner-border-sm text-primary"></div>
240
+ }
241
+ {
242
+ this.props.sensitive_enabled &&
243
+ <NSBoxBoolean
244
+ ref={this.NSBoxBoolean_Sensitive}
245
+ title="Sensitive"
246
+ required={false}
247
+ hideHeader
248
+ onChanged={async (box) =>
249
+ {
250
+ await this.handleSensitiveChange(box.getValue() ?? false);
251
+ }}
252
+ classList={[Styles.ns_checkbox, this.state.is_loading ? Styles.disabled : ""]}
253
+ />
254
+ }
255
+ </div>
256
+ </NSColumn>
257
+ );
258
+ }
259
259
  }
@@ -1,38 +1,38 @@
1
- import { NamirasoftSecretServer } from 'namirasoft-secret';
2
- import { NSLabelSensitive } from 'namirasoft-site-react';
3
-
4
- export interface NSLabelSecretProps
5
- {
6
- sensitive: boolean;
7
- encrypted_value: string;
8
- server: NamirasoftSecretServer;
9
- decryptor?: (value: string) => Promise<string>;
10
- }
11
-
12
- export interface NSLabelSecretState
13
- {
14
- show: boolean;
15
- loading: boolean;
16
- decrypted_value: string | null;
17
- }
18
-
19
- export function NSLabelSecret(props: NSLabelSecretProps)
20
- {
21
- let decryptor_secret = async (value: string) =>
22
- {
23
- let decrypted = await props.server.secret.GetValue(value);
24
- if (props.decryptor)
25
- decrypted = await props.decryptor(decrypted);
26
- return decrypted;
27
- };
28
-
29
- return (
30
- <NSLabelSensitive
31
- sensitive={props.sensitive}
32
- value={props.encrypted_value}
33
- decryptor={decryptor_secret}
34
- />
35
- )
36
- }
37
-
1
+ import { NamirasoftSecretServer } from 'namirasoft-secret';
2
+ import { NSLabelSensitive } from 'namirasoft-site-react';
3
+
4
+ export interface NSLabelSecretProps
5
+ {
6
+ sensitive: boolean;
7
+ encrypted_value: string;
8
+ server: NamirasoftSecretServer;
9
+ decryptor?: (value: string) => Promise<string>;
10
+ }
11
+
12
+ export interface NSLabelSecretState
13
+ {
14
+ show: boolean;
15
+ loading: boolean;
16
+ decrypted_value: string | null;
17
+ }
18
+
19
+ export function NSLabelSecret(props: NSLabelSecretProps)
20
+ {
21
+ let decryptor_secret = async (value: string) =>
22
+ {
23
+ let decrypted = await props.server.secret.GetValue(value);
24
+ if (props.decryptor)
25
+ decrypted = await props.decryptor(decrypted);
26
+ return decrypted;
27
+ };
28
+
29
+ return (
30
+ <NSLabelSensitive
31
+ sensitive={props.sensitive}
32
+ value={props.encrypted_value}
33
+ decryptor={decryptor_secret}
34
+ />
35
+ )
36
+ }
37
+
38
38
  export default NSLabelSecret;