type
stringclasses
7 values
content
stringlengths
4
9.55k
repo
stringlengths
7
96
path
stringlengths
4
178
language
stringclasses
1 value
ArrowFunction
(_bytesWritten: number, totalBytesWritten: number, totalBytesExpectedToWrite: number) => { const percent = Number((100 * (totalBytesWritten / totalBytesExpectedToWrite)).toFixed(2)); progress({ total: totalBytesExpectedToWrite, loaded: totalBytesWritten, percent }); }
Bernard-Cloutier/imodeljs
core/backend/src/MobileDevice.ts
TypeScript
ArrowFunction
(_downloadUrl: string, _downloadFileUrl: string, cancelled: boolean, err?: string) => { if (cancelled) reject(new UserCancelledError(BriefcaseStatus.DownloadCancelled, "User cancelled download", Logger.logWarning)); else if (err) reject(new DownloadFailed(400, "Download failed")); ...
Bernard-Cloutier/imodeljs
core/backend/src/MobileDevice.ts
TypeScript
ArrowFunction
() => { return this._impl.cancelDownloadTask!(requestId); }
Bernard-Cloutier/imodeljs
core/backend/src/MobileDevice.ts
TypeScript
ArrowFunction
(accessToken?: string, err?: string) => { if (accessToken) { // Patch user info const tmp = JSON.parse(accessToken); if (typeof tmp._userInfo === undefined) { tmp._userInfo = {}; } accessToken = JSON.stringify(tmp); } this.onUserStateChanged.raiseEven...
Bernard-Cloutier/imodeljs
core/backend/src/MobileDevice.ts
TypeScript
ArrowFunction
(resolve, reject) => { this._impl.authInit!(ctx, settings, (err?: string) => { if (!err) { this._authInitialized = true; resolve(); } else { this._authInitialized = false; reject(new Error(err)); } }); }
Bernard-Cloutier/imodeljs
core/backend/src/MobileDevice.ts
TypeScript
ArrowFunction
(err?: string) => { if (!err) { this._authInitialized = true; resolve(); } else { this._authInitialized = false; reject(new Error(err)); } }
Bernard-Cloutier/imodeljs
core/backend/src/MobileDevice.ts
TypeScript
ArrowFunction
(resolve, reject) => { this._impl.authSignIn!(ctx, (err?: string) => { if (!err) { resolve(); } else { reject(new Error(err)); } }); }
Bernard-Cloutier/imodeljs
core/backend/src/MobileDevice.ts
TypeScript
ArrowFunction
(err?: string) => { if (!err) { resolve(); } else { reject(new Error(err)); } }
Bernard-Cloutier/imodeljs
core/backend/src/MobileDevice.ts
TypeScript
ArrowFunction
(resolve, reject) => { this._impl.authSignOut!(ctx, (err?: string) => { if (!err) { resolve(); } else { reject(new Error(err)); } }); }
Bernard-Cloutier/imodeljs
core/backend/src/MobileDevice.ts
TypeScript
ArrowFunction
(resolve, reject) => { this._impl.authGetAccessToken!(ctx, (accessToken?: string, err?: string) => { if (!err) { resolve(AccessToken.fromJson(accessToken)); } else { reject(new Error(err)); } }); }
Bernard-Cloutier/imodeljs
core/backend/src/MobileDevice.ts
TypeScript
ArrowFunction
(accessToken?: string, err?: string) => { if (!err) { resolve(AccessToken.fromJson(accessToken)); } else { reject(new Error(err)); } }
Bernard-Cloutier/imodeljs
core/backend/src/MobileDevice.ts
TypeScript
ClassDeclaration
class MobileDeviceRpcImpl { public emit(eventName: DeviceEvents, ...args: any[]) { MobileDevice.currentDevice.emit(eventName, ...args); } public getOrientation?: () => Orientation; public getBatteryState?: () => BatteryState; public getBatteryLevel?: () => number; public createDownloadTask?: (downloadU...
Bernard-Cloutier/imodeljs
core/backend/src/MobileDevice.ts
TypeScript
ClassDeclaration
export class MobileDevice { private get _impl(): MobileDeviceRpcImpl { const client = (global as any).MobileDeviceRpcImpl as MobileDeviceRpcImpl; if (!client) { throw new Error("MobileDeviceRpcImpl is not registered."); } return client; } private _authInitialized: boolean = false; public ...
Bernard-Cloutier/imodeljs
core/backend/src/MobileDevice.ts
TypeScript
InterfaceDeclaration
export interface MobileDeviceAuthSettings { issuerUrl: string; clientId: string; redirectUrl: string; scope: string; stateKey?: string; }
Bernard-Cloutier/imodeljs
core/backend/src/MobileDevice.ts
TypeScript
InterfaceDeclaration
export interface DownloadTask { url: string; downloadPath: string; isDetached: boolean; isRunning: boolean; totalBytes?: number; doneBytes?: number; cancelId?: number; isBackground?: boolean; cancel?: MobileCancelCallback; toBackground: () => boolean; toForeground: () => boolean; }
Bernard-Cloutier/imodeljs
core/backend/src/MobileDevice.ts
TypeScript
EnumDeclaration
export enum Orientation { Unknown = 0, Portrait = 0x1, PortraitUpsideDown = 0x2, LandscapeLeft = 0x4, LandscapeRight = 0x8, FaceUp = 0x10, FaceDown = 0x20, }
Bernard-Cloutier/imodeljs
core/backend/src/MobileDevice.ts
TypeScript
EnumDeclaration
export enum BatteryState { Unknown = 0, Unplugged = 1, Charging = 2, Full = 3, }
Bernard-Cloutier/imodeljs
core/backend/src/MobileDevice.ts
TypeScript
EnumDeclaration
export enum DeviceEvents { MemoryWarning = "memoryWarning", OrientationChanged = "orientationChanged", EnterForeground = "enterForeground", EnterBackground = "enterBackground", WillTerminate = "willTerminate", }
Bernard-Cloutier/imodeljs
core/backend/src/MobileDevice.ts
TypeScript
TypeAliasDeclaration
export type MobileCompletionCallback = (downloadUrl: string, downloadFileUrl: string, cancelled: boolean, err?: string) => void;
Bernard-Cloutier/imodeljs
core/backend/src/MobileDevice.ts
TypeScript
TypeAliasDeclaration
export type MobileProgressCallback = (bytesWritten: number, totalBytesWritten: number, totalBytesExpectedToWrite: number) => void;
Bernard-Cloutier/imodeljs
core/backend/src/MobileDevice.ts
TypeScript
TypeAliasDeclaration
export type MobileCancelCallback = () => boolean;
Bernard-Cloutier/imodeljs
core/backend/src/MobileDevice.ts
TypeScript
MethodDeclaration
public emit(eventName: DeviceEvents, ...args: any[]) { MobileDevice.currentDevice.emit(eventName, ...args); }
Bernard-Cloutier/imodeljs
core/backend/src/MobileDevice.ts
TypeScript
MethodDeclaration
/** * Download file * @internal */ public async downloadFile(downloadUrl: string, downloadTo: string, progress?: ProgressCallback, cancelRequest?: CancelRequest): Promise<void> { return new Promise<void>((resolve, reject) => { if (!this._impl.createDownloadTask) { throw new Error("Native back...
Bernard-Cloutier/imodeljs
core/backend/src/MobileDevice.ts
TypeScript
MethodDeclaration
/** * Reconnect app * @internal */ public reconnect(connection: number) { if (!this._impl.reconnect) { throw new Error("Native backend did not registered reconnect() functions"); } this._impl.reconnect(connection); }
Bernard-Cloutier/imodeljs
core/backend/src/MobileDevice.ts
TypeScript
MethodDeclaration
public emit(eventName: DeviceEvents, ...args: any[]) { switch (eventName) { case DeviceEvents.MemoryWarning: this.onMemoryWarning.raiseEvent(...args); break; case DeviceEvents.OrientationChanged: this.onOrientationChanged.raiseEvent(...args); break; case DeviceEvents.EnterForegrou...
Bernard-Cloutier/imodeljs
core/backend/src/MobileDevice.ts
TypeScript
MethodDeclaration
public async authInit(ctx: ClientRequestContext, settings: MobileDeviceAuthSettings) { if (!this.hasAuthClient) { throw new Error("App did not registered any native auth client or implement all required functions"); } if (this._authInitialized) { return; } // Set callback for ios th...
Bernard-Cloutier/imodeljs
core/backend/src/MobileDevice.ts
TypeScript
MethodDeclaration
public async signIn(ctx: ClientRequestContext): Promise<void> { // eslint-disable-next-line no-console console.log("signIn() ", JSON.stringify(ctx)); if (!this.hasAuthClient) { throw new Error("App did not registered any native auth client or implement all required functions"); } return new P...
Bernard-Cloutier/imodeljs
core/backend/src/MobileDevice.ts
TypeScript
MethodDeclaration
public async signOut(ctx: ClientRequestContext): Promise<void> { if (!this.hasAuthClient) { throw new Error("App did not registered any native auth client or implement all required functions"); } return new Promise<void>((resolve, reject) => { this._impl.authSignOut!(ctx, (err?: string) => { ...
Bernard-Cloutier/imodeljs
core/backend/src/MobileDevice.ts
TypeScript
MethodDeclaration
public async getAccessToken(ctx: ClientRequestContext): Promise<AccessToken> { if (!this.hasAuthClient) { throw new Error("App did not registered any native auth client or implement all required functions"); } return new Promise<AccessToken>((resolve, reject) => { this._impl.authGetAccessToken!...
Bernard-Cloutier/imodeljs
core/backend/src/MobileDevice.ts
TypeScript
FunctionDeclaration
function ChallengeBox() { const { activeChallenge, resetChallenge, completeChallenge } = useContext(ChallengesContext); const { resetCountdown } = useContext(CountdownContext); function handleChallengeSucceeded() { completeChallenge(); resetCountdown(); } function handleChallengeFailed() { ...
martinsgabriel1956/moveit_nlw4
src/components/ChallengeBox/index.tsx
TypeScript
FunctionDeclaration
function handleChallengeSucceeded() { completeChallenge(); resetCountdown(); }
martinsgabriel1956/moveit_nlw4
src/components/ChallengeBox/index.tsx
TypeScript
FunctionDeclaration
function handleChallengeFailed() { resetChallenge(); resetCountdown(); }
martinsgabriel1956/moveit_nlw4
src/components/ChallengeBox/index.tsx
TypeScript
MethodDeclaration
activeChallenge ? ( <div className={styles.challengeActive}> <header>Ganhe {activeChallenge
martinsgabriel1956/moveit_nlw4
src/components/ChallengeBox/index.tsx
TypeScript
ClassDeclaration
export declare class Info extends MenuItem { constructor(vditor: IVditor, menuItem: IMenuItem); }
lbb4511/storyhub
static/vditor/ts/toolbar/Info.d.ts
TypeScript
ClassDeclaration
/** * 连线 [v.1.0.0] * 将该对象 放置到 两个节点之间,形成连线, 可以无视节点关系 */ @ccclass @menu("添加特殊行为/General/Line (连线)") @disallowMultiple export default class BhvLine extends cc.Component { @property(cc.Node) startNode: cc.Node = null; @property(cc.Node) endNode: cc.Node = null; // LIFE-CYCLE CALLBACKS: start(...
wsssheep/cc_easy_script
assets/Behavior/general/BhvLine.ts
TypeScript
MethodDeclaration
// LIFE-CYCLE CALLBACKS: start() { if (this.startNode && this.endNode) { this.setLine(this.startNode, this.endNode); } }
wsssheep/cc_easy_script
assets/Behavior/general/BhvLine.ts
TypeScript
MethodDeclaration
/**设置这条线 与 两个节点 动态连接起来 */ setLine(nodeStart: cc.Node, nodeEnd: cc.Node) { if (!this.startNode || !this.endNode) return; this.node.anchorX = 0; this.node.anchorY = 0.5; this.startNode = nodeStart; this.endNode = nodeEnd; }
wsssheep/cc_easy_script
assets/Behavior/general/BhvLine.ts
TypeScript
MethodDeclaration
update() { if (!this.startNode || !this.endNode) return; var startPos: cc.Vec2 = this.startNode.convertToWorldSpaceAR(cc.Vec2.ZERO); var endPos: cc.Vec2 = this.endNode.convertToWorldSpaceAR(cc.Vec2.ZERO); var distance: number = startPos.sub(endPos).mag(); var angle: number = Mat...
wsssheep/cc_easy_script
assets/Behavior/general/BhvLine.ts
TypeScript
FunctionDeclaration
/** * https://simplestatistics.org/docs/#sample */ declare function sample<T extends any>( x: T[], n: number, randomSource: () => number ): T[];
angelyaaaaa/simple-statistics
src/sample.d.ts
TypeScript
ClassDeclaration
export declare class CHTMLmunder<N, T, D> extends CHTMLmunder_base { static kind: string; static styles: StyleList; toCHTML(parent: N): void; }
NishadPatilMuzero/react-native-math-view-customize
node_modules/mathjax-full/js/output/chtml/Wrappers/munderover.d.ts
TypeScript
ClassDeclaration
export declare class CHTMLmover<N, T, D> extends CHTMLmover_base { static kind: string; static styles: StyleList; toCHTML(parent: N): void; }
NishadPatilMuzero/react-native-math-view-customize
node_modules/mathjax-full/js/output/chtml/Wrappers/munderover.d.ts
TypeScript
ClassDeclaration
export declare class CHTMLmunderover<N, T, D> extends CHTMLmunderover_base { static kind: string; static styles: StyleList; toCHTML(parent: N): void; }
NishadPatilMuzero/react-native-math-view-customize
node_modules/mathjax-full/js/output/chtml/Wrappers/munderover.d.ts
TypeScript
MethodDeclaration
toCHTML(parent: N): void;
NishadPatilMuzero/react-native-math-view-customize
node_modules/mathjax-full/js/output/chtml/Wrappers/munderover.d.ts
TypeScript
InterfaceDeclaration
//Components export interface IChatItemProps { data:{ users:string[]|[], room:string, messages:{ mess:string, name:string }[]|[] }, chatGo:Function, userInf:{ id:string, name?:string, email:string, nickname?:string, ...
YuriiDubnytskyi/practick
client/my-app/src/interfaces/IProps.ts
TypeScript
ArrowFunction
(props) => { const { intl } = props const { exchange, wallet, createWallet, history } = messages const { exchange: exchangeLink, quickSwap, createWallet: create, // farm, history: historyLink, home, } = links const itemsWithWallet = [ { title: intl.formatMessage(wallet), ...
AAH20/MultiCurrencyWallet
src/front/shared/components/Header/config.tsx
TypeScript
ArrowFunction
(props, isWalletCreate, dinamicPath) => { const { intl } = props const { exchange, wallet, createWallet, history } = messages const { exchange: exchangeLink, quickSwap, // farm, history: historyLink, } = links const mobileItemsWithWallet = [ { title: intl.formatMessage(isWalletCre...
AAH20/MultiCurrencyWallet
src/front/shared/components/Header/config.tsx
TypeScript
ArrowFunction
(event: MessageEventInit) => event.data.message.toUpperCase()
mprobber/anansi
examples/typescript/src/pages/Home/my.worker.ts
TypeScript
ArrowFunction
() => MultipleGameAdditionModelService
Spielekreis-Darmstadt/lending
lending-admin-frontend/src/app/add-multiple/add-multiple-games/add-multiple-games.component.ts
TypeScript
ClassDeclaration
/** * A component used to add a list of games at once. * This list needs to be provided as a table file, e.g. as an xls or csv file */ @Component({ selector: 'lending-add-multiple-games', templateUrl: './add-multiple-games.component.html', styleUrls: ['./add-multiple-games.component.css'], providers: [{provi...
Spielekreis-Darmstadt/lending
lending-admin-frontend/src/app/add-multiple/add-multiple-games/add-multiple-games.component.ts
TypeScript
ClassDeclaration
@Component({ selector: 'gb-pedigree-constraint', templateUrl: './gb-pedigree-constraint.component.html', styleUrls: ['./gb-pedigree-constraint.component.css', '../gb-constraint/gb-constraint.component.css'] }) export class GbPedigreeConstraintComponent extends GbConstraintComponent implements OnInit { selecte...
thehyve/glowing-bear
src/app/modules/gb-cohort-selection-module/constraint-components/gb-pedigree-constraint/gb-pedigree-constraint.component.ts
TypeScript
TypeAliasDeclaration
type TriState = true | false | undefined;
thehyve/glowing-bear
src/app/modules/gb-cohort-selection-module/constraint-components/gb-pedigree-constraint/gb-pedigree-constraint.component.ts
TypeScript
MethodDeclaration
ngOnInit() { this.pedigreeTypes = []; this.triStateOptions = [ {label: 'both', value: undefined}, {label: 'yes', value: true}, {label: 'no', value: false} ]; const relationType = (<PedigreeConstraint>this.constraint).relationType; for (let typeObj of this.constraintService.valid...
thehyve/glowing-bear
src/app/modules/gb-cohort-selection-module/constraint-components/gb-pedigree-constraint/gb-pedigree-constraint.component.ts
TypeScript
MethodDeclaration
updateRelationType(event) { (<PedigreeConstraint>this.constraint).relationType = event.value; this.update(); }
thehyve/glowing-bear
src/app/modules/gb-cohort-selection-module/constraint-components/gb-pedigree-constraint/gb-pedigree-constraint.component.ts
TypeScript
FunctionDeclaration
/** * Creates a span using the global tracer. * @param name The name of the operation being performed. * @param tracingOptions The tracingOptions for the underlying http request. */ export function createSpan( operationName: string, tracingOptions: OperationTracingOptions = {} ): { span: Span; spanOptions: Span...
burkeholland/azure-sdk-for-js
sdk/storage/storage-file-share/src/utils/tracing.ts
TypeScript
TypeAliasDeclaration
export declare type AppProps = { children: React.ReactNode; iconsSprite: string | null; };
nevendyulgerov/react-fidelity-ui
dist/components/App.d.ts
TypeScript
ClassDeclaration
@Bean('selectionHandleFactory') export class SelectionHandleFactory extends BeanStub implements ISelectionHandleFactory { public createSelectionHandle(type: SelectionHandleType): ISelectionHandle { return this.createBean(type === SelectionHandleType.RANGE ? new RangeHandle() : new FillHandle()); } }
39155319/ag-grid
enterprise-modules/range-selection/src/rangeSelection/selectionHandleFactory.ts
TypeScript
MethodDeclaration
public createSelectionHandle(type: SelectionHandleType): ISelectionHandle { return this.createBean(type === SelectionHandleType.RANGE ? new RangeHandle() : new FillHandle()); }
39155319/ag-grid
enterprise-modules/range-selection/src/rangeSelection/selectionHandleFactory.ts
TypeScript
EnumDeclaration
export enum EFGSignificanceType { Creature, AudioVolume, GenericTickHelper, ConveyorBelt, Factory, LowDistanceGainSignificance, MidDistanceGainSignificance, HighDistanceGainSignificance, AmbientSoundSpline, CustomDistanceGainSignificance, ParticleSignificance, TrainSignificance, PipelineSigni...
ficsit/data-landing
interfaces/enums/EFGSignificanceType.ts
TypeScript
FunctionDeclaration
/** * Not undefined type guard * @internal * @param x */ function notUndefined<T>(x: T | undefined): x is T { return x !== undefined; }
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
ArrowFunction
(accessToken: string): Observable<string> => { const aliases: string[] = this.storage.getTokenAliases(accessToken); return of(accessToken).pipe( tap(currentAccessToken => this.removeRefreshDigest(currentAccessToken)), switchMap(() => this.refresh(aliases)), map(({ access_token }: To...
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
ArrowFunction
currentAccessToken => this.removeRefreshDigest(currentAccessToken)
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
ArrowFunction
() => this.refresh(aliases)
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
ArrowFunction
({ access_token }: Tokens): string => access_token
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
ArrowFunction
newAccessToken => this.startRefreshDigest(aliases, newAccessToken)
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
ArrowFunction
() => { const tokens = this.storage.getTokens(auth); if (!tokens) { throw new Error(MESSAGE.TOKEN_MANAGER.TOKEN_NOT_AVAILABLE); } return tokens.access_token; }
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
ArrowFunction
(accessToken: string) => iif( () => isTokenExpired(accessToken), $refresh(accessToken), of(accessToken))
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
ArrowFunction
() => isTokenExpired(accessToken)
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
ArrowFunction
() => this.login(opts).toPromise()
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
ArrowFunction
() => this
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
ArrowFunction
timeout => clearTimeout(timeout)
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
ArrowFunction
(alias, index) => { this.storage.setTokens(alias, tokens, !index && defaults); }
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
ArrowFunction
() => { this.logger.debug("tokenManager", `refresh ${aliases[0]} token`); this.refresh(aliases) .pipe( finalize(() => this.removeRefreshDigest(accessToken)), ) .subscribe( ({ access_token }: Tokens) => this.startRefreshDigest(aliases, access_token), // start a di...
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
ArrowFunction
() => this.removeRefreshDigest(accessToken)
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
ArrowFunction
({ access_token }: Tokens) => this.startRefreshDigest(aliases, access_token)
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
ArrowFunction
() => this.terminate()
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
ArrowFunction
(tokens: Tokens) => this.addTokens([auth], tokens, true)
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
ArrowFunction
() => this.dispatcher.emit(DispatchEvents.TOKEN_LOGIN)
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
ArrowFunction
(refreshedTokens: Tokens) => [auth, ...restAliases].forEach((alias) => this.storage.setTokens(alias, refreshedTokens))
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
ArrowFunction
(alias) => this.storage.setTokens(alias, refreshedTokens)
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
ArrowFunction
() => this.dispatcher.emit(DispatchEvents.TOKEN_REFRESH)
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
ArrowFunction
() => { this.dispatcher.emit(DispatchEvents.TOKEN_REFRESH_FAILED); throw new Error("Refreshing token failed"); }
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
ArrowFunction
(r) => resolve = r
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
ArrowFunction
(refreshedTokens: Tokens) => resolve(refreshedTokens.access_token)
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
ArrowFunction
(error: IRequestError) => { delete this.defers[auth]; throw { httpStatus: error.httpStatus, message: this.getErrorMessage(error), }; }
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
InterfaceDeclaration
/** * Authorization options of the project */ export interface IAuthOptions { /** * Project ID */ readonly projectID?: string | null; /** * Project Zone */ readonly zone?: string | null; /** * Project URL (using this field overrides zone and projectID when composing the project url) */ r...
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
TypeAliasDeclaration
/** * API interface of the authorization token */ export type Tokens = { /** * JSON web token */ access_token: string, /** * Refresh token */ refresh_token: string, };
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
MethodDeclaration
/** * Get access token for the specific authentication alias (APK by default) * When a token is expired, try to refresh the token * @param {string} auth Authentication alias */ public token(auth?: string): Observable<string> { // refreshing a token means: cancel current digest for expired token, fetch n...
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
MethodDeclaration
private validateAuthOptions({ projectID, projectURL }: IAuthOptions): void { if (!projectID && !projectURL) { throw this.authOptionsError; } }
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
MethodDeclaration
/** * Initialize Token Manager * should be always initialized with projectID * ApiKey auth is optional * @param {IAuthOptions} opts Initialize options */ public init(opts: IAuthOptions): Promise<TokenManager> { this.validateAuthOptions(opts); this.config = opts; this.initPromise = Promise.r...
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
MethodDeclaration
/** Terminate token manager and clear all tokens */ public terminate(): void { this.storage.clear(); this.refreshes.forEach(timeout => clearTimeout(timeout)); this.refreshes.clear(); }
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
MethodDeclaration
/** * Set specific token to use by default * @param {string} auth authentication alias */ public setDefault(auth: string): void { this.storage.setDefault(auth); }
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
MethodDeclaration
/** * Switch back to apikey token */ public resetDefault(): void { this.storage.setDefault(APIKEY_DEFAULT_ALIAS); }
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
MethodDeclaration
/** * Add new token pair and run refresh digest * @param {Array<string | undefined>} aliases an array of authenticate aliases * @param {Tokens} tokens Token pair * @param {boolean} defaults Whether to use this token by default */ public addTokens(aliases: Array<string | undefined>, tokens: Tokens, defaul...
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
MethodDeclaration
/** * Remove a token based on the name of the key * * @param {string} alias The key to identify the token */ public removeTokens(alias: string): void { this.storage.removeTokens(alias); }
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
MethodDeclaration
/** * Start refreshing digest for the specific auth based on the exp value from the token * @ignore */ private startRefreshDigest(aliases: string[], accessToken: string) { const delay = delayTokenRefresh(accessToken); const timer = setTimeout(() => { this.logger.debug("tokenManager", `refresh ${a...
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
MethodDeclaration
/** * Stop a refreshing digest * @ignore */ private removeRefreshDigest(currentAccessToken: string): void { if(this.refreshes.has(currentAccessToken)) { const timer = this.refreshes.get(currentAccessToken); clearTimeout(timer); this.refreshes.delete(currentAccessToken); } }
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
MethodDeclaration
/** * Login to the project using APK method * @ignore */ private login({auth = APIKEY_DEFAULT_ALIAS, key, secret}: IAuthOptions): Observable<Tokens> { return this.obtainTokens(auth, this.authUrl, { method: "apk", key, secret }).pipe( tap((tokens: Tokens) => this.addTokens([auth], tokens, true)), ...
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
MethodDeclaration
/** * Refresh the token * @ignore */ private refresh([auth, ...restAliases]: string[] = []): Observable<Tokens> { const tokens = this.storage.getTokens(auth); if (!tokens || !tokens.refresh_token) { throw new Error(`There is no refresh token for ${auth}`); } return this.obtainTokens(au...
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
MethodDeclaration
/** * Get tokens from the project * @ignore */ private obtainTokens(auth: string, url: string, body: object): Observable<Tokens> { let resolve: (value?: any) => void; this.defers[auth] = new Promise((r) => resolve = r); return this.requestAdapter.execute(url, { body, method: RequestMe...
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
MethodDeclaration
public getErrorMessage({ httpStatus: { code, status } }: IRequestError): string { if (code === 404) { return `Authorization failed: project ${getProjectId(this.config)} not found.`; } return `Authorization failed: ${code} ${status}`; }
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript