@xyo-network/huri 7.0.5 → 7.0.6
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/README.md +1 -47
- package/dist/neutral/index.d.ts +5 -1
- package/dist/neutral/index.d.ts.map +1 -1
- package/dist/neutral/index.mjs +2 -117
- package/dist/neutral/index.mjs.map +3 -3
- package/package.json +17 -20
- package/dist/neutral/Huri.d.ts +0 -33
- package/dist/neutral/Huri.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -1,49 +1,3 @@
|
|
|
1
|
-
[![logo][]](https://xyo.network)
|
|
2
|
-
|
|
3
1
|
# @xyo-network/huri
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
[![license][license-badge]][license-link]
|
|
7
|
-
|
|
8
|
-
> Primary SDK for using XYO Protocol 2.0
|
|
9
|
-
|
|
10
|
-
## Install
|
|
11
|
-
|
|
12
|
-
Using npm:
|
|
13
|
-
|
|
14
|
-
```sh
|
|
15
|
-
npm install {{name}}
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
Using yarn:
|
|
19
|
-
|
|
20
|
-
```sh
|
|
21
|
-
yarn add {{name}}
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
Using pnpm:
|
|
25
|
-
|
|
26
|
-
```sh
|
|
27
|
-
pnpm add {{name}}
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
Using bun:
|
|
31
|
-
|
|
32
|
-
```sh
|
|
33
|
-
bun add {{name}}
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
## License
|
|
38
|
-
|
|
39
|
-
See the [LICENSE](LICENSE) file for license rights and limitations (LGPL-3.0-only).
|
|
40
|
-
|
|
41
|
-
## Credits
|
|
42
|
-
|
|
43
|
-
[Made with 🔥 and ❄️ by XYO Foundation](https://xyo.network)
|
|
44
|
-
|
|
45
|
-
[npm-badge]: https://img.shields.io/npm/v/@xyo-network/huri.svg
|
|
46
|
-
[npm-link]: https://www.npmjs.com/package/@xyo-network/huri
|
|
47
|
-
[license-badge]: https://img.shields.io/npm/l/@xyo-network/huri.svg
|
|
48
|
-
[license-link]: https://github.com/xylabs/sdk-js/blob/main/LICENSE
|
|
49
|
-
[logo]: https://cdn.xy.company/img/brand/XYO_full_colored.png
|
|
3
|
+
Deprecated compatibility stub. Use `@xyo-network/sdk-protocol/huri` instead.
|
package/dist/neutral/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,gCAAgC,CAAA"}
|
package/dist/neutral/index.mjs
CHANGED
|
@@ -1,118 +1,3 @@
|
|
|
1
|
-
// src/
|
|
2
|
-
|
|
3
|
-
assertEx,
|
|
4
|
-
fetchJson,
|
|
5
|
-
isDefined,
|
|
6
|
-
isHash,
|
|
7
|
-
isString
|
|
8
|
-
} from "@xylabs/sdk";
|
|
9
|
-
import { AddressValue } from "@xyo-network/account";
|
|
10
|
-
var Huri = class _Huri {
|
|
11
|
-
isHuri = true;
|
|
12
|
-
archive;
|
|
13
|
-
archivist;
|
|
14
|
-
hash;
|
|
15
|
-
originalHref;
|
|
16
|
-
protocol;
|
|
17
|
-
token;
|
|
18
|
-
constructor(huri, { archivistUri, token } = {}) {
|
|
19
|
-
let huriString;
|
|
20
|
-
const existingHuri = _Huri.isHuri(huri);
|
|
21
|
-
if (existingHuri) {
|
|
22
|
-
huriString = existingHuri.href;
|
|
23
|
-
} else if (typeof huri === "string") {
|
|
24
|
-
huriString = huri;
|
|
25
|
-
} else if (huri instanceof ArrayBuffer) {
|
|
26
|
-
const addressValue = new AddressValue(huri);
|
|
27
|
-
huriString = addressValue.hex;
|
|
28
|
-
} else {
|
|
29
|
-
huriString = huri.href;
|
|
30
|
-
}
|
|
31
|
-
this.originalHref = huriString;
|
|
32
|
-
const protocol = _Huri.parseProtocol(huriString);
|
|
33
|
-
this.protocol = protocol ?? "https";
|
|
34
|
-
const path = assertEx(_Huri.parsePath(huriString), () => "Missing path");
|
|
35
|
-
this.hash = assertEx(this.parsePath(path, protocol !== void 0), () => "Missing hash");
|
|
36
|
-
assertEx(isHash(this.hash), () => `Invalid hash [${this.hash}]`);
|
|
37
|
-
if (isString(archivistUri)) {
|
|
38
|
-
const archivistUriParts = archivistUri.split("://");
|
|
39
|
-
this.protocol = archivistUriParts[0];
|
|
40
|
-
this.archivist = archivistUriParts[1];
|
|
41
|
-
}
|
|
42
|
-
this.token = token;
|
|
43
|
-
this.validateParse();
|
|
44
|
-
}
|
|
45
|
-
static async fetch(huri) {
|
|
46
|
-
const headers = isDefined(huri.token) ? { Authorization: `Bearer ${huri.token}` } : void 0;
|
|
47
|
-
const response = await fetchJson(huri.href, { headers });
|
|
48
|
-
return response.data ?? void 0;
|
|
49
|
-
}
|
|
50
|
-
static isHuri(value) {
|
|
51
|
-
if (typeof value === "object") {
|
|
52
|
-
return value.isHuri ? value : void 0;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
static parsePath(huri) {
|
|
56
|
-
const protocolSplit = huri.split("//");
|
|
57
|
-
assertEx(protocolSplit.length <= 2, () => `Invalid format [${huri}]`);
|
|
58
|
-
if (protocolSplit.length === 1) {
|
|
59
|
-
return huri;
|
|
60
|
-
}
|
|
61
|
-
if (protocolSplit.length === 2) {
|
|
62
|
-
return protocolSplit[1];
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
static parseProtocol(huri) {
|
|
66
|
-
const protocolSplit = huri.split("//");
|
|
67
|
-
assertEx(protocolSplit.length <= 2, () => `Invalid second protocol [${protocolSplit[2]}]`);
|
|
68
|
-
const rawProtocol = protocolSplit.length === 2 ? protocolSplit.shift() : void 0;
|
|
69
|
-
if (isString(rawProtocol)) {
|
|
70
|
-
const protocolParts = rawProtocol?.split(":");
|
|
71
|
-
assertEx(protocolParts.length === 2, () => `Invalid protocol format [${rawProtocol}]`);
|
|
72
|
-
assertEx(protocolParts[1].length === 0, () => `Invalid protocol format (post :) [${rawProtocol}]`);
|
|
73
|
-
return protocolParts.shift();
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
parsePath(path, hasProtocol) {
|
|
77
|
-
const pathParts = path.split("/");
|
|
78
|
-
assertEx(!(hasProtocol && pathParts[0].length === 0), () => "Invalid protocol separator");
|
|
79
|
-
pathParts[0].length === 0 ? pathParts.shift() : null;
|
|
80
|
-
const hash = assertEx(pathParts.pop(), () => "No hash specified");
|
|
81
|
-
this.archivist = pathParts.shift() ?? "api.archivist.xyo.network";
|
|
82
|
-
this.archive = pathParts.pop();
|
|
83
|
-
assertEx(pathParts.length === 0, () => "Too many path parts");
|
|
84
|
-
return hash;
|
|
85
|
-
}
|
|
86
|
-
validateParse() {
|
|
87
|
-
assertEx(this.archivist?.length !== 0, () => "Invalid archivist length");
|
|
88
|
-
assertEx(this.archive?.length !== 0, () => "Invalid archive length");
|
|
89
|
-
assertEx(!(isString(this.archive) && !isString(this.archivist)), () => "If specifying archive, archivist is also required");
|
|
90
|
-
}
|
|
91
|
-
/*
|
|
92
|
-
The full href or the hash
|
|
93
|
-
*/
|
|
94
|
-
get href() {
|
|
95
|
-
const parts = [];
|
|
96
|
-
if (isDefined(this.protocol)) {
|
|
97
|
-
parts.push(`${this.protocol}:/`);
|
|
98
|
-
}
|
|
99
|
-
if (isDefined(this.archive)) {
|
|
100
|
-
parts.push(this.archive);
|
|
101
|
-
}
|
|
102
|
-
if (isDefined(this.archivist)) {
|
|
103
|
-
parts.push(this.archivist);
|
|
104
|
-
}
|
|
105
|
-
parts.push(this.hash);
|
|
106
|
-
return parts.join("/");
|
|
107
|
-
}
|
|
108
|
-
async fetch() {
|
|
109
|
-
return await _Huri.fetch(this);
|
|
110
|
-
}
|
|
111
|
-
toString() {
|
|
112
|
-
return this.href;
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
export {
|
|
116
|
-
Huri
|
|
117
|
-
};
|
|
1
|
+
// src/index.ts
|
|
2
|
+
export * from "@xyo-network/sdk-protocol/huri";
|
|
118
3
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";
|
|
3
|
+
"sources": ["../../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * @deprecated Use `@xyo-network/sdk-protocol/huri` instead.\n * `@xyo-network/huri` is a backward-compatibility re-export stub.\n */\nexport * from '@xyo-network/sdk-protocol/huri'\n"],
|
|
5
|
+
"mappings": ";AAIA,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/huri",
|
|
3
|
-
"version": "7.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "7.0.6",
|
|
4
|
+
"description": "DEPRECATED - use @xyo-network/sdk-protocol/huri. Backward-compatibility re-export stub for @xyo-network/huri.",
|
|
5
|
+
"deprecated": "Use @xyo-network/sdk-protocol/huri instead. @xyo-network/huri is a backward-compatibility re-export stub and will not receive further updates.",
|
|
5
6
|
"homepage": "https://xyo.network",
|
|
6
7
|
"bugs": {
|
|
7
8
|
"url": "git+https://github.com/XYOracleNetwork/sdk-xyo-client-js/issues",
|
|
@@ -34,37 +35,33 @@
|
|
|
34
35
|
"README.md"
|
|
35
36
|
],
|
|
36
37
|
"dependencies": {
|
|
37
|
-
"@xyo-network/
|
|
38
|
-
"@xyo-network/address": "~7.0.5",
|
|
39
|
-
"@xyo-network/payload-model": "~7.0.5"
|
|
38
|
+
"@xyo-network/sdk-protocol": "~7.0.6"
|
|
40
39
|
},
|
|
41
40
|
"devDependencies": {
|
|
42
|
-
"@
|
|
43
|
-
"@
|
|
44
|
-
"@opentelemetry/sdk-trace-base": "^2.8.0",
|
|
45
|
-
"@scure/base": "~2.2.0",
|
|
46
|
-
"@xylabs/sdk": "^7.0.1",
|
|
47
|
-
"@xylabs/toolchain": "~8.5.3",
|
|
48
|
-
"@xylabs/tsconfig": "~8.5.3",
|
|
49
|
-
"@xylabs/vitest-extended": "^7.0.1",
|
|
50
|
-
"async-mutex": "^0.5.0",
|
|
41
|
+
"@xylabs/toolchain": "~8.5.12",
|
|
42
|
+
"@xylabs/tsconfig": "~8.5.12",
|
|
51
43
|
"browserslist": "4.28.4",
|
|
52
44
|
"eslint": "^10.6.0",
|
|
53
45
|
"eslint-import-resolver-typescript": "^4.4.5",
|
|
54
|
-
"
|
|
55
|
-
"typescript": "~6.0.3",
|
|
56
|
-
"vite": "^8.1.0",
|
|
57
|
-
"vitest": "~4.1.9",
|
|
58
|
-
"zod": "^4.4.3"
|
|
46
|
+
"typescript": "~6.0.3"
|
|
59
47
|
},
|
|
60
48
|
"peerDependencies": {
|
|
49
|
+
"@ariestools/sdk": "^7.0.4",
|
|
61
50
|
"@bitauth/libauth": "~3.0",
|
|
51
|
+
"@noble/post-quantum": "~0.6.1",
|
|
62
52
|
"@opentelemetry/api": "^1.9",
|
|
63
53
|
"@opentelemetry/sdk-trace-base": "^2.7",
|
|
64
54
|
"@scure/base": "~2.2",
|
|
65
|
-
"@
|
|
55
|
+
"@scure/bip39": "~2.2",
|
|
56
|
+
"@xylabs/geo": "^7.0",
|
|
57
|
+
"@xylabs/threads": "^7.0",
|
|
58
|
+
"ajv": "^8.20",
|
|
66
59
|
"async-mutex": "^0.5",
|
|
60
|
+
"debug": "^4.4",
|
|
67
61
|
"ethers": "^6.16",
|
|
62
|
+
"hash-wasm": "~4.12",
|
|
63
|
+
"idb": "^8.0",
|
|
64
|
+
"observable-fns": "^0.6",
|
|
68
65
|
"zod": "^4.4"
|
|
69
66
|
},
|
|
70
67
|
"engines": {
|
package/dist/neutral/Huri.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { Hash } from '@xylabs/sdk';
|
|
2
|
-
import type { XyoAddress } from '@xyo-network/address';
|
|
3
|
-
import type { Payload } from '@xyo-network/payload-model';
|
|
4
|
-
export type ObjectCategory = 'block' | 'payload';
|
|
5
|
-
export type HuriFetchFunction = (huri: Huri) => Promise<Payload | undefined>;
|
|
6
|
-
export interface HuriOptions {
|
|
7
|
-
archivistUri?: string;
|
|
8
|
-
token?: string;
|
|
9
|
-
}
|
|
10
|
-
export interface FetchedPayload<T extends Payload = Payload> {
|
|
11
|
-
huri?: Huri;
|
|
12
|
-
payload: T;
|
|
13
|
-
}
|
|
14
|
-
export declare class Huri<T extends Payload = Payload> {
|
|
15
|
-
private isHuri;
|
|
16
|
-
archive?: string;
|
|
17
|
-
archivist?: XyoAddress | string;
|
|
18
|
-
hash: Hash;
|
|
19
|
-
originalHref: string;
|
|
20
|
-
protocol?: string;
|
|
21
|
-
token?: string;
|
|
22
|
-
constructor(huri: Hash | Huri | string, { archivistUri, token }?: HuriOptions);
|
|
23
|
-
static fetch<T extends Payload = Payload>(huri: Huri): Promise<T | undefined>;
|
|
24
|
-
static isHuri(value: unknown): Huri<Payload> | undefined;
|
|
25
|
-
private static parsePath;
|
|
26
|
-
private static parseProtocol;
|
|
27
|
-
private parsePath;
|
|
28
|
-
private validateParse;
|
|
29
|
-
get href(): string;
|
|
30
|
-
fetch(): Promise<T | undefined>;
|
|
31
|
-
toString(): string;
|
|
32
|
-
}
|
|
33
|
-
//# sourceMappingURL=Huri.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Huri.d.ts","sourceRoot":"","sources":["../../src/Huri.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAKvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,KAAK,EAA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