/* * This file is part of paste. * Copyright (c) 2022 Joe Ma * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ import {AwsClient} from 'aws4fetch'; import {customAlphabet} from 'nanoid'; import {sha256} from 'js-sha256'; import dedent from 'dedent-js'; // Constants const SERVICE_URL = 'pb.nekoul.com'; const PASTE_INDEX_HTML_URL = 'https://raw.githubusercontent.com/rikkaneko/paste/main/paste.html'; const UUID_LENGTH = 4; export interface Env { PASTE_INDEX: KVNamespace; QRCODE: ServiceWorkerGlobalScope; AWS_ACCESS_KEY_ID: string; AWS_SECRET_ACCESS_KEY: string; ENDPOINT: string; } const API_SPEC_TEXT = `Paste service https://${SERVICE_URL} [API Specification] GET / Fetch the Web frontpage for uploading text/file [x] GET /api Fetch API specification # Authentication support HTTP Basic access authentication (RFC 7617) or the x-pass header GET / Fetch the paste by uuid [x] # Currently, only the following options is supported for