Skip to content
Open
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
- `onion3`
- `skynet`
- `arweave`
- `walrus`

## 📥 Install

Expand Down
2 changes: 2 additions & 0 deletions src/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export const codeToName = {
0x01bd: "onion3",
0xb19910: "skynet",
0xb29910: "arweave",
0xb59910: "walrus",
} as const;

export const nameToCode = {
Expand All @@ -16,6 +17,7 @@ export const nameToCode = {
onion3: 0x01bd,
skynet: 0xb19910,
arweave: 0xb29910,
walrus: 0xb59910,
} as const;

export type CodecId = keyof typeof codeToName;
Expand Down
10 changes: 10 additions & 0 deletions src/profiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ const encodes = {
arweave: (value: string): Bytes => {
return base64Decode(value);
},
walrus: (value: string): Bytes => {
return hexStringToBytes(value);
}
};

/**
Expand Down Expand Up @@ -150,6 +153,9 @@ const decodes = {
base64: (value: Bytes): string => {
return base64url.encode(value).substring(1);
},
hex: (value: Bytes): string => {
return bytesToHexString(value);
},
};

export type Profile = {
Expand Down Expand Up @@ -183,6 +189,10 @@ export const profiles = {
encode: encodes.arweave,
decode: decodes.base64,
},
walrus: {
encode: encodes.walrus,
decode: decodes.hex,
},
default: {
encode: encodes.utf8,
decode: decodes.utf8,
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"importHelpers": true, // This is only used for build validation. Since we do not have `tslib` installed, this will fail if we accidentally make use of anything that'd require injection of helpers.

// Language and environment
"moduleResolution": "NodeNext",
"moduleResolution": "Node",
"module": "ESNext",
"target": "ES2021", // Setting this to `ES2021` enables native support for `Node v16+`: https://github.com/microsoft/TypeScript/wiki/Node-Target-Mapping.

Expand Down