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
+6
View File
@@ -0,0 +1,6 @@
import type { EncryptedJsonEncoding, EncryptedJsonVersion } from './types.js';
export declare const ENCODING: EncryptedJsonEncoding[];
export declare const ENCODING_NONE: EncryptedJsonEncoding[];
export declare const ENCODING_VERSION: EncryptedJsonVersion;
export declare const NONCE_LENGTH = 24;
export declare const SCRYPT_LENGTH: number;
+5
View File
@@ -0,0 +1,5 @@
export const ENCODING = ['scrypt', 'xsalsa20-poly1305'];
export const ENCODING_NONE = ['none'];
export const ENCODING_VERSION = '3';
export const NONCE_LENGTH = 24;
export const SCRYPT_LENGTH = 32 + (3 * 4);
+2
View File
@@ -0,0 +1,2 @@
import type { EncryptedJson } from './types.js';
export declare function jsonDecrypt({ encoded, encoding }: EncryptedJson, passphrase?: string | null): Uint8Array;
+13
View File
@@ -0,0 +1,13 @@
import { hexToU8a, isHex } from '@pezkuwi/util';
import { base64Decode } from '../base64/index.js';
import { jsonDecryptData } from './decryptData.js';
export function jsonDecrypt({ encoded, encoding }, passphrase) {
if (!encoded) {
throw new Error('No encrypted data available to decode');
}
return jsonDecryptData(isHex(encoded)
? hexToU8a(encoded)
: base64Decode(encoded), passphrase, Array.isArray(encoding.type)
? encoding.type
: [encoding.type]);
}
+2
View File
@@ -0,0 +1,2 @@
import type { EncryptedJsonEncoding } from './types.js';
export declare function jsonDecryptData(encrypted?: Uint8Array | null, passphrase?: string | null, encType?: EncryptedJsonEncoding[]): Uint8Array;
+29
View File
@@ -0,0 +1,29 @@
import { stringToU8a, u8aFixLength } from '@pezkuwi/util';
import { naclDecrypt } from '../nacl/index.js';
import { scryptEncode, scryptFromU8a } from '../scrypt/index.js';
import { ENCODING, NONCE_LENGTH, SCRYPT_LENGTH } from './constants.js';
export function jsonDecryptData(encrypted, passphrase, encType = ENCODING) {
if (!encrypted) {
throw new Error('No encrypted data available to decode');
}
else if (encType.includes('xsalsa20-poly1305') && !passphrase) {
throw new Error('Password required to decode encrypted data');
}
let encoded = encrypted;
if (passphrase) {
let password;
if (encType.includes('scrypt')) {
const { params, salt } = scryptFromU8a(encrypted);
password = scryptEncode(passphrase, salt, params).password;
encrypted = encrypted.subarray(SCRYPT_LENGTH);
}
else {
password = stringToU8a(passphrase);
}
encoded = naclDecrypt(encrypted.subarray(NONCE_LENGTH), encrypted.subarray(0, NONCE_LENGTH), u8aFixLength(password, 256, true));
}
if (!encoded) {
throw new Error('Unable to decode using the supplied passphrase');
}
return encoded;
}
+2
View File
@@ -0,0 +1,2 @@
import type { EncryptedJson } from './types.js';
export declare function jsonEncrypt(data: Uint8Array, contentType: string[], passphrase?: string | null): EncryptedJson;
+15
View File
@@ -0,0 +1,15 @@
import { u8aConcat } from '@pezkuwi/util';
import { naclEncrypt } from '../nacl/index.js';
import { scryptEncode, scryptToU8a } from '../scrypt/index.js';
import { jsonEncryptFormat } from './encryptFormat.js';
export function jsonEncrypt(data, contentType, passphrase) {
let isEncrypted = false;
let encoded = data;
if (passphrase) {
const { params, password, salt } = scryptEncode(passphrase);
const { encrypted, nonce } = naclEncrypt(encoded, password.subarray(0, 32));
isEncrypted = true;
encoded = u8aConcat(scryptToU8a(salt, params), nonce, encrypted);
}
return jsonEncryptFormat(encoded, contentType, isEncrypted);
}
+2
View File
@@ -0,0 +1,2 @@
import type { EncryptedJson } from './types.js';
export declare function jsonEncryptFormat(encoded: Uint8Array, contentType: string[], isEncrypted: boolean): EncryptedJson;
@@ -0,0 +1,14 @@
import { base64Encode } from '../base64/index.js';
import { ENCODING, ENCODING_NONE, ENCODING_VERSION } from './constants.js';
export function jsonEncryptFormat(encoded, contentType, isEncrypted) {
return {
encoded: base64Encode(encoded),
encoding: {
content: contentType,
type: isEncrypted
? ENCODING
: ENCODING_NONE,
version: ENCODING_VERSION
}
};
}
+4
View File
@@ -0,0 +1,4 @@
export { jsonDecrypt } from './decrypt.js';
export { jsonDecryptData } from './decryptData.js';
export { jsonEncrypt } from './encrypt.js';
export { jsonEncryptFormat } from './encryptFormat.js';
+4
View File
@@ -0,0 +1,4 @@
export { jsonDecrypt } from './decrypt.js';
export { jsonDecryptData } from './decryptData.js';
export { jsonEncrypt } from './encrypt.js';
export { jsonEncryptFormat } from './encryptFormat.js';
+16
View File
@@ -0,0 +1,16 @@
export type EncryptedJsonVersion = '0' | '1' | '2' | '3';
export type EncryptedJsonEncoding = 'none' | 'scrypt' | 'xsalsa20-poly1305';
export interface EncryptedJsonDescriptor {
/** Descriptor for the content */
content: string[];
/** The encoding (in current/latest versions this is always an array) */
type: EncryptedJsonEncoding | EncryptedJsonEncoding[];
/** The version of encoding applied */
version: EncryptedJsonVersion;
}
export interface EncryptedJson {
/** The encoded string */
encoded: string;
/** The encoding used */
encoding: EncryptedJsonDescriptor;
}
+1
View File
@@ -0,0 +1 @@
export {};