Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "git",
"url": "https://github.com/PropelAuth/javascript"
},
"version": "2.0.5",
"version": "2.0.6",
"keywords": [
"auth",
"user",
Expand Down
44 changes: 44 additions & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@ export interface IAuthClient {
*/
getSetupSAMLPageUrl(orgId: string): string

/**
* Gets the URL for the hosted personal API key page.
*/
getPersonalApiKeyPageUrl(): string

/**
* Gets the URL for the hosted org API key page.
*/
getOrgApiKeyPageUrl(orgId: string): string

/**
* Redirects the user to the signup page.
*/
Expand Down Expand Up @@ -95,6 +105,16 @@ export interface IAuthClient {
*/
redirectToSetupSAMLPage(orgId: string): void

/**
* Redirects the user to the personal API key page.
*/
redirectToPersonalApiKeyPage(): void

/**
* Redirects the user to the org API key page.
*/
redirectToOrgApiKeyPage(): void


/**
* Adds an observer which is called whenever the users logs in or logs out.
Expand Down Expand Up @@ -277,6 +297,14 @@ export function createClient(authOptions: IAuthOptions): IAuthClient {
return `${clientState.authUrl}/saml?id=${orgId}`
}

const getPersonalApiKeyPageUrl = () => {
return `${clientState.authUrl}/api_keys/personal`
}

const getOrgApiKeyPageUrl = () => {
return `${clientState.authUrl}/api_keys/org`
}

const client = {
addLoggedInChangeObserver(loggedInChangeObserver: (isLoggedIn: boolean) => void): void {
const hasObserver = clientState.observers.includes(loggedInChangeObserver)
Expand Down Expand Up @@ -329,6 +357,14 @@ export function createClient(authOptions: IAuthOptions): IAuthClient {
return getAccountPageUrl()
},

getPersonalApiKeyPageUrl(): string {
return getPersonalApiKeyPageUrl()
},

getOrgApiKeyPageUrl(): string {
return getOrgApiKeyPageUrl()
},

getOrgPageUrl(orgId?: string): string {
return getOrgPageUrl(orgId)
},
Expand Down Expand Up @@ -365,6 +401,14 @@ export function createClient(authOptions: IAuthOptions): IAuthClient {
window.location.href = getSetupSAMLPageUrl(orgId)
},

redirectToPersonalApiKeyPage(): void {
window.location.href = getPersonalApiKeyPageUrl()
},

redirectToOrgApiKeyPage(): void {
window.location.href = getOrgApiKeyPageUrl()
},

async logout(redirectAfterLogout: boolean): Promise<void> {
const logoutResponse = await logout(clientState.authUrl)
setAuthenticationInfoAndUpdateDownstream(null)
Expand Down