@1shotapi/ows-types 0.13.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/dist/eip1193/eip7715.d.ts +22 -18
  2. package/dist/eip1193/eip7715.d.ts.map +1 -1
  3. package/dist/errors/rpc.d.ts +0 -6
  4. package/dist/errors/rpc.d.ts.map +1 -1
  5. package/dist/errors/rpc.js +0 -10
  6. package/dist/errors/rpc.js.map +1 -1
  7. package/dist/errors/signer.d.ts +0 -5
  8. package/dist/errors/signer.d.ts.map +1 -1
  9. package/dist/errors/signer.js +0 -10
  10. package/dist/errors/signer.js.map +1 -1
  11. package/dist/index.d.ts +5 -4
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +5 -4
  14. package/dist/index.js.map +1 -1
  15. package/dist/primitives/Base64String.d.ts +13 -0
  16. package/dist/primitives/Base64String.d.ts.map +1 -0
  17. package/dist/primitives/Base64String.js +13 -0
  18. package/dist/primitives/Base64String.js.map +1 -0
  19. package/dist/primitives/OWSChainId.d.ts +13 -12
  20. package/dist/primitives/OWSChainId.d.ts.map +1 -1
  21. package/dist/primitives/OWSChainId.js.map +1 -1
  22. package/dist/primitives/SolanaATAAddress.d.ts +16 -0
  23. package/dist/primitives/SolanaATAAddress.d.ts.map +1 -0
  24. package/dist/primitives/SolanaATAAddress.js +22 -0
  25. package/dist/primitives/SolanaATAAddress.js.map +1 -0
  26. package/dist/primitives/SolanaAccountAddress.d.ts +6 -1
  27. package/dist/primitives/SolanaAccountAddress.d.ts.map +1 -1
  28. package/dist/primitives/SolanaAccountAddress.js +13 -16
  29. package/dist/primitives/SolanaAccountAddress.js.map +1 -1
  30. package/dist/primitives/SolanaChainId.d.ts +23 -14
  31. package/dist/primitives/SolanaChainId.d.ts.map +1 -1
  32. package/dist/primitives/SolanaChainId.js +14 -5
  33. package/dist/primitives/SolanaChainId.js.map +1 -1
  34. package/dist/primitives/SolanaMintAddress.d.ts +17 -0
  35. package/dist/primitives/SolanaMintAddress.d.ts.map +1 -0
  36. package/dist/primitives/SolanaMintAddress.js +22 -0
  37. package/dist/primitives/SolanaMintAddress.js.map +1 -0
  38. package/dist/primitives/SolanaProgramAddress.d.ts +17 -0
  39. package/dist/primitives/SolanaProgramAddress.d.ts.map +1 -0
  40. package/dist/primitives/SolanaProgramAddress.js +22 -0
  41. package/dist/primitives/SolanaProgramAddress.js.map +1 -0
  42. package/dist/primitives/SolanaSignature.d.ts +12 -0
  43. package/dist/primitives/SolanaSignature.d.ts.map +1 -0
  44. package/dist/primitives/SolanaSignature.js +21 -0
  45. package/dist/primitives/SolanaSignature.js.map +1 -0
  46. package/dist/primitives/SolanaTransactionHash.d.ts +13 -0
  47. package/dist/primitives/SolanaTransactionHash.d.ts.map +1 -0
  48. package/dist/primitives/SolanaTransactionHash.js +21 -0
  49. package/dist/primitives/SolanaTransactionHash.js.map +1 -0
  50. package/dist/primitives/TransactionHash.d.ts +13 -0
  51. package/dist/primitives/TransactionHash.d.ts.map +1 -0
  52. package/dist/primitives/TransactionHash.js +22 -0
  53. package/dist/primitives/TransactionHash.js.map +1 -0
  54. package/dist/primitives/index.d.ts +7 -0
  55. package/dist/primitives/index.d.ts.map +1 -1
  56. package/dist/primitives/index.js +7 -0
  57. package/dist/primitives/index.js.map +1 -1
  58. package/dist/protocol/solana.d.ts +95 -0
  59. package/dist/protocol/solana.d.ts.map +1 -0
  60. package/dist/protocol/solana.js +18 -0
  61. package/dist/protocol/solana.js.map +1 -0
  62. package/dist/protocol/wallet.d.ts +0 -1
  63. package/dist/protocol/wallet.d.ts.map +1 -1
  64. package/dist/protocol/wallet.js +0 -1
  65. package/dist/protocol/wallet.js.map +1 -1
  66. package/dist/utils/ChainUtils.d.ts +4 -1
  67. package/dist/utils/ChainUtils.d.ts.map +1 -1
  68. package/dist/utils/ChainUtils.js +15 -2
  69. package/dist/utils/ChainUtils.js.map +1 -1
  70. package/dist/utils/ConversionUtils.d.ts +28 -6
  71. package/dist/utils/ConversionUtils.d.ts.map +1 -1
  72. package/dist/utils/ConversionUtils.js +42 -6
  73. package/dist/utils/ConversionUtils.js.map +1 -1
  74. package/dist/utils/SolanaAddressUtils.d.ts +17 -0
  75. package/dist/utils/SolanaAddressUtils.d.ts.map +1 -0
  76. package/dist/utils/SolanaAddressUtils.js +27 -0
  77. package/dist/utils/SolanaAddressUtils.js.map +1 -0
  78. package/dist/utils/index.d.ts +2 -1
  79. package/dist/utils/index.d.ts.map +1 -1
  80. package/dist/utils/index.js +2 -1
  81. package/dist/utils/index.js.map +1 -1
  82. package/package.json +2 -1
  83. package/dist/primitives/BitcoinAccountAddress.d.ts +0 -8
  84. package/dist/primitives/BitcoinAccountAddress.d.ts.map +0 -1
  85. package/dist/primitives/BitcoinAccountAddress.js +0 -3
  86. package/dist/primitives/BitcoinAccountAddress.js.map +0 -1
  87. package/dist/primitives/PasskeyPublicKey.d.ts +0 -5
  88. package/dist/primitives/PasskeyPublicKey.d.ts.map +0 -1
  89. package/dist/primitives/PasskeyPublicKey.js +0 -3
  90. package/dist/primitives/PasskeyPublicKey.js.map +0 -1
  91. package/dist/utils/credentials/jwk-thumbprint.d.ts +0 -6
  92. package/dist/utils/credentials/jwk-thumbprint.d.ts.map +0 -1
  93. package/dist/utils/credentials/jwk-thumbprint.js +0 -37
  94. package/dist/utils/credentials/jwk-thumbprint.js.map +0 -1
  95. package/dist/utils/credentials/oid4vci-proof.d.ts +0 -30
  96. package/dist/utils/credentials/oid4vci-proof.d.ts.map +0 -1
  97. package/dist/utils/credentials/oid4vci-proof.js +0 -102
  98. package/dist/utils/credentials/oid4vci-proof.js.map +0 -1
  99. package/dist/utils/credentials/sd-jwt-vc/CredentialCryptoUtils.d.ts +0 -40
  100. package/dist/utils/credentials/sd-jwt-vc/CredentialCryptoUtils.d.ts.map +0 -1
  101. package/dist/utils/credentials/sd-jwt-vc/CredentialCryptoUtils.js +0 -94
  102. package/dist/utils/credentials/sd-jwt-vc/CredentialCryptoUtils.js.map +0 -1
  103. package/dist/utils/credentials/sd-jwt-vc/PresentationUtils.d.ts +0 -54
  104. package/dist/utils/credentials/sd-jwt-vc/PresentationUtils.d.ts.map +0 -1
  105. package/dist/utils/credentials/sd-jwt-vc/PresentationUtils.js +0 -123
  106. package/dist/utils/credentials/sd-jwt-vc/PresentationUtils.js.map +0 -1
  107. package/dist/utils/credentials/sd-jwt-vc/crypto.d.ts +0 -13
  108. package/dist/utils/credentials/sd-jwt-vc/crypto.d.ts.map +0 -1
  109. package/dist/utils/credentials/sd-jwt-vc/crypto.js +0 -51
  110. package/dist/utils/credentials/sd-jwt-vc/crypto.js.map +0 -1
  111. package/dist/utils/credentials/sd-jwt-vc/decode.d.ts +0 -25
  112. package/dist/utils/credentials/sd-jwt-vc/decode.d.ts.map +0 -1
  113. package/dist/utils/credentials/sd-jwt-vc/decode.js +0 -30
  114. package/dist/utils/credentials/sd-jwt-vc/decode.js.map +0 -1
  115. package/dist/utils/credentials/sd-jwt-vc/holder-signer.d.ts +0 -5
  116. package/dist/utils/credentials/sd-jwt-vc/holder-signer.d.ts.map +0 -1
  117. package/dist/utils/credentials/sd-jwt-vc/holder-signer.js +0 -5
  118. package/dist/utils/credentials/sd-jwt-vc/holder-signer.js.map +0 -1
  119. package/dist/utils/credentials/sd-jwt-vc/presentation.d.ts +0 -17
  120. package/dist/utils/credentials/sd-jwt-vc/presentation.d.ts.map +0 -1
  121. package/dist/utils/credentials/sd-jwt-vc/presentation.js +0 -58
  122. package/dist/utils/credentials/sd-jwt-vc/presentation.js.map +0 -1
  123. package/dist/utils/credentials/sd-jwt-vc/unpack-subject.d.ts +0 -8
  124. package/dist/utils/credentials/sd-jwt-vc/unpack-subject.d.ts.map +0 -1
  125. package/dist/utils/credentials/sd-jwt-vc/unpack-subject.js +0 -35
  126. package/dist/utils/credentials/sd-jwt-vc/unpack-subject.js.map +0 -1
@@ -1,123 +0,0 @@
1
- import { decodeJwt, decodeSdJwt, getClaims, splitSdJwt } from "@sd-jwt/core";
2
- import { SDJwtVcInstance } from "@sd-jwt/sd-jwt-vc";
3
- import { SdJwtVcPresentationString } from "../../../primitives/SdJwtVcPresentationString.js";
4
- import { CredentialCryptoUtils } from "./CredentialCryptoUtils.js";
5
- /** JWT / SD-JWT envelope keys excluded from credential-subject maps. */
6
- const SD_JWT_ENVELOPE_KEYS = new Set([
7
- "iss",
8
- "iat",
9
- "exp",
10
- "nbf",
11
- "vct",
12
- "cnf",
13
- "status",
14
- "_sd",
15
- "_sd_alg",
16
- "aud",
17
- "sub",
18
- "jti",
19
- ]);
20
- /**
21
- * SD-JWT VC presentation helpers: decode compact strings, unpack selective
22
- * disclosures, and build holder presentations with key binding.
23
- */
24
- export class PresentationUtils {
25
- /** Decodes issuer JWT payload claims from an SD-JWT VC compact string. */
26
- static decodeIssuerClaims(encoded) {
27
- const { jwt } = splitSdJwt(String(encoded));
28
- const { payload } = decodeJwt(jwt);
29
- return payload;
30
- }
31
- /** Reads `cnf.jwk` from an SD-JWT VC (presentation or full credential). */
32
- static extractHolderJwk(encoded) {
33
- return PresentationUtils.decodeIssuerClaims(encoded).cnf?.jwk;
34
- }
35
- /**
36
- * Decodes the key-binding JWT (`kb+jwt`) claims from a presentation.
37
- * Returns `undefined` when no kb segment is present.
38
- */
39
- static extractKbJwtClaims(encoded) {
40
- const parts = String(encoded).split("~");
41
- const kb = parts[parts.length - 1];
42
- if (!kb || !kb.includes(".")) {
43
- return undefined;
44
- }
45
- try {
46
- const { payload } = decodeJwt(kb);
47
- return payload;
48
- }
49
- catch {
50
- return undefined;
51
- }
52
- }
53
- /**
54
- * Unpack an SD-JWT VC compact string into a credential-subject claim map.
55
- *
56
- * Selectively disclosed claims live only in `~` disclosure segments (hashed as
57
- * `_sd` in the JWT). Callers that peek at the JWT payload alone miss them.
58
- */
59
- static async unpackSubject(sdJwt) {
60
- const decoded = await decodeSdJwt(sdJwt, CredentialCryptoUtils.hasher);
61
- const claims = await getClaims(decoded.jwt.payload, decoded.disclosures, CredentialCryptoUtils.hasher);
62
- const subject = {};
63
- for (const [key, value] of Object.entries(claims)) {
64
- if (SD_JWT_ENVELOPE_KEYS.has(key))
65
- continue;
66
- subject[key] = value;
67
- }
68
- return subject;
69
- }
70
- /** Builds a selective-disclosure SD-JWT VC presentation with holder key binding. */
71
- static async build(input) {
72
- const { credential, definition, holderSigner } = input;
73
- if (credential.format !== "sd-jwt-vc") {
74
- throw new Error(`PresentationUtils.build: unsupported format ${credential.format}`);
75
- }
76
- // Prefer unpacked SD disclosures; selectively disclosed claims are absent
77
- // from the JWT payload (and thus from a naïve credentialSubject peek).
78
- const unpacked = await PresentationUtils.unpackSubject(credential.payload);
79
- const subject = Object.keys(unpacked).length > 0
80
- ? unpacked
81
- : credential.semantic.credentialSubject;
82
- const disclosedClaims = definition.requestedClaims.filter((claim) => claim in subject);
83
- if (disclosedClaims.length === 0) {
84
- throw new Error("PresentationUtils.build: no requested claims present in credential");
85
- }
86
- const presentationFrame = PresentationUtils.presentationFrameFromClaims(definition.requestedClaims, subject);
87
- const sdjwt = new SDJwtVcInstance({
88
- kbSigner: (data) => holderSigner.signKbJwt(data),
89
- kbSignAlg: "EdDSA",
90
- hasher: CredentialCryptoUtils.hasher,
91
- hashAlg: "sha-256",
92
- saltGenerator: CredentialCryptoUtils.saltGenerator,
93
- });
94
- const nonce = definition.nonce;
95
- const audience = definition.audience ?? definition.verifier.id;
96
- if (!nonce) {
97
- throw new Error("PresentationUtils.build: presentation definition requires nonce for key binding");
98
- }
99
- const presentation = await sdjwt.present(credential.payload, presentationFrame, {
100
- kb: {
101
- payload: {
102
- iat: Math.floor(Date.now() / 1000),
103
- aud: audience,
104
- nonce,
105
- },
106
- },
107
- });
108
- return {
109
- presentation: SdJwtVcPresentationString(presentation),
110
- disclosedClaims,
111
- };
112
- }
113
- static presentationFrameFromClaims(requestedClaims, subject) {
114
- const frame = {};
115
- for (const claim of requestedClaims) {
116
- if (claim in subject) {
117
- frame[claim] = true;
118
- }
119
- }
120
- return frame;
121
- }
122
- }
123
- //# sourceMappingURL=PresentationUtils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PresentationUtils.js","sourceRoot":"","sources":["../../../../src/utils/credentials/sd-jwt-vc/PresentationUtils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC7E,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAKpD,OAAO,EAAE,yBAAyB,EAAE,MAAM,kDAAkD,CAAC;AAC7F,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AA2BnE,wEAAwE;AACxE,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC;IACnC,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,QAAQ;IACR,KAAK;IACL,SAAS;IACT,KAAK;IACL,KAAK;IACL,KAAK;CACN,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,OAAO,iBAAiB;IAC5B,0EAA0E;IAC1E,MAAM,CAAC,kBAAkB,CACvB,OAA2C;QAE3C,MAAM,EAAE,GAAG,EAAE,GAAG,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;QAC5C,MAAM,EAAE,OAAO,EAAE,GAAG,SAAS,CAC3B,GAAG,CACJ,CAAC;QACF,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,2EAA2E;IAC3E,MAAM,CAAC,gBAAgB,CACrB,OAA2C;QAE3C,OAAO,iBAAiB,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC;IAChE,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,kBAAkB,CACvB,OAA2C;QAE3C,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACzC,MAAM,EAAE,GAAG,KAAK,CAAC,K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ACP,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;oBAClC,GAAG,EAAE,QAAQ;oBACb,KAAK;iBACN;aACF;SACF,CACF,CAAC;QAEF,OAAO;YACL,YAAY,EAAE,yBAAyB,CAAC,YAAY,CAAC;YACrD,eAAe;SAChB,CAAC;IACJ,CAAC;IAEO,MAAM,CAAC,2BAA2B,CACxC,eAAsC,EACtC,OAAgC;QAEhC,MAAM,KAAK,GAA4B,EAAE,CAAC;QAC1C,KAAK,MAAM,KAAK,IAAI,eAAe,EAAE,CAAC;YACpC,IAAI,KAAK,IAAI,OAAO,EAAE,CAAC;gBACrB,KAAK,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;YACtB,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF"}
@@ -1,13 +0,0 @@
1
- import { Base64UrlEncodedString } from "../../../primitives/Base64UrlEncodedString.js";
2
- import type { Hasher, SaltGenerator, Signer, Verifier } from "@sd-jwt/core";
3
- /** SHA-256 hasher for SD-JWT (@sd-jwt/core `Hasher` contract). Uses Web Crypto. */
4
- export declare const sdJwtHasher: Hasher;
5
- /** Random salt generator for SD-JWT disclosures. Uses Web Crypto. */
6
- export declare const sdJwtSaltGenerator: SaltGenerator;
7
- export declare function importEd25519PrivateKey(jwk: JsonWebKey): Promise<CryptoKey>;
8
- export declare function importEd25519PublicKey(jwk: JsonWebKey): Promise<CryptoKey>;
9
- export declare function signEd25519(privateJwk: JsonWebKey, data: string): Promise<Base64UrlEncodedString>;
10
- export declare function verifyEd25519(publicJwk: JsonWebKey, data: string, signatureBase64Url: Base64UrlEncodedString): Promise<boolean>;
11
- export declare function createEd25519SignerFromJwk(privateJwk: JsonWebKey): Signer;
12
- export declare function createEd25519VerifierFromJwk(publicJwk: JsonWebKey): Verifier;
13
- //# sourceMappingURL=crypto.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../../../../src/utils/credentials/sd-jwt-vc/crypto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,+CAA+C,CAAC;AAEvF,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAa5E,mFAAmF;AACnF,eAAO,MAAM,WAAW,EAAE,MASzB,CAAC;AAEF,qEAAqE;AACrE,eAAO,MAAM,kBAAkB,EAAE,aAIhC,CAAC;AAEF,wBAAsB,uBAAuB,CAC3C,GAAG,EAAE,UAAU,GACd,OAAO,CAAC,SAAS,CAAC,CAIpB;AAED,wBAAsB,sBAAsB,CAC1C,GAAG,EAAE,UAAU,GACd,OAAO,CAAC,SAAS,CAAC,CAIpB;AAED,wBAAsB,WAAW,CAC/B,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,sBAAsB,CAAC,CAQjC;AAED,wBAAsB,aAAa,CACjC,SAAS,EAAE,UAAU,EACrB,IAAI,EAAE,MAAM,EACZ,kBAAkB,EAAE,sBAAsB,GACzC,OAAO,CAAC,OAAO,CAAC,CAQlB;AAED,wBAAgB,0BAA0B,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,CAEzE;AAED,wBAAgB,4BAA4B,CAAC,SAAS,EAAE,UAAU,GAAG,QAAQ,CAG5E"}
@@ -1,51 +0,0 @@
1
- import { Base64UrlEncodedString } from "../../../primitives/Base64UrlEncodedString.js";
2
- import { ConversionUtils } from "../../ConversionUtils.js";
3
- function toHashBytes(data) {
4
- return typeof data === "string"
5
- ? new TextEncoder().encode(data)
6
- : new Uint8Array(data);
7
- }
8
- /** Web Crypto expects BufferSource backed by ArrayBuffer, not ArrayBufferLike. */
9
- function asBufferSource(bytes) {
10
- return new Uint8Array(bytes);
11
- }
12
- /** SHA-256 hasher for SD-JWT (@sd-jwt/core `Hasher` contract). Uses Web Crypto. */
13
- export const sdJwtHasher = async (data, alg) => {
14
- if (!alg.includes("sha-256")) {
15
- throw new Error(`sdJwtHasher: unsupported algorithm ${alg}`);
16
- }
17
- const digest = await crypto.subtle.digest("SHA-256", asBufferSource(toHashBytes(data)));
18
- return new Uint8Array(digest);
19
- };
20
- /** Random salt generator for SD-JWT disclosures. Uses Web Crypto. */
21
- export const sdJwtSaltGenerator = async (length) => {
22
- const bytes = new Uint8Array(length);
23
- crypto.getRandomValues(bytes);
24
- return ConversionUtils.bytesToBase64Url(bytes);
25
- };
26
- export async function importEd25519PrivateKey(jwk) {
27
- return crypto.subtle.importKey("jwk", jwk, { name: "Ed25519" }, false, [
28
- "sign",
29
- ]);
30
- }
31
- export async function importEd25519PublicKey(jwk) {
32
- return crypto.subtle.importKey("jwk", jwk, { name: "Ed25519" }, false, [
33
- "verify",
34
- ]);
35
- }
36
- export async function signEd25519(privateJwk, data) {
37
- const key = await importEd25519PrivateKey(privateJwk);
38
- const signature = await crypto.subtle.sign("Ed25519", key, asBufferSource(new TextEncoder().encode(data)));
39
- return ConversionUtils.bytesToBase64Url(new Uint8Array(signature));
40
- }
41
- export async function verifyEd25519(publicJwk, data, signatureBase64Url) {
42
- const key = await importEd25519PublicKey(publicJwk);
43
- return crypto.subtle.verify("Ed25519", key, asBufferSource(ConversionUtils.base64UrlToBytes(signatureBase64Url)), asBufferSource(new TextEncoder().encode(data)));
44
- }
45
- export function createEd25519SignerFromJwk(privateJwk) {
46
- return (data) => signEd25519(privateJwk, data);
47
- }
48
- export function createEd25519VerifierFromJwk(publicJwk) {
49
- return (data, sig) => verifyEd25519(publicJwk, data, Base64UrlEncodedString(sig));
50
- }
51
- //# sourceMappingURL=crypto.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"crypto.js","sourceRoot":"","sources":["../../../../src/utils/credentials/sd-jwt-vc/crypto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,+CAA+C,CAAC;AACvF,OAAO,EAAE,eAAe,EAAE,MAAM,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AAsB,CAAC,GAAG,CAAC,CAAC,CAAC;AAChE,CAAC"}
@@ -1,25 +0,0 @@
1
- import type { SdJwtVcPresentationString } from "../../../primitives/SdJwtVcPresentationString.js";
2
- export type SdJwtVcIssuerClaims = {
3
- iss?: string;
4
- vct?: string;
5
- iat?: number;
6
- cnf?: {
7
- jwk?: JsonWebKey;
8
- };
9
- };
10
- export type KbJwtClaims = {
11
- iat?: number;
12
- aud?: string;
13
- nonce?: string;
14
- sd_hash?: string;
15
- };
16
- /** Reads `cnf.jwk` from an SD-JWT VC (presentation or full credential). */
17
- export declare function extractHolderJwkFromSdJwtVc(encoded: SdJwtVcPresentationString): JsonWebKey | undefined;
18
- /** Decodes issuer JWT payload claims from an SD-JWT VC compact string. */
19
- export declare function decodeSdJwtVcIssuerClaims(encoded: SdJwtVcPresentationString): SdJwtVcIssuerClaims;
20
- /**
21
- * Decodes the key-binding JWT (`kb+jwt`) claims from a presentation.
22
- * Returns `undefined` when no kb segment is present.
23
- */
24
- export declare function extractKbJwtClaims(encoded: SdJwtVcPresentationString): KbJwtClaims | undefined;
25
- //# sourceMappingURL=decode.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"decode.d.ts","sourceRoot":"","sources":["../../../../src/utils/credentials/sd-jwt-vc/decode.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,kDAAkD,CAAC;AAElG,MAAM,MAAM,mBAAmB,GAAG;IAChC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE;QAAE,GAAG,CAAC,EAAE,UAAU,CAAA;KAAE,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,2EAA2E;AAC3E,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,yBAAyB,GACjC,UAAU,GAAG,SAAS,CAExB;AAED,0EAA0E;AAC1E,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,yBAAyB,GACjC,mBAAmB,CAIrB;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,yBAAyB,GACjC,WAAW,GAAG,SAAS,CAYzB"}
@@ -1,30 +0,0 @@
1
- import { decodeJwt, splitSdJwt } from "@sd-jwt/core";
2
- /** Reads `cnf.jwk` from an SD-JWT VC (presentation or full credential). */
3
- export function extractHolderJwkFromSdJwtVc(encoded) {
4
- return decodeSdJwtVcIssuerClaims(encoded).cnf?.jwk;
5
- }
6
- /** Decodes issuer JWT payload claims from an SD-JWT VC compact string. */
7
- export function decodeSdJwtVcIssuerClaims(encoded) {
8
- const { jwt } = splitSdJwt(encoded);
9
- const { payload } = decodeJwt(jwt);
10
- return payload;
11
- }
12
- /**
13
- * Decodes the key-binding JWT (`kb+jwt`) claims from a presentation.
14
- * Returns `undefined` when no kb segment is present.
15
- */
16
- export function extractKbJwtClaims(encoded) {
17
- const parts = encoded.split("~");
18
- const kb = parts[parts.length - 1];
19
- if (!kb || !kb.includes(".")) {
20
- return undefined;
21
- }
22
- try {
23
- const { payload } = decodeJwt(kb);
24
- return payload;
25
- }
26
- catch {
27
- return undefined;
28
- }
29
- }
30
- //# sourceMappingURL=decode.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"decode.js","sourceRoot":"","sources":["../../../../src/utils/credentials/sd-jwt-vc/decode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAiBrD,2EAA2E;AAC3E,MAAM,UAAU,2BAA2B,CACzC,OAAkC;IAElC,OAAO,yBAAyB,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC;AACrD,CAAC;AAED,0EAA0E;AAC1E,MAAM,UAAU,yBAAyB,CACvC,OAAkC;IAElC,MAAM,EAAE,GAAG,EAAE,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IACpC,MAAM,EAAE,OAAO,EAAE,GAAG,SAAS,CAA+C,GAAG,CAAC,CAAC;IACjF,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAChC,OAAkC;IAElC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACjC,MAAM,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACnC,IAAI,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QAC7B,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,IAAI,CAAC;QACH,MAAM,EAAE,OAAO,EAAE,GAAG,SAAS,CAAuC,EAAE,CAAC,CAAC;QACxE,OAAO,OAAO,CAAC;IACjB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
@@ -1,5 +0,0 @@
1
- import type { Signer } from "@sd-jwt/core";
2
- import type { IHolderSigner } from "../../../credentials/holder-signer.js";
3
- /** Adapts a `IHolderSigner` to the `@sd-jwt/core` kbSigner callback. */
4
- export declare function holderSignerToKbSigner(holder: IHolderSigner): Signer;
5
- //# sourceMappingURL=holder-signer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"holder-signer.d.ts","sourceRoot":"","sources":["../../../../src/utils/credentials/sd-jwt-vc/holder-signer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AAE3E,wEAAwE;AACxE,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAEpE"}
@@ -1,5 +0,0 @@
1
- /** Adapts a `IHolderSigner` to the `@sd-jwt/core` kbSigner callback. */
2
- export function holderSignerToKbSigner(holder) {
3
- return (data) => holder.signKbJwt(data);
4
- }
5
- //# sourceMappingURL=holder-signer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"holder-signer.js","sourceRoot":"","sources":["../../../../src/utils/credentials/sd-jwt-vc/holder-signer.ts"],"names":[],"mappings":"AAGA,wEAAwE;AACxE,MAAM,UAAU,sBAAsB,CAAC,MAAqB;IAC1D,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;AAC1C,CAAC"}
@@ -1,17 +0,0 @@
1
- import { SdJwtVcPresentationString } from "../../../primitives/SdJwtVcPresentationString.js";
2
- import type { CredentialClaimName } from "../../../primitives/CredentialClaimName.js";
3
- import type { IHolderSigner } from "../../../credentials/holder-signer.js";
4
- import type { PresentationDefinition } from "../../../credentials/presentation.js";
5
- import type { StoredCredential } from "../../../credentials/credential.js";
6
- export type BuildSdJwtVcPresentationInput = {
7
- credential: StoredCredential;
8
- definition: PresentationDefinition;
9
- holderSigner: IHolderSigner;
10
- };
11
- export type BuildSdJwtVcPresentationResult = {
12
- presentation: SdJwtVcPresentationString;
13
- disclosedClaims: CredentialClaimName[];
14
- };
15
- /** Builds a selective-disclosure SD-JWT VC presentation with holder key binding. */
16
- export declare function buildSdJwtVcPresentation(input: BuildSdJwtVcPresentationInput): Promise<BuildSdJwtVcPresentationResult>;
17
- //# sourceMappingURL=presentation.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"presentation.d.ts","sourceRoot":"","sources":["../../../../src/utils/credentials/sd-jwt-vc/presentation.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,yBAAyB,EAAE,MAAM,kDAAkD,CAAC;AAC7F,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4CAA4C,CAAC;AACtF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AACnF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAK3E,MAAM,MAAM,6BAA6B,GAAG;IAC1C,UAAU,EAAE,gBAAgB,CAAC;IAC7B,UAAU,EAAE,sBAAsB,CAAC;IACnC,YAAY,EAAE,aAAa,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG;IAC3C,YAAY,EAAE,yBAAyB,CAAC;IACxC,eAAe,EAAE,mBAAmB,EAAE,CAAC;CACxC,CAAC;AAeF,oFAAoF;AACpF,wBAAsB,wBAAwB,CAC5C,KAAK,EAAE,6BAA6B,GACnC,OAAO,CAAC,8BAA8B,CAAC,CAuDzC"}
@@ -1,58 +0,0 @@
1
- import { SDJwtVcInstance } from "@sd-jwt/sd-jwt-vc";
2
- import { SdJwtVcPresentationString } from "../../../primitives/SdJwtVcPresentationString.js";
3
- import { CredentialCryptoUtils } from "./CredentialCryptoUtils.js";
4
- import { holderSignerToKbSigner } from "./holder-signer.js";
5
- import { unpackSdJwtVcSubject } from "./unpack-subject.js";
6
- function presentationFrameFromClaims(requestedClaims, subject) {
7
- const frame = {};
8
- for (const claim of requestedClaims) {
9
- if (claim in subject) {
10
- frame[claim] = true;
11
- }
12
- }
13
- return frame;
14
- }
15
- /** Builds a selective-disclosure SD-JWT VC presentation with holder key binding. */
16
- export async function buildSdJwtVcPresentation(input) {
17
- const { credential, definition, holderSigner } = input;
18
- if (credential.format !== "sd-jwt-vc") {
19
- throw new Error(`buildSdJwtVcPresentation: unsupported format ${credential.format}`);
20
- }
21
- // Prefer unpacked SD disclosures; selectively disclosed claims are absent
22
- // from the JWT payload (and thus from a naïve credentialSubject peek).
23
- const unpacked = await unpackSdJwtVcSubject(credential.payload);
24
- const subject = Object.keys(unpacked).length > 0
25
- ? unpacked
26
- : credential.semantic.credentialSubject;
27
- const disclosedClaims = definition.requestedClaims.filter((claim) => claim in subject);
28
- if (disclosedClaims.length === 0) {
29
- throw new Error("buildSdJwtVcPresentation: no requested claims present in credential");
30
- }
31
- const presentationFrame = presentationFrameFromClaims(definition.requestedClaims, subject);
32
- const sdjwt = new SDJwtVcInstance({
33
- kbSigner: holderSignerToKbSigner(holderSigner),
34
- kbSignAlg: "EdDSA",
35
- hasher: CredentialCryptoUtils.hasher,
36
- hashAlg: "sha-256",
37
- saltGenerator: CredentialCryptoUtils.saltGenerator,
38
- });
39
- const nonce = definition.nonce;
40
- const audience = definition.audience ?? definition.verifier.id;
41
- if (!nonce) {
42
- throw new Error("buildSdJwtVcPresentation: presentation definition requires nonce for key binding");
43
- }
44
- const presentation = await sdjwt.present(credential.payload, presentationFrame, {
45
- kb: {
46
- payload: {
47
- iat: Math.floor(Date.now() / 1000),
48
- aud: audience,
49
- nonce,
50
- },
51
- },
52
- });
53
- return {
54
- presentation: SdJwtVcPresentationString(presentation),
55
- disclosedClaims,
56
- };
57
- }
58
- //# sourceMappingURL=presentation.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"presentation.js","sourceRoot":"","sources":["../../../../src/utils/credentials/sd-jwt-vc/presentation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,yBAAyB,EAAE,MAAM,kDAAkD,CAAC;AAK7F,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAa3D,SAAS,2BAA2B,CAClC,eAAsC,EACtC,OAAgC;IAEhC,MAAM,KAAK,GAA4B,EAAE,CAAC;IAC1C,KAAK,MAAM,KAAK,IAAI,eAAe,EAAE,CAAC;QACpC,IAAI,KAAK,IAAI,OAAO,EAAE,CAA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GAAG,UAAU,CAAC,KAAK,CAAC;IAC/B,MAAM,QAAQ,GAAG,UAAU,CAAC,QAAQ,IAAI,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;IAC/D,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,kFAAkF,CAAC,CAAC;IACtG,CAAC;IAED,MAAM,YAAY,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,EAAE,iBAAiB,EAAE;QAC9E,EAAE,EAAE;YACF,OAAO,EAAE;gBACP,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;gBAClC,GAAG,EAAE,QAAQ;gBACb,KAAK;aACN;SACF;KACF,CAAC,CAAC;IAEH,OAAO;QACL,YAAY,EAAE,yBAAyB,CAAC,YAAY,CAAC;QACrD,eAAe;KAChB,CAAC;AACJ,CAAC"}
@@ -1,8 +0,0 @@
1
- /**
2
- * Unpack an SD-JWT VC compact string into a credential-subject claim map.
3
- *
4
- * Selectively disclosed claims live only in `~` disclosure segments (hashed as
5
- * `_sd` in the JWT). Callers that peek at the JWT payload alone miss them.
6
- */
7
- export declare function unpackSdJwtVcSubject(sdJwt: string): Promise<Record<string, unknown>>;
8
- //# sourceMappingURL=unpack-subject.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"unpack-subject.d.ts","sourceRoot":"","sources":["../../../../src/utils/credentials/sd-jwt-vc/unpack-subject.ts"],"names":[],"mappings":"AAmBA;;;;;GAKG;AACH,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAclC"}
@@ -1,35 +0,0 @@
1
- import { decodeSdJwt, getClaims } from "@sd-jwt/core";
2
- import { CredentialCryptoUtils } from "./CredentialCryptoUtils.js";
3
- /** JWT / SD-JWT envelope keys excluded from credential-subject maps. */
4
- const SD_JWT_ENVELOPE_KEYS = new Set([
5
- "iss",
6
- "iat",
7
- "exp",
8
- "nbf",
9
- "vct",
10
- "cnf",
11
- "status",
12
- "_sd",
13
- "_sd_alg",
14
- "aud",
15
- "sub",
16
- "jti",
17
- ]);
18
- /**
19
- * Unpack an SD-JWT VC compact string into a credential-subject claim map.
20
- *
21
- * Selectively disclosed claims live only in `~` disclosure segments (hashed as
22
- * `_sd` in the JWT). Callers that peek at the JWT payload alone miss them.
23
- */
24
- export async function unpackSdJwtVcSubject(sdJwt) {
25
- const decoded = await decodeSdJwt(sdJwt, CredentialCryptoUtils.hasher);
26
- const claims = await getClaims(decoded.jwt.payload, decoded.disclosures, CredentialCryptoUtils.hasher);
27
- const subject = {};
28
- for (const [key, value] of Object.entries(claims)) {
29
- if (SD_JWT_ENVELOPE_KEYS.has(key))
30
- continue;
31
- subject[key] = value;
32
- }
33
- return subject;
34
- }
35
- //# sourceMappingURL=unpack-subject.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"unpack-subject.js","sourceRoot":"","sources":["../../../../src/utils/credentials/sd-jwt-vc/unpack-subject.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,wEAAwE;AACxE,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC;IACnC,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,QAAQ;IACR,KAAK;IACL,SAAS;IACT,KAAK;IACL,KAAK;IACL,KAAK;CACN,CAAC,CAAC;AAEH;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,KAAa;IAEb,MAAM,OAAO,GAAG,MAAM,WAAW,CAAC,KAAK,EAAE,qBAAqB,CAAC,MAAM,CAAC,CAAC;IACvE,MAAM,MAAM,GAAG,MAAM,SAAS,CAC5B,OAAO,CAAC,GAAG,CAAC,OAAO,EACnB,OAAO,CAAC,WAAW,EACnB,qBAAqB,CAAC,MAAM,CAC7B,CAAC;IAEF,MAAM,OAAO,GAA4B,EAAE,CAAC;IAC5C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAClD,IAAI,oBAAoB,CAAC,GAAG,CAAC,GAAG,CAAC;YAAE,SAAS;QAC5C,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACvB,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}