@xyo-network/huri 5.1.21 → 5.1.23
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 +14 -11
- package/dist/browser/spec/Huri.spec.d.ts +0 -2
- package/dist/browser/spec/Huri.spec.d.ts.map +0 -1
- package/dist/neutral/spec/Huri.spec.d.ts +0 -2
- package/dist/neutral/spec/Huri.spec.d.ts.map +0 -1
- package/dist/node/spec/Huri.spec.d.ts +0 -2
- package/dist/node/spec/Huri.spec.d.ts.map +0 -1
- package/src/spec/Huri.spec.ts +0 -111
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/huri",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.23",
|
|
4
4
|
"description": "Primary SDK for using XYO Protocol 2.0",
|
|
5
5
|
"homepage": "https://xyo.network",
|
|
6
6
|
"bugs": {
|
|
@@ -30,24 +30,27 @@
|
|
|
30
30
|
"types": "dist/neutral/index.d.ts",
|
|
31
31
|
"files": [
|
|
32
32
|
"dist",
|
|
33
|
-
"src"
|
|
33
|
+
"src",
|
|
34
|
+
"!**/*.bench.*",
|
|
35
|
+
"!**/*.spec.*",
|
|
36
|
+
"!**/*.test.*"
|
|
34
37
|
],
|
|
35
38
|
"dependencies": {
|
|
36
|
-
"@xylabs/assert": "~5.0.
|
|
37
|
-
"@xylabs/axios": "~5.0.
|
|
38
|
-
"@xylabs/hex": "~5.0.
|
|
39
|
-
"@xylabs/typeof": "~5.0.
|
|
40
|
-
"@xyo-network/account": "~5.1.
|
|
41
|
-
"@xyo-network/payload-model": "~5.1.
|
|
39
|
+
"@xylabs/assert": "~5.0.33",
|
|
40
|
+
"@xylabs/axios": "~5.0.33",
|
|
41
|
+
"@xylabs/hex": "~5.0.33",
|
|
42
|
+
"@xylabs/typeof": "~5.0.33",
|
|
43
|
+
"@xyo-network/account": "~5.1.23",
|
|
44
|
+
"@xyo-network/payload-model": "~5.1.23"
|
|
42
45
|
},
|
|
43
46
|
"devDependencies": {
|
|
44
|
-
"@xylabs/delay": "~5.0.
|
|
47
|
+
"@xylabs/delay": "~5.0.33",
|
|
45
48
|
"@xylabs/ts-scripts-yarn3": "~7.2.8",
|
|
46
49
|
"@xylabs/tsconfig": "~7.2.8",
|
|
47
|
-
"@xylabs/vitest-extended": "~5.0.
|
|
50
|
+
"@xylabs/vitest-extended": "~5.0.33",
|
|
48
51
|
"axios": "^1.13.2",
|
|
49
52
|
"typescript": "~5.9.3",
|
|
50
|
-
"vitest": "~4.0.
|
|
53
|
+
"vitest": "~4.0.9"
|
|
51
54
|
},
|
|
52
55
|
"peerDependencies": {
|
|
53
56
|
"axios": "^1.13.1"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Huri.spec.d.ts","sourceRoot":"","sources":["../../../src/spec/Huri.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Huri.spec.d.ts","sourceRoot":"","sources":["../../../src/spec/Huri.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Huri.spec.d.ts","sourceRoot":"","sources":["../../../src/spec/Huri.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA"}
|
package/src/spec/Huri.spec.ts
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import '@xylabs/vitest-extended'
|
|
2
|
-
|
|
3
|
-
import { axios } from '@xylabs/axios'
|
|
4
|
-
import { delay } from '@xylabs/delay'
|
|
5
|
-
import type { Payload } from '@xyo-network/payload-model'
|
|
6
|
-
import {
|
|
7
|
-
describe, expect, it, test,
|
|
8
|
-
} from 'vitest'
|
|
9
|
-
|
|
10
|
-
import { Huri } from '../Huri.ts'
|
|
11
|
-
|
|
12
|
-
const hash = 'fb3606d71dcdd49a0aacc9d234e412684d577803c8a9ed9399a9d3776cc88e24'
|
|
13
|
-
|
|
14
|
-
const valid = [
|
|
15
|
-
`https://${hash}`,
|
|
16
|
-
`https://api.archivist.xyo.network/temp/${hash}`,
|
|
17
|
-
`https://api.archivist.xyo.network/${hash}`,
|
|
18
|
-
`http://api.archivist.xyo.network/${hash}`,
|
|
19
|
-
`/api.archivist.xyo.network/${hash}`,
|
|
20
|
-
`//${hash}`,
|
|
21
|
-
`/${hash}`,
|
|
22
|
-
`${hash}`,
|
|
23
|
-
]
|
|
24
|
-
|
|
25
|
-
const validWithTempArchive = [
|
|
26
|
-
`https://api.archivist.xyo.network/temp/${hash}`,
|
|
27
|
-
`https://api.archivist.xyo.network/temp/${hash}`,
|
|
28
|
-
`http://api.archivist.xyo.network/temp/${hash}`,
|
|
29
|
-
`/api.archivist.xyo.network/temp/${hash}`,
|
|
30
|
-
]
|
|
31
|
-
|
|
32
|
-
const invalid = [`https:///api.archivist.xyo.network/${hash}`, `https://api.archivist.xyo.network//${hash}`]
|
|
33
|
-
|
|
34
|
-
describe.skip('Huri', () => {
|
|
35
|
-
describe('Valid Items', () => {
|
|
36
|
-
for (const item of valid) {
|
|
37
|
-
test(`valid [${item}]`, () => {
|
|
38
|
-
try {
|
|
39
|
-
const huri = new Huri(item)
|
|
40
|
-
expect(huri.hash).toBe(hash)
|
|
41
|
-
} catch (error) {
|
|
42
|
-
console.error(`Valid Huri failed: [${item}]`)
|
|
43
|
-
console.error(error)
|
|
44
|
-
}
|
|
45
|
-
})
|
|
46
|
-
}
|
|
47
|
-
})
|
|
48
|
-
describe('Valid Items w/archive', () => {
|
|
49
|
-
for (const item of validWithTempArchive) {
|
|
50
|
-
test(`valid w/archive [${item}]`, () => {
|
|
51
|
-
try {
|
|
52
|
-
const huri = new Huri(item)
|
|
53
|
-
expect(huri.hash).toBe(hash)
|
|
54
|
-
expect(huri.archive).toBe('temp')
|
|
55
|
-
} catch (error) {
|
|
56
|
-
console.error(`Valid Huri w/archive failed: [${item}]`)
|
|
57
|
-
console.error(error)
|
|
58
|
-
}
|
|
59
|
-
})
|
|
60
|
-
}
|
|
61
|
-
})
|
|
62
|
-
describe('Invalid Items', () => {
|
|
63
|
-
for (const item of invalid) {
|
|
64
|
-
test(`invalid [${item}]`, () => {
|
|
65
|
-
expect(() => new Huri(item)).toThrow()
|
|
66
|
-
})
|
|
67
|
-
}
|
|
68
|
-
})
|
|
69
|
-
describe('Api Fetch', () => {
|
|
70
|
-
it('Valid Huri', async () => {
|
|
71
|
-
const huri = new Huri('http://localhost:8080/18f97b3e85f5bede65e7c0a85d74aee896de58ead8bc4b1b3d7300646c653057')
|
|
72
|
-
const result = await huri.fetch()
|
|
73
|
-
expect(result?.schema).toBe('network.xyo.schema')
|
|
74
|
-
})
|
|
75
|
-
it('Valid Huri with token', async () => {
|
|
76
|
-
return await new Promise((resolve) => {
|
|
77
|
-
const token = 'abc123'
|
|
78
|
-
const huri = new Huri('http://localhost:8080/18f97b3e85f5bede65e7c0a85d74aee896de58ead8bc4b1b3d7300646c653057', { token })
|
|
79
|
-
expect(huri.token).toBe(token)
|
|
80
|
-
axios.interceptors.request.use((config) => {
|
|
81
|
-
const tokenValue = config.headers.get('Authorization')
|
|
82
|
-
expect(tokenValue).toBe(`Bearer ${token}`)
|
|
83
|
-
resolve(true)
|
|
84
|
-
return config
|
|
85
|
-
})
|
|
86
|
-
// ignore result since token is fake
|
|
87
|
-
huri.fetch().catch(() => {})
|
|
88
|
-
})
|
|
89
|
-
})
|
|
90
|
-
it('Invalid Huri', async () => {
|
|
91
|
-
const huri = new Huri('http://localhost:8080/18f97b3e85f5bede65e7c0a85d74aee896de58ead8bc4b1b3d7300646c653bad')
|
|
92
|
-
await expect(huri.fetch()).rejects.toThrow()
|
|
93
|
-
})
|
|
94
|
-
})
|
|
95
|
-
describe('Fetch Override', () => {
|
|
96
|
-
for (const item of invalid) {
|
|
97
|
-
test(`invalid [${item}]`, async () => {
|
|
98
|
-
const oldFetch = Huri.fetch
|
|
99
|
-
Huri.fetch = async <T extends Payload = Payload>(huri: Huri): Promise<T | undefined> => {
|
|
100
|
-
await delay(0)
|
|
101
|
-
const payload: T = { schema: huri.hash as string } as T
|
|
102
|
-
return payload
|
|
103
|
-
}
|
|
104
|
-
const huri = new Huri('http://localhost:8080/18f97b3e85f5bede65e7c0a85d74aee896de58ead8bc4b1b3d7300646c653057')
|
|
105
|
-
const result = await huri.fetch()
|
|
106
|
-
Huri.fetch = oldFetch
|
|
107
|
-
expect(result?.schema).toBe('18f97b3e85f5bede65e7c0a85d74aee896de58ead8bc4b1b3d7300646c653057')
|
|
108
|
-
})
|
|
109
|
-
}
|
|
110
|
-
})
|
|
111
|
-
})
|