libp2r2p 0.4.0 → 0.5.0
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/README.md +1 -1
- package/base36/index.js +6 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -234,7 +234,7 @@ to use the normal locale fallback behavior.
|
|
|
234
234
|
Base16, Base36, Base62, Base64/Base64URL, and Base93 helpers are available
|
|
235
235
|
through their matching `libp2r2p/<encoding>` subpaths. Base36 exposes both a
|
|
236
236
|
binary-safe variable-width codec and the canonical 32-byte/50-character
|
|
237
|
-
|
|
237
|
+
Base36Nsite representation from NIP-5A. Base62 uses the same case-sensitive
|
|
238
238
|
alphabet as app NIP-19 entities; its default byte mode preserves leading zero
|
|
239
239
|
bytes, while integer mode supports fixed-width identifiers.
|
|
240
240
|
|
package/base36/index.js
CHANGED
|
@@ -83,14 +83,14 @@ export function base36ToBase16 (value) {
|
|
|
83
83
|
// NIP-5A treats a raw 32-byte value as one unsigned integer and represents it
|
|
84
84
|
// as exactly 50 lowercase Base36 digits. Its leading zeros are numeric width,
|
|
85
85
|
// not zero-byte markers as they are in the binary-safe codec above.
|
|
86
|
-
export function
|
|
86
|
+
export function bytesToBase36Nsite (bytes) {
|
|
87
87
|
if (bytes.length !== NSITE_BYTE_LENGTH) {
|
|
88
88
|
throw new Error('Nsite Base36 input should be ' + NSITE_BYTE_LENGTH + ' bytes')
|
|
89
89
|
}
|
|
90
90
|
return integerToBase36(bytesToInteger(bytes)).padStart(NSITE_TEXT_LENGTH, LEADER)
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
export function
|
|
93
|
+
export function base36NsiteToBytes (value) {
|
|
94
94
|
if (typeof value !== 'string') throw new TypeError('Nsite Base36 value should be a string')
|
|
95
95
|
if (value.length !== NSITE_TEXT_LENGTH) {
|
|
96
96
|
throw new Error('Nsite Base36 value should be ' + NSITE_TEXT_LENGTH + ' characters')
|
|
@@ -105,10 +105,10 @@ export function nsiteBase36ToBytes (value) {
|
|
|
105
105
|
return result
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
export function
|
|
109
|
-
return
|
|
108
|
+
export function base16ToBase36Nsite (value) {
|
|
109
|
+
return bytesToBase36Nsite(base16ToBytes(value))
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
export function
|
|
113
|
-
return bytesToBase16(
|
|
112
|
+
export function base36NsiteToBase16 (value) {
|
|
113
|
+
return bytesToBase16(base36NsiteToBytes(value))
|
|
114
114
|
}
|