Skip to content

Commit

Permalink
Merge pull request #522 from wwWallet/shared-library-fix-code-format
Browse files Browse the repository at this point in the history
Fix code format on `shared-library`
  • Loading branch information
gkatrakazas authored Feb 20, 2025
2 parents af66b14 + 469bb6d commit 28429b7
Show file tree
Hide file tree
Showing 26 changed files with 136 additions and 144 deletions.
10 changes: 5 additions & 5 deletions lib/core/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"editor.tabSize": 2,
"editor.detectIndentation": false,
"editor.insertSpaces": false,
"remote.autoForwardPorts": false
}
"editor.tabSize": 2,
"editor.detectIndentation": false,
"editor.insertSpaces": false,
"remote.autoForwardPorts": false
}
1 change: 0 additions & 1 deletion lib/core/src/ParsingEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { CredentialParsingError } from "./error";
import { CredentialParser, ParsingEngineI } from "./interfaces";
import { VerifiableCredentialFormat } from "./types";


export function ParsingEngine(): ParsingEngineI {
const parsers: CredentialParser[] = [];

Expand Down
3 changes: 1 addition & 2 deletions lib/core/src/PublicKeyResolverEngine.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { PublicKeyResolutionError } from "./error";
import { PublicKeyResolver, PublicKeyResolverEngineI } from "./interfaces";



export function PublicKeyResolverEngine(): PublicKeyResolverEngineI {
const resolvers: PublicKeyResolver[] = [];

Expand All @@ -21,3 +19,4 @@ export function PublicKeyResolverEngine(): PublicKeyResolverEngineI {
},
}
}

2 changes: 1 addition & 1 deletion lib/core/src/VerifyingEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ export function VerifyingEngine(): VerifyingEngineI {
}
}
}
}
}
2 changes: 1 addition & 1 deletion lib/core/src/credential-parsers/MsoMdocParser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ describe("The MsoMdocParser", () => {

})

})
})
3 changes: 1 addition & 2 deletions lib/core/src/credential-parsers/MsoMdocParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { fromBase64Url } from "../utils/util";
import { ParsedCredential, VerifiableCredentialFormat } from "../types";
import { cborDecode, cborEncode } from "@auth0/mdl/lib/cbor";


export function MsoMdocParser(args: { context: Context, httpClient: HttpClient }): CredentialParser {

async function deviceResponseParser(rawCredential: string): Promise<ParsedCredential | null> {
Expand Down Expand Up @@ -114,4 +113,4 @@ export function MsoMdocParser(args: { context: Context, httpClient: HttpClient }
}
},
}
}
}
6 changes: 3 additions & 3 deletions lib/core/src/credential-parsers/SDJWTVCParser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ const expiredCredential = `eyJ0eXAiOiJ2YytzZC1qd3QiLCJ2Y3RtIjpbImV5SjJZM1FpT2lKM

const httpClient: HttpClient = {
async get(url, headers) {
return axios.get(url, { headers: headers as AxiosHeaders }).then((res) => (res?.data ? {...res.data} : {})).catch((err) => (err?.response?.data ? {...err.response.data} : { }));
return axios.get(url, { headers: headers as AxiosHeaders }).then((res) => (res?.data ? { ...res.data } : {})).catch((err) => (err?.response?.data ? { ...err.response.data } : {}));
},
async post(url, data, headers) {
return axios.post(url, data, { headers: headers as AxiosHeaders }).then((res) => (res?.data ? {...res.data} : {})).catch((err) => (err?.response?.data ? {...err.response.data} : { }));
return axios.post(url, data, { headers: headers as AxiosHeaders }).then((res) => (res?.data ? { ...res.data } : {})).catch((err) => (err?.response?.data ? { ...err.response.data } : {}));
},
}

Expand All @@ -37,4 +37,4 @@ describe("The SDJWTVCParser", () => {
const parsedCredential = await parser.parse({ rawCredential: expiredCredential });
assert(parsedCredential.success);
})
})
})
2 changes: 1 addition & 1 deletion lib/core/src/credential-parsers/SDJWTVCParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,4 @@ export function SDJWTVCParser(args: { context: Context, httpClient: HttpClient }
}
},
}
}
}
2 changes: 1 addition & 1 deletion lib/core/src/credential-verifiers/MsoMdocVerifier.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ describe("The MsoMdocVerifier", () => {
assert(result.success === false);
assert(result.error === CredentialVerificationError.NotTrustedIssuer);
});
})
})
2 changes: 1 addition & 1 deletion lib/core/src/credential-verifiers/MsoMdocVerifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,4 +222,4 @@ export function MsoMdocVerifier(args: { context: Context, resolverEngine: Public
}
},
}
}
}
2 changes: 1 addition & 1 deletion lib/core/src/credential-verifiers/SDJWTVCVerifier.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ describe("The SDJWTVerifier", () => {
});


})
})
4 changes: 2 additions & 2 deletions lib/core/src/credential-verifiers/SDJWTVCVerifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export function SDJWTVCVerifier(args: { context: Context, pkResolverEngine: Publ
}
}
const { sd_hash, nonce, aud } = kbJwtDecodedPayload as { sd_hash: string, nonce: string, aud: string };

const data = encoder.encode(rawCredentialWithoutKbJwt);

const hashBuffer = await args.context.subtle.digest('SHA-256', data);
Expand Down Expand Up @@ -267,4 +267,4 @@ export function SDJWTVCVerifier(args: { context: Context, pkResolverEngine: Publ
}
},
}
}
}
4 changes: 2 additions & 2 deletions lib/core/src/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export enum CredentialVerificationError {

InvalidSignature = "InvalidSignature",
CannotResolveIssuerPublicKey = "CannotResolveIssuerPublicKey",
CannotImportIssuerPublicKey = "CannotImportIssuerPublicKey",
CannotImportIssuerPublicKey = "CannotImportIssuerPublicKey",
NotTrustedIssuer = "NotTrustedIssuer",

ExpiredCredential = "ExpiredCredential",
Expand Down Expand Up @@ -59,4 +59,4 @@ export enum PublicKeyResolutionError {
export enum CredentialRenderingError {
IntegrityCheckFailed = "IntegrityCheckFailed",
CouldNotFetchSvg = "CouldNotFetchSvg",
}
}
2 changes: 1 addition & 1 deletion lib/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ export * from './PublicKeyResolverEngine';

export * from './interfaces';

export * from './schemas';
export * from './schemas';
1 change: 0 additions & 1 deletion lib/core/src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { JWK } from "jose";
import { CredentialParsingError, CredentialVerificationError, PublicKeyResolutionError, CredentialRenderingError, ValidatePresentationRequirementsError } from "./error";
import { Result, ParsedCredential, VerifiableCredentialFormat } from "./types";


export interface CredentialRendering {
renderSvgTemplate(args: {
json: any;
Expand Down
2 changes: 1 addition & 1 deletion lib/core/src/rendering.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,4 @@ describe("The CredentialRendering", () => {
assert(dataUri !== null, "Svg not rendered");
assert(isValidSVG(dataUri) == true, "Not valid generated datauri svg");
});
})
})
14 changes: 7 additions & 7 deletions lib/core/src/rendering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export function CredentialRenderingService(): CredentialRendering {
} catch (error) {
return null; // Return null if fetching fails
}

if (svgContent) {
// Build pathMap from credentialHeader.vctm.claims
const pathMap = sdJwtVcMetadataClaims.reduce((acc: any, claim: any) => {
Expand All @@ -20,20 +20,20 @@ export function CredentialRenderingService(): CredentialRendering {
}
return acc;
}, {});

// Regular expression to match {{svg_id}} placeholders
const regex = /{{([^}]+)}}/g;
const replacedSvgText = svgContent.replace(regex, (_match, svgId) => {
// Retrieve the path array for the current svgId from pathMap
const pathArray = pathMap[svgId];

// If pathArray exists, convert it to a JSON pointer path
if (Array.isArray(pathArray)) {
const jsonPointerPath = `/${pathArray.join('/')}`;

// Retrieve the value from beautifiedForm using jsonpointer
let value = jsonpointer.get(json, jsonPointerPath);

if (value !== undefined) {
value = formatDate(value, 'date');
return value;
Expand All @@ -44,11 +44,11 @@ export function CredentialRenderingService(): CredentialRendering {
const dataUri = `data:image/svg+xml;utf8,${encodeURIComponent(replacedSvgText)}`;
return dataUri; // Return the data URI for the SVG
}

return null;
};

return {
renderSvgTemplate,
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ export const OpenidAuthorizationServerMetadataSchema = z.object({
dpop_signing_alg_values_supported: z.array(z.string()).optional(),
});


export type OpenidAuthorizationServerMetadata = z.infer<typeof OpenidAuthorizationServerMetadataSchema>;
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@ export const OpenidCredentialIssuerMetadataSchema = z.object({
signed_metadata: z.string().optional(),
})


export type OpenidCredentialIssuerMetadata = z.infer<typeof OpenidCredentialIssuerMetadataSchema>;
2 changes: 1 addition & 1 deletion lib/core/src/schemas/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export * from './CredentialConfigurationSupportedSchema';
export * from './CredentialOfferSchema';
export * from './OpenidAuthorizationServerMetadataSchema';
export * from './OpenidCredentialIssuerMetadataSchema';
export * from './OpenidCredentialIssuerMetadataSchema';
5 changes: 2 additions & 3 deletions lib/core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ export enum VerifiableCredentialFormat {
}

export type CredentialIssuer = {
id: string; // must have the value of "iss" attribute of an SD-JWT VC credential
id: string; // must have the value of "iss" attribute of an SD-JWT VC credential
name: string;

// ...other metadata
}

export type CredentialClaims = Record<string, unknown>;


export type Result<T, E> = { success: true; value: T } | { success: false; error: E };

export type ParsedCredential = {
Expand All @@ -28,4 +27,4 @@ export type ParsedCredential = {
issuer: CredentialIssuer,
},
signedClaims: CredentialClaims,
};
};
1 change: 0 additions & 1 deletion lib/core/src/utils/getSdJwtVcMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export async function getSdJwtVcMetadata(credential: string): Promise<{ credenti
}
}


// use vct to fetch metadata if hosted
const fetchResult = (await axios.get(credentialPayload.vct).catch(() => null));
if (fetchResult && fetchResult.data.vct === credentialPayload.vct) {
Expand Down
Loading

0 comments on commit 28429b7

Please sign in to comment.