@cyclonedx/cyclonedx-library 1.0.0-beta.1

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 (169) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +5 -0
  3. package/README.md +152 -0
  4. package/dist.node/_index.node.js +53 -0
  5. package/dist.node/_index.node.js.map +1 -0
  6. package/dist.node/enums/attachmentEncoding.js +26 -0
  7. package/dist.node/enums/attachmentEncoding.js.map +1 -0
  8. package/dist.node/enums/componentScope.js +28 -0
  9. package/dist.node/enums/componentScope.js.map +1 -0
  10. package/dist.node/enums/componentType.js +33 -0
  11. package/dist.node/enums/componentType.js.map +1 -0
  12. package/dist.node/enums/externalReferenceType.js +41 -0
  13. package/dist.node/enums/externalReferenceType.js.map +1 -0
  14. package/dist.node/enums/hashAlogorithm.js +37 -0
  15. package/dist.node/enums/hashAlogorithm.js.map +1 -0
  16. package/dist.node/enums/index.js +40 -0
  17. package/dist.node/enums/index.js.map +1 -0
  18. package/dist.node/factories/index.js +36 -0
  19. package/dist.node/factories/index.js.map +1 -0
  20. package/dist.node/factories/licenseFactory.js +56 -0
  21. package/dist.node/factories/licenseFactory.js.map +1 -0
  22. package/dist.node/helpers/types.js +26 -0
  23. package/dist.node/helpers/types.js.map +1 -0
  24. package/dist.node/models/attachment.js +30 -0
  25. package/dist.node/models/attachment.js.map +1 -0
  26. package/dist.node/models/bom.js +67 -0
  27. package/dist.node/models/bom.js.map +1 -0
  28. package/dist.node/models/bomRef.js +37 -0
  29. package/dist.node/models/bomRef.js.map +1 -0
  30. package/dist.node/models/component.js +96 -0
  31. package/dist.node/models/component.js.map +1 -0
  32. package/dist.node/models/externalReference.js +40 -0
  33. package/dist.node/models/externalReference.js.map +1 -0
  34. package/dist.node/models/hash.js +29 -0
  35. package/dist.node/models/hash.js.map +1 -0
  36. package/dist.node/models/index.js +47 -0
  37. package/dist.node/models/index.js.map +1 -0
  38. package/dist.node/models/license.js +103 -0
  39. package/dist.node/models/license.js.map +1 -0
  40. package/dist.node/models/metadata.js +35 -0
  41. package/dist.node/models/metadata.js.map +1 -0
  42. package/dist.node/models/organizationalContact.js +41 -0
  43. package/dist.node/models/organizationalContact.js.map +1 -0
  44. package/dist.node/models/organizationalEntity.js +31 -0
  45. package/dist.node/models/organizationalEntity.js.map +1 -0
  46. package/dist.node/models/swid.js +58 -0
  47. package/dist.node/models/swid.js.map +1 -0
  48. package/dist.node/models/tool.js +45 -0
  49. package/dist.node/models/tool.js.map +1 -0
  50. package/dist.node/resources.node.js +55 -0
  51. package/dist.node/resources.node.js.map +1 -0
  52. package/dist.node/serialize/_index.node.js +37 -0
  53. package/dist.node/serialize/_index.node.js.map +1 -0
  54. package/dist.node/serialize/baseSerializer.js +56 -0
  55. package/dist.node/serialize/baseSerializer.js.map +1 -0
  56. package/dist.node/serialize/bomRefDiscriminator.js +66 -0
  57. package/dist.node/serialize/bomRefDiscriminator.js.map +1 -0
  58. package/dist.node/serialize/index.js +55 -0
  59. package/dist.node/serialize/index.js.map +1 -0
  60. package/dist.node/serialize/json/index.js +47 -0
  61. package/dist.node/serialize/json/index.js.map +1 -0
  62. package/dist.node/serialize/json/normalize.js +431 -0
  63. package/dist.node/serialize/json/normalize.js.map +1 -0
  64. package/dist.node/serialize/json/types.js +35 -0
  65. package/dist.node/serialize/json/types.js.map +1 -0
  66. package/dist.node/serialize/jsonSerializer.js +55 -0
  67. package/dist.node/serialize/jsonSerializer.js.map +1 -0
  68. package/dist.node/serialize/types.js +21 -0
  69. package/dist.node/serialize/types.js.map +1 -0
  70. package/dist.node/serialize/xml/index.js +47 -0
  71. package/dist.node/serialize/xml/index.js.map +1 -0
  72. package/dist.node/serialize/xml/normalize.js +560 -0
  73. package/dist.node/serialize/xml/normalize.js.map +1 -0
  74. package/dist.node/serialize/xml/types.js +31 -0
  75. package/dist.node/serialize/xml/types.js.map +1 -0
  76. package/dist.node/serialize/xmlBaseSerializer.js +52 -0
  77. package/dist.node/serialize/xmlBaseSerializer.js.map +1 -0
  78. package/dist.node/serialize/xmlSerializer.node.js +30 -0
  79. package/dist.node/serialize/xmlSerializer.node.js.map +1 -0
  80. package/dist.node/spdx.js +35 -0
  81. package/dist.node/spdx.js.map +1 -0
  82. package/dist.node/spec.js +229 -0
  83. package/dist.node/spec.js.map +1 -0
  84. package/dist.node/types/cpe.js +28 -0
  85. package/dist.node/types/cpe.js.map +1 -0
  86. package/dist.node/types/index.js +39 -0
  87. package/dist.node/types/index.js.map +1 -0
  88. package/dist.node/types/integer.js +36 -0
  89. package/dist.node/types/integer.js.map +1 -0
  90. package/dist.node/types/mimeType.js +28 -0
  91. package/dist.node/types/mimeType.js.map +1 -0
  92. package/dist.node/types/urn.js +28 -0
  93. package/dist.node/types/urn.js.map +1 -0
  94. package/dist.web/lib.dev.js +3487 -0
  95. package/dist.web/lib.dev.js.map +1 -0
  96. package/dist.web/lib.js +2 -0
  97. package/dist.web/lib.js.LICENSE.txt +18 -0
  98. package/libs/universal-node-xml/index.d.ts +33 -0
  99. package/libs/universal-node-xml/index.js +42 -0
  100. package/libs/universal-node-xml/stringifiers/helpers.js +17 -0
  101. package/libs/universal-node-xml/stringifiers/xmlbuilder2.js +51 -0
  102. package/package.json +86 -0
  103. package/res/README.md +27 -0
  104. package/res/bom-1.0.SNAPSHOT.xsd +247 -0
  105. package/res/bom-1.1.SNAPSHOT.xsd +731 -0
  106. package/res/bom-1.2-strict.SNAPSHOT.schema.json +1026 -0
  107. package/res/bom-1.2.SNAPSHOT.schema.json +997 -0
  108. package/res/bom-1.2.SNAPSHOT.xsd +1418 -0
  109. package/res/bom-1.3-strict.SNAPSHOT.schema.json +1085 -0
  110. package/res/bom-1.3.SNAPSHOT.schema.json +1054 -0
  111. package/res/bom-1.3.SNAPSHOT.xsd +1631 -0
  112. package/res/bom-1.4.SNAPSHOT.schema.json +1697 -0
  113. package/res/bom-1.4.SNAPSHOT.xsd +2407 -0
  114. package/res/jsf-0.82.SNAPSHOT.schema.json +244 -0
  115. package/res/spdx.SNAPSHOT.schema.json +533 -0
  116. package/res/spdx.SNAPSHOT.xsd +2639 -0
  117. package/src/_index.node.ts +31 -0
  118. package/src/_index.web.ts +27 -0
  119. package/src/enums/attachmentEncoding.ts +22 -0
  120. package/src/enums/componentScope.ts +24 -0
  121. package/src/enums/componentType.ts +29 -0
  122. package/src/enums/externalReferenceType.ts +37 -0
  123. package/src/enums/hashAlogorithm.ts +33 -0
  124. package/src/enums/index.ts +24 -0
  125. package/src/factories/index.ts +20 -0
  126. package/src/factories/licenseFactory.ts +62 -0
  127. package/src/helpers/README.md +3 -0
  128. package/src/helpers/types.ts +28 -0
  129. package/src/models/attachment.ts +37 -0
  130. package/src/models/bom.ts +85 -0
  131. package/src/models/bomRef.ts +41 -0
  132. package/src/models/component.ts +136 -0
  133. package/src/models/externalReference.ts +48 -0
  134. package/src/models/hash.ts +38 -0
  135. package/src/models/index.ts +31 -0
  136. package/src/models/license.ts +133 -0
  137. package/src/models/metadata.ts +50 -0
  138. package/src/models/organizationalContact.ts +49 -0
  139. package/src/models/organizationalEntity.ts +38 -0
  140. package/src/models/swid.ts +71 -0
  141. package/src/models/tool.ts +58 -0
  142. package/src/resources.node.ts +59 -0
  143. package/src/serialize/_index.node.ts +23 -0
  144. package/src/serialize/_index.web.ts +23 -0
  145. package/src/serialize/baseSerializer.ts +52 -0
  146. package/src/serialize/bomRefDiscriminator.ts +69 -0
  147. package/src/serialize/index.ts +35 -0
  148. package/src/serialize/json/index.ts +23 -0
  149. package/src/serialize/json/normalize.ts +450 -0
  150. package/src/serialize/json/types.ts +187 -0
  151. package/src/serialize/jsonSerializer.ts +59 -0
  152. package/src/serialize/types.ts +38 -0
  153. package/src/serialize/xml/index.ts +23 -0
  154. package/src/serialize/xml/normalize.ts +590 -0
  155. package/src/serialize/xml/types.ts +112 -0
  156. package/src/serialize/xmlBaseSerializer.ts +52 -0
  157. package/src/serialize/xmlSerializer.node.ts +35 -0
  158. package/src/serialize/xmlSerializer.web.ts +89 -0
  159. package/src/spdx.ts +48 -0
  160. package/src/spec.ts +289 -0
  161. package/src/types/cpe.ts +33 -0
  162. package/src/types/index.ts +23 -0
  163. package/src/types/integer.ts +50 -0
  164. package/src/types/mimeType.ts +31 -0
  165. package/src/types/urn.ts +33 -0
  166. package/tsconfig.json +108 -0
  167. package/tsconfig.node.json +8 -0
  168. package/tsconfig.web.json +5 -0
  169. package/webpack.config.js +74 -0
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ /*!
3
+ This file is part of CycloneDX JavaScript Library.
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+
17
+ SPDX-License-Identifier: Apache-2.0
18
+ Copyright (c) OWASP Foundation. All Rights Reserved.
19
+ */
20
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ var desc = Object.getOwnPropertyDescriptor(m, k);
23
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
24
+ desc = { enumerable: true, get: function() { return m[k]; } };
25
+ }
26
+ Object.defineProperty(o, k2, desc);
27
+ }) : (function(o, m, k, k2) {
28
+ if (k2 === undefined) k2 = k;
29
+ o[k2] = m[k];
30
+ }));
31
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
32
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
33
+ };
34
+ Object.defineProperty(exports, "__esModule", { value: true });
35
+ __exportStar(require("./licenseFactory"), exports);
36
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/factories/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;EAiBE;;;;;;;;;;;;;;;;AAEF,mDAAgC"}
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ /*!
3
+ This file is part of CycloneDX JavaScript Library.
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+
17
+ SPDX-License-Identifier: Apache-2.0
18
+ Copyright (c) OWASP Foundation. All Rights Reserved.
19
+ */
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.LicenseFactory = void 0;
22
+ const models_1 = require("../models");
23
+ const spdx_1 = require("../spdx");
24
+ class LicenseFactory {
25
+ makeFromString(value) {
26
+ try {
27
+ return this.makeExpression(value);
28
+ }
29
+ catch (Error) {
30
+ return this.makeDisjunctive(value);
31
+ }
32
+ }
33
+ makeExpression(value) {
34
+ return new models_1.LicenseExpression(value);
35
+ }
36
+ makeDisjunctive(value) {
37
+ try {
38
+ return this.makeDisjunctiveWithId(value);
39
+ }
40
+ catch (error) {
41
+ return this.makeDisjunctiveWithName(value);
42
+ }
43
+ }
44
+ makeDisjunctiveWithId(value) {
45
+ const spdxId = (0, spdx_1.fixupSpdxId)(String(value));
46
+ if (undefined === spdxId) {
47
+ throw new RangeError('Unsupported SPDX id');
48
+ }
49
+ return new models_1.SpdxLicense(spdxId);
50
+ }
51
+ makeDisjunctiveWithName(value) {
52
+ return new models_1.NamedLicense(String(value));
53
+ }
54
+ }
55
+ exports.LicenseFactory = LicenseFactory;
56
+ //# sourceMappingURL=licenseFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"licenseFactory.js","sourceRoot":"","sources":["../../src/factories/licenseFactory.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;EAiBE;;;AAEF,sCAAqG;AACrG,kCAAqC;AAErC,MAAa,cAAc;IACzB,cAAc,CAAE,KAAa;QAC3B,IAAI;YACF,OAAO,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAA;SAClC;QAAC,OAAO,KAAK,EAAE;YACd,OAAO,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAA;SACnC;IACH,CAAC;IAKD,cAAc,CAAE,KAAa;QAC3B,OAAO,IAAI,0BAAiB,CAAC,KAAK,CAAC,CAAA;IACrC,CAAC;IAED,eAAe,CAAE,KAAa;QAC5B,IAAI;YACF,OAAO,IAAI,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAA;SACzC;QAAC,OAAO,KAAK,EAAE;YACd,OAAO,IAAI,CAAC,uBAAuB,CAAC,KAAK,CAAC,CAAA;SAC3C;IACH,CAAC;IAKD,qBAAqB,CAAE,KAAmB;QACxC,MAAM,MAAM,GAAG,IAAA,kBAAW,EAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;QACzC,IAAI,SAAS,KAAK,MAAM,EAAE;YACxB,MAAM,IAAI,UAAU,CAAC,qBAAqB,CAAC,CAAA;SAC5C;QAED,OAAO,IAAI,oBAAW,CAAC,MAAM,CAAC,CAAA;IAChC,CAAC;IAED,uBAAuB,CAAE,KAAmB;QAC1C,OAAO,IAAI,qBAAY,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;IACxC,CAAC;CACF;AAvCD,wCAuCC"}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ /*!
3
+ This file is part of CycloneDX JavaScript Library.
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+
17
+ SPDX-License-Identifier: Apache-2.0
18
+ Copyright (c) OWASP Foundation. All Rights Reserved.
19
+ */
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.isNotUndefined = void 0;
22
+ function isNotUndefined(value) {
23
+ return value !== undefined;
24
+ }
25
+ exports.isNotUndefined = isNotUndefined;
26
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/helpers/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;EAiBE;;;AAIF,SAAgB,cAAc,CAAK,KAAoB;IACrD,OAAO,KAAK,KAAK,SAAS,CAAA;AAC5B,CAAC;AAFD,wCAEC"}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ /*!
3
+ This file is part of CycloneDX JavaScript Library.
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+
17
+ SPDX-License-Identifier: Apache-2.0
18
+ Copyright (c) OWASP Foundation. All Rights Reserved.
19
+ */
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.Attachment = void 0;
22
+ class Attachment {
23
+ constructor(content, op = {}) {
24
+ this.contentType = op.contentType;
25
+ this.content = content;
26
+ this.encoding = op.encoding;
27
+ }
28
+ }
29
+ exports.Attachment = Attachment;
30
+ //# sourceMappingURL=attachment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attachment.js","sourceRoot":"","sources":["../../src/models/attachment.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;EAiBE;;;AASF,MAAa,UAAU;IAKrB,YAAa,OAAe,EAAE,KAAyB,EAAE;QACvD,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC,WAAW,CAAA;QACjC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC,QAAQ,CAAA;IAC7B,CAAC;CACF;AAVD,gCAUC"}
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ /*!
3
+ This file is part of CycloneDX JavaScript Library.
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+
17
+ SPDX-License-Identifier: Apache-2.0
18
+ Copyright (c) OWASP Foundation. All Rights Reserved.
19
+ */
20
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
21
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
22
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
23
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
24
+ };
25
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
26
+ if (kind === "m") throw new TypeError("Private method is not writable");
27
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
28
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
29
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
30
+ };
31
+ var _Bom_version, _Bom_serialNumber;
32
+ Object.defineProperty(exports, "__esModule", { value: true });
33
+ exports.Bom = void 0;
34
+ const types_1 = require("../types");
35
+ const metadata_1 = require("./metadata");
36
+ const component_1 = require("./component");
37
+ class Bom {
38
+ constructor(op = {}) {
39
+ _Bom_version.set(this, 1);
40
+ _Bom_serialNumber.set(this, void 0);
41
+ this.metadata = op.metadata ?? new metadata_1.Metadata();
42
+ this.components = op.components ?? new component_1.ComponentRepository();
43
+ this.version = op.version ?? this.version;
44
+ this.serialNumber = op.serialNumber;
45
+ }
46
+ get version() {
47
+ return __classPrivateFieldGet(this, _Bom_version, "f");
48
+ }
49
+ set version(value) {
50
+ if (!(0, types_1.isPositiveInteger)(value)) {
51
+ throw new TypeError('Not PositiveInteger');
52
+ }
53
+ __classPrivateFieldSet(this, _Bom_version, value, "f");
54
+ }
55
+ get serialNumber() {
56
+ return __classPrivateFieldGet(this, _Bom_serialNumber, "f");
57
+ }
58
+ set serialNumber(value) {
59
+ if (value !== undefined && !(0, types_1.isUrnUuid)(value)) {
60
+ throw new TypeError('Not UrnUuid nor undefined');
61
+ }
62
+ __classPrivateFieldSet(this, _Bom_serialNumber, value, "f");
63
+ }
64
+ }
65
+ exports.Bom = Bom;
66
+ _Bom_version = new WeakMap(), _Bom_serialNumber = new WeakMap();
67
+ //# sourceMappingURL=bom.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bom.js","sourceRoot":"","sources":["../../src/models/bom.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;EAiBE;;;;;;;;;;;;;;;AAEF,oCAAiF;AACjF,yCAAqC;AACrC,2CAAiD;AASjD,MAAa,GAAG;IAoBd,YAAa,KAAyB,EAAE;QAfxC,uBAA4B,CAAC,EAAA;QAG7B,oCAAuB;QAarB,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC,QAAQ,IAAI,IAAI,mBAAQ,EAAE,CAAA;QAC7C,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC,UAAU,IAAI,IAAI,+BAAmB,EAAE,CAAA;QAC5D,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAA;QACzC,IAAI,CAAC,YAAY,GAAG,EAAE,CAAC,YAAY,CAAA;IACrC,CAAC;IAED,IAAI,OAAO;QACT,OAAO,uBAAA,IAAI,oBAAS,CAAA;IACtB,CAAC;IAKD,IAAI,OAAO,CAAE,KAAsB;QACjC,IAAI,CAAC,IAAA,yBAAiB,EAAC,KAAK,CAAC,EAAE;YAC7B,MAAM,IAAI,SAAS,CAAC,qBAAqB,CAAC,CAAA;SAC3C;QACD,uBAAA,IAAI,gBAAY,KAAK,MAAA,CAAA;IACvB,CAAC;IAED,IAAI,YAAY;QACd,OAAO,uBAAA,IAAI,yBAAc,CAAA;IAC3B,CAAC;IAKD,IAAI,YAAY,CAAE,KAA0B;QAC1C,IAAI,KAAK,KAAK,SAAS,IAAI,CAAC,IAAA,iBAAS,EAAC,KAAK,CAAC,EAAE;YAC5C,MAAM,IAAI,SAAS,CAAC,2BAA2B,CAAC,CAAA;SACjD;QACD,uBAAA,IAAI,qBAAiB,KAAK,MAAA,CAAA;IAC5B,CAAC;CACF;AAtDD,kBAsDC"}
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ /*!
3
+ This file is part of CycloneDX JavaScript Library.
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+
17
+ SPDX-License-Identifier: Apache-2.0
18
+ Copyright (c) OWASP Foundation. All Rights Reserved.
19
+ */
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.BomRefRepository = exports.BomRef = void 0;
22
+ class BomRef {
23
+ constructor(value) {
24
+ this.value = value;
25
+ }
26
+ compare(other) {
27
+ return (this.toString()).localeCompare(other.toString());
28
+ }
29
+ toString() {
30
+ return this.value ?? '';
31
+ }
32
+ }
33
+ exports.BomRef = BomRef;
34
+ class BomRefRepository extends Set {
35
+ }
36
+ exports.BomRefRepository = BomRefRepository;
37
+ //# sourceMappingURL=bomRef.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bomRef.js","sourceRoot":"","sources":["../../src/models/bomRef.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;EAiBE;;;AAMF,MAAa,MAAM;IAGjB,YAAa,KAAc;QACzB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;IAED,OAAO,CAAE,KAAa;QACpB,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAA;IAC1D,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,KAAK,IAAI,EAAE,CAAA;IACzB,CAAC;CACF;AAdD,wBAcC;AAED,MAAa,gBAAiB,SAAQ,GAAW;CAChD;AADD,4CACC"}
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ /*!
3
+ This file is part of CycloneDX JavaScript Library.
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+
17
+ SPDX-License-Identifier: Apache-2.0
18
+ Copyright (c) OWASP Foundation. All Rights Reserved.
19
+ */
20
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
21
+ if (kind === "m") throw new TypeError("Private method is not writable");
22
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
23
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
24
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
25
+ };
26
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
27
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
28
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
29
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
30
+ };
31
+ var _Component_bomRef, _Component_cpe;
32
+ Object.defineProperty(exports, "__esModule", { value: true });
33
+ exports.ComponentRepository = exports.Component = void 0;
34
+ const types_1 = require("../types");
35
+ const bomRef_1 = require("./bomRef");
36
+ const hash_1 = require("./hash");
37
+ const externalReference_1 = require("./externalReference");
38
+ const license_1 = require("./license");
39
+ class Component {
40
+ constructor(type, name, op = {}) {
41
+ _Component_bomRef.set(this, void 0);
42
+ _Component_cpe.set(this, void 0);
43
+ __classPrivateFieldSet(this, _Component_bomRef, new bomRef_1.BomRef(op.bomRef), "f");
44
+ this.type = type;
45
+ this.name = name;
46
+ this.author = op.author;
47
+ this.copyright = op.copyright;
48
+ this.externalReferences = op.externalReferences ?? new externalReference_1.ExternalReferenceRepository();
49
+ this.group = op.group;
50
+ this.hashes = op.hashes ?? new hash_1.HashRepository();
51
+ this.licenses = op.licenses ?? new license_1.LicenseRepository();
52
+ this.publisher = op.publisher;
53
+ this.purl = op.purl;
54
+ this.scope = op.scope;
55
+ this.swid = op.swid;
56
+ this.version = op.version;
57
+ this.dependencies = op.dependencies ?? new bomRef_1.BomRefRepository();
58
+ this.cpe = op.cpe;
59
+ }
60
+ get bomRef() {
61
+ return __classPrivateFieldGet(this, _Component_bomRef, "f");
62
+ }
63
+ get cpe() {
64
+ return __classPrivateFieldGet(this, _Component_cpe, "f");
65
+ }
66
+ set cpe(value) {
67
+ if (value !== undefined && !(0, types_1.isCPE)(value)) {
68
+ throw new TypeError('Not CPE nor undefined');
69
+ }
70
+ __classPrivateFieldSet(this, _Component_cpe, value, "f");
71
+ }
72
+ compare(other) {
73
+ const bomRefCompare = this.bomRef.compare(other.bomRef);
74
+ if (bomRefCompare !== 0) {
75
+ return bomRefCompare;
76
+ }
77
+ if (this.purl !== undefined && other.purl !== undefined) {
78
+ return this.purl.toString().localeCompare(other.purl.toString());
79
+ }
80
+ if (__classPrivateFieldGet(this, _Component_cpe, "f") !== undefined && __classPrivateFieldGet(other, _Component_cpe, "f") !== undefined) {
81
+ return __classPrivateFieldGet(this, _Component_cpe, "f").toString().localeCompare(__classPrivateFieldGet(other, _Component_cpe, "f").toString());
82
+ }
83
+ return (this.group ?? '').localeCompare(other.group ?? '') ||
84
+ this.name.localeCompare(other.name) ||
85
+ (this.version ?? '').localeCompare(other.version ?? '');
86
+ }
87
+ }
88
+ exports.Component = Component;
89
+ _Component_bomRef = new WeakMap(), _Component_cpe = new WeakMap();
90
+ class ComponentRepository extends Set {
91
+ static compareItems(a, b) {
92
+ return a.compare(b);
93
+ }
94
+ }
95
+ exports.ComponentRepository = ComponentRepository;
96
+ //# sourceMappingURL=component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component.js","sourceRoot":"","sources":["../../src/models/component.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;EAiBE;;;;;;;;;;;;;;;AAIF,oCAAqC;AAErC,qCAAmD;AACnD,iCAAuC;AAEvC,2DAAiE;AACjE,uCAA6C;AAsB7C,MAAa,SAAS;IA2BpB,YAAa,IAAmB,EAAE,IAAY,EAAE,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;CACF;AAJD,kDAIC"}
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ /*!
3
+ This file is part of CycloneDX JavaScript Library.
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+
17
+ SPDX-License-Identifier: Apache-2.0
18
+ Copyright (c) OWASP Foundation. All Rights Reserved.
19
+ */
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.ExternalReferenceRepository = exports.ExternalReference = void 0;
22
+ class ExternalReference {
23
+ constructor(url, type, op = {}) {
24
+ this.url = url;
25
+ this.type = type;
26
+ this.comment = op.comment;
27
+ }
28
+ compare(other) {
29
+ return this.type.localeCompare(other.type) ||
30
+ this.url.toString().localeCompare(other.url.toString());
31
+ }
32
+ }
33
+ exports.ExternalReference = ExternalReference;
34
+ class ExternalReferenceRepository extends Set {
35
+ static compareItems(a, b) {
36
+ return a.compare(b);
37
+ }
38
+ }
39
+ exports.ExternalReferenceRepository = ExternalReferenceRepository;
40
+ //# sourceMappingURL=externalReference.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"externalReference.js","sourceRoot":"","sources":["../../src/models/externalReference.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;EAiBE;;;AAQF,MAAa,iBAAiB;IAK5B,YAAa,GAAiB,EAAE,IAA2B,EAAE,KAAyB,EAAE;QACtF,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC,OAAO,CAAA;IAC3B,CAAC;IAED,OAAO,CAAE,KAAwB;QAE/B,OAAO,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC;YACxC,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAA;IAC3D,CAAC;CACF;AAhBD,8CAgBC;AAED,MAAa,2BAA4B,SAAQ,GAAsB;IACrE,MAAM,CAAC,YAAY,CAAE,CAAoB,EAAE,CAAoB;QAC7D,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;IACrB,CAAC;CACF;AAJD,kEAIC"}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ /*!
3
+ This file is part of CycloneDX JavaScript Library.
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+
17
+ SPDX-License-Identifier: Apache-2.0
18
+ Copyright (c) OWASP Foundation. All Rights Reserved.
19
+ */
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.HashRepository = void 0;
22
+ class HashRepository extends Map {
23
+ static compareItems(a, b) {
24
+ return a[0].localeCompare(b[0]) ||
25
+ a[1].localeCompare(b[1]);
26
+ }
27
+ }
28
+ exports.HashRepository = HashRepository;
29
+ //# sourceMappingURL=hash.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hash.js","sourceRoot":"","sources":["../../src/models/hash.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;EAiBE;;;AAcF,MAAa,cAAe,SAAQ,GAAqB;IACvD,MAAM,CAAC,YAAY,CAAE,CAAO,EAAE,CAAO;QAEnC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC7B,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAC5B,CAAC;CACF;AAND,wCAMC"}
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ /*!
3
+ This file is part of CycloneDX JavaScript Library.
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+
17
+ SPDX-License-Identifier: Apache-2.0
18
+ Copyright (c) OWASP Foundation. All Rights Reserved.
19
+ */
20
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ var desc = Object.getOwnPropertyDescriptor(m, k);
23
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
24
+ desc = { enumerable: true, get: function() { return m[k]; } };
25
+ }
26
+ Object.defineProperty(o, k2, desc);
27
+ }) : (function(o, m, k, k2) {
28
+ if (k2 === undefined) k2 = k;
29
+ o[k2] = m[k];
30
+ }));
31
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
32
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
33
+ };
34
+ Object.defineProperty(exports, "__esModule", { value: true });
35
+ __exportStar(require("./attachment"), exports);
36
+ __exportStar(require("./bom"), exports);
37
+ __exportStar(require("./bomRef"), exports);
38
+ __exportStar(require("./component"), exports);
39
+ __exportStar(require("./externalReference"), exports);
40
+ __exportStar(require("./hash"), exports);
41
+ __exportStar(require("./license"), exports);
42
+ __exportStar(require("./metadata"), exports);
43
+ __exportStar(require("./organizationalContact"), exports);
44
+ __exportStar(require("./organizationalEntity"), exports);
45
+ __exportStar(require("./swid"), exports);
46
+ __exportStar(require("./tool"), exports);
47
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;EAiBE;;;;;;;;;;;;;;;;AAEF,+CAA4B;AAC5B,wCAAqB;AACrB,2CAAwB;AACxB,8CAA2B;AAC3B,sDAAmC;AACnC,yCAAsB;AACtB,4CAAyB;AACzB,6CAA0B;AAC1B,0DAAuC;AACvC,yDAAsC;AACtC,yCAAsB;AACtB,yCAAsB"}
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ /*!
3
+ This file is part of CycloneDX JavaScript Library.
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+
17
+ SPDX-License-Identifier: Apache-2.0
18
+ Copyright (c) OWASP Foundation. All Rights Reserved.
19
+ */
20
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
21
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
22
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
23
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
24
+ };
25
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
26
+ if (kind === "m") throw new TypeError("Private method is not writable");
27
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
28
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
29
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
30
+ };
31
+ var _LicenseExpression_expression, _SpdxLicense_id;
32
+ Object.defineProperty(exports, "__esModule", { value: true });
33
+ exports.LicenseRepository = exports.SpdxLicense = exports.NamedLicense = exports.LicenseExpression = void 0;
34
+ const spdx_1 = require("../spdx");
35
+ class LicenseExpression {
36
+ constructor(expression) {
37
+ _LicenseExpression_expression.set(this, void 0);
38
+ this.expression = expression;
39
+ }
40
+ static isEligibleExpression(expression) {
41
+ return typeof expression === 'string' &&
42
+ expression.length >= 8 &&
43
+ expression[0] === '(' &&
44
+ expression[expression.length - 1] === ')';
45
+ }
46
+ get expression() {
47
+ return __classPrivateFieldGet(this, _LicenseExpression_expression, "f");
48
+ }
49
+ set expression(value) {
50
+ if (!LicenseExpression.isEligibleExpression(value)) {
51
+ throw new RangeError('Not eligible expression');
52
+ }
53
+ __classPrivateFieldSet(this, _LicenseExpression_expression, value, "f");
54
+ }
55
+ compare(other) {
56
+ return __classPrivateFieldGet(this, _LicenseExpression_expression, "f").localeCompare(__classPrivateFieldGet(other, _LicenseExpression_expression, "f"));
57
+ }
58
+ }
59
+ exports.LicenseExpression = LicenseExpression;
60
+ _LicenseExpression_expression = new WeakMap();
61
+ class NamedLicense {
62
+ constructor(name, op = {}) {
63
+ this.name = name;
64
+ this.text = op.text;
65
+ this.url = op.url;
66
+ }
67
+ compare(other) {
68
+ return this.name.localeCompare(other.name);
69
+ }
70
+ }
71
+ exports.NamedLicense = NamedLicense;
72
+ class SpdxLicense {
73
+ constructor(id, op = {}) {
74
+ _SpdxLicense_id.set(this, void 0);
75
+ this.id = id;
76
+ this.text = op.text;
77
+ this.url = op.url;
78
+ }
79
+ get id() {
80
+ return __classPrivateFieldGet(this, _SpdxLicense_id, "f");
81
+ }
82
+ set id(value) {
83
+ if (!(0, spdx_1.isSupportedSpdxId)(value)) {
84
+ throw new RangeError('Unknown SPDX id');
85
+ }
86
+ __classPrivateFieldSet(this, _SpdxLicense_id, value, "f");
87
+ }
88
+ compare(other) {
89
+ return __classPrivateFieldGet(this, _SpdxLicense_id, "f").localeCompare(__classPrivateFieldGet(other, _SpdxLicense_id, "f"));
90
+ }
91
+ }
92
+ exports.SpdxLicense = SpdxLicense;
93
+ _SpdxLicense_id = new WeakMap();
94
+ class LicenseRepository extends Set {
95
+ static compareItems(a, b) {
96
+ if (a.constructor === b.constructor) {
97
+ return a.compare(b);
98
+ }
99
+ return a.constructor.name.localeCompare(b.constructor.name);
100
+ }
101
+ }
102
+ exports.LicenseRepository = LicenseRepository;
103
+ //# sourceMappingURL=license.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"license.js","sourceRoot":"","sources":["../../src/models/license.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;EAiBE;;;;;;;;;;;;;;;AAEF,kCAAmD;AAGnD,MAAa,iBAAiB;IAe5B,YAAa,UAAkB;QAL/B,gDAAoB;QAMlB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;IAC9B,CAAC;IAhBD,MAAM,CAAC,oBAAoB,CAAE,UAAwB;QAEnD,OAAO,OAAO,UAAU,KAAK,QAAQ;YACnC,UAAU,CAAC,MAAM,IAAI,CAAC;YACtB,UAAU,CAAC,CAAC,CAAC,KAAK,GAAG;YACrB,UAAU,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,GAAG,CAAA;IAC7C,CAAC;IAYD,IAAI,UAAU;QACZ,OAAO,uBAAA,IAAI,qCAAY,CAAA;IACzB,CAAC;IAKD,IAAI,UAAU,CAAE,KAAa;QAC3B,IAAI,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,KAAK,CAAC,EAAE;YAClD,MAAM,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