@form-engine-ts/privacy 5.0.1 → 6.0.0
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/README.md +3 -0
- package/dist/index.cjs +22 -0
- package/dist/index.d.cts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +21 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -18,3 +18,6 @@ const findings = detector.detect(schema, values);
|
|
|
18
18
|
|
|
19
19
|
Use `normalizePiiFindingsToMetadata(findings, userConfirmed)` to persist a compact confirmation flag, distinct finding
|
|
20
20
|
types, and the detected count alongside a submission.
|
|
21
|
+
|
|
22
|
+
Use `createSubmissionErrorFromPii(findings)` to turn findings into a typed `FormSubmissionError` requiring confirmation;
|
|
23
|
+
the optional `messageKey` customizes the renderer message key.
|
package/dist/index.cjs
CHANGED
|
@@ -21,13 +21,34 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
createStandardPrivacyDetector: () => createStandardPrivacyDetector,
|
|
24
|
+
createSubmissionErrorFromPii: () => createSubmissionErrorFromPii,
|
|
24
25
|
normalizePiiFindingsToMetadata: () => normalizePiiFindingsToMetadata
|
|
25
26
|
});
|
|
26
27
|
module.exports = __toCommonJS(index_exports);
|
|
28
|
+
var import_core = require("@form-engine-ts/core");
|
|
27
29
|
function normalizePiiFindingsToMetadata(findings, userConfirmed) {
|
|
28
30
|
const piiFindingTypes = [...new Set(findings.map((finding) => finding.type))];
|
|
29
31
|
return { piiConfirmed: userConfirmed, piiFindingTypes, piiDetectedCount: findings.length };
|
|
30
32
|
}
|
|
33
|
+
var createSubmissionErrorFromPii = (findings, options) => {
|
|
34
|
+
const messageKey = options?.messageKey ?? "renderer.confirmSensitiveDataMessage";
|
|
35
|
+
const formTitleMap = options?.formTitleMap ?? {};
|
|
36
|
+
const fieldErrors = {};
|
|
37
|
+
for (const finding of findings) {
|
|
38
|
+
const fieldTitle = formTitleMap[finding.fieldId] ?? finding.fieldId;
|
|
39
|
+
void fieldTitle;
|
|
40
|
+
fieldErrors[finding.fieldId] = `\u500B\u4EBA\u60C5\u5831\uFF08${finding.typeLabel ?? finding.type}\uFF09\u304C\u542B\u307E\u308C\u3066\u3044\u308B\u53EF\u80FD\u6027\u304C\u3042\u308A\u307E\u3059\u3002`;
|
|
41
|
+
}
|
|
42
|
+
const payload = {
|
|
43
|
+
code: "PII_CONFIRMATION_REQUIRED",
|
|
44
|
+
messageKey,
|
|
45
|
+
fieldErrors,
|
|
46
|
+
formErrors: ["\u500B\u4EBA\u60C5\u5831\u306E\u78BA\u8A8D\u304C\u5FC5\u8981\u3067\u3059\u3002"],
|
|
47
|
+
piiFindings: findings,
|
|
48
|
+
piiWarningAcknowledged: false
|
|
49
|
+
};
|
|
50
|
+
return new import_core.FormSubmissionError(payload);
|
|
51
|
+
};
|
|
31
52
|
var STANDARD_RULES = [
|
|
32
53
|
{ type: "email", pattern: /\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/giu },
|
|
33
54
|
{ type: "url", pattern: /\b(?:https?:\/\/|www\.)[^\s<>"']*[A-Z0-9/#]/giu },
|
|
@@ -121,5 +142,6 @@ function createStandardPrivacyDetector(config = {}) {
|
|
|
121
142
|
// Annotate the CommonJS export names for ESM import in node:
|
|
122
143
|
0 && (module.exports = {
|
|
123
144
|
createStandardPrivacyDetector,
|
|
145
|
+
createSubmissionErrorFromPii,
|
|
124
146
|
normalizePiiFindingsToMetadata
|
|
125
147
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FormSchema } from '@form-engine-ts/core';
|
|
1
|
+
import { FormSchema, FormSubmissionError } from '@form-engine-ts/core';
|
|
2
2
|
|
|
3
3
|
interface SensitiveDataFinding {
|
|
4
4
|
readonly fieldId: string;
|
|
@@ -27,6 +27,10 @@ declare function normalizePiiFindingsToMetadata(findings: readonly SensitiveData
|
|
|
27
27
|
readonly piiFindingTypes: readonly string[];
|
|
28
28
|
readonly piiDetectedCount: number;
|
|
29
29
|
};
|
|
30
|
+
declare const createSubmissionErrorFromPii: (findings: readonly SensitiveDataFinding[], options?: {
|
|
31
|
+
readonly messageKey?: string;
|
|
32
|
+
readonly formTitleMap?: Record<string, string>;
|
|
33
|
+
}) => FormSubmissionError;
|
|
30
34
|
declare function createStandardPrivacyDetector(config?: PrivacyDetectorConfig): SensitiveDataDetector;
|
|
31
35
|
|
|
32
|
-
export { type PrivacyDetectorConfig, type SensitiveDataDetector, type SensitiveDataDetectorRule, type SensitiveDataFinding, createStandardPrivacyDetector, normalizePiiFindingsToMetadata };
|
|
36
|
+
export { type PrivacyDetectorConfig, type SensitiveDataDetector, type SensitiveDataDetectorRule, type SensitiveDataFinding, createStandardPrivacyDetector, createSubmissionErrorFromPii, normalizePiiFindingsToMetadata };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FormSchema } from '@form-engine-ts/core';
|
|
1
|
+
import { FormSchema, FormSubmissionError } from '@form-engine-ts/core';
|
|
2
2
|
|
|
3
3
|
interface SensitiveDataFinding {
|
|
4
4
|
readonly fieldId: string;
|
|
@@ -27,6 +27,10 @@ declare function normalizePiiFindingsToMetadata(findings: readonly SensitiveData
|
|
|
27
27
|
readonly piiFindingTypes: readonly string[];
|
|
28
28
|
readonly piiDetectedCount: number;
|
|
29
29
|
};
|
|
30
|
+
declare const createSubmissionErrorFromPii: (findings: readonly SensitiveDataFinding[], options?: {
|
|
31
|
+
readonly messageKey?: string;
|
|
32
|
+
readonly formTitleMap?: Record<string, string>;
|
|
33
|
+
}) => FormSubmissionError;
|
|
30
34
|
declare function createStandardPrivacyDetector(config?: PrivacyDetectorConfig): SensitiveDataDetector;
|
|
31
35
|
|
|
32
|
-
export { type PrivacyDetectorConfig, type SensitiveDataDetector, type SensitiveDataDetectorRule, type SensitiveDataFinding, createStandardPrivacyDetector, normalizePiiFindingsToMetadata };
|
|
36
|
+
export { type PrivacyDetectorConfig, type SensitiveDataDetector, type SensitiveDataDetectorRule, type SensitiveDataFinding, createStandardPrivacyDetector, createSubmissionErrorFromPii, normalizePiiFindingsToMetadata };
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,28 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
+
import { FormSubmissionError } from "@form-engine-ts/core";
|
|
2
3
|
function normalizePiiFindingsToMetadata(findings, userConfirmed) {
|
|
3
4
|
const piiFindingTypes = [...new Set(findings.map((finding) => finding.type))];
|
|
4
5
|
return { piiConfirmed: userConfirmed, piiFindingTypes, piiDetectedCount: findings.length };
|
|
5
6
|
}
|
|
7
|
+
var createSubmissionErrorFromPii = (findings, options) => {
|
|
8
|
+
const messageKey = options?.messageKey ?? "renderer.confirmSensitiveDataMessage";
|
|
9
|
+
const formTitleMap = options?.formTitleMap ?? {};
|
|
10
|
+
const fieldErrors = {};
|
|
11
|
+
for (const finding of findings) {
|
|
12
|
+
const fieldTitle = formTitleMap[finding.fieldId] ?? finding.fieldId;
|
|
13
|
+
void fieldTitle;
|
|
14
|
+
fieldErrors[finding.fieldId] = `\u500B\u4EBA\u60C5\u5831\uFF08${finding.typeLabel ?? finding.type}\uFF09\u304C\u542B\u307E\u308C\u3066\u3044\u308B\u53EF\u80FD\u6027\u304C\u3042\u308A\u307E\u3059\u3002`;
|
|
15
|
+
}
|
|
16
|
+
const payload = {
|
|
17
|
+
code: "PII_CONFIRMATION_REQUIRED",
|
|
18
|
+
messageKey,
|
|
19
|
+
fieldErrors,
|
|
20
|
+
formErrors: ["\u500B\u4EBA\u60C5\u5831\u306E\u78BA\u8A8D\u304C\u5FC5\u8981\u3067\u3059\u3002"],
|
|
21
|
+
piiFindings: findings,
|
|
22
|
+
piiWarningAcknowledged: false
|
|
23
|
+
};
|
|
24
|
+
return new FormSubmissionError(payload);
|
|
25
|
+
};
|
|
6
26
|
var STANDARD_RULES = [
|
|
7
27
|
{ type: "email", pattern: /\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/giu },
|
|
8
28
|
{ type: "url", pattern: /\b(?:https?:\/\/|www\.)[^\s<>"']*[A-Z0-9/#]/giu },
|
|
@@ -95,5 +115,6 @@ function createStandardPrivacyDetector(config = {}) {
|
|
|
95
115
|
}
|
|
96
116
|
export {
|
|
97
117
|
createStandardPrivacyDetector,
|
|
118
|
+
createSubmissionErrorFromPii,
|
|
98
119
|
normalizePiiFindingsToMetadata
|
|
99
120
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@form-engine-ts/privacy",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"typescript"
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@form-engine-ts/core": "
|
|
41
|
+
"@form-engine-ts/core": "6.0.0"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
44
|
"build": "tsup src/index.ts --format esm,cjs --dts --clean --external @form-engine-ts/core",
|