@pagopa/io-wallet-oid4vci 0.4.1 → 0.4.2

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.
@@ -0,0 +1,89 @@
1
+ import { ClientAttestationJwtPayload } from '@openid4vc/oauth2';
2
+ import { Openid4vciWalletProvider } from '@openid4vc/openid4vci';
3
+
4
+ /**
5
+ * Generic error thrown on Oid4vci operations
6
+ */
7
+ declare class Oid4vciError extends Error {
8
+ readonly statusCode?: number | undefined;
9
+ constructor(message: string, statusCode?: number | undefined);
10
+ }
11
+ /**
12
+ * Error thrown in case the DPoP key passed to the
13
+ * {@link WalletProvider.createItWalletAttestationJwt} method
14
+ * doesn't contain a kid
15
+ */
16
+ declare class WalletProviderError extends Oid4vciError {
17
+ readonly originalError?: unknown;
18
+ constructor(message: string, originalError?: unknown);
19
+ }
20
+
21
+ /**
22
+ * @interface WalletAttestationOptions
23
+ * @description Defines the options required to create a wallet attestation JWT.
24
+ * This attestation is a signed token that proves the wallet's identity and possession of a cryptographic key.
25
+ */
26
+ interface WalletAttestationOptions {
27
+ /**
28
+ * The public part of the DPoP (Demonstrating Proof-of-Possession) key in JWK (JSON Web Key) format.
29
+ * This key is used to bind the attestation to the client's session.
30
+ * @type {ClientAttestationJwtPayload['cnf']}
31
+ */
32
+ dpopJwkPublic: ClientAttestationJwtPayload["cnf"]["jwk"];
33
+ /**
34
+ * The optional expiration date for the attestation JWT. If not provided, a default lifetime will be used.
35
+ * @type {Date}
36
+ */
37
+ expiresAt?: Date;
38
+ /**
39
+ * The issuer of the attestation, typically the Wallet Provider's identifier.
40
+ * @type {string}
41
+ */
42
+ issuer: string;
43
+ signer: {
44
+ /**
45
+ * An array of JWTs representing the chain of trust from the federation's trust anchor
46
+ * to the wallet provider. This is used in federated identity systems to validate the provider's authenticity.
47
+ * @type {[string, ...string[]]}
48
+ */
49
+ trustChain: [string, ...string[]];
50
+ /**
51
+ * The Key ID (`kid`) of the wallet provider's public key used for signing the attestation.
52
+ * @type {string}
53
+ */
54
+ walletProviderJwkPublicKid: string;
55
+ };
56
+ /**
57
+ * An optional deep link or URL that can be used to open or interact with the wallet.
58
+ * @type {string}
59
+ */
60
+ walletLink?: string;
61
+ /**
62
+ * An optional display name for the wallet.
63
+ * @type {string}
64
+ */
65
+ walletName?: string;
66
+ }
67
+ /**
68
+ * @class WalletProvider
69
+ * @extends Openid4vciWalletProvider
70
+ * @description An implementation of a wallet provider for the OpenID4VCI protocol, tailored for a specific ecosystem (e.g., the Italian one).
71
+ * It handles the creation of wallet attestations required during the credential issuance flow.
72
+ */
73
+ declare class WalletProvider extends Openid4vciWalletProvider {
74
+ /**
75
+ * Creates a wallet attestation JWT.
76
+ *
77
+ * This method constructs a signed JWT that asserts the wallet's control over a specific
78
+ * cryptographic key (DPoP key). This is a security measure to ensure that the entity
79
+ * presenting the credential offer is the legitimate wallet instance.
80
+ *
81
+ * @public
82
+ * @async
83
+ * @param {WalletAttestationOptions} options - The necessary parameters to build the attestation.
84
+ * @returns {Promise<string>} A promise that resolves to the signed wallet attestation JWT as a string.
85
+ */
86
+ createItWalletAttestationJwt(options: WalletAttestationOptions): Promise<string>;
87
+ }
88
+
89
+ export { Oid4vciError, type WalletAttestationOptions, WalletProvider, WalletProviderError };
@@ -0,0 +1,89 @@
1
+ import { ClientAttestationJwtPayload } from '@openid4vc/oauth2';
2
+ import { Openid4vciWalletProvider } from '@openid4vc/openid4vci';
3
+
4
+ /**
5
+ * Generic error thrown on Oid4vci operations
6
+ */
7
+ declare class Oid4vciError extends Error {
8
+ readonly statusCode?: number | undefined;
9
+ constructor(message: string, statusCode?: number | undefined);
10
+ }
11
+ /**
12
+ * Error thrown in case the DPoP key passed to the
13
+ * {@link WalletProvider.createItWalletAttestationJwt} method
14
+ * doesn't contain a kid
15
+ */
16
+ declare class WalletProviderError extends Oid4vciError {
17
+ readonly originalError?: unknown;
18
+ constructor(message: string, originalError?: unknown);
19
+ }
20
+
21
+ /**
22
+ * @interface WalletAttestationOptions
23
+ * @description Defines the options required to create a wallet attestation JWT.
24
+ * This attestation is a signed token that proves the wallet's identity and possession of a cryptographic key.
25
+ */
26
+ interface WalletAttestationOptions {
27
+ /**
28
+ * The public part of the DPoP (Demonstrating Proof-of-Possession) key in JWK (JSON Web Key) format.
29
+ * This key is used to bind the attestation to the client's session.
30
+ * @type {ClientAttestationJwtPayload['cnf']}
31
+ */
32
+ dpopJwkPublic: ClientAttestationJwtPayload["cnf"]["jwk"];
33
+ /**
34
+ * The optional expiration date for the attestation JWT. If not provided, a default lifetime will be used.
35
+ * @type {Date}
36
+ */
37
+ expiresAt?: Date;
38
+ /**
39
+ * The issuer of the attestation, typically the Wallet Provider's identifier.
40
+ * @type {string}
41
+ */
42
+ issuer: string;
43
+ signer: {
44
+ /**
45
+ * An array of JWTs representing the chain of trust from the federation's trust anchor
46
+ * to the wallet provider. This is used in federated identity systems to validate the provider's authenticity.
47
+ * @type {[string, ...string[]]}
48
+ */
49
+ trustChain: [string, ...string[]];
50
+ /**
51
+ * The Key ID (`kid`) of the wallet provider's public key used for signing the attestation.
52
+ * @type {string}
53
+ */
54
+ walletProviderJwkPublicKid: string;
55
+ };
56
+ /**
57
+ * An optional deep link or URL that can be used to open or interact with the wallet.
58
+ * @type {string}
59
+ */
60
+ walletLink?: string;
61
+ /**
62
+ * An optional display name for the wallet.
63
+ * @type {string}
64
+ */
65
+ walletName?: string;
66
+ }
67
+ /**
68
+ * @class WalletProvider
69
+ * @extends Openid4vciWalletProvider
70
+ * @description An implementation of a wallet provider for the OpenID4VCI protocol, tailored for a specific ecosystem (e.g., the Italian one).
71
+ * It handles the creation of wallet attestations required during the credential issuance flow.
72
+ */
73
+ declare class WalletProvider extends Openid4vciWalletProvider {
74
+ /**
75
+ * Creates a wallet attestation JWT.
76
+ *
77
+ * This method constructs a signed JWT that asserts the wallet's control over a specific
78
+ * cryptographic key (DPoP key). This is a security measure to ensure that the entity
79
+ * presenting the credential offer is the legitimate wallet instance.
80
+ *
81
+ * @public
82
+ * @async
83
+ * @param {WalletAttestationOptions} options - The necessary parameters to build the attestation.
84
+ * @returns {Promise<string>} A promise that resolves to the signed wallet attestation JWT as a string.
85
+ */
86
+ createItWalletAttestationJwt(options: WalletAttestationOptions): Promise<string>;
87
+ }
88
+
89
+ export { Oid4vciError, type WalletAttestationOptions, WalletProvider, WalletProviderError };
package/package.json CHANGED
@@ -1,15 +1,18 @@
1
1
  {
2
2
  "name": "@pagopa/io-wallet-oid4vci",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "files": [
5
5
  "dist"
6
6
  ],
7
7
  "license": "Apache-2.0",
8
+ "main": "./dist/index.js",
9
+ "module": "./dist/index.mjs",
10
+ "types": "./dist/index.d.ts",
8
11
  "exports": {
9
12
  ".": {
13
+ "types": "./dist/index.d.ts",
10
14
  "import": "./dist/index.mjs",
11
- "require": "./dist/index.js",
12
- "types": "./dist/index.d.ts"
15
+ "require": "./dist/index.js"
13
16
  },
14
17
  "./package.json": "./package.json"
15
18
  },
@@ -32,8 +35,5 @@
32
35
  "scripts": {
33
36
  "build": "tsup src/index.ts --format cjs,esm --dts --clean --sourcemap",
34
37
  "test": "vitest"
35
- },
36
- "main": "./dist/index.js",
37
- "module": "./dist/index.mjs",
38
- "types": "./dist/index.d.ts"
38
+ }
39
39
  }