@xyo-network/url-safety-plugin 2.73.3 → 2.73.4
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/dist/docs.json +124 -124
- package/dist/index.d.mts +119 -0
- package/dist/index.d.ts +119 -0
- package/dist/index.js +123 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +93 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +35 -22
- package/tsup.config.ts +16 -0
- package/dist/cjs/Plugin.js +0 -16
- package/dist/cjs/Plugin.js.map +0 -1
- package/dist/cjs/Witness/Config.js +0 -6
- package/dist/cjs/Witness/Config.js.map +0 -1
- package/dist/cjs/Witness/Params.js +0 -3
- package/dist/cjs/Witness/Params.js.map +0 -1
- package/dist/cjs/Witness/Witness.js +0 -76
- package/dist/cjs/Witness/Witness.js.map +0 -1
- package/dist/cjs/Witness/index.js +0 -7
- package/dist/cjs/Witness/index.js.map +0 -1
- package/dist/cjs/index.js +0 -10
- package/dist/cjs/index.js.map +0 -1
- package/dist/esm/Plugin.js +0 -11
- package/dist/esm/Plugin.js.map +0 -1
- package/dist/esm/Witness/Config.js +0 -3
- package/dist/esm/Witness/Config.js.map +0 -1
- package/dist/esm/Witness/Params.js +0 -2
- package/dist/esm/Witness/Params.js.map +0 -1
- package/dist/esm/Witness/Witness.js +0 -64
- package/dist/esm/Witness/Witness.js.map +0 -1
- package/dist/esm/Witness/index.js +0 -4
- package/dist/esm/Witness/index.js.map +0 -1
- package/dist/esm/index.js +0 -6
- package/dist/esm/index.js.map +0 -1
- package/dist/types/Plugin.d.ts +0 -67
- package/dist/types/Plugin.d.ts.map +0 -1
- package/dist/types/Witness/Config.d.ts +0 -13
- package/dist/types/Witness/Config.d.ts.map +0 -1
- package/dist/types/Witness/Params.d.ts +0 -12
- package/dist/types/Witness/Params.d.ts.map +0 -1
- package/dist/types/Witness/Witness.d.ts +0 -24
- package/dist/types/Witness/Witness.d.ts.map +0 -1
- package/dist/types/Witness/index.d.ts +0 -4
- package/dist/types/Witness/index.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -5
- package/dist/types/index.d.ts.map +0 -1
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import * as _xyo_network_payloadset_plugin from '@xyo-network/payloadset-plugin';
|
|
2
|
+
import * as _xyo_network_wallet_model from '@xyo-network/wallet-model';
|
|
3
|
+
import * as _xyo_network_module_model from '@xyo-network/module-model';
|
|
4
|
+
import * as _xyo_network_payload_model from '@xyo-network/payload-model';
|
|
5
|
+
import { Payload } from '@xyo-network/payload-model';
|
|
6
|
+
import * as _xyo_network_account_model from '@xyo-network/account-model';
|
|
7
|
+
import * as _xyo_network_core from '@xyo-network/core';
|
|
8
|
+
import { UrlPayload } from '@xyo-network/url-payload-plugin';
|
|
9
|
+
import { UrlSafetyPayload } from '@xyo-network/url-safety-payload-plugin';
|
|
10
|
+
import { WitnessConfig, WitnessParams, AbstractWitness } from '@xyo-network/witness';
|
|
11
|
+
import { AnyConfigSchema } from '@xyo-network/module';
|
|
12
|
+
|
|
13
|
+
declare const UrlSafetyWitnessConfigSchema: "network.xyo.url.safety.witness.config";
|
|
14
|
+
type UrlSafetyWitnessConfigSchema = typeof UrlSafetyWitnessConfigSchema;
|
|
15
|
+
type UrlSafetyWitnessConfig = WitnessConfig<{
|
|
16
|
+
google?: {
|
|
17
|
+
safeBrowsing?: {
|
|
18
|
+
endPoint?: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
schema: UrlSafetyWitnessConfigSchema;
|
|
22
|
+
urls?: string[];
|
|
23
|
+
}>;
|
|
24
|
+
|
|
25
|
+
type UrlSafetyWitnessParams = WitnessParams<AnyConfigSchema<UrlSafetyWitnessConfig>, {
|
|
26
|
+
google?: {
|
|
27
|
+
safeBrowsing?: {
|
|
28
|
+
endPoint?: string;
|
|
29
|
+
key?: string;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
}>;
|
|
33
|
+
|
|
34
|
+
type GoogleSafeBrowsingMatchSchema = 'com.google.safebrowsing.match';
|
|
35
|
+
declare const GoogleSafeBrowsingMatchSchema: GoogleSafeBrowsingMatchSchema;
|
|
36
|
+
interface GoogleSafeBrowsingMatch {
|
|
37
|
+
cacheDuration: string;
|
|
38
|
+
platformType: string;
|
|
39
|
+
threat: {
|
|
40
|
+
url: string;
|
|
41
|
+
};
|
|
42
|
+
threatEntryType: string;
|
|
43
|
+
threatType: string;
|
|
44
|
+
}
|
|
45
|
+
type GoogleSafeBrowsingMatchPayload = Payload<GoogleSafeBrowsingMatch, GoogleSafeBrowsingMatchSchema>;
|
|
46
|
+
declare class UrlSafetyWitness<TParams extends UrlSafetyWitnessParams = UrlSafetyWitnessParams> extends AbstractWitness<TParams> {
|
|
47
|
+
static configSchemas: "network.xyo.url.safety.witness.config"[];
|
|
48
|
+
get key(): string | undefined;
|
|
49
|
+
get urls(): string[] | undefined;
|
|
50
|
+
protected observeHandler(payloads?: UrlPayload[]): Promise<UrlSafetyPayload[]>;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
declare const UrlSafetyPlugin: () => _xyo_network_payloadset_plugin.PayloadSetWitnessPlugin<UrlSafetyWitness<_xyo_network_core.BaseParamsFields & {
|
|
54
|
+
account?: _xyo_network_account_model.AccountInstance | "random" | undefined;
|
|
55
|
+
config: _xyo_network_payload_model.SchemaFields & _xyo_network_payload_model.PayloadFields & {
|
|
56
|
+
accountDerivationPath?: string | undefined;
|
|
57
|
+
readonly archivist?: _xyo_network_module_model.ArchivistModuleConfig | undefined;
|
|
58
|
+
readonly name?: string | undefined;
|
|
59
|
+
readonly paging?: Record<string, {
|
|
60
|
+
size?: number | undefined;
|
|
61
|
+
}> | undefined;
|
|
62
|
+
readonly schema: string;
|
|
63
|
+
readonly security?: {
|
|
64
|
+
readonly allowAnonymous?: boolean | undefined;
|
|
65
|
+
readonly allowed?: Record<string, (string | _xyo_network_module_model.CosigningAddressSet)[]> | undefined;
|
|
66
|
+
readonly disallowed?: Record<string, string[]> | undefined;
|
|
67
|
+
} | undefined;
|
|
68
|
+
readonly sign?: boolean | undefined;
|
|
69
|
+
readonly storeQueries?: boolean | undefined;
|
|
70
|
+
readonly timestamp?: boolean | undefined;
|
|
71
|
+
} & Omit<Omit<_xyo_network_payload_model.SchemaFields & _xyo_network_payload_model.PayloadFields & {
|
|
72
|
+
accountDerivationPath?: string | undefined;
|
|
73
|
+
readonly archivist?: _xyo_network_module_model.ArchivistModuleConfig | undefined;
|
|
74
|
+
readonly name?: string | undefined;
|
|
75
|
+
readonly paging?: Record<string, {
|
|
76
|
+
size?: number | undefined;
|
|
77
|
+
}> | undefined;
|
|
78
|
+
readonly schema: "network.xyo.url.safety.witness.config";
|
|
79
|
+
readonly security?: {
|
|
80
|
+
readonly allowAnonymous?: boolean | undefined;
|
|
81
|
+
readonly allowed?: Record<string, (string | _xyo_network_module_model.CosigningAddressSet)[]> | undefined;
|
|
82
|
+
readonly disallowed?: Record<string, string[]> | undefined;
|
|
83
|
+
} | undefined;
|
|
84
|
+
readonly sign?: boolean | undefined;
|
|
85
|
+
readonly storeQueries?: boolean | undefined;
|
|
86
|
+
readonly timestamp?: boolean | undefined;
|
|
87
|
+
} & Omit<{
|
|
88
|
+
archivist?: string | undefined;
|
|
89
|
+
schema: "network.xyo.url.safety.witness.config";
|
|
90
|
+
targetSet?: (_xyo_network_payload_model.SchemaFields & _xyo_network_payload_model.PayloadFields & _xyo_network_payload_model.PayloadSet & {
|
|
91
|
+
schema: "network.xyo.payload.set";
|
|
92
|
+
}) | undefined;
|
|
93
|
+
} & {
|
|
94
|
+
google?: {
|
|
95
|
+
safeBrowsing?: {
|
|
96
|
+
endPoint?: string | undefined;
|
|
97
|
+
} | undefined;
|
|
98
|
+
} | undefined;
|
|
99
|
+
schema: "network.xyo.url.safety.witness.config";
|
|
100
|
+
urls?: string[] | undefined;
|
|
101
|
+
}, "schema"> & {
|
|
102
|
+
schema: "network.xyo.url.safety.witness.config";
|
|
103
|
+
}, "schema"> & {
|
|
104
|
+
schema: string;
|
|
105
|
+
}, "schema"> & {
|
|
106
|
+
schema: string;
|
|
107
|
+
};
|
|
108
|
+
ephemeralQueryAccountEnabled?: boolean | undefined;
|
|
109
|
+
wallet?: _xyo_network_wallet_model.WalletInstance | undefined;
|
|
110
|
+
} & {
|
|
111
|
+
google?: {
|
|
112
|
+
safeBrowsing?: {
|
|
113
|
+
endPoint?: string | undefined;
|
|
114
|
+
key?: string | undefined;
|
|
115
|
+
} | undefined;
|
|
116
|
+
} | undefined;
|
|
117
|
+
}>>;
|
|
118
|
+
|
|
119
|
+
export { GoogleSafeBrowsingMatch, GoogleSafeBrowsingMatchPayload, GoogleSafeBrowsingMatchSchema, UrlSafetyPlugin, UrlSafetyWitness, UrlSafetyWitnessConfig, UrlSafetyWitnessConfigSchema, UrlSafetyWitnessParams, UrlSafetyPlugin as default };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import * as _xyo_network_payloadset_plugin from '@xyo-network/payloadset-plugin';
|
|
2
|
+
import * as _xyo_network_wallet_model from '@xyo-network/wallet-model';
|
|
3
|
+
import * as _xyo_network_module_model from '@xyo-network/module-model';
|
|
4
|
+
import * as _xyo_network_payload_model from '@xyo-network/payload-model';
|
|
5
|
+
import { Payload } from '@xyo-network/payload-model';
|
|
6
|
+
import * as _xyo_network_account_model from '@xyo-network/account-model';
|
|
7
|
+
import * as _xyo_network_core from '@xyo-network/core';
|
|
8
|
+
import { UrlPayload } from '@xyo-network/url-payload-plugin';
|
|
9
|
+
import { UrlSafetyPayload } from '@xyo-network/url-safety-payload-plugin';
|
|
10
|
+
import { WitnessConfig, WitnessParams, AbstractWitness } from '@xyo-network/witness';
|
|
11
|
+
import { AnyConfigSchema } from '@xyo-network/module';
|
|
12
|
+
|
|
13
|
+
declare const UrlSafetyWitnessConfigSchema: "network.xyo.url.safety.witness.config";
|
|
14
|
+
type UrlSafetyWitnessConfigSchema = typeof UrlSafetyWitnessConfigSchema;
|
|
15
|
+
type UrlSafetyWitnessConfig = WitnessConfig<{
|
|
16
|
+
google?: {
|
|
17
|
+
safeBrowsing?: {
|
|
18
|
+
endPoint?: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
schema: UrlSafetyWitnessConfigSchema;
|
|
22
|
+
urls?: string[];
|
|
23
|
+
}>;
|
|
24
|
+
|
|
25
|
+
type UrlSafetyWitnessParams = WitnessParams<AnyConfigSchema<UrlSafetyWitnessConfig>, {
|
|
26
|
+
google?: {
|
|
27
|
+
safeBrowsing?: {
|
|
28
|
+
endPoint?: string;
|
|
29
|
+
key?: string;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
}>;
|
|
33
|
+
|
|
34
|
+
type GoogleSafeBrowsingMatchSchema = 'com.google.safebrowsing.match';
|
|
35
|
+
declare const GoogleSafeBrowsingMatchSchema: GoogleSafeBrowsingMatchSchema;
|
|
36
|
+
interface GoogleSafeBrowsingMatch {
|
|
37
|
+
cacheDuration: string;
|
|
38
|
+
platformType: string;
|
|
39
|
+
threat: {
|
|
40
|
+
url: string;
|
|
41
|
+
};
|
|
42
|
+
threatEntryType: string;
|
|
43
|
+
threatType: string;
|
|
44
|
+
}
|
|
45
|
+
type GoogleSafeBrowsingMatchPayload = Payload<GoogleSafeBrowsingMatch, GoogleSafeBrowsingMatchSchema>;
|
|
46
|
+
declare class UrlSafetyWitness<TParams extends UrlSafetyWitnessParams = UrlSafetyWitnessParams> extends AbstractWitness<TParams> {
|
|
47
|
+
static configSchemas: "network.xyo.url.safety.witness.config"[];
|
|
48
|
+
get key(): string | undefined;
|
|
49
|
+
get urls(): string[] | undefined;
|
|
50
|
+
protected observeHandler(payloads?: UrlPayload[]): Promise<UrlSafetyPayload[]>;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
declare const UrlSafetyPlugin: () => _xyo_network_payloadset_plugin.PayloadSetWitnessPlugin<UrlSafetyWitness<_xyo_network_core.BaseParamsFields & {
|
|
54
|
+
account?: _xyo_network_account_model.AccountInstance | "random" | undefined;
|
|
55
|
+
config: _xyo_network_payload_model.SchemaFields & _xyo_network_payload_model.PayloadFields & {
|
|
56
|
+
accountDerivationPath?: string | undefined;
|
|
57
|
+
readonly archivist?: _xyo_network_module_model.ArchivistModuleConfig | undefined;
|
|
58
|
+
readonly name?: string | undefined;
|
|
59
|
+
readonly paging?: Record<string, {
|
|
60
|
+
size?: number | undefined;
|
|
61
|
+
}> | undefined;
|
|
62
|
+
readonly schema: string;
|
|
63
|
+
readonly security?: {
|
|
64
|
+
readonly allowAnonymous?: boolean | undefined;
|
|
65
|
+
readonly allowed?: Record<string, (string | _xyo_network_module_model.CosigningAddressSet)[]> | undefined;
|
|
66
|
+
readonly disallowed?: Record<string, string[]> | undefined;
|
|
67
|
+
} | undefined;
|
|
68
|
+
readonly sign?: boolean | undefined;
|
|
69
|
+
readonly storeQueries?: boolean | undefined;
|
|
70
|
+
readonly timestamp?: boolean | undefined;
|
|
71
|
+
} & Omit<Omit<_xyo_network_payload_model.SchemaFields & _xyo_network_payload_model.PayloadFields & {
|
|
72
|
+
accountDerivationPath?: string | undefined;
|
|
73
|
+
readonly archivist?: _xyo_network_module_model.ArchivistModuleConfig | undefined;
|
|
74
|
+
readonly name?: string | undefined;
|
|
75
|
+
readonly paging?: Record<string, {
|
|
76
|
+
size?: number | undefined;
|
|
77
|
+
}> | undefined;
|
|
78
|
+
readonly schema: "network.xyo.url.safety.witness.config";
|
|
79
|
+
readonly security?: {
|
|
80
|
+
readonly allowAnonymous?: boolean | undefined;
|
|
81
|
+
readonly allowed?: Record<string, (string | _xyo_network_module_model.CosigningAddressSet)[]> | undefined;
|
|
82
|
+
readonly disallowed?: Record<string, string[]> | undefined;
|
|
83
|
+
} | undefined;
|
|
84
|
+
readonly sign?: boolean | undefined;
|
|
85
|
+
readonly storeQueries?: boolean | undefined;
|
|
86
|
+
readonly timestamp?: boolean | undefined;
|
|
87
|
+
} & Omit<{
|
|
88
|
+
archivist?: string | undefined;
|
|
89
|
+
schema: "network.xyo.url.safety.witness.config";
|
|
90
|
+
targetSet?: (_xyo_network_payload_model.SchemaFields & _xyo_network_payload_model.PayloadFields & _xyo_network_payload_model.PayloadSet & {
|
|
91
|
+
schema: "network.xyo.payload.set";
|
|
92
|
+
}) | undefined;
|
|
93
|
+
} & {
|
|
94
|
+
google?: {
|
|
95
|
+
safeBrowsing?: {
|
|
96
|
+
endPoint?: string | undefined;
|
|
97
|
+
} | undefined;
|
|
98
|
+
} | undefined;
|
|
99
|
+
schema: "network.xyo.url.safety.witness.config";
|
|
100
|
+
urls?: string[] | undefined;
|
|
101
|
+
}, "schema"> & {
|
|
102
|
+
schema: "network.xyo.url.safety.witness.config";
|
|
103
|
+
}, "schema"> & {
|
|
104
|
+
schema: string;
|
|
105
|
+
}, "schema"> & {
|
|
106
|
+
schema: string;
|
|
107
|
+
};
|
|
108
|
+
ephemeralQueryAccountEnabled?: boolean | undefined;
|
|
109
|
+
wallet?: _xyo_network_wallet_model.WalletInstance | undefined;
|
|
110
|
+
} & {
|
|
111
|
+
google?: {
|
|
112
|
+
safeBrowsing?: {
|
|
113
|
+
endPoint?: string | undefined;
|
|
114
|
+
key?: string | undefined;
|
|
115
|
+
} | undefined;
|
|
116
|
+
} | undefined;
|
|
117
|
+
}>>;
|
|
118
|
+
|
|
119
|
+
export { GoogleSafeBrowsingMatch, GoogleSafeBrowsingMatchPayload, GoogleSafeBrowsingMatchSchema, UrlSafetyPlugin, UrlSafetyWitness, UrlSafetyWitnessConfig, UrlSafetyWitnessConfigSchema, UrlSafetyWitnessParams, UrlSafetyPlugin as default };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
GoogleSafeBrowsingMatchSchema: () => GoogleSafeBrowsingMatchSchema,
|
|
24
|
+
UrlSafetyPlugin: () => UrlSafetyPlugin,
|
|
25
|
+
UrlSafetyWitness: () => UrlSafetyWitness,
|
|
26
|
+
UrlSafetyWitnessConfigSchema: () => UrlSafetyWitnessConfigSchema,
|
|
27
|
+
default: () => src_default
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(src_exports);
|
|
30
|
+
|
|
31
|
+
// src/Plugin.ts
|
|
32
|
+
var import_payload_model = require("@xyo-network/payload-model");
|
|
33
|
+
var import_payloadset_plugin = require("@xyo-network/payloadset-plugin");
|
|
34
|
+
var import_url_safety_payload_plugin3 = require("@xyo-network/url-safety-payload-plugin");
|
|
35
|
+
|
|
36
|
+
// src/Witness/Config.ts
|
|
37
|
+
var import_url_safety_payload_plugin = require("@xyo-network/url-safety-payload-plugin");
|
|
38
|
+
var UrlSafetyWitnessConfigSchema = `${import_url_safety_payload_plugin.UrlSafetySchema}.witness.config`;
|
|
39
|
+
|
|
40
|
+
// src/Witness/Witness.ts
|
|
41
|
+
var import_axios = require("@xyo-network/axios");
|
|
42
|
+
var import_url_payload_plugin = require("@xyo-network/url-payload-plugin");
|
|
43
|
+
var import_url_safety_payload_plugin2 = require("@xyo-network/url-safety-payload-plugin");
|
|
44
|
+
var import_witness = require("@xyo-network/witness");
|
|
45
|
+
var GoogleSafeBrowsingMatchSchema = "com.google.safebrowsing.match";
|
|
46
|
+
var checkUrlSafety = async (urls, config) => {
|
|
47
|
+
const axios = new import_axios.AxiosJson();
|
|
48
|
+
const endPoint = config?.endPoint ?? "https://safebrowsing.googleapis.com/v4/threatMatches:find";
|
|
49
|
+
const key = config?.key;
|
|
50
|
+
const mutatedUrls = urls.map((url) => url.replace("ipfs://", "https://cloudflare-ipfs.com/"));
|
|
51
|
+
if (mutatedUrls.length === 0) {
|
|
52
|
+
return [];
|
|
53
|
+
}
|
|
54
|
+
const postData = {
|
|
55
|
+
client: {
|
|
56
|
+
clientId: "foreventory",
|
|
57
|
+
clientVersion: "1.0"
|
|
58
|
+
},
|
|
59
|
+
threatInfo: {
|
|
60
|
+
platformTypes: ["WINDOWS", "LINUX", "OSX"],
|
|
61
|
+
threatEntries: mutatedUrls.map((url) => ({ url })),
|
|
62
|
+
threatEntryTypes: ["URL"],
|
|
63
|
+
threatTypes: ["SOCIAL_ENGINEERING", "POTENTIALLY_HARMFUL_APPLICATION", "UNWANTED_SOFTWARE", "THREAT_TYPE_UNSPECIFIED"]
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
console.log(`checkUrlSafetyIn: ${JSON.stringify(postData, null, 2)}`);
|
|
67
|
+
const result = (await axios.post(`${endPoint}?key=${key}`, postData, { headers: { referer: "http://localhost:3000" } })).data;
|
|
68
|
+
console.log(`checkUrlSafetyOut: ${JSON.stringify(result, null, 2)}`);
|
|
69
|
+
return result.matches?.map((match) => ({ ...match, schema: GoogleSafeBrowsingMatchSchema })) ?? [];
|
|
70
|
+
};
|
|
71
|
+
var UrlSafetyWitness = class extends import_witness.AbstractWitness {
|
|
72
|
+
static configSchemas = [UrlSafetyWitnessConfigSchema];
|
|
73
|
+
get key() {
|
|
74
|
+
return this.params.google?.safeBrowsing?.key;
|
|
75
|
+
}
|
|
76
|
+
get urls() {
|
|
77
|
+
return this.config?.urls;
|
|
78
|
+
}
|
|
79
|
+
async observeHandler(payloads = []) {
|
|
80
|
+
const urls = this.urls ?? payloads.filter((p) => p.schema === import_url_payload_plugin.UrlSchema).map((p) => {
|
|
81
|
+
return p.url;
|
|
82
|
+
});
|
|
83
|
+
const matches = await checkUrlSafety(urls, { key: this.key });
|
|
84
|
+
return urls.map((url) => {
|
|
85
|
+
const payload = matches.reduce(
|
|
86
|
+
(prev, match) => {
|
|
87
|
+
if (match.threat.url === url) {
|
|
88
|
+
prev.threatTypes = prev.threatTypes ?? [];
|
|
89
|
+
if (!prev.threatTypes.includes(match.threatEntryType)) {
|
|
90
|
+
prev.threatTypes.push(match.threatEntryType);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return prev;
|
|
94
|
+
},
|
|
95
|
+
{ schema: import_url_safety_payload_plugin2.UrlSafetySchema, url }
|
|
96
|
+
);
|
|
97
|
+
payload.threatTypes = payload.threatTypes?.sort();
|
|
98
|
+
return payload;
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
// src/Plugin.ts
|
|
104
|
+
var UrlSafetyPlugin = () => (0, import_payloadset_plugin.createPayloadSetWitnessPlugin)(
|
|
105
|
+
{ required: { [import_url_safety_payload_plugin3.UrlSafetySchema]: 1 }, schema: import_payload_model.PayloadSetSchema },
|
|
106
|
+
{
|
|
107
|
+
witness: async (params) => {
|
|
108
|
+
const result = await UrlSafetyWitness.create(params);
|
|
109
|
+
return result;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
// src/index.ts
|
|
115
|
+
var src_default = UrlSafetyPlugin;
|
|
116
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
117
|
+
0 && (module.exports = {
|
|
118
|
+
GoogleSafeBrowsingMatchSchema,
|
|
119
|
+
UrlSafetyPlugin,
|
|
120
|
+
UrlSafetyWitness,
|
|
121
|
+
UrlSafetyWitnessConfigSchema
|
|
122
|
+
});
|
|
123
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/Plugin.ts","../src/Witness/Config.ts","../src/Witness/Witness.ts"],"sourcesContent":["import { UrlSafetyPlugin } from './Plugin'\n\nexport * from './Witness'\n\nexport { UrlSafetyPlugin }\n\n// eslint-disable-next-line import/no-default-export\nexport default UrlSafetyPlugin\n","import { PayloadSetSchema } from '@xyo-network/payload-model'\nimport { createPayloadSetWitnessPlugin } from '@xyo-network/payloadset-plugin'\nimport { UrlSafetySchema } from '@xyo-network/url-safety-payload-plugin'\n\nimport { UrlSafetyWitness } from './Witness'\n\nexport const UrlSafetyPlugin = () =>\n createPayloadSetWitnessPlugin<UrlSafetyWitness>(\n { required: { [UrlSafetySchema]: 1 }, schema: PayloadSetSchema },\n {\n witness: async (params) => {\n const result = await UrlSafetyWitness.create(params)\n return result\n },\n },\n )\n","import { UrlSafetySchema } from '@xyo-network/url-safety-payload-plugin'\nimport { WitnessConfig } from '@xyo-network/witness'\n\nexport const UrlSafetyWitnessConfigSchema = `${UrlSafetySchema}.witness.config` as const\nexport type UrlSafetyWitnessConfigSchema = typeof UrlSafetyWitnessConfigSchema\n\nexport type UrlSafetyWitnessConfig = WitnessConfig<{\n google?: {\n safeBrowsing?: {\n endPoint?: string\n }\n }\n schema: UrlSafetyWitnessConfigSchema\n urls?: string[]\n}>\n","import { AxiosJson } from '@xyo-network/axios'\nimport { Payload } from '@xyo-network/payload-model'\nimport { UrlPayload, UrlSchema } from '@xyo-network/url-payload-plugin'\nimport { UrlSafetyPayload, UrlSafetySchema, UrlSafetyThreatType } from '@xyo-network/url-safety-payload-plugin'\nimport { AbstractWitness } from '@xyo-network/witness'\n\nimport { UrlSafetyWitnessConfigSchema } from './Config'\nimport { UrlSafetyWitnessParams } from './Params'\n\nexport type GoogleSafeBrowsingMatchSchema = 'com.google.safebrowsing.match'\nexport const GoogleSafeBrowsingMatchSchema: GoogleSafeBrowsingMatchSchema = 'com.google.safebrowsing.match'\n\nexport interface GoogleSafeBrowsingMatch {\n cacheDuration: string\n platformType: string\n threat: {\n url: string\n }\n threatEntryType: string\n threatType: string\n}\n\nexport type GoogleSafeBrowsingMatchPayload = Payload<GoogleSafeBrowsingMatch, GoogleSafeBrowsingMatchSchema>\n\ninterface GoogleSafeBrowsingResult {\n matches?: GoogleSafeBrowsingMatch[]\n}\n\nconst checkUrlSafety = async (\n urls: string[],\n config?: {\n endPoint?: string\n key?: string\n },\n): Promise<GoogleSafeBrowsingMatchPayload[]> => {\n const axios = new AxiosJson()\n const endPoint = config?.endPoint ?? 'https://safebrowsing.googleapis.com/v4/threatMatches:find'\n const key = config?.key\n const mutatedUrls = urls.map((url) => url.replace('ipfs://', 'https://cloudflare-ipfs.com/'))\n if (mutatedUrls.length === 0) {\n return []\n }\n const postData = {\n client: {\n clientId: 'foreventory',\n clientVersion: '1.0',\n },\n threatInfo: {\n platformTypes: ['WINDOWS', 'LINUX', 'OSX'],\n threatEntries: mutatedUrls.map((url) => ({ url })),\n threatEntryTypes: ['URL'],\n threatTypes: ['SOCIAL_ENGINEERING', 'POTENTIALLY_HARMFUL_APPLICATION', 'UNWANTED_SOFTWARE', 'THREAT_TYPE_UNSPECIFIED'],\n },\n }\n console.log(`checkUrlSafetyIn: ${JSON.stringify(postData, null, 2)}`)\n const result = (await axios.post<GoogleSafeBrowsingResult>(`${endPoint}?key=${key}`, postData, { headers: { referer: 'http://localhost:3000' } }))\n .data\n console.log(`checkUrlSafetyOut: ${JSON.stringify(result, null, 2)}`)\n return result.matches?.map<GoogleSafeBrowsingMatchPayload>((match) => ({ ...match, schema: GoogleSafeBrowsingMatchSchema })) ?? []\n}\n\nexport class UrlSafetyWitness<TParams extends UrlSafetyWitnessParams = UrlSafetyWitnessParams> extends AbstractWitness<TParams> {\n static override configSchemas = [UrlSafetyWitnessConfigSchema]\n\n get key() {\n return this.params.google?.safeBrowsing?.key\n }\n\n get urls() {\n return this.config?.urls\n }\n\n protected override async observeHandler(payloads: UrlPayload[] = []): Promise<UrlSafetyPayload[]> {\n const urls: string[] =\n this.urls ??\n payloads\n .filter((p): p is UrlPayload => p.schema === UrlSchema)\n .map((p) => {\n return p.url\n })\n\n const matches = await checkUrlSafety(urls, { key: this.key })\n\n return urls.map((url) => {\n const payload = matches.reduce<UrlSafetyPayload>(\n (prev, match) => {\n if (match.threat.url === url) {\n prev.threatTypes = prev.threatTypes ?? []\n if (!prev.threatTypes.includes(match.threatEntryType as UrlSafetyThreatType)) {\n prev.threatTypes.push(match.threatEntryType as UrlSafetyThreatType)\n }\n }\n return prev\n },\n { schema: UrlSafetySchema, url },\n )\n payload.threatTypes = payload.threatTypes?.sort()\n return payload\n })\n }\n}\n"],"mappings":"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","names":["import_url_safety_payload_plugin","import_url_safety_payload_plugin"]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
// src/Plugin.ts
|
|
2
|
+
import { PayloadSetSchema } from "@xyo-network/payload-model";
|
|
3
|
+
import { createPayloadSetWitnessPlugin } from "@xyo-network/payloadset-plugin";
|
|
4
|
+
import { UrlSafetySchema as UrlSafetySchema3 } from "@xyo-network/url-safety-payload-plugin";
|
|
5
|
+
|
|
6
|
+
// src/Witness/Config.ts
|
|
7
|
+
import { UrlSafetySchema } from "@xyo-network/url-safety-payload-plugin";
|
|
8
|
+
var UrlSafetyWitnessConfigSchema = `${UrlSafetySchema}.witness.config`;
|
|
9
|
+
|
|
10
|
+
// src/Witness/Witness.ts
|
|
11
|
+
import { AxiosJson } from "@xyo-network/axios";
|
|
12
|
+
import { UrlSchema } from "@xyo-network/url-payload-plugin";
|
|
13
|
+
import { UrlSafetySchema as UrlSafetySchema2 } from "@xyo-network/url-safety-payload-plugin";
|
|
14
|
+
import { AbstractWitness } from "@xyo-network/witness";
|
|
15
|
+
var GoogleSafeBrowsingMatchSchema = "com.google.safebrowsing.match";
|
|
16
|
+
var checkUrlSafety = async (urls, config) => {
|
|
17
|
+
const axios = new AxiosJson();
|
|
18
|
+
const endPoint = config?.endPoint ?? "https://safebrowsing.googleapis.com/v4/threatMatches:find";
|
|
19
|
+
const key = config?.key;
|
|
20
|
+
const mutatedUrls = urls.map((url) => url.replace("ipfs://", "https://cloudflare-ipfs.com/"));
|
|
21
|
+
if (mutatedUrls.length === 0) {
|
|
22
|
+
return [];
|
|
23
|
+
}
|
|
24
|
+
const postData = {
|
|
25
|
+
client: {
|
|
26
|
+
clientId: "foreventory",
|
|
27
|
+
clientVersion: "1.0"
|
|
28
|
+
},
|
|
29
|
+
threatInfo: {
|
|
30
|
+
platformTypes: ["WINDOWS", "LINUX", "OSX"],
|
|
31
|
+
threatEntries: mutatedUrls.map((url) => ({ url })),
|
|
32
|
+
threatEntryTypes: ["URL"],
|
|
33
|
+
threatTypes: ["SOCIAL_ENGINEERING", "POTENTIALLY_HARMFUL_APPLICATION", "UNWANTED_SOFTWARE", "THREAT_TYPE_UNSPECIFIED"]
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
console.log(`checkUrlSafetyIn: ${JSON.stringify(postData, null, 2)}`);
|
|
37
|
+
const result = (await axios.post(`${endPoint}?key=${key}`, postData, { headers: { referer: "http://localhost:3000" } })).data;
|
|
38
|
+
console.log(`checkUrlSafetyOut: ${JSON.stringify(result, null, 2)}`);
|
|
39
|
+
return result.matches?.map((match) => ({ ...match, schema: GoogleSafeBrowsingMatchSchema })) ?? [];
|
|
40
|
+
};
|
|
41
|
+
var UrlSafetyWitness = class extends AbstractWitness {
|
|
42
|
+
static configSchemas = [UrlSafetyWitnessConfigSchema];
|
|
43
|
+
get key() {
|
|
44
|
+
return this.params.google?.safeBrowsing?.key;
|
|
45
|
+
}
|
|
46
|
+
get urls() {
|
|
47
|
+
return this.config?.urls;
|
|
48
|
+
}
|
|
49
|
+
async observeHandler(payloads = []) {
|
|
50
|
+
const urls = this.urls ?? payloads.filter((p) => p.schema === UrlSchema).map((p) => {
|
|
51
|
+
return p.url;
|
|
52
|
+
});
|
|
53
|
+
const matches = await checkUrlSafety(urls, { key: this.key });
|
|
54
|
+
return urls.map((url) => {
|
|
55
|
+
const payload = matches.reduce(
|
|
56
|
+
(prev, match) => {
|
|
57
|
+
if (match.threat.url === url) {
|
|
58
|
+
prev.threatTypes = prev.threatTypes ?? [];
|
|
59
|
+
if (!prev.threatTypes.includes(match.threatEntryType)) {
|
|
60
|
+
prev.threatTypes.push(match.threatEntryType);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return prev;
|
|
64
|
+
},
|
|
65
|
+
{ schema: UrlSafetySchema2, url }
|
|
66
|
+
);
|
|
67
|
+
payload.threatTypes = payload.threatTypes?.sort();
|
|
68
|
+
return payload;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
// src/Plugin.ts
|
|
74
|
+
var UrlSafetyPlugin = () => createPayloadSetWitnessPlugin(
|
|
75
|
+
{ required: { [UrlSafetySchema3]: 1 }, schema: PayloadSetSchema },
|
|
76
|
+
{
|
|
77
|
+
witness: async (params) => {
|
|
78
|
+
const result = await UrlSafetyWitness.create(params);
|
|
79
|
+
return result;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
// src/index.ts
|
|
85
|
+
var src_default = UrlSafetyPlugin;
|
|
86
|
+
export {
|
|
87
|
+
GoogleSafeBrowsingMatchSchema,
|
|
88
|
+
UrlSafetyPlugin,
|
|
89
|
+
UrlSafetyWitness,
|
|
90
|
+
UrlSafetyWitnessConfigSchema,
|
|
91
|
+
src_default as default
|
|
92
|
+
};
|
|
93
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/Plugin.ts","../src/Witness/Config.ts","../src/Witness/Witness.ts","../src/index.ts"],"sourcesContent":["import { PayloadSetSchema } from '@xyo-network/payload-model'\nimport { createPayloadSetWitnessPlugin } from '@xyo-network/payloadset-plugin'\nimport { UrlSafetySchema } from '@xyo-network/url-safety-payload-plugin'\n\nimport { UrlSafetyWitness } from './Witness'\n\nexport const UrlSafetyPlugin = () =>\n createPayloadSetWitnessPlugin<UrlSafetyWitness>(\n { required: { [UrlSafetySchema]: 1 }, schema: PayloadSetSchema },\n {\n witness: async (params) => {\n const result = await UrlSafetyWitness.create(params)\n return result\n },\n },\n )\n","import { UrlSafetySchema } from '@xyo-network/url-safety-payload-plugin'\nimport { WitnessConfig } from '@xyo-network/witness'\n\nexport const UrlSafetyWitnessConfigSchema = `${UrlSafetySchema}.witness.config` as const\nexport type UrlSafetyWitnessConfigSchema = typeof UrlSafetyWitnessConfigSchema\n\nexport type UrlSafetyWitnessConfig = WitnessConfig<{\n google?: {\n safeBrowsing?: {\n endPoint?: string\n }\n }\n schema: UrlSafetyWitnessConfigSchema\n urls?: string[]\n}>\n","import { AxiosJson } from '@xyo-network/axios'\nimport { Payload } from '@xyo-network/payload-model'\nimport { UrlPayload, UrlSchema } from '@xyo-network/url-payload-plugin'\nimport { UrlSafetyPayload, UrlSafetySchema, UrlSafetyThreatType } from '@xyo-network/url-safety-payload-plugin'\nimport { AbstractWitness } from '@xyo-network/witness'\n\nimport { UrlSafetyWitnessConfigSchema } from './Config'\nimport { UrlSafetyWitnessParams } from './Params'\n\nexport type GoogleSafeBrowsingMatchSchema = 'com.google.safebrowsing.match'\nexport const GoogleSafeBrowsingMatchSchema: GoogleSafeBrowsingMatchSchema = 'com.google.safebrowsing.match'\n\nexport interface GoogleSafeBrowsingMatch {\n cacheDuration: string\n platformType: string\n threat: {\n url: string\n }\n threatEntryType: string\n threatType: string\n}\n\nexport type GoogleSafeBrowsingMatchPayload = Payload<GoogleSafeBrowsingMatch, GoogleSafeBrowsingMatchSchema>\n\ninterface GoogleSafeBrowsingResult {\n matches?: GoogleSafeBrowsingMatch[]\n}\n\nconst checkUrlSafety = async (\n urls: string[],\n config?: {\n endPoint?: string\n key?: string\n },\n): Promise<GoogleSafeBrowsingMatchPayload[]> => {\n const axios = new AxiosJson()\n const endPoint = config?.endPoint ?? 'https://safebrowsing.googleapis.com/v4/threatMatches:find'\n const key = config?.key\n const mutatedUrls = urls.map((url) => url.replace('ipfs://', 'https://cloudflare-ipfs.com/'))\n if (mutatedUrls.length === 0) {\n return []\n }\n const postData = {\n client: {\n clientId: 'foreventory',\n clientVersion: '1.0',\n },\n threatInfo: {\n platformTypes: ['WINDOWS', 'LINUX', 'OSX'],\n threatEntries: mutatedUrls.map((url) => ({ url })),\n threatEntryTypes: ['URL'],\n threatTypes: ['SOCIAL_ENGINEERING', 'POTENTIALLY_HARMFUL_APPLICATION', 'UNWANTED_SOFTWARE', 'THREAT_TYPE_UNSPECIFIED'],\n },\n }\n console.log(`checkUrlSafetyIn: ${JSON.stringify(postData, null, 2)}`)\n const result = (await axios.post<GoogleSafeBrowsingResult>(`${endPoint}?key=${key}`, postData, { headers: { referer: 'http://localhost:3000' } }))\n .data\n console.log(`checkUrlSafetyOut: ${JSON.stringify(result, null, 2)}`)\n return result.matches?.map<GoogleSafeBrowsingMatchPayload>((match) => ({ ...match, schema: GoogleSafeBrowsingMatchSchema })) ?? []\n}\n\nexport class UrlSafetyWitness<TParams extends UrlSafetyWitnessParams = UrlSafetyWitnessParams> extends AbstractWitness<TParams> {\n static override configSchemas = [UrlSafetyWitnessConfigSchema]\n\n get key() {\n return this.params.google?.safeBrowsing?.key\n }\n\n get urls() {\n return this.config?.urls\n }\n\n protected override async observeHandler(payloads: UrlPayload[] = []): Promise<UrlSafetyPayload[]> {\n const urls: string[] =\n this.urls ??\n payloads\n .filter((p): p is UrlPayload => p.schema === UrlSchema)\n .map((p) => {\n return p.url\n })\n\n const matches = await checkUrlSafety(urls, { key: this.key })\n\n return urls.map((url) => {\n const payload = matches.reduce<UrlSafetyPayload>(\n (prev, match) => {\n if (match.threat.url === url) {\n prev.threatTypes = prev.threatTypes ?? []\n if (!prev.threatTypes.includes(match.threatEntryType as UrlSafetyThreatType)) {\n prev.threatTypes.push(match.threatEntryType as UrlSafetyThreatType)\n }\n }\n return prev\n },\n { schema: UrlSafetySchema, url },\n )\n payload.threatTypes = payload.threatTypes?.sort()\n return payload\n })\n }\n}\n","import { UrlSafetyPlugin } from './Plugin'\n\nexport * from './Witness'\n\nexport { UrlSafetyPlugin }\n\n// eslint-disable-next-line import/no-default-export\nexport default UrlSafetyPlugin\n"],"mappings":";AAAA,SAAS,wBAAwB;AACjC,SAAS,qCAAqC;AAC9C,SAAS,mBAAAA,wBAAuB;;;ACFhC,SAAS,uBAAuB;AAGzB,IAAM,+BAA+B,GAAG,eAAe;;;ACH9D,SAAS,iBAAiB;AAE1B,SAAqB,iBAAiB;AACtC,SAA2B,mBAAAC,wBAA4C;AACvE,SAAS,uBAAuB;AAMzB,IAAM,gCAA+D;AAkB5E,IAAM,iBAAiB,OACrB,MACA,WAI8C;AAC9C,QAAM,QAAQ,IAAI,UAAU;AAC5B,QAAM,WAAW,QAAQ,YAAY;AACrC,QAAM,MAAM,QAAQ;AACpB,QAAM,cAAc,KAAK,IAAI,CAAC,QAAQ,IAAI,QAAQ,WAAW,8BAA8B,CAAC;AAC5F,MAAI,YAAY,WAAW,GAAG;AAC5B,WAAO,CAAC;AAAA,EACV;AACA,QAAM,WAAW;AAAA,IACf,QAAQ;AAAA,MACN,UAAU;AAAA,MACV,eAAe;AAAA,IACjB;AAAA,IACA,YAAY;AAAA,MACV,eAAe,CAAC,WAAW,SAAS,KAAK;AAAA,MACzC,eAAe,YAAY,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE;AAAA,MACjD,kBAAkB,CAAC,KAAK;AAAA,MACxB,aAAa,CAAC,sBAAsB,mCAAmC,qBAAqB,yBAAyB;AAAA,IACvH;AAAA,EACF;AACA,UAAQ,IAAI,qBAAqB,KAAK,UAAU,UAAU,MAAM,CAAC,CAAC,EAAE;AACpE,QAAM,UAAU,MAAM,MAAM,KAA+B,GAAG,QAAQ,QAAQ,GAAG,IAAI,UAAU,EAAE,SAAS,EAAE,SAAS,wBAAwB,EAAE,CAAC,GAC7I;AACH,UAAQ,IAAI,sBAAsB,KAAK,UAAU,QAAQ,MAAM,CAAC,CAAC,EAAE;AACnE,SAAO,OAAO,SAAS,IAAoC,CAAC,WAAW,EAAE,GAAG,OAAO,QAAQ,8BAA8B,EAAE,KAAK,CAAC;AACnI;AAEO,IAAM,mBAAN,cAAgG,gBAAyB;AAAA,EAC9H,OAAgB,gBAAgB,CAAC,4BAA4B;AAAA,EAE7D,IAAI,MAAM;AACR,WAAO,KAAK,OAAO,QAAQ,cAAc;AAAA,EAC3C;AAAA,EAEA,IAAI,OAAO;AACT,WAAO,KAAK,QAAQ;AAAA,EACtB;AAAA,EAEA,MAAyB,eAAe,WAAyB,CAAC,GAAgC;AAChG,UAAM,OACJ,KAAK,QACL,SACG,OAAO,CAAC,MAAuB,EAAE,WAAW,SAAS,EACrD,IAAI,CAAC,MAAM;AACV,aAAO,EAAE;AAAA,IACX,CAAC;AAEL,UAAM,UAAU,MAAM,eAAe,MAAM,EAAE,KAAK,KAAK,IAAI,CAAC;AAE5D,WAAO,KAAK,IAAI,CAAC,QAAQ;AACvB,YAAM,UAAU,QAAQ;AAAA,QACtB,CAAC,MAAM,UAAU;AACf,cAAI,MAAM,OAAO,QAAQ,KAAK;AAC5B,iBAAK,cAAc,KAAK,eAAe,CAAC;AACxC,gBAAI,CAAC,KAAK,YAAY,SAAS,MAAM,eAAsC,GAAG;AAC5E,mBAAK,YAAY,KAAK,MAAM,eAAsC;AAAA,YACpE;AAAA,UACF;AACA,iBAAO;AAAA,QACT;AAAA,QACA,EAAE,QAAQC,kBAAiB,IAAI;AAAA,MACjC;AACA,cAAQ,cAAc,QAAQ,aAAa,KAAK;AAChD,aAAO;AAAA,IACT,CAAC;AAAA,EACH;AACF;;;AF9FO,IAAM,kBAAkB,MAC7B;AAAA,EACE,EAAE,UAAU,EAAE,CAACC,gBAAe,GAAG,EAAE,GAAG,QAAQ,iBAAiB;AAAA,EAC/D;AAAA,IACE,SAAS,OAAO,WAAW;AACzB,YAAM,SAAS,MAAM,iBAAiB,OAAO,MAAM;AACnD,aAAO;AAAA,IACT;AAAA,EACF;AACF;;;AGRF,IAAO,cAAQ;","names":["UrlSafetySchema","UrlSafetySchema","UrlSafetySchema","UrlSafetySchema"]}
|
package/package.json
CHANGED
|
@@ -10,41 +10,55 @@
|
|
|
10
10
|
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/issues"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@xyo-network/axios": "~2.73.
|
|
14
|
-
"@xyo-network/module": "~2.73.
|
|
15
|
-
"@xyo-network/payload-model": "~2.73.
|
|
16
|
-
"@xyo-network/payloadset-plugin": "~2.73.
|
|
17
|
-
"@xyo-network/url-payload-plugin": "~2.73.
|
|
18
|
-
"@xyo-network/url-safety-payload-plugin": "~2.73.
|
|
19
|
-
"@xyo-network/witness": "~2.73.
|
|
13
|
+
"@xyo-network/axios": "~2.73.4",
|
|
14
|
+
"@xyo-network/module": "~2.73.4",
|
|
15
|
+
"@xyo-network/payload-model": "~2.73.4",
|
|
16
|
+
"@xyo-network/payloadset-plugin": "~2.73.4",
|
|
17
|
+
"@xyo-network/url-payload-plugin": "~2.73.4",
|
|
18
|
+
"@xyo-network/url-safety-payload-plugin": "~2.73.4",
|
|
19
|
+
"@xyo-network/witness": "~2.73.4"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@xylabs/ts-scripts-yarn3": "^2.19.
|
|
23
|
-
"@xylabs/tsconfig": "^2.19.
|
|
22
|
+
"@xylabs/ts-scripts-yarn3": "^2.19.12",
|
|
23
|
+
"@xylabs/tsconfig": "^2.19.12",
|
|
24
|
+
"publint": "^0.2.2",
|
|
25
|
+
"tsup": "^7.2.0",
|
|
24
26
|
"typescript": "^5.2.2"
|
|
25
27
|
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"package-compile": "tsup && publint",
|
|
30
|
+
"package-recompile": "tsup && publint"
|
|
31
|
+
},
|
|
26
32
|
"description": "Primary SDK for using XYO Protocol 2.0",
|
|
27
|
-
"browser": "dist/esm/index.js",
|
|
28
33
|
"docs": "dist/docs.json",
|
|
34
|
+
"types": "dist/index.d.ts",
|
|
29
35
|
"exports": {
|
|
30
36
|
".": {
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
},
|
|
35
|
-
"browser": {
|
|
36
|
-
"import": "./dist/esm/index.js",
|
|
37
|
-
"require": "./dist/cjs/index.js"
|
|
37
|
+
"require": {
|
|
38
|
+
"types": "./dist/index.d.ts",
|
|
39
|
+
"default": "./dist/index.js"
|
|
38
40
|
},
|
|
39
|
-
"
|
|
41
|
+
"import": {
|
|
42
|
+
"types": "./dist/index.d.mts",
|
|
43
|
+
"default": "./dist/index.mjs"
|
|
44
|
+
}
|
|
40
45
|
},
|
|
41
46
|
"./dist/docs.json": {
|
|
42
47
|
"default": "./dist/docs.json"
|
|
43
48
|
},
|
|
49
|
+
"./cjs": {
|
|
50
|
+
"default": "./dist/index.js"
|
|
51
|
+
},
|
|
52
|
+
"./docs": {
|
|
53
|
+
"default": "./dist/docs.json"
|
|
54
|
+
},
|
|
55
|
+
"./esm": {
|
|
56
|
+
"default": "./dist/index.mjs"
|
|
57
|
+
},
|
|
44
58
|
"./package.json": "./package.json"
|
|
45
59
|
},
|
|
46
|
-
"main": "dist/
|
|
47
|
-
"module": "dist/
|
|
60
|
+
"main": "dist/index.js",
|
|
61
|
+
"module": "dist/index.mjs",
|
|
48
62
|
"homepage": "https://xyo.network",
|
|
49
63
|
"license": "LGPL-3.0",
|
|
50
64
|
"publishConfig": {
|
|
@@ -55,6 +69,5 @@
|
|
|
55
69
|
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js.git"
|
|
56
70
|
},
|
|
57
71
|
"sideEffects": false,
|
|
58
|
-
"
|
|
59
|
-
"version": "2.73.3"
|
|
72
|
+
"version": "2.73.4"
|
|
60
73
|
}
|
package/tsup.config.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { defineConfig } from 'tsup'
|
|
2
|
+
|
|
3
|
+
// eslint-disable-next-line import/no-default-export
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
bundle: true,
|
|
6
|
+
cjsInterop: true,
|
|
7
|
+
clean: false,
|
|
8
|
+
dts: {
|
|
9
|
+
entry: ['src/index.ts'],
|
|
10
|
+
},
|
|
11
|
+
entry: ['src/index.ts'],
|
|
12
|
+
format: ['cjs', 'esm'],
|
|
13
|
+
sourcemap: true,
|
|
14
|
+
splitting: false,
|
|
15
|
+
tsconfig: 'tsconfig.json',
|
|
16
|
+
})
|
package/dist/cjs/Plugin.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UrlSafetyPlugin = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const payload_model_1 = require("@xyo-network/payload-model");
|
|
6
|
-
const payloadset_plugin_1 = require("@xyo-network/payloadset-plugin");
|
|
7
|
-
const url_safety_payload_plugin_1 = require("@xyo-network/url-safety-payload-plugin");
|
|
8
|
-
const Witness_1 = require("./Witness");
|
|
9
|
-
const UrlSafetyPlugin = () => (0, payloadset_plugin_1.createPayloadSetWitnessPlugin)({ required: { [url_safety_payload_plugin_1.UrlSafetySchema]: 1 }, schema: payload_model_1.PayloadSetSchema }, {
|
|
10
|
-
witness: (params) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
11
|
-
const result = yield Witness_1.UrlSafetyWitness.create(params);
|
|
12
|
-
return result;
|
|
13
|
-
}),
|
|
14
|
-
});
|
|
15
|
-
exports.UrlSafetyPlugin = UrlSafetyPlugin;
|
|
16
|
-
//# sourceMappingURL=Plugin.js.map
|
package/dist/cjs/Plugin.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Plugin.js","sourceRoot":"","sources":["../../src/Plugin.ts"],"names":[],"mappings":";;;;AAAA,8DAA6D;AAC7D,sEAA8E;AAC9E,sFAAwE;AAExE,uCAA4C;AAErC,MAAM,eAAe,GAAG,GAAG,EAAE,CAClC,IAAA,iDAA6B,EAC3B,EAAE,QAAQ,EAAE,EAAE,CAAC,2CAAe,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,gCAAgB,EAAE,EAChE;IACE,OAAO,EAAE,CAAO,MAAM,EAAE,EAAE;QACxB,MAAM,MAAM,GAAG,MAAM,0BAAgB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;QACpD,OAAO,MAAM,CAAA;IACf,CAAC,CAAA;CACF,CACF,CAAA;AATU,QAAA,eAAe,mBASzB"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UrlSafetyWitnessConfigSchema = void 0;
|
|
4
|
-
const url_safety_payload_plugin_1 = require("@xyo-network/url-safety-payload-plugin");
|
|
5
|
-
exports.UrlSafetyWitnessConfigSchema = `${url_safety_payload_plugin_1.UrlSafetySchema}.witness.config`;
|
|
6
|
-
//# sourceMappingURL=Config.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Config.js","sourceRoot":"","sources":["../../../src/Witness/Config.ts"],"names":[],"mappings":";;;AAAA,sFAAwE;AAG3D,QAAA,4BAA4B,GAAG,GAAG,2CAAe,iBAA0B,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Params.js","sourceRoot":"","sources":["../../../src/Witness/Params.ts"],"names":[],"mappings":""}
|