@xyo-network/url-safety-plugin 4.1.1 → 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.
@@ -1,53 +1,3 @@
1
- import * as _xyo_network_payloadset_plugin from '@xyo-network/payloadset-plugin';
2
- import { AnyConfigSchema } from '@xyo-network/module-model';
3
- import { WitnessConfig, WitnessParams } from '@xyo-network/witness-model';
4
- import { AbstractWitness } from '@xyo-network/abstract-witness';
5
- import { Schema, Payload } from '@xyo-network/payload-model';
6
- import { UrlPayload } from '@xyo-network/url-payload-plugin';
7
- import { UrlSafetyPayload } from '@xyo-network/url-safety-payload-plugin';
8
-
9
- declare const UrlSafetyWitnessConfigSchema: "network.xyo.url.safety.witness.config";
10
- type UrlSafetyWitnessConfigSchema = typeof UrlSafetyWitnessConfigSchema;
11
- type UrlSafetyWitnessConfig = WitnessConfig<{
12
- google?: {
13
- safeBrowsing?: {
14
- endPoint?: string;
15
- };
16
- };
17
- schema: UrlSafetyWitnessConfigSchema;
18
- urls?: string[];
19
- }>;
20
-
21
- interface UrlSafetyWitnessParams extends WitnessParams<AnyConfigSchema<UrlSafetyWitnessConfig>> {
22
- google?: {
23
- safeBrowsing?: {
24
- endPoint?: string;
25
- key?: string;
26
- };
27
- };
28
- }
29
-
30
- type GoogleSafeBrowsingMatchSchema = 'com.google.safebrowsing.match';
31
- declare const GoogleSafeBrowsingMatchSchema: GoogleSafeBrowsingMatchSchema;
32
- interface GoogleSafeBrowsingMatch {
33
- cacheDuration: string;
34
- platformType: string;
35
- threat: {
36
- url: string;
37
- };
38
- threatEntryType: string;
39
- threatType: string;
40
- }
41
- type GoogleSafeBrowsingMatchPayload = Payload<GoogleSafeBrowsingMatch, GoogleSafeBrowsingMatchSchema>;
42
- declare class UrlSafetyWitness<TParams extends UrlSafetyWitnessParams = UrlSafetyWitnessParams> extends AbstractWitness<TParams> {
43
- static readonly configSchemas: Schema[];
44
- static readonly defaultConfigSchema: Schema;
45
- get key(): string | undefined;
46
- get urls(): string[] | undefined;
47
- protected observeHandler(payloads?: UrlPayload[]): Promise<UrlSafetyPayload[]>;
48
- }
49
-
50
- declare const UrlSafetyPlugin: () => _xyo_network_payloadset_plugin.PayloadSetWitnessPlugin<UrlSafetyWitness<UrlSafetyWitnessParams>>;
51
-
52
- export { GoogleSafeBrowsingMatchSchema, UrlSafetyPlugin, UrlSafetyWitness, UrlSafetyWitnessConfigSchema, UrlSafetyPlugin as default };
53
- export type { GoogleSafeBrowsingMatch, GoogleSafeBrowsingMatchPayload, UrlSafetyWitnessConfig, UrlSafetyWitnessParams };
1
+ export { UrlSafetyPlugin as default, UrlSafetyPlugin } from './Plugin.ts';
2
+ export * from './Witness/index.ts';
3
+ //# sourceMappingURL=index.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyo-network/url-safety-plugin",
3
- "version": "4.1.1",
3
+ "version": "5.0.0",
4
4
  "description": "Typescript/Javascript Plugins for XYO Platform",
5
5
  "homepage": "https://xyo.network",
6
6
  "bugs": {
@@ -28,20 +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": "^4.13.23",
33
- "@xyo-network/abstract-witness": "^4.1.7",
34
- "@xyo-network/module-model": "^4.1.7",
35
- "@xyo-network/payload-model": "^4.1.7",
36
- "@xyo-network/payloadset-plugin": "^4.1.7",
37
- "@xyo-network/url-payload-plugin": "^4.1.1",
38
- "@xyo-network/url-safety-payload-plugin": "^4.1.1",
39
- "@xyo-network/witness-model": "^4.1.7"
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.0-rc.24",
43
- "@xylabs/tsconfig": "^7.0.0-rc.24",
44
- "knip": "^5.62.0",
46
+ "@xylabs/ts-scripts-yarn3": "^7.0.2",
47
+ "@xylabs/tsconfig": "^7.0.2",
45
48
  "typescript": "^5.8.3",
46
49
  "vitest": "^3.2.4"
47
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
@@ -1,5 +0,0 @@
1
- {
2
- "$schema": "https://typedoc.org/schema.json",
3
- "entryPoints": ["./src/index.ts"],
4
- "tsconfig": "./tsconfig.typedoc.json"
5
- }
package/xy.config.ts DELETED
@@ -1,10 +0,0 @@
1
- import type { XyTsupConfig } from '@xylabs/ts-scripts-yarn3'
2
- const config: XyTsupConfig = {
3
- compile: {
4
- browser: {},
5
- node: {},
6
- neutral: { src: true },
7
- },
8
- }
9
-
10
- export default config