feat: Use V2 API's in Console (#9312)

# Which Problems Are Solved
Solves #8976

# Additional Changes
I have done some intensive refactorings and we are using the new
@zitadel/client package for GRPC access.

# Additional Context
- Closes #8976

---------

Co-authored-by: Max Peintner <[email protected]>
This commit is contained in:
Ramon
2025-02-17 19:25:46 +01:00
committed by GitHub
co-authored by Max Peintner
parent ad225836d5
commit 3042bbb993
90 changed files with 3679 additions and 2315 deletions
@@ -1,5 +1,5 @@
import { Injectable } from '@angular/core';
import { Request, UnaryInterceptor, UnaryResponse } from 'grpc-web';
import { Request, RpcError, StatusCode, UnaryInterceptor, UnaryResponse } from 'grpc-web';
import { Org } from 'src/app/proto/generated/zitadel/org_pb';
import { StorageKey, StorageLocation, StorageService } from '../storage.service';
@@ -9,7 +9,7 @@ const ORG_HEADER_KEY = 'x-zitadel-orgid';
export class OrgInterceptor<TReq = unknown, TResp = unknown> implements UnaryInterceptor<TReq, TResp> {
constructor(private readonly storageService: StorageService) {}
public intercept(request: Request<TReq, TResp>, invoker: any): Promise<UnaryResponse<TReq, TResp>> {
public async intercept(request: Request<TReq, TResp>, invoker: any): Promise<UnaryResponse<TReq, TResp>> {
const metadata = request.getMetadata();
const org: Org.AsObject | null = this.storageService.getItem(StorageKey.organization, StorageLocation.session);
@@ -18,15 +18,17 @@ export class OrgInterceptor<TReq = unknown, TResp = unknown> implements UnaryInt
metadata[ORG_HEADER_KEY] = `${org.id}`;
}
return invoker(request)
.then((response: any) => {
return response;
})
.catch((error: any) => {
if (error.code === 7 && error.message.startsWith("Organisation doesn't exist")) {
this.storageService.removeItem(StorageKey.organization, StorageLocation.session);
}
return Promise.reject(error);
});
try {
return await invoker(request);
} catch (error: any) {
if (
error instanceof RpcError &&
error.code === StatusCode.PERMISSION_DENIED &&
error.message.startsWith("Organisation doesn't exist")
) {
this.storageService.removeItem(StorageKey.organization, StorageLocation.session);
}
throw error;
}
}
}