@ai-pip/core 0.1.1 → 0.1.3

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 (165) hide show
  1. package/README.md +102 -9
  2. package/dist/cpe/envelope.d.ts +34 -0
  3. package/dist/cpe/envelope.d.ts.map +1 -0
  4. package/dist/cpe/envelope.js +70 -0
  5. package/dist/cpe/envelope.js.map +1 -0
  6. package/dist/cpe/exceptions/EnvelopeError.d.ts +8 -0
  7. package/dist/cpe/exceptions/EnvelopeError.d.ts.map +1 -0
  8. package/dist/cpe/exceptions/EnvelopeError.js +13 -0
  9. package/dist/cpe/exceptions/EnvelopeError.js.map +1 -0
  10. package/dist/cpe/exceptions/index.d.ts +5 -0
  11. package/dist/cpe/exceptions/index.d.ts.map +1 -0
  12. package/dist/cpe/exceptions/index.js +5 -0
  13. package/dist/cpe/exceptions/index.js.map +1 -0
  14. package/dist/cpe/index.d.ts +24 -0
  15. package/dist/cpe/index.d.ts.map +1 -0
  16. package/dist/cpe/index.js +28 -0
  17. package/dist/cpe/index.js.map +1 -0
  18. package/dist/cpe/types.d.ts +58 -0
  19. package/dist/cpe/types.d.ts.map +1 -0
  20. package/dist/cpe/types.js +5 -0
  21. package/dist/cpe/types.js.map +1 -0
  22. package/dist/cpe/utils.d.ts +38 -0
  23. package/dist/cpe/utils.d.ts.map +1 -0
  24. package/dist/cpe/utils.js +47 -0
  25. package/dist/cpe/utils.js.map +1 -0
  26. package/dist/cpe/value-objects/Metadata.d.ts +32 -0
  27. package/dist/cpe/value-objects/Metadata.d.ts.map +1 -0
  28. package/dist/cpe/value-objects/Metadata.js +65 -0
  29. package/dist/cpe/value-objects/Metadata.js.map +1 -0
  30. package/dist/cpe/value-objects/Nonce.d.ts +33 -0
  31. package/dist/cpe/value-objects/Nonce.d.ts.map +1 -0
  32. package/dist/cpe/value-objects/Nonce.js +44 -0
  33. package/dist/cpe/value-objects/Nonce.js.map +1 -0
  34. package/dist/cpe/value-objects/Signature.d.ts +39 -0
  35. package/dist/cpe/value-objects/Signature.d.ts.map +1 -0
  36. package/dist/cpe/value-objects/Signature.js +60 -0
  37. package/dist/cpe/value-objects/Signature.js.map +1 -0
  38. package/dist/cpe/value-objects/index.d.ts +7 -0
  39. package/dist/cpe/value-objects/index.d.ts.map +1 -0
  40. package/dist/cpe/value-objects/index.js +7 -0
  41. package/dist/cpe/value-objects/index.js.map +1 -0
  42. package/dist/csl/classify.d.ts +35 -0
  43. package/dist/csl/classify.d.ts.map +1 -0
  44. package/dist/csl/classify.js +62 -0
  45. package/dist/csl/classify.js.map +1 -0
  46. package/dist/csl/exceptions/ClassificationError.d.ts +12 -0
  47. package/dist/csl/exceptions/ClassificationError.d.ts.map +1 -0
  48. package/dist/csl/exceptions/ClassificationError.js +16 -0
  49. package/dist/csl/exceptions/ClassificationError.js.map +1 -0
  50. package/dist/csl/exceptions/SegmentationError.d.ts +13 -0
  51. package/dist/csl/exceptions/SegmentationError.d.ts.map +1 -0
  52. package/dist/csl/exceptions/SegmentationError.js +18 -0
  53. package/dist/csl/exceptions/SegmentationError.js.map +1 -0
  54. package/dist/csl/exceptions/index.d.ts +3 -0
  55. package/dist/csl/exceptions/index.d.ts.map +1 -0
  56. package/dist/csl/exceptions/index.js +3 -0
  57. package/dist/csl/exceptions/index.js.map +1 -0
  58. package/dist/csl/index.d.ts +24 -0
  59. package/dist/csl/index.d.ts.map +1 -0
  60. package/dist/csl/index.js +29 -0
  61. package/dist/csl/index.js.map +1 -0
  62. package/dist/csl/lineage.d.ts +31 -0
  63. package/dist/csl/lineage.d.ts.map +1 -0
  64. package/dist/csl/lineage.js +36 -0
  65. package/dist/csl/lineage.js.map +1 -0
  66. package/dist/csl/segment.d.ts +35 -0
  67. package/dist/csl/segment.d.ts.map +1 -0
  68. package/dist/csl/segment.js +90 -0
  69. package/dist/csl/segment.js.map +1 -0
  70. package/dist/csl/types.d.ts +97 -0
  71. package/dist/csl/types.d.ts.map +1 -0
  72. package/dist/csl/types.js +62 -0
  73. package/dist/csl/types.js.map +1 -0
  74. package/dist/csl/utils.d.ts +16 -0
  75. package/dist/csl/utils.d.ts.map +1 -0
  76. package/dist/csl/utils.js +27 -0
  77. package/dist/csl/utils.js.map +1 -0
  78. package/dist/csl/value-objects/ContentHash.d.ts +18 -0
  79. package/dist/csl/value-objects/ContentHash.d.ts.map +1 -0
  80. package/dist/csl/value-objects/ContentHash.js +33 -0
  81. package/dist/csl/value-objects/ContentHash.js.map +1 -0
  82. package/dist/csl/value-objects/LineageEntry.d.ts +20 -0
  83. package/dist/csl/value-objects/LineageEntry.d.ts.map +1 -0
  84. package/dist/csl/value-objects/LineageEntry.js +20 -0
  85. package/dist/csl/value-objects/LineageEntry.js.map +1 -0
  86. package/dist/csl/value-objects/Origin-map.d.ts +21 -0
  87. package/dist/csl/value-objects/Origin-map.d.ts.map +1 -0
  88. package/dist/csl/value-objects/Origin-map.js +42 -0
  89. package/dist/csl/value-objects/Origin-map.js.map +1 -0
  90. package/dist/csl/value-objects/Origin.d.ts +22 -0
  91. package/dist/csl/value-objects/Origin.d.ts.map +1 -0
  92. package/dist/csl/value-objects/Origin.js +38 -0
  93. package/dist/csl/value-objects/Origin.js.map +1 -0
  94. package/dist/csl/value-objects/TrustLevel.d.ts +18 -0
  95. package/dist/csl/value-objects/TrustLevel.d.ts.map +1 -0
  96. package/dist/csl/value-objects/TrustLevel.js +23 -0
  97. package/dist/csl/value-objects/TrustLevel.js.map +1 -0
  98. package/dist/csl/value-objects/index.d.ts +10 -0
  99. package/dist/csl/value-objects/index.d.ts.map +1 -0
  100. package/dist/csl/value-objects/index.js +8 -0
  101. package/dist/csl/value-objects/index.js.map +1 -0
  102. package/dist/index.d.ts +17 -0
  103. package/dist/index.d.ts.map +1 -0
  104. package/dist/index.js +18 -0
  105. package/dist/index.js.map +1 -0
  106. package/dist/isl/exceptions/SanitizationError.d.ts +8 -0
  107. package/dist/isl/exceptions/SanitizationError.d.ts.map +1 -0
  108. package/dist/isl/exceptions/SanitizationError.js +13 -0
  109. package/dist/isl/exceptions/SanitizationError.js.map +1 -0
  110. package/dist/isl/exceptions/index.d.ts +2 -0
  111. package/dist/isl/exceptions/index.d.ts.map +1 -0
  112. package/dist/isl/exceptions/index.js +2 -0
  113. package/dist/isl/exceptions/index.js.map +1 -0
  114. package/dist/isl/index.d.ts +12 -0
  115. package/dist/isl/index.d.ts.map +1 -0
  116. package/dist/isl/index.js +16 -0
  117. package/dist/isl/index.js.map +1 -0
  118. package/dist/isl/sanitize.d.ts +13 -0
  119. package/dist/isl/sanitize.d.ts.map +1 -0
  120. package/dist/isl/sanitize.js +74 -0
  121. package/dist/isl/sanitize.js.map +1 -0
  122. package/dist/isl/types.d.ts +75 -0
  123. package/dist/isl/types.d.ts.map +1 -0
  124. package/dist/isl/types.js +5 -0
  125. package/dist/isl/types.js.map +1 -0
  126. package/dist/isl/value-objects/AnomalyScore.d.ts +19 -0
  127. package/dist/isl/value-objects/AnomalyScore.d.ts.map +1 -0
  128. package/dist/isl/value-objects/AnomalyScore.js +25 -0
  129. package/dist/isl/value-objects/AnomalyScore.js.map +1 -0
  130. package/dist/isl/value-objects/Pattern.d.ts +32 -0
  131. package/dist/isl/value-objects/Pattern.d.ts.map +1 -0
  132. package/dist/isl/value-objects/Pattern.js +116 -0
  133. package/dist/isl/value-objects/Pattern.js.map +1 -0
  134. package/dist/isl/value-objects/PiDetection.d.ts +22 -0
  135. package/dist/isl/value-objects/PiDetection.d.ts.map +1 -0
  136. package/dist/isl/value-objects/PiDetection.js +60 -0
  137. package/dist/isl/value-objects/PiDetection.js.map +1 -0
  138. package/dist/isl/value-objects/PiDetectionResult.d.ts +24 -0
  139. package/dist/isl/value-objects/PiDetectionResult.d.ts.map +1 -0
  140. package/dist/isl/value-objects/PiDetectionResult.js +90 -0
  141. package/dist/isl/value-objects/PiDetectionResult.js.map +1 -0
  142. package/dist/isl/value-objects/PolicyRule.d.ts +39 -0
  143. package/dist/isl/value-objects/PolicyRule.d.ts.map +1 -0
  144. package/dist/isl/value-objects/PolicyRule.js +65 -0
  145. package/dist/isl/value-objects/PolicyRule.js.map +1 -0
  146. package/dist/isl/value-objects/index.d.ts +9 -0
  147. package/dist/isl/value-objects/index.d.ts.map +1 -0
  148. package/dist/isl/value-objects/index.js +8 -0
  149. package/dist/isl/value-objects/index.js.map +1 -0
  150. package/dist/shared/index.d.ts +9 -0
  151. package/dist/shared/index.d.ts.map +1 -0
  152. package/dist/shared/index.js +12 -0
  153. package/dist/shared/index.js.map +1 -0
  154. package/dist/shared/lineage.d.ts +29 -0
  155. package/dist/shared/lineage.d.ts.map +1 -0
  156. package/dist/shared/lineage.js +36 -0
  157. package/dist/shared/lineage.js.map +1 -0
  158. package/package.json +21 -19
  159. package/src/cpe/envelope.ts +3 -3
  160. package/src/cpe/types.ts +1 -1
  161. package/src/index.ts +2 -0
  162. package/src/isl/sanitize.ts +5 -5
  163. package/src/isl/types.ts +1 -1
  164. package/src/shared/lineage.ts +1 -1
  165. package/tsconfig.json +6 -3
@@ -0,0 +1,90 @@
1
+ import { classifySource } from './classify';
2
+ import { initLineage } from './lineage';
3
+ import { generateId, splitByContextRules } from './utils';
4
+ import { SegmentationError } from './exceptions';
5
+ /**
6
+ * Segmenta input en segmentos semánticos - función pura principal de CSL
7
+ *
8
+ * @remarks
9
+ * Esta es la función principal de CSL. Segmenta el contenido, clasifica
10
+ * por origen, e inicializa el linaje. Todo de forma pura y determinista.
11
+ *
12
+ * **Invariantes preservados:**
13
+ * - El contenido original nunca se pierde
14
+ * - El orden de segmentos es estable
15
+ * - Todo segmento tiene linaje inicial
16
+ * - CSL es determinista
17
+ *
18
+ * @param input - Input con contenido y source
19
+ * @returns CSLResult con segmentos clasificados y linaje inicializado
20
+ *
21
+ * @throws {SegmentationError} Si la segmentación falla
22
+ *
23
+ * @example
24
+ * ```typescript
25
+ * const result = segment({
26
+ * content: 'Hello\nWorld',
27
+ * source: 'UI',
28
+ * metadata: {}
29
+ * })
30
+ *
31
+ * // result.segments contiene 2 segmentos, cada uno con:
32
+ * // - content original
33
+ * // - trust level clasificado
34
+ * // - lineage inicializado
35
+ * ```
36
+ */
37
+ export function segment(input) {
38
+ try {
39
+ // 1. Validar input
40
+ if (!input.content || typeof input.content !== 'string') {
41
+ throw new SegmentationError('CSLInput content must be a non-empty string');
42
+ }
43
+ if (!input.source) {
44
+ throw new SegmentationError('CSLInput source is required');
45
+ }
46
+ // 2. Dividir contenido en segmentos estructurales (función pura)
47
+ // CSL solo segmenta por estructura, no por intención semántica
48
+ const contentSegments = splitByContextRules(input.content);
49
+ // 3. Si no hay contenido, retornar resultado vacío
50
+ if (contentSegments.length === 0) {
51
+ return {
52
+ segments: Object.freeze([]),
53
+ lineage: Object.freeze([])
54
+ };
55
+ }
56
+ // 4. Clasificar source una vez (determinista)
57
+ const trust = classifySource(input.source);
58
+ // 5. Crear segmentos con clasificación y linaje
59
+ const segments = contentSegments.map((content) => {
60
+ // Crear segmento temporal para inicializar linaje
61
+ const tempSegment = {
62
+ id: generateId(),
63
+ content, // ✅ Original preservado
64
+ source: input.source, // ✅ Origen preservado
65
+ trust, // ✅ Clasificación determinista
66
+ lineage: [], // Se inicializa después
67
+ ...(input.metadata && { metadata: input.metadata })
68
+ };
69
+ // Inicializar linaje
70
+ const lineage = initLineage(tempSegment);
71
+ // Retornar segmento completo
72
+ return {
73
+ ...tempSegment,
74
+ lineage // ✅ Linaje inicializado
75
+ };
76
+ });
77
+ // 6. Recolectar todo el linaje
78
+ const allLineage = segments.flatMap(s => s.lineage);
79
+ // 7. Retornar resultado puro
80
+ return {
81
+ segments: Object.freeze(segments),
82
+ lineage: Object.freeze(allLineage)
83
+ };
84
+ }
85
+ catch (error) {
86
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error during segmentation';
87
+ throw new SegmentationError(`Failed to segment content: ${errorMessage}`, error);
88
+ }
89
+ }
90
+ //# sourceMappingURL=segment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"segment.js","sourceRoot":"","sources":["../../src/csl/segment.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AACvC,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,UAAU,OAAO,CAAC,KAAe;IACrC,IAAI,CAAC;QACH,mBAAmB;QACnB,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;YACxD,MAAM,IAAI,iBAAiB,CAAC,6CAA6C,CAAC,CAAA;QAC5E,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;YAClB,MAAM,IAAI,iBAAiB,CAAC,6BAA6B,CAAC,CAAA;QAC5D,CAAC;QAED,iEAAiE;QACjE,+DAA+D;QAC/D,MAAM,eAAe,GAAG,mBAAmB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;QAE1D,mDAAmD;QACnD,IAAI,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACjC,OAAO;gBACL,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;gBAC3B,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;aAC3B,CAAA;QACH,CAAC;QAED,8CAA8C;QAC9C,MAAM,KAAK,GAAG,cAAc,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;QAE1C,gDAAgD;QAChD,MAAM,QAAQ,GAAiB,eAAe,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;YAC7D,kDAAkD;YAClD,MAAM,WAAW,GAAe;gBAC9B,EAAE,EAAE,UAAU,EAAE;gBAChB,OAAO,EAAqB,wBAAwB;gBACpD,MAAM,EAAE,KAAK,CAAC,MAAM,EAAQ,sBAAsB;gBAClD,KAAK,EAAuB,+BAA+B;gBAC3D,OAAO,EAAE,EAAE,EAAiB,wBAAwB;gBACpD,GAAG,CAAC,KAAK,CAAC,QAAQ,IAAI,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC;aACpD,CAAA;YAED,qBAAqB;YACrB,MAAM,OAAO,GAAG,WAAW,CAAC,WAAW,CAAC,CAAA;YAExC,6BAA6B;YAC7B,OAAO;gBACL,GAAG,WAAW;gBACd,OAAO,CAAsB,wBAAwB;aACtD,CAAA;QACH,CAAC,CAAC,CAAA;QAEF,+BAA+B;QAC/B,MAAM,UAAU,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;QAEnD,6BAA6B;QAC7B,OAAO;YACL,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC;YACjC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC;SACnC,CAAA;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,mCAAmC,CAAA;QACjG,MAAM,IAAI,iBAAiB,CAAC,8BAA8B,YAAY,EAAE,EAAE,KAAK,CAAC,CAAA;IAClF,CAAC;AACH,CAAC"}
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Types for CSL (Context Segmentation Layer) - Core Semántico
3
+ *
4
+ * Solo tipos esenciales para CSL. Tipos relacionados con detección,
5
+ * anomalías y políticas van a ISL.
6
+ */
7
+ /**
8
+ * OriginType represents the deterministic source of a content segment.
9
+ */
10
+ export declare enum OriginType {
11
+ /**
12
+ * Direct user input from UI controls
13
+ * Always classified as UC (Untrusted Content) for security.
14
+ */
15
+ USER = "USER",
16
+ /**
17
+ * Content from visible DOM elements
18
+ * Classified as STC (Semi-Trusted Content) because user can verify it.
19
+ */
20
+ DOM_VISIBLE = "DOM_VISIBLE",
21
+ /**
22
+ * Content from hidden DOM elements
23
+ * Classified as UC (Untrusted Content) - potential attack vector.
24
+ */
25
+ DOM_HIDDEN = "DOM_HIDDEN",
26
+ /**
27
+ * Content from DOM attributes (data-*, aria-*, etc.)
28
+ * Classified as STC (Semi-Trusted Content) - visible in source.
29
+ */
30
+ DOM_ATTRIBUTE = "DOM_ATTRIBUTE",
31
+ /**
32
+ * Content injected by scripts (dynamically generated)
33
+ * Classified as UC (Untrusted Content) - can be manipulated.
34
+ */
35
+ SCRIPT_INJECTED = "SCRIPT_INJECTED",
36
+ /**
37
+ * Content fetched from network (API calls, external resources)
38
+ * Classified as UC (Untrusted Content) - external source, not verified.
39
+ */
40
+ NETWORK_FETCHED = "NETWORK_FETCHED",
41
+ /**
42
+ * System-generated content (instructions, system prompts, etc.)
43
+ * Classified as TC (Trusted Content) - system controls this content.
44
+ */
45
+ SYSTEM_GENERATED = "SYSTEM_GENERATED",
46
+ /**
47
+ * Origin cannot be determined
48
+ * Classified as UC (Untrusted Content) - unknown is untrusted by default.
49
+ */
50
+ UNKNOWN = "UNKNOWN"
51
+ }
52
+ /**
53
+ * TrustLevelType represents the trust level of content
54
+ */
55
+ export declare enum TrustLevelType {
56
+ TC = "TC",// Trusted Content
57
+ STC = "STC",// Semi-Trusted Content
58
+ UC = "UC"
59
+ }
60
+ /**
61
+ * HashAlgorithm for ContentHash (opcional, para trazabilidad)
62
+ */
63
+ export type HashAlgorithm = 'sha256' | 'sha512';
64
+ /**
65
+ * Source type for CSL input
66
+ */
67
+ export type Source = 'DOM' | 'UI' | 'SYSTEM' | 'API';
68
+ /**
69
+ * CSLInput - Input para la función segment()
70
+ */
71
+ export interface CSLInput {
72
+ readonly content: string;
73
+ readonly source: Source;
74
+ readonly metadata?: Record<string, unknown>;
75
+ }
76
+ import type { ContentHash, LineageEntry, TrustLevel } from './value-objects';
77
+ /**
78
+ * CSLSegment - Segmento puro, solo datos semánticos
79
+ */
80
+ export interface CSLSegment {
81
+ readonly id: string;
82
+ readonly content: string;
83
+ readonly source: Source;
84
+ readonly trust: TrustLevel;
85
+ readonly lineage: LineageEntry[];
86
+ readonly hash?: ContentHash;
87
+ readonly metadata?: Record<string, unknown>;
88
+ }
89
+ /**
90
+ * CSLResult - Resultado puro, solo datos
91
+ */
92
+ export interface CSLResult {
93
+ readonly segments: readonly CSLSegment[];
94
+ readonly lineage: readonly LineageEntry[];
95
+ readonly processingTimeMs?: number;
96
+ }
97
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/csl/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,oBAAY,UAAU;IACpB;;;OAGG;IACH,IAAI,SAAS;IAEb;;;OAGG;IACH,WAAW,gBAAgB;IAE3B;;;OAGG;IACH,UAAU,eAAe;IAEzB;;;OAGG;IACH,aAAa,kBAAkB;IAE/B;;;OAGG;IACH,eAAe,oBAAoB;IAEnC;;;OAGG;IACH,eAAe,oBAAoB;IAEnC;;;OAGG;IACH,gBAAgB,qBAAqB;IAErC;;;OAGG;IACH,OAAO,YAAY;CACpB;AAED;;GAEG;AACH,oBAAY,cAAc;IACxB,EAAE,OAAO,CAAI,kBAAkB;IAC/B,GAAG,QAAQ,CAAE,uBAAuB;IACpC,EAAE,OAAO;CACV;AAED;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,QAAQ,CAAA;AAE/C;;GAEG;AACH,MAAM,MAAM,MAAM,GAAG,KAAK,GAAG,IAAI,GAAG,QAAQ,GAAG,KAAK,CAAA;AAEpD;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC5C;AAGD,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE5E;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAA;IAC1B,QAAQ,CAAC,OAAO,EAAE,YAAY,EAAE,CAAA;IAChC,QAAQ,CAAC,IAAI,CAAC,EAAE,WAAW,CAAA;IAC3B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC5C;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,QAAQ,EAAE,SAAS,UAAU,EAAE,CAAA;IACxC,QAAQ,CAAC,OAAO,EAAE,SAAS,YAAY,EAAE,CAAA;IACzC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAA;CACnC"}
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Types for CSL (Context Segmentation Layer) - Core Semántico
3
+ *
4
+ * Solo tipos esenciales para CSL. Tipos relacionados con detección,
5
+ * anomalías y políticas van a ISL.
6
+ */
7
+ /**
8
+ * OriginType represents the deterministic source of a content segment.
9
+ */
10
+ export var OriginType;
11
+ (function (OriginType) {
12
+ /**
13
+ * Direct user input from UI controls
14
+ * Always classified as UC (Untrusted Content) for security.
15
+ */
16
+ OriginType["USER"] = "USER";
17
+ /**
18
+ * Content from visible DOM elements
19
+ * Classified as STC (Semi-Trusted Content) because user can verify it.
20
+ */
21
+ OriginType["DOM_VISIBLE"] = "DOM_VISIBLE";
22
+ /**
23
+ * Content from hidden DOM elements
24
+ * Classified as UC (Untrusted Content) - potential attack vector.
25
+ */
26
+ OriginType["DOM_HIDDEN"] = "DOM_HIDDEN";
27
+ /**
28
+ * Content from DOM attributes (data-*, aria-*, etc.)
29
+ * Classified as STC (Semi-Trusted Content) - visible in source.
30
+ */
31
+ OriginType["DOM_ATTRIBUTE"] = "DOM_ATTRIBUTE";
32
+ /**
33
+ * Content injected by scripts (dynamically generated)
34
+ * Classified as UC (Untrusted Content) - can be manipulated.
35
+ */
36
+ OriginType["SCRIPT_INJECTED"] = "SCRIPT_INJECTED";
37
+ /**
38
+ * Content fetched from network (API calls, external resources)
39
+ * Classified as UC (Untrusted Content) - external source, not verified.
40
+ */
41
+ OriginType["NETWORK_FETCHED"] = "NETWORK_FETCHED";
42
+ /**
43
+ * System-generated content (instructions, system prompts, etc.)
44
+ * Classified as TC (Trusted Content) - system controls this content.
45
+ */
46
+ OriginType["SYSTEM_GENERATED"] = "SYSTEM_GENERATED";
47
+ /**
48
+ * Origin cannot be determined
49
+ * Classified as UC (Untrusted Content) - unknown is untrusted by default.
50
+ */
51
+ OriginType["UNKNOWN"] = "UNKNOWN";
52
+ })(OriginType || (OriginType = {}));
53
+ /**
54
+ * TrustLevelType represents the trust level of content
55
+ */
56
+ export var TrustLevelType;
57
+ (function (TrustLevelType) {
58
+ TrustLevelType["TC"] = "TC";
59
+ TrustLevelType["STC"] = "STC";
60
+ TrustLevelType["UC"] = "UC";
61
+ })(TrustLevelType || (TrustLevelType = {}));
62
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/csl/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,CAAN,IAAY,UAgDX;AAhDD,WAAY,UAAU;IACpB;;;OAGG;IACH,2BAAa,CAAA;IAEb;;;OAGG;IACH,yCAA2B,CAAA;IAE3B;;;OAGG;IACH,uCAAyB,CAAA;IAEzB;;;OAGG;IACH,6CAA+B,CAAA;IAE/B;;;OAGG;IACH,iDAAmC,CAAA;IAEnC;;;OAGG;IACH,iDAAmC,CAAA;IAEnC;;;OAGG;IACH,mDAAqC,CAAA;IAErC;;;OAGG;IACH,iCAAmB,CAAA;AACrB,CAAC,EAhDW,UAAU,KAAV,UAAU,QAgDrB;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,cAIX;AAJD,WAAY,cAAc;IACxB,2BAAS,CAAA;IACT,6BAAW,CAAA;IACX,2BAAS,CAAA;AACX,CAAC,EAJW,cAAc,KAAd,cAAc,QAIzB"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Utility functions for CSL - funciones puras
3
+ */
4
+ /**
5
+ * Generates a unique ID for a segment
6
+ */
7
+ export declare function generateId(): string;
8
+ /**
9
+ * Splits content by context rules - función pura de segmentación
10
+ *
11
+ * @remarks
12
+ * Segmentación básica por líneas. Sin normalización agresiva
13
+ * (la normalización va a ISL).
14
+ */
15
+ export declare function splitByContextRules(content: string): string[];
16
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/csl/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAU7D"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Utility functions for CSL - funciones puras
3
+ */
4
+ /**
5
+ * Generates a unique ID for a segment
6
+ */
7
+ export function generateId() {
8
+ return `seg-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
9
+ }
10
+ /**
11
+ * Splits content by context rules - función pura de segmentación
12
+ *
13
+ * @remarks
14
+ * Segmentación básica por líneas. Sin normalización agresiva
15
+ * (la normalización va a ISL).
16
+ */
17
+ export function splitByContextRules(content) {
18
+ if (content.length === 0) {
19
+ return [];
20
+ }
21
+ // Segmentación básica por líneas
22
+ return content
23
+ .split(/\n+/)
24
+ .map(line => line.trim())
25
+ .filter(line => line.length > 0);
26
+ }
27
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/csl/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,UAAU,UAAU;IACxB,OAAO,OAAO,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAA;AAC1E,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAe;IACjD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,EAAE,CAAA;IACX,CAAC;IAED,iCAAiC;IACjC,OAAO,OAAO;SACX,KAAK,CAAC,KAAK,CAAC;SACZ,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;SACxB,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;AACpC,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { HashAlgorithm } from '../types';
2
+ /**
3
+ * ContentHash - tipo puro
4
+ */
5
+ export type ContentHash = {
6
+ readonly value: string;
7
+ readonly algorithm: HashAlgorithm;
8
+ };
9
+ /**
10
+ * Crea un ContentHash - función pura
11
+ */
12
+ export declare function createContentHash(value: string, algorithm?: HashAlgorithm): ContentHash;
13
+ /**
14
+ * Funciones puras para ContentHash
15
+ */
16
+ export declare function isSha256(hash: ContentHash): boolean;
17
+ export declare function isSha512(hash: ContentHash): boolean;
18
+ //# sourceMappingURL=ContentHash.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContentHash.d.ts","sourceRoot":"","sources":["../../../src/csl/value-objects/ContentHash.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAE7C;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAA;CAClC,CAAA;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,GAAE,aAAwB,GAAG,WAAW,CAuBjG;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAEnD;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAEnD"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Crea un ContentHash - función pura
3
+ */
4
+ export function createContentHash(value, algorithm = 'sha256') {
5
+ if (!value || typeof value !== 'string') {
6
+ throw new Error('ContentHash value must be a non-empty string');
7
+ }
8
+ if (!['sha256', 'sha512'].includes(algorithm)) {
9
+ throw new Error(`Invalid HashAlgorithm: ${algorithm}. Must be 'sha256' or 'sha512'`);
10
+ }
11
+ const hexPattern = /^[a-f0-9]+$/i;
12
+ if (!hexPattern.test(value)) {
13
+ throw new Error('ContentHash value must be a valid hexadecimal string');
14
+ }
15
+ const expectedLength = algorithm === 'sha256' ? 64 : 128;
16
+ if (value.length !== expectedLength) {
17
+ throw new Error(`ContentHash value length must be ${expectedLength} characters for ${algorithm}`);
18
+ }
19
+ return {
20
+ value: value.toLowerCase(),
21
+ algorithm
22
+ };
23
+ }
24
+ /**
25
+ * Funciones puras para ContentHash
26
+ */
27
+ export function isSha256(hash) {
28
+ return hash.algorithm === 'sha256';
29
+ }
30
+ export function isSha512(hash) {
31
+ return hash.algorithm === 'sha512';
32
+ }
33
+ //# sourceMappingURL=ContentHash.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContentHash.js","sourceRoot":"","sources":["../../../src/csl/value-objects/ContentHash.ts"],"names":[],"mappings":"AAUA;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAa,EAAE,YAA2B,QAAQ;IAClF,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAA;IACjE,CAAC;IAED,IAAI,CAAC,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;QAC9C,MAAM,IAAI,KAAK,CAAC,0BAA0B,SAAS,gCAAgC,CAAC,CAAA;IACtF,CAAC;IAED,MAAM,UAAU,GAAG,cAAc,CAAA;IACjC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAA;IACzE,CAAC;IAED,MAAM,cAAc,GAAG,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAA;IACxD,IAAI,KAAK,CAAC,MAAM,KAAK,cAAc,EAAE,CAAC;QACpC,MAAM,IAAI,KAAK,CAAC,oCAAoC,cAAc,mBAAmB,SAAS,EAAE,CAAC,CAAA;IACnG,CAAC;IAED,OAAO;QACL,KAAK,EAAE,KAAK,CAAC,WAAW,EAAE;QAC1B,SAAS;KACV,CAAA;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAC,IAAiB;IACxC,OAAO,IAAI,CAAC,SAAS,KAAK,QAAQ,CAAA;AACpC,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,IAAiB;IACxC,OAAO,IAAI,CAAC,SAAS,KAAK,QAAQ,CAAA;AACpC,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * LineageEntry - tipo puro
3
+ *
4
+ * @remarks
5
+ * El core semántico solo preserva linaje estructural.
6
+ * Notes libres son para observabilidad (SDK), no core.
7
+ */
8
+ export type LineageEntry = {
9
+ readonly step: string;
10
+ readonly timestamp: number;
11
+ };
12
+ /**
13
+ * Crea un LineageEntry - función pura
14
+ *
15
+ * @remarks
16
+ * El core solo registra step y timestamp.
17
+ * Notes y metadata van en el SDK para observabilidad.
18
+ */
19
+ export declare function createLineageEntry(step: string, timestamp: number): LineageEntry;
20
+ //# sourceMappingURL=LineageEntry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LineageEntry.d.ts","sourceRoot":"","sources":["../../../src/csl/value-objects/LineageEntry.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;CAC3B,CAAA;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,YAAY,CAahF"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Crea un LineageEntry - función pura
3
+ *
4
+ * @remarks
5
+ * El core solo registra step y timestamp.
6
+ * Notes y metadata van en el SDK para observabilidad.
7
+ */
8
+ export function createLineageEntry(step, timestamp) {
9
+ if (!step || typeof step !== 'string' || step.trim().length === 0) {
10
+ throw new Error('LineageEntry step must be a non-empty string');
11
+ }
12
+ if (typeof timestamp !== 'number' || timestamp < 0 || !Number.isFinite(timestamp)) {
13
+ throw new Error('LineageEntry timestamp must be a valid positive number');
14
+ }
15
+ return {
16
+ step: step.trim(),
17
+ timestamp
18
+ };
19
+ }
20
+ //# sourceMappingURL=LineageEntry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LineageEntry.js","sourceRoot":"","sources":["../../../src/csl/value-objects/LineageEntry.ts"],"names":[],"mappings":"AAYA;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAY,EAAE,SAAiB;IAChE,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAClE,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAA;IACjE,CAAC;IAED,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,SAAS,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;QAClF,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAA;IAC3E,CAAC;IAED,OAAO;QACL,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE;QACjB,SAAS;KACV,CAAA;AACH,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { OriginType, TrustLevelType } from '../types';
2
+ /**
3
+ * originMap is the deterministic mapping from OriginType to TrustLevelType.
4
+ *
5
+ * @remarks
6
+ * This map defines the **deterministic classification rules** for content segments.
7
+ * The mapping is based solely on the origin type, not on content analysis.
8
+ *
9
+ * **Key Principles:**
10
+ * - 100% deterministic: same origin → same trust level, always
11
+ * - No heuristics or content analysis
12
+ * - All OriginType values must be present in this map
13
+ */
14
+ export declare const originMap: Map<OriginType, TrustLevelType>;
15
+ /**
16
+ * Validates that all OriginType values are mapped in originMap.
17
+ *
18
+ * @throws {Error} If any OriginType is not present in originMap
19
+ */
20
+ export declare function validateOriginMap(): void;
21
+ //# sourceMappingURL=Origin-map.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Origin-map.d.ts","sourceRoot":"","sources":["../../../src/csl/value-objects/Origin-map.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAErD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,SAAS,iCAkBpB,CAAA;AAEF;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CAUxC"}
@@ -0,0 +1,42 @@
1
+ import { OriginType, TrustLevelType } from '../types';
2
+ /**
3
+ * originMap is the deterministic mapping from OriginType to TrustLevelType.
4
+ *
5
+ * @remarks
6
+ * This map defines the **deterministic classification rules** for content segments.
7
+ * The mapping is based solely on the origin type, not on content analysis.
8
+ *
9
+ * **Key Principles:**
10
+ * - 100% deterministic: same origin → same trust level, always
11
+ * - No heuristics or content analysis
12
+ * - All OriginType values must be present in this map
13
+ */
14
+ export const originMap = new Map([
15
+ // User origins - always untrusted (security by default)
16
+ [OriginType.USER, TrustLevelType.UC],
17
+ // DOM origins - trust based on visibility
18
+ [OriginType.DOM_VISIBLE, TrustLevelType.STC],
19
+ [OriginType.DOM_HIDDEN, TrustLevelType.UC],
20
+ [OriginType.DOM_ATTRIBUTE, TrustLevelType.STC],
21
+ // External origins - always untrusted
22
+ [OriginType.SCRIPT_INJECTED, TrustLevelType.UC],
23
+ [OriginType.NETWORK_FETCHED, TrustLevelType.UC],
24
+ // System origins - trusted (system controls)
25
+ [OriginType.SYSTEM_GENERATED, TrustLevelType.TC],
26
+ // Unknown - untrusted by default (fail-secure)
27
+ [OriginType.UNKNOWN, TrustLevelType.UC],
28
+ ]);
29
+ /**
30
+ * Validates that all OriginType values are mapped in originMap.
31
+ *
32
+ * @throws {Error} If any OriginType is not present in originMap
33
+ */
34
+ export function validateOriginMap() {
35
+ const allOriginTypes = Object.values(OriginType);
36
+ const missingTypes = allOriginTypes.filter(type => !originMap.has(type));
37
+ if (missingTypes.length > 0) {
38
+ throw new Error(`Missing origin mappings: ${missingTypes.join(', ')}. ` +
39
+ `All OriginType values must be mapped in originMap.`);
40
+ }
41
+ }
42
+ //# sourceMappingURL=Origin-map.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Origin-map.js","sourceRoot":"","sources":["../../../src/csl/value-objects/Origin-map.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAErD;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,GAAG,CAA6B;IAC3D,wDAAwD;IACxD,CAAC,UAAU,CAAC,IAAI,EAAE,cAAc,CAAC,EAAE,CAAC;IAEpC,0CAA0C;IAC1C,CAAC,UAAU,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,CAAC;IAC5C,CAAC,UAAU,CAAC,UAAU,EAAE,cAAc,CAAC,EAAE,CAAC;IAC1C,CAAC,UAAU,CAAC,aAAa,EAAE,cAAc,CAAC,GAAG,CAAC;IAE9C,sCAAsC;IACtC,CAAC,UAAU,CAAC,eAAe,EAAE,cAAc,CAAC,EAAE,CAAC;IAC/C,CAAC,UAAU,CAAC,eAAe,EAAE,cAAc,CAAC,EAAE,CAAC;IAE/C,6CAA6C;IAC7C,CAAC,UAAU,CAAC,gBAAgB,EAAE,cAAc,CAAC,EAAE,CAAC;IAEhD,+CAA+C;IAC/C,CAAC,UAAU,CAAC,OAAO,EAAE,cAAc,CAAC,EAAE,CAAC;CACxC,CAAC,CAAA;AAEF;;;;GAIG;AACH,MAAM,UAAU,iBAAiB;IAC/B,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAA;IAChD,MAAM,YAAY,GAAG,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAA;IAExE,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CACb,4BAA4B,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI;YACvD,oDAAoD,CACrD,CAAA;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { OriginType } from '../types';
2
+ /**
3
+ * Origin - tipo puro
4
+ */
5
+ export type Origin = {
6
+ readonly type: OriginType;
7
+ };
8
+ /**
9
+ * Crea un Origin - función pura
10
+ */
11
+ export declare function createOrigin(type: OriginType): Origin;
12
+ /**
13
+ * Funciones puras para Origin
14
+ */
15
+ export declare function isDom(origin: Origin): boolean;
16
+ export declare function isUser(origin: Origin): boolean;
17
+ export declare function isSystem(origin: Origin): boolean;
18
+ export declare function isInjected(origin: Origin): boolean;
19
+ export declare function isUnknown(origin: Origin): boolean;
20
+ export declare function isNetworkFetched(origin: Origin): boolean;
21
+ export declare function isExternal(origin: Origin): boolean;
22
+ //# sourceMappingURL=Origin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Origin.d.ts","sourceRoot":"","sources":["../../../src/csl/value-objects/Origin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAErC;;GAEG;AACH,MAAM,MAAM,MAAM,GAAG;IACnB,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAA;CAC1B,CAAA;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CAKrD;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAI7C;AAED,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAE9C;AAED,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEhD;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAElD;AAED,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEjD;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAExD;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAGlD"}
@@ -0,0 +1,38 @@
1
+ import { OriginType } from '../types';
2
+ /**
3
+ * Crea un Origin - función pura
4
+ */
5
+ export function createOrigin(type) {
6
+ if (!Object.values(OriginType).includes(type)) {
7
+ throw new Error(`Invalid Origin type: ${type}`);
8
+ }
9
+ return { type };
10
+ }
11
+ /**
12
+ * Funciones puras para Origin
13
+ */
14
+ export function isDom(origin) {
15
+ return origin.type === OriginType.DOM_HIDDEN ||
16
+ origin.type === OriginType.DOM_VISIBLE ||
17
+ origin.type === OriginType.DOM_ATTRIBUTE;
18
+ }
19
+ export function isUser(origin) {
20
+ return origin.type === OriginType.USER;
21
+ }
22
+ export function isSystem(origin) {
23
+ return origin.type === OriginType.SYSTEM_GENERATED;
24
+ }
25
+ export function isInjected(origin) {
26
+ return origin.type === OriginType.SCRIPT_INJECTED;
27
+ }
28
+ export function isUnknown(origin) {
29
+ return origin.type === OriginType.UNKNOWN;
30
+ }
31
+ export function isNetworkFetched(origin) {
32
+ return origin.type === OriginType.NETWORK_FETCHED;
33
+ }
34
+ export function isExternal(origin) {
35
+ return origin.type === OriginType.NETWORK_FETCHED ||
36
+ origin.type === OriginType.SCRIPT_INJECTED;
37
+ }
38
+ //# sourceMappingURL=Origin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Origin.js","sourceRoot":"","sources":["../../../src/csl/value-objects/Origin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AASrC;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,IAAgB;IAC3C,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QAC9C,MAAM,IAAI,KAAK,CAAC,wBAAwB,IAAI,EAAE,CAAC,CAAA;IACjD,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,CAAA;AACjB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,KAAK,CAAC,MAAc;IAClC,OAAO,MAAM,CAAC,IAAI,KAAK,UAAU,CAAC,UAAU;QACrC,MAAM,CAAC,IAAI,KAAK,UAAU,CAAC,WAAW;QACtC,MAAM,CAAC,IAAI,KAAK,UAAU,CAAC,aAAa,CAAA;AACjD,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,MAAc;IACnC,OAAO,MAAM,CAAC,IAAI,KAAK,UAAU,CAAC,IAAI,CAAA;AACxC,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,MAAc;IACrC,OAAO,MAAM,CAAC,IAAI,KAAK,UAAU,CAAC,gBAAgB,CAAA;AACpD,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,MAAc;IACvC,OAAO,MAAM,CAAC,IAAI,KAAK,UAAU,CAAC,eAAe,CAAA;AACnD,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,MAAc;IACtC,OAAO,MAAM,CAAC,IAAI,KAAK,UAAU,CAAC,OAAO,CAAA;AAC3C,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,MAAc;IAC7C,OAAO,MAAM,CAAC,IAAI,KAAK,UAAU,CAAC,eAAe,CAAA;AACnD,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,MAAc;IACvC,OAAO,MAAM,CAAC,IAAI,KAAK,UAAU,CAAC,eAAe;QAC1C,MAAM,CAAC,IAAI,KAAK,UAAU,CAAC,eAAe,CAAA;AACnD,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { TrustLevelType } from '../types';
2
+ /**
3
+ * TrustLevel - tipo puro
4
+ */
5
+ export type TrustLevel = {
6
+ readonly value: TrustLevelType;
7
+ };
8
+ /**
9
+ * Crea un TrustLevel - función pura
10
+ */
11
+ export declare function createTrustLevel(value: TrustLevelType): TrustLevel;
12
+ /**
13
+ * Funciones puras para TrustLevel
14
+ */
15
+ export declare function isTrusted(trust: TrustLevel): boolean;
16
+ export declare function isSemiTrusted(trust: TrustLevel): boolean;
17
+ export declare function isUntrusted(trust: TrustLevel): boolean;
18
+ //# sourceMappingURL=TrustLevel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TrustLevel.d.ts","sourceRoot":"","sources":["../../../src/csl/value-objects/TrustLevel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAEzC;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAA;CAC/B,CAAA;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,cAAc,GAAG,UAAU,CAKlE;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAEpD;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAExD;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAEtD"}
@@ -0,0 +1,23 @@
1
+ import { TrustLevelType } from '../types';
2
+ /**
3
+ * Crea un TrustLevel - función pura
4
+ */
5
+ export function createTrustLevel(value) {
6
+ if (!Object.values(TrustLevelType).includes(value)) {
7
+ throw new Error(`Invalid TrustLevel: ${value}`);
8
+ }
9
+ return { value };
10
+ }
11
+ /**
12
+ * Funciones puras para TrustLevel
13
+ */
14
+ export function isTrusted(trust) {
15
+ return trust.value === TrustLevelType.TC;
16
+ }
17
+ export function isSemiTrusted(trust) {
18
+ return trust.value === TrustLevelType.STC;
19
+ }
20
+ export function isUntrusted(trust) {
21
+ return trust.value === TrustLevelType.UC;
22
+ }
23
+ //# sourceMappingURL=TrustLevel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TrustLevel.js","sourceRoot":"","sources":["../../../src/csl/value-objects/TrustLevel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AASzC;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAqB;IACpD,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACnD,MAAM,IAAI,KAAK,CAAC,uBAAuB,KAAK,EAAE,CAAC,CAAA;IACjD,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,CAAA;AAClB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,KAAiB;IACzC,OAAO,KAAK,CAAC,KAAK,KAAK,cAAc,CAAC,EAAE,CAAA;AAC1C,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,KAAiB;IAC7C,OAAO,KAAK,CAAC,KAAK,KAAK,cAAc,CAAC,GAAG,CAAA;AAC3C,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,KAAiB;IAC3C,OAAO,KAAK,CAAC,KAAK,KAAK,cAAc,CAAC,EAAE,CAAA;AAC1C,CAAC"}
@@ -0,0 +1,10 @@
1
+ export type { TrustLevel } from './TrustLevel';
2
+ export type { Origin } from './Origin';
3
+ export type { LineageEntry } from './LineageEntry';
4
+ export type { ContentHash } from './ContentHash';
5
+ export { createTrustLevel, isTrusted, isSemiTrusted, isUntrusted } from './TrustLevel';
6
+ export { createOrigin, isDom, isUser, isSystem, isInjected, isUnknown, isNetworkFetched, isExternal } from './Origin';
7
+ export { createLineageEntry } from './LineageEntry';
8
+ export { createContentHash, isSha256, isSha512 } from './ContentHash';
9
+ export { originMap, validateOriginMap } from './Origin-map';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/csl/value-objects/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAC9C,YAAY,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACtC,YAAY,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAClD,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAGhD,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AACtF,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AACrH,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AACnD,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAGrE,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA"}