UNPKG

propylons-client

Version:
74 lines (73 loc) 2.24 kB
/*! * Propylons * Copyright(c) 2022 Xavier Raffin * MIT Licensed */ export declare enum TokenType { USER = "USER", API_KEY = "API_KEY" } export interface StandardJWTToken { email: string; sub: string; aud: string; iss: string; token_use: string; auth_time: number; exp: number; } export interface RawToken extends StandardJWTToken { assumedByUserEmail?: string; assumedByUserId?: string; assumedByGroup?: string; assumedBySub?: string; email_verified?: boolean; locale?: string; tokenType: TokenType; top_level_account_features?: string; } export declare class BaseToken { readonly isAssumed: boolean; readonly loggedInFromSSO: boolean; readonly id: string; readonly email: string; readonly isEmailVerified: boolean; readonly timezone: string | undefined; readonly country: string | undefined; readonly locale: string | undefined; readonly groups: string[]; readonly associatedSSOProviders: string[]; readonly sub: string; readonly assumedByUserEmail: string | undefined; readonly assumedByUserId: string | undefined; readonly assumedByGroup: string | undefined; readonly assumedBySub: string | undefined; constructor(rawToken: RawToken); } export declare enum ContextType { USER = "USER", WORKSPACE = "WORKSPACE", ORGANISATION = "ORGANISATION" } export declare class OwnershipContext { readonly type: ContextType; readonly id: string; constructor(type: ContextType, id: string); static fromUserId(id: string | number): OwnershipContext; static fromWorkspaceId(id: string | number): OwnershipContext; static fromOrganisationId(id: string | number): OwnershipContext; /** /!\ Cannot tell workspace and org ids apart, so assuming workspace id if negative */ static fromJobOwnerId(id: string | number): OwnershipContext; isUser(): boolean; isWorkspace(): boolean; isOrganisation(): boolean; isJobOwner(): boolean; isAccount(): boolean; ownerId(): number; comboId(): number; assertUserId(): number; assertWorkspaceId(): number; assertOrganisationId(): number; assertJobOwnerId(): number; assertAccountId(): number; }