forked from Kieran/void.cat
Fix package
This commit is contained in:
parent
22c238b704
commit
076e83626b
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@void-cat/api",
|
"name": "@void-cat/api",
|
||||||
"version": "1.0.5",
|
"version": "1.0.7",
|
||||||
"description": "void.cat API package",
|
"description": "void.cat API package",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
|
@ -9,9 +9,9 @@ import {
|
|||||||
SiteInfoResponse,
|
SiteInfoResponse,
|
||||||
VoidFileResponse
|
VoidFileResponse
|
||||||
} from "./index";
|
} from "./index";
|
||||||
import {ProgressHandler, ProxyChallengeHandler, StateChangeHandler, VoidUploader} from "./Upload";
|
import { ProgressHandler, ProxyChallengeHandler, StateChangeHandler, VoidUploader } from "./upload";
|
||||||
import {StreamUploader} from "./StreamUploader";
|
import { StreamUploader } from "./stream-uploader";
|
||||||
import {XHRUploader} from "./XHRUploader";
|
import { XHRUploader } from "./xhr-uploader";
|
||||||
|
|
||||||
export class VoidApi {
|
export class VoidApi {
|
||||||
readonly #uri: string
|
readonly #uri: string
|
||||||
@ -88,11 +88,11 @@ export class VoidApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
login(username: string, password: string, captcha?: string) {
|
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) {
|
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) {
|
getUser(id: string) {
|
||||||
@ -108,7 +108,7 @@ export class VoidApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
submitVerifyCode(uid: string, code: string) {
|
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) {
|
sendNewCode(uid: string) {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import {VoidUploadResult} from "./index";
|
import { VoidUploadResult } from "./index";
|
||||||
import sjcl from "sjcl";
|
import sjcl from "sjcl";
|
||||||
import {sjclcodec} from "./codecBytes";
|
import { sjclcodec } from "./codecBytes";
|
||||||
import {buf2hex} from "./Util";
|
import { buf2hex } from "./utils";
|
||||||
/**
|
/**
|
||||||
* Generic upload state
|
* Generic upload state
|
||||||
*/
|
*/
|
||||||
|
@ -14,9 +14,9 @@ export const sjclcodec = {
|
|||||||
/** Convert from a bitArray to an array of bytes. */
|
/** Convert from a bitArray to an array of bytes. */
|
||||||
fromBits: function (arr) {
|
fromBits: function (arr) {
|
||||||
var out = [], bl = sjcl.bitArray.bitLength(arr), i, tmp;
|
var out = [], bl = sjcl.bitArray.bitLength(arr), i, tmp;
|
||||||
for (i=0; i<bl/8; i++) {
|
for (i = 0; i < bl / 8; i++) {
|
||||||
if ((i&3) === 0) {
|
if ((i & 3) === 0) {
|
||||||
tmp = arr[i/4];
|
tmp = arr[i / 4];
|
||||||
}
|
}
|
||||||
out.push(tmp >>> 24);
|
out.push(tmp >>> 24);
|
||||||
tmp <<= 8;
|
tmp <<= 8;
|
||||||
@ -26,16 +26,16 @@ export const sjclcodec = {
|
|||||||
/** Convert from an array of bytes to a bitArray. */
|
/** Convert from an array of bytes to a bitArray. */
|
||||||
/** @return {bitArray} */
|
/** @return {bitArray} */
|
||||||
toBits: function (bytes) {
|
toBits: function (bytes) {
|
||||||
var out = [], i, tmp=0;
|
var out = [], i, tmp = 0;
|
||||||
for (i=0; i<bytes.length; i++) {
|
for (i = 0; i < bytes.length; i++) {
|
||||||
tmp = tmp << 8 | bytes[i];
|
tmp = tmp << 8 | bytes[i];
|
||||||
if ((i&3) === 3) {
|
if ((i & 3) === 3) {
|
||||||
out.push(tmp);
|
out.push(tmp);
|
||||||
tmp = 0;
|
tmp = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (i&3) {
|
if (i & 3) {
|
||||||
out.push(sjcl.bitArray.partial(8*(i&3), tmp));
|
out.push(sjcl.bitArray.partial(8 * (i & 3), tmp));
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
export {VoidApi} from "./Api"
|
export { VoidApi } from "./api"
|
||||||
export {UploadState} from "./Upload";
|
export { UploadState } from "./upload";
|
||||||
export {StreamEncryption} from "./StreamEncryption";
|
export { StreamEncryption } from "./stream-encryption";
|
||||||
|
|
||||||
export class ApiError extends Error {
|
export class ApiError extends Error {
|
||||||
readonly statusCode: number
|
readonly statusCode: number
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import {sjclcodec} from "./codecBytes";
|
import { sjclcodec } from "./codecBytes";
|
||||||
import sjcl, {SjclCipher} from "sjcl";
|
import sjcl, { SjclCipher } from "sjcl";
|
||||||
|
|
||||||
import {buf2hex} from "Util";
|
import { buf2hex } from "./utils";
|
||||||
|
|
||||||
interface EncryptionParams {
|
interface EncryptionParams {
|
||||||
ts: number,
|
ts: number,
|
@ -1,6 +1,6 @@
|
|||||||
import {UploadState, VoidUploader} from "./Upload";
|
import { UploadState, VoidUploader } from "./upload";
|
||||||
import {VoidUploadResult} from "./index";
|
import { VoidUploadResult } from "./index";
|
||||||
import {StreamEncryption} from "./StreamEncryption";
|
import { StreamEncryption } from "./stream-encryption";
|
||||||
|
|
||||||
export class StreamUploader extends VoidUploader {
|
export class StreamUploader extends VoidUploader {
|
||||||
#encrypt?: StreamEncryption;
|
#encrypt?: StreamEncryption;
|
@ -1,5 +1,5 @@
|
|||||||
import {UploadState, VoidUploader} from "./Upload";
|
import { UploadState, VoidUploader } from "./upload";
|
||||||
import {VoidUploadResult} from "./index";
|
import { VoidUploadResult } from "./index";
|
||||||
|
|
||||||
export class XHRUploader extends VoidUploader {
|
export class XHRUploader extends VoidUploader {
|
||||||
canEncrypt(): boolean {
|
canEncrypt(): boolean {
|
||||||
@ -49,7 +49,7 @@ export class XHRUploader extends VoidUploader {
|
|||||||
* @param headers
|
* @param headers
|
||||||
*/
|
*/
|
||||||
async #xhrSegment(segment: ArrayBuffer | Blob, fullDigest: string,
|
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);
|
this.onStateChange?.(UploadState.Uploading);
|
||||||
|
|
||||||
return await new Promise<VoidUploadResult>((resolve, reject) => {
|
return await new Promise<VoidUploadResult>((resolve, reject) => {
|
Loading…
Reference in New Issue
Block a user