From 487f208565894f332ca58c13e1b208c3beb9c8c6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 Sep 2021 21:06:22 +0000 Subject: Bump node-fetch from 2.6.1 to 3.0.0 (#116) * Bump node-fetch from 2.6.1 to 3.0.0 Bumps [node-fetch](https://github.com/node-fetch/node-fetch) from 2.6.1 to 3.0.0. - [Release notes](https://github.com/node-fetch/node-fetch/releases) - [Changelog](https://github.com/node-fetch/node-fetch/blob/main/docs/CHANGELOG.md) - [Commits](https://github.com/node-fetch/node-fetch/compare/v2.6.1...v3.0.0) --- updated-dependencies: - dependency-name: node-fetch dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] * fix issues with node fetch 3.0 * change module to esnext instead of commonjs * fix imports and tests * fix package-lock.json Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: mat Co-authored-by: mat <27899617+mat-1@users.noreply.github.com> --- src/mojang.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/mojang.ts') diff --git a/src/mojang.ts b/src/mojang.ts index 84c8c7d..9b224d6 100644 --- a/src/mojang.ts +++ b/src/mojang.ts @@ -2,10 +2,10 @@ * Fetch the Mojang username API through api.ashcon.app */ -import fetch from 'node-fetch' +import { isUuid, undashUuid } from './util.js' import * as nodeFetch from 'node-fetch' +import fetch from 'node-fetch' import { Agent } from 'https' -import { isUuid, undashUuid } from './util' // We need to create an agent to prevent memory leaks const httpsAgent = new Agent({ @@ -21,7 +21,7 @@ interface MojangApiResponse { /** * Get mojang api data from the session server */ -export async function profileFromUuid(uuid: string): Promise { +export let profileFromUuid = async function profileFromUuid(uuid: string): Promise { let fetchResponse: nodeFetch.Response try { @@ -56,7 +56,7 @@ export async function profileFromUuid(uuid: string): Promise } -export async function profileFromUsername(username: string): Promise { +export let profileFromUsername = async function profileFromUsername(username: string): Promise { // since we don't care about anything other than the uuid, we can use /uuid/ instead of /user/ let fetchResponse: nodeFetch.Response @@ -118,9 +118,15 @@ export async function profileFromUsernameAlternative(username: string): Promise< } } -export async function profileFromUser(user: string): Promise { +export let profileFromUser = async function profileFromUser(user: string): Promise { if (isUuid(user)) { return await profileFromUuid(user) } else return await profileFromUsername(user) } + + +// this is necessary for mocking in the tests because es6 +export function mockProfileFromUuid($value) { profileFromUuid = $value } +export function mockProfileFromUsername($value) { profileFromUsername = $value } +export function mockProfileFromUser($value) { profileFromUser = $value } -- cgit