@dignetwork/dig-sdk 0.0.1-alpha.191 → 0.0.1-alpha.192

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.
@@ -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
- static toStandardBase64(base64UrlSafe: string): string;
14
- static addBase64Padding(base64: string): string;
15
- toUrn(encoding?: "hex" | "base32" | "base64"): string;
13
+ toUrn(encoding?: "hex" | "base32"): 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
@@ -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,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAS;IACpC,MAAM,CAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAoB;gBAGnD,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,QAAQ,GAAE,MAAM,GAAG,IAAW,EAC9B,WAAW,GAAE,MAAM,GAAG,IAAW;IAWnC,MAAM,CAAC,kBAAkB,CAAC,KAAK,EAA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AAC,GAAG,EAAE,MAAM,CAAS;IACpC,MAAM,CAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAoB;gBAGnD,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,QAAQ,GAAE,MAAM,GAAG,IAAW,EAC9B,WAAW,GAAE,MAAM,GAAG,IAAW;IAWnC,MAAM,CAAC,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAOhD,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG;IA4BhC,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAkB1C,MAAM,CAAC,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAK9C,KAAK,CAAC,QAAQ,GAAE,KAAK,GAAG,QAAgB,GAAG,MAAM;IAmBjD,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,27 +75,18 @@ class Udi {
78
75
  catch (e) {
79
76
  console.warn("Base32 decoding failed, trying Base64 encoding...");
80
77
  }
81
- // Convert from Base64
82
- try {
83
- const standardBase64 = Udi.addBase64Padding(Udi.toStandardBase64(input));
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
- catch (e) {
88
- throw new Error("Invalid input encoding. Must be 32-byte hex, Base32, or Base64 string.");
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
- static toStandardBase64(base64UrlSafe) {
96
- return base64UrlSafe.replace(/-/g, "+").replace(/_/g, "/");
97
- }
98
- static addBase64Padding(base64) {
99
- const paddingNeeded = (4 - (base64.length % 4)) % 4;
100
- return base64 + "=".repeat(paddingNeeded);
101
- }
102
90
  toUrn(encoding = "hex") {
103
91
  const storeIdStr = this.formatBufferAsEncoding(this._storeIdHex, encoding);
104
92
  let urn = `${Udi.namespace}:${this.chainName}:${storeIdStr}`;
@@ -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 ? this.formatBufferAsEncoding(this._rootHashHex, "base32") : null;
160
- }
161
- get storeIdBase64() {
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dignetwork/dig-sdk",
3
- "version": "0.0.1-alpha.191",
3
+ "version": "0.0.1-alpha.192",
4
4
  "description": "",
5
5
  "type": "commonjs",
6
6
  "main": "./dist/index.js",