@dignetwork/dig-sdk 0.0.1-alpha.187 → 0.0.1-alpha.189
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.js +5 -5
- package/package.json +1 -1
package/dist/utils/Udi.js
CHANGED
|
@@ -41,11 +41,11 @@ class Udi {
|
|
|
41
41
|
if (!/^[a-fA-F0-9]{64}$/.test(input)) {
|
|
42
42
|
throw new Error("Input must be a 64-character hex string.");
|
|
43
43
|
}
|
|
44
|
-
return input
|
|
44
|
+
return input;
|
|
45
45
|
}
|
|
46
46
|
static fromUrn(urn) {
|
|
47
47
|
const parsedUrn = urns.parseURN(urn);
|
|
48
|
-
if (parsedUrn.nid
|
|
48
|
+
if (parsedUrn.nid !== Udi.nid) {
|
|
49
49
|
throw new Error(`Invalid nid: ${parsedUrn.nid}`);
|
|
50
50
|
}
|
|
51
51
|
const parts = parsedUrn.nss.split(":");
|
|
@@ -68,10 +68,10 @@ class Udi {
|
|
|
68
68
|
static convertToHex(input) {
|
|
69
69
|
// Attempt hex conversion first
|
|
70
70
|
if (/^[a-fA-F0-9]{64}$/.test(input))
|
|
71
|
-
return input
|
|
71
|
+
return input;
|
|
72
72
|
// Convert from Base32
|
|
73
73
|
try {
|
|
74
|
-
const paddedInput = Udi.addBase32Padding(input
|
|
74
|
+
const paddedInput = Udi.addBase32Padding(input);
|
|
75
75
|
const buffer = Buffer.from((0, hi_base32_1.decode)(paddedInput, false));
|
|
76
76
|
return buffer.toString("hex");
|
|
77
77
|
}
|
|
@@ -117,7 +117,7 @@ class Udi {
|
|
|
117
117
|
return hexString;
|
|
118
118
|
}
|
|
119
119
|
else if (encoding === "base32") {
|
|
120
|
-
return (0, hi_base32_1.encode)(buffer).
|
|
120
|
+
return (0, hi_base32_1.encode)(buffer).replace(/=+$/, "");
|
|
121
121
|
}
|
|
122
122
|
else if (encoding === "base64") {
|
|
123
123
|
return Udi.toBase64UrlSafe(buffer.toString("base64"));
|