UNPKG

cnpmcore

Version:

Private NPM Registry for Enterprise

51 lines (50 loc) 1.53 kB
import { type EasyData } from '../util/EntityUtil.ts'; import { Entity, type EntityData } from './Entity.ts'; export declare enum TokenType { granular = "granular", classic = "classic" } interface BaseTokenData extends EntityData { tokenId: string; tokenMark: string; tokenKey: string; cidrWhitelist?: string[]; userId: string; isReadonly?: boolean; type?: TokenType | string; lastUsedAt?: Date; } interface ClassicTokenData extends BaseTokenData { isAutomation?: boolean; } interface GranularTokenData extends BaseTokenData { name: string; description?: string; allowedScopes?: string[]; allowedPackages?: string[]; expires: number; expiredAt: Date; } type TokenData = ClassicTokenData | GranularTokenData; export declare function isGranularToken(data: TokenData | Token): data is GranularTokenData; export declare class Token extends Entity { readonly tokenId: string; readonly tokenMark: string; readonly tokenKey: string; readonly cidrWhitelist: string[]; readonly userId: string; readonly isReadonly: boolean; readonly isAutomation: boolean; readonly type?: TokenType; readonly name?: string; readonly description?: string; readonly allowedScopes?: string[]; readonly expiredAt?: Date; readonly expires?: number; lastUsedAt: Date | null; allowedPackages?: string[]; token: string; constructor(data: TokenData); static create(data: EasyData<TokenData, 'tokenId'>): Token; } export {};