@dignetwork/dig-sdk 0.0.1-alpha.191 → 0.0.1-alpha.194
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/utils/Udi.d.ts +1 -6
- package/dist/utils/Udi.d.ts.map +1 -1
- package/dist/utils/Udi.js +11 -33
- package/dist/utils/config.d.ts.map +1 -1
- package/dist/utils/config.js +3 -1
- package/package.json +1 -1
package/dist/utils/Udi.d.ts
CHANGED
|
@@ -10,11 +10,8 @@ declare class Udi {
|
|
|
10
10
|
static fromUrn(urn: string): Udi;
|
|
11
11
|
static convertToHex(input: string): string;
|
|
12
12
|
static addBase32Padding(input: string): string;
|
|
13
|
-
|
|
14
|
-
static addBase64Padding(base64: string): string;
|
|
15
|
-
toUrn(encoding?: "hex" | "base32" | "base64"): string;
|
|
13
|
+
toUrn(): string;
|
|
16
14
|
private formatBufferAsEncoding;
|
|
17
|
-
static toBase64UrlSafe(base64Standard: string): string;
|
|
18
15
|
equals(other: Udi): boolean;
|
|
19
16
|
toString(): string;
|
|
20
17
|
clone(): Udi;
|
|
@@ -23,8 +20,6 @@ declare class Udi {
|
|
|
23
20
|
get rootHash(): string | null;
|
|
24
21
|
get storeIdBase32(): string;
|
|
25
22
|
get rootHashBase32(): string | null;
|
|
26
|
-
get storeIdBase64(): string;
|
|
27
|
-
get rootHashBase64(): string | null;
|
|
28
23
|
}
|
|
29
24
|
export { Udi };
|
|
30
25
|
//# sourceMappingURL=Udi.d.ts.map
|
package/dist/utils/Udi.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Udi.d.ts","sourceRoot":"","sources":["../../src/utils/Udi.ts"],"names":[],"mappings":"AAIA,cAAM,GAAG;IACP,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAgB;IAC7C,QAAQ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GAAG,MAAM;IAK9C,KAAK,IAAI,MAAM;IAmBf,OAAO,CAAC,sBAAsB;IAa9B,MAAM,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO;IAW3B,QAAQ,IAAI,MAAM;IAIlB,KAAK,IAAI,GAAG;IASZ,QAAQ,IAAI,MAAM;IAMlB,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED,IAAI,QAAQ,IAAI,MAAM,GAAG,IAAI,CAE5B;IAED,IAAI,aAAa,IAAI,MAAM,CAE1B;IAED,IAAI,cAAc,IAAI,MAAM,GAAG,IAAI,CAIlC;CACF;AAED,OAAO,EAAE,GAAG,EAAE,CAAC"}
|
package/dist/utils/Udi.js
CHANGED
|
@@ -66,9 +66,6 @@ class Udi {
|
|
|
66
66
|
return new Udi(chainName, storeIdHex, rootHashHex, resourceKey);
|
|
67
67
|
}
|
|
68
68
|
static convertToHex(input) {
|
|
69
|
-
// Attempt hex conversion first
|
|
70
|
-
if (/^[a-fA-F0-9]{64}$/.test(input))
|
|
71
|
-
return input;
|
|
72
69
|
// Convert from Base32
|
|
73
70
|
try {
|
|
74
71
|
const paddedInput = Udi.addBase32Padding(input.toUpperCase());
|
|
@@ -78,32 +75,23 @@ class Udi {
|
|
|
78
75
|
catch (e) {
|
|
79
76
|
console.warn("Base32 decoding failed, trying Base64 encoding...");
|
|
80
77
|
}
|
|
81
|
-
//
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
const buffer = Buffer.from(standardBase64, "base64");
|
|
85
|
-
return buffer.toString("hex");
|
|
78
|
+
// Attempt hex conversion first
|
|
79
|
+
if (/^[a-fA-F0-9]{64}$/.test(input)) {
|
|
80
|
+
return input;
|
|
86
81
|
}
|
|
87
|
-
|
|
88
|
-
throw new Error("
|
|
82
|
+
else {
|
|
83
|
+
throw new Error("Input must be a 64-character hex string.");
|
|
89
84
|
}
|
|
90
85
|
}
|
|
91
86
|
static addBase32Padding(input) {
|
|
92
87
|
const paddingNeeded = (8 - (input.length % 8)) % 8;
|
|
93
88
|
return input + "=".repeat(paddingNeeded);
|
|
94
89
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
static addBase64Padding(base64) {
|
|
99
|
-
const paddingNeeded = (4 - (base64.length % 4)) % 4;
|
|
100
|
-
return base64 + "=".repeat(paddingNeeded);
|
|
101
|
-
}
|
|
102
|
-
toUrn(encoding = "hex") {
|
|
103
|
-
const storeIdStr = this.formatBufferAsEncoding(this._storeIdHex, encoding);
|
|
90
|
+
toUrn() {
|
|
91
|
+
const storeIdStr = this.formatBufferAsEncoding(this._storeIdHex, "hex");
|
|
104
92
|
let urn = `${Udi.namespace}:${this.chainName}:${storeIdStr}`;
|
|
105
93
|
if (this._rootHashHex) {
|
|
106
|
-
const rootHashStr = this.formatBufferAsEncoding(this._rootHashHex,
|
|
94
|
+
const rootHashStr = this.formatBufferAsEncoding(this._rootHashHex, "hex");
|
|
107
95
|
urn += `:${rootHashStr}`;
|
|
108
96
|
}
|
|
109
97
|
if (this.resourceKey) {
|
|
@@ -119,14 +107,8 @@ class Udi {
|
|
|
119
107
|
else if (encoding === "base32") {
|
|
120
108
|
return (0, hi_base32_1.encode)(buffer).replace(/=+$/, ""); // Strip padding for Base32
|
|
121
109
|
}
|
|
122
|
-
else if (encoding === "base64") {
|
|
123
|
-
return Udi.toBase64UrlSafe(buffer.toString("base64")); // Convert to URL-safe Base64
|
|
124
|
-
}
|
|
125
110
|
throw new Error("Unsupported encoding type");
|
|
126
111
|
}
|
|
127
|
-
static toBase64UrlSafe(base64Standard) {
|
|
128
|
-
return base64Standard.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
129
|
-
}
|
|
130
112
|
equals(other) {
|
|
131
113
|
return (this._storeIdHex === other._storeIdHex &&
|
|
132
114
|
this.chainName === other.chainName &&
|
|
@@ -156,13 +138,9 @@ class Udi {
|
|
|
156
138
|
return this.formatBufferAsEncoding(this._storeIdHex, "base32");
|
|
157
139
|
}
|
|
158
140
|
get rootHashBase32() {
|
|
159
|
-
return this._rootHashHex
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
return this.formatBufferAsEncoding(this._storeIdHex, "base64");
|
|
163
|
-
}
|
|
164
|
-
get rootHashBase64() {
|
|
165
|
-
return this._rootHashHex ? this.formatBufferAsEncoding(this._rootHashHex, "base64") : null;
|
|
141
|
+
return this._rootHashHex
|
|
142
|
+
? this.formatBufferAsEncoding(this._rootHashHex, "base32")
|
|
143
|
+
: null;
|
|
166
144
|
}
|
|
167
145
|
}
|
|
168
146
|
exports.Udi = Udi;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/utils/config.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAMrC,eAAO,MAAM,oBAAoB,qEACmC,CAAC;AAErE,eAAO,MAAM,0BAA0B,qEAAuB,CAAC;AAE/D,eAAO,MAAM,UAAU,UAAU,CAAC;AAClC,eAAO,MAAM,sBAAsB,qEACiC,CAAC;AAErE,eAAO,MAAM,eAAe,QACqC,CAAC;AAElE,eAAO,MAAM,UAAU,QAAuC,CAAC;AAE/D,eAAO,MAAM,aAAa,QAAkC,CAAC;AAC7D,eAAO,MAAM,gBAAgB,QAAgD,CAAC;AAE9E,eAAO,MAAM,iBAAiB,YAAa,MAAM,KAAG,MACL,CAAC;AAEhD,eAAO,MAAM,mBAAmB,QAAO,IAItC,CAAC;AAEF,eAAO,MAAM,SAAS,WAAY,MAAM,KAAG,IAQ1C,CAAC;AAEF,eAAO,MAAM,cAAc,YAAa,MAAM,KAAG,IAQhD,CAAC;AAqBF,eAAO,MAAM,YAAY,YACd,MAAM,KACd;IACD,QAAQ,EAAE;QACR,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;QACd,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;CAYH,CAAC;AAEF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AAM,eAAe,YACjB,MAAM,OACV,MAAM,SACJ,GAAG,KACT,IAMF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,YAAa,MAAM,OAAO,MAAM,KAAG,IAcjE,CAAC"}
|
package/dist/utils/config.js
CHANGED
|
@@ -106,7 +106,9 @@ const getStoresList = () => {
|
|
|
106
106
|
}
|
|
107
107
|
const folders = fs.readdirSync(exports.STORE_PATH);
|
|
108
108
|
return folders.filter((folder) => /^[a-f0-9]{64}$/.test(folder) &&
|
|
109
|
-
fs.lstatSync(path.join(exports.STORE_PATH, folder)).isDirectory()
|
|
109
|
+
fs.lstatSync(path.join(exports.STORE_PATH, folder)).isDirectory() &&
|
|
110
|
+
// temp fix to remove folder that is causing issues
|
|
111
|
+
folder !== "a3f1b2c4d5e6f708192a3b4c5d6e7f8091a2b3c4d5e6f708192a3b4c5d6e7f80");
|
|
110
112
|
};
|
|
111
113
|
exports.getStoresList = getStoresList;
|
|
112
114
|
/**
|