Skip to content
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ClientType } from "../../../enums/clientType";
Comment thread
BTreston marked this conversation as resolved.
import { Utils } from "../../../misc/utils";
import { CaptchaProtectedRequest } from "../captchaProtectedRequest";
Comment thread
BTreston marked this conversation as resolved.
import { DeviceRequest } from "../deviceRequest";

Expand Down Expand Up @@ -30,5 +29,4 @@ export class PasswordTokenRequest extends TokenRequest implements CaptchaProtect

return obj;
}

}
3 changes: 1 addition & 2 deletions jslib/common/src/services/state.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ const partialKeys = {
export class StateService<
TGlobalState extends GlobalState = GlobalState,
TAccount extends Account = Account,
> implements StateServiceAbstraction<TAccount>
{
> implements StateServiceAbstraction<TAccount> {
Comment thread
BTreston marked this conversation as resolved.
Comment thread
BTreston marked this conversation as resolved.
protected accountsSubject = new BehaviorSubject<{ [userId: string]: TAccount }>({});
accounts$ = this.accountsSubject.asObservable();

Expand Down
30 changes: 30 additions & 0 deletions jslib/node/src/cli/commands/update.command.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { components } from "@octokit/openapi-types";
Comment thread
BTreston marked this conversation as resolved.
import * as fetch from "node-fetch";
Comment thread
BTreston marked this conversation as resolved.
Outdated
Comment thread
BTreston marked this conversation as resolved.
Outdated

import { I18nService } from "@/jslib/common/src/abstractions/i18n.service";
Expand All @@ -6,6 +7,30 @@ import { PlatformUtilsService } from "@/jslib/common/src/abstractions/platformUt
import { Response } from "../models/response";
import { MessageResponse } from "../models/response/messageResponse";

type GitHubRelease = components["schemas"]["release"];
Comment thread
BTreston marked this conversation as resolved.
Comment thread
BTreston marked this conversation as resolved.

function isGitHubRelease(value: unknown): value is GitHubRelease {
if (typeof value !== "object" || value === null) {
return false;
}

const obj = value as Record<string, unknown>;

if (typeof obj.tag_name !== "string") {
return false;
}

if (obj.body !== undefined && obj.body !== null && typeof obj.body !== "string") {
return false;
}

if (obj.assets !== undefined && obj.assets !== null && !Array.isArray(obj.assets)) {
return false;
}

return true;
Comment thread
BTreston marked this conversation as resolved.
}

export class UpdateCommand {
inPkg = false;

Expand All @@ -27,6 +52,11 @@ export class UpdateCommand {
);
if (response.status === 200) {
const responseJson = await response.json();

if (!isGitHubRelease(responseJson)) {
return Response.error("Invalid response from GitHub API");
}

const res = new MessageResponse(null, null);

const tagName: string = responseJson.tag_name;
Expand Down
223 changes: 188 additions & 35 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading