Compare commits

...
2 Commits
Author SHA1 Message Date
Ruslan Bakiev a89e66f373 Return KYC approval timestamps
Build and deploy Docker image / build (push) Successful in 1m7s
2026-08-20 19:07:39 +07:00
Ruslan Bakiev 9417aa95bb Authorize default client access
Build and deploy Docker image / build (push) Successful in 4m6s
2026-08-20 18:52:07 +07:00
3 changed files with 11 additions and 5 deletions
+8 -4
View File
@@ -32,6 +32,10 @@ function scopesFromPayload(payload: JWTPayload): string[] {
return [];
}
function clientScopes(payload: JWTPayload): string[] {
return [...new Set([...scopesFromPayload(payload), "teams:user"])];
}
function claimList(payload: JWTPayload, key: string): string[] {
const value = (payload as Record<string, unknown>)[key];
if (typeof value === "string") return value.split(" ");
@@ -57,12 +61,12 @@ export async function publicContext(req: FastifyRequest): Promise<AuthContext> {
issuer: LOGTO_ISSUER,
audience: LOGTO_KYC_AUDIENCE,
});
const scopes = scopesFromPayload(payload);
if (!scopes.includes("teams:user")) {
if (!payload.sub) {
throw new GraphQLError("Unauthorized", {
extensions: { code: "UNAUTHENTICATED" },
});
}
const scopes = clientScopes(payload);
return { userId: payload.sub, scopes };
}
@@ -77,12 +81,12 @@ export async function userContext(req: FastifyRequest): Promise<AuthContext> {
issuer: LOGTO_ISSUER,
audience: LOGTO_KYC_AUDIENCE,
});
const scopes = scopesFromPayload(payload);
if (!scopes.includes("teams:user")) {
if (!payload.sub) {
throw new GraphQLError("Unauthorized", {
extensions: { code: "UNAUTHENTICATED" },
});
}
const scopes = clientScopes(payload);
return { userId: payload.sub, scopes };
}
+2
View File
@@ -14,6 +14,7 @@ export const userTypeDefs = `#graphql
contactPerson: String
contactEmail: String
contactPhone: String
approvedAt: String
countryData: String
createdAt: String!
updatedAt: String!
@@ -140,6 +141,7 @@ export const userResolvers = {
createKycRequestRussia: createApplicationRussia,
},
KYCApplication: {
approvedAt: (parent: { approvedAt: Date | null }) => parent.approvedAt?.toISOString() ?? null,
countryData: async (parent: { objectId: number | null }) => getCountryData(parent),
createdAt: (parent: { createdAt: Date }) => parent.createdAt.toISOString(),
updatedAt: (parent: { updatedAt: Date }) => parent.updatedAt.toISOString(),