feat(tokens): Add support for organization-owned API tokens and org-level token management
This commit is contained in:
@@ -39,11 +39,21 @@ export interface IPackage {
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface ITokenScope {
|
||||
protocol: string;
|
||||
organizationId?: string;
|
||||
repositoryId?: string;
|
||||
actions: string[];
|
||||
}
|
||||
|
||||
export interface IToken {
|
||||
id: string;
|
||||
name: string;
|
||||
tokenPrefix: string;
|
||||
protocols: string[];
|
||||
scopes?: ITokenScope[];
|
||||
organizationId?: string;
|
||||
createdById?: string;
|
||||
expiresAt?: string;
|
||||
lastUsedAt?: string;
|
||||
usageCount: number;
|
||||
@@ -179,14 +189,21 @@ export class ApiService {
|
||||
}
|
||||
|
||||
// Tokens
|
||||
getTokens(): Observable<{ tokens: IToken[] }> {
|
||||
return this.http.get<{ tokens: IToken[] }>(`${this.baseUrl}/tokens`);
|
||||
getTokens(organizationId?: string): Observable<{ tokens: IToken[] }> {
|
||||
let httpParams = new HttpParams();
|
||||
if (organizationId) {
|
||||
httpParams = httpParams.set('organizationId', organizationId);
|
||||
}
|
||||
return this.http.get<{ tokens: IToken[] }>(`${this.baseUrl}/tokens`, {
|
||||
params: httpParams,
|
||||
});
|
||||
}
|
||||
|
||||
createToken(data: {
|
||||
name: string;
|
||||
organizationId?: string;
|
||||
protocols: string[];
|
||||
scopes: { protocol: string; actions: string[] }[];
|
||||
scopes: ITokenScope[];
|
||||
expiresInDays?: number;
|
||||
}): Observable<IToken & { token: string }> {
|
||||
return this.http.post<IToken & { token: string }>(
|
||||
|
||||
Reference in New Issue
Block a user