chore: update to version 14.0.11 and align website URLs

This commit is contained in:
2026-01-11 11:34:13 +03:00
parent ef74383349
commit 19c8d69bd8
1499 changed files with 53633 additions and 89 deletions
+26
View File
@@ -0,0 +1,26 @@
/**
* @name base32Validate
* @summary Validates a base32 value.
* @description
* Validates that the supplied value is valid base32, throwing exceptions if not
*/
export declare const base32Validate: (value?: unknown, ipfsCompat?: boolean) => value is string;
/**
* @name isBase32
* @description Checks if the input is in base32, returning true/false
*/
export declare const isBase32: (value?: unknown, ipfsCompat?: boolean) => value is string;
/**
* @name base32Decode
* @summary Delookup a base32 value.
* @description
* From the provided input, decode the base32 and return the result as an `Uint8Array`.
*/
export declare const base32Decode: (value: string, ipfsCompat?: boolean) => Uint8Array;
/**
* @name base32Encode
* @summary Creates a base32 value.
* @description
* From the provided input, create the base32 and return the result as a string.
*/
export declare const base32Encode: (value: import("@pezkuwi/util/types").U8aLike, ipfsCompat?: boolean) => string;
+43
View File
@@ -0,0 +1,43 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.base32Encode = exports.base32Decode = exports.isBase32 = exports.base32Validate = void 0;
const base_1 = require("@scure/base");
const helpers_js_1 = require("./helpers.js");
const chars = 'abcdefghijklmnopqrstuvwxyz234567';
const config = {
chars,
coder: base_1.utils.chain(
// We define our own chain, the default base32 has padding
base_1.utils.radix2(5), base_1.utils.alphabet(chars), {
decode: (input) => input.split(''),
encode: (input) => input.join('')
}),
ipfs: 'b',
type: 'base32'
};
/**
* @name base32Validate
* @summary Validates a base32 value.
* @description
* Validates that the supplied value is valid base32, throwing exceptions if not
*/
exports.base32Validate = (0, helpers_js_1.createValidate)(config);
/**
* @name isBase32
* @description Checks if the input is in base32, returning true/false
*/
exports.isBase32 = (0, helpers_js_1.createIs)(exports.base32Validate);
/**
* @name base32Decode
* @summary Delookup a base32 value.
* @description
* From the provided input, decode the base32 and return the result as an `Uint8Array`.
*/
exports.base32Decode = (0, helpers_js_1.createDecode)(config, exports.base32Validate);
/**
* @name base32Encode
* @summary Creates a base32 value.
* @description
* From the provided input, create the base32 and return the result as a string.
*/
exports.base32Encode = (0, helpers_js_1.createEncode)(config);
+25
View File
@@ -0,0 +1,25 @@
import type { U8aLike } from '@pezkuwi/util/types';
export type { U8aLike } from '@pezkuwi/util/types';
interface Coder {
decode: (value: string) => Uint8Array;
encode: (value: Uint8Array) => string;
}
interface Config {
chars: string;
coder: Coder;
ipfs?: string;
regex?: RegExp;
type: string;
withPadding?: boolean;
}
type DecodeFn = (value: string, ipfsCompat?: boolean) => Uint8Array;
type EncodeFn = (value: U8aLike, ipfsCompat?: boolean) => string;
type ValidateFn = (value?: unknown, ipfsCompat?: boolean) => value is string;
/** @internal */
export declare function createDecode({ coder, ipfs }: Config, validate: ValidateFn): DecodeFn;
/** @internal */
export declare function createEncode({ coder, ipfs }: Config): EncodeFn;
/** @internal */
export declare function createIs(validate: ValidateFn): ValidateFn;
/** @internal */
export declare function createValidate({ chars, ipfs, type, withPadding }: Config): ValidateFn;
@@ -0,0 +1,67 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createDecode = createDecode;
exports.createEncode = createEncode;
exports.createIs = createIs;
exports.createValidate = createValidate;
const util_1 = require("@pezkuwi/util");
/** @internal */
function createDecode({ coder, ipfs }, validate) {
return (value, ipfsCompat) => {
validate(value, ipfsCompat);
return coder.decode(ipfs && ipfsCompat
? value.substring(1)
: value);
};
}
/** @internal */
function createEncode({ coder, ipfs }) {
return (value, ipfsCompat) => {
const out = coder.encode((0, util_1.u8aToU8a)(value));
return ipfs && ipfsCompat
? `${ipfs}${out}`
: out;
};
}
/** @internal */
function createIs(validate) {
return (value, ipfsCompat) => {
try {
return validate(value, ipfsCompat);
}
catch {
return false;
}
};
}
/** @internal */
function createValidate({ chars, ipfs, type, withPadding }) {
return (value, ipfsCompat) => {
if (typeof value !== 'string') {
throw new Error(`Expected ${type} string input`);
}
else if (ipfs && ipfsCompat && !value.startsWith(ipfs)) {
throw new Error(`Expected ipfs-compatible ${type} to start with '${ipfs}'`);
}
for (let i = (ipfsCompat ? 1 : 0), count = value.length; i < count; i++) {
if (chars.includes(value[i])) {
// all ok, character found
}
else if (withPadding && value[i] === '=') {
if (i === count - 1) {
// last character, everything ok
}
else if (value[i + 1] === '=') {
// next one is also padding, sequence ok
}
else {
throw new Error(`Invalid ${type} padding sequence "${value[i]}${value[i + 1]}" at index ${i}`);
}
}
else {
throw new Error(`Invalid ${type} character "${value[i]}" (0x${value.charCodeAt(i).toString(16)}) at index ${i}`);
}
}
return true;
};
}
+4
View File
@@ -0,0 +1,4 @@
/**
* @summary Encode and decode base32 values
*/
export { base32Decode, base32Encode, base32Validate, isBase32 } from './bs32.js';
+11
View File
@@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isBase32 = exports.base32Validate = exports.base32Encode = exports.base32Decode = void 0;
/**
* @summary Encode and decode base32 values
*/
var bs32_js_1 = require("./bs32.js");
Object.defineProperty(exports, "base32Decode", { enumerable: true, get: function () { return bs32_js_1.base32Decode; } });
Object.defineProperty(exports, "base32Encode", { enumerable: true, get: function () { return bs32_js_1.base32Encode; } });
Object.defineProperty(exports, "base32Validate", { enumerable: true, get: function () { return bs32_js_1.base32Validate; } });
Object.defineProperty(exports, "isBase32", { enumerable: true, get: function () { return bs32_js_1.isBase32; } });