working rss feed to nostr publish
This commit is contained in:
+35
@@ -0,0 +1,35 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.maxLetterValue = exports.bitsPerByte = exports.bitsPerLetter = exports.alphabetByValue = exports.alphabetByEncoding = void 0;
|
||||
const alphabetByEncoding = {};
|
||||
exports.alphabetByEncoding = alphabetByEncoding;
|
||||
const alphabetByValue = new Array(64);
|
||||
exports.alphabetByValue = alphabetByValue;
|
||||
for (let i = 0, start = "A".charCodeAt(0), limit = "Z".charCodeAt(0); i + start <= limit; i++) {
|
||||
const char = String.fromCharCode(i + start);
|
||||
alphabetByEncoding[char] = i;
|
||||
alphabetByValue[i] = char;
|
||||
}
|
||||
for (let i = 0, start = "a".charCodeAt(0), limit = "z".charCodeAt(0); i + start <= limit; i++) {
|
||||
const char = String.fromCharCode(i + start);
|
||||
const index = i + 26;
|
||||
alphabetByEncoding[char] = index;
|
||||
alphabetByValue[index] = char;
|
||||
}
|
||||
for (let i = 0; i < 10; i++) {
|
||||
alphabetByEncoding[i.toString(10)] = i + 52;
|
||||
const char = i.toString(10);
|
||||
const index = i + 52;
|
||||
alphabetByEncoding[char] = index;
|
||||
alphabetByValue[index] = char;
|
||||
}
|
||||
alphabetByEncoding["+"] = 62;
|
||||
alphabetByValue[62] = "+";
|
||||
alphabetByEncoding["/"] = 63;
|
||||
alphabetByValue[63] = "/";
|
||||
const bitsPerLetter = 6;
|
||||
exports.bitsPerLetter = bitsPerLetter;
|
||||
const bitsPerByte = 8;
|
||||
exports.bitsPerByte = bitsPerByte;
|
||||
const maxLetterValue = 0b111111;
|
||||
exports.maxLetterValue = maxLetterValue;
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.fromBase64 = void 0;
|
||||
const constants_browser_1 = require("./constants.browser");
|
||||
const fromBase64 = (input) => {
|
||||
let totalByteLength = (input.length / 4) * 3;
|
||||
if (input.slice(-2) === "==") {
|
||||
totalByteLength -= 2;
|
||||
}
|
||||
else if (input.slice(-1) === "=") {
|
||||
totalByteLength--;
|
||||
}
|
||||
const out = new ArrayBuffer(totalByteLength);
|
||||
const dataView = new DataView(out);
|
||||
for (let i = 0; i < input.length; i += 4) {
|
||||
let bits = 0;
|
||||
let bitLength = 0;
|
||||
for (let j = i, limit = i + 3; j <= limit; j++) {
|
||||
if (input[j] !== "=") {
|
||||
if (!(input[j] in constants_browser_1.alphabetByEncoding)) {
|
||||
throw new TypeError(`Invalid character ${input[j]} in base64 string.`);
|
||||
}
|
||||
bits |= constants_browser_1.alphabetByEncoding[input[j]] << ((limit - j) * constants_browser_1.bitsPerLetter);
|
||||
bitLength += constants_browser_1.bitsPerLetter;
|
||||
}
|
||||
else {
|
||||
bits >>= constants_browser_1.bitsPerLetter;
|
||||
}
|
||||
}
|
||||
const chunkOffset = (i / 4) * 3;
|
||||
bits >>= bitLength % constants_browser_1.bitsPerByte;
|
||||
const byteLength = Math.floor(bitLength / constants_browser_1.bitsPerByte);
|
||||
for (let k = 0; k < byteLength; k++) {
|
||||
const offset = (byteLength - k - 1) * constants_browser_1.bitsPerByte;
|
||||
dataView.setUint8(chunkOffset + k, (bits & (255 << offset)) >> offset);
|
||||
}
|
||||
}
|
||||
return new Uint8Array(out);
|
||||
};
|
||||
exports.fromBase64 = fromBase64;
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.fromBase64 = void 0;
|
||||
const util_buffer_from_1 = require("@smithy/util-buffer-from");
|
||||
const BASE64_REGEX = /^[A-Za-z0-9+/]*={0,2}$/;
|
||||
const fromBase64 = (input) => {
|
||||
if ((input.length * 3) % 4 !== 0) {
|
||||
throw new TypeError(`Incorrect padding on base64 string.`);
|
||||
}
|
||||
if (!BASE64_REGEX.exec(input)) {
|
||||
throw new TypeError(`Invalid base64 string.`);
|
||||
}
|
||||
const buffer = (0, util_buffer_from_1.fromString)(input, "base64");
|
||||
return new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
||||
};
|
||||
exports.fromBase64 = fromBase64;
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const tslib_1 = require("tslib");
|
||||
tslib_1.__exportStar(require("./fromBase64"), exports);
|
||||
tslib_1.__exportStar(require("./toBase64"), exports);
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.toBase64 = void 0;
|
||||
const constants_browser_1 = require("./constants.browser");
|
||||
function toBase64(input) {
|
||||
let str = "";
|
||||
for (let i = 0; i < input.length; i += 3) {
|
||||
let bits = 0;
|
||||
let bitLength = 0;
|
||||
for (let j = i, limit = Math.min(i + 3, input.length); j < limit; j++) {
|
||||
bits |= input[j] << ((limit - j - 1) * constants_browser_1.bitsPerByte);
|
||||
bitLength += constants_browser_1.bitsPerByte;
|
||||
}
|
||||
const bitClusterCount = Math.ceil(bitLength / constants_browser_1.bitsPerLetter);
|
||||
bits <<= bitClusterCount * constants_browser_1.bitsPerLetter - bitLength;
|
||||
for (let k = 1; k <= bitClusterCount; k++) {
|
||||
const offset = (bitClusterCount - k) * constants_browser_1.bitsPerLetter;
|
||||
str += constants_browser_1.alphabetByValue[(bits & (constants_browser_1.maxLetterValue << offset)) >> offset];
|
||||
}
|
||||
str += "==".slice(0, 4 - bitClusterCount);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
exports.toBase64 = toBase64;
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.toBase64 = void 0;
|
||||
const util_buffer_from_1 = require("@smithy/util-buffer-from");
|
||||
const toBase64 = (input) => (0, util_buffer_from_1.fromArrayBuffer)(input.buffer, input.byteOffset, input.byteLength).toString("base64");
|
||||
exports.toBase64 = toBase64;
|
||||
Reference in New Issue
Block a user