Update dependencies

This commit is contained in:
Samuel Elliott
2022-11-27 15:15:57 +00:00
parent 890c02e3ef
commit 6d1391929f
8 changed files with 183 additions and 380 deletions

View File

@@ -24,7 +24,7 @@ export default class MoonApi {
readonly znma_useragent = ZNMA_USER_AGENT,
) {}
async fetch<T = unknown>(url: string, method = 'GET', body?: string, headers?: object) {
async fetch<T extends object>(url: string, method = 'GET', body?: string, headers?: object) {
const [signal, cancel] = timeoutSignal();
const response = await fetch(MOON_URL + url, {
method,

View File

@@ -23,7 +23,7 @@ export default class NooklinkApi {
readonly client_version = BLANCO_VERSION,
) {}
async fetch<T = unknown>(url: string, method = 'GET', body?: string | FormData, headers?: object) {
async fetch<T extends object>(url: string, method = 'GET', body?: string | FormData, headers?: object) {
const [signal, cancel] = timeoutSignal();
const response = await fetch(NOOKLINK_URL + url, {
method,
@@ -164,7 +164,7 @@ export class NooklinkUserApi {
readonly client_version = BLANCO_VERSION,
) {}
async fetch<T = unknown>(url: string, method = 'GET', body?: string | FormData, headers?: object) {
async fetch<T extends object>(url: string, method = 'GET', body?: string | FormData, headers?: object) {
const [signal, cancel] = timeoutSignal();
const response = await fetch(NOOKLINK_URL + url, {
method,
@@ -224,7 +224,7 @@ export class NooklinkUserApi {
}
async postMessage(body: string, type: MessageType, destination_user_id?: string) {
return this.fetch<unknown>('/sd/v1/messages', 'POST', JSON.stringify({
return this.fetch('/sd/v1/messages', 'POST', JSON.stringify({
type,
body,
userId: destination_user_id,

View File

@@ -31,7 +31,7 @@ export default class SplatNet2Api {
public useragent: string,
) {}
async fetch<T = unknown>(url: string, method = 'GET', body?: string | FormData, headers?: object) {
async fetch<T extends object>(url: string, method = 'GET', body?: string | FormData, headers?: object) {
const [signal, cancel] = timeoutSignal();
const response = await fetch(SPLATNET2_URL + url, {
method,

View File

@@ -8,7 +8,7 @@ import { getDiscordPresence, getInactiveDiscordPresence } from '../../discord/ut
import { DiscordPresenceContext, DiscordPresencePlayTime } from '../../discord/types.js';
import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js';
import { initStorage } from '../../util/storage.js';
import { getToken } from '../../common/auth/coral.js';
import { getToken, Login } from '../../common/auth/coral.js';
import { timeoutSignal } from '../../util/misc.js';
import { getUserAgent } from '../../util/useragent.js';
@@ -153,7 +153,7 @@ async function getPresenceFromCoral(argv: ArgumentsCamelCase<Arguments>) {
const friends = await nso.getFriendList();
const webservices = await nso.getWebServices();
const activeevent = await nso.getActiveEvent();
const user = 'expires_at' in data ? await nso.getCurrentUser() : data.nsoAccount.user;
const user = data[Login] ? data.nsoAccount.user : await nso.getCurrentUser();
if (argv.friendNsaid) {
const friend = friends.friends.find(f => f.nsaId === argv.friendNsaid);

View File

@@ -51,7 +51,7 @@ export class HttpServer {
}
}
if (err && 'type' in err && 'code' in err && (err as any).type === 'system') {
if (err && typeof err === 'object' && 'type' in err && 'code' in err && (err as any).type === 'system') {
const code: string = (err as any).code;
if (code === 'ETIMEDOUT' || code === 'ENOTFOUND' || code === 'EAI_AGAIN') {

View File

@@ -93,7 +93,7 @@ export class ZncNotifications extends Loop {
const activeevent: GetActiveEventResult = this.user ?
await this.user.getActiveEvent() :
await this.nso.getActiveEvent();
result.activeevent = 'id' in activeevent ? activeevent : undefined;
result.activeevent = 'id' in activeevent ? activeevent as ActiveEvent : undefined;
}
if (req.includes('user')) {
result.user = await this.nso.getCurrentUser();