@xyo-network/huri 7.0.14 → 7.0.15
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/neutral/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from '
|
|
1
|
+
export * from '@xyo-network/sdk-protocol/huri';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,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 "@ariestools/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": ";AACA
|
|
3
|
+
"sources": ["../../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["// Compatibility shim: this package re-exports from @xyo-network/sdk-protocol.\nexport * from '@xyo-network/sdk-protocol/huri'\n"],
|
|
5
|
+
"mappings": ";AACA,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/huri",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.15",
|
|
4
4
|
"description": "Primary SDK for using XYO Protocol 2.0",
|
|
5
5
|
"homepage": "https://xyo.network",
|
|
6
6
|
"bugs": {
|
|
@@ -34,36 +34,51 @@
|
|
|
34
34
|
"README.md"
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@xyo-network/
|
|
38
|
-
"@xyo-network/address": "~7.0.14",
|
|
39
|
-
"@xyo-network/payload-model": "~7.0.14"
|
|
37
|
+
"@xyo-network/sdk-protocol": "~7.0.15"
|
|
40
38
|
},
|
|
41
39
|
"devDependencies": {
|
|
42
40
|
"@ariestools/sdk": "~8.0.2",
|
|
43
|
-
"@ariestools/
|
|
41
|
+
"@ariestools/threads": "~8.0.2",
|
|
44
42
|
"@bitauth/libauth": "~3.0.0",
|
|
43
|
+
"@metamask/providers": "~22.1.1",
|
|
44
|
+
"@noble/post-quantum": "~0.6.1",
|
|
45
45
|
"@opentelemetry/api": "~1.9.1",
|
|
46
46
|
"@opentelemetry/sdk-trace-base": "~2.9.0",
|
|
47
47
|
"@scure/base": "~2.2.0",
|
|
48
|
-
"@
|
|
49
|
-
"@xylabs/
|
|
48
|
+
"@scure/bip39": "~2.2.0",
|
|
49
|
+
"@xylabs/toolchain": "~8.6.7",
|
|
50
|
+
"@xylabs/tsconfig": "~8.6.7",
|
|
51
|
+
"ajv": "~8.20.0",
|
|
50
52
|
"async-mutex": "~0.5.0",
|
|
53
|
+
"debug": "~4.4.3",
|
|
51
54
|
"eslint": "~10.6.0",
|
|
52
55
|
"eslint-import-resolver-typescript": "~4.4.5",
|
|
53
56
|
"ethers": "~6.17.0",
|
|
57
|
+
"hash-wasm": "~4.12.0",
|
|
58
|
+
"idb": "~8.0.3",
|
|
59
|
+
"observable-fns": "~0.6.1",
|
|
54
60
|
"typescript": "~6.0.3",
|
|
55
|
-
"
|
|
56
|
-
"vitest": "~4.1.9",
|
|
61
|
+
"webextension-polyfill": "~0.12.0",
|
|
57
62
|
"zod": "~4.4.3"
|
|
58
63
|
},
|
|
59
64
|
"peerDependencies": {
|
|
60
65
|
"@ariestools/sdk": "^8.0.2",
|
|
66
|
+
"@ariestools/threads": "^8.0.2",
|
|
61
67
|
"@bitauth/libauth": "^3.0.0",
|
|
68
|
+
"@metamask/providers": "^22.1.1",
|
|
69
|
+
"@noble/post-quantum": "^0.6.1",
|
|
62
70
|
"@opentelemetry/api": "^1.9.1",
|
|
63
71
|
"@opentelemetry/sdk-trace-base": "^2.9.0",
|
|
64
72
|
"@scure/base": "^2.2.0",
|
|
73
|
+
"@scure/bip39": "^2.2.0",
|
|
74
|
+
"ajv": "^8.20.0",
|
|
65
75
|
"async-mutex": "^0.5.0",
|
|
76
|
+
"debug": "^4.4.3",
|
|
66
77
|
"ethers": "^6.17.0",
|
|
78
|
+
"hash-wasm": "^4.12.0",
|
|
79
|
+
"idb": "^8.0.3",
|
|
80
|
+
"observable-fns": "^0.6.1",
|
|
81
|
+
"webextension-polyfill": "^0.12.0",
|
|
67
82
|
"zod": "^4.4.3"
|
|
68
83
|
},
|
|
69
84
|
"engines": {
|
|
@@ -71,5 +86,6 @@
|
|
|
71
86
|
},
|
|
72
87
|
"publishConfig": {
|
|
73
88
|
"access": "public"
|
|
74
|
-
}
|
|
89
|
+
},
|
|
90
|
+
"deprecated": "Use @xyo-network/sdk-protocol/huri instead. Replace @xyo-network/huri with @xyo-network/sdk-protocol/huri. This package is a compatibility shim only and will not receive further updates."
|
|
75
91
|
}
|
package/dist/neutral/Huri.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { Hash } from '@ariestools/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
|
-
//# s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