Skip to content

Commit c8babc0

Browse files
committed
Adding getAccessToken and getAuthConfig functions to authentication module, and update exports in mod.ts and index.ts
1 parent abfd337 commit c8babc0

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

mod.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { authenticate, requestHref, setup } from "./src/shared/index.ts";
1+
import { authenticate, getAccessToken, getAuthConfig, requestHref, setup } from "./src/shared/index.ts";
22
import * as wow from "./src/wow/index.ts";
33
import * as wowClassic from "./src/wow_classic/index.ts";
44
import * as hearthstone from "./src/hearthstone/index.ts";
55
import * as sc2 from "./src/starcraft2/index.ts";
66
import * as errors from "./src/shared/errors.ts";
77

8-
export { authenticate, errors, hearthstone, requestHref, sc2, setup, wow, wowClassic };
8+
export { authenticate, errors, getAccessToken, getAuthConfig, hearthstone, requestHref, sc2, setup, wow, wowClassic };

src/shared/auth.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,22 @@ export function getauthConfig(): AuthConfig {
3838
return authConfig;
3939
}
4040

41+
/**
42+
* Retrieves the current access token for debugging or external use.
43+
* @returns {string} The current access token, or empty string if not authenticated.
44+
*/
45+
export function getAccessToken(): string {
46+
return authConfig.accessToken;
47+
}
48+
49+
/**
50+
* Retrieves the current authentication configuration for debugging or external use.
51+
* @returns {AuthConfig} The current authentication configuration.
52+
*/
53+
export function getAuthConfig(): AuthConfig {
54+
return { ...authConfig };
55+
}
56+
4157
/**
4258
* Handles authentication and obtains an access token if needed.
4359
* @param {boolean} forceNewToken - If true, forces the retrieval of a new token, ignoring any existing one.

src/shared/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export { setup } from "./config.ts";
2-
export { authenticate } from "./auth.ts";
2+
export { authenticate, getAccessToken, getAuthConfig } from "./auth.ts";
33
export { request, requestHref } from "./request.ts";
44

55
export type {

0 commit comments

Comments
 (0)