Fix package

This commit is contained in:
Kieran 2023-07-20 12:31:07 +01:00
parent 22c238b704
commit 076e83626b
Signed by: Kieran
GPG Key ID: DE71CEB3925BE941
9 changed files with 30 additions and 30 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@void-cat/api",
"version": "1.0.5",
"version": "1.0.7",
"description": "void.cat API package",
"main": "dist/index.js",
"types": "dist/index.d.ts",

View File

@ -9,9 +9,9 @@ import {
SiteInfoResponse,
VoidFileResponse
} from "./index";
import {ProgressHandler, ProxyChallengeHandler, StateChangeHandler, VoidUploader} from "./Upload";
import {StreamUploader} from "./StreamUploader";
import {XHRUploader} from "./XHRUploader";
import { ProgressHandler, ProxyChallengeHandler, StateChangeHandler, VoidUploader } from "./upload";
import { StreamUploader } from "./stream-uploader";
import { XHRUploader } from "./xhr-uploader";
export class VoidApi {
readonly #uri: string
@ -88,11 +88,11 @@ export class VoidApi {
}
login(username: string, password: string, captcha?: string) {
return this.#req<LoginSession>("POST", `/auth/login`, {username, password, captcha});
return this.#req<LoginSession>("POST", `/auth/login`, { username, password, captcha });
}
register(username: string, password: string, captcha?: string) {
return this.#req<LoginSession>("POST", `/auth/register`, {username, password, captcha});
return this.#req<LoginSession>("POST", `/auth/register`, { username, password, captcha });
}
getUser(id: string) {
@ -108,7 +108,7 @@ export class VoidApi {
}
submitVerifyCode(uid: string, code: string) {
return this.#req<void>("POST", `/user/${uid}/verify`, {code});
return this.#req<void>("POST", `/user/${uid}/verify`, { code });
}
sendNewCode(uid: string) {

View File

@ -1,7 +1,7 @@
import {VoidUploadResult} from "./index";
import { VoidUploadResult } from "./index";
import sjcl from "sjcl";
import {sjclcodec} from "./codecBytes";
import {buf2hex} from "./Util";
import { sjclcodec } from "./codecBytes";
import { buf2hex } from "./utils";
/**
* Generic upload state
*/

View File

@ -14,9 +14,9 @@ export const sjclcodec = {
/** Convert from a bitArray to an array of bytes. */
fromBits: function (arr) {
var out = [], bl = sjcl.bitArray.bitLength(arr), i, tmp;
for (i=0; i<bl/8; i++) {
if ((i&3) === 0) {
tmp = arr[i/4];
for (i = 0; i < bl / 8; i++) {
if ((i & 3) === 0) {
tmp = arr[i / 4];
}
out.push(tmp >>> 24);
tmp <<= 8;
@ -26,16 +26,16 @@ export const sjclcodec = {
/** Convert from an array of bytes to a bitArray. */
/** @return {bitArray} */
toBits: function (bytes) {
var out = [], i, tmp=0;
for (i=0; i<bytes.length; i++) {
var out = [], i, tmp = 0;
for (i = 0; i < bytes.length; i++) {
tmp = tmp << 8 | bytes[i];
if ((i&3) === 3) {
if ((i & 3) === 3) {
out.push(tmp);
tmp = 0;
}
}
if (i&3) {
out.push(sjcl.bitArray.partial(8*(i&3), tmp));
if (i & 3) {
out.push(sjcl.bitArray.partial(8 * (i & 3), tmp));
}
return out;
}

View File

@ -1,6 +1,6 @@
export {VoidApi} from "./Api"
export {UploadState} from "./Upload";
export {StreamEncryption} from "./StreamEncryption";
export { VoidApi } from "./api"
export { UploadState } from "./upload";
export { StreamEncryption } from "./stream-encryption";
export class ApiError extends Error {
readonly statusCode: number

View File

@ -1,7 +1,7 @@
import {sjclcodec} from "./codecBytes";
import sjcl, {SjclCipher} from "sjcl";
import { sjclcodec } from "./codecBytes";
import sjcl, { SjclCipher } from "sjcl";
import {buf2hex} from "Util";
import { buf2hex } from "./utils";
interface EncryptionParams {
ts: number,

View File

@ -1,6 +1,6 @@
import {UploadState, VoidUploader} from "./Upload";
import {VoidUploadResult} from "./index";
import {StreamEncryption} from "./StreamEncryption";
import { UploadState, VoidUploader } from "./upload";
import { VoidUploadResult } from "./index";
import { StreamEncryption } from "./stream-encryption";
export class StreamUploader extends VoidUploader {
#encrypt?: StreamEncryption;

View File

@ -1,5 +1,5 @@
import {UploadState, VoidUploader} from "./Upload";
import {VoidUploadResult} from "./index";
import { UploadState, VoidUploader } from "./upload";
import { VoidUploadResult } from "./index";
export class XHRUploader extends VoidUploader {
canEncrypt(): boolean {
@ -49,7 +49,7 @@ export class XHRUploader extends VoidUploader {
* @param headers
*/
async #xhrSegment(segment: ArrayBuffer | Blob, fullDigest: string,
id?: string, editSecret?: string, part?: number, partOf?: number, headers?: HeadersInit) {
id?: string, editSecret?: string, part?: number, partOf?: number, headers?: HeadersInit) {
this.onStateChange?.(UploadState.Uploading);
return await new Promise<VoidUploadResult>((resolve, reject) => {