mirror of
https://github.com/samuelthomas2774/nxapi.git
synced 2026-09-07 10:55:09 -05:00
Use package.json exports field
This commit is contained in:
@@ -10,7 +10,7 @@ const debugFlapg = createDebug('nxapi:api:flapg');
|
||||
const debugImink = createDebug('nxapi:api:imink');
|
||||
const debugZncaApi = createDebug('nxapi:api:znca-api');
|
||||
|
||||
abstract class ZncaApi {
|
||||
export abstract class ZncaApi {
|
||||
constructor(
|
||||
public useragent?: string
|
||||
) {}
|
||||
@@ -291,7 +291,7 @@ export type FResult = {
|
||||
result: AndroidZncaFResponse;
|
||||
});
|
||||
|
||||
function getZncaApiFromEnvironment(useragent?: string): ZncaApi {
|
||||
export function getZncaApiFromEnvironment(useragent?: string): ZncaApi {
|
||||
if (process.env.NXAPI_ZNCA_API) {
|
||||
if (process.env.NXAPI_ZNCA_API === 'flapg') {
|
||||
return new ZncaApiFlapg(useragent);
|
||||
|
||||
@@ -178,9 +178,14 @@ export type PresenceUrlResponse =
|
||||
CurrentUser | {user: CurrentUser} |
|
||||
Friend | {friend: Friend};
|
||||
|
||||
export async function getPresenceFromUrl(presence_url: string) {
|
||||
export async function getPresenceFromUrl(presence_url: string, useragent?: string) {
|
||||
const [signal, cancel] = timeoutSignal();
|
||||
const response = await fetch(presence_url, {signal}).finally(cancel);
|
||||
const response = await fetch(presence_url, {
|
||||
headers: {
|
||||
'User-Agent': getUserAgent(useragent),
|
||||
},
|
||||
signal,
|
||||
}).finally(cancel);
|
||||
|
||||
debug('fetch %s %s, response %s', 'GET', presence_url, response.status);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user