@xyo-network/url-safety-plugin 4.2.0 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +15 -11
- package/src/spec/Witness.spec.ts +38 -0
- package/typedoc.json +0 -5
- package/xy.config.ts +0 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/url-safety-plugin",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "Typescript/Javascript Plugins for XYO Platform",
|
|
5
5
|
"homepage": "https://xyo.network",
|
|
6
6
|
"bugs": {
|
|
@@ -28,19 +28,23 @@
|
|
|
28
28
|
},
|
|
29
29
|
"module": "dist/neutral/index.mjs",
|
|
30
30
|
"types": "dist/neutral/index.d.ts",
|
|
31
|
+
"files": [
|
|
32
|
+
"dist",
|
|
33
|
+
"src"
|
|
34
|
+
],
|
|
31
35
|
"dependencies": {
|
|
32
|
-
"@xylabs/axios": "^
|
|
33
|
-
"@xyo-network/abstract-witness": "^
|
|
34
|
-
"@xyo-network/module-model": "^
|
|
35
|
-
"@xyo-network/payload-model": "^
|
|
36
|
-
"@xyo-network/payloadset-plugin": "^
|
|
37
|
-
"@xyo-network/url-payload-plugin": "^
|
|
38
|
-
"@xyo-network/url-safety-payload-plugin": "^
|
|
39
|
-
"@xyo-network/witness-model": "^
|
|
36
|
+
"@xylabs/axios": "^5.0.0",
|
|
37
|
+
"@xyo-network/abstract-witness": "^5.0.0",
|
|
38
|
+
"@xyo-network/module-model": "^5.0.0",
|
|
39
|
+
"@xyo-network/payload-model": "^5.0.0",
|
|
40
|
+
"@xyo-network/payloadset-plugin": "^5.0.0",
|
|
41
|
+
"@xyo-network/url-payload-plugin": "^5.0.0",
|
|
42
|
+
"@xyo-network/url-safety-payload-plugin": "^5.0.0",
|
|
43
|
+
"@xyo-network/witness-model": "^5.0.0"
|
|
40
44
|
},
|
|
41
45
|
"devDependencies": {
|
|
42
|
-
"@xylabs/ts-scripts-yarn3": "^7.0.
|
|
43
|
-
"@xylabs/tsconfig": "^7.0.
|
|
46
|
+
"@xylabs/ts-scripts-yarn3": "^7.0.2",
|
|
47
|
+
"@xylabs/tsconfig": "^7.0.2",
|
|
44
48
|
"typescript": "^5.8.3",
|
|
45
49
|
"vitest": "^3.2.4"
|
|
46
50
|
},
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { ModuleError } from '@xyo-network/payload-model'
|
|
2
|
+
import type { UrlPayload } from '@xyo-network/url-payload-plugin'
|
|
3
|
+
import { UrlSchema } from '@xyo-network/url-payload-plugin'
|
|
4
|
+
import type { UrlSafetyPayload } from '@xyo-network/url-safety-payload-plugin'
|
|
5
|
+
import {
|
|
6
|
+
beforeAll, describe, expect, test,
|
|
7
|
+
} from 'vitest'
|
|
8
|
+
|
|
9
|
+
import { UrlSafetyWitness } from '../Witness/index.ts'
|
|
10
|
+
|
|
11
|
+
describe.skipIf(!process.env.GOOGLE_SAFEBROWSING_KEY)('UrlSafetyWitness', () => {
|
|
12
|
+
let witness: UrlSafetyWitness
|
|
13
|
+
const schema = UrlSchema
|
|
14
|
+
beforeAll(async () => {
|
|
15
|
+
witness = await UrlSafetyWitness.create({
|
|
16
|
+
account: 'random',
|
|
17
|
+
google: { safeBrowsing: { key: process.env.GOOGLE_SAFEBROWSING_KEY } },
|
|
18
|
+
})
|
|
19
|
+
})
|
|
20
|
+
test('Safe', async () => {
|
|
21
|
+
const safePayload: UrlPayload = { schema, url: 'https://cnn.com' }
|
|
22
|
+
const result = (await witness.observe([safePayload])) as (UrlSafetyPayload | ModuleError)[]
|
|
23
|
+
const safety = result[0] as UrlSafetyPayload
|
|
24
|
+
expect(safety.threatTypes).toBeUndefined()
|
|
25
|
+
})
|
|
26
|
+
test('Unsafe [unknown]', async () => {
|
|
27
|
+
const safePayload: UrlPayload = { schema, url: 'https://ethercb.com/image.png' }
|
|
28
|
+
const result = (await witness.observe([safePayload])) as (UrlSafetyPayload | ModuleError)[]
|
|
29
|
+
const safety = result[0] as UrlSafetyPayload
|
|
30
|
+
expect(safety.threatTypes).toBeUndefined()
|
|
31
|
+
})
|
|
32
|
+
test('Unsafe [test vector]', async () => {
|
|
33
|
+
const safePayload: UrlPayload = { schema, url: 'https://testsafebrowsing.appspot.com/s/phishing.html' }
|
|
34
|
+
const result = (await witness.observe([safePayload])) as (UrlSafetyPayload | ModuleError)[]
|
|
35
|
+
const safety = result[0] as UrlSafetyPayload
|
|
36
|
+
expect(safety.threatTypes?.length).toBeGreaterThan(0)
|
|
37
|
+
})
|
|
38
|
+
})
|
package/typedoc.json
DELETED