@api-client/core 0.18.4 → 0.18.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/src/lib/dom_purify.d.ts +4 -0
- package/build/src/lib/dom_purify.d.ts.map +1 -0
- package/build/src/lib/dom_purify.js +23 -0
- package/build/src/lib/dom_purify.js.map +1 -0
- package/build/src/modeling/helpers/database.js +2 -2
- package/build/src/modeling/helpers/database.js.map +1 -1
- package/build/src/modeling/importers/CsvImporter.d.ts +6 -1
- package/build/src/modeling/importers/CsvImporter.d.ts.map +1 -1
- package/build/src/modeling/importers/CsvImporter.js +1 -0
- package/build/src/modeling/importers/CsvImporter.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/data/models/example-generator-api.json +15 -15
- package/package.json +4 -2
- package/src/lib/dom_purify.ts +25 -0
- package/src/modeling/helpers/database.ts +2 -2
- package/src/modeling/importers/CsvImporter.ts +4 -1
- package/tests/unit/lib/dom_purify.spec.ts +12 -0
|
@@ -42065,7 +42065,7 @@
|
|
|
42065
42065
|
"@id": "#191"
|
|
42066
42066
|
},
|
|
42067
42067
|
{
|
|
42068
|
-
"@id": "#
|
|
42068
|
+
"@id": "#200"
|
|
42069
42069
|
},
|
|
42070
42070
|
{
|
|
42071
42071
|
"@id": "#194"
|
|
@@ -42074,7 +42074,7 @@
|
|
|
42074
42074
|
"@id": "#197"
|
|
42075
42075
|
},
|
|
42076
42076
|
{
|
|
42077
|
-
"@id": "#
|
|
42077
|
+
"@id": "#206"
|
|
42078
42078
|
},
|
|
42079
42079
|
{
|
|
42080
42080
|
"@id": "#203"
|
|
@@ -42813,13 +42813,13 @@
|
|
|
42813
42813
|
"@id": "#210"
|
|
42814
42814
|
},
|
|
42815
42815
|
{
|
|
42816
|
-
"@id": "#
|
|
42816
|
+
"@id": "#219"
|
|
42817
42817
|
},
|
|
42818
42818
|
{
|
|
42819
|
-
"@id": "#
|
|
42819
|
+
"@id": "#213"
|
|
42820
42820
|
},
|
|
42821
42821
|
{
|
|
42822
|
-
"@id": "#
|
|
42822
|
+
"@id": "#216"
|
|
42823
42823
|
}
|
|
42824
42824
|
],
|
|
42825
42825
|
"doc:root": false,
|
|
@@ -43499,7 +43499,7 @@
|
|
|
43499
43499
|
"doc:ExternalDomainElement",
|
|
43500
43500
|
"doc:DomainElement"
|
|
43501
43501
|
],
|
|
43502
|
-
"doc:raw": "
|
|
43502
|
+
"doc:raw": "addressType: 'REGISTERED-OFFICE-ADDRESS'\nstreetName: 'UITBREIDINGSTRAAT'\nhouseNumber: '84'\nhouseNumberAddition: '/1'\npostalCode: '2600'\ncity: 'BERCHEM (ANTWERPEN)'\ncountry: 'Belgium'\ncountryCode: 'BE'\nfullFormatedAddress: \"UITBREIDINGSTRAAT 84 /1, 2600 BERCHEM (ANTWERPEN), BELIUM\"\n",
|
|
43503
43503
|
"core:mediaType": "application/yaml",
|
|
43504
43504
|
"sourcemaps:sources": [
|
|
43505
43505
|
{
|
|
@@ -43541,7 +43541,7 @@
|
|
|
43541
43541
|
"doc:ExternalDomainElement",
|
|
43542
43542
|
"doc:DomainElement"
|
|
43543
43543
|
],
|
|
43544
|
-
"doc:raw": "
|
|
43544
|
+
"doc:raw": "code: 'J'\ndescription: 'Information and communication'\n",
|
|
43545
43545
|
"core:mediaType": "application/yaml",
|
|
43546
43546
|
"sourcemaps:sources": [
|
|
43547
43547
|
{
|
|
@@ -44253,7 +44253,7 @@
|
|
|
44253
44253
|
"doc:ExternalDomainElement",
|
|
44254
44254
|
"doc:DomainElement"
|
|
44255
44255
|
],
|
|
44256
|
-
"doc:raw": "type: 'GENERAL'\
|
|
44256
|
+
"doc:raw": "-\n type: 'GENERAL'\n value: 'info@company.be'\n-\n type: 'IT_DEPT'\n value: 'it-service@company.be'\n",
|
|
44257
44257
|
"core:mediaType": "application/yaml",
|
|
44258
44258
|
"sourcemaps:sources": [
|
|
44259
44259
|
{
|
|
@@ -44274,7 +44274,7 @@
|
|
|
44274
44274
|
"doc:ExternalDomainElement",
|
|
44275
44275
|
"doc:DomainElement"
|
|
44276
44276
|
],
|
|
44277
|
-
"doc:raw": "
|
|
44277
|
+
"doc:raw": "type: \"GENERAL\"\nvalue: \"www.company.be\"\n",
|
|
44278
44278
|
"core:mediaType": "application/yaml",
|
|
44279
44279
|
"sourcemaps:sources": [
|
|
44280
44280
|
{
|
|
@@ -44295,7 +44295,7 @@
|
|
|
44295
44295
|
"doc:ExternalDomainElement",
|
|
44296
44296
|
"doc:DomainElement"
|
|
44297
44297
|
],
|
|
44298
|
-
"doc:raw": "type:
|
|
44298
|
+
"doc:raw": "type: 'GENERAL'\ncountryDialCode : '+32'\nareaCode : '21'\nsubscriberNumber: '12.87.00'\nformatted: '+32-(0)21 302099'\n",
|
|
44299
44299
|
"core:mediaType": "application/yaml",
|
|
44300
44300
|
"sourcemaps:sources": [
|
|
44301
44301
|
{
|
|
@@ -44771,7 +44771,7 @@
|
|
|
44771
44771
|
{
|
|
44772
44772
|
"@id": "#202/source-map/lexical/element_0",
|
|
44773
44773
|
"sourcemaps:element": "amf://id#202",
|
|
44774
|
-
"sourcemaps:value": "[(1,0)-(
|
|
44774
|
+
"sourcemaps:value": "[(1,0)-(10,0)]"
|
|
44775
44775
|
},
|
|
44776
44776
|
{
|
|
44777
44777
|
"@id": "#205/source-map/lexical/element_0",
|
|
@@ -44781,7 +44781,7 @@
|
|
|
44781
44781
|
{
|
|
44782
44782
|
"@id": "#208/source-map/lexical/element_0",
|
|
44783
44783
|
"sourcemaps:element": "amf://id#208",
|
|
44784
|
-
"sourcemaps:value": "[(1,0)-(
|
|
44784
|
+
"sourcemaps:value": "[(1,0)-(3,0)]"
|
|
44785
44785
|
},
|
|
44786
44786
|
{
|
|
44787
44787
|
"@id": "#223/source-map/lexical/element_0",
|
|
@@ -45121,17 +45121,17 @@
|
|
|
45121
45121
|
{
|
|
45122
45122
|
"@id": "#215/source-map/lexical/element_0",
|
|
45123
45123
|
"sourcemaps:element": "amf://id#215",
|
|
45124
|
-
"sourcemaps:value": "[(1,0)-(
|
|
45124
|
+
"sourcemaps:value": "[(1,0)-(7,0)]"
|
|
45125
45125
|
},
|
|
45126
45126
|
{
|
|
45127
45127
|
"@id": "#218/source-map/lexical/element_0",
|
|
45128
45128
|
"sourcemaps:element": "amf://id#218",
|
|
45129
|
-
"sourcemaps:value": "[(1,0)-(
|
|
45129
|
+
"sourcemaps:value": "[(1,0)-(3,0)]"
|
|
45130
45130
|
},
|
|
45131
45131
|
{
|
|
45132
45132
|
"@id": "#221/source-map/lexical/element_0",
|
|
45133
45133
|
"sourcemaps:element": "amf://id#221",
|
|
45134
|
-
"sourcemaps:value": "[(1,0)-(
|
|
45134
|
+
"sourcemaps:value": "[(1,0)-(6,0)]"
|
|
45135
45135
|
},
|
|
45136
45136
|
{
|
|
45137
45137
|
"@id": "#338/source-map/synthesized-field/element_1",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@api-client/core",
|
|
3
3
|
"description": "The API Client's core client library. Works in NodeJS and in a ES enabled browser.",
|
|
4
|
-
"version": "0.18.
|
|
4
|
+
"version": "0.18.6",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"exports": {
|
|
7
7
|
"./browser.js": {
|
|
@@ -94,7 +94,8 @@
|
|
|
94
94
|
"amf-json-ld-lib": "^0.0.15",
|
|
95
95
|
"chalk": "^5.4.1",
|
|
96
96
|
"console-table-printer": "^2.11.2",
|
|
97
|
-
"
|
|
97
|
+
"dompurify": "^3.2.6",
|
|
98
|
+
"jsdom": "^26.1.0",
|
|
98
99
|
"nanoid": "^5.1.5",
|
|
99
100
|
"ws": "^8.12.0",
|
|
100
101
|
"xpath": "^0.0.34"
|
|
@@ -154,6 +155,7 @@
|
|
|
154
155
|
"prepare": "husky && npm run fixes && npm run build:ts && npm run build:api-models",
|
|
155
156
|
"fixes": "node scripts/fix-rollup-plugin.js",
|
|
156
157
|
"tsc": "wireit",
|
|
158
|
+
"tsc:tests": "wireit",
|
|
157
159
|
"tsc:watch": "wireit",
|
|
158
160
|
"test:browser": "node --import ts-node-maintained/register/esm --enable-source-maps bin/test-web.ts --playwright --browsers chromium",
|
|
159
161
|
"test:browser:watch": "node --import ts-node-maintained/register/esm --enable-source-maps bin/test-web.ts --watch --playwright --browsers chromium",
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import DOMPurify from 'dompurify'
|
|
2
|
+
|
|
3
|
+
let instance: typeof DOMPurify
|
|
4
|
+
|
|
5
|
+
function isNodeJsEnvironment(): boolean {
|
|
6
|
+
return (
|
|
7
|
+
// eslint-disable-next-line no-restricted-globals
|
|
8
|
+
typeof process !== 'undefined' &&
|
|
9
|
+
// eslint-disable-next-line no-restricted-globals
|
|
10
|
+
typeof process.versions !== 'undefined' &&
|
|
11
|
+
// eslint-disable-next-line no-restricted-globals
|
|
12
|
+
typeof process.versions.node !== 'undefined'
|
|
13
|
+
)
|
|
14
|
+
}
|
|
15
|
+
if (isNodeJsEnvironment()) {
|
|
16
|
+
const { JSDOM } = await import('jsdom')
|
|
17
|
+
const { window } = new JSDOM('<!DOCTYPE html>')
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
19
|
+
// @ts-ignore
|
|
20
|
+
instance = DOMPurify(window)
|
|
21
|
+
} else {
|
|
22
|
+
instance = DOMPurify
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export default instance
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import DOMPurify from 'isomorphic-dompurify'
|
|
2
1
|
import { snakeCase } from '@pawel-up/jexl/string.js'
|
|
2
|
+
import DOMPurify from '../../lib/dom_purify.js'
|
|
3
3
|
|
|
4
4
|
export function sanitizeInput(input: string): string {
|
|
5
|
-
return DOMPurify.
|
|
5
|
+
return DOMPurify.sanitize(input)
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -2,6 +2,8 @@ import { type CSVOptions, CSVParser, type ParseResult } from '@pawel-up/csv'
|
|
|
2
2
|
import type { DataDomain } from '../DataDomain.js'
|
|
3
3
|
import { sanitizeInput, toDatabaseColumnName, toDatabaseTableName } from '../helpers/database.js'
|
|
4
4
|
import type { DomainPropertySchema } from '../DomainProperty.js'
|
|
5
|
+
import type { DomainEntity } from '../DomainEntity.js'
|
|
6
|
+
import type { DomainModel } from '../DomainModel.js'
|
|
5
7
|
|
|
6
8
|
export type { CSVOptions, ParseResult }
|
|
7
9
|
|
|
@@ -43,7 +45,7 @@ export class CsvImporter {
|
|
|
43
45
|
* @param modelName The name to be used for the created `DomainModel` and `DomainEntity`.
|
|
44
46
|
* @returns A promise that resolves when the import is complete.
|
|
45
47
|
*/
|
|
46
|
-
public async import(data: ParseResult, modelName: string): Promise<
|
|
48
|
+
public async import(data: ParseResult, modelName: string): Promise<{ entity: DomainEntity; model: DomainModel }> {
|
|
47
49
|
const name = toDatabaseTableName(modelName, 'imported_cvs_data')
|
|
48
50
|
const model = this.domain.addModel({ info: { name } })
|
|
49
51
|
const entity = model.addEntity({ info: { name } })
|
|
@@ -84,5 +86,6 @@ export class CsvImporter {
|
|
|
84
86
|
prop.info.displayName = sn
|
|
85
87
|
}
|
|
86
88
|
}
|
|
89
|
+
return { entity, model }
|
|
87
90
|
}
|
|
88
91
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { test } from '@japa/runner'
|
|
2
|
+
import DOMPurify from '../../../src/lib/dom_purify.js'
|
|
3
|
+
|
|
4
|
+
test('DOMPurify is initialized correctly', ({ assert }) => {
|
|
5
|
+
assert.isFunction(DOMPurify.sanitize, 'DOMPurify should have a sanitize function')
|
|
6
|
+
})
|
|
7
|
+
|
|
8
|
+
test('DOMPurify sanitizes input correctly', ({ assert }) => {
|
|
9
|
+
const unsafeInput = '<script>alert("XSS")</script>'
|
|
10
|
+
const safeOutput = DOMPurify.sanitize(unsafeInput)
|
|
11
|
+
assert.equal(safeOutput, '', 'Sanitized output should be empty for unsafe input')
|
|
12
|
+
})
|