@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,3487 @@
1
+ (function webpackUniversalModuleDefinition(root, factory) {
2
+ if(typeof exports === 'object' && typeof module === 'object')
3
+ module.exports = factory();
4
+ else if(typeof define === 'function' && define.amd)
5
+ define([], factory);
6
+ else if(typeof exports === 'object')
7
+ exports["CycloneDX_library"] = factory();
8
+ else
9
+ root["CycloneDX_library"] = factory();
10
+ })(self, () => {
11
+ return /******/ (() => { // webpackBootstrap
12
+ /******/ "use strict";
13
+ /******/ var __webpack_modules__ = ({
14
+
15
+ /***/ "./src/_index.web.ts":
16
+ /*!***************************!*\
17
+ !*** ./src/_index.web.ts ***!
18
+ \***************************/
19
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
20
+
21
+
22
+ /*!
23
+ This file is part of CycloneDX JavaScript Library.
24
+
25
+ Licensed under the Apache License, Version 2.0 (the "License");
26
+ you may not use this file except in compliance with the License.
27
+ You may obtain a copy of the License at
28
+
29
+ http://www.apache.org/licenses/LICENSE-2.0
30
+
31
+ Unless required by applicable law or agreed to in writing, software
32
+ distributed under the License is distributed on an "AS IS" BASIS,
33
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
34
+ See the License for the specific language governing permissions and
35
+ limitations under the License.
36
+
37
+ SPDX-License-Identifier: Apache-2.0
38
+ Copyright (c) OWASP Foundation. All Rights Reserved.
39
+ */
40
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
41
+ if (k2 === undefined) k2 = k;
42
+ var desc = Object.getOwnPropertyDescriptor(m, k);
43
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
44
+ desc = { enumerable: true, get: function() { return m[k]; } };
45
+ }
46
+ Object.defineProperty(o, k2, desc);
47
+ }) : (function(o, m, k, k2) {
48
+ if (k2 === undefined) k2 = k;
49
+ o[k2] = m[k];
50
+ }));
51
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
52
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
53
+ }) : function(o, v) {
54
+ o["default"] = v;
55
+ });
56
+ var __importStar = (this && this.__importStar) || function (mod) {
57
+ if (mod && mod.__esModule) return mod;
58
+ var result = {};
59
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
60
+ __setModuleDefault(result, mod);
61
+ return result;
62
+ };
63
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
64
+ exports.Serialize = exports.Spec = exports.Factories = exports.Models = exports.SPDX = exports.Enums = exports.Types = void 0;
65
+ exports.Types = __importStar(__webpack_require__(/*! ./types */ "./src/types/index.ts"));
66
+ exports.Enums = __importStar(__webpack_require__(/*! ./enums */ "./src/enums/index.ts"));
67
+ exports.SPDX = __importStar(__webpack_require__(/*! ./spdx */ "./src/spdx.ts"));
68
+ exports.Models = __importStar(__webpack_require__(/*! ./models */ "./src/models/index.ts"));
69
+ exports.Factories = __importStar(__webpack_require__(/*! ./factories */ "./src/factories/index.ts"));
70
+ exports.Spec = __importStar(__webpack_require__(/*! ./spec */ "./src/spec.ts"));
71
+ exports.Serialize = __importStar(__webpack_require__(/*! ./serialize/_index.web */ "./src/serialize/_index.web.ts"));
72
+
73
+
74
+ /***/ }),
75
+
76
+ /***/ "./src/enums/attachmentEncoding.ts":
77
+ /*!*****************************************!*\
78
+ !*** ./src/enums/attachmentEncoding.ts ***!
79
+ \*****************************************/
80
+ /***/ ((__unused_webpack_module, exports) => {
81
+
82
+
83
+ /*!
84
+ This file is part of CycloneDX JavaScript Library.
85
+
86
+ Licensed under the Apache License, Version 2.0 (the "License");
87
+ you may not use this file except in compliance with the License.
88
+ You may obtain a copy of the License at
89
+
90
+ http://www.apache.org/licenses/LICENSE-2.0
91
+
92
+ Unless required by applicable law or agreed to in writing, software
93
+ distributed under the License is distributed on an "AS IS" BASIS,
94
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
95
+ See the License for the specific language governing permissions and
96
+ limitations under the License.
97
+
98
+ SPDX-License-Identifier: Apache-2.0
99
+ Copyright (c) OWASP Foundation. All Rights Reserved.
100
+ */
101
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
102
+ exports.AttachmentEncoding = void 0;
103
+ var AttachmentEncoding;
104
+ (function (AttachmentEncoding) {
105
+ AttachmentEncoding["Base64"] = "base64";
106
+ })(AttachmentEncoding = exports.AttachmentEncoding || (exports.AttachmentEncoding = {}));
107
+
108
+
109
+ /***/ }),
110
+
111
+ /***/ "./src/enums/componentScope.ts":
112
+ /*!*************************************!*\
113
+ !*** ./src/enums/componentScope.ts ***!
114
+ \*************************************/
115
+ /***/ ((__unused_webpack_module, exports) => {
116
+
117
+
118
+ /*!
119
+ This file is part of CycloneDX JavaScript Library.
120
+
121
+ Licensed under the Apache License, Version 2.0 (the "License");
122
+ you may not use this file except in compliance with the License.
123
+ You may obtain a copy of the License at
124
+
125
+ http://www.apache.org/licenses/LICENSE-2.0
126
+
127
+ Unless required by applicable law or agreed to in writing, software
128
+ distributed under the License is distributed on an "AS IS" BASIS,
129
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
130
+ See the License for the specific language governing permissions and
131
+ limitations under the License.
132
+
133
+ SPDX-License-Identifier: Apache-2.0
134
+ Copyright (c) OWASP Foundation. All Rights Reserved.
135
+ */
136
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
137
+ exports.ComponentScope = void 0;
138
+ var ComponentScope;
139
+ (function (ComponentScope) {
140
+ ComponentScope["Required"] = "required";
141
+ ComponentScope["Optional"] = "optional";
142
+ ComponentScope["Excluded"] = "excluded";
143
+ })(ComponentScope = exports.ComponentScope || (exports.ComponentScope = {}));
144
+
145
+
146
+ /***/ }),
147
+
148
+ /***/ "./src/enums/componentType.ts":
149
+ /*!************************************!*\
150
+ !*** ./src/enums/componentType.ts ***!
151
+ \************************************/
152
+ /***/ ((__unused_webpack_module, exports) => {
153
+
154
+
155
+ /*!
156
+ This file is part of CycloneDX JavaScript Library.
157
+
158
+ Licensed under the Apache License, Version 2.0 (the "License");
159
+ you may not use this file except in compliance with the License.
160
+ You may obtain a copy of the License at
161
+
162
+ http://www.apache.org/licenses/LICENSE-2.0
163
+
164
+ Unless required by applicable law or agreed to in writing, software
165
+ distributed under the License is distributed on an "AS IS" BASIS,
166
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
167
+ See the License for the specific language governing permissions and
168
+ limitations under the License.
169
+
170
+ SPDX-License-Identifier: Apache-2.0
171
+ Copyright (c) OWASP Foundation. All Rights Reserved.
172
+ */
173
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
174
+ exports.ComponentType = void 0;
175
+ var ComponentType;
176
+ (function (ComponentType) {
177
+ ComponentType["Application"] = "application";
178
+ ComponentType["Framework"] = "framework";
179
+ ComponentType["Library"] = "library";
180
+ ComponentType["Container"] = "container";
181
+ ComponentType["OperatingSystem"] = "operating-system";
182
+ ComponentType["Device"] = "device";
183
+ ComponentType["Firmware"] = "firmware";
184
+ ComponentType["File"] = "file";
185
+ })(ComponentType = exports.ComponentType || (exports.ComponentType = {}));
186
+
187
+
188
+ /***/ }),
189
+
190
+ /***/ "./src/enums/externalReferenceType.ts":
191
+ /*!********************************************!*\
192
+ !*** ./src/enums/externalReferenceType.ts ***!
193
+ \********************************************/
194
+ /***/ ((__unused_webpack_module, exports) => {
195
+
196
+
197
+ /*!
198
+ This file is part of CycloneDX JavaScript Library.
199
+
200
+ Licensed under the Apache License, Version 2.0 (the "License");
201
+ you may not use this file except in compliance with the License.
202
+ You may obtain a copy of the License at
203
+
204
+ http://www.apache.org/licenses/LICENSE-2.0
205
+
206
+ Unless required by applicable law or agreed to in writing, software
207
+ distributed under the License is distributed on an "AS IS" BASIS,
208
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
209
+ See the License for the specific language governing permissions and
210
+ limitations under the License.
211
+
212
+ SPDX-License-Identifier: Apache-2.0
213
+ Copyright (c) OWASP Foundation. All Rights Reserved.
214
+ */
215
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
216
+ exports.ExternalReferenceType = void 0;
217
+ var ExternalReferenceType;
218
+ (function (ExternalReferenceType) {
219
+ ExternalReferenceType["VCS"] = "vcs";
220
+ ExternalReferenceType["IssueTracker"] = "issue-tracker";
221
+ ExternalReferenceType["Website"] = "website";
222
+ ExternalReferenceType["Advisories"] = "advisories";
223
+ ExternalReferenceType["BOM"] = "bom";
224
+ ExternalReferenceType["MailingList"] = "mailing-list";
225
+ ExternalReferenceType["Social"] = "social";
226
+ ExternalReferenceType["Chat"] = "chat";
227
+ ExternalReferenceType["Documentation"] = "documentation";
228
+ ExternalReferenceType["Support"] = "support";
229
+ ExternalReferenceType["Distribution"] = "distribution";
230
+ ExternalReferenceType["License"] = "license";
231
+ ExternalReferenceType["BuildMeta"] = "build-meta";
232
+ ExternalReferenceType["BuildSystem"] = "build-system";
233
+ ExternalReferenceType["ReleaseNotes"] = "release-notes";
234
+ ExternalReferenceType["Other"] = "other";
235
+ })(ExternalReferenceType = exports.ExternalReferenceType || (exports.ExternalReferenceType = {}));
236
+
237
+
238
+ /***/ }),
239
+
240
+ /***/ "./src/enums/hashAlogorithm.ts":
241
+ /*!*************************************!*\
242
+ !*** ./src/enums/hashAlogorithm.ts ***!
243
+ \*************************************/
244
+ /***/ ((__unused_webpack_module, exports) => {
245
+
246
+
247
+ /*!
248
+ This file is part of CycloneDX JavaScript Library.
249
+
250
+ Licensed under the Apache License, Version 2.0 (the "License");
251
+ you may not use this file except in compliance with the License.
252
+ You may obtain a copy of the License at
253
+
254
+ http://www.apache.org/licenses/LICENSE-2.0
255
+
256
+ Unless required by applicable law or agreed to in writing, software
257
+ distributed under the License is distributed on an "AS IS" BASIS,
258
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
259
+ See the License for the specific language governing permissions and
260
+ limitations under the License.
261
+
262
+ SPDX-License-Identifier: Apache-2.0
263
+ Copyright (c) OWASP Foundation. All Rights Reserved.
264
+ */
265
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
266
+ exports.HashAlgorithm = void 0;
267
+ var HashAlgorithm;
268
+ (function (HashAlgorithm) {
269
+ HashAlgorithm["MD5"] = "MD5";
270
+ HashAlgorithm["SHA-1"] = "SHA-1";
271
+ HashAlgorithm["SHA-256"] = "SHA-256";
272
+ HashAlgorithm["SHA-384"] = "SHA-384";
273
+ HashAlgorithm["SHA-512"] = "SHA-512";
274
+ HashAlgorithm["SHA3-256"] = "SHA3-256";
275
+ HashAlgorithm["SHA3-384"] = "SHA3-384";
276
+ HashAlgorithm["SHA3-512"] = "SHA3-512";
277
+ HashAlgorithm["BLAKE2b-256"] = "BLAKE2b-256";
278
+ HashAlgorithm["BLAKE2b-384"] = "BLAKE2b-384";
279
+ HashAlgorithm["BLAKE2b-512"] = "BLAKE2b-512";
280
+ HashAlgorithm["BLAKE3"] = "BLAKE3";
281
+ })(HashAlgorithm = exports.HashAlgorithm || (exports.HashAlgorithm = {}));
282
+
283
+
284
+ /***/ }),
285
+
286
+ /***/ "./src/enums/index.ts":
287
+ /*!****************************!*\
288
+ !*** ./src/enums/index.ts ***!
289
+ \****************************/
290
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
291
+
292
+
293
+ /*!
294
+ This file is part of CycloneDX JavaScript Library.
295
+
296
+ Licensed under the Apache License, Version 2.0 (the "License");
297
+ you may not use this file except in compliance with the License.
298
+ You may obtain a copy of the License at
299
+
300
+ http://www.apache.org/licenses/LICENSE-2.0
301
+
302
+ Unless required by applicable law or agreed to in writing, software
303
+ distributed under the License is distributed on an "AS IS" BASIS,
304
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
305
+ See the License for the specific language governing permissions and
306
+ limitations under the License.
307
+
308
+ SPDX-License-Identifier: Apache-2.0
309
+ Copyright (c) OWASP Foundation. All Rights Reserved.
310
+ */
311
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
312
+ if (k2 === undefined) k2 = k;
313
+ var desc = Object.getOwnPropertyDescriptor(m, k);
314
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
315
+ desc = { enumerable: true, get: function() { return m[k]; } };
316
+ }
317
+ Object.defineProperty(o, k2, desc);
318
+ }) : (function(o, m, k, k2) {
319
+ if (k2 === undefined) k2 = k;
320
+ o[k2] = m[k];
321
+ }));
322
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
323
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
324
+ };
325
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
326
+ __exportStar(__webpack_require__(/*! ./attachmentEncoding */ "./src/enums/attachmentEncoding.ts"), exports);
327
+ __exportStar(__webpack_require__(/*! ./componentScope */ "./src/enums/componentScope.ts"), exports);
328
+ __exportStar(__webpack_require__(/*! ./componentType */ "./src/enums/componentType.ts"), exports);
329
+ __exportStar(__webpack_require__(/*! ./externalReferenceType */ "./src/enums/externalReferenceType.ts"), exports);
330
+ __exportStar(__webpack_require__(/*! ./hashAlogorithm */ "./src/enums/hashAlogorithm.ts"), exports);
331
+
332
+
333
+ /***/ }),
334
+
335
+ /***/ "./src/factories/index.ts":
336
+ /*!********************************!*\
337
+ !*** ./src/factories/index.ts ***!
338
+ \********************************/
339
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
340
+
341
+
342
+ /*!
343
+ This file is part of CycloneDX JavaScript Library.
344
+
345
+ Licensed under the Apache License, Version 2.0 (the "License");
346
+ you may not use this file except in compliance with the License.
347
+ You may obtain a copy of the License at
348
+
349
+ http://www.apache.org/licenses/LICENSE-2.0
350
+
351
+ Unless required by applicable law or agreed to in writing, software
352
+ distributed under the License is distributed on an "AS IS" BASIS,
353
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
354
+ See the License for the specific language governing permissions and
355
+ limitations under the License.
356
+
357
+ SPDX-License-Identifier: Apache-2.0
358
+ Copyright (c) OWASP Foundation. All Rights Reserved.
359
+ */
360
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
361
+ if (k2 === undefined) k2 = k;
362
+ var desc = Object.getOwnPropertyDescriptor(m, k);
363
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
364
+ desc = { enumerable: true, get: function() { return m[k]; } };
365
+ }
366
+ Object.defineProperty(o, k2, desc);
367
+ }) : (function(o, m, k, k2) {
368
+ if (k2 === undefined) k2 = k;
369
+ o[k2] = m[k];
370
+ }));
371
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
372
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
373
+ };
374
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
375
+ __exportStar(__webpack_require__(/*! ./licenseFactory */ "./src/factories/licenseFactory.ts"), exports);
376
+
377
+
378
+ /***/ }),
379
+
380
+ /***/ "./src/factories/licenseFactory.ts":
381
+ /*!*****************************************!*\
382
+ !*** ./src/factories/licenseFactory.ts ***!
383
+ \*****************************************/
384
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
385
+
386
+
387
+ /*!
388
+ This file is part of CycloneDX JavaScript Library.
389
+
390
+ Licensed under the Apache License, Version 2.0 (the "License");
391
+ you may not use this file except in compliance with the License.
392
+ You may obtain a copy of the License at
393
+
394
+ http://www.apache.org/licenses/LICENSE-2.0
395
+
396
+ Unless required by applicable law or agreed to in writing, software
397
+ distributed under the License is distributed on an "AS IS" BASIS,
398
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
399
+ See the License for the specific language governing permissions and
400
+ limitations under the License.
401
+
402
+ SPDX-License-Identifier: Apache-2.0
403
+ Copyright (c) OWASP Foundation. All Rights Reserved.
404
+ */
405
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
406
+ exports.LicenseFactory = void 0;
407
+ const models_1 = __webpack_require__(/*! ../models */ "./src/models/index.ts");
408
+ const spdx_1 = __webpack_require__(/*! ../spdx */ "./src/spdx.ts");
409
+ class LicenseFactory {
410
+ makeFromString(value) {
411
+ try {
412
+ return this.makeExpression(value);
413
+ }
414
+ catch (Error) {
415
+ return this.makeDisjunctive(value);
416
+ }
417
+ }
418
+ makeExpression(value) {
419
+ return new models_1.LicenseExpression(value);
420
+ }
421
+ makeDisjunctive(value) {
422
+ try {
423
+ return this.makeDisjunctiveWithId(value);
424
+ }
425
+ catch (error) {
426
+ return this.makeDisjunctiveWithName(value);
427
+ }
428
+ }
429
+ makeDisjunctiveWithId(value) {
430
+ const spdxId = (0, spdx_1.fixupSpdxId)(String(value));
431
+ if (undefined === spdxId) {
432
+ throw new RangeError('Unsupported SPDX id');
433
+ }
434
+ return new models_1.SpdxLicense(spdxId);
435
+ }
436
+ makeDisjunctiveWithName(value) {
437
+ return new models_1.NamedLicense(String(value));
438
+ }
439
+ }
440
+ exports.LicenseFactory = LicenseFactory;
441
+
442
+
443
+ /***/ }),
444
+
445
+ /***/ "./src/helpers/types.ts":
446
+ /*!******************************!*\
447
+ !*** ./src/helpers/types.ts ***!
448
+ \******************************/
449
+ /***/ ((__unused_webpack_module, exports) => {
450
+
451
+
452
+ /*!
453
+ This file is part of CycloneDX JavaScript Library.
454
+
455
+ Licensed under the Apache License, Version 2.0 (the "License");
456
+ you may not use this file except in compliance with the License.
457
+ You may obtain a copy of the License at
458
+
459
+ http://www.apache.org/licenses/LICENSE-2.0
460
+
461
+ Unless required by applicable law or agreed to in writing, software
462
+ distributed under the License is distributed on an "AS IS" BASIS,
463
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
464
+ See the License for the specific language governing permissions and
465
+ limitations under the License.
466
+
467
+ SPDX-License-Identifier: Apache-2.0
468
+ Copyright (c) OWASP Foundation. All Rights Reserved.
469
+ */
470
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
471
+ exports.isNotUndefined = void 0;
472
+ function isNotUndefined(value) {
473
+ return value !== undefined;
474
+ }
475
+ exports.isNotUndefined = isNotUndefined;
476
+
477
+
478
+ /***/ }),
479
+
480
+ /***/ "./src/models/attachment.ts":
481
+ /*!**********************************!*\
482
+ !*** ./src/models/attachment.ts ***!
483
+ \**********************************/
484
+ /***/ ((__unused_webpack_module, exports) => {
485
+
486
+
487
+ /*!
488
+ This file is part of CycloneDX JavaScript Library.
489
+
490
+ Licensed under the Apache License, Version 2.0 (the "License");
491
+ you may not use this file except in compliance with the License.
492
+ You may obtain a copy of the License at
493
+
494
+ http://www.apache.org/licenses/LICENSE-2.0
495
+
496
+ Unless required by applicable law or agreed to in writing, software
497
+ distributed under the License is distributed on an "AS IS" BASIS,
498
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
499
+ See the License for the specific language governing permissions and
500
+ limitations under the License.
501
+
502
+ SPDX-License-Identifier: Apache-2.0
503
+ Copyright (c) OWASP Foundation. All Rights Reserved.
504
+ */
505
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
506
+ exports.Attachment = void 0;
507
+ class Attachment {
508
+ constructor(content, op = {}) {
509
+ this.contentType = op.contentType;
510
+ this.content = content;
511
+ this.encoding = op.encoding;
512
+ }
513
+ }
514
+ exports.Attachment = Attachment;
515
+
516
+
517
+ /***/ }),
518
+
519
+ /***/ "./src/models/bom.ts":
520
+ /*!***************************!*\
521
+ !*** ./src/models/bom.ts ***!
522
+ \***************************/
523
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
524
+
525
+
526
+ /*!
527
+ This file is part of CycloneDX JavaScript Library.
528
+
529
+ Licensed under the Apache License, Version 2.0 (the "License");
530
+ you may not use this file except in compliance with the License.
531
+ You may obtain a copy of the License at
532
+
533
+ http://www.apache.org/licenses/LICENSE-2.0
534
+
535
+ Unless required by applicable law or agreed to in writing, software
536
+ distributed under the License is distributed on an "AS IS" BASIS,
537
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
538
+ See the License for the specific language governing permissions and
539
+ limitations under the License.
540
+
541
+ SPDX-License-Identifier: Apache-2.0
542
+ Copyright (c) OWASP Foundation. All Rights Reserved.
543
+ */
544
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
545
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
546
+ 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");
547
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
548
+ };
549
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
550
+ if (kind === "m") throw new TypeError("Private method is not writable");
551
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
552
+ 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");
553
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
554
+ };
555
+ var _Bom_version, _Bom_serialNumber;
556
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
557
+ exports.Bom = void 0;
558
+ const types_1 = __webpack_require__(/*! ../types */ "./src/types/index.ts");
559
+ const metadata_1 = __webpack_require__(/*! ./metadata */ "./src/models/metadata.ts");
560
+ const component_1 = __webpack_require__(/*! ./component */ "./src/models/component.ts");
561
+ class Bom {
562
+ constructor(op = {}) {
563
+ _Bom_version.set(this, 1);
564
+ _Bom_serialNumber.set(this, void 0);
565
+ this.metadata = op.metadata ?? new metadata_1.Metadata();
566
+ this.components = op.components ?? new component_1.ComponentRepository();
567
+ this.version = op.version ?? this.version;
568
+ this.serialNumber = op.serialNumber;
569
+ }
570
+ get version() {
571
+ return __classPrivateFieldGet(this, _Bom_version, "f");
572
+ }
573
+ set version(value) {
574
+ if (!(0, types_1.isPositiveInteger)(value)) {
575
+ throw new TypeError('Not PositiveInteger');
576
+ }
577
+ __classPrivateFieldSet(this, _Bom_version, value, "f");
578
+ }
579
+ get serialNumber() {
580
+ return __classPrivateFieldGet(this, _Bom_serialNumber, "f");
581
+ }
582
+ set serialNumber(value) {
583
+ if (value !== undefined && !(0, types_1.isUrnUuid)(value)) {
584
+ throw new TypeError('Not UrnUuid nor undefined');
585
+ }
586
+ __classPrivateFieldSet(this, _Bom_serialNumber, value, "f");
587
+ }
588
+ }
589
+ exports.Bom = Bom;
590
+ _Bom_version = new WeakMap(), _Bom_serialNumber = new WeakMap();
591
+
592
+
593
+ /***/ }),
594
+
595
+ /***/ "./src/models/bomRef.ts":
596
+ /*!******************************!*\
597
+ !*** ./src/models/bomRef.ts ***!
598
+ \******************************/
599
+ /***/ ((__unused_webpack_module, exports) => {
600
+
601
+
602
+ /*!
603
+ This file is part of CycloneDX JavaScript Library.
604
+
605
+ Licensed under the Apache License, Version 2.0 (the "License");
606
+ you may not use this file except in compliance with the License.
607
+ You may obtain a copy of the License at
608
+
609
+ http://www.apache.org/licenses/LICENSE-2.0
610
+
611
+ Unless required by applicable law or agreed to in writing, software
612
+ distributed under the License is distributed on an "AS IS" BASIS,
613
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
614
+ See the License for the specific language governing permissions and
615
+ limitations under the License.
616
+
617
+ SPDX-License-Identifier: Apache-2.0
618
+ Copyright (c) OWASP Foundation. All Rights Reserved.
619
+ */
620
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
621
+ exports.BomRefRepository = exports.BomRef = void 0;
622
+ class BomRef {
623
+ constructor(value) {
624
+ this.value = value;
625
+ }
626
+ compare(other) {
627
+ return (this.toString()).localeCompare(other.toString());
628
+ }
629
+ toString() {
630
+ return this.value ?? '';
631
+ }
632
+ }
633
+ exports.BomRef = BomRef;
634
+ class BomRefRepository extends Set {
635
+ }
636
+ exports.BomRefRepository = BomRefRepository;
637
+
638
+
639
+ /***/ }),
640
+
641
+ /***/ "./src/models/component.ts":
642
+ /*!*********************************!*\
643
+ !*** ./src/models/component.ts ***!
644
+ \*********************************/
645
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
646
+
647
+
648
+ /*!
649
+ This file is part of CycloneDX JavaScript Library.
650
+
651
+ Licensed under the Apache License, Version 2.0 (the "License");
652
+ you may not use this file except in compliance with the License.
653
+ You may obtain a copy of the License at
654
+
655
+ http://www.apache.org/licenses/LICENSE-2.0
656
+
657
+ Unless required by applicable law or agreed to in writing, software
658
+ distributed under the License is distributed on an "AS IS" BASIS,
659
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
660
+ See the License for the specific language governing permissions and
661
+ limitations under the License.
662
+
663
+ SPDX-License-Identifier: Apache-2.0
664
+ Copyright (c) OWASP Foundation. All Rights Reserved.
665
+ */
666
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
667
+ if (kind === "m") throw new TypeError("Private method is not writable");
668
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
669
+ 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");
670
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
671
+ };
672
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
673
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
674
+ 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");
675
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
676
+ };
677
+ var _Component_bomRef, _Component_cpe;
678
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
679
+ exports.ComponentRepository = exports.Component = void 0;
680
+ const types_1 = __webpack_require__(/*! ../types */ "./src/types/index.ts");
681
+ const bomRef_1 = __webpack_require__(/*! ./bomRef */ "./src/models/bomRef.ts");
682
+ const hash_1 = __webpack_require__(/*! ./hash */ "./src/models/hash.ts");
683
+ const externalReference_1 = __webpack_require__(/*! ./externalReference */ "./src/models/externalReference.ts");
684
+ const license_1 = __webpack_require__(/*! ./license */ "./src/models/license.ts");
685
+ class Component {
686
+ constructor(type, name, op = {}) {
687
+ _Component_bomRef.set(this, void 0);
688
+ _Component_cpe.set(this, void 0);
689
+ __classPrivateFieldSet(this, _Component_bomRef, new bomRef_1.BomRef(op.bomRef), "f");
690
+ this.type = type;
691
+ this.name = name;
692
+ this.author = op.author;
693
+ this.copyright = op.copyright;
694
+ this.externalReferences = op.externalReferences ?? new externalReference_1.ExternalReferenceRepository();
695
+ this.group = op.group;
696
+ this.hashes = op.hashes ?? new hash_1.HashRepository();
697
+ this.licenses = op.licenses ?? new license_1.LicenseRepository();
698
+ this.publisher = op.publisher;
699
+ this.purl = op.purl;
700
+ this.scope = op.scope;
701
+ this.swid = op.swid;
702
+ this.version = op.version;
703
+ this.dependencies = op.dependencies ?? new bomRef_1.BomRefRepository();
704
+ this.cpe = op.cpe;
705
+ }
706
+ get bomRef() {
707
+ return __classPrivateFieldGet(this, _Component_bomRef, "f");
708
+ }
709
+ get cpe() {
710
+ return __classPrivateFieldGet(this, _Component_cpe, "f");
711
+ }
712
+ set cpe(value) {
713
+ if (value !== undefined && !(0, types_1.isCPE)(value)) {
714
+ throw new TypeError('Not CPE nor undefined');
715
+ }
716
+ __classPrivateFieldSet(this, _Component_cpe, value, "f");
717
+ }
718
+ compare(other) {
719
+ const bomRefCompare = this.bomRef.compare(other.bomRef);
720
+ if (bomRefCompare !== 0) {
721
+ return bomRefCompare;
722
+ }
723
+ if (this.purl !== undefined && other.purl !== undefined) {
724
+ return this.purl.toString().localeCompare(other.purl.toString());
725
+ }
726
+ if (__classPrivateFieldGet(this, _Component_cpe, "f") !== undefined && __classPrivateFieldGet(other, _Component_cpe, "f") !== undefined) {
727
+ return __classPrivateFieldGet(this, _Component_cpe, "f").toString().localeCompare(__classPrivateFieldGet(other, _Component_cpe, "f").toString());
728
+ }
729
+ return (this.group ?? '').localeCompare(other.group ?? '') ||
730
+ this.name.localeCompare(other.name) ||
731
+ (this.version ?? '').localeCompare(other.version ?? '');
732
+ }
733
+ }
734
+ exports.Component = Component;
735
+ _Component_bomRef = new WeakMap(), _Component_cpe = new WeakMap();
736
+ class ComponentRepository extends Set {
737
+ static compareItems(a, b) {
738
+ return a.compare(b);
739
+ }
740
+ }
741
+ exports.ComponentRepository = ComponentRepository;
742
+
743
+
744
+ /***/ }),
745
+
746
+ /***/ "./src/models/externalReference.ts":
747
+ /*!*****************************************!*\
748
+ !*** ./src/models/externalReference.ts ***!
749
+ \*****************************************/
750
+ /***/ ((__unused_webpack_module, exports) => {
751
+
752
+
753
+ /*!
754
+ This file is part of CycloneDX JavaScript Library.
755
+
756
+ Licensed under the Apache License, Version 2.0 (the "License");
757
+ you may not use this file except in compliance with the License.
758
+ You may obtain a copy of the License at
759
+
760
+ http://www.apache.org/licenses/LICENSE-2.0
761
+
762
+ Unless required by applicable law or agreed to in writing, software
763
+ distributed under the License is distributed on an "AS IS" BASIS,
764
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
765
+ See the License for the specific language governing permissions and
766
+ limitations under the License.
767
+
768
+ SPDX-License-Identifier: Apache-2.0
769
+ Copyright (c) OWASP Foundation. All Rights Reserved.
770
+ */
771
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
772
+ exports.ExternalReferenceRepository = exports.ExternalReference = void 0;
773
+ class ExternalReference {
774
+ constructor(url, type, op = {}) {
775
+ this.url = url;
776
+ this.type = type;
777
+ this.comment = op.comment;
778
+ }
779
+ compare(other) {
780
+ return this.type.localeCompare(other.type) ||
781
+ this.url.toString().localeCompare(other.url.toString());
782
+ }
783
+ }
784
+ exports.ExternalReference = ExternalReference;
785
+ class ExternalReferenceRepository extends Set {
786
+ static compareItems(a, b) {
787
+ return a.compare(b);
788
+ }
789
+ }
790
+ exports.ExternalReferenceRepository = ExternalReferenceRepository;
791
+
792
+
793
+ /***/ }),
794
+
795
+ /***/ "./src/models/hash.ts":
796
+ /*!****************************!*\
797
+ !*** ./src/models/hash.ts ***!
798
+ \****************************/
799
+ /***/ ((__unused_webpack_module, exports) => {
800
+
801
+
802
+ /*!
803
+ This file is part of CycloneDX JavaScript Library.
804
+
805
+ Licensed under the Apache License, Version 2.0 (the "License");
806
+ you may not use this file except in compliance with the License.
807
+ You may obtain a copy of the License at
808
+
809
+ http://www.apache.org/licenses/LICENSE-2.0
810
+
811
+ Unless required by applicable law or agreed to in writing, software
812
+ distributed under the License is distributed on an "AS IS" BASIS,
813
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
814
+ See the License for the specific language governing permissions and
815
+ limitations under the License.
816
+
817
+ SPDX-License-Identifier: Apache-2.0
818
+ Copyright (c) OWASP Foundation. All Rights Reserved.
819
+ */
820
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
821
+ exports.HashRepository = void 0;
822
+ class HashRepository extends Map {
823
+ static compareItems(a, b) {
824
+ return a[0].localeCompare(b[0]) ||
825
+ a[1].localeCompare(b[1]);
826
+ }
827
+ }
828
+ exports.HashRepository = HashRepository;
829
+
830
+
831
+ /***/ }),
832
+
833
+ /***/ "./src/models/index.ts":
834
+ /*!*****************************!*\
835
+ !*** ./src/models/index.ts ***!
836
+ \*****************************/
837
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
838
+
839
+
840
+ /*!
841
+ This file is part of CycloneDX JavaScript Library.
842
+
843
+ Licensed under the Apache License, Version 2.0 (the "License");
844
+ you may not use this file except in compliance with the License.
845
+ You may obtain a copy of the License at
846
+
847
+ http://www.apache.org/licenses/LICENSE-2.0
848
+
849
+ Unless required by applicable law or agreed to in writing, software
850
+ distributed under the License is distributed on an "AS IS" BASIS,
851
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
852
+ See the License for the specific language governing permissions and
853
+ limitations under the License.
854
+
855
+ SPDX-License-Identifier: Apache-2.0
856
+ Copyright (c) OWASP Foundation. All Rights Reserved.
857
+ */
858
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
859
+ if (k2 === undefined) k2 = k;
860
+ var desc = Object.getOwnPropertyDescriptor(m, k);
861
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
862
+ desc = { enumerable: true, get: function() { return m[k]; } };
863
+ }
864
+ Object.defineProperty(o, k2, desc);
865
+ }) : (function(o, m, k, k2) {
866
+ if (k2 === undefined) k2 = k;
867
+ o[k2] = m[k];
868
+ }));
869
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
870
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
871
+ };
872
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
873
+ __exportStar(__webpack_require__(/*! ./attachment */ "./src/models/attachment.ts"), exports);
874
+ __exportStar(__webpack_require__(/*! ./bom */ "./src/models/bom.ts"), exports);
875
+ __exportStar(__webpack_require__(/*! ./bomRef */ "./src/models/bomRef.ts"), exports);
876
+ __exportStar(__webpack_require__(/*! ./component */ "./src/models/component.ts"), exports);
877
+ __exportStar(__webpack_require__(/*! ./externalReference */ "./src/models/externalReference.ts"), exports);
878
+ __exportStar(__webpack_require__(/*! ./hash */ "./src/models/hash.ts"), exports);
879
+ __exportStar(__webpack_require__(/*! ./license */ "./src/models/license.ts"), exports);
880
+ __exportStar(__webpack_require__(/*! ./metadata */ "./src/models/metadata.ts"), exports);
881
+ __exportStar(__webpack_require__(/*! ./organizationalContact */ "./src/models/organizationalContact.ts"), exports);
882
+ __exportStar(__webpack_require__(/*! ./organizationalEntity */ "./src/models/organizationalEntity.ts"), exports);
883
+ __exportStar(__webpack_require__(/*! ./swid */ "./src/models/swid.ts"), exports);
884
+ __exportStar(__webpack_require__(/*! ./tool */ "./src/models/tool.ts"), exports);
885
+
886
+
887
+ /***/ }),
888
+
889
+ /***/ "./src/models/license.ts":
890
+ /*!*******************************!*\
891
+ !*** ./src/models/license.ts ***!
892
+ \*******************************/
893
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
894
+
895
+
896
+ /*!
897
+ This file is part of CycloneDX JavaScript Library.
898
+
899
+ Licensed under the Apache License, Version 2.0 (the "License");
900
+ you may not use this file except in compliance with the License.
901
+ You may obtain a copy of the License at
902
+
903
+ http://www.apache.org/licenses/LICENSE-2.0
904
+
905
+ Unless required by applicable law or agreed to in writing, software
906
+ distributed under the License is distributed on an "AS IS" BASIS,
907
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
908
+ See the License for the specific language governing permissions and
909
+ limitations under the License.
910
+
911
+ SPDX-License-Identifier: Apache-2.0
912
+ Copyright (c) OWASP Foundation. All Rights Reserved.
913
+ */
914
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
915
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
916
+ 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");
917
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
918
+ };
919
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
920
+ if (kind === "m") throw new TypeError("Private method is not writable");
921
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
922
+ 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");
923
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
924
+ };
925
+ var _LicenseExpression_expression, _SpdxLicense_id;
926
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
927
+ exports.LicenseRepository = exports.SpdxLicense = exports.NamedLicense = exports.LicenseExpression = void 0;
928
+ const spdx_1 = __webpack_require__(/*! ../spdx */ "./src/spdx.ts");
929
+ class LicenseExpression {
930
+ constructor(expression) {
931
+ _LicenseExpression_expression.set(this, void 0);
932
+ this.expression = expression;
933
+ }
934
+ static isEligibleExpression(expression) {
935
+ return typeof expression === 'string' &&
936
+ expression.length >= 8 &&
937
+ expression[0] === '(' &&
938
+ expression[expression.length - 1] === ')';
939
+ }
940
+ get expression() {
941
+ return __classPrivateFieldGet(this, _LicenseExpression_expression, "f");
942
+ }
943
+ set expression(value) {
944
+ if (!LicenseExpression.isEligibleExpression(value)) {
945
+ throw new RangeError('Not eligible expression');
946
+ }
947
+ __classPrivateFieldSet(this, _LicenseExpression_expression, value, "f");
948
+ }
949
+ compare(other) {
950
+ return __classPrivateFieldGet(this, _LicenseExpression_expression, "f").localeCompare(__classPrivateFieldGet(other, _LicenseExpression_expression, "f"));
951
+ }
952
+ }
953
+ exports.LicenseExpression = LicenseExpression;
954
+ _LicenseExpression_expression = new WeakMap();
955
+ class NamedLicense {
956
+ constructor(name, op = {}) {
957
+ this.name = name;
958
+ this.text = op.text;
959
+ this.url = op.url;
960
+ }
961
+ compare(other) {
962
+ return this.name.localeCompare(other.name);
963
+ }
964
+ }
965
+ exports.NamedLicense = NamedLicense;
966
+ class SpdxLicense {
967
+ constructor(id, op = {}) {
968
+ _SpdxLicense_id.set(this, void 0);
969
+ this.id = id;
970
+ this.text = op.text;
971
+ this.url = op.url;
972
+ }
973
+ get id() {
974
+ return __classPrivateFieldGet(this, _SpdxLicense_id, "f");
975
+ }
976
+ set id(value) {
977
+ if (!(0, spdx_1.isSupportedSpdxId)(value)) {
978
+ throw new RangeError('Unknown SPDX id');
979
+ }
980
+ __classPrivateFieldSet(this, _SpdxLicense_id, value, "f");
981
+ }
982
+ compare(other) {
983
+ return __classPrivateFieldGet(this, _SpdxLicense_id, "f").localeCompare(__classPrivateFieldGet(other, _SpdxLicense_id, "f"));
984
+ }
985
+ }
986
+ exports.SpdxLicense = SpdxLicense;
987
+ _SpdxLicense_id = new WeakMap();
988
+ class LicenseRepository extends Set {
989
+ static compareItems(a, b) {
990
+ if (a.constructor === b.constructor) {
991
+ return a.compare(b);
992
+ }
993
+ return a.constructor.name.localeCompare(b.constructor.name);
994
+ }
995
+ }
996
+ exports.LicenseRepository = LicenseRepository;
997
+
998
+
999
+ /***/ }),
1000
+
1001
+ /***/ "./src/models/metadata.ts":
1002
+ /*!********************************!*\
1003
+ !*** ./src/models/metadata.ts ***!
1004
+ \********************************/
1005
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1006
+
1007
+
1008
+ /*!
1009
+ This file is part of CycloneDX JavaScript Library.
1010
+
1011
+ Licensed under the Apache License, Version 2.0 (the "License");
1012
+ you may not use this file except in compliance with the License.
1013
+ You may obtain a copy of the License at
1014
+
1015
+ http://www.apache.org/licenses/LICENSE-2.0
1016
+
1017
+ Unless required by applicable law or agreed to in writing, software
1018
+ distributed under the License is distributed on an "AS IS" BASIS,
1019
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1020
+ See the License for the specific language governing permissions and
1021
+ limitations under the License.
1022
+
1023
+ SPDX-License-Identifier: Apache-2.0
1024
+ Copyright (c) OWASP Foundation. All Rights Reserved.
1025
+ */
1026
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
1027
+ exports.Metadata = void 0;
1028
+ const tool_1 = __webpack_require__(/*! ./tool */ "./src/models/tool.ts");
1029
+ const organizationalContact_1 = __webpack_require__(/*! ./organizationalContact */ "./src/models/organizationalContact.ts");
1030
+ class Metadata {
1031
+ constructor(op = {}) {
1032
+ this.timestamp = op.timestamp;
1033
+ this.tools = op.tools ?? new tool_1.ToolRepository();
1034
+ this.authors = op.authors ?? new organizationalContact_1.OrganizationalContactRepository();
1035
+ this.component = op.component;
1036
+ this.manufacture = op.manufacture;
1037
+ this.supplier = op.supplier;
1038
+ }
1039
+ }
1040
+ exports.Metadata = Metadata;
1041
+
1042
+
1043
+ /***/ }),
1044
+
1045
+ /***/ "./src/models/organizationalContact.ts":
1046
+ /*!*********************************************!*\
1047
+ !*** ./src/models/organizationalContact.ts ***!
1048
+ \*********************************************/
1049
+ /***/ ((__unused_webpack_module, exports) => {
1050
+
1051
+
1052
+ /*!
1053
+ This file is part of CycloneDX JavaScript Library.
1054
+
1055
+ Licensed under the Apache License, Version 2.0 (the "License");
1056
+ you may not use this file except in compliance with the License.
1057
+ You may obtain a copy of the License at
1058
+
1059
+ http://www.apache.org/licenses/LICENSE-2.0
1060
+
1061
+ Unless required by applicable law or agreed to in writing, software
1062
+ distributed under the License is distributed on an "AS IS" BASIS,
1063
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1064
+ See the License for the specific language governing permissions and
1065
+ limitations under the License.
1066
+
1067
+ SPDX-License-Identifier: Apache-2.0
1068
+ Copyright (c) OWASP Foundation. All Rights Reserved.
1069
+ */
1070
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
1071
+ exports.OrganizationalContactRepository = exports.OrganizationalContact = void 0;
1072
+ class OrganizationalContact {
1073
+ constructor(op = {}) {
1074
+ this.name = op.name;
1075
+ this.email = op.email;
1076
+ this.phone = op.phone;
1077
+ }
1078
+ compare(other) {
1079
+ return (this.name ?? '').localeCompare(other.name ?? '') ||
1080
+ (this.email ?? '').localeCompare(other.email ?? '') ||
1081
+ (this.phone ?? '').localeCompare(other.phone ?? '');
1082
+ }
1083
+ }
1084
+ exports.OrganizationalContact = OrganizationalContact;
1085
+ class OrganizationalContactRepository extends Set {
1086
+ static compareItems(a, b) {
1087
+ return a.compare(b);
1088
+ }
1089
+ }
1090
+ exports.OrganizationalContactRepository = OrganizationalContactRepository;
1091
+
1092
+
1093
+ /***/ }),
1094
+
1095
+ /***/ "./src/models/organizationalEntity.ts":
1096
+ /*!********************************************!*\
1097
+ !*** ./src/models/organizationalEntity.ts ***!
1098
+ \********************************************/
1099
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1100
+
1101
+
1102
+ /*!
1103
+ This file is part of CycloneDX JavaScript Library.
1104
+
1105
+ Licensed under the Apache License, Version 2.0 (the "License");
1106
+ you may not use this file except in compliance with the License.
1107
+ You may obtain a copy of the License at
1108
+
1109
+ http://www.apache.org/licenses/LICENSE-2.0
1110
+
1111
+ Unless required by applicable law or agreed to in writing, software
1112
+ distributed under the License is distributed on an "AS IS" BASIS,
1113
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1114
+ See the License for the specific language governing permissions and
1115
+ limitations under the License.
1116
+
1117
+ SPDX-License-Identifier: Apache-2.0
1118
+ Copyright (c) OWASP Foundation. All Rights Reserved.
1119
+ */
1120
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
1121
+ exports.OrganizationalEntity = void 0;
1122
+ const organizationalContact_1 = __webpack_require__(/*! ./organizationalContact */ "./src/models/organizationalContact.ts");
1123
+ class OrganizationalEntity {
1124
+ constructor(op = {}) {
1125
+ this.name = op.name;
1126
+ this.url = op.url ?? new Set();
1127
+ this.contact = op.contact ?? new organizationalContact_1.OrganizationalContactRepository();
1128
+ }
1129
+ }
1130
+ exports.OrganizationalEntity = OrganizationalEntity;
1131
+
1132
+
1133
+ /***/ }),
1134
+
1135
+ /***/ "./src/models/swid.ts":
1136
+ /*!****************************!*\
1137
+ !*** ./src/models/swid.ts ***!
1138
+ \****************************/
1139
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
1140
+
1141
+
1142
+ /*!
1143
+ This file is part of CycloneDX JavaScript Library.
1144
+
1145
+ Licensed under the Apache License, Version 2.0 (the "License");
1146
+ you may not use this file except in compliance with the License.
1147
+ You may obtain a copy of the License at
1148
+
1149
+ http://www.apache.org/licenses/LICENSE-2.0
1150
+
1151
+ Unless required by applicable law or agreed to in writing, software
1152
+ distributed under the License is distributed on an "AS IS" BASIS,
1153
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1154
+ See the License for the specific language governing permissions and
1155
+ limitations under the License.
1156
+
1157
+ SPDX-License-Identifier: Apache-2.0
1158
+ Copyright (c) OWASP Foundation. All Rights Reserved.
1159
+ */
1160
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
1161
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
1162
+ 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");
1163
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
1164
+ };
1165
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
1166
+ if (kind === "m") throw new TypeError("Private method is not writable");
1167
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
1168
+ 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");
1169
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
1170
+ };
1171
+ var _SWID_tagVersion;
1172
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
1173
+ exports.SWID = void 0;
1174
+ const types_1 = __webpack_require__(/*! ../types */ "./src/types/index.ts");
1175
+ class SWID {
1176
+ constructor(tagId, name, op = {}) {
1177
+ _SWID_tagVersion.set(this, void 0);
1178
+ this.tagId = tagId;
1179
+ this.name = name;
1180
+ this.version = op.version;
1181
+ this.patch = op.patch;
1182
+ this.text = op.text;
1183
+ this.url = op.url;
1184
+ this.tagVersion = op.tagVersion;
1185
+ }
1186
+ get tagVersion() {
1187
+ return __classPrivateFieldGet(this, _SWID_tagVersion, "f");
1188
+ }
1189
+ set tagVersion(value) {
1190
+ if (value !== undefined && !(0, types_1.isNonNegativeInteger)(value)) {
1191
+ throw new TypeError('Not NonNegativeInteger nor undefined');
1192
+ }
1193
+ __classPrivateFieldSet(this, _SWID_tagVersion, value, "f");
1194
+ }
1195
+ }
1196
+ exports.SWID = SWID;
1197
+ _SWID_tagVersion = new WeakMap();
1198
+
1199
+
1200
+ /***/ }),
1201
+
1202
+ /***/ "./src/models/tool.ts":
1203
+ /*!****************************!*\
1204
+ !*** ./src/models/tool.ts ***!
1205
+ \****************************/
1206
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1207
+
1208
+
1209
+ /*!
1210
+ This file is part of CycloneDX JavaScript Library.
1211
+
1212
+ Licensed under the Apache License, Version 2.0 (the "License");
1213
+ you may not use this file except in compliance with the License.
1214
+ You may obtain a copy of the License at
1215
+
1216
+ http://www.apache.org/licenses/LICENSE-2.0
1217
+
1218
+ Unless required by applicable law or agreed to in writing, software
1219
+ distributed under the License is distributed on an "AS IS" BASIS,
1220
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1221
+ See the License for the specific language governing permissions and
1222
+ limitations under the License.
1223
+
1224
+ SPDX-License-Identifier: Apache-2.0
1225
+ Copyright (c) OWASP Foundation. All Rights Reserved.
1226
+ */
1227
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
1228
+ exports.ToolRepository = exports.Tool = void 0;
1229
+ const hash_1 = __webpack_require__(/*! ./hash */ "./src/models/hash.ts");
1230
+ const externalReference_1 = __webpack_require__(/*! ./externalReference */ "./src/models/externalReference.ts");
1231
+ class Tool {
1232
+ constructor(op = {}) {
1233
+ this.vendor = op.vendor;
1234
+ this.name = op.name;
1235
+ this.version = op.version;
1236
+ this.hashes = op.hashes ?? new hash_1.HashRepository();
1237
+ this.externalReferences = op.externalReferences ?? new externalReference_1.ExternalReferenceRepository();
1238
+ }
1239
+ compare(other) {
1240
+ return (this.vendor ?? '').localeCompare(other.vendor ?? '') ||
1241
+ (this.name ?? '').localeCompare(other.name ?? '') ||
1242
+ (this.version ?? '').localeCompare(other.version ?? '');
1243
+ }
1244
+ }
1245
+ exports.Tool = Tool;
1246
+ class ToolRepository extends Set {
1247
+ static compareItems(a, b) {
1248
+ return a.compare(b);
1249
+ }
1250
+ }
1251
+ exports.ToolRepository = ToolRepository;
1252
+
1253
+
1254
+ /***/ }),
1255
+
1256
+ /***/ "./src/serialize/_index.web.ts":
1257
+ /*!*************************************!*\
1258
+ !*** ./src/serialize/_index.web.ts ***!
1259
+ \*************************************/
1260
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
1261
+
1262
+
1263
+ /*!
1264
+ This file is part of CycloneDX JavaScript Library.
1265
+
1266
+ Licensed under the Apache License, Version 2.0 (the "License");
1267
+ you may not use this file except in compliance with the License.
1268
+ You may obtain a copy of the License at
1269
+
1270
+ http://www.apache.org/licenses/LICENSE-2.0
1271
+
1272
+ Unless required by applicable law or agreed to in writing, software
1273
+ distributed under the License is distributed on an "AS IS" BASIS,
1274
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1275
+ See the License for the specific language governing permissions and
1276
+ limitations under the License.
1277
+
1278
+ SPDX-License-Identifier: Apache-2.0
1279
+ Copyright (c) OWASP Foundation. All Rights Reserved.
1280
+ */
1281
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
1282
+ if (k2 === undefined) k2 = k;
1283
+ var desc = Object.getOwnPropertyDescriptor(m, k);
1284
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
1285
+ desc = { enumerable: true, get: function() { return m[k]; } };
1286
+ }
1287
+ Object.defineProperty(o, k2, desc);
1288
+ }) : (function(o, m, k, k2) {
1289
+ if (k2 === undefined) k2 = k;
1290
+ o[k2] = m[k];
1291
+ }));
1292
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
1293
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
1294
+ };
1295
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
1296
+ __exportStar(__webpack_require__(/*! ./index */ "./src/serialize/index.ts"), exports);
1297
+ __exportStar(__webpack_require__(/*! ./xmlSerializer.web */ "./src/serialize/xmlSerializer.web.ts"), exports);
1298
+
1299
+
1300
+ /***/ }),
1301
+
1302
+ /***/ "./src/serialize/baseSerializer.ts":
1303
+ /*!*****************************************!*\
1304
+ !*** ./src/serialize/baseSerializer.ts ***!
1305
+ \*****************************************/
1306
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
1307
+
1308
+
1309
+ /*!
1310
+ This file is part of CycloneDX JavaScript Library.
1311
+
1312
+ Licensed under the Apache License, Version 2.0 (the "License");
1313
+ you may not use this file except in compliance with the License.
1314
+ You may obtain a copy of the License at
1315
+
1316
+ http://www.apache.org/licenses/LICENSE-2.0
1317
+
1318
+ Unless required by applicable law or agreed to in writing, software
1319
+ distributed under the License is distributed on an "AS IS" BASIS,
1320
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1321
+ See the License for the specific language governing permissions and
1322
+ limitations under the License.
1323
+
1324
+ SPDX-License-Identifier: Apache-2.0
1325
+ Copyright (c) OWASP Foundation. All Rights Reserved.
1326
+ */
1327
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
1328
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
1329
+ 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");
1330
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
1331
+ };
1332
+ var _BaseSerializer_instances, _BaseSerializer_getAllBomRefs;
1333
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
1334
+ exports.BaseSerializer = void 0;
1335
+ const bomRefDiscriminator_1 = __webpack_require__(/*! ./bomRefDiscriminator */ "./src/serialize/bomRefDiscriminator.ts");
1336
+ class BaseSerializer {
1337
+ constructor() {
1338
+ _BaseSerializer_instances.add(this);
1339
+ }
1340
+ serialize(bom, options) {
1341
+ const bomRefDiscriminator = new bomRefDiscriminator_1.BomRefDiscriminator(__classPrivateFieldGet(this, _BaseSerializer_instances, "m", _BaseSerializer_getAllBomRefs).call(this, bom));
1342
+ try {
1343
+ bomRefDiscriminator.discriminate();
1344
+ const normalized = this._normalize(bom, options);
1345
+ return this._serialize(normalized, options);
1346
+ }
1347
+ finally {
1348
+ bomRefDiscriminator.reset();
1349
+ }
1350
+ }
1351
+ }
1352
+ exports.BaseSerializer = BaseSerializer;
1353
+ _BaseSerializer_instances = new WeakSet(), _BaseSerializer_getAllBomRefs = function _BaseSerializer_getAllBomRefs(bom) {
1354
+ const bomRefs = new Set();
1355
+ if (bom.metadata.component !== undefined) {
1356
+ bomRefs.add(bom.metadata.component.bomRef);
1357
+ }
1358
+ for (const { bomRef } of bom.components) {
1359
+ bomRefs.add(bomRef);
1360
+ }
1361
+ return bomRefs.values();
1362
+ };
1363
+
1364
+
1365
+ /***/ }),
1366
+
1367
+ /***/ "./src/serialize/bomRefDiscriminator.ts":
1368
+ /*!**********************************************!*\
1369
+ !*** ./src/serialize/bomRefDiscriminator.ts ***!
1370
+ \**********************************************/
1371
+ /***/ (function(__unused_webpack_module, exports) {
1372
+
1373
+
1374
+ /*!
1375
+ This file is part of CycloneDX JavaScript Library.
1376
+
1377
+ Licensed under the Apache License, Version 2.0 (the "License");
1378
+ you may not use this file except in compliance with the License.
1379
+ You may obtain a copy of the License at
1380
+
1381
+ http://www.apache.org/licenses/LICENSE-2.0
1382
+
1383
+ Unless required by applicable law or agreed to in writing, software
1384
+ distributed under the License is distributed on an "AS IS" BASIS,
1385
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1386
+ See the License for the specific language governing permissions and
1387
+ limitations under the License.
1388
+
1389
+ SPDX-License-Identifier: Apache-2.0
1390
+ Copyright (c) OWASP Foundation. All Rights Reserved.
1391
+ */
1392
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
1393
+ if (kind === "m") throw new TypeError("Private method is not writable");
1394
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
1395
+ 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");
1396
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
1397
+ };
1398
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
1399
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
1400
+ 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");
1401
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
1402
+ };
1403
+ var _BomRefDiscriminator_instances, _BomRefDiscriminator_originalValues, _BomRefDiscriminator_prefix, _BomRefDiscriminator_makeUniqueId;
1404
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
1405
+ exports.BomRefDiscriminator = void 0;
1406
+ class BomRefDiscriminator {
1407
+ constructor(bomRefs, prefix = 'BomRef') {
1408
+ _BomRefDiscriminator_instances.add(this);
1409
+ _BomRefDiscriminator_originalValues.set(this, void 0);
1410
+ _BomRefDiscriminator_prefix.set(this, void 0);
1411
+ __classPrivateFieldSet(this, _BomRefDiscriminator_originalValues, new Map(Array.from(bomRefs).map(ref => [ref, ref.value])), "f");
1412
+ __classPrivateFieldSet(this, _BomRefDiscriminator_prefix, prefix, "f");
1413
+ }
1414
+ [(_BomRefDiscriminator_originalValues = new WeakMap(), _BomRefDiscriminator_prefix = new WeakMap(), _BomRefDiscriminator_instances = new WeakSet(), Symbol.iterator)]() {
1415
+ return __classPrivateFieldGet(this, _BomRefDiscriminator_originalValues, "f").keys();
1416
+ }
1417
+ discriminate() {
1418
+ const knownRefValues = new Set();
1419
+ for (const [bomRef] of __classPrivateFieldGet(this, _BomRefDiscriminator_originalValues, "f")) {
1420
+ let value = bomRef.value;
1421
+ if (value === undefined || knownRefValues.has(value)) {
1422
+ value = __classPrivateFieldGet(this, _BomRefDiscriminator_instances, "m", _BomRefDiscriminator_makeUniqueId).call(this);
1423
+ bomRef.value = value;
1424
+ }
1425
+ knownRefValues.add(value);
1426
+ }
1427
+ }
1428
+ reset() {
1429
+ for (const [bomRef, originalValue] of __classPrivateFieldGet(this, _BomRefDiscriminator_originalValues, "f")) {
1430
+ bomRef.value = originalValue;
1431
+ }
1432
+ }
1433
+ }
1434
+ exports.BomRefDiscriminator = BomRefDiscriminator;
1435
+ _BomRefDiscriminator_makeUniqueId = function _BomRefDiscriminator_makeUniqueId() {
1436
+ return `${__classPrivateFieldGet(this, _BomRefDiscriminator_prefix, "f")}${Math.random().toString(32).substring(1)}${Math.random().toString(32).substring(1)}`;
1437
+ };
1438
+
1439
+
1440
+ /***/ }),
1441
+
1442
+ /***/ "./src/serialize/index.ts":
1443
+ /*!********************************!*\
1444
+ !*** ./src/serialize/index.ts ***!
1445
+ \********************************/
1446
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
1447
+
1448
+
1449
+ /*!
1450
+ This file is part of CycloneDX JavaScript Library.
1451
+
1452
+ Licensed under the Apache License, Version 2.0 (the "License");
1453
+ you may not use this file except in compliance with the License.
1454
+ You may obtain a copy of the License at
1455
+
1456
+ http://www.apache.org/licenses/LICENSE-2.0
1457
+
1458
+ Unless required by applicable law or agreed to in writing, software
1459
+ distributed under the License is distributed on an "AS IS" BASIS,
1460
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1461
+ See the License for the specific language governing permissions and
1462
+ limitations under the License.
1463
+
1464
+ SPDX-License-Identifier: Apache-2.0
1465
+ Copyright (c) OWASP Foundation. All Rights Reserved.
1466
+ */
1467
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
1468
+ if (k2 === undefined) k2 = k;
1469
+ var desc = Object.getOwnPropertyDescriptor(m, k);
1470
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
1471
+ desc = { enumerable: true, get: function() { return m[k]; } };
1472
+ }
1473
+ Object.defineProperty(o, k2, desc);
1474
+ }) : (function(o, m, k, k2) {
1475
+ if (k2 === undefined) k2 = k;
1476
+ o[k2] = m[k];
1477
+ }));
1478
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
1479
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
1480
+ }) : function(o, v) {
1481
+ o["default"] = v;
1482
+ });
1483
+ var __importStar = (this && this.__importStar) || function (mod) {
1484
+ if (mod && mod.__esModule) return mod;
1485
+ var result = {};
1486
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
1487
+ __setModuleDefault(result, mod);
1488
+ return result;
1489
+ };
1490
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
1491
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
1492
+ };
1493
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
1494
+ exports.XML = exports.JSON = exports.Types = void 0;
1495
+ exports.Types = __importStar(__webpack_require__(/*! ./types */ "./src/serialize/types.ts"));
1496
+ __exportStar(__webpack_require__(/*! ./baseSerializer */ "./src/serialize/baseSerializer.ts"), exports);
1497
+ __exportStar(__webpack_require__(/*! ./bomRefDiscriminator */ "./src/serialize/bomRefDiscriminator.ts"), exports);
1498
+ exports.JSON = __importStar(__webpack_require__(/*! ./json */ "./src/serialize/json/index.ts"));
1499
+ __exportStar(__webpack_require__(/*! ./jsonSerializer */ "./src/serialize/jsonSerializer.ts"), exports);
1500
+ exports.XML = __importStar(__webpack_require__(/*! ./xml */ "./src/serialize/xml/index.ts"));
1501
+ __exportStar(__webpack_require__(/*! ./xmlBaseSerializer */ "./src/serialize/xmlBaseSerializer.ts"), exports);
1502
+
1503
+
1504
+ /***/ }),
1505
+
1506
+ /***/ "./src/serialize/json/index.ts":
1507
+ /*!*************************************!*\
1508
+ !*** ./src/serialize/json/index.ts ***!
1509
+ \*************************************/
1510
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
1511
+
1512
+
1513
+ /*!
1514
+ This file is part of CycloneDX JavaScript Library.
1515
+
1516
+ Licensed under the Apache License, Version 2.0 (the "License");
1517
+ you may not use this file except in compliance with the License.
1518
+ You may obtain a copy of the License at
1519
+
1520
+ http://www.apache.org/licenses/LICENSE-2.0
1521
+
1522
+ Unless required by applicable law or agreed to in writing, software
1523
+ distributed under the License is distributed on an "AS IS" BASIS,
1524
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1525
+ See the License for the specific language governing permissions and
1526
+ limitations under the License.
1527
+
1528
+ SPDX-License-Identifier: Apache-2.0
1529
+ Copyright (c) OWASP Foundation. All Rights Reserved.
1530
+ */
1531
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
1532
+ if (k2 === undefined) k2 = k;
1533
+ var desc = Object.getOwnPropertyDescriptor(m, k);
1534
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
1535
+ desc = { enumerable: true, get: function() { return m[k]; } };
1536
+ }
1537
+ Object.defineProperty(o, k2, desc);
1538
+ }) : (function(o, m, k, k2) {
1539
+ if (k2 === undefined) k2 = k;
1540
+ o[k2] = m[k];
1541
+ }));
1542
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
1543
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
1544
+ }) : function(o, v) {
1545
+ o["default"] = v;
1546
+ });
1547
+ var __importStar = (this && this.__importStar) || function (mod) {
1548
+ if (mod && mod.__esModule) return mod;
1549
+ var result = {};
1550
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
1551
+ __setModuleDefault(result, mod);
1552
+ return result;
1553
+ };
1554
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
1555
+ exports.Normalize = exports.Types = void 0;
1556
+ exports.Types = __importStar(__webpack_require__(/*! ./types */ "./src/serialize/json/types.ts"));
1557
+ exports.Normalize = __importStar(__webpack_require__(/*! ./normalize */ "./src/serialize/json/normalize.ts"));
1558
+
1559
+
1560
+ /***/ }),
1561
+
1562
+ /***/ "./src/serialize/json/normalize.ts":
1563
+ /*!*****************************************!*\
1564
+ !*** ./src/serialize/json/normalize.ts ***!
1565
+ \*****************************************/
1566
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
1567
+
1568
+
1569
+ /*!
1570
+ This file is part of CycloneDX JavaScript Library.
1571
+
1572
+ Licensed under the Apache License, Version 2.0 (the "License");
1573
+ you may not use this file except in compliance with the License.
1574
+ You may obtain a copy of the License at
1575
+
1576
+ http://www.apache.org/licenses/LICENSE-2.0
1577
+
1578
+ Unless required by applicable law or agreed to in writing, software
1579
+ distributed under the License is distributed on an "AS IS" BASIS,
1580
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1581
+ See the License for the specific language governing permissions and
1582
+ limitations under the License.
1583
+
1584
+ SPDX-License-Identifier: Apache-2.0
1585
+ Copyright (c) OWASP Foundation. All Rights Reserved.
1586
+ */
1587
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
1588
+ if (k2 === undefined) k2 = k;
1589
+ var desc = Object.getOwnPropertyDescriptor(m, k);
1590
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
1591
+ desc = { enumerable: true, get: function() { return m[k]; } };
1592
+ }
1593
+ Object.defineProperty(o, k2, desc);
1594
+ }) : (function(o, m, k, k2) {
1595
+ if (k2 === undefined) k2 = k;
1596
+ o[k2] = m[k];
1597
+ }));
1598
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
1599
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
1600
+ }) : function(o, v) {
1601
+ o["default"] = v;
1602
+ });
1603
+ var __importStar = (this && this.__importStar) || function (mod) {
1604
+ if (mod && mod.__esModule) return mod;
1605
+ var result = {};
1606
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
1607
+ __setModuleDefault(result, mod);
1608
+ return result;
1609
+ };
1610
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
1611
+ if (kind === "m") throw new TypeError("Private method is not writable");
1612
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
1613
+ 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");
1614
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
1615
+ };
1616
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
1617
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
1618
+ 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");
1619
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
1620
+ };
1621
+ var _Factory_spec, _LicenseNormalizer_instances, _LicenseNormalizer_normalizeNamedLicense, _LicenseNormalizer_normalizeSpdxLicense, _LicenseNormalizer_normalizeLicenseExpression, _DependencyGraphNormalizer_instances, _DependencyGraphNormalizer_normalizeDependency;
1622
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
1623
+ exports.DependencyGraphNormalizer = exports.AttachmentNormalizer = exports.ExternalReferenceNormalizer = exports.SWIDNormalizer = exports.LicenseNormalizer = exports.ComponentNormalizer = exports.OrganizationalEntityNormalizer = exports.OrganizationalContactNormalizer = exports.HashNormalizer = exports.ToolNormalizer = exports.MetadataNormalizer = exports.BomNormalizer = exports.Factory = void 0;
1624
+ const types_1 = __webpack_require__(/*! ../../helpers/types */ "./src/helpers/types.ts");
1625
+ const Models = __importStar(__webpack_require__(/*! ../../models */ "./src/models/index.ts"));
1626
+ const spec_1 = __webpack_require__(/*! ../../spec */ "./src/spec.ts");
1627
+ const types_2 = __webpack_require__(/*! ./types */ "./src/serialize/json/types.ts");
1628
+ class Factory {
1629
+ constructor(spec) {
1630
+ _Factory_spec.set(this, void 0);
1631
+ __classPrivateFieldSet(this, _Factory_spec, spec, "f");
1632
+ }
1633
+ get spec() {
1634
+ return __classPrivateFieldGet(this, _Factory_spec, "f");
1635
+ }
1636
+ makeForBom() {
1637
+ return new BomNormalizer(this);
1638
+ }
1639
+ makeForMetadata() {
1640
+ return new MetadataNormalizer(this);
1641
+ }
1642
+ makeForComponent() {
1643
+ return new ComponentNormalizer(this);
1644
+ }
1645
+ makeForTool() {
1646
+ return new ToolNormalizer(this);
1647
+ }
1648
+ makeForOrganizationalContact() {
1649
+ return new OrganizationalContactNormalizer(this);
1650
+ }
1651
+ makeForOrganizationalEntity() {
1652
+ return new OrganizationalEntityNormalizer(this);
1653
+ }
1654
+ makeForHash() {
1655
+ return new HashNormalizer(this);
1656
+ }
1657
+ makeForLicense() {
1658
+ return new LicenseNormalizer(this);
1659
+ }
1660
+ makeForSWID() {
1661
+ return new SWIDNormalizer(this);
1662
+ }
1663
+ makeForExternalReference() {
1664
+ return new ExternalReferenceNormalizer(this);
1665
+ }
1666
+ makeForAttachment() {
1667
+ return new AttachmentNormalizer(this);
1668
+ }
1669
+ makeForDependencyGraph() {
1670
+ return new DependencyGraphNormalizer(this);
1671
+ }
1672
+ }
1673
+ exports.Factory = Factory;
1674
+ _Factory_spec = new WeakMap();
1675
+ const schemaUrl = new Map([
1676
+ [spec_1.Version.v1dot2, 'http://cyclonedx.org/schema/bom-1.2b.schema.json'],
1677
+ [spec_1.Version.v1dot3, 'http://cyclonedx.org/schema/bom-1.3a.schema.json'],
1678
+ [spec_1.Version.v1dot4, 'http://cyclonedx.org/schema/bom-1.4.schema.json']
1679
+ ]);
1680
+ class Base {
1681
+ constructor(factory) {
1682
+ this._factory = factory;
1683
+ }
1684
+ }
1685
+ class BomNormalizer extends Base {
1686
+ normalize(data, options) {
1687
+ return {
1688
+ $schema: schemaUrl.get(this._factory.spec.version),
1689
+ bomFormat: 'CycloneDX',
1690
+ specVersion: this._factory.spec.version,
1691
+ version: data.version,
1692
+ serialNumber: data.serialNumber,
1693
+ metadata: this._factory.makeForMetadata().normalize(data.metadata, options),
1694
+ components: data.components.size > 0
1695
+ ? this._factory.makeForComponent().normalizeIter(data.components, options)
1696
+ : [],
1697
+ dependencies: this._factory.spec.supportsDependencyGraph
1698
+ ? this._factory.makeForDependencyGraph().normalize(data, options)
1699
+ : undefined
1700
+ };
1701
+ }
1702
+ }
1703
+ exports.BomNormalizer = BomNormalizer;
1704
+ class MetadataNormalizer extends Base {
1705
+ normalize(data, options) {
1706
+ const orgEntityNormalizer = this._factory.makeForOrganizationalEntity();
1707
+ return {
1708
+ timestamp: data.timestamp?.toISOString(),
1709
+ tools: data.tools.size > 0
1710
+ ? this._factory.makeForTool().normalizeIter(data.tools, options)
1711
+ : undefined,
1712
+ authors: data.authors.size > 0
1713
+ ? this._factory.makeForOrganizationalContact().normalizeIter(data.authors, options)
1714
+ : undefined,
1715
+ component: data.component === undefined
1716
+ ? undefined
1717
+ : this._factory.makeForComponent().normalize(data.component, options),
1718
+ manufacture: data.manufacture === undefined
1719
+ ? undefined
1720
+ : orgEntityNormalizer.normalize(data.manufacture, options),
1721
+ supplier: data.supplier === undefined
1722
+ ? undefined
1723
+ : orgEntityNormalizer.normalize(data.supplier, options)
1724
+ };
1725
+ }
1726
+ }
1727
+ exports.MetadataNormalizer = MetadataNormalizer;
1728
+ class ToolNormalizer extends Base {
1729
+ normalize(data, options) {
1730
+ return {
1731
+ vendor: data.vendor || undefined,
1732
+ name: data.name || undefined,
1733
+ version: data.version || undefined,
1734
+ hashes: data.hashes.size > 0
1735
+ ? this._factory.makeForHash().normalizeIter(data.hashes, options)
1736
+ : undefined,
1737
+ externalReferences: this._factory.spec.supportsToolReferences && data.externalReferences.size > 0
1738
+ ? this._factory.makeForExternalReference().normalizeIter(data.externalReferences, options)
1739
+ : undefined
1740
+ };
1741
+ }
1742
+ normalizeIter(data, options) {
1743
+ const tools = Array.from(data);
1744
+ if (options.sortLists ?? false) {
1745
+ tools.sort(Models.ToolRepository.compareItems);
1746
+ }
1747
+ return tools.map(t => this.normalize(t, options));
1748
+ }
1749
+ }
1750
+ exports.ToolNormalizer = ToolNormalizer;
1751
+ class HashNormalizer extends Base {
1752
+ normalize([algorithm, content], options) {
1753
+ const spec = this._factory.spec;
1754
+ return spec.supportsHashAlgorithm(algorithm) && spec.supportsHashValue(content)
1755
+ ? {
1756
+ alg: algorithm,
1757
+ content: content
1758
+ }
1759
+ : undefined;
1760
+ }
1761
+ normalizeIter(data, options) {
1762
+ const hashes = Array.from(data);
1763
+ if (options.sortLists ?? false) {
1764
+ hashes.sort(Models.HashRepository.compareItems);
1765
+ }
1766
+ return hashes.map(h => this.normalize(h, options))
1767
+ .filter(types_1.isNotUndefined);
1768
+ }
1769
+ }
1770
+ exports.HashNormalizer = HashNormalizer;
1771
+ class OrganizationalContactNormalizer extends Base {
1772
+ normalize(data, options) {
1773
+ return {
1774
+ name: data.name || undefined,
1775
+ email: types_2.JsonSchema.isIdnEmail(data.email)
1776
+ ? data.email
1777
+ : undefined,
1778
+ phone: data.phone || undefined
1779
+ };
1780
+ }
1781
+ normalizeIter(data, options) {
1782
+ const contacts = Array.from(data);
1783
+ if (options.sortLists ?? false) {
1784
+ contacts.sort(Models.OrganizationalContactRepository.compareItems);
1785
+ }
1786
+ return contacts.map(c => this.normalize(c, options));
1787
+ }
1788
+ }
1789
+ exports.OrganizationalContactNormalizer = OrganizationalContactNormalizer;
1790
+ class OrganizationalEntityNormalizer extends Base {
1791
+ normalize(data, options) {
1792
+ const urls = normalizeStringableIter(data.url, options)
1793
+ .filter(types_2.JsonSchema.isIriReference);
1794
+ return {
1795
+ name: data.name || undefined,
1796
+ url: urls.length > 0
1797
+ ? urls
1798
+ : undefined,
1799
+ contact: data.contact.size > 0
1800
+ ? this._factory.makeForOrganizationalContact().normalizeIter(data.contact, options)
1801
+ : undefined
1802
+ };
1803
+ }
1804
+ }
1805
+ exports.OrganizationalEntityNormalizer = OrganizationalEntityNormalizer;
1806
+ class ComponentNormalizer extends Base {
1807
+ normalize(data, options) {
1808
+ return this._factory.spec.supportsComponentType(data.type)
1809
+ ? {
1810
+ type: data.type,
1811
+ name: data.name,
1812
+ group: data.group || undefined,
1813
+ version: data.version || '',
1814
+ 'bom-ref': data.bomRef.value || undefined,
1815
+ supplier: data.supplier === undefined
1816
+ ? undefined
1817
+ : this._factory.makeForOrganizationalEntity().normalize(data.supplier, options),
1818
+ author: data.author || undefined,
1819
+ publisher: data.publisher || undefined,
1820
+ description: data.description || undefined,
1821
+ scope: data.scope,
1822
+ hashes: data.hashes.size > 0
1823
+ ? this._factory.makeForHash().normalizeIter(data.hashes, options)
1824
+ : undefined,
1825
+ licenses: data.licenses.size > 0
1826
+ ? this._factory.makeForLicense().normalizeIter(data.licenses, options)
1827
+ : undefined,
1828
+ copyright: data.copyright || undefined,
1829
+ cpe: data.cpe || undefined,
1830
+ purl: data.purl?.toString(),
1831
+ swid: data.swid === undefined
1832
+ ? undefined
1833
+ : this._factory.makeForSWID().normalize(data.swid, options),
1834
+ externalReferences: data.externalReferences.size > 0
1835
+ ? this._factory.makeForExternalReference().normalizeIter(data.externalReferences, options)
1836
+ : undefined
1837
+ }
1838
+ : undefined;
1839
+ }
1840
+ normalizeIter(data, options) {
1841
+ const components = Array.from(data);
1842
+ if (options.sortLists ?? false) {
1843
+ components.sort(Models.ComponentRepository.compareItems);
1844
+ }
1845
+ return components.map(c => this.normalize(c, options))
1846
+ .filter(types_1.isNotUndefined);
1847
+ }
1848
+ }
1849
+ exports.ComponentNormalizer = ComponentNormalizer;
1850
+ class LicenseNormalizer extends Base {
1851
+ constructor() {
1852
+ super(...arguments);
1853
+ _LicenseNormalizer_instances.add(this);
1854
+ }
1855
+ normalize(data, options) {
1856
+ switch (true) {
1857
+ case data instanceof Models.NamedLicense:
1858
+ return __classPrivateFieldGet(this, _LicenseNormalizer_instances, "m", _LicenseNormalizer_normalizeNamedLicense).call(this, data, options);
1859
+ case data instanceof Models.SpdxLicense:
1860
+ return __classPrivateFieldGet(this, _LicenseNormalizer_instances, "m", _LicenseNormalizer_normalizeSpdxLicense).call(this, data, options);
1861
+ case data instanceof Models.LicenseExpression:
1862
+ return __classPrivateFieldGet(this, _LicenseNormalizer_instances, "m", _LicenseNormalizer_normalizeLicenseExpression).call(this, data);
1863
+ default:
1864
+ throw new TypeError('Unexpected LicenseChoice');
1865
+ }
1866
+ }
1867
+ normalizeIter(data, options) {
1868
+ const licenses = Array.from(data);
1869
+ if (options.sortLists ?? false) {
1870
+ licenses.sort(Models.LicenseRepository.compareItems);
1871
+ }
1872
+ return licenses.map(c => this.normalize(c, options));
1873
+ }
1874
+ }
1875
+ exports.LicenseNormalizer = LicenseNormalizer;
1876
+ _LicenseNormalizer_instances = new WeakSet(), _LicenseNormalizer_normalizeNamedLicense = function _LicenseNormalizer_normalizeNamedLicense(data, options) {
1877
+ return {
1878
+ license: {
1879
+ name: data.name,
1880
+ text: data.text === undefined
1881
+ ? undefined
1882
+ : this._factory.makeForAttachment().normalize(data.text, options),
1883
+ url: data.url?.toString()
1884
+ }
1885
+ };
1886
+ }, _LicenseNormalizer_normalizeSpdxLicense = function _LicenseNormalizer_normalizeSpdxLicense(data, options) {
1887
+ return {
1888
+ license: {
1889
+ id: data.id,
1890
+ text: data.text === undefined
1891
+ ? undefined
1892
+ : this._factory.makeForAttachment().normalize(data.text, options),
1893
+ url: data.url?.toString()
1894
+ }
1895
+ };
1896
+ }, _LicenseNormalizer_normalizeLicenseExpression = function _LicenseNormalizer_normalizeLicenseExpression(data) {
1897
+ return {
1898
+ expression: data.expression
1899
+ };
1900
+ };
1901
+ class SWIDNormalizer extends Base {
1902
+ normalize(data, options) {
1903
+ const url = data.url?.toString();
1904
+ return {
1905
+ tagId: data.tagId,
1906
+ name: data.name,
1907
+ version: data.version || undefined,
1908
+ tagVersion: data.tagVersion,
1909
+ patch: data.patch,
1910
+ text: data.text === undefined
1911
+ ? undefined
1912
+ : this._factory.makeForAttachment().normalize(data.text, options),
1913
+ url: types_2.JsonSchema.isIriReference(url)
1914
+ ? url
1915
+ : undefined
1916
+ };
1917
+ }
1918
+ }
1919
+ exports.SWIDNormalizer = SWIDNormalizer;
1920
+ class ExternalReferenceNormalizer extends Base {
1921
+ normalize(data, options) {
1922
+ return this._factory.spec.supportsExternalReferenceType(data.type)
1923
+ ? {
1924
+ url: data.url.toString(),
1925
+ type: data.type,
1926
+ comment: data.comment || undefined
1927
+ }
1928
+ : undefined;
1929
+ }
1930
+ normalizeIter(data, options) {
1931
+ const refs = Array.from(data);
1932
+ if (options.sortLists ?? false) {
1933
+ refs.sort(Models.ExternalReferenceRepository.compareItems);
1934
+ }
1935
+ return refs.map(r => this.normalize(r, options))
1936
+ .filter(types_1.isNotUndefined);
1937
+ }
1938
+ }
1939
+ exports.ExternalReferenceNormalizer = ExternalReferenceNormalizer;
1940
+ class AttachmentNormalizer extends Base {
1941
+ normalize(data, options) {
1942
+ return {
1943
+ content: data.content,
1944
+ contentType: data.contentType || undefined,
1945
+ encoding: data.encoding
1946
+ };
1947
+ }
1948
+ }
1949
+ exports.AttachmentNormalizer = AttachmentNormalizer;
1950
+ class DependencyGraphNormalizer extends Base {
1951
+ constructor() {
1952
+ super(...arguments);
1953
+ _DependencyGraphNormalizer_instances.add(this);
1954
+ }
1955
+ normalize(data, options) {
1956
+ if (!data.metadata.component?.bomRef.value) {
1957
+ return undefined;
1958
+ }
1959
+ const allRefs = new Map();
1960
+ for (const c of data.components) {
1961
+ allRefs.set(c.bomRef, new Models.BomRefRepository(c.dependencies));
1962
+ }
1963
+ allRefs.set(data.metadata.component.bomRef, data.metadata.component.dependencies);
1964
+ const normalized = [];
1965
+ for (const [ref, deps] of allRefs) {
1966
+ const dep = __classPrivateFieldGet(this, _DependencyGraphNormalizer_instances, "m", _DependencyGraphNormalizer_normalizeDependency).call(this, ref, deps, allRefs, options);
1967
+ if ((0, types_1.isNotUndefined)(dep)) {
1968
+ normalized.push(dep);
1969
+ }
1970
+ }
1971
+ if (options.sortLists ?? false) {
1972
+ normalized.sort(({ ref: a }, { ref: b }) => a.localeCompare(b));
1973
+ }
1974
+ return normalized;
1975
+ }
1976
+ }
1977
+ exports.DependencyGraphNormalizer = DependencyGraphNormalizer;
1978
+ _DependencyGraphNormalizer_instances = new WeakSet(), _DependencyGraphNormalizer_normalizeDependency = function _DependencyGraphNormalizer_normalizeDependency(ref, deps, allRefs, options) {
1979
+ const bomRef = ref.toString();
1980
+ if (bomRef.length === 0) {
1981
+ return undefined;
1982
+ }
1983
+ const dependsOn = normalizeStringableIter(Array.from(deps).filter(d => allRefs.has(d) && d !== ref), options).filter(d => d.length > 0);
1984
+ return {
1985
+ ref: bomRef,
1986
+ dependsOn: dependsOn.length > 0
1987
+ ? dependsOn
1988
+ : undefined
1989
+ };
1990
+ };
1991
+ function normalizeStringableIter(data, options) {
1992
+ const r = Array.from(data, d => d.toString());
1993
+ if (options.sortLists ?? false) {
1994
+ r.sort((a, b) => a.localeCompare(b));
1995
+ }
1996
+ return r;
1997
+ }
1998
+
1999
+
2000
+ /***/ }),
2001
+
2002
+ /***/ "./src/serialize/json/types.ts":
2003
+ /*!*************************************!*\
2004
+ !*** ./src/serialize/json/types.ts ***!
2005
+ \*************************************/
2006
+ /***/ ((__unused_webpack_module, exports) => {
2007
+
2008
+
2009
+ /*!
2010
+ This file is part of CycloneDX JavaScript Library.
2011
+
2012
+ Licensed under the Apache License, Version 2.0 (the "License");
2013
+ you may not use this file except in compliance with the License.
2014
+ You may obtain a copy of the License at
2015
+
2016
+ http://www.apache.org/licenses/LICENSE-2.0
2017
+
2018
+ Unless required by applicable law or agreed to in writing, software
2019
+ distributed under the License is distributed on an "AS IS" BASIS,
2020
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2021
+ See the License for the specific language governing permissions and
2022
+ limitations under the License.
2023
+
2024
+ SPDX-License-Identifier: Apache-2.0
2025
+ Copyright (c) OWASP Foundation. All Rights Reserved.
2026
+ */
2027
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
2028
+ exports.JsonSchema = void 0;
2029
+ var JsonSchema;
2030
+ (function (JsonSchema) {
2031
+ function isIriReference(value) {
2032
+ return typeof value === 'string' &&
2033
+ value.length > 0;
2034
+ }
2035
+ JsonSchema.isIriReference = isIriReference;
2036
+ function isIdnEmail(value) {
2037
+ return typeof value === 'string' &&
2038
+ value.length > 0;
2039
+ }
2040
+ JsonSchema.isIdnEmail = isIdnEmail;
2041
+ })(JsonSchema = exports.JsonSchema || (exports.JsonSchema = {}));
2042
+
2043
+
2044
+ /***/ }),
2045
+
2046
+ /***/ "./src/serialize/jsonSerializer.ts":
2047
+ /*!*****************************************!*\
2048
+ !*** ./src/serialize/jsonSerializer.ts ***!
2049
+ \*****************************************/
2050
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
2051
+
2052
+
2053
+ /*!
2054
+ This file is part of CycloneDX JavaScript Library.
2055
+
2056
+ Licensed under the Apache License, Version 2.0 (the "License");
2057
+ you may not use this file except in compliance with the License.
2058
+ You may obtain a copy of the License at
2059
+
2060
+ http://www.apache.org/licenses/LICENSE-2.0
2061
+
2062
+ Unless required by applicable law or agreed to in writing, software
2063
+ distributed under the License is distributed on an "AS IS" BASIS,
2064
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2065
+ See the License for the specific language governing permissions and
2066
+ limitations under the License.
2067
+
2068
+ SPDX-License-Identifier: Apache-2.0
2069
+ Copyright (c) OWASP Foundation. All Rights Reserved.
2070
+ */
2071
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2072
+ if (kind === "m") throw new TypeError("Private method is not writable");
2073
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
2074
+ 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");
2075
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
2076
+ };
2077
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2078
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
2079
+ 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");
2080
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
2081
+ };
2082
+ var _JsonSerializer_normalizerFactory;
2083
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
2084
+ exports.JsonSerializer = void 0;
2085
+ const spec_1 = __webpack_require__(/*! ../spec */ "./src/spec.ts");
2086
+ const baseSerializer_1 = __webpack_require__(/*! ./baseSerializer */ "./src/serialize/baseSerializer.ts");
2087
+ class JsonSerializer extends baseSerializer_1.BaseSerializer {
2088
+ constructor(normalizerFactory) {
2089
+ if (!normalizerFactory.spec.supportsFormat(spec_1.Format.JSON)) {
2090
+ throw new spec_1.UnsupportedFormatError('Spec does not support JSON format.');
2091
+ }
2092
+ super();
2093
+ _JsonSerializer_normalizerFactory.set(this, void 0);
2094
+ __classPrivateFieldSet(this, _JsonSerializer_normalizerFactory, normalizerFactory, "f");
2095
+ }
2096
+ _normalize(bom, options = {}) {
2097
+ return __classPrivateFieldGet(this, _JsonSerializer_normalizerFactory, "f").makeForBom()
2098
+ .normalize(bom, options);
2099
+ }
2100
+ _serialize(bom, { space } = {}) {
2101
+ return JSON.stringify(bom, null, space);
2102
+ }
2103
+ }
2104
+ exports.JsonSerializer = JsonSerializer;
2105
+ _JsonSerializer_normalizerFactory = new WeakMap();
2106
+
2107
+
2108
+ /***/ }),
2109
+
2110
+ /***/ "./src/serialize/types.ts":
2111
+ /*!********************************!*\
2112
+ !*** ./src/serialize/types.ts ***!
2113
+ \********************************/
2114
+ /***/ ((__unused_webpack_module, exports) => {
2115
+
2116
+
2117
+ /*!
2118
+ This file is part of CycloneDX JavaScript Library.
2119
+
2120
+ Licensed under the Apache License, Version 2.0 (the "License");
2121
+ you may not use this file except in compliance with the License.
2122
+ You may obtain a copy of the License at
2123
+
2124
+ http://www.apache.org/licenses/LICENSE-2.0
2125
+
2126
+ Unless required by applicable law or agreed to in writing, software
2127
+ distributed under the License is distributed on an "AS IS" BASIS,
2128
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2129
+ See the License for the specific language governing permissions and
2130
+ limitations under the License.
2131
+
2132
+ SPDX-License-Identifier: Apache-2.0
2133
+ Copyright (c) OWASP Foundation. All Rights Reserved.
2134
+ */
2135
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
2136
+
2137
+
2138
+ /***/ }),
2139
+
2140
+ /***/ "./src/serialize/xml/index.ts":
2141
+ /*!************************************!*\
2142
+ !*** ./src/serialize/xml/index.ts ***!
2143
+ \************************************/
2144
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
2145
+
2146
+
2147
+ /*!
2148
+ This file is part of CycloneDX JavaScript Library.
2149
+
2150
+ Licensed under the Apache License, Version 2.0 (the "License");
2151
+ you may not use this file except in compliance with the License.
2152
+ You may obtain a copy of the License at
2153
+
2154
+ http://www.apache.org/licenses/LICENSE-2.0
2155
+
2156
+ Unless required by applicable law or agreed to in writing, software
2157
+ distributed under the License is distributed on an "AS IS" BASIS,
2158
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2159
+ See the License for the specific language governing permissions and
2160
+ limitations under the License.
2161
+
2162
+ SPDX-License-Identifier: Apache-2.0
2163
+ Copyright (c) OWASP Foundation. All Rights Reserved.
2164
+ */
2165
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
2166
+ if (k2 === undefined) k2 = k;
2167
+ var desc = Object.getOwnPropertyDescriptor(m, k);
2168
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
2169
+ desc = { enumerable: true, get: function() { return m[k]; } };
2170
+ }
2171
+ Object.defineProperty(o, k2, desc);
2172
+ }) : (function(o, m, k, k2) {
2173
+ if (k2 === undefined) k2 = k;
2174
+ o[k2] = m[k];
2175
+ }));
2176
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
2177
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
2178
+ }) : function(o, v) {
2179
+ o["default"] = v;
2180
+ });
2181
+ var __importStar = (this && this.__importStar) || function (mod) {
2182
+ if (mod && mod.__esModule) return mod;
2183
+ var result = {};
2184
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
2185
+ __setModuleDefault(result, mod);
2186
+ return result;
2187
+ };
2188
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
2189
+ exports.Normalize = exports.Types = void 0;
2190
+ exports.Types = __importStar(__webpack_require__(/*! ./types */ "./src/serialize/xml/types.ts"));
2191
+ exports.Normalize = __importStar(__webpack_require__(/*! ./normalize */ "./src/serialize/xml/normalize.ts"));
2192
+
2193
+
2194
+ /***/ }),
2195
+
2196
+ /***/ "./src/serialize/xml/normalize.ts":
2197
+ /*!****************************************!*\
2198
+ !*** ./src/serialize/xml/normalize.ts ***!
2199
+ \****************************************/
2200
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
2201
+
2202
+
2203
+ /*!
2204
+ This file is part of CycloneDX JavaScript Library.
2205
+
2206
+ Licensed under the Apache License, Version 2.0 (the "License");
2207
+ you may not use this file except in compliance with the License.
2208
+ You may obtain a copy of the License at
2209
+
2210
+ http://www.apache.org/licenses/LICENSE-2.0
2211
+
2212
+ Unless required by applicable law or agreed to in writing, software
2213
+ distributed under the License is distributed on an "AS IS" BASIS,
2214
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2215
+ See the License for the specific language governing permissions and
2216
+ limitations under the License.
2217
+
2218
+ SPDX-License-Identifier: Apache-2.0
2219
+ Copyright (c) OWASP Foundation. All Rights Reserved.
2220
+ */
2221
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
2222
+ if (k2 === undefined) k2 = k;
2223
+ var desc = Object.getOwnPropertyDescriptor(m, k);
2224
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
2225
+ desc = { enumerable: true, get: function() { return m[k]; } };
2226
+ }
2227
+ Object.defineProperty(o, k2, desc);
2228
+ }) : (function(o, m, k, k2) {
2229
+ if (k2 === undefined) k2 = k;
2230
+ o[k2] = m[k];
2231
+ }));
2232
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
2233
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
2234
+ }) : function(o, v) {
2235
+ o["default"] = v;
2236
+ });
2237
+ var __importStar = (this && this.__importStar) || function (mod) {
2238
+ if (mod && mod.__esModule) return mod;
2239
+ var result = {};
2240
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
2241
+ __setModuleDefault(result, mod);
2242
+ return result;
2243
+ };
2244
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2245
+ if (kind === "m") throw new TypeError("Private method is not writable");
2246
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
2247
+ 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");
2248
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
2249
+ };
2250
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2251
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
2252
+ 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");
2253
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
2254
+ };
2255
+ var _Factory_spec, _LicenseNormalizer_instances, _LicenseNormalizer_normalizeNamedLicense, _LicenseNormalizer_normalizeSpdxLicense, _LicenseNormalizer_normalizeLicenseExpression, _DependencyGraphNormalizer_instances, _DependencyGraphNormalizer_normalizeDependency;
2256
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
2257
+ exports.DependencyGraphNormalizer = exports.AttachmentNormalizer = exports.ExternalReferenceNormalizer = exports.SWIDNormalizer = exports.LicenseNormalizer = exports.ComponentNormalizer = exports.OrganizationalEntityNormalizer = exports.OrganizationalContactNormalizer = exports.HashNormalizer = exports.ToolNormalizer = exports.MetadataNormalizer = exports.BomNormalizer = exports.Factory = void 0;
2258
+ const types_1 = __webpack_require__(/*! ../../helpers/types */ "./src/helpers/types.ts");
2259
+ const Models = __importStar(__webpack_require__(/*! ../../models */ "./src/models/index.ts"));
2260
+ const spec_1 = __webpack_require__(/*! ../../spec */ "./src/spec.ts");
2261
+ const types_2 = __webpack_require__(/*! ./types */ "./src/serialize/xml/types.ts");
2262
+ class Factory {
2263
+ constructor(spec) {
2264
+ _Factory_spec.set(this, void 0);
2265
+ __classPrivateFieldSet(this, _Factory_spec, spec, "f");
2266
+ }
2267
+ get spec() {
2268
+ return __classPrivateFieldGet(this, _Factory_spec, "f");
2269
+ }
2270
+ makeForBom() {
2271
+ return new BomNormalizer(this);
2272
+ }
2273
+ makeForMetadata() {
2274
+ return new MetadataNormalizer(this);
2275
+ }
2276
+ makeForComponent() {
2277
+ return new ComponentNormalizer(this);
2278
+ }
2279
+ makeForTool() {
2280
+ return new ToolNormalizer(this);
2281
+ }
2282
+ makeForOrganizationalContact() {
2283
+ return new OrganizationalContactNormalizer(this);
2284
+ }
2285
+ makeForOrganizationalEntity() {
2286
+ return new OrganizationalEntityNormalizer(this);
2287
+ }
2288
+ makeForHash() {
2289
+ return new HashNormalizer(this);
2290
+ }
2291
+ makeForLicense() {
2292
+ return new LicenseNormalizer(this);
2293
+ }
2294
+ makeForSWID() {
2295
+ return new SWIDNormalizer(this);
2296
+ }
2297
+ makeForExternalReference() {
2298
+ return new ExternalReferenceNormalizer(this);
2299
+ }
2300
+ makeForAttachment() {
2301
+ return new AttachmentNormalizer(this);
2302
+ }
2303
+ makeForDependencyGraph() {
2304
+ return new DependencyGraphNormalizer(this);
2305
+ }
2306
+ }
2307
+ exports.Factory = Factory;
2308
+ _Factory_spec = new WeakMap();
2309
+ const xmlNamespace = new Map([
2310
+ [spec_1.Version.v1dot2, 'http://cyclonedx.org/schema/bom/1.2'],
2311
+ [spec_1.Version.v1dot3, 'http://cyclonedx.org/schema/bom/1.3'],
2312
+ [spec_1.Version.v1dot4, 'http://cyclonedx.org/schema/bom/1.4']
2313
+ ]);
2314
+ class Base {
2315
+ constructor(factory) {
2316
+ this._factory = factory;
2317
+ }
2318
+ }
2319
+ class BomNormalizer extends Base {
2320
+ normalize(data, options) {
2321
+ const components = {
2322
+ type: 'element',
2323
+ name: 'components',
2324
+ children: data.components.size > 0
2325
+ ? this._factory.makeForComponent().normalizeIter(data.components, options, 'component')
2326
+ : undefined
2327
+ };
2328
+ return {
2329
+ type: 'element',
2330
+ name: 'bom',
2331
+ namespace: xmlNamespace.get(this._factory.spec.version),
2332
+ attributes: {
2333
+ version: data.version,
2334
+ serialNumber: data.serialNumber
2335
+ },
2336
+ children: [
2337
+ data.metadata
2338
+ ? this._factory.makeForMetadata().normalize(data.metadata, options, 'metadata')
2339
+ : undefined,
2340
+ components,
2341
+ this._factory.spec.supportsDependencyGraph
2342
+ ? this._factory.makeForDependencyGraph().normalize(data, options, 'dependencies')
2343
+ : undefined
2344
+ ].filter(types_1.isNotUndefined)
2345
+ };
2346
+ }
2347
+ }
2348
+ exports.BomNormalizer = BomNormalizer;
2349
+ class MetadataNormalizer extends Base {
2350
+ normalize(data, options, elementName) {
2351
+ const orgEntityNormalizer = this._factory.makeForOrganizationalEntity();
2352
+ const timestamp = data.timestamp === undefined
2353
+ ? undefined
2354
+ : {
2355
+ type: 'element',
2356
+ name: 'timestamp',
2357
+ children: data.timestamp.toISOString()
2358
+ };
2359
+ const tools = data.tools.size > 0
2360
+ ? {
2361
+ type: 'element',
2362
+ name: 'tools',
2363
+ children: this._factory.makeForTool().normalizeIter(data.tools, options, 'tool')
2364
+ }
2365
+ : undefined;
2366
+ const authors = data.authors.size > 0
2367
+ ? {
2368
+ type: 'element',
2369
+ name: 'authors',
2370
+ children: this._factory.makeForOrganizationalContact()
2371
+ .normalizeIter(data.authors, options, 'author')
2372
+ }
2373
+ : undefined;
2374
+ return {
2375
+ type: 'element',
2376
+ name: elementName,
2377
+ children: [
2378
+ timestamp,
2379
+ tools,
2380
+ authors,
2381
+ data.component === undefined
2382
+ ? undefined
2383
+ : this._factory.makeForComponent().normalize(data.component, options, 'component'),
2384
+ data.manufacture === undefined
2385
+ ? undefined
2386
+ : orgEntityNormalizer.normalize(data.manufacture, options, 'manufacture'),
2387
+ data.supplier === undefined
2388
+ ? undefined
2389
+ : orgEntityNormalizer.normalize(data.supplier, options, 'supplier')
2390
+ ].filter(types_1.isNotUndefined)
2391
+ };
2392
+ }
2393
+ }
2394
+ exports.MetadataNormalizer = MetadataNormalizer;
2395
+ class ToolNormalizer extends Base {
2396
+ normalize(data, options, elementName) {
2397
+ const hashes = data.hashes.size > 0
2398
+ ? {
2399
+ type: 'element',
2400
+ name: 'hashes',
2401
+ children: this._factory.makeForHash().normalizeIter(data.hashes, options, 'hash')
2402
+ }
2403
+ : undefined;
2404
+ const externalReferences = this._factory.spec.supportsToolReferences && data.externalReferences.size > 0
2405
+ ? {
2406
+ type: 'element',
2407
+ name: 'externalReferences',
2408
+ children: this._factory.makeForExternalReference()
2409
+ .normalizeIter(data.externalReferences, options, 'reference')
2410
+ }
2411
+ : undefined;
2412
+ return {
2413
+ type: 'element',
2414
+ name: elementName,
2415
+ children: [
2416
+ makeOptionalTextElement(data.vendor, 'vendor'),
2417
+ makeOptionalTextElement(data.name, 'name'),
2418
+ makeOptionalTextElement(data.version, 'version'),
2419
+ hashes,
2420
+ externalReferences
2421
+ ].filter(types_1.isNotUndefined)
2422
+ };
2423
+ }
2424
+ normalizeIter(data, options, elementName) {
2425
+ const tools = Array.from(data);
2426
+ if (options.sortLists) {
2427
+ tools.sort(Models.ToolRepository.compareItems);
2428
+ }
2429
+ return tools.map(t => this.normalize(t, options, elementName));
2430
+ }
2431
+ }
2432
+ exports.ToolNormalizer = ToolNormalizer;
2433
+ class HashNormalizer extends Base {
2434
+ normalize([algorithm, content], options, elementName) {
2435
+ const spec = this._factory.spec;
2436
+ return spec.supportsHashAlgorithm(algorithm) && spec.supportsHashValue(content)
2437
+ ? {
2438
+ type: 'element',
2439
+ name: elementName,
2440
+ attributes: { alg: algorithm },
2441
+ children: content
2442
+ }
2443
+ : undefined;
2444
+ }
2445
+ normalizeIter(data, options, elementName) {
2446
+ const hashes = Array.from(data);
2447
+ if (options.sortLists ?? false) {
2448
+ hashes.sort(Models.HashRepository.compareItems);
2449
+ }
2450
+ return hashes.map(h => this.normalize(h, options, elementName))
2451
+ .filter(types_1.isNotUndefined);
2452
+ }
2453
+ }
2454
+ exports.HashNormalizer = HashNormalizer;
2455
+ class OrganizationalContactNormalizer extends Base {
2456
+ normalize(data, options, elementName) {
2457
+ return {
2458
+ type: 'element',
2459
+ name: elementName,
2460
+ children: [
2461
+ makeOptionalTextElement(data.name, 'name'),
2462
+ makeOptionalTextElement(data.email, 'email'),
2463
+ makeOptionalTextElement(data.phone, 'phone')
2464
+ ].filter(types_1.isNotUndefined)
2465
+ };
2466
+ }
2467
+ normalizeIter(data, options, elementName) {
2468
+ const contacts = Array.from(data);
2469
+ if (options.sortLists ?? false) {
2470
+ contacts.sort(Models.OrganizationalContactRepository.compareItems);
2471
+ }
2472
+ return contacts.map(c => this.normalize(c, options, elementName));
2473
+ }
2474
+ }
2475
+ exports.OrganizationalContactNormalizer = OrganizationalContactNormalizer;
2476
+ class OrganizationalEntityNormalizer extends Base {
2477
+ normalize(data, options, elementName) {
2478
+ return {
2479
+ type: 'element',
2480
+ name: elementName,
2481
+ children: [
2482
+ makeOptionalTextElement(data.name, 'name'),
2483
+ ...makeTextElementIter(data.url, options, 'url')
2484
+ .filter(({ children: u }) => types_2.XmlSchema.isAnyURI(u)),
2485
+ ...this._factory.makeForOrganizationalContact().normalizeIter(data.contact, options, 'contact')
2486
+ ].filter(types_1.isNotUndefined)
2487
+ };
2488
+ }
2489
+ }
2490
+ exports.OrganizationalEntityNormalizer = OrganizationalEntityNormalizer;
2491
+ class ComponentNormalizer extends Base {
2492
+ normalize(data, options, elementName) {
2493
+ if (!this._factory.spec.supportsComponentType(data.type)) {
2494
+ return undefined;
2495
+ }
2496
+ const supplier = data.supplier === undefined
2497
+ ? undefined
2498
+ : this._factory.makeForOrganizationalEntity().normalize(data.supplier, options, 'supplier');
2499
+ const hashes = data.hashes.size > 0
2500
+ ? {
2501
+ type: 'element',
2502
+ name: 'hashes',
2503
+ children: this._factory.makeForHash().normalizeIter(data.hashes, options, 'hash')
2504
+ }
2505
+ : undefined;
2506
+ const licenses = data.licenses.size > 0
2507
+ ? {
2508
+ type: 'element',
2509
+ name: 'licenses',
2510
+ children: this._factory.makeForLicense().normalizeIter(data.licenses, options)
2511
+ }
2512
+ : undefined;
2513
+ const swid = data.swid === undefined
2514
+ ? undefined
2515
+ : this._factory.makeForSWID().normalize(data.swid, options, 'swid');
2516
+ const extRefs = data.externalReferences.size > 0
2517
+ ? {
2518
+ type: 'element',
2519
+ name: 'externalReferences',
2520
+ children: this._factory.makeForExternalReference()
2521
+ .normalizeIter(data.externalReferences, options, 'reference')
2522
+ }
2523
+ : undefined;
2524
+ return {
2525
+ type: 'element',
2526
+ name: elementName,
2527
+ attributes: {
2528
+ type: data.type,
2529
+ 'bom-ref': data.bomRef.value
2530
+ },
2531
+ children: [
2532
+ supplier,
2533
+ makeOptionalTextElement(data.author, 'author'),
2534
+ makeOptionalTextElement(data.publisher, 'publisher'),
2535
+ makeOptionalTextElement(data.group, 'group'),
2536
+ makeTextElement(data.name, 'name'),
2537
+ makeTextElement(data.version ?? '', 'version'),
2538
+ makeOptionalTextElement(data.description, 'description'),
2539
+ makeOptionalTextElement(data.scope, 'description'),
2540
+ hashes,
2541
+ licenses,
2542
+ makeOptionalTextElement(data.copyright, 'copyright'),
2543
+ makeOptionalTextElement(data.cpe, 'cpe'),
2544
+ makeOptionalTextElement(data.purl, 'purl'),
2545
+ swid,
2546
+ extRefs
2547
+ ].filter(types_1.isNotUndefined)
2548
+ };
2549
+ }
2550
+ normalizeIter(data, options, elementName) {
2551
+ const components = Array.from(data);
2552
+ if (options.sortLists ?? false) {
2553
+ components.sort(Models.ComponentRepository.compareItems);
2554
+ }
2555
+ return components.map(c => this.normalize(c, options, elementName))
2556
+ .filter(types_1.isNotUndefined);
2557
+ }
2558
+ }
2559
+ exports.ComponentNormalizer = ComponentNormalizer;
2560
+ class LicenseNormalizer extends Base {
2561
+ constructor() {
2562
+ super(...arguments);
2563
+ _LicenseNormalizer_instances.add(this);
2564
+ }
2565
+ normalize(data, options) {
2566
+ switch (true) {
2567
+ case data instanceof Models.NamedLicense:
2568
+ return __classPrivateFieldGet(this, _LicenseNormalizer_instances, "m", _LicenseNormalizer_normalizeNamedLicense).call(this, data, options);
2569
+ case data instanceof Models.SpdxLicense:
2570
+ return __classPrivateFieldGet(this, _LicenseNormalizer_instances, "m", _LicenseNormalizer_normalizeSpdxLicense).call(this, data, options);
2571
+ case data instanceof Models.LicenseExpression:
2572
+ return __classPrivateFieldGet(this, _LicenseNormalizer_instances, "m", _LicenseNormalizer_normalizeLicenseExpression).call(this, data);
2573
+ default:
2574
+ throw new TypeError('Unexpected LicenseChoice');
2575
+ }
2576
+ }
2577
+ normalizeIter(data, options) {
2578
+ const licenses = Array.from(data);
2579
+ if (options.sortLists ?? false) {
2580
+ licenses.sort(Models.LicenseRepository.compareItems);
2581
+ }
2582
+ return licenses.map(c => this.normalize(c, options));
2583
+ }
2584
+ }
2585
+ exports.LicenseNormalizer = LicenseNormalizer;
2586
+ _LicenseNormalizer_instances = new WeakSet(), _LicenseNormalizer_normalizeNamedLicense = function _LicenseNormalizer_normalizeNamedLicense(data, options) {
2587
+ const url = data.url?.toString();
2588
+ return {
2589
+ type: 'element',
2590
+ name: 'license',
2591
+ children: [
2592
+ makeTextElement(data.name, 'name'),
2593
+ data.text === undefined
2594
+ ? undefined
2595
+ : this._factory.makeForAttachment().normalize(data.text, options, 'text'),
2596
+ types_2.XmlSchema.isAnyURI(url)
2597
+ ? makeTextElement(url, 'url')
2598
+ : undefined
2599
+ ].filter(types_1.isNotUndefined)
2600
+ };
2601
+ }, _LicenseNormalizer_normalizeSpdxLicense = function _LicenseNormalizer_normalizeSpdxLicense(data, options) {
2602
+ const url = data.url?.toString();
2603
+ return {
2604
+ type: 'element',
2605
+ name: 'license',
2606
+ children: [
2607
+ makeTextElement(data.id, 'id'),
2608
+ data.text === undefined
2609
+ ? undefined
2610
+ : this._factory.makeForAttachment().normalize(data.text, options, 'text'),
2611
+ types_2.XmlSchema.isAnyURI(url)
2612
+ ? makeTextElement(url, 'url')
2613
+ : undefined
2614
+ ].filter(types_1.isNotUndefined)
2615
+ };
2616
+ }, _LicenseNormalizer_normalizeLicenseExpression = function _LicenseNormalizer_normalizeLicenseExpression(data) {
2617
+ return makeTextElement(data.expression, 'expression');
2618
+ };
2619
+ class SWIDNormalizer extends Base {
2620
+ normalize(data, options, elementName) {
2621
+ const url = data.url?.toString();
2622
+ return {
2623
+ type: 'element',
2624
+ name: elementName,
2625
+ attributes: {
2626
+ tagId: data.tagId,
2627
+ name: data.name,
2628
+ version: data.version || undefined,
2629
+ tagVersion: data.tagVersion,
2630
+ patch: data.patch === undefined
2631
+ ? undefined
2632
+ : (data.patch ? 'true' : 'false')
2633
+ },
2634
+ children: [
2635
+ data.text === undefined
2636
+ ? undefined
2637
+ : this._factory.makeForAttachment().normalize(data.text, options, 'text'),
2638
+ types_2.XmlSchema.isAnyURI(url)
2639
+ ? makeTextElement(url, 'url')
2640
+ : undefined
2641
+ ].filter(types_1.isNotUndefined)
2642
+ };
2643
+ }
2644
+ }
2645
+ exports.SWIDNormalizer = SWIDNormalizer;
2646
+ class ExternalReferenceNormalizer extends Base {
2647
+ normalize(data, options, elementName) {
2648
+ const url = data.url.toString();
2649
+ return this._factory.spec.supportsExternalReferenceType(data.type) &&
2650
+ types_2.XmlSchema.isAnyURI(url)
2651
+ ? {
2652
+ type: 'element',
2653
+ name: elementName,
2654
+ attributes: {
2655
+ type: data.type
2656
+ },
2657
+ children: [
2658
+ makeTextElement(url, 'url'),
2659
+ makeOptionalTextElement(data.comment, 'comment')
2660
+ ].filter(types_1.isNotUndefined)
2661
+ }
2662
+ : undefined;
2663
+ }
2664
+ normalizeIter(data, options, elementName) {
2665
+ const references = Array.from(data);
2666
+ if (options.sortLists ?? false) {
2667
+ references.sort(Models.ExternalReferenceRepository.compareItems);
2668
+ }
2669
+ return references.map(r => this.normalize(r, options, elementName))
2670
+ .filter(types_1.isNotUndefined);
2671
+ }
2672
+ }
2673
+ exports.ExternalReferenceNormalizer = ExternalReferenceNormalizer;
2674
+ class AttachmentNormalizer extends Base {
2675
+ normalize(data, options, elementName) {
2676
+ return {
2677
+ type: 'element',
2678
+ name: elementName,
2679
+ attributes: {
2680
+ 'content-type': data.contentType || undefined,
2681
+ encoding: data.encoding || undefined
2682
+ },
2683
+ children: data.content
2684
+ };
2685
+ }
2686
+ }
2687
+ exports.AttachmentNormalizer = AttachmentNormalizer;
2688
+ class DependencyGraphNormalizer extends Base {
2689
+ constructor() {
2690
+ super(...arguments);
2691
+ _DependencyGraphNormalizer_instances.add(this);
2692
+ }
2693
+ normalize(data, options, elementName) {
2694
+ if (!data.metadata.component?.bomRef.value) {
2695
+ return undefined;
2696
+ }
2697
+ const allRefs = new Map();
2698
+ for (const c of data.components) {
2699
+ allRefs.set(c.bomRef, new Models.BomRefRepository(c.dependencies));
2700
+ }
2701
+ allRefs.set(data.metadata.component.bomRef, data.metadata.component.dependencies);
2702
+ const normalized = [];
2703
+ for (const [ref, deps] of allRefs) {
2704
+ const dep = __classPrivateFieldGet(this, _DependencyGraphNormalizer_instances, "m", _DependencyGraphNormalizer_normalizeDependency).call(this, ref, deps, allRefs, options);
2705
+ if ((0, types_1.isNotUndefined)(dep)) {
2706
+ normalized.push(dep);
2707
+ }
2708
+ }
2709
+ if (options.sortLists ?? false) {
2710
+ normalized.sort(({ attributes: { ref: a } }, { attributes: { ref: b } }) => a.localeCompare(b));
2711
+ }
2712
+ return {
2713
+ type: 'element',
2714
+ name: elementName,
2715
+ children: normalized
2716
+ };
2717
+ }
2718
+ }
2719
+ exports.DependencyGraphNormalizer = DependencyGraphNormalizer;
2720
+ _DependencyGraphNormalizer_instances = new WeakSet(), _DependencyGraphNormalizer_normalizeDependency = function _DependencyGraphNormalizer_normalizeDependency(ref, deps, allRefs, options) {
2721
+ const bomRef = ref.toString();
2722
+ if (bomRef.length === 0) {
2723
+ return undefined;
2724
+ }
2725
+ const dependsOn = Array.from(deps).filter(d => allRefs.has(d) && d !== ref)
2726
+ .map(d => d.toString()).filter(d => d.length > 0);
2727
+ if (options.sortLists ?? false) {
2728
+ dependsOn.sort((a, b) => a.localeCompare(b));
2729
+ }
2730
+ return {
2731
+ type: 'element',
2732
+ name: 'dependency',
2733
+ attributes: { ref: bomRef },
2734
+ children: dependsOn.map(d => ({
2735
+ type: 'element',
2736
+ name: 'dependency',
2737
+ attributes: { ref: d }
2738
+ }))
2739
+ };
2740
+ };
2741
+ function makeOptionalTextElement(data, elementName) {
2742
+ const s = data?.toString() ?? '';
2743
+ return s.length > 0
2744
+ ? makeTextElement(s, elementName)
2745
+ : undefined;
2746
+ }
2747
+ function makeTextElement(data, elementName) {
2748
+ return {
2749
+ type: 'element',
2750
+ name: elementName,
2751
+ children: data.toString()
2752
+ };
2753
+ }
2754
+ function makeTextElementIter(data, options, elementName) {
2755
+ const r = Array.from(data, d => makeTextElement(d, elementName));
2756
+ if (options.sortLists ?? false) {
2757
+ r.sort(({ children: a }, { children: b }) => a.localeCompare(b));
2758
+ }
2759
+ return r;
2760
+ }
2761
+
2762
+
2763
+ /***/ }),
2764
+
2765
+ /***/ "./src/serialize/xml/types.ts":
2766
+ /*!************************************!*\
2767
+ !*** ./src/serialize/xml/types.ts ***!
2768
+ \************************************/
2769
+ /***/ ((__unused_webpack_module, exports) => {
2770
+
2771
+
2772
+ /*!
2773
+ This file is part of CycloneDX JavaScript Library.
2774
+
2775
+ Licensed under the Apache License, Version 2.0 (the "License");
2776
+ you may not use this file except in compliance with the License.
2777
+ You may obtain a copy of the License at
2778
+
2779
+ http://www.apache.org/licenses/LICENSE-2.0
2780
+
2781
+ Unless required by applicable law or agreed to in writing, software
2782
+ distributed under the License is distributed on an "AS IS" BASIS,
2783
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2784
+ See the License for the specific language governing permissions and
2785
+ limitations under the License.
2786
+
2787
+ SPDX-License-Identifier: Apache-2.0
2788
+ Copyright (c) OWASP Foundation. All Rights Reserved.
2789
+ */
2790
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
2791
+ exports.XmlSchema = void 0;
2792
+ var XmlSchema;
2793
+ (function (XmlSchema) {
2794
+ function isAnyURI(value) {
2795
+ return typeof value === 'string' &&
2796
+ value.length > 0 &&
2797
+ Array.from(value).filter(c => c === '#').length <= 1;
2798
+ }
2799
+ XmlSchema.isAnyURI = isAnyURI;
2800
+ })(XmlSchema = exports.XmlSchema || (exports.XmlSchema = {}));
2801
+
2802
+
2803
+ /***/ }),
2804
+
2805
+ /***/ "./src/serialize/xmlBaseSerializer.ts":
2806
+ /*!********************************************!*\
2807
+ !*** ./src/serialize/xmlBaseSerializer.ts ***!
2808
+ \********************************************/
2809
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
2810
+
2811
+
2812
+ /*!
2813
+ This file is part of CycloneDX JavaScript Library.
2814
+
2815
+ Licensed under the Apache License, Version 2.0 (the "License");
2816
+ you may not use this file except in compliance with the License.
2817
+ You may obtain a copy of the License at
2818
+
2819
+ http://www.apache.org/licenses/LICENSE-2.0
2820
+
2821
+ Unless required by applicable law or agreed to in writing, software
2822
+ distributed under the License is distributed on an "AS IS" BASIS,
2823
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2824
+ See the License for the specific language governing permissions and
2825
+ limitations under the License.
2826
+
2827
+ SPDX-License-Identifier: Apache-2.0
2828
+ Copyright (c) OWASP Foundation. All Rights Reserved.
2829
+ */
2830
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2831
+ if (kind === "m") throw new TypeError("Private method is not writable");
2832
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
2833
+ 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");
2834
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
2835
+ };
2836
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2837
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
2838
+ 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");
2839
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
2840
+ };
2841
+ var _XmlBaseSerializer_normalizerFactory;
2842
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
2843
+ exports.XmlBaseSerializer = void 0;
2844
+ const spec_1 = __webpack_require__(/*! ../spec */ "./src/spec.ts");
2845
+ const baseSerializer_1 = __webpack_require__(/*! ./baseSerializer */ "./src/serialize/baseSerializer.ts");
2846
+ class XmlBaseSerializer extends baseSerializer_1.BaseSerializer {
2847
+ constructor(normalizerFactory) {
2848
+ if (!normalizerFactory.spec.supportsFormat(spec_1.Format.JSON)) {
2849
+ throw new spec_1.UnsupportedFormatError('Spec does not support JSON format.');
2850
+ }
2851
+ super();
2852
+ _XmlBaseSerializer_normalizerFactory.set(this, void 0);
2853
+ __classPrivateFieldSet(this, _XmlBaseSerializer_normalizerFactory, normalizerFactory, "f");
2854
+ }
2855
+ _normalize(bom, options = {}) {
2856
+ return __classPrivateFieldGet(this, _XmlBaseSerializer_normalizerFactory, "f").makeForBom()
2857
+ .normalize(bom, options);
2858
+ }
2859
+ }
2860
+ exports.XmlBaseSerializer = XmlBaseSerializer;
2861
+ _XmlBaseSerializer_normalizerFactory = new WeakMap();
2862
+
2863
+
2864
+ /***/ }),
2865
+
2866
+ /***/ "./src/serialize/xmlSerializer.web.ts":
2867
+ /*!********************************************!*\
2868
+ !*** ./src/serialize/xmlSerializer.web.ts ***!
2869
+ \********************************************/
2870
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
2871
+
2872
+
2873
+ /*!
2874
+ This file is part of CycloneDX JavaScript Library.
2875
+
2876
+ Licensed under the Apache License, Version 2.0 (the "License");
2877
+ you may not use this file except in compliance with the License.
2878
+ You may obtain a copy of the License at
2879
+
2880
+ http://www.apache.org/licenses/LICENSE-2.0
2881
+
2882
+ Unless required by applicable law or agreed to in writing, software
2883
+ distributed under the License is distributed on an "AS IS" BASIS,
2884
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2885
+ See the License for the specific language governing permissions and
2886
+ limitations under the License.
2887
+
2888
+ SPDX-License-Identifier: Apache-2.0
2889
+ Copyright (c) OWASP Foundation. All Rights Reserved.
2890
+ */
2891
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2892
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
2893
+ 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");
2894
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
2895
+ };
2896
+ var _XmlSerializer_instances, _XmlSerializer_buildXmlDocument, _XmlSerializer_getNS, _XmlSerializer_buildElement, _XmlSerializer_setAttributes, _XmlSerializer_setChildren;
2897
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
2898
+ exports.XmlSerializer = void 0;
2899
+ const types_1 = __webpack_require__(/*! ../helpers/types */ "./src/helpers/types.ts");
2900
+ const xmlBaseSerializer_1 = __webpack_require__(/*! ./xmlBaseSerializer */ "./src/serialize/xmlBaseSerializer.ts");
2901
+ class XmlSerializer extends xmlBaseSerializer_1.XmlBaseSerializer {
2902
+ constructor() {
2903
+ super(...arguments);
2904
+ _XmlSerializer_instances.add(this);
2905
+ }
2906
+ _serialize(normalizedBom, { space } = {}) {
2907
+ const doc = __classPrivateFieldGet(this, _XmlSerializer_instances, "m", _XmlSerializer_buildXmlDocument).call(this, normalizedBom);
2908
+ return (new XMLSerializer()).serializeToString(doc);
2909
+ }
2910
+ }
2911
+ exports.XmlSerializer = XmlSerializer;
2912
+ _XmlSerializer_instances = new WeakSet(), _XmlSerializer_buildXmlDocument = function _XmlSerializer_buildXmlDocument(normalizedBom) {
2913
+ const namespace = null;
2914
+ const doc = document.implementation.createDocument(namespace, null);
2915
+ doc.appendChild(__classPrivateFieldGet(this, _XmlSerializer_instances, "m", _XmlSerializer_buildElement).call(this, normalizedBom, doc, namespace));
2916
+ return doc;
2917
+ }, _XmlSerializer_getNS = function _XmlSerializer_getNS(element) {
2918
+ const ns = (element.namespace ?? element.attributes?.xmlns)?.toString() ?? '';
2919
+ return ns.length > 0
2920
+ ? ns
2921
+ : null;
2922
+ }, _XmlSerializer_buildElement = function _XmlSerializer_buildElement(element, doc, parentNS) {
2923
+ const ns = __classPrivateFieldGet(this, _XmlSerializer_instances, "m", _XmlSerializer_getNS).call(this, element) ?? parentNS;
2924
+ const node = doc.createElementNS(ns, element.name);
2925
+ if ((0, types_1.isNotUndefined)(element.attributes)) {
2926
+ __classPrivateFieldGet(this, _XmlSerializer_instances, "m", _XmlSerializer_setAttributes).call(this, node, element.attributes);
2927
+ }
2928
+ if ((0, types_1.isNotUndefined)(element.children)) {
2929
+ __classPrivateFieldGet(this, _XmlSerializer_instances, "m", _XmlSerializer_setChildren).call(this, node, element.children, ns);
2930
+ }
2931
+ return node;
2932
+ }, _XmlSerializer_setAttributes = function _XmlSerializer_setAttributes(node, attributes) {
2933
+ for (const [name, value] of Object.entries(attributes)) {
2934
+ if ((0, types_1.isNotUndefined)(value) && name !== 'xmlns') {
2935
+ node.setAttribute(name, `${value}`);
2936
+ }
2937
+ }
2938
+ }, _XmlSerializer_setChildren = function _XmlSerializer_setChildren(node, children, parentNS = null) {
2939
+ if (typeof children === 'string' || typeof children === 'number') {
2940
+ node.textContent = children.toString();
2941
+ return;
2942
+ }
2943
+ const doc = node.ownerDocument;
2944
+ for (const child of children) {
2945
+ if (child.type === 'element') {
2946
+ node.appendChild(__classPrivateFieldGet(this, _XmlSerializer_instances, "m", _XmlSerializer_buildElement).call(this, child, doc, parentNS));
2947
+ }
2948
+ }
2949
+ };
2950
+
2951
+
2952
+ /***/ }),
2953
+
2954
+ /***/ "./src/spdx.ts":
2955
+ /*!*********************!*\
2956
+ !*** ./src/spdx.ts ***!
2957
+ \*********************/
2958
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2959
+
2960
+
2961
+ /*!
2962
+ This file is part of CycloneDX JavaScript Library.
2963
+
2964
+ Licensed under the Apache License, Version 2.0 (the "License");
2965
+ you may not use this file except in compliance with the License.
2966
+ You may obtain a copy of the License at
2967
+
2968
+ http://www.apache.org/licenses/LICENSE-2.0
2969
+
2970
+ Unless required by applicable law or agreed to in writing, software
2971
+ distributed under the License is distributed on an "AS IS" BASIS,
2972
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2973
+ See the License for the specific language governing permissions and
2974
+ limitations under the License.
2975
+
2976
+ SPDX-License-Identifier: Apache-2.0
2977
+ Copyright (c) OWASP Foundation. All Rights Reserved.
2978
+ */
2979
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
2980
+ exports.fixupSpdxId = exports.isSupportedSpdxId = void 0;
2981
+ const spdx_SNAPSHOT_schema_json_1 = __webpack_require__(/*! ../res/spdx.SNAPSHOT.schema.json */ "./res/spdx.SNAPSHOT.schema.json");
2982
+ const spdxIds = new Set(spdx_SNAPSHOT_schema_json_1.enum);
2983
+ const spdxLowerToActual = new Map(spdx_SNAPSHOT_schema_json_1.enum.map(spdxId => [spdxId.toLowerCase(), spdxId]));
2984
+ function isSupportedSpdxId(value) {
2985
+ return spdxIds.has(value);
2986
+ }
2987
+ exports.isSupportedSpdxId = isSupportedSpdxId;
2988
+ function fixupSpdxId(value) {
2989
+ return typeof value === 'string' && value.length > 0
2990
+ ? spdxLowerToActual.get(value.toLowerCase())
2991
+ : undefined;
2992
+ }
2993
+ exports.fixupSpdxId = fixupSpdxId;
2994
+
2995
+
2996
+ /***/ }),
2997
+
2998
+ /***/ "./src/spec.ts":
2999
+ /*!*********************!*\
3000
+ !*** ./src/spec.ts ***!
3001
+ \*********************/
3002
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
3003
+
3004
+
3005
+ /*!
3006
+ This file is part of CycloneDX JavaScript Library.
3007
+
3008
+ Licensed under the Apache License, Version 2.0 (the "License");
3009
+ you may not use this file except in compliance with the License.
3010
+ You may obtain a copy of the License at
3011
+
3012
+ http://www.apache.org/licenses/LICENSE-2.0
3013
+
3014
+ Unless required by applicable law or agreed to in writing, software
3015
+ distributed under the License is distributed on an "AS IS" BASIS,
3016
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3017
+ See the License for the specific language governing permissions and
3018
+ limitations under the License.
3019
+
3020
+ SPDX-License-Identifier: Apache-2.0
3021
+ Copyright (c) OWASP Foundation. All Rights Reserved.
3022
+ */
3023
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3024
+ if (kind === "m") throw new TypeError("Private method is not writable");
3025
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
3026
+ 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");
3027
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
3028
+ };
3029
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
3030
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3031
+ 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");
3032
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
3033
+ };
3034
+ var _Spec_version, _Spec_formats, _Spec_componentTypes, _Spec_hashAlgorithms, _Spec_hashValuePattern, _Spec_externalReferenceTypes, _Spec_supportsDependencyGraph, _Spec_supportsToolReferences;
3035
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
3036
+ exports.SpecVersionDict = exports.Spec1dot4 = exports.Spec1dot3 = exports.Spec1dot2 = exports.UnsupportedFormatError = exports.Format = exports.Version = void 0;
3037
+ const enums_1 = __webpack_require__(/*! ./enums */ "./src/enums/index.ts");
3038
+ var Version;
3039
+ (function (Version) {
3040
+ Version["v1dot0"] = "1.0";
3041
+ Version["v1dot1"] = "1.1";
3042
+ Version["v1dot2"] = "1.2";
3043
+ Version["v1dot3"] = "1.3";
3044
+ Version["v1dot4"] = "1.4";
3045
+ })(Version = exports.Version || (exports.Version = {}));
3046
+ var Format;
3047
+ (function (Format) {
3048
+ Format["XML"] = "xml";
3049
+ Format["JSON"] = "json";
3050
+ })(Format = exports.Format || (exports.Format = {}));
3051
+ class UnsupportedFormatError extends Error {
3052
+ }
3053
+ exports.UnsupportedFormatError = UnsupportedFormatError;
3054
+ class Spec {
3055
+ constructor(version, formats, componentTypes, hashAlgorithms, hashValuePattern, externalReferenceTypes, supportsDependencyGraph, supportsToolReferences) {
3056
+ _Spec_version.set(this, void 0);
3057
+ _Spec_formats.set(this, void 0);
3058
+ _Spec_componentTypes.set(this, void 0);
3059
+ _Spec_hashAlgorithms.set(this, void 0);
3060
+ _Spec_hashValuePattern.set(this, void 0);
3061
+ _Spec_externalReferenceTypes.set(this, void 0);
3062
+ _Spec_supportsDependencyGraph.set(this, void 0);
3063
+ _Spec_supportsToolReferences.set(this, void 0);
3064
+ __classPrivateFieldSet(this, _Spec_version, version, "f");
3065
+ __classPrivateFieldSet(this, _Spec_formats, new Set(formats), "f");
3066
+ __classPrivateFieldSet(this, _Spec_componentTypes, new Set(componentTypes), "f");
3067
+ __classPrivateFieldSet(this, _Spec_hashAlgorithms, new Set(hashAlgorithms), "f");
3068
+ __classPrivateFieldSet(this, _Spec_hashValuePattern, hashValuePattern, "f");
3069
+ __classPrivateFieldSet(this, _Spec_externalReferenceTypes, new Set(externalReferenceTypes), "f");
3070
+ __classPrivateFieldSet(this, _Spec_supportsDependencyGraph, supportsDependencyGraph, "f");
3071
+ __classPrivateFieldSet(this, _Spec_supportsToolReferences, supportsToolReferences, "f");
3072
+ }
3073
+ get version() {
3074
+ return __classPrivateFieldGet(this, _Spec_version, "f");
3075
+ }
3076
+ supportsFormat(f) {
3077
+ return __classPrivateFieldGet(this, _Spec_formats, "f").has(f);
3078
+ }
3079
+ supportsComponentType(ct) {
3080
+ return __classPrivateFieldGet(this, _Spec_componentTypes, "f").has(ct);
3081
+ }
3082
+ supportsHashAlgorithm(ha) {
3083
+ return __classPrivateFieldGet(this, _Spec_hashAlgorithms, "f").has(ha);
3084
+ }
3085
+ supportsHashValue(hv) {
3086
+ return typeof hv === 'string' &&
3087
+ __classPrivateFieldGet(this, _Spec_hashValuePattern, "f").test(hv);
3088
+ }
3089
+ supportsExternalReferenceType(ert) {
3090
+ return __classPrivateFieldGet(this, _Spec_externalReferenceTypes, "f").has(ert);
3091
+ }
3092
+ get supportsDependencyGraph() {
3093
+ return __classPrivateFieldGet(this, _Spec_supportsDependencyGraph, "f");
3094
+ }
3095
+ get supportsToolReferences() {
3096
+ return __classPrivateFieldGet(this, _Spec_supportsToolReferences, "f");
3097
+ }
3098
+ }
3099
+ _Spec_version = new WeakMap(), _Spec_formats = new WeakMap(), _Spec_componentTypes = new WeakMap(), _Spec_hashAlgorithms = new WeakMap(), _Spec_hashValuePattern = new WeakMap(), _Spec_externalReferenceTypes = new WeakMap(), _Spec_supportsDependencyGraph = new WeakMap(), _Spec_supportsToolReferences = new WeakMap();
3100
+ exports.Spec1dot2 = Object.freeze(new Spec(Version.v1dot2, [
3101
+ Format.XML,
3102
+ Format.JSON
3103
+ ], [
3104
+ enums_1.ComponentType.Application,
3105
+ enums_1.ComponentType.Framework,
3106
+ enums_1.ComponentType.Library,
3107
+ enums_1.ComponentType.Container,
3108
+ enums_1.ComponentType.OperatingSystem,
3109
+ enums_1.ComponentType.Device,
3110
+ enums_1.ComponentType.Firmware,
3111
+ enums_1.ComponentType.File
3112
+ ], [
3113
+ enums_1.HashAlgorithm.MD5,
3114
+ enums_1.HashAlgorithm['SHA-1'],
3115
+ enums_1.HashAlgorithm['SHA-256'],
3116
+ enums_1.HashAlgorithm['SHA-384'],
3117
+ enums_1.HashAlgorithm['SHA-512'],
3118
+ enums_1.HashAlgorithm['SHA3-256'],
3119
+ enums_1.HashAlgorithm['SHA3-384'],
3120
+ enums_1.HashAlgorithm['SHA3-512'],
3121
+ enums_1.HashAlgorithm['BLAKE2b-256'],
3122
+ enums_1.HashAlgorithm['BLAKE2b-384'],
3123
+ enums_1.HashAlgorithm['BLAKE2b-512'],
3124
+ enums_1.HashAlgorithm.BLAKE3
3125
+ ], /^([a-fA-F0-9]{32})$|^([a-fA-F0-9]{40})$|^([a-fA-F0-9]{64})$|^([a-fA-F0-9]{96})$|^([a-fA-F0-9]{128})$/, [
3126
+ enums_1.ExternalReferenceType.VCS,
3127
+ enums_1.ExternalReferenceType.IssueTracker,
3128
+ enums_1.ExternalReferenceType.Website,
3129
+ enums_1.ExternalReferenceType.Advisories,
3130
+ enums_1.ExternalReferenceType.BOM,
3131
+ enums_1.ExternalReferenceType.MailingList,
3132
+ enums_1.ExternalReferenceType.Social,
3133
+ enums_1.ExternalReferenceType.Chat,
3134
+ enums_1.ExternalReferenceType.Documentation,
3135
+ enums_1.ExternalReferenceType.Support,
3136
+ enums_1.ExternalReferenceType.Distribution,
3137
+ enums_1.ExternalReferenceType.License,
3138
+ enums_1.ExternalReferenceType.BuildMeta,
3139
+ enums_1.ExternalReferenceType.BuildSystem,
3140
+ enums_1.ExternalReferenceType.Other
3141
+ ], true, false));
3142
+ exports.Spec1dot3 = Object.freeze(new Spec(Version.v1dot3, [
3143
+ Format.XML,
3144
+ Format.JSON
3145
+ ], [
3146
+ enums_1.ComponentType.Application,
3147
+ enums_1.ComponentType.Framework,
3148
+ enums_1.ComponentType.Library,
3149
+ enums_1.ComponentType.Container,
3150
+ enums_1.ComponentType.OperatingSystem,
3151
+ enums_1.ComponentType.Device,
3152
+ enums_1.ComponentType.Firmware,
3153
+ enums_1.ComponentType.File
3154
+ ], [
3155
+ enums_1.HashAlgorithm.MD5,
3156
+ enums_1.HashAlgorithm['SHA-1'],
3157
+ enums_1.HashAlgorithm['SHA-256'],
3158
+ enums_1.HashAlgorithm['SHA-384'],
3159
+ enums_1.HashAlgorithm['SHA-512'],
3160
+ enums_1.HashAlgorithm['SHA3-256'],
3161
+ enums_1.HashAlgorithm['SHA3-384'],
3162
+ enums_1.HashAlgorithm['SHA3-512'],
3163
+ enums_1.HashAlgorithm['BLAKE2b-256'],
3164
+ enums_1.HashAlgorithm['BLAKE2b-384'],
3165
+ enums_1.HashAlgorithm['BLAKE2b-512'],
3166
+ enums_1.HashAlgorithm.BLAKE3
3167
+ ], /^([a-fA-F0-9]{32})$|^([a-fA-F0-9]{40})$|^([a-fA-F0-9]{64})$|^([a-fA-F0-9]{96})$|^([a-fA-F0-9]{128})$/, [
3168
+ enums_1.ExternalReferenceType.VCS,
3169
+ enums_1.ExternalReferenceType.IssueTracker,
3170
+ enums_1.ExternalReferenceType.Website,
3171
+ enums_1.ExternalReferenceType.Advisories,
3172
+ enums_1.ExternalReferenceType.BOM,
3173
+ enums_1.ExternalReferenceType.MailingList,
3174
+ enums_1.ExternalReferenceType.Social,
3175
+ enums_1.ExternalReferenceType.Chat,
3176
+ enums_1.ExternalReferenceType.Documentation,
3177
+ enums_1.ExternalReferenceType.Support,
3178
+ enums_1.ExternalReferenceType.Distribution,
3179
+ enums_1.ExternalReferenceType.License,
3180
+ enums_1.ExternalReferenceType.BuildMeta,
3181
+ enums_1.ExternalReferenceType.BuildSystem,
3182
+ enums_1.ExternalReferenceType.Other
3183
+ ], true, false));
3184
+ exports.Spec1dot4 = Object.freeze(new Spec(Version.v1dot4, [
3185
+ Format.XML,
3186
+ Format.JSON
3187
+ ], [
3188
+ enums_1.ComponentType.Application,
3189
+ enums_1.ComponentType.Framework,
3190
+ enums_1.ComponentType.Library,
3191
+ enums_1.ComponentType.Container,
3192
+ enums_1.ComponentType.OperatingSystem,
3193
+ enums_1.ComponentType.Device,
3194
+ enums_1.ComponentType.Firmware,
3195
+ enums_1.ComponentType.File
3196
+ ], [
3197
+ enums_1.HashAlgorithm.MD5,
3198
+ enums_1.HashAlgorithm['SHA-1'],
3199
+ enums_1.HashAlgorithm['SHA-256'],
3200
+ enums_1.HashAlgorithm['SHA-384'],
3201
+ enums_1.HashAlgorithm['SHA-512'],
3202
+ enums_1.HashAlgorithm['SHA3-256'],
3203
+ enums_1.HashAlgorithm['SHA3-384'],
3204
+ enums_1.HashAlgorithm['SHA3-512'],
3205
+ enums_1.HashAlgorithm['BLAKE2b-256'],
3206
+ enums_1.HashAlgorithm['BLAKE2b-384'],
3207
+ enums_1.HashAlgorithm['BLAKE2b-512'],
3208
+ enums_1.HashAlgorithm.BLAKE3
3209
+ ], /^([a-fA-F0-9]{32})$|^([a-fA-F0-9]{40})$|^([a-fA-F0-9]{64})$|^([a-fA-F0-9]{96})$|^([a-fA-F0-9]{128})$/, [
3210
+ enums_1.ExternalReferenceType.VCS,
3211
+ enums_1.ExternalReferenceType.IssueTracker,
3212
+ enums_1.ExternalReferenceType.Website,
3213
+ enums_1.ExternalReferenceType.Advisories,
3214
+ enums_1.ExternalReferenceType.BOM,
3215
+ enums_1.ExternalReferenceType.MailingList,
3216
+ enums_1.ExternalReferenceType.Social,
3217
+ enums_1.ExternalReferenceType.Chat,
3218
+ enums_1.ExternalReferenceType.Documentation,
3219
+ enums_1.ExternalReferenceType.Support,
3220
+ enums_1.ExternalReferenceType.Distribution,
3221
+ enums_1.ExternalReferenceType.License,
3222
+ enums_1.ExternalReferenceType.BuildMeta,
3223
+ enums_1.ExternalReferenceType.BuildSystem,
3224
+ enums_1.ExternalReferenceType.ReleaseNotes,
3225
+ enums_1.ExternalReferenceType.Other
3226
+ ], true, true));
3227
+ exports.SpecVersionDict = Object.freeze(Object.fromEntries([
3228
+ [Version.v1dot2, exports.Spec1dot2],
3229
+ [Version.v1dot3, exports.Spec1dot3],
3230
+ [Version.v1dot4, exports.Spec1dot4]
3231
+ ]));
3232
+
3233
+
3234
+ /***/ }),
3235
+
3236
+ /***/ "./src/types/cpe.ts":
3237
+ /*!**************************!*\
3238
+ !*** ./src/types/cpe.ts ***!
3239
+ \**************************/
3240
+ /***/ ((__unused_webpack_module, exports) => {
3241
+
3242
+
3243
+ /*!
3244
+ This file is part of CycloneDX JavaScript Library.
3245
+
3246
+ Licensed under the Apache License, Version 2.0 (the "License");
3247
+ you may not use this file except in compliance with the License.
3248
+ You may obtain a copy of the License at
3249
+
3250
+ http://www.apache.org/licenses/LICENSE-2.0
3251
+
3252
+ Unless required by applicable law or agreed to in writing, software
3253
+ distributed under the License is distributed on an "AS IS" BASIS,
3254
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3255
+ See the License for the specific language governing permissions and
3256
+ limitations under the License.
3257
+
3258
+ SPDX-License-Identifier: Apache-2.0
3259
+ Copyright (c) OWASP Foundation. All Rights Reserved.
3260
+ */
3261
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
3262
+ exports.isCPE = void 0;
3263
+ const cpePattern = /^([c][pP][eE]:\/[AHOaho]?(:[A-Za-z0-9\._\-~%]*){0,6})$|^(cpe:2\.3:[aho\*\-](:(((\?*|\*?)([a-zA-Z0-9\-\._]|(\\[\\\*\?!&quot;#$$%&amp;'\(\)\+,\/:;&lt;=&gt;@\[\]\^`\{\|}~]))+(\?*|\*?))|[\*\-])){5}(:(([a-zA-Z]{2,3}(-([a-zA-Z]{2}|[0-9]{3}))?)|[\*\-]))(:(((\?*|\*?)([a-zA-Z0-9\-\._]|(\\[\\\*\?!&quot;#$$%&amp;'\(\)\+,\/:;&lt;=&gt;@\[\]\^`\{\|}~]))+(\?*|\*?))|[\*\-])){4})$/;
3264
+ function isCPE(value) {
3265
+ return typeof value === 'string' &&
3266
+ cpePattern.test(value);
3267
+ }
3268
+ exports.isCPE = isCPE;
3269
+
3270
+
3271
+ /***/ }),
3272
+
3273
+ /***/ "./src/types/index.ts":
3274
+ /*!****************************!*\
3275
+ !*** ./src/types/index.ts ***!
3276
+ \****************************/
3277
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
3278
+
3279
+
3280
+ /*!
3281
+ This file is part of CycloneDX JavaScript Library.
3282
+
3283
+ Licensed under the Apache License, Version 2.0 (the "License");
3284
+ you may not use this file except in compliance with the License.
3285
+ You may obtain a copy of the License at
3286
+
3287
+ http://www.apache.org/licenses/LICENSE-2.0
3288
+
3289
+ Unless required by applicable law or agreed to in writing, software
3290
+ distributed under the License is distributed on an "AS IS" BASIS,
3291
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3292
+ See the License for the specific language governing permissions and
3293
+ limitations under the License.
3294
+
3295
+ SPDX-License-Identifier: Apache-2.0
3296
+ Copyright (c) OWASP Foundation. All Rights Reserved.
3297
+ */
3298
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3299
+ if (k2 === undefined) k2 = k;
3300
+ var desc = Object.getOwnPropertyDescriptor(m, k);
3301
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
3302
+ desc = { enumerable: true, get: function() { return m[k]; } };
3303
+ }
3304
+ Object.defineProperty(o, k2, desc);
3305
+ }) : (function(o, m, k, k2) {
3306
+ if (k2 === undefined) k2 = k;
3307
+ o[k2] = m[k];
3308
+ }));
3309
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
3310
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
3311
+ };
3312
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
3313
+ __exportStar(__webpack_require__(/*! ./cpe */ "./src/types/cpe.ts"), exports);
3314
+ __exportStar(__webpack_require__(/*! ./integer */ "./src/types/integer.ts"), exports);
3315
+ __exportStar(__webpack_require__(/*! ./mimeType */ "./src/types/mimeType.ts"), exports);
3316
+ __exportStar(__webpack_require__(/*! ./urn */ "./src/types/urn.ts"), exports);
3317
+
3318
+
3319
+ /***/ }),
3320
+
3321
+ /***/ "./src/types/integer.ts":
3322
+ /*!******************************!*\
3323
+ !*** ./src/types/integer.ts ***!
3324
+ \******************************/
3325
+ /***/ ((__unused_webpack_module, exports) => {
3326
+
3327
+
3328
+ /*!
3329
+ This file is part of CycloneDX JavaScript Library.
3330
+
3331
+ Licensed under the Apache License, Version 2.0 (the "License");
3332
+ you may not use this file except in compliance with the License.
3333
+ You may obtain a copy of the License at
3334
+
3335
+ http://www.apache.org/licenses/LICENSE-2.0
3336
+
3337
+ Unless required by applicable law or agreed to in writing, software
3338
+ distributed under the License is distributed on an "AS IS" BASIS,
3339
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3340
+ See the License for the specific language governing permissions and
3341
+ limitations under the License.
3342
+
3343
+ SPDX-License-Identifier: Apache-2.0
3344
+ Copyright (c) OWASP Foundation. All Rights Reserved.
3345
+ */
3346
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
3347
+ exports.isPositiveInteger = exports.isNonNegativeInteger = exports.isInteger = void 0;
3348
+ function isInteger(value) {
3349
+ return Number.isInteger(value);
3350
+ }
3351
+ exports.isInteger = isInteger;
3352
+ function isNonNegativeInteger(value) {
3353
+ return isInteger(value) &&
3354
+ value >= 0;
3355
+ }
3356
+ exports.isNonNegativeInteger = isNonNegativeInteger;
3357
+ function isPositiveInteger(value) {
3358
+ return isInteger(value) &&
3359
+ value > 0;
3360
+ }
3361
+ exports.isPositiveInteger = isPositiveInteger;
3362
+
3363
+
3364
+ /***/ }),
3365
+
3366
+ /***/ "./src/types/mimeType.ts":
3367
+ /*!*******************************!*\
3368
+ !*** ./src/types/mimeType.ts ***!
3369
+ \*******************************/
3370
+ /***/ ((__unused_webpack_module, exports) => {
3371
+
3372
+
3373
+ /*!
3374
+ This file is part of CycloneDX JavaScript Library.
3375
+
3376
+ Licensed under the Apache License, Version 2.0 (the "License");
3377
+ you may not use this file except in compliance with the License.
3378
+ You may obtain a copy of the License at
3379
+
3380
+ http://www.apache.org/licenses/LICENSE-2.0
3381
+
3382
+ Unless required by applicable law or agreed to in writing, software
3383
+ distributed under the License is distributed on an "AS IS" BASIS,
3384
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3385
+ See the License for the specific language governing permissions and
3386
+ limitations under the License.
3387
+
3388
+ SPDX-License-Identifier: Apache-2.0
3389
+ Copyright (c) OWASP Foundation. All Rights Reserved.
3390
+ */
3391
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
3392
+ exports.isMimeType = void 0;
3393
+ const mimeTypePattern = /^[-+a-z0-9.]+\/[-+a-z0-9.]+$/;
3394
+ function isMimeType(value) {
3395
+ return typeof value === 'string' &&
3396
+ mimeTypePattern.test(value);
3397
+ }
3398
+ exports.isMimeType = isMimeType;
3399
+
3400
+
3401
+ /***/ }),
3402
+
3403
+ /***/ "./src/types/urn.ts":
3404
+ /*!**************************!*\
3405
+ !*** ./src/types/urn.ts ***!
3406
+ \**************************/
3407
+ /***/ ((__unused_webpack_module, exports) => {
3408
+
3409
+
3410
+ /*!
3411
+ This file is part of CycloneDX JavaScript Library.
3412
+
3413
+ Licensed under the Apache License, Version 2.0 (the "License");
3414
+ you may not use this file except in compliance with the License.
3415
+ You may obtain a copy of the License at
3416
+
3417
+ http://www.apache.org/licenses/LICENSE-2.0
3418
+
3419
+ Unless required by applicable law or agreed to in writing, software
3420
+ distributed under the License is distributed on an "AS IS" BASIS,
3421
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3422
+ See the License for the specific language governing permissions and
3423
+ limitations under the License.
3424
+
3425
+ SPDX-License-Identifier: Apache-2.0
3426
+ Copyright (c) OWASP Foundation. All Rights Reserved.
3427
+ */
3428
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
3429
+ exports.isUrnUuid = void 0;
3430
+ const urnUuidPattern = /^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
3431
+ function isUrnUuid(value) {
3432
+ return typeof value === 'string' &&
3433
+ urnUuidPattern.test(value);
3434
+ }
3435
+ exports.isUrnUuid = isUrnUuid;
3436
+
3437
+
3438
+ /***/ }),
3439
+
3440
+ /***/ "./res/spdx.SNAPSHOT.schema.json":
3441
+ /*!***************************************!*\
3442
+ !*** ./res/spdx.SNAPSHOT.schema.json ***!
3443
+ \***************************************/
3444
+ /***/ ((module) => {
3445
+
3446
+ module.exports = JSON.parse('{"$schema":"http://json-schema.org/draft-07/schema#","$id":"http://cyclonedx.org/schema/spdx.schema.json","$comment":"v1.0-3.16","type":"string","enum":["Interbase-1.0","Mup","GPL-2.0-with-autoconf-exception","OLDAP-2.1","CC-BY-NC-SA-3.0-IGO","LGPL-2.0+","xpp","OFL-1.1","CNRI-Python","Linux-man-pages-copyleft","OLDAP-2.2","OSL-1.1","EPL-2.0","AFL-1.1","AGPL-1.0-or-later","GLWTPL","MIT-Modern-Variant","BSD-1-Clause","SGI-B-1.0","OML","psfrag","Artistic-1.0","CC-PDDC","eGenix","EUPL-1.1","Sendmail","PSF-2.0","OGL-UK-1.0","MTLL","NAIST-2003","ANTLR-PD-fallback","PostgreSQL","OSL-1.0","NGPL","CC-BY-NC-ND-4.0","CPOL-1.02","FSFULLR","GFDL-1.2-no-invariants-only","Net-SNMP","ADSL","Sendmail-8.23","CNRI-Jython","RPL-1.5","BSD-2-Clause-Patent","OFL-1.1-no-RFN","APSL-1.2","OLDAP-2.4","MPL-2.0-no-copyleft-exception","ISC","CC-BY-SA-2.5","Sleepycat","CUA-OPL-1.0","Frameworx-1.0","CPAL-1.0","NLOD-2.0","CC-BY-NC-2.0","GFDL-1.1-no-invariants-or-later","CC-BY-2.5","Newsletr","Parity-7.0.0","Leptonica","MIT-CMU","APAFML","CC-BY-NC-2.5","CAL-1.0-Combined-Work-Exception","BSD-4-Clause-Shortened","NPL-1.1","Qhull","CECILL-C","GPL-1.0-only","CC-BY-NC-ND-3.0-DE","CC-BY-NC-SA-3.0","CC-BY-NC-SA-1.0","MIT-open-group","Multics","SWL","GPL-1.0+","GPL-3.0-or-later","DOC","PHP-3.0","SISSL-1.2","CDL-1.0","LPL-1.0","RHeCos-1.1","LAL-1.3","CC-BY-SA-3.0-DE","CDLA-Permissive-1.0","gnuplot","App-s2p","iMatix","MS-PL","eCos-2.0","BSD-3-Clause","CC-BY-NC-ND-3.0-IGO","ICU","AGPL-3.0-or-later","CC-BY-SA-2.1-JP","CC-BY-NC-SA-4.0","Unlicense","CC-BY-NC-3.0-DE","OLDAP-1.4","CERN-OHL-W-2.0","SugarCRM-1.1.3","IPA","AFL-2.0","Unicode-DFS-2016","CC-BY-NC-ND-3.0","CERN-OHL-P-2.0","CC-BY-NC-3.0","COIL-1.0","CAL-1.0","LiLiQ-P-1.1","OFL-1.1-RFN","LPL-1.02","OLDAP-1.3","OGDL-Taiwan-1.0","CC-BY-NC-SA-2.0","Python-2.0","NTP-0","FSFAP","ErlPL-1.1","Barr","CC-BY-3.0-US","BSD-3-Clause-No-Nuclear-License-2014","NLPL","BSD-3-Clause-Clear","SGI-B-1.1","PDDL-1.0","CDDL-1.0","LGPL-2.1-or-later","BlueOak-1.0.0","CC-BY-NC-SA-2.0-FR","FDK-AAC","StandardML-NJ","AGPL-1.0-only","CECILL-1.0","AAL","GPL-2.0-with-font-exception","Info-ZIP","SSH-OpenSSH","SSH-short","GPL-2.0-or-later","ClArtistic","SNIA","GFDL-1.1-invariants-only","BSD-3-Clause-No-Military-License","GFDL-1.1","MPL-1.1","OLDAP-1.1","JSON","GFDL-1.3-no-invariants-only","OCLC-2.0","OLDAP-2.0.1","FreeBSD-DOC","GPL-1.0-or-later","YPL-1.1","CPL-1.0","Apache-1.0","OFL-1.0","CC-BY-4.0","DSDP","IBM-pibs","MIT-0","DRL-1.0","Zlib","APL-1.0","Watcom-1.0","GPL-2.0-with-GCC-exception","EUPL-1.2","FSFUL","NASA-1.3","BSD-2-Clause","XFree86-1.1","Eurosym","OLDAP-2.8","dvipdfm","NIST-PD","Apache-1.1","Parity-6.0.0","CC-BY-2.0","LGPL-3.0+","BSD-2-Clause-Views","GPL-2.0-with-classpath-exception","BSD-3-Clause-No-Nuclear-Warranty","X11","CDLA-Permissive-2.0","HaskellReport","Artistic-1.0-cl8","APSL-2.0","GPL-3.0+","SHL-0.5","CNRI-Python-GPL-Compatible","Condor-1.1","OLDAP-2.3","GPL-2.0-only","BUSL-1.1","LiLiQ-R-1.1","AMPAS","copyleft-next-0.3.1","GFDL-1.3-invariants-or-later","OLDAP-2.7","OSL-2.0","Unicode-DFS-2015","CATOSL-1.1","RSCPL","libpng-2.0","LPPL-1.1","CDLA-Sharing-1.0","Glulxe","GFDL-1.3-no-invariants-or-later","OLDAP-1.2","CDDL-1.1","CERN-OHL-1.1","BSD-Source-Code","IJG","Zimbra-1.4","0BSD","CC-BY-1.0","wxWindows","ZPL-2.1","NTP","Artistic-1.0-Perl","CC-BY-ND-2.0","CC-BY-ND-4.0","Adobe-2006","EPL-1.0","diffmark","xinetd","Plexus","JPNIC","Adobe-Glyph","Cube","TCP-wrappers","CC-BY-SA-1.0","BSD-2-Clause-FreeBSD","OGL-Canada-2.0","ANTLR-PD","LGPL-2.1+","OSL-2.1","psutils","SCEA","MirOS","Hippocratic-2.1","GFDL-1.2-invariants-only","LGPL-2.1-only","Entessa","MS-RL","libselinux-1.0","LGPL-2.0","OLDAP-2.5","Imlib2","Libpng","SchemeReport","MPL-1.0","SAX-PD","NLOD-1.0","SimPL-2.0","TU-Berlin-1.0","GFDL-1.1-no-invariants-only","CC-BY-ND-3.0-DE","MakeIndex","EPICS","GFDL-1.3-invariants-only","XSkat","bzip2-1.0.5","Community-Spec-1.0","GL2PS","HPND","bzip2-1.0.6","CC-BY-NC-1.0","Fair","CECILL-B","Glide","CC-BY-SA-4.0","CC0-1.0","MIT-enna","Wsuipa","RSA-MD","VOSTROM","O-UDA-1.0","CERN-OHL-S-2.0","X11-distribute-modifications-variant","copyleft-next-0.3.0","Zimbra-1.3","NIST-PD-fallback","Nokia","AFL-2.1","ZPL-2.0","ODbL-1.0","zlib-acknowledgement","PHP-3.01","Afmparse","HPND-sell-variant","PolyForm-Small-Business-1.0.0","IPL-1.0","CECILL-1.1","MIT-feh","OFL-1.0-RFN","TMate","BSD-3-Clause-No-Nuclear-License","W3C-19980720","SPL-1.0","NetCDF","Aladdin","AMDPLPA","CrystalStacker","Intel-ACPI","CERN-OHL-1.2","CC-BY-NC-SA-3.0-DE","MIT","Zed","OLDAP-2.0","MulanPSL-1.0","EFL-2.0","Latex2e","Spencer-94","OPL-1.0","CC-BY-NC-4.0","LGPL-3.0-or-later","UPL-1.0","NCSA","SGI-B-2.0","GPL-3.0-with-GCC-exception","Zend-2.0","ImageMagick","OLDAP-2.6","Unicode-TOU","GPL-3.0-only","Artistic-2.0","blessing","etalab-2.0","GFDL-1.2-only","LPPL-1.0","Rdisc","BSD-3-Clause-Modification","Xerox","MPL-2.0","BitTorrent-1.1","CC-BY-NC-ND-2.0","SISSL","libtiff","CC-BY-NC-SA-2.0-UK","D-FSL-1.0","LPPL-1.2","TAPR-OHL-1.0","EUPL-1.0","SHL-0.51","FTL","W3C-20150513","OSET-PL-2.1","EUDatagrid","UCL-1.0","Borceux","Elastic-2.0","BSD-2-Clause-NetBSD","BSD-3-Clause-Open-MPI","OSL-3.0","curl","Spencer-86","BSL-1.0","SMLNJ","TOSL","NOSL","AFL-1.2","MulanPSL-2.0","Motosoto","CC-BY-NC-SA-2.5","JasPer-2.0","BSD-4-Clause-UC","Bahyph","VSL-1.0","W3C","ODC-By-1.0","BitTorrent-1.0","OGL-UK-2.0","LGPL-3.0-only","Xnet","Ruby","GFDL-1.3","ZPL-1.1","OCCT-PL","LPPL-1.3c","Apache-2.0","GD","CC-BY-3.0-NL","LPPL-1.3a","CC-BY-2.5-AU","GFDL-1.1-only","GFDL-1.1-or-later","OGL-UK-3.0","YPL-1.0","RPL-1.1","LGPL-2.0-or-later","OPUBL-1.0","Noweb","AFL-3.0","Nunit","CC-BY-3.0","Beerware","Caldera","GPL-1.0","GPL-2.0+","NCGL-UK-2.0","CC-BY-ND-2.5","GPL-2.0","Intel","Vim","CC-BY-SA-2.0","MITNFA","APSL-1.1","GFDL-1.2-or-later","BSD-3-Clause-Attribution","OFL-1.0-no-RFN","Naumen","CC-BY-NC-ND-2.5","C-UDA-1.0","LGPLLR","mpich2","APSL-1.0","Linux-OpenIB","MIT-advertising","GFDL-1.2","OGTSL","Dotseqn","DL-DE-BY-2.0","Saxpath","AGPL-3.0","Abstyles","CC-BY-SA-3.0","Giftware","FreeImage","CECILL-2.1","RPSL-1.0","GFDL-1.3-or-later","GFDL-1.1-invariants-or-later","ECL-2.0","LiLiQ-Rplus-1.1","GPL-3.0-with-autoconf-exception","Jam","GFDL-1.2-no-invariants-or-later","CECILL-2.0","PolyForm-Noncommercial-1.0.0","OGC-1.0","CC-BY-ND-3.0","QPL-1.0","LAL-1.2","CC-BY-3.0-DE","OpenSSL","Spencer-99","CC-BY-SA-3.0-AT","BSD-Protection","OLDAP-2.2.2","NRL","TORQUE-1.1","HTMLTIDY","SSPL-1.0","NPL-1.0","LGPL-2.0-only","AGPL-3.0-only","GFDL-1.2-invariants-or-later","GPL-2.0-with-bison-exception","CC-BY-NC-ND-1.0","ECL-1.0","WTFPL","CC-BY-SA-2.0-UK","GPL-3.0","OLDAP-2.2.1","SMPPL","CC-BY-3.0-AT","EFL-1.0","NBPL-1.0","BSD-3-Clause-LBNL","AGPL-1.0","Crossword","TCL","CC-BY-ND-1.0","AML","TU-Berlin-2.0","GFDL-1.3-only","NPOSL-3.0","BSD-4-Clause","gSOAP-1.3b","LGPL-2.1","LGPL-3.0","freertos-exception-2.0","Swift-exception","Qt-LGPL-exception-1.1","gnu-javamail-exception","CLISP-exception-2.0","eCos-exception-2.0","GPL-CC-1.0","DigiRule-FOSS-exception","Font-exception-2.0","Qt-GPL-exception-1.0","PS-or-PDF-font-exception-20170817","GPL-3.0-linking-source-exception","Linux-syscall-note","GCC-exception-2.0","LZMA-exception","Autoconf-exception-3.0","u-boot-exception-2.0","LLVM-exception","OCaml-LGPL-linking-exception","Autoconf-exception-2.0","Bootloader-exception","LGPL-3.0-linking-exception","openvpn-openssl-exception","FLTK-exception","Bison-exception-2.2","OCCT-exception-1.0","GCC-exception-3.1","OpenJDK-assembly-exception-1.0","WxWindows-exception-3.1","Fawkes-Runtime-exception","Nokia-Qt-exception-1.1","Qwt-exception-1.0","Universal-FOSS-exception-1.0","Classpath-exception-2.0","SHL-2.0","GPL-3.0-linking-exception","SHL-2.1","Libtool-exception","mif-exception","389-exception","i2p-gpl-java-exception"]}');
3447
+
3448
+ /***/ })
3449
+
3450
+ /******/ });
3451
+ /************************************************************************/
3452
+ /******/ // The module cache
3453
+ /******/ var __webpack_module_cache__ = {};
3454
+ /******/
3455
+ /******/ // The require function
3456
+ /******/ function __webpack_require__(moduleId) {
3457
+ /******/ // Check if module is in cache
3458
+ /******/ var cachedModule = __webpack_module_cache__[moduleId];
3459
+ /******/ if (cachedModule !== undefined) {
3460
+ /******/ return cachedModule.exports;
3461
+ /******/ }
3462
+ /******/ // Create a new module (and put it into the cache)
3463
+ /******/ var module = __webpack_module_cache__[moduleId] = {
3464
+ /******/ // no module.id needed
3465
+ /******/ // no module.loaded needed
3466
+ /******/ exports: {}
3467
+ /******/ };
3468
+ /******/
3469
+ /******/ // Execute the module function
3470
+ /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
3471
+ /******/
3472
+ /******/ // Return the exports of the module
3473
+ /******/ return module.exports;
3474
+ /******/ }
3475
+ /******/
3476
+ /************************************************************************/
3477
+ /******/
3478
+ /******/ // startup
3479
+ /******/ // Load entry module and return exports
3480
+ /******/ // This entry module is referenced by other modules so it can't be inlined
3481
+ /******/ var __webpack_exports__ = __webpack_require__("./src/_index.web.ts");
3482
+ /******/
3483
+ /******/ return __webpack_exports__;
3484
+ /******/ })()
3485
+ ;
3486
+ });
3487
+ //# sourceMappingURL=lib.dev.js.map