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
1 change: 1 addition & 0 deletions CONTRIBUTOR_LICENCE_AGREEMENT.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Full name: _____________________________________________________
* if you do not enter a public name your full name will be public
* Public name: ____________________________________________________
your public name might not include honorific, suffix, or middle name
Country: _________________________________________________
* E-Mail: ______________________________________________________

* The starred fields above will become part of your public profile.
Expand Down
9 changes: 9 additions & 0 deletions docs/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 39 additions & 0 deletions packages/auth-client/src/config-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,3 +314,42 @@ export class ConfigManager {
return ConfigManager.INSTANCE;
}
}

export function addDefaultAppHeaders(
headers: Record<string, string> = {},
values?: Record<string, string>
) {
const normalizedHeaders = headers as Record<string, string>;
// Modify the "Accept" header
const currentAccept = normalizedHeaders['Accept'];
if (!currentAccept) {
normalizedHeaders['Accept'] = 'application/vnd.catalyst.v2+json';
} else {
normalizedHeaders['Accept'] = `application/vnd.catalyst.v2+json, ${currentAccept}`;
}
normalizedHeaders['CATALYST-COMPONENT'] = 'true';

const conf = ConfigManager.getInstance();
if (typeof conf?.OrgId === 'string') {
normalizedHeaders['CATALYST-ORG'] = conf.OrgId;
}

return normalizedHeaders;
}

export function getToken(key?: string) {
let jwtAuthToken = '';
const cookies = document.cookie.split(';');
const cookiesLen = cookies.length;
for (let i = 0; i < cookiesLen; i++) {
const keyValuePairSplitted = cookies[i].split('=');
if (keyValuePairSplitted[0].trim() === (key ? key : 'cookie')) {
jwtAuthToken = keyValuePairSplitted[1];
}
}
return jwtAuthToken;
}

export function setToken(authObj: { access_token?: string; expires_in?: number }, key?: string) {
document.cookie = `${key ? key : 'cookie'}=${authObj.access_token}; max-age=${authObj.expires_in}; path=/`;
}
Loading
Loading