diff --git a/lib/utils/sdJwt.ts b/lib/utils/sdJwt.ts index 3a025b45..94ba2c1c 100644 --- a/lib/utils/sdJwt.ts +++ b/lib/utils/sdJwt.ts @@ -1,7 +1,5 @@ -import { Disclosure } from '@sd-jwt/core'; -import { getDisclosuresForPresentationFrame } from '@sd-jwt/core/build/sdJwt'; -import { swapClaims } from '@sd-jwt/core/build/sdJwt/swapClaim'; -import { PresentationFrame } from '@sd-jwt/core/build/types/present'; +import { decodeDisclosuresInPayload } from '@sd-jwt/decode'; +import { getDisclosuresForPresentationFrame, PresentationFrame } from '@sd-jwt/present'; import { Base64url } from '@sd-jwt/utils'; import { Hasher, @@ -21,7 +19,7 @@ export function calculateSdHash(compactSdJwtVc: string, alg: string, hasher: Has * `decodedPayload`, `compactSdJwt` and `disclosures` properties. * * Both the input and output interfaces of this method are defined in `@sphereon/ssi-types`, so - * this method hides the actual implementation of SD-JWT (which is currently based on @sd-jwt/core) + * this method hides the actual implementation of SD-JWT (which is currently based on @sd-jwt/*) */ export function applySdJwtLimitDisclosure( sdJwtDecodedVerifiableCredential: SdJwtDecodedVerifiableCredential, @@ -32,12 +30,18 @@ export function applySdJwtLimitDisclosure( presentationFrame as PresentationFrame>, sdJwtDecodedVerifiableCredential.decodedPayload, // Map to sd-jwt disclosure format - sdJwtDecodedVerifiableCredential.disclosures.map((d) => Disclosure.fromString(d.encoded).withDigest(d.digest)), + sdJwtDecodedVerifiableCredential.disclosures.map((d) => ({ + digest: d.digest, + encoded: d.encoded, + salt: d.decoded[0], + value: d.decoded.length === 3 ? d.decoded[2] : d.decoded[1], + key: d.decoded.length === 3 ? d.decoded[1] : undefined, + })), ); sdJwtDecodedVerifiableCredential.disclosures = requiredDisclosures.map((d) => ({ encoded: d.encoded, - decoded: d.decoded as SdJwtDecodedDisclosure, + decoded: (d.key ? [d.salt, d.key, d.value] : [d.salt, d.value]) as SdJwtDecodedDisclosure, digest: d.digest, })); @@ -50,7 +54,7 @@ export function applySdJwtLimitDisclosure( .join('~'); // Update the decoded / 'pretty' payload - sdJwtDecodedVerifiableCredential.decodedPayload = swapClaims( + sdJwtDecodedVerifiableCredential.decodedPayload = decodeDisclosuresInPayload( sdJwtDecodedVerifiableCredential.signedPayload, requiredDisclosures, ) as SdJwtDecodedVerifiableCredentialPayload; diff --git a/package.json b/package.json index 155f2468..154b5a89 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,9 @@ }, "dependencies": { "@astronautlabs/jsonpath": "^1.1.2", - "@sd-jwt/core": "^0.1.2-alpha.2", + "@sd-jwt/present": "^0.1.2-alpha.9", + "@sd-jwt/decode": "^0.1.2-alpha.9", + "@sd-jwt/utils": "^0.1.2-alpha.9", "@sphereon/pex-models": "^2.1.5", "@sphereon/ssi-types": "0.18.0", "ajv": "^8.12.0", @@ -72,11 +74,6 @@ "ts-node": "^10.9.2", "typescript": "^5.3.3" }, - "resolutions": { - "@sd-jwt/utils": "0.1.2-alpha.2", - "@sd-jwt/decode": "0.1.2-alpha.1", - "@sd-jwt/types": "0.1.2-alpha.3" - }, "files": [ "index.ts", "lib/validation/validatePDv1.js", diff --git a/yarn.lock b/yarn.lock index 2f652513..caab2bef 100644 --- a/yarn.lock +++ b/yarn.lock @@ -703,34 +703,33 @@ dependencies: buffer "*" -"@sd-jwt/core@^0.1.2-alpha.2": - version "0.1.2-alpha.2" - resolved "https://registry.yarnpkg.com/@sd-jwt/core/-/core-0.1.2-alpha.2.tgz#572680c388f8c9d0922b849ac87b43c5c88e2672" - integrity sha512-MNBzv3TtBRwnlYoCrzS0tMcQIdesiN4H3XbCYbZr7Ku0lLbBJtWR2hp6xEyC3VQPlphC6XCUNOvNoRhDsVgVmg== - dependencies: - "@sd-jwt/decode" "workspace:*" - "@sd-jwt/types" "workspace:*" - "@sd-jwt/utils" "workspace:*" - -"@sd-jwt/decode@0.1.2-alpha.1", "@sd-jwt/decode@workspace:*": - version "0.1.2-alpha.1" - resolved "https://registry.yarnpkg.com/@sd-jwt/decode/-/decode-0.1.2-alpha.1.tgz#163c6bf4f0702c6d310ccc3f3f3c726863d8c30e" - integrity sha512-gm6iQeNVZFErk2yvhsK1Q48koGbJPGh6yFDEd9ACdprOkzHI/TAz9ytJbxmHk4wTmpy1MBxnKuljzaSGOcQXEw== - dependencies: - "@sd-jwt/types" "workspace:*" - "@sd-jwt/utils" "workspace:*" - -"@sd-jwt/types@0.1.2-alpha.3", "@sd-jwt/types@workspace:*": - version "0.1.2-alpha.3" - resolved "https://registry.yarnpkg.com/@sd-jwt/types/-/types-0.1.2-alpha.3.tgz#5e42ceb18a6b6e3cb9cdc9607a2c3d27d7ab12df" - integrity sha512-xeP2Z+Ub8nsdbuT2JqQDYs93C1TTNm9efZI8+rAxlyeUuCl2sbJnWiUR39kU6jlYKYs1U7c31wMf8aP4yMMUdg== - -"@sd-jwt/utils@0.1.2-alpha.2", "@sd-jwt/utils@workspace:*": - version "0.1.2-alpha.2" - resolved "https://registry.yarnpkg.com/@sd-jwt/utils/-/utils-0.1.2-alpha.2.tgz#df94cc675bb0a43df44f327ec5142260ccf49add" - integrity sha512-jl6Tk7agFdi9Ebeg3S3HdI7wl0uvelknSKM/X5DGx6a5EomJyx40dOc+KKeNf22me+8l8QJ7a0JyNkD/RP3KQQ== - dependencies: - "@sd-jwt/types" "workspace:*" +"@sd-jwt/decode@^0.1.2-alpha.9": + version "0.1.2-alpha.9" + resolved "https://registry.yarnpkg.com/@sd-jwt/decode/-/decode-0.1.2-alpha.9.tgz#02bb88725ba8e3ca0957624ef3eee7d2e3dc2ef9" + integrity sha512-3Hx5yd1b9gDC0wK7ZkNVzKevyvdGGkmV+mK7/LBUIR+q5SLZlwOmIHz80EM+8Eg0WFAnAmRgWKjn7jWWRQO5dw== + dependencies: + "@sd-jwt/types" "0.1.2-alpha.9" + "@sd-jwt/utils" "0.1.2-alpha.9" + +"@sd-jwt/present@^0.1.2-alpha.9": + version "0.1.2-alpha.9" + resolved "https://registry.yarnpkg.com/@sd-jwt/present/-/present-0.1.2-alpha.9.tgz#f0577dcc66dc08e6bc91faf108565e0fc40d2383" + integrity sha512-LR7uIoC4As2EmGke+lCv2GifG2Xmr4iEFacx30GJW1n35T7vRBDpldIuoMNqHmsR+z3eHx/TWtjrXsh7lGcFtw== + dependencies: + "@sd-jwt/types" "0.1.2-alpha.9" + "@sd-jwt/utils" "0.1.2-alpha.9" + +"@sd-jwt/types@0.1.2-alpha.9": + version "0.1.2-alpha.9" + resolved "https://registry.yarnpkg.com/@sd-jwt/types/-/types-0.1.2-alpha.9.tgz#198899e3a98f9329f35b20fd8af5c1ee37e1e739" + integrity sha512-j7Nf3RhQshkEjf3RQhF5hWMMOPQmzwhXBUhjcOoF5eJNgkpF6R13ryb3GDJHkRomIhkygaWaFEzC+ioRAZ7FzQ== + +"@sd-jwt/utils@0.1.2-alpha.9", "@sd-jwt/utils@^0.1.2-alpha.9": + version "0.1.2-alpha.9" + resolved "https://registry.yarnpkg.com/@sd-jwt/utils/-/utils-0.1.2-alpha.9.tgz#efbde280798afb964e829726214167f50e7022a3" + integrity sha512-oPNWO/XDUkJxdEyOZvmLoqCo0uwiu5Xk0wGkmpwB9KtzeaioVW3JziFUswEczE9RED4+dOWtQwbSpEcy1DEWQw== + dependencies: + "@sd-jwt/types" "0.1.2-alpha.9" buffer "*" "@sinclair/typebox@^0.27.8":