New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

floatplane

Package Overview
Dependencies
Maintainers
1
Versions
95
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

floatplane - npm Package Compare versions

Comparing version
5.2.1
to
5.2.3
+16
-4
dist/index.d.ts

@@ -9,5 +9,5 @@ import got from "got";

import { Content } from "./content.js";
export declare const version = "5.2.1";
export declare const version = "5.2.3";
export type AuthToken = TokenEndpointResponse & {
expires_at?: Date;
expiresEpoch?: number;
};

@@ -43,5 +43,17 @@ export type OnDeviceCode = (response: client.DeviceAuthorizationResponse) => any;

private set authToken(value);
expiresIn(tokenSet?: AuthToken): number | undefined;
refreshAuthToken(): Promise<unknown>;
/**
* Time untl token expiry in ms
*/
expiresIn(tokenSet?: AuthToken): number;
tokenExpired(): boolean;
refreshAuthToken: () => Promise<{
id: string;
username: string;
profileImage: import("./lib/apiSchema.js").components["schemas"]["ImageModel"];
email: string;
displayName: string;
creators: unknown[];
scheduledDeletionDate: string | null;
} | undefined>;
/**
* Login to floatplane so future requests are authenticated using the Device flow

@@ -48,0 +60,0 @@ * @returns {Promise<User>} User object.

+24
-30

@@ -7,6 +7,6 @@ import got from "got";

import { User } from "./user.js";
import { isDate } from "util/types";
import { asyncDebounce } from "@inrixia/helpers";
import { Content } from "./content.js";
import { Core } from "./Core.js";
export const version = "5.2.1";
export const version = "5.2.3";
export class Floatplane {

@@ -64,33 +64,29 @@ got;

}
set authToken(value) {
if (this.authConfig.onAuthToken && value)
this.authConfig.onAuthToken(value);
this.authConfig.authToken = value ?? undefined;
set authToken(authToken) {
if (authToken)
authToken.expiresEpoch = Date.now() + (authToken?.expires_in ?? 30) * 1000;
this.authConfig.authToken = authToken ?? undefined;
if (this.authConfig.onAuthToken && authToken)
this.authConfig.onAuthToken(authToken);
}
/**
* Time untl token expiry in ms
*/
expiresIn(tokenSet) {
if (tokenSet?.expires_at && isDate(tokenSet.expires_at)) {
const exp = tokenSet.expires_at;
if (exp) {
const now = new Date();
if (exp > now)
return Math.floor((exp.getTime() - now.getTime()) / 1000);
return 0;
}
}
return undefined;
const expiresEpoch = tokenSet?.expiresEpoch;
if (!expiresEpoch)
return -1;
return Math.max(expiresEpoch - Date.now(), 0);
}
async refreshAuthToken() {
tokenExpired() {
return this.expiresIn() < 60000;
}
refreshAuthToken = asyncDebounce(async () => {
if (!this.authToken)
return this.login();
const expires = this.expiresIn(this.authToken);
if (!expires || expires < 60) {
if (this.tokenExpired()) {
const refreshToken = this.authToken.refresh_token;
if (!refreshToken) {
console.warn("[floatplane.api] - No refresh token available to refresh OAuth token! Falling back to login...");
// Corrupted?
this.authToken = null;
return this.login();
}
if (!this.oauthConfig)
throw new Error("No OAuth configuration available to refresh token!");
if (!refreshToken)
throw new Error("No refresh token available to refresh OAuth token!");
this.oauthConfig ??= await client.discovery(new URL(this.authConfig.serverUrl ?? "https://auth.floatplane.com/realms/floatplane"), this.authConfig.clientId, this.authConfig.clientSecret);
const refreshedTokenSet = await client.refreshTokenGrant(this.oauthConfig, refreshToken);

@@ -101,3 +97,3 @@ if (refreshedTokenSet.access_token === undefined)

}
}
});
/**

@@ -116,5 +112,3 @@ * Login to floatplane so future requests are authenticated using the Device flow

this.authToken = authToken;
this.authToken.expires_at = authToken.expires_in ? new Date(Date.now() + authToken.expires_in * 1000) : undefined;
}
await this.refreshAuthToken();
return this.user.self();

@@ -121,0 +115,0 @@ };

{
"name": "floatplane",
"version": "5.2.1",
"version": "5.2.3",
"description": "Library for interfacing with the LMG Floatplane.com api",

@@ -8,12 +8,12 @@ "type": "module",

"cross-env": "^10.1.0",
"got": "^14.6.5",
"got": "^14.6.6",
"openid-client": "^6.8.1"
},
"devDependencies": {
"@inrixia/helpers": "^3.20.3",
"@types/node": "^24.10.1",
"@inrixia/helpers": "^3.21.1",
"@types/node": "^25.0.9",
"@types/tough-cookie": "^4.0.5",
"@types/tough-cookie-file-store": "^2.0.4",
"@typescript-eslint/eslint-plugin": "^8.48.0",
"eslint": "^9.39.1",
"@typescript-eslint/eslint-plugin": "^8.53.0",
"eslint": "^9.39.2",
"openapi-typescript": "^7.10.1",

@@ -20,0 +20,0 @@ "rimraf": "^6.1.2",