Skip to content

Commit bd6f961

Browse files
Expose auth URL from client
1 parent 8730831 commit bd6f961

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"type": "git",
66
"url": "https://github.com/PropelAuth/javascript"
77
},
8-
"version": "2.0.17",
8+
"version": "2.0.18",
99
"keywords": [
1010
"auth",
1111
"user",

src/client.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,11 @@ export interface IAuthClient {
163163
* Cleanup the auth client if you no longer need it.
164164
*/
165165
destroy(): void
166+
167+
/**
168+
* Gets the auth URL.
169+
*/
170+
getAuthUrl(): string
166171
}
167172

168173
export interface IAuthOptions {
@@ -599,6 +604,10 @@ export function createClient(authOptions: IAuthOptions): IAuthClient {
599604
clearInterval(clientState.refreshInterval)
600605
}
601606
},
607+
608+
getAuthUrl() {
609+
return authOptions.authUrl
610+
},
602611
}
603612

604613
const onStorageChange = async function () {

src/tests/index.test.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
/**
22
* @jest-environment jsdom
33
*/
4+
import { DEFAULT_RETRIES } from "../fetch_retries"
45
import { createClient } from "../index"
56
import { OrgIdToOrgMemberInfo } from "../org"
67
import { ok, ResponseStatus, setupMockFetch, UnauthorizedResponse, UnknownErrorResponse } from "./mockfetch.test"
7-
import {DEFAULT_RETRIES} from "../fetch_retries";
88

99
const INITIAL_TIME_MILLIS = 1619743452595
1010
const INITIAL_TIME_SECONDS = INITIAL_TIME_MILLIS / 1000
1111

1212
beforeAll(() => {
1313
jest.useFakeTimers("modern")
1414
// @ts-ignore
15-
global.setTimeout = jest.fn(cb => cb());
15+
global.setTimeout = jest.fn((cb) => cb())
1616
})
1717

1818
beforeEach(() => {
@@ -99,6 +99,12 @@ test("client works without ending slash", async () => {
9999
expectCorrectEndpointWasHit(mockFetch, "https://www.example.com/api/v1/refresh_token")
100100
})
101101

102+
test("client gets auth URL back correctly", async () => {
103+
let client = createClient({ authUrl: "https://www.example.com", enableBackgroundTokenRefresh: false })
104+
105+
expect(client.getAuthUrl()).toBe("https://www.example.com")
106+
})
107+
102108
test("client parses user correctly", async () => {
103109
const { mockFetch } = setupMockFetchThatReturnsAccessToken()
104110
let client = createClient({ authUrl: "https://www.example.com", enableBackgroundTokenRefresh: false })

0 commit comments

Comments
 (0)