Skip to content

Commit

Permalink
fix: change SDJwtPayload to SdJwtPayload
Browse files Browse the repository at this point in the history
Signed-off-by: Mirko Mollik <[email protected]>
  • Loading branch information
cre8 committed Mar 8, 2024
1 parent aef22da commit 9f06ef7
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ export * from './kbjwt';
export * from './jwt';
export * from './decoy';

export type SdJwtPayload = Record<string, unknown>
export type SdJwtPayload = Record<string, unknown>;

export abstract class SDJwtInstance<ExtendedPayload extends SDJwtPayload> {
export abstract class SDJwtInstance<ExtendedPayload extends SdJwtPayload> {
//header type
protected abstract type: string;

Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/test/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { SDJwtInstance, SDJwtPayload } from '../index';
import { SDJwtInstance, SdJwtPayload } from '../index';
import { DisclosureFrame, Signer, Verifier } from '@sd-jwt/types';
import Crypto from 'node:crypto';
import { describe, expect, test } from 'vitest';
import { digest, generateSalt } from '@sd-jwt/crypto-nodejs';

export class TestInstance extends SDJwtInstance<SDJwtPayload> {
export class TestInstance extends SDJwtInstance<SdJwtPayload> {
protected type = 'sd-jwt';

protected validateReservedFields(
disclosureFrame: DisclosureFrame<SDJwtPayload>,
disclosureFrame: DisclosureFrame<SdJwtPayload>,
): void {
return;
}
Expand Down
6 changes: 3 additions & 3 deletions packages/core/test/app-e2e.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Crypto from 'node:crypto';
import { SDJwtPayload } from '../src';
import { SdJwtPayload } from '../src';
import { DisclosureFrame, SD, Signer, Verifier } from '@sd-jwt/types';
import fs from 'fs';
import path from 'path';
Expand Down Expand Up @@ -235,8 +235,8 @@ async function JSONtest(filename: string) {
}

type TestJson = {
claims: SDJwtPayload;
disclosureFrame: DisclosureFrame<SDJwtPayload>;
claims: SdJwtPayload;
disclosureFrame: DisclosureFrame<SdJwtPayload>;
presentationKeys: string[];
presenatedClaims: object;
requiredClaimKeys: string[];
Expand Down
12 changes: 6 additions & 6 deletions packages/decode/src/decode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,8 @@ export const createHashMappingSync = (
};

// Extract _sd_alg. If it is not present, it is assumed to be sha-256
export const getSDAlgAndPayload = (sdjwtPayload: Record<string, unknown>) => {
const { _sd_alg, ...payload } = sdjwtPayload;
export const getSDAlgAndPayload = (SdJwtPayload: Record<string, unknown>) => {
const { _sd_alg, ...payload } = SdJwtPayload;
if (typeof _sd_alg !== 'string') {
// This is for compatibility
return { _sd_alg: 'sha-256', payload };
Expand All @@ -283,23 +283,23 @@ export const getSDAlgAndPayload = (sdjwtPayload: Record<string, unknown>) => {
// Match the digests of the disclosures with the claims and extract the claims
// unpack function use unpackObj and unpackArray to recursively unpack the claims
export const unpack = async (
sdjwtPayload: Record<string, unknown>,
SdJwtPayload: Record<string, unknown>,
disclosures: Array<Disclosure>,
hasher: Hasher,
) => {
const { _sd_alg, payload } = getSDAlgAndPayload(sdjwtPayload);
const { _sd_alg, payload } = getSDAlgAndPayload(SdJwtPayload);
const hash = { hasher, alg: _sd_alg };
const map = await createHashMapping(disclosures, hash);

return unpackObj(payload, map);
};

export const unpackSync = (
sdjwtPayload: Record<string, unknown>,
SdJwtPayload: Record<string, unknown>,
disclosures: Array<Disclosure>,
hasher: HasherSync,
) => {
const { _sd_alg, payload } = getSDAlgAndPayload(sdjwtPayload);
const { _sd_alg, payload } = getSDAlgAndPayload(SdJwtPayload);
const hash = { hasher, alg: _sd_alg };
const map = createHashMappingSync(disclosures, hash);

Expand Down
4 changes: 2 additions & 2 deletions packages/sd-jwt-vc/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { SDJwt, SDJwtInstance, SDJwtPayload } from '@sd-jwt/core';
import { SDJwt, SDJwtInstance, SdJwtPayload } from '@sd-jwt/core';
import { DisclosureFrame } from '@sd-jwt/types';
import { SDJWTException } from '../../utils/dist';

export interface SdJwtVcPayload extends SDJwtPayload {
export interface SdJwtVcPayload extends SdJwtPayload {
// The Issuer of the Verifiable Credential. The value of iss MUST be a URI. See [RFC7519] for more information.
iss: string;
// The time of issuance of the Verifiable Credential. See [RFC7519] for more information.
Expand Down

0 comments on commit 9f06ef7

Please sign in to comment.