Deno lint

This commit is contained in:
Roj Serbest 2021-11-18 15:01:55 +03:00
parent 51a4903331
commit 8e8ab7cc81
13 changed files with 121 additions and 104 deletions

View File

@ -62,7 +62,7 @@ for (const typ of types) {
for (const param of typ.parameters) { for (const param of typ.parameters) {
typs += `// ${param.description}\n`; typs += `// ${param.description}\n`;
typs += `${param.name}`; typs += `"${param.name}"`;
if (!param.required) { if (!param.required) {
typs += "?"; typs += "?";

View File

@ -20,6 +20,7 @@ export class BaseClient {
) { ) {
} }
// deno-lint-ignore require-await
async getCDNEndpoint(): Promise<string> { async getCDNEndpoint(): Promise<string> {
throw new Error("Not implemented"); throw new Error("Not implemented");
} }
@ -88,7 +89,7 @@ export class BaseClient {
return stream ? await response.blob() : await response.arrayBuffer(); return stream ? await response.blob() : await response.arrayBuffer();
} }
async send(data: any) { async send(data: string) {
return await ( return await (
await fetch(this.rpcEndpoint, { await fetch(this.rpcEndpoint, {
method: "POST", method: "POST",

View File

@ -7,9 +7,11 @@ export const isBrowser = typeof Deno === "undefined";
export const os = isBrowser ? "Browser" : Deno.build.os; export const os = isBrowser ? "Browser" : Deno.build.os;
export const writeTextFileSync = isBrowser ? (...args: any) => {} : Deno.writeTextFileSync; // deno-lint-ignore no-explicit-any
export const writeTextFileSync = isBrowser ? (..._args: any) => {} : Deno.writeTextFileSync;
export const readTextFileSync = isBrowser ? (...args: any) => "" : Deno.readTextFileSync; // deno-lint-ignore no-explicit-any
export const readTextFileSync = isBrowser ? (..._args: any) => "" : Deno.readTextFileSync;
export const getRandomValues = (size: number) => { export const getRandomValues = (size: number) => {
return crypto.getRandomValues(new Uint8Array(size)).buffer; return crypto.getRandomValues(new Uint8Array(size)).buffer;

View File

@ -6,9 +6,9 @@ import jsSHA from "jssha";
import fetch from "node-fetch"; import fetch from "node-fetch";
import FormData from "form-data"; import FormData from "form-data";
// @ts-ignore // @ts-ignore: Node-side error
globalThis.fetch = fetch; globalThis.fetch = fetch;
// @ts-ignore // @ts-ignore: Node-side error
globalThis.FormData = FormData; globalThis.FormData = FormData;
export const isBrowser = typeof window !== "undefined"; export const isBrowser = typeof window !== "undefined";

View File

@ -8,6 +8,7 @@ export class CDN extends MethodBase {
* *
* @param document The file, it can be a buffer or a readable stream. * @param document The file, it can be a buffer or a readable stream.
*/ */
// deno-lint-ignore no-explicit-any
async upload(document: any): Promise<Document> { async upload(document: any): Promise<Document> {
const form = formFromObj({ const form = formFromObj({
action: "upload", action: "upload",

View File

@ -3,6 +3,7 @@ export class Request {
constructor( constructor(
public method: string, public method: string,
// deno-lint-ignore no-explicit-any
public params?: any, public params?: any,
public notification = false, public notification = false,
) { ) {

View File

@ -5,6 +5,7 @@ export class Response {
success: boolean; success: boolean;
error?: { code: number; message: string }; error?: { code: number; message: string };
// deno-lint-ignore no-explicit-any
constructor(public data: any) { constructor(public data: any) {
if (!this.data.id) { if (!this.data.id) {
throw new Error(`Got invalid data: ${data}`); throw new Error(`Got invalid data: ${data}`);

View File

@ -3,6 +3,7 @@ import { Store } from "./store.ts";
import { readTextFileSync, writeTextFileSync } from "../deps.deno.ts"; import { readTextFileSync, writeTextFileSync } from "../deps.deno.ts";
export class FileStore extends Store { export class FileStore extends Store {
// deno-lint-ignore no-explicit-any
data: { [key: string]: any }; data: { [key: string]: any };
constructor(public readonly file: string) { constructor(public readonly file: string) {
@ -21,6 +22,7 @@ export class FileStore extends Store {
} }
} }
// deno-lint-ignore no-explicit-any
set(key: string, value: any) { set(key: string, value: any) {
this.data[key] = value; this.data[key] = value;
} }

View File

@ -1,6 +1,7 @@
import { IS_BROWSER } from "../constants.ts"; import { IS_BROWSER } from "../constants.ts";
import { Store } from "./store.ts"; import { Store } from "./store.ts";
// deno-lint-ignore no-explicit-any
function resolveToBeSet(toBeSet: any) { function resolveToBeSet(toBeSet: any) {
return JSON.stringify(toBeSet); return JSON.stringify(toBeSet);
} }
@ -22,6 +23,7 @@ export class LocalStorageStore extends Store {
return key + this.id; return key + this.id;
} }
// deno-lint-ignore no-explicit-any
set(key: string, value: any) { set(key: string, value: any) {
localStorage.setItem(this.resolveKey(key), resolveToBeSet(value)); localStorage.setItem(this.resolveKey(key), resolveToBeSet(value));
} }

View File

@ -1,6 +1,7 @@
import { Store } from "./store.ts"; import { Store } from "./store.ts";
export class MemoryStore extends Store { export class MemoryStore extends Store {
// deno-lint-ignore no-explicit-any
private data: { [key: string]: any }; private data: { [key: string]: any };
constructor() { constructor() {
@ -8,6 +9,7 @@ export class MemoryStore extends Store {
this.data = {}; this.data = {};
} }
// deno-lint-ignore no-explicit-any
set(key: string, value: any) { set(key: string, value: any) {
this.data[key] = value; this.data[key] = value;
} }

View File

@ -1,5 +1,7 @@
export abstract class Store { export abstract class Store {
// deno-lint-ignore no-explicit-any
abstract set(key: string, value: any): void; abstract set(key: string, value: any): void;
// deno-lint-ignore no-explicit-any
abstract get(key: string): any; abstract get(key: string): any;
abstract delete(key: string): void; abstract delete(key: string): void;
abstract save(): void; abstract save(): void;

View File

@ -1,259 +1,259 @@
// This object describes the size of a display picture followed by a document object that results in said display picture size. // This object describes the size of a display picture followed by a document object that results in said display picture size.
export interface DisplayPictureSize { export interface DisplayPictureSize {
// The width of the image // The width of the image
width: number; "width": number;
// The height of the image // The height of the image
height: number; "height": number;
// The document object that points to the display picture // The document object that points to the display picture
document: Document; "document": Document;
} }
// A document object contains basic information about the file associated with the document and the document ID used to retrieve the document from the CDN Server // A document object contains basic information about the file associated with the document and the document ID used to retrieve the document from the CDN Server
export interface Document { export interface Document {
// The ID of the document // The ID of the document
id: string; "id": string;
// The Mime of the file // The Mime of the file
file_mime: string; "file_mime": string;
// The original name of the file // The original name of the file
file_name: string; "file_name": string;
// The size of the file in bytes // The size of the file in bytes
file_size: number; "file_size": number;
// The type of file detected by the server // The type of file detected by the server
file_type: string; "file_type": string;
// An array of flags associated with this document // An array of flags associated with this document
flags: string[]; "flags": string[];
} }
// The object ErrorDefinition contains information about an error that the server is capable of returning if a method fails to execute. // The object ErrorDefinition contains information about an error that the server is capable of returning if a method fails to execute.
export interface ErrorDefinition { export interface ErrorDefinition {
// The ID of the ErrorDefinition, which is a crc32 hash of the following value; <ProtocolVersion>:<ErrorName>:<ErrorCode> (1.0:InternalServerError:16384) // The ID of the ErrorDefinition, which is a crc32 hash of the following value; <ProtocolVersion>:<ErrorName>:<ErrorCode> (1.0:InternalServerError:16384)
id: string; "id": string;
// The name of the error, this is a unique value. // The name of the error, this is a unique value.
name: string; "name": string;
// A description of the error // A description of the error
description: string; "description": string;
// The error code, this is a unique value. // The error code, this is a unique value.
error_code: number; "error_code": number;
} }
// A help document is often retrieved from the server as a way to represent a document to the user for multiple purposes, from quick guides to server announcements or the legal documents required to be shown to the user before they register an account to the network. // A help document is often retrieved from the server as a way to represent a document to the user for multiple purposes, from quick guides to server announcements or the legal documents required to be shown to the user before they register an account to the network.
export interface HelpDocument { export interface HelpDocument {
// The ID of the document, if the document gets updated then the ID will change // The ID of the document, if the document gets updated then the ID will change
id: string; "id": string;
// The text contents of the document // The text contents of the document
text: string; "text": string;
// An array of text entities being represented in the text // An array of text entities being represented in the text
entities: TextEntity[]; "entities": TextEntity[];
} }
// The object MethodDefinition contains information about method, namespace, permission requirements and the parameters it accepts // The object MethodDefinition contains information about method, namespace, permission requirements and the parameters it accepts
export interface MethodDefinition { export interface MethodDefinition {
// A crc32 hash of the methods's ID following the value; <ProtocolVersion>:<MethodName> eg; 1.0:timelime.compose // A crc32 hash of the methods's ID following the value; <ProtocolVersion>:<MethodName> eg; 1.0:timelime.compose
id: string; "id": string;
// The namespace of the method e.g., timeline, network, etc. // The namespace of the method e.g., timeline, network, etc.
namespace: string; "namespace": string;
// The name of the method without the namespace compose, like, repost, etc. // The name of the method without the namespace compose, like, repost, etc.
method_name: string; "method_name": string;
// The full name of the method with the leading namespace e.g. timeline.compose, timeline.like // The full name of the method with the leading namespace e.g. timeline.compose, timeline.like
method: string; "method": string;
// The description of the method // The description of the method
description: string; "description": string;
// The array of permission requirements for this method // The array of permission requirements for this method
permission_requirements: string[]; "permission_requirements": string[];
// An array of possible return types // An array of possible return types
return_types: TypeDefinition[]; "return_types": TypeDefinition[];
} }
// The object ObjectDefinition explains the structure of a object that the server could return or work with. // The object ObjectDefinition explains the structure of a object that the server could return or work with.
export interface ObjectDefinition { export interface ObjectDefinition {
// A crc32 hash of the object's ID following the value; <ProtocolVersion>:<ObjectName> eg; 1.0:Peer // A crc32 hash of the object's ID following the value; <ProtocolVersion>:<ObjectName> eg; 1.0:Peer
id: string; "id": string;
// The name of the object // The name of the object
name: string; "name": string;
// A description of the object // A description of the object
description: string; "description": string;
// An array of ParameterDefinitions explaining the object structure // An array of ParameterDefinitions explaining the object structure
parameters: ParameterDefinition[]; "parameters": ParameterDefinition[];
} }
// The object ParameterDefinition contains information about the parameters used and or available, usually represented within an array; this object indicates the availabe types, name, description and requirement of the parameter. This can be applied to object property structures or method parameters // The object ParameterDefinition contains information about the parameters used and or available, usually represented within an array; this object indicates the availabe types, name, description and requirement of the parameter. This can be applied to object property structures or method parameters
export interface ParameterDefinition { export interface ParameterDefinition {
// The name of the parameter // The name of the parameter
name: string; "name": string;
// An array of types that are used for this parameter // An array of types that are used for this parameter
types: TypeDefinition[]; "types": TypeDefinition[];
// Indicates if this parameter is required or not, for objects this will always be true. // Indicates if this parameter is required or not, for objects this will always be true.
required: boolean; "required": boolean;
// The description of the parameter // The description of the parameter
description: string; "description": string;
} }
// A peer object provides a basic description and identification a peer entity that can contain information used to identify a peer on the client or basic flags and properties of the peer to pre-determine what actions are available for a peer. // A peer object provides a basic description and identification a peer entity that can contain information used to identify a peer on the client or basic flags and properties of the peer to pre-determine what actions are available for a peer.
export interface Peer { export interface Peer {
// The ID of the document, if the document gets updated then the ID will change // The ID of the document, if the document gets updated then the ID will change
id: string; "id": string;
// The type of the peer entity // The type of the peer entity
type: string; "type": string;
// The display name of the peer // The display name of the peer
name: string; "name": string;
// The username associated with this peer // The username associated with this peer
username: string; "username": string;
// Flags associated with this peer // Flags associated with this peer
flags: string[]; "flags": string[];
} }
// A post object is used to represent a post submitted either by a peer, this object can contain recursive objects. // A post object is used to represent a post submitted either by a peer, this object can contain recursive objects.
export interface Post { export interface Post {
// The unique ID for the post // The unique ID for the post
id: string; "id": string;
// The post type used to represent the true intention of the post // The post type used to represent the true intention of the post
type: string; "type": string;
// The author peer of the post, this property can be null if the post was deleted. // The author peer of the post, this property can be null if the post was deleted.
peer: Peer | null; "peer": Peer | null;
// The source for where this post was composed from or collected from (eg; the client the user is using or the third-party source that the post was collected. This is determined by the server). This property can be null if the post was deleted. // The source for where this post was composed from or collected from (eg; the client the user is using or the third-party source that the post was collected. This is determined by the server). This property can be null if the post was deleted.
source: string | null; "source": string | null;
// The text content of the post source. This property can be null if the post has been deleted // The text content of the post source. This property can be null if the post has been deleted
text: string | null; "text": string | null;
// An array of attached documents to the post // An array of attached documents to the post
attachments: Document[]; "attachments": Document[];
// An array of entities extracted from the text, can be used by the client to highlight clickable entities that preforms an action. // An array of entities extracted from the text, can be used by the client to highlight clickable entities that preforms an action.
entities: TextEntity[]; "entities": TextEntity[];
// An array of resolved peers that was mentioned in the post text. // An array of resolved peers that was mentioned in the post text.
mentioned_peers: Peer[]; "mentioned_peers": Peer[];
// The original post that this post is replying to if applicable, otherwise null. // The original post that this post is replying to if applicable, otherwise null.
reply_to_post: Post | null; "reply_to_post": Post | null;
// The original post that this post is quoting if applicable, otherwise null // The original post that this post is quoting if applicable, otherwise null
quoted_post: Post | null; "quoted_post": Post | null;
// The original post that this post is reposting if applicable, otherwise null // The original post that this post is reposting if applicable, otherwise null
reposted_post: Post | null; "reposted_post": Post | null;
// The original thread post, only applicable to replies. This value indicates the main thread post where all the replies originated from. This value will remain the same for all sub-replies of the main post. // The original thread post, only applicable to replies. This value indicates the main thread post where all the replies originated from. This value will remain the same for all sub-replies of the main post.
original_thread_post: Post | null; "original_thread_post": Post | null;
// The amount of likes that this post has if applicable, otherwise null // The amount of likes that this post has if applicable, otherwise null
like_count: number | null; "like_count": number | null;
// The amount of repost that this post has if applicable, otherwise null // The amount of repost that this post has if applicable, otherwise null
repost_count: number | null; "repost_count": number | null;
// The amount of quoted posts that this post has if applicable, otherwise null // The amount of quoted posts that this post has if applicable, otherwise null
quote_count: number | null; "quote_count": number | null;
// The amount of replies that this post has if applicable, otherwise null // The amount of replies that this post has if applicable, otherwise null
reply_count: number | null; "reply_count": number | null;
// The Unix Timestamp for when this post was created // The Unix Timestamp for when this post was created
posted_timestamp: number; "posted_timestamp": number;
// The flags associated with this post // The flags associated with this post
flags: string[]; "flags": string[];
} }
// The profile object provides a profile display for a peer entity, this is mainly used to represent a "Profile" display of a peer. // The profile object provides a profile display for a peer entity, this is mainly used to represent a "Profile" display of a peer.
export interface Profile { export interface Profile {
// The first name of the entity // The first name of the entity
first_name: string; "first_name": string;
// The last name of the entity // The last name of the entity
last_name: string | null; "last_name": string | null;
// The full display name of the entity // The full display name of the entity
name: string; "name": string;
// A biography or description of the entity // A biography or description of the entity
biography: string | null; "biography": string | null;
// The location of the entity // The location of the entity
location: string | null; "location": string | null;
// The URL of the entity (Can be a website or a blog, etc) // The URL of the entity (Can be a website or a blog, etc)
url: string | null; "url": string | null;
// The amount of followers that this entity has // The amount of followers that this entity has
followers_count: number; "followers_count": number;
// The amount of peers that this entity is following // The amount of peers that this entity is following
following_count: number; "following_count": number;
// An array of display picture size objects that represents the entity's display picture // An array of display picture size objects that represents the entity's display picture
display_picture_sizes: DisplayPictureSize[]; "display_picture_sizes": DisplayPictureSize[];
} }
// The ProtocolDefinitions object contains object definitions of what the server's version of the protocol has defined and what their use cases are. Much like a documentation representation in a object structure that can be understood by clients which allows for constructors during runtime. // The ProtocolDefinitions object contains object definitions of what the server's version of the protocol has defined and what their use cases are. Much like a documentation representation in a object structure that can be understood by clients which allows for constructors during runtime.
export interface ProtocolDefinitions { export interface ProtocolDefinitions {
// The version of the protocol being used by the server, eg; 1.0 // The version of the protocol being used by the server, eg; 1.0
version: string; "version": string;
// A list of error definitions defined by the server and protocol with their respective error codes and descriptions // A list of error definitions defined by the server and protocol with their respective error codes and descriptions
errors: ErrorDefinition[]; "errors": ErrorDefinition[];
// A list of object definitions defined by the server and protocol with their respective descriptions, names and parameters. // A list of object definitions defined by the server and protocol with their respective descriptions, names and parameters.
objects: ObjectDefinition[]; "objects": ObjectDefinition[];
// A list of method definitions defined by the server and protocol with their respective descriptions, names and parameters. // A list of method definitions defined by the server and protocol with their respective descriptions, names and parameters.
methods: MethodDefinition[]; "methods": MethodDefinition[];
} }
// The ServerInformation object is a simple object that gives details about the server's attributes and limits or location of other servers that the client should communicate to for other purposes such as a CDN. // The ServerInformation object is a simple object that gives details about the server's attributes and limits or location of other servers that the client should communicate to for other purposes such as a CDN.
export interface ServerInformation { export interface ServerInformation {
// The name of the network, eg; "Socialvoid" // The name of the network, eg; "Socialvoid"
network_name: string; "network_name": string;
// The version of the protocol standard that the server is using, eg; "1.0" // The version of the protocol standard that the server is using, eg; "1.0"
protocol_version: string; "protocol_version": string;
// The HTTP URL Endpoint for the CDN server of the network // The HTTP URL Endpoint for the CDN server of the network
cdn_server: string; "cdn_server": string;
// The maximum size of a file that you can upload to the CDN Server (in bytes) // The maximum size of a file that you can upload to the CDN Server (in bytes)
upload_max_file_size: number; "upload_max_file_size": number;
// The maximum time-to-live (in seconds) that an unauthorized session may have. The server will often reset the expiration whenever the session is used. // The maximum time-to-live (in seconds) that an unauthorized session may have. The server will often reset the expiration whenever the session is used.
unauthorized_session_ttl: number; "unauthorized_session_ttl": number;
// The maximum time-to-live (in seconds) that an authorized session may have. The server will often reset the expiration whenever the session is used. // The maximum time-to-live (in seconds) that an authorized session may have. The server will often reset the expiration whenever the session is used.
authorized_session_ttl: number; "authorized_session_ttl": number;
// The maximum amount of likes a client can retrieve at once using the method timeline.get_likes via the page parameter // The maximum amount of likes a client can retrieve at once using the method timeline.get_likes via the page parameter
retrieve_likes_max_limit: number; "retrieve_likes_max_limit": number;
// The maximum amount of reposts a client can retrieve at once using the method timeline.get_reposted_peers via the page parameter // The maximum amount of reposts a client can retrieve at once using the method timeline.get_reposted_peers via the page parameter
retrieve_reposts_max_limit: number; "retrieve_reposts_max_limit": number;
// The maximum amount of replies a client can retrieve at once using the method timeline.get_replies via the page parameter // The maximum amount of replies a client can retrieve at once using the method timeline.get_replies via the page parameter
retrieve_replies_max_limit: number; "retrieve_replies_max_limit": number;
// The maximum amount of quotes a client can retrieve at once using the method timeline.get_quotes via the page parameter // The maximum amount of quotes a client can retrieve at once using the method timeline.get_quotes via the page parameter
retrieve_quotes_max_limit: number; "retrieve_quotes_max_limit": number;
// The maximum amount of followers a client can retrieve at once using the method network.get_followers via the page parameter // The maximum amount of followers a client can retrieve at once using the method network.get_followers via the page parameter
retrieve_followers_max_limit: number; "retrieve_followers_max_limit": number;
// The maximum amount of following peers a client can retrieve at once using the method network.get_following via the page parameter // The maximum amount of following peers a client can retrieve at once using the method network.get_following via the page parameter
retrieve_following_max_limit: number; "retrieve_following_max_limit": number;
// The amount of posts a client can retrieve at once using the method timeline.retrieve_feed via the page parameter // The amount of posts a client can retrieve at once using the method timeline.retrieve_feed via the page parameter
retrieve_feed_max_limit: number; "retrieve_feed_max_limit": number;
} }
// A session object is contains basic information about the session. // A session object is contains basic information about the session.
export interface Session { export interface Session {
// The ID of the session obtained when establishing a session // The ID of the session obtained when establishing a session
id: string; "id": string;
// An array of flags that has been set to this session // An array of flags that has been set to this session
flags: string[]; "flags": string[];
// An array of permission sets that has been set to this session // An array of permission sets that has been set to this session
permissions: string[]; "permissions": string[];
// Indicates if the session is currently authenticated to a user // Indicates if the session is currently authenticated to a user
authenticated: boolean; "authenticated": boolean;
// The Unix Timestamp for when this session was first created // The Unix Timestamp for when this session was first created
created: number; "created": number;
// The Unix Timestamp for when this session expires // The Unix Timestamp for when this session expires
expires: number; "expires": number;
} }
// A SessionEstablished object is returned when you create a session. This object returns basic information about the session that the server has created for you. // A SessionEstablished object is returned when you create a session. This object returns basic information about the session that the server has created for you.
export interface SessionEstablished { export interface SessionEstablished {
// The ID of the session obtained when establishing a session // The ID of the session obtained when establishing a session
id: string; "id": string;
// The TOTP based challenge secret // The TOTP based challenge secret
challenge: string[]; "challenge": string[];
} }
// A SessionIdentification object allows your client to identify the session it's using and prove that it is the owner of the session, it proves as a identification effort and security effort. // A SessionIdentification object allows your client to identify the session it's using and prove that it is the owner of the session, it proves as a identification effort and security effort.
export interface SessionIdentification { export interface SessionIdentification {
// The ID of the session obtained when establishing a session // The ID of the session obtained when establishing a session
id: string; "id": string;
// The TOTP based challenge secret // The TOTP based challenge secret
challenge: string[]; "challenge": string[];
} }
// The text entity object describes the text type, this is useful for clients to render the given text correctly. For example a "@mention" will have a TextEntity with the value mention. So that the client can perform an action when this entity is clicked. // The text entity object describes the text type, this is useful for clients to render the given text correctly. For example a "@mention" will have a TextEntity with the value mention. So that the client can perform an action when this entity is clicked.
export interface TextEntity { export interface TextEntity {
// The text entity type // The text entity type
type: string; "type": string;
// The offset for when the entity begins in the text // The offset for when the entity begins in the text
offset: number; "offset": number;
// The length of the entity // The length of the entity
length: number; "length": number;
// The value of the entity, for styling entities such as BOLD, ITALIC, etc. this value will be null, but for values such as MENTION, HASHTAG & URL the value will contain the respective value for the entity, for example a URL entity will contain a value of a http URL // The value of the entity, for styling entities such as BOLD, ITALIC, etc. this value will be null, but for values such as MENTION, HASHTAG & URL the value will contain the respective value for the entity, for example a URL entity will contain a value of a http URL
value: string | null; "value": string | null;
} }
// The object TypeDefinition contains information about the defined type, the vector property can indicate if the type is being represented is a vector (list/array) and should be iterated // The object TypeDefinition contains information about the defined type, the vector property can indicate if the type is being represented is a vector (list/array) and should be iterated
export interface TypeDefinition { export interface TypeDefinition {
// The type of the value, can either be a builtin type or one of the pre-defined object being represented as a string, eg; string, Peer, null // The type of the value, can either be a builtin type or one of the pre-defined object being represented as a string, eg; string, Peer, null
type: string; "type": string;
// An array of types that are used for this parameterIndicates if the type is represented as a vector or not (List/Array) // An array of types that are used for this parameterIndicates if the type is represented as a vector or not (List/Array)
vector: boolean; "vector": boolean;
} }

View File

@ -33,6 +33,7 @@ export function answerChallenge(clientPrivateHash: string, challenge: string) {
export const unixTimestampToDate = (unixTimestamp: number) => new Date(unixTimestamp * 1000); export const unixTimestampToDate = (unixTimestamp: number) => new Date(unixTimestamp * 1000);
// deno-lint-ignore no-explicit-any
export function parseResponses(body: any): Response | Response[] | undefined { export function parseResponses(body: any): Response | Response[] | undefined {
if (!body) { if (!body) {
return undefined; return undefined;
@ -44,7 +45,9 @@ export function parseResponses(body: any): Response | Response[] | undefined {
return Array.isArray(body) return Array.isArray(body)
? body ? body
// deno-lint-ignore no-explicit-any
.filter((item: any) => "id" in item) .filter((item: any) => "id" in item)
// deno-lint-ignore no-explicit-any
.map((item: any) => new Response(item)) .map((item: any) => new Response(item))
: "id" in body : "id" in body
? new Response(body) ? new Response(body)
@ -52,7 +55,7 @@ export function parseResponses(body: any): Response | Response[] | undefined {
} }
export function serializeRequests(...requests: Request[]): string { export function serializeRequests(...requests: Request[]): string {
const toReturn: any[] = []; const toReturn: (Request & { jsonrpc: "2.0" })[] = [];
for (const request of requests) { for (const request of requests) {
toReturn.push({ ...request, jsonrpc: "2.0" }); toReturn.push({ ...request, jsonrpc: "2.0" });
@ -65,7 +68,7 @@ export const newHash = () => {
return bufferToHex(getRandomValues(32)); return bufferToHex(getRandomValues(32));
}; };
export const formFromObj = (obj: { [key: string]: any }) => { export const formFromObj = (obj: { [key: string]: FormDataEntryValue }) => {
const form = new FormData(); const form = new FormData();
for (const i in obj) { for (const i in obj) {