@xyo-network/url-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.
- package/dist/browser/indexBrowser.d.ts +3 -27
- package/dist/neutral/indexNode.d.ts +3 -27
- package/dist/node/indexNode.d.ts +3 -27
- package/package.json +16 -13
- package/src/spec/Plugin.spec.ts +18 -0
- package/src/util/spec/hashFile.spec.ts +35 -0
- package/src/util/spec/hashHttpUrl.spec.ts +38 -0
- package/src/util/spec/hashUrl.spec.ts +25 -0
- package/typedoc.json +0 -5
- package/xy.config.ts +0 -11
|
@@ -1,27 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { AbstractWitness } from '@xyo-network/abstract-witness';
|
|
5
|
-
import { Schema, Payload } from '@xyo-network/payload-model';
|
|
6
|
-
|
|
7
|
-
declare const UrlWitnessConfigSchema: "network.xyo.url.witness.config";
|
|
8
|
-
type UrlWitnessConfigSchema = typeof UrlWitnessConfigSchema;
|
|
9
|
-
type UrlWitnessConfig = WitnessConfig<{
|
|
10
|
-
schema: UrlWitnessConfigSchema;
|
|
11
|
-
urls?: string[];
|
|
12
|
-
}>;
|
|
13
|
-
|
|
14
|
-
type UrlWitnessParams = WitnessParams<AnyConfigSchema<UrlWitnessConfig>>;
|
|
15
|
-
|
|
16
|
-
declare class UrlWitness<TParams extends UrlWitnessParams = UrlWitnessParams> extends AbstractWitness<TParams> {
|
|
17
|
-
static readonly configSchemas: Schema[];
|
|
18
|
-
static readonly defaultConfigSchema: Schema;
|
|
19
|
-
static hashUrl: ((url: string) => Promise<string>) | undefined;
|
|
20
|
-
get urls(): string[] | undefined;
|
|
21
|
-
protected observeHandler(payloads?: Payload[]): Promise<Payload[]>;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
declare const UrlPlugin: () => _xyo_network_payloadset_plugin.PayloadSetWitnessPlugin<UrlWitness<UrlWitnessParams>>;
|
|
25
|
-
|
|
26
|
-
export { UrlPlugin, UrlWitness, UrlWitnessConfigSchema, UrlPlugin as default };
|
|
27
|
-
export type { UrlWitnessConfig, UrlWitnessParams };
|
|
1
|
+
export { UrlPlugin as default, UrlPlugin } from './PluginNode.ts';
|
|
2
|
+
export * from './Witness/index.ts';
|
|
3
|
+
//# sourceMappingURL=indexBrowser.d.ts.map
|
|
@@ -1,27 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { AbstractWitness } from '@xyo-network/abstract-witness';
|
|
5
|
-
import { Schema, Payload } from '@xyo-network/payload-model';
|
|
6
|
-
|
|
7
|
-
declare const UrlWitnessConfigSchema: "network.xyo.url.witness.config";
|
|
8
|
-
type UrlWitnessConfigSchema = typeof UrlWitnessConfigSchema;
|
|
9
|
-
type UrlWitnessConfig = WitnessConfig<{
|
|
10
|
-
schema: UrlWitnessConfigSchema;
|
|
11
|
-
urls?: string[];
|
|
12
|
-
}>;
|
|
13
|
-
|
|
14
|
-
type UrlWitnessParams = WitnessParams<AnyConfigSchema<UrlWitnessConfig>>;
|
|
15
|
-
|
|
16
|
-
declare class UrlWitness<TParams extends UrlWitnessParams = UrlWitnessParams> extends AbstractWitness<TParams> {
|
|
17
|
-
static readonly configSchemas: Schema[];
|
|
18
|
-
static readonly defaultConfigSchema: Schema;
|
|
19
|
-
static hashUrl: ((url: string) => Promise<string>) | undefined;
|
|
20
|
-
get urls(): string[] | undefined;
|
|
21
|
-
protected observeHandler(payloads?: Payload[]): Promise<Payload[]>;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
declare const UrlPlugin: () => _xyo_network_payloadset_plugin.PayloadSetWitnessPlugin<UrlWitness<UrlWitnessParams>>;
|
|
25
|
-
|
|
26
|
-
export { UrlPlugin, UrlWitness, UrlWitnessConfigSchema, UrlPlugin as default };
|
|
27
|
-
export type { UrlWitnessConfig, UrlWitnessParams };
|
|
1
|
+
export { UrlPlugin as default, UrlPlugin } from './PluginNode.ts';
|
|
2
|
+
export * from './Witness/index.ts';
|
|
3
|
+
//# sourceMappingURL=indexNode.d.ts.map
|
package/dist/node/indexNode.d.ts
CHANGED
|
@@ -1,27 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { AbstractWitness } from '@xyo-network/abstract-witness';
|
|
5
|
-
import { Schema, Payload } from '@xyo-network/payload-model';
|
|
6
|
-
|
|
7
|
-
declare const UrlWitnessConfigSchema: "network.xyo.url.witness.config";
|
|
8
|
-
type UrlWitnessConfigSchema = typeof UrlWitnessConfigSchema;
|
|
9
|
-
type UrlWitnessConfig = WitnessConfig<{
|
|
10
|
-
schema: UrlWitnessConfigSchema;
|
|
11
|
-
urls?: string[];
|
|
12
|
-
}>;
|
|
13
|
-
|
|
14
|
-
type UrlWitnessParams = WitnessParams<AnyConfigSchema<UrlWitnessConfig>>;
|
|
15
|
-
|
|
16
|
-
declare class UrlWitness<TParams extends UrlWitnessParams = UrlWitnessParams> extends AbstractWitness<TParams> {
|
|
17
|
-
static readonly configSchemas: Schema[];
|
|
18
|
-
static readonly defaultConfigSchema: Schema;
|
|
19
|
-
static hashUrl: ((url: string) => Promise<string>) | undefined;
|
|
20
|
-
get urls(): string[] | undefined;
|
|
21
|
-
protected observeHandler(payloads?: Payload[]): Promise<Payload[]>;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
declare const UrlPlugin: () => _xyo_network_payloadset_plugin.PayloadSetWitnessPlugin<UrlWitness<UrlWitnessParams>>;
|
|
25
|
-
|
|
26
|
-
export { UrlPlugin, UrlWitness, UrlWitnessConfigSchema, UrlPlugin as default };
|
|
27
|
-
export type { UrlWitnessConfig, UrlWitnessParams };
|
|
1
|
+
export { UrlPlugin as default, UrlPlugin } from './PluginNode.ts';
|
|
2
|
+
export * from './Witness/index.ts';
|
|
3
|
+
//# sourceMappingURL=indexNode.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/url-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": {
|
|
@@ -36,21 +36,24 @@
|
|
|
36
36
|
},
|
|
37
37
|
"module": "dist/neutral/indexNode.mjs",
|
|
38
38
|
"types": "dist/neutral/indexNode.d.ts",
|
|
39
|
+
"files": [
|
|
40
|
+
"dist",
|
|
41
|
+
"src"
|
|
42
|
+
],
|
|
39
43
|
"dependencies": {
|
|
40
|
-
"@xylabs/assert": "^
|
|
41
|
-
"@xylabs/crypto": "^
|
|
42
|
-
"@xyo-network/abstract-witness": "^
|
|
43
|
-
"@xyo-network/module-model": "^
|
|
44
|
-
"@xyo-network/payload-model": "^
|
|
45
|
-
"@xyo-network/payloadset-plugin": "^
|
|
46
|
-
"@xyo-network/url-payload-plugin": "^
|
|
47
|
-
"@xyo-network/witness-model": "^
|
|
44
|
+
"@xylabs/assert": "^5.0.0",
|
|
45
|
+
"@xylabs/crypto": "^5.0.0",
|
|
46
|
+
"@xyo-network/abstract-witness": "^5.0.0",
|
|
47
|
+
"@xyo-network/module-model": "^5.0.0",
|
|
48
|
+
"@xyo-network/payload-model": "^5.0.0",
|
|
49
|
+
"@xyo-network/payloadset-plugin": "^5.0.0",
|
|
50
|
+
"@xyo-network/url-payload-plugin": "^5.0.0",
|
|
51
|
+
"@xyo-network/witness-model": "^5.0.0"
|
|
48
52
|
},
|
|
49
53
|
"devDependencies": {
|
|
50
|
-
"@xylabs/ts-scripts-yarn3": "^7.0.
|
|
51
|
-
"@xylabs/tsconfig": "^7.0.
|
|
52
|
-
"@xylabs/vitest-extended": "^
|
|
53
|
-
"knip": "^5.62.0",
|
|
54
|
+
"@xylabs/ts-scripts-yarn3": "^7.0.2",
|
|
55
|
+
"@xylabs/tsconfig": "^7.0.2",
|
|
56
|
+
"@xylabs/vitest-extended": "^5.0.0",
|
|
54
57
|
"typescript": "^5.8.3",
|
|
55
58
|
"vitest": "^3.2.4"
|
|
56
59
|
},
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import '@xylabs/vitest-extended'
|
|
2
|
+
|
|
3
|
+
import { PayloadSetPluginResolver } from '@xyo-network/payloadset-plugin'
|
|
4
|
+
import {
|
|
5
|
+
describe, expect,
|
|
6
|
+
test,
|
|
7
|
+
} from 'vitest'
|
|
8
|
+
|
|
9
|
+
import { UrlPlugin } from '../PluginNode.ts'
|
|
10
|
+
|
|
11
|
+
describe('UrlPlugin', () => {
|
|
12
|
+
test('Add to Resolver', async () => {
|
|
13
|
+
const plugin = UrlPlugin()
|
|
14
|
+
const resolver = await new PayloadSetPluginResolver().register(plugin)
|
|
15
|
+
expect(await resolver.resolve(plugin.set)).toBeObject()
|
|
16
|
+
expect(await resolver.witness(plugin.set)).toBeObject()
|
|
17
|
+
})
|
|
18
|
+
})
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import '@xylabs/vitest-extended'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
describe, expect,
|
|
5
|
+
it,
|
|
6
|
+
} from 'vitest'
|
|
7
|
+
|
|
8
|
+
import { hashFile } from '../hashFile.ts'
|
|
9
|
+
|
|
10
|
+
describe('hashFile', () => {
|
|
11
|
+
describe('with existing file', () => {
|
|
12
|
+
const expected = '5359b8ebfd4e9251c27a40cc12e64a4cc182e8cfacafc53d2e0c591651d4cc42'
|
|
13
|
+
it('hashes file by path', async () => {
|
|
14
|
+
const file = `${__dirname}/test.txt`
|
|
15
|
+
const actual = await hashFile(file)
|
|
16
|
+
expect(actual).toEqual(expected)
|
|
17
|
+
})
|
|
18
|
+
it('hashes file by file URI', async () => {
|
|
19
|
+
const file = `file://${__dirname}/test.txt`
|
|
20
|
+
const actual = await hashFile(file)
|
|
21
|
+
expect(actual).toEqual(expected)
|
|
22
|
+
})
|
|
23
|
+
})
|
|
24
|
+
describe('with non-existent file', () => {
|
|
25
|
+
it('throws', async () => {
|
|
26
|
+
try {
|
|
27
|
+
await hashFile('missing.txt')
|
|
28
|
+
} catch {
|
|
29
|
+
expect(true).toBeTruthy()
|
|
30
|
+
return
|
|
31
|
+
}
|
|
32
|
+
expect(false).toBeTruthy()
|
|
33
|
+
})
|
|
34
|
+
})
|
|
35
|
+
})
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import '@xylabs/vitest-extended'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
describe, expect,
|
|
5
|
+
it,
|
|
6
|
+
} from 'vitest'
|
|
7
|
+
|
|
8
|
+
import { hashHttpUrl } from '../hashHttpUrl.ts'
|
|
9
|
+
|
|
10
|
+
describe('hashHttpUrl', () => {
|
|
11
|
+
describe('with existing URL', () => {
|
|
12
|
+
it('hashes http URLs', async () => {
|
|
13
|
+
// TODO: Replace with a more static http URL
|
|
14
|
+
const expected = '6da5620880159634213e197fafca1dde0272153be3e4590818533fab8d040770'
|
|
15
|
+
|
|
16
|
+
const url = 'http://www.google.com/favicon.ico'
|
|
17
|
+
const actual = await hashHttpUrl(url)
|
|
18
|
+
expect(actual).toEqual(expected)
|
|
19
|
+
})
|
|
20
|
+
it('hashes https URLs', async () => {
|
|
21
|
+
const expected = '5b6fb901d981dd1da84844069c3eb5aaf725a4f23e40613751eecd5ca0bc4060'
|
|
22
|
+
const url = 'https://xyo.network/favicon.ico'
|
|
23
|
+
const actual = await hashHttpUrl(url)
|
|
24
|
+
expect(actual).toEqual(expected)
|
|
25
|
+
})
|
|
26
|
+
})
|
|
27
|
+
describe('with non-existent URL', () => {
|
|
28
|
+
it('throws', async () => {
|
|
29
|
+
try {
|
|
30
|
+
await hashHttpUrl('https://foo.bar.baz.quix/missing.txt')
|
|
31
|
+
} catch {
|
|
32
|
+
expect(true).toBeTruthy()
|
|
33
|
+
return
|
|
34
|
+
}
|
|
35
|
+
expect(false).toBeTruthy()
|
|
36
|
+
})
|
|
37
|
+
})
|
|
38
|
+
})
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import '@xylabs/vitest-extended'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
describe, expect,
|
|
5
|
+
it,
|
|
6
|
+
} from 'vitest'
|
|
7
|
+
|
|
8
|
+
import { hashUrl } from '../hashUrl.ts'
|
|
9
|
+
|
|
10
|
+
describe('hashUrl', () => {
|
|
11
|
+
describe('with https URL', () => {
|
|
12
|
+
it('hashes resource', async () => {
|
|
13
|
+
const url = 'https://xyo.network/favicon.ico'
|
|
14
|
+
const actual = await hashUrl(url)
|
|
15
|
+
expect(actual).toBeTruthy()
|
|
16
|
+
})
|
|
17
|
+
})
|
|
18
|
+
describe('with file URL', () => {
|
|
19
|
+
it('hashes resource', async () => {
|
|
20
|
+
const url = `file://${__dirname}/test.txt`
|
|
21
|
+
const actual = await hashUrl(url)
|
|
22
|
+
expect(actual).toBeTruthy()
|
|
23
|
+
})
|
|
24
|
+
})
|
|
25
|
+
})
|
package/typedoc.json
DELETED
package/xy.config.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { XyTsupConfig } from '@xylabs/ts-scripts-yarn3'
|
|
2
|
-
const config: XyTsupConfig = {
|
|
3
|
-
compile: {
|
|
4
|
-
entryMode: 'custom',
|
|
5
|
-
browser: { src: { entry: ['indexBrowser.ts'] } },
|
|
6
|
-
neutral: { src: { entry: ['indexNode.ts'] } },
|
|
7
|
-
node: { src: { entry: ['indexNode.ts'] } },
|
|
8
|
-
},
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export default config
|