Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/v0.0.1 alpha.189 #176

Merged
merged 3 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [0.0.1-alpha.189](https://github.com/DIG-Network/dig-chia-sdk/compare/v0.0.1-alpha.188...v0.0.1-alpha.189) (2024-11-01)

### [0.0.1-alpha.188](https://github.com/DIG-Network/dig-chia-sdk/compare/v0.0.1-alpha.187...v0.0.1-alpha.188) (2024-11-01)


### Features

* add base64 getters to udi class ([b77cc11](https://github.com/DIG-Network/dig-chia-sdk/commit/b77cc1107719b1cfff158e7ba65f7c169ccd6dcf))

### [0.0.1-alpha.187](https://github.com/DIG-Network/dig-chia-sdk/compare/v0.0.1-alpha.186...v0.0.1-alpha.187) (2024-11-01)


Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dignetwork/dig-sdk",
"version": "0.0.1-alpha.187",
"version": "0.0.1-alpha.189",
"description": "",
"type": "commonjs",
"main": "./dist/index.js",
Expand Down
10 changes: 5 additions & 5 deletions src/utils/Udi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ class Udi {
if (!/^[a-fA-F0-9]{64}$/.test(input)) {
throw new Error("Input must be a 64-character hex string.");
}
return input.toLowerCase();
return input;
}

static fromUrn(urn: string): Udi {
const parsedUrn = urns.parseURN(urn);
if (parsedUrn.nid.toLowerCase() !== Udi.nid) {
if (parsedUrn.nid !== Udi.nid) {
throw new Error(`Invalid nid: ${parsedUrn.nid}`);
}

Expand Down Expand Up @@ -62,11 +62,11 @@ class Udi {

static convertToHex(input: string): string {
// Attempt hex conversion first
if (/^[a-fA-F0-9]{64}$/.test(input)) return input.toLowerCase();
if (/^[a-fA-F0-9]{64}$/.test(input)) return input;

// Convert from Base32
try {
const paddedInput = Udi.addBase32Padding(input.toUpperCase());
const paddedInput = Udi.addBase32Padding(input);
const buffer = Buffer.from(base32Decode(paddedInput, false));
return buffer.toString("hex");
} catch (e) {
Expand Down Expand Up @@ -118,7 +118,7 @@ class Udi {
if (encoding === "hex") {
return hexString;
} else if (encoding === "base32") {
return base32Encode(buffer).toLowerCase().replace(/=+$/, "");
return base32Encode(buffer).replace(/=+$/, "");
} else if (encoding === "base64") {
return Udi.toBase64UrlSafe(buffer.toString("base64"));
}
Expand Down
Loading