@pagopa/io-react-native-wallet 2.1.1 → 2.3.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.
- package/README.md +4 -3
- package/lib/commonjs/credential/index.js +3 -1
- package/lib/commonjs/credential/index.js.map +1 -1
- package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js +82 -58
- package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
- package/lib/commonjs/credential/offer/01-start-flow.js +75 -0
- package/lib/commonjs/credential/offer/01-start-flow.js.map +1 -0
- package/lib/commonjs/credential/offer/02-fetch-credential-offer.js +45 -0
- package/lib/commonjs/credential/offer/02-fetch-credential-offer.js.map +1 -0
- package/lib/commonjs/credential/offer/README.md +174 -0
- package/lib/commonjs/credential/offer/errors.js +22 -0
- package/lib/commonjs/credential/offer/errors.js.map +1 -0
- package/lib/commonjs/credential/offer/index.js +25 -0
- package/lib/commonjs/credential/offer/index.js.map +1 -0
- package/lib/commonjs/credential/offer/types.js +51 -0
- package/lib/commonjs/credential/offer/types.js.map +1 -0
- package/lib/commonjs/credential/presentation/01-start-flow.js +1 -1
- package/lib/commonjs/credentials-catalogue/README.md +15 -0
- package/lib/commonjs/credentials-catalogue/fetch-and-parse-catalogue.js +42 -0
- package/lib/commonjs/credentials-catalogue/fetch-and-parse-catalogue.js.map +1 -0
- package/lib/commonjs/credentials-catalogue/index.js +13 -0
- package/lib/commonjs/credentials-catalogue/index.js.map +1 -0
- package/lib/commonjs/credentials-catalogue/types.js +99 -0
- package/lib/commonjs/credentials-catalogue/types.js.map +1 -0
- package/lib/commonjs/index.js +5 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/mdoc/index.js +15 -0
- package/lib/commonjs/mdoc/index.js.map +1 -1
- package/lib/commonjs/mdoc/utils.js +37 -1
- package/lib/commonjs/mdoc/utils.js.map +1 -1
- package/lib/commonjs/utils/nestedProperty.js +21 -10
- package/lib/commonjs/utils/nestedProperty.js.map +1 -1
- package/lib/commonjs/utils/zod.js +28 -0
- package/lib/commonjs/utils/zod.js.map +1 -0
- package/lib/module/credential/index.js +2 -1
- package/lib/module/credential/index.js.map +1 -1
- package/lib/module/credential/issuance/07-verify-and-parse-credential.js +83 -59
- package/lib/module/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
- package/lib/module/credential/offer/01-start-flow.js +66 -0
- package/lib/module/credential/offer/01-start-flow.js.map +1 -0
- package/lib/module/credential/offer/02-fetch-credential-offer.js +38 -0
- package/lib/module/credential/offer/02-fetch-credential-offer.js.map +1 -0
- package/lib/module/credential/offer/README.md +174 -0
- package/lib/module/credential/offer/errors.js +14 -0
- package/lib/module/credential/offer/errors.js.map +1 -0
- package/lib/module/credential/offer/index.js +5 -0
- package/lib/module/credential/offer/index.js.map +1 -0
- package/lib/module/credential/offer/types.js +41 -0
- package/lib/module/credential/offer/types.js.map +1 -0
- package/lib/module/credential/presentation/01-start-flow.js +1 -1
- package/lib/module/credentials-catalogue/README.md +15 -0
- package/lib/module/credentials-catalogue/fetch-and-parse-catalogue.js +35 -0
- package/lib/module/credentials-catalogue/fetch-and-parse-catalogue.js.map +1 -0
- package/lib/module/credentials-catalogue/index.js +2 -0
- package/lib/module/credentials-catalogue/index.js.map +1 -0
- package/lib/module/credentials-catalogue/types.js +89 -0
- package/lib/module/credentials-catalogue/types.js.map +1 -0
- package/lib/module/index.js +3 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/mdoc/index.js +1 -0
- package/lib/module/mdoc/index.js.map +1 -1
- package/lib/module/mdoc/utils.js +35 -0
- package/lib/module/mdoc/utils.js.map +1 -1
- package/lib/module/utils/nestedProperty.js +21 -10
- package/lib/module/utils/nestedProperty.js.map +1 -1
- package/lib/module/utils/zod.js +20 -0
- package/lib/module/utils/zod.js.map +1 -0
- package/lib/typescript/credential/index.d.ts +2 -1
- package/lib/typescript/credential/index.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/01-start-flow.d.ts +1 -1
- package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts.map +1 -1
- package/lib/typescript/credential/offer/01-start-flow.d.ts +172 -0
- package/lib/typescript/credential/offer/01-start-flow.d.ts.map +1 -0
- package/lib/typescript/credential/offer/02-fetch-credential-offer.d.ts +20 -0
- package/lib/typescript/credential/offer/02-fetch-credential-offer.d.ts.map +1 -0
- package/lib/typescript/credential/offer/errors.d.ts +10 -0
- package/lib/typescript/credential/offer/errors.d.ts.map +1 -0
- package/lib/typescript/credential/offer/index.d.ts +7 -0
- package/lib/typescript/credential/offer/index.d.ts.map +1 -0
- package/lib/typescript/credential/offer/types.d.ts +264 -0
- package/lib/typescript/credential/offer/types.d.ts.map +1 -0
- package/lib/typescript/credential/presentation/01-start-flow.d.ts +1 -1
- package/lib/typescript/credentials-catalogue/fetch-and-parse-catalogue.d.ts +15 -0
- package/lib/typescript/credentials-catalogue/fetch-and-parse-catalogue.d.ts.map +1 -0
- package/lib/typescript/credentials-catalogue/index.d.ts +3 -0
- package/lib/typescript/credentials-catalogue/index.d.ts.map +1 -0
- package/lib/typescript/credentials-catalogue/types.d.ts +844 -0
- package/lib/typescript/credentials-catalogue/types.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +3 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/mdoc/index.d.ts +1 -0
- package/lib/typescript/mdoc/index.d.ts.map +1 -1
- package/lib/typescript/mdoc/utils.d.ts +50 -0
- package/lib/typescript/mdoc/utils.d.ts.map +1 -1
- package/lib/typescript/utils/nestedProperty.d.ts +2 -1
- package/lib/typescript/utils/nestedProperty.d.ts.map +1 -1
- package/lib/typescript/utils/zod.d.ts +15 -0
- package/lib/typescript/utils/zod.d.ts.map +1 -0
- package/package.json +21 -2
- package/src/credential/index.ts +2 -1
- package/src/credential/issuance/01-start-flow.ts +1 -1
- package/src/credential/issuance/07-verify-and-parse-credential.ts +60 -26
- package/src/credential/offer/01-start-flow.ts +89 -0
- package/src/credential/offer/02-fetch-credential-offer.ts +54 -0
- package/src/credential/offer/README.md +174 -0
- package/src/credential/offer/errors.ts +17 -0
- package/src/credential/offer/index.ts +16 -0
- package/src/credential/offer/types.ts +59 -0
- package/src/credential/presentation/01-start-flow.ts +1 -1
- package/src/credentials-catalogue/README.md +15 -0
- package/src/credentials-catalogue/fetch-and-parse-catalogue.ts +54 -0
- package/src/credentials-catalogue/index.ts +2 -0
- package/src/credentials-catalogue/types.ts +97 -0
- package/src/index.ts +4 -0
- package/src/mdoc/index.ts +1 -0
- package/src/mdoc/utils.ts +43 -0
- package/src/utils/nestedProperty.ts +35 -10
- package/src/utils/zod.ts +28 -0
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
# Credential Offer
|
|
2
|
+
|
|
3
|
+
This flow handles the initial step of credential issuance by processing Credential Offers from Credential Issuers. The Credential Offer contains information about what credentials are available and how they can be obtained. Each step in the flow is imported from the related file which is named with a sequential number.
|
|
4
|
+
|
|
5
|
+
A Credential Offer can be received by the Wallet in two ways: **by value** (complete offer embedded in the URL) or **by reference** (URL pointing to the offer endpoint). The offer specifies which credentials are available and what authorization flows are supported by the issuer.
|
|
6
|
+
|
|
7
|
+
The implementation follows the [OpenID for Verifiable Credential Issuance 1.0](https://openid.net/specs/openid-4-verifiable-credential-issuance-1_0.html#name-credential-offer-endpoint) specification and supports both Authorization Code flow and Pre-Authorized Code flow.
|
|
8
|
+
|
|
9
|
+
## Sequence Diagram
|
|
10
|
+
|
|
11
|
+
```mermaid
|
|
12
|
+
sequenceDiagram
|
|
13
|
+
autonumber
|
|
14
|
+
participant U as User
|
|
15
|
+
participant W as Wallet
|
|
16
|
+
participant CI as Credential Issuer
|
|
17
|
+
|
|
18
|
+
CI->>U: QR Code / Deep Link with Credential Offer
|
|
19
|
+
U->>W: Scan QR / Click Link
|
|
20
|
+
W->>W: startFlowFromQR: Parse offer parameters
|
|
21
|
+
alt Credential Offer by Reference
|
|
22
|
+
W->>CI: fetchCredentialOffer: Fetch offer from URI
|
|
23
|
+
CI->>W: Return Credential Offer JSON
|
|
24
|
+
end
|
|
25
|
+
W->>W: Validate Credential Offer schema
|
|
26
|
+
W->>W: Determine available grant types
|
|
27
|
+
Note over W: Flow continues with credential issuance
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Grant Types
|
|
31
|
+
|
|
32
|
+
The Credential Offer supports two OAuth 2.0 grant types that determine how authorization is handled:
|
|
33
|
+
|
|
34
|
+
### Authorization Code Flow
|
|
35
|
+
|
|
36
|
+
Used for interactive flows where user authentication and consent are required at the Authorization Server.
|
|
37
|
+
|
|
38
|
+
- **`issuer_state`** (optional): Binds the authorization request to a specific issuer context
|
|
39
|
+
- **`authorization_server`** (optional): Identifies which authorization server to use when multiple are available
|
|
40
|
+
|
|
41
|
+
### Pre-Authorized Code Flow
|
|
42
|
+
|
|
43
|
+
Used when the user has already been authenticated and authorized out-of-band. The issuer provides a pre-authorized code that can be exchanged directly for credentials.
|
|
44
|
+
|
|
45
|
+
- **`pre-authorized_code`**: Short-lived single-use authorization code
|
|
46
|
+
- **`tx_code`** (optional): Additional transaction code requirements for security
|
|
47
|
+
- **`authorization_server`** (optional): Identifies which authorization server to use
|
|
48
|
+
|
|
49
|
+
## Transaction Code Requirements
|
|
50
|
+
|
|
51
|
+
When a transaction code is required for Pre-Authorized Code flow, the following parameters control the user experience:
|
|
52
|
+
|
|
53
|
+
| Parameter | Type | Description |
|
|
54
|
+
| ------------- | ----------------------- | ---------------------------------------------------- |
|
|
55
|
+
| `input_mode` | `"numeric"` \| `"text"` | Character set for the code (default: `"numeric"`) |
|
|
56
|
+
| `length` | number | Expected code length to optimize input UI |
|
|
57
|
+
| `description` | string | User guidance (max 300 chars) for obtaining the code |
|
|
58
|
+
|
|
59
|
+
## Credential Offer Transmission
|
|
60
|
+
|
|
61
|
+
### By Value
|
|
62
|
+
|
|
63
|
+
The complete Credential Offer is embedded in the URL parameter:
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
openid-credential-offer://?credential_offer=%7B%22credential_issuer%22...
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### By Reference
|
|
70
|
+
|
|
71
|
+
A URL points to an endpoint serving the Credential Offer:
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
openid-credential-offer://?credential_offer_uri=https%3A%2F%2Fserver.example.com%2Foffer
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
When using by reference, the Wallet fetches the offer via HTTP GET with `Accept: application/json`.
|
|
78
|
+
|
|
79
|
+
## Mapped Results
|
|
80
|
+
|
|
81
|
+
The following errors are mapped during credential offer processing:
|
|
82
|
+
|
|
83
|
+
| Error | Description |
|
|
84
|
+
| ----------------------------- | ---------------------------------------------------------------------------------- |
|
|
85
|
+
| `InvalidQRCodeError` | The QR code format is invalid or doesn't contain valid credential offer parameters |
|
|
86
|
+
| `InvalidCredentialOfferError` | The credential offer schema validation failed or contains invalid data |
|
|
87
|
+
|
|
88
|
+
## Examples
|
|
89
|
+
|
|
90
|
+
<details>
|
|
91
|
+
<summary>Credential Offer processing flow</summary>
|
|
92
|
+
|
|
93
|
+
```ts
|
|
94
|
+
// Parse QR code or deep link
|
|
95
|
+
const qrCode =
|
|
96
|
+
"openid-credential-offer://?credential_offer_uri=https%3A%2F%2Fissuer.example.com%2Foffer";
|
|
97
|
+
const { credential_offer_uri } = startFlowFromQR(qrCode);
|
|
98
|
+
|
|
99
|
+
// Fetch the credential offer if by reference
|
|
100
|
+
const offer = await fetchCredentialOffer(credential_offer_uri, { appFetch });
|
|
101
|
+
|
|
102
|
+
console.log(offer);
|
|
103
|
+
// {
|
|
104
|
+
// credential_issuer: "https://issuer.example.com",
|
|
105
|
+
// credential_configuration_ids: ["UniversityDegree", "DriverLicense"],
|
|
106
|
+
// grants: {
|
|
107
|
+
// authorization_code: {
|
|
108
|
+
// issuer_state: "xyz123"
|
|
109
|
+
// },
|
|
110
|
+
// "urn:ietf:params:oauth:grant-type:pre-authorized_code": {
|
|
111
|
+
// "pre-authorized_code": "SplxlOBeZQQYbYS6WxSbIA",
|
|
112
|
+
// tx_code: {
|
|
113
|
+
// length: 6,
|
|
114
|
+
// input_mode: "numeric",
|
|
115
|
+
// description: "Enter the code sent to your email"
|
|
116
|
+
// }
|
|
117
|
+
// }
|
|
118
|
+
// }
|
|
119
|
+
// }
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
</details>
|
|
123
|
+
|
|
124
|
+
<details>
|
|
125
|
+
<summary>Pre-Authorized Code with Transaction Code</summary>
|
|
126
|
+
|
|
127
|
+
```ts
|
|
128
|
+
const offer: CredentialOffer = {
|
|
129
|
+
credential_issuer: "https://university.example.edu",
|
|
130
|
+
credential_configuration_ids: ["DiplomaCredential"],
|
|
131
|
+
grants: {
|
|
132
|
+
"urn:ietf:params:oauth:grant-type:pre-authorized_code": {
|
|
133
|
+
"pre-authorized_code": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9",
|
|
134
|
+
tx_code: {
|
|
135
|
+
length: 4,
|
|
136
|
+
input_mode: "numeric",
|
|
137
|
+
description: "Check your email for the verification code",
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
// The user would need to:
|
|
144
|
+
// 1. Check their email for a 4-digit numeric code
|
|
145
|
+
// 2. Enter it in the wallet when prompted
|
|
146
|
+
// 3. The wallet uses both pre-authorized_code and tx_code in the token request
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
</details>
|
|
150
|
+
|
|
151
|
+
<details>
|
|
152
|
+
<summary>Authorization Code Flow</summary>
|
|
153
|
+
|
|
154
|
+
```ts
|
|
155
|
+
const offer: CredentialOffer = {
|
|
156
|
+
credential_issuer: "https://dmv.example.gov",
|
|
157
|
+
credential_configuration_ids: ["org.iso.18013.5.1.mDL"],
|
|
158
|
+
grants: {
|
|
159
|
+
authorization_code: {
|
|
160
|
+
issuer_state: "af0ifjsldkj",
|
|
161
|
+
authorization_server: "https://auth.dmv.example.gov",
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
// This would lead to:
|
|
167
|
+
// 1. User authentication at the authorization server
|
|
168
|
+
// 2. User consent for credential issuance
|
|
169
|
+
// 3. Authorization code returned to wallet
|
|
170
|
+
// 4. Wallet exchanges code for access token
|
|
171
|
+
// 5. Wallet uses access token to request credential
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
</details>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.InvalidQRCodeError = exports.InvalidCredentialOfferError = void 0;
|
|
7
|
+
var _errors = require("../../utils/errors");
|
|
8
|
+
class InvalidCredentialOfferError extends _errors.IoWalletError {
|
|
9
|
+
code = "ERR_INVALID_CREDENTIAL_OFFER";
|
|
10
|
+
constructor(message) {
|
|
11
|
+
super(message);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.InvalidCredentialOfferError = InvalidCredentialOfferError;
|
|
15
|
+
class InvalidQRCodeError extends _errors.IoWalletError {
|
|
16
|
+
code = "ERR_INVALID_QR_CODE";
|
|
17
|
+
constructor(message) {
|
|
18
|
+
super(message);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.InvalidQRCodeError = InvalidQRCodeError;
|
|
22
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_errors","require","InvalidCredentialOfferError","IoWalletError","code","constructor","message","exports","InvalidQRCodeError"],"sourceRoot":"../../../../src","sources":["credential/offer/errors.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAEO,MAAMC,2BAA2B,SAASC,qBAAa,CAAC;EAC7DC,IAAI,GAAG,8BAA8B;EAErCC,WAAWA,CAACC,OAAgB,EAAE;IAC5B,KAAK,CAACA,OAAO,CAAC;EAChB;AACF;AAACC,OAAA,CAAAL,2BAAA,GAAAA,2BAAA;AAEM,MAAMM,kBAAkB,SAASL,qBAAa,CAAC;EACpDC,IAAI,GAAG,qBAAqB;EAE5BC,WAAWA,CAACC,OAAgB,EAAE;IAC5B,KAAK,CAACA,OAAO,CAAC;EAChB;AACF;AAACC,OAAA,CAAAC,kBAAA,GAAAA,kBAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Errors = void 0;
|
|
7
|
+
Object.defineProperty(exports, "fetchCredentialOffer", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return _fetchCredentialOffer.fetchCredentialOffer;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
Object.defineProperty(exports, "startFlowFromQR", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () {
|
|
16
|
+
return _startFlow.startFlowFromQR;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
var _startFlow = require("./01-start-flow");
|
|
20
|
+
var _fetchCredentialOffer = require("./02-fetch-credential-offer");
|
|
21
|
+
var Errors = _interopRequireWildcard(require("./errors"));
|
|
22
|
+
exports.Errors = Errors;
|
|
23
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
24
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_startFlow","require","_fetchCredentialOffer","Errors","_interopRequireWildcard","exports","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set"],"sourceRoot":"../../../../src","sources":["credential/offer/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,qBAAA,GAAAD,OAAA;AAIA,IAAAE,MAAA,GAAAC,uBAAA,CAAAH,OAAA;AAAmCI,OAAA,CAAAF,MAAA,GAAAA,MAAA;AAAA,SAAAG,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAH,wBAAAO,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,YAAAG,KAAA,CAAAE,GAAA,CAAAL,GAAA,SAAAM,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,GAAA,IAAAX,GAAA,QAAAW,GAAA,kBAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAd,GAAA,EAAAW,GAAA,SAAAI,IAAA,GAAAR,qBAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAV,GAAA,EAAAW,GAAA,cAAAI,IAAA,KAAAA,IAAA,CAAAV,GAAA,IAAAU,IAAA,CAAAC,GAAA,KAAAR,MAAA,CAAAC,cAAA,CAAAH,MAAA,EAAAK,GAAA,EAAAI,IAAA,YAAAT,MAAA,CAAAK,GAAA,IAAAX,GAAA,CAAAW,GAAA,SAAAL,MAAA,CAAAJ,OAAA,GAAAF,GAAA,MAAAG,KAAA,IAAAA,KAAA,CAAAa,GAAA,CAAAhB,GAAA,EAAAM,MAAA,YAAAA,MAAA"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.TransactionCodeSchema = exports.PreAuthorizedCodeGrantSchema = exports.GrantsSchema = exports.CredentialOfferSchema = exports.AuthorizationCodeGrantSchema = void 0;
|
|
7
|
+
var _zod = require("zod");
|
|
8
|
+
/**
|
|
9
|
+
* OAuth 2.0 Authorization Code flow parameters.
|
|
10
|
+
*/
|
|
11
|
+
const AuthorizationCodeGrantSchema = _zod.z.object({
|
|
12
|
+
issuer_state: _zod.z.string().optional(),
|
|
13
|
+
authorization_server: _zod.z.string().url().optional()
|
|
14
|
+
});
|
|
15
|
+
exports.AuthorizationCodeGrantSchema = AuthorizationCodeGrantSchema;
|
|
16
|
+
/**
|
|
17
|
+
* Transaction Code requirements for Pre-Authorized Code flow.
|
|
18
|
+
*/
|
|
19
|
+
const TransactionCodeSchema = _zod.z.object({
|
|
20
|
+
input_mode: _zod.z.enum(["numeric", "text"]).optional(),
|
|
21
|
+
length: _zod.z.number().int().positive().optional(),
|
|
22
|
+
description: _zod.z.string().max(300).optional()
|
|
23
|
+
});
|
|
24
|
+
exports.TransactionCodeSchema = TransactionCodeSchema;
|
|
25
|
+
/**
|
|
26
|
+
* Pre-Authorized Code flow parameters.
|
|
27
|
+
*/
|
|
28
|
+
const PreAuthorizedCodeGrantSchema = _zod.z.object({
|
|
29
|
+
"pre-authorized_code": _zod.z.string(),
|
|
30
|
+
tx_code: TransactionCodeSchema.optional(),
|
|
31
|
+
authorization_server: _zod.z.string().url().optional()
|
|
32
|
+
});
|
|
33
|
+
exports.PreAuthorizedCodeGrantSchema = PreAuthorizedCodeGrantSchema;
|
|
34
|
+
/**
|
|
35
|
+
* Supported grant types for Credential Offer.
|
|
36
|
+
*/
|
|
37
|
+
const GrantsSchema = _zod.z.object({
|
|
38
|
+
authorization_code: AuthorizationCodeGrantSchema.optional(),
|
|
39
|
+
"urn:ietf:params:oauth:grant-type:pre-authorized_code": PreAuthorizedCodeGrantSchema.optional()
|
|
40
|
+
});
|
|
41
|
+
exports.GrantsSchema = GrantsSchema;
|
|
42
|
+
/**
|
|
43
|
+
* Credential Offer object as defined in OpenID4VCI Section 4.1.1.
|
|
44
|
+
*/
|
|
45
|
+
const CredentialOfferSchema = _zod.z.object({
|
|
46
|
+
credential_issuer: _zod.z.string().url(),
|
|
47
|
+
credential_configuration_ids: _zod.z.array(_zod.z.string()).min(1),
|
|
48
|
+
grants: GrantsSchema.optional()
|
|
49
|
+
});
|
|
50
|
+
exports.CredentialOfferSchema = CredentialOfferSchema;
|
|
51
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_zod","require","AuthorizationCodeGrantSchema","z","object","issuer_state","string","optional","authorization_server","url","exports","TransactionCodeSchema","input_mode","enum","length","number","int","positive","description","max","PreAuthorizedCodeGrantSchema","tx_code","GrantsSchema","authorization_code","CredentialOfferSchema","credential_issuer","credential_configuration_ids","array","min","grants"],"sourceRoot":"../../../../src","sources":["credential/offer/types.ts"],"mappings":";;;;;;AAAA,IAAAA,IAAA,GAAAC,OAAA;AAEA;AACA;AACA;AACO,MAAMC,4BAA4B,GAAGC,MAAC,CAACC,MAAM,CAAC;EACnDC,YAAY,EAAEF,MAAC,CAACG,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC;EACnCC,oBAAoB,EAAEL,MAAC,CAACG,MAAM,CAAC,CAAC,CAACG,GAAG,CAAC,CAAC,CAACF,QAAQ,CAAC;AAClD,CAAC,CAAC;AAACG,OAAA,CAAAR,4BAAA,GAAAA,4BAAA;AAMH;AACA;AACA;AACO,MAAMS,qBAAqB,GAAGR,MAAC,CAACC,MAAM,CAAC;EAC5CQ,UAAU,EAAET,MAAC,CAACU,IAAI,CAAC,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,CAACN,QAAQ,CAAC,CAAC;EAClDO,MAAM,EAAEX,MAAC,CAACY,MAAM,CAAC,CAAC,CAACC,GAAG,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC,CAACV,QAAQ,CAAC,CAAC;EAC9CW,WAAW,EAAEf,MAAC,CAACG,MAAM,CAAC,CAAC,CAACa,GAAG,CAAC,GAAG,CAAC,CAACZ,QAAQ,CAAC;AAC5C,CAAC,CAAC;AAACG,OAAA,CAAAC,qBAAA,GAAAA,qBAAA;AAIH;AACA;AACA;AACO,MAAMS,4BAA4B,GAAGjB,MAAC,CAACC,MAAM,CAAC;EACnD,qBAAqB,EAAED,MAAC,CAACG,MAAM,CAAC,CAAC;EACjCe,OAAO,EAAEV,qBAAqB,CAACJ,QAAQ,CAAC,CAAC;EACzCC,oBAAoB,EAAEL,MAAC,CAACG,MAAM,CAAC,CAAC,CAACG,GAAG,CAAC,CAAC,CAACF,QAAQ,CAAC;AAClD,CAAC,CAAC;AAACG,OAAA,CAAAU,4BAAA,GAAAA,4BAAA;AAMH;AACA;AACA;AACO,MAAME,YAAY,GAAGnB,MAAC,CAACC,MAAM,CAAC;EACnCmB,kBAAkB,EAAErB,4BAA4B,CAACK,QAAQ,CAAC,CAAC;EAC3D,sDAAsD,EACpDa,4BAA4B,CAACb,QAAQ,CAAC;AAC1C,CAAC,CAAC;AAACG,OAAA,CAAAY,YAAA,GAAAA,YAAA;AAIH;AACA;AACA;AACO,MAAME,qBAAqB,GAAGrB,MAAC,CAACC,MAAM,CAAC;EAC5CqB,iBAAiB,EAAEtB,MAAC,CAACG,MAAM,CAAC,CAAC,CAACG,GAAG,CAAC,CAAC;EACnCiB,4BAA4B,EAAEvB,MAAC,CAACwB,KAAK,CAACxB,MAAC,CAACG,MAAM,CAAC,CAAC,CAAC,CAACsB,GAAG,CAAC,CAAC,CAAC;EACxDC,MAAM,EAAEP,YAAY,CAACf,QAAQ,CAAC;AAChC,CAAC,CAAC;AAACG,OAAA,CAAAc,qBAAA,GAAAA,qBAAA"}
|
|
@@ -17,7 +17,7 @@ const PresentationParams = z.object({
|
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* The beginning of the presentation flow.
|
|
20
|
-
* To be implemented
|
|
20
|
+
* To be implemented according to the user touchpoint
|
|
21
21
|
*
|
|
22
22
|
* @param params Presentation parameters, depending on the starting touchpoint
|
|
23
23
|
* @returns The url for the Relying Party to connect with
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Digital Credentials Catalogue
|
|
2
|
+
|
|
3
|
+
Module that manages the [**Digital Credentials Catalogue**](https://italia.github.io/eid-wallet-it-docs/releases/1.1.0/en/registry-catalogue.html) published by the Trust Anchor.
|
|
4
|
+
|
|
5
|
+
The module allows:
|
|
6
|
+
- Fetching, verifying and parsing the catalogue's JWT.
|
|
7
|
+
|
|
8
|
+
## Usage
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
// Fetch the catalogue
|
|
12
|
+
const TRUST_ANCHOR_BASE_URL = "https://pre.ta.wallet.ipzs.it";
|
|
13
|
+
const credentialsCatalogue =
|
|
14
|
+
await CredentialsCatalogue.fetchAndParseCatalogue(TRUST_ANCHOR_BASE_URL);
|
|
15
|
+
```
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.fetchAndParseCatalogue = void 0;
|
|
7
|
+
var _ioReactNativeJwt = require("@pagopa/io-react-native-jwt");
|
|
8
|
+
var _misc = require("../utils/misc");
|
|
9
|
+
var _errors = require("../utils/errors");
|
|
10
|
+
var _types = require("./types");
|
|
11
|
+
var _buildChain = require("../trust/build-chain");
|
|
12
|
+
/**
|
|
13
|
+
* Fetch and parse the Digital Credential Catalogue from the Trust Anchor.
|
|
14
|
+
* The catalogue's JWT signature is verified against the Trust Anchor's JWKs.
|
|
15
|
+
*
|
|
16
|
+
* @param trustAnchorUrl Base URL of the Trust Anchor
|
|
17
|
+
* @param context.appFetch (optional) fetch API implementation. Default: built-in fetch
|
|
18
|
+
* @returns The Digital Credential Catalogue payload
|
|
19
|
+
*/
|
|
20
|
+
const fetchAndParseCatalogue = async function (trustAnchorBaseUrl) {
|
|
21
|
+
let {
|
|
22
|
+
appFetch = fetch
|
|
23
|
+
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
24
|
+
const trustAnchorConfig = await (0, _buildChain.getTrustAnchorEntityConfiguration)(trustAnchorBaseUrl);
|
|
25
|
+
const responseText = await appFetch(`${trustAnchorConfig.payload.sub}/.well-known/credential-catalogue`, {
|
|
26
|
+
method: "GET"
|
|
27
|
+
}).then((0, _misc.hasStatusOrThrow)(200)).then(res => res.text());
|
|
28
|
+
const responseJwt = (0, _ioReactNativeJwt.decode)(responseText);
|
|
29
|
+
const catalogueKid = responseJwt.protectedHeader.kid;
|
|
30
|
+
const trustAnchorJwk = trustAnchorConfig.payload.jwks.keys.find(jwk => jwk.kid === catalogueKid);
|
|
31
|
+
if (!trustAnchorJwk) {
|
|
32
|
+
throw new _errors.IoWalletError(`Could not find JWK with kid ${catalogueKid} in Trust Anchor's Entity Configuration`);
|
|
33
|
+
}
|
|
34
|
+
await (0, _ioReactNativeJwt.verify)(responseText, trustAnchorJwk);
|
|
35
|
+
const parsedDigitalCredentialsCatalogue = _types.DigitalCredentialsCatalogue.parse({
|
|
36
|
+
header: responseJwt.protectedHeader,
|
|
37
|
+
payload: responseJwt.payload
|
|
38
|
+
});
|
|
39
|
+
return parsedDigitalCredentialsCatalogue.payload;
|
|
40
|
+
};
|
|
41
|
+
exports.fetchAndParseCatalogue = fetchAndParseCatalogue;
|
|
42
|
+
//# sourceMappingURL=fetch-and-parse-catalogue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_ioReactNativeJwt","require","_misc","_errors","_types","_buildChain","fetchAndParseCatalogue","trustAnchorBaseUrl","appFetch","fetch","arguments","length","undefined","trustAnchorConfig","getTrustAnchorEntityConfiguration","responseText","payload","sub","method","then","hasStatusOrThrow","res","text","responseJwt","decodeJwt","catalogueKid","protectedHeader","kid","trustAnchorJwk","jwks","keys","find","jwk","IoWalletError","verify","parsedDigitalCredentialsCatalogue","DigitalCredentialsCatalogue","parse","header","exports"],"sourceRoot":"../../../src","sources":["credentials-catalogue/fetch-and-parse-catalogue.ts"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMK,sBAAsB,GAAG,eAAAA,CACpCC,kBAA0B,EAE0B;EAAA,IADpD;IAAEC,QAAQ,GAAGC;EAA2B,CAAC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EAE9C,MAAMG,iBAAiB,GACrB,MAAM,IAAAC,6CAAiC,EAACP,kBAAkB,CAAC;EAE7D,MAAMQ,YAAY,GAAG,MAAMP,QAAQ,CAChC,GAAEK,iBAAiB,CAACG,OAAO,CAACC,GAAI,mCAAkC,EACnE;IAAEC,MAAM,EAAE;EAAM,CAClB,CAAC,CACEC,IAAI,CAAC,IAAAC,sBAAgB,EAAC,GAAG,CAAC,CAAC,CAC3BD,IAAI,CAAEE,GAAG,IAAKA,GAAG,CAACC,IAAI,CAAC,CAAC,CAAC;EAE5B,MAAMC,WAAW,GAAG,IAAAC,wBAAS,EAACT,YAAY,CAAC;EAC3C,MAAMU,YAAY,GAAGF,WAAW,CAACG,eAAe,CAACC,GAAG;EAEpD,MAAMC,cAAc,GAAGf,iBAAiB,CAACG,OAAO,CAACa,IAAI,CAACC,IAAI,CAACC,IAAI,CAC5DC,GAAG,IAAKA,GAAG,CAACL,GAAG,KAAKF,YACvB,CAAC;EAED,IAAI,CAACG,cAAc,EAAE;IACnB,MAAM,IAAIK,qBAAa,CACpB,+BAA8BR,YAAa,yCAC9C,CAAC;EACH;EAEA,MAAM,IAAAS,wBAAM,EAACnB,YAAY,EAAEa,cAAc,CAAC;EAE1C,MAAMO,iCAAiC,GAAGC,kCAA2B,CAACC,KAAK,CAAC;IAC1EC,MAAM,EAAEf,WAAW,CAACG,eAAe;IACnCV,OAAO,EAAEO,WAAW,CAACP;EACvB,CAAC,CAAC;EAEF,OAAOmB,iCAAiC,CAACnB,OAAO;AAClD,CAAC;AAACuB,OAAA,CAAAjC,sBAAA,GAAAA,sBAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "fetchAndParseCatalogue", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _fetchAndParseCatalogue.fetchAndParseCatalogue;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _fetchAndParseCatalogue = require("./fetch-and-parse-catalogue");
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_fetchAndParseCatalogue","require"],"sourceRoot":"../../../src","sources":["credentials-catalogue/index.ts"],"mappings":";;;;;;;;;;;AAAA,IAAAA,uBAAA,GAAAC,OAAA"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.DigitalCredentialsCatalogue = exports.DigitalCredential = void 0;
|
|
7
|
+
var z = _interopRequireWildcard(require("zod"));
|
|
8
|
+
var _types = require("../sd-jwt/types");
|
|
9
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
10
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
11
|
+
const CredentialPurpose = z.object({
|
|
12
|
+
id: z.string(),
|
|
13
|
+
description: z.string(),
|
|
14
|
+
category: z.string(),
|
|
15
|
+
subcategory: z.string(),
|
|
16
|
+
claims_required: z.array(z.string()),
|
|
17
|
+
claim_recommended: z.array(z.string())
|
|
18
|
+
});
|
|
19
|
+
const CredentialIssuer = z.object({
|
|
20
|
+
id: z.string(),
|
|
21
|
+
organization_name: z.string(),
|
|
22
|
+
organization_code: z.string(),
|
|
23
|
+
organization_country: z.string(),
|
|
24
|
+
contacts: z.array(z.string()).optional(),
|
|
25
|
+
homepage_uri: z.string().optional(),
|
|
26
|
+
logo_uri: z.string().optional(),
|
|
27
|
+
policy_uri: z.string().optional(),
|
|
28
|
+
tos_uri: z.string().optional()
|
|
29
|
+
});
|
|
30
|
+
const AuthenticSource = z.object({
|
|
31
|
+
id: z.string(),
|
|
32
|
+
organization_name: z.string(),
|
|
33
|
+
organization_code: z.string(),
|
|
34
|
+
organization_country: z.string(),
|
|
35
|
+
source_type: z.enum(["public", "private"]),
|
|
36
|
+
contacts: z.array(z.string()).optional(),
|
|
37
|
+
homepage_uri: z.string().optional(),
|
|
38
|
+
logo_uri: z.string().optional(),
|
|
39
|
+
user_information: z.string().optional()
|
|
40
|
+
});
|
|
41
|
+
const CredentialFormat = z.object({
|
|
42
|
+
configuration_id: z.string(),
|
|
43
|
+
format: z.enum(["dc+sd-jwt", "mso_mdoc"]),
|
|
44
|
+
vct: z.string().url().optional(),
|
|
45
|
+
docType: z.string().optional(),
|
|
46
|
+
schema_uri: z.string().url().optional(),
|
|
47
|
+
"schema_uri#integrity": z.string().optional()
|
|
48
|
+
});
|
|
49
|
+
const Claim = z.object({
|
|
50
|
+
name: z.string(),
|
|
51
|
+
taxonomy_ref: z.string(),
|
|
52
|
+
display_name: z.string()
|
|
53
|
+
});
|
|
54
|
+
const DigitalCredential = z.object({
|
|
55
|
+
version: z.string(),
|
|
56
|
+
credential_type: z.string(),
|
|
57
|
+
legal_type: z.string(),
|
|
58
|
+
name: z.string(),
|
|
59
|
+
description: z.string(),
|
|
60
|
+
validity_info: z.object({
|
|
61
|
+
max_validity_days: z.number(),
|
|
62
|
+
status_methods: z.array(z.string()),
|
|
63
|
+
allowed_states: z.array(z.string())
|
|
64
|
+
}),
|
|
65
|
+
authentication: z.object({
|
|
66
|
+
user_auth_required: z.boolean(),
|
|
67
|
+
min_loa: z.string(),
|
|
68
|
+
supported_eid_schemes: z.array(z.string())
|
|
69
|
+
}),
|
|
70
|
+
purposes: z.array(CredentialPurpose),
|
|
71
|
+
issuers: z.array(CredentialIssuer),
|
|
72
|
+
authentic_sources: z.array(AuthenticSource),
|
|
73
|
+
formats: z.array(CredentialFormat),
|
|
74
|
+
claims: z.array(Claim)
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* The Digital Credentials Catalogue published by the Trust Anchor
|
|
79
|
+
*
|
|
80
|
+
* @version 1.1.0
|
|
81
|
+
* @see https://italia.github.io/eid-wallet-it-docs/releases/1.1.0/en/registry-catalogue.html
|
|
82
|
+
*/
|
|
83
|
+
exports.DigitalCredential = DigitalCredential;
|
|
84
|
+
const DigitalCredentialsCatalogue = z.object({
|
|
85
|
+
header: z.object({
|
|
86
|
+
typ: z.string(),
|
|
87
|
+
alg: z.string(),
|
|
88
|
+
kid: z.string()
|
|
89
|
+
}),
|
|
90
|
+
payload: z.object({
|
|
91
|
+
catalog_version: z.string(),
|
|
92
|
+
taxonomy_uri: z.string().url(),
|
|
93
|
+
credentials: z.array(DigitalCredential),
|
|
94
|
+
iat: _types.UnixTime,
|
|
95
|
+
exp: _types.UnixTime
|
|
96
|
+
})
|
|
97
|
+
});
|
|
98
|
+
exports.DigitalCredentialsCatalogue = DigitalCredentialsCatalogue;
|
|
99
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["z","_interopRequireWildcard","require","_types","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","CredentialPurpose","object","id","string","description","category","subcategory","claims_required","array","claim_recommended","CredentialIssuer","organization_name","organization_code","organization_country","contacts","optional","homepage_uri","logo_uri","policy_uri","tos_uri","AuthenticSource","source_type","enum","user_information","CredentialFormat","configuration_id","format","vct","url","docType","schema_uri","Claim","name","taxonomy_ref","display_name","DigitalCredential","version","credential_type","legal_type","validity_info","max_validity_days","number","status_methods","allowed_states","authentication","user_auth_required","boolean","min_loa","supported_eid_schemes","purposes","issuers","authentic_sources","formats","claims","exports","DigitalCredentialsCatalogue","header","typ","alg","kid","payload","catalog_version","taxonomy_uri","credentials","iat","UnixTime","exp"],"sourceRoot":"../../../src","sources":["credentials-catalogue/types.ts"],"mappings":";;;;;;AAAA,IAAAA,CAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAA2C,SAAAE,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAJ,wBAAAQ,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,YAAAG,KAAA,CAAAE,GAAA,CAAAL,GAAA,SAAAM,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,GAAA,IAAAX,GAAA,QAAAW,GAAA,kBAAAH,MAAA,CAAAI,SA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C,CAAC;IAC9BmC,WAAW,EAAEzF,CAAC,CAACkC,KAAK,CAAC2B,iBAAiB,CAAC;IACvC6B,GAAG,EAAEC,eAAQ;IACbC,GAAG,EAAED;EACP,CAAC;AACH,CAAC,CAAC;AAACX,OAAA,CAAAC,2BAAA,GAAAA,2BAAA"}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -15,7 +15,7 @@ Object.defineProperty(exports, "AuthorizationDetails", {
|
|
|
15
15
|
return _par.AuthorizationDetails;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
-
exports.WalletInstanceAttestation = exports.WalletInstance = exports.Trust = exports.SdJwt = exports.PID = exports.Logging = exports.Errors = exports.Credential = void 0;
|
|
18
|
+
exports.WalletInstanceAttestation = exports.WalletInstance = exports.Trust = exports.SdJwt = exports.PID = exports.Mdoc = exports.Logging = exports.Errors = exports.CredentialsCatalogue = exports.Credential = void 0;
|
|
19
19
|
Object.defineProperty(exports, "createCryptoContextFor", {
|
|
20
20
|
enumerable: true,
|
|
21
21
|
get: function () {
|
|
@@ -32,10 +32,14 @@ var _jwk = require("./utils/jwk");
|
|
|
32
32
|
require("react-native-url-polyfill/auto");
|
|
33
33
|
var Credential = _interopRequireWildcard(require("./credential"));
|
|
34
34
|
exports.Credential = Credential;
|
|
35
|
+
var CredentialsCatalogue = _interopRequireWildcard(require("./credentials-catalogue"));
|
|
36
|
+
exports.CredentialsCatalogue = CredentialsCatalogue;
|
|
35
37
|
var PID = _interopRequireWildcard(require("./pid"));
|
|
36
38
|
exports.PID = PID;
|
|
37
39
|
var SdJwt = _interopRequireWildcard(require("./sd-jwt"));
|
|
38
40
|
exports.SdJwt = SdJwt;
|
|
41
|
+
var Mdoc = _interopRequireWildcard(require("./mdoc"));
|
|
42
|
+
exports.Mdoc = Mdoc;
|
|
39
43
|
var Errors = _interopRequireWildcard(require("./utils/errors"));
|
|
40
44
|
exports.Errors = Errors;
|
|
41
45
|
var WalletInstanceAttestation = _interopRequireWildcard(require("./wallet-instance-attestation"));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_jwk","require","Credential","_interopRequireWildcard","exports","PID","SdJwt","Errors","WalletInstanceAttestation","Trust","WalletInstance","Logging","_par","_crypto","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,IAAAA,IAAA,GAAAC,OAAA;AAGAA,OAAA;AAEA,IAAAC,UAAA,GAAAC,uBAAA,CAAAF,OAAA;AAA2CG,OAAA,CAAAF,UAAA,GAAAA,UAAA;AAC3C,IAAAG,
|
|
1
|
+
{"version":3,"names":["_jwk","require","Credential","_interopRequireWildcard","exports","CredentialsCatalogue","PID","SdJwt","Mdoc","Errors","WalletInstanceAttestation","Trust","WalletInstance","Logging","_par","_crypto","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,IAAAA,IAAA,GAAAC,OAAA;AAGAA,OAAA;AAEA,IAAAC,UAAA,GAAAC,uBAAA,CAAAF,OAAA;AAA2CG,OAAA,CAAAF,UAAA,GAAAA,UAAA;AAC3C,IAAAG,oBAAA,GAAAF,uBAAA,CAAAF,OAAA;AAAgEG,OAAA,CAAAC,oBAAA,GAAAA,oBAAA;AAChE,IAAAC,GAAA,GAAAH,uBAAA,CAAAF,OAAA;AAA6BG,OAAA,CAAAE,GAAA,GAAAA,GAAA;AAC7B,IAAAC,KAAA,GAAAJ,uBAAA,CAAAF,OAAA;AAAkCG,O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AX,GAAA,QAAAW,GAAA,kBAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAd,GAAA,EAAAW,GAAA,SAAAI,IAAA,GAAAR,qBAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAV,GAAA,EAAAW,GAAA,cAAAI,IAAA,KAAAA,IAAA,CAAAV,GAAA,IAAAU,IAAA,CAAAC,GAAA,KAAAR,MAAA,CAAAC,cAAA,CAAAH,MAAA,EAAAK,GAAA,EAAAI,IAAA,YAAAT,MAAA,CAAAK,GAAA,IAAAX,GAAA,CAAAW,GAAA,SAAAL,MAAA,CAAAJ,OAAA,GAAAF,GAAA,MAAAG,KAAA,IAAAA,KAAA,CAAAa,GAAA,CAAAhB,GAAA,EAAAM,MAAA,YAAAA,MAAA"}
|
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
verify: true
|
|
8
|
+
};
|
|
6
9
|
exports.verify = void 0;
|
|
7
10
|
var _ioReactNativeIso = require("@pagopa/io-react-native-iso18013");
|
|
8
11
|
var _jsrsasign = require("jsrsasign");
|
|
@@ -10,6 +13,18 @@ var _ioReactNativeCrypto = require("@pagopa/io-react-native-crypto");
|
|
|
10
13
|
var _errors = require("../trust/errors");
|
|
11
14
|
var _errors2 = require("../utils/errors");
|
|
12
15
|
var _crypto = require("../utils/crypto");
|
|
16
|
+
var _utils = require("./utils");
|
|
17
|
+
Object.keys(_utils).forEach(function (key) {
|
|
18
|
+
if (key === "default" || key === "__esModule") return;
|
|
19
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
20
|
+
if (key in exports && exports[key] === _utils[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _utils[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
13
28
|
const verify = async (token, x509CertRoot) => {
|
|
14
29
|
var _issuerSigned$issuerA;
|
|
15
30
|
// get decoded data
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_ioReactNativeIso","require","_jsrsasign","_ioReactNativeCrypto","_errors","_errors2","_crypto","verify","token","x509CertRoot","_issuerSigned$issuerA","issuerSigned","CBOR","decodeIssuerSigned","IoWalletError","issuerAuth","unprotectedHeader","x5chain","Array","isArray","length","MissingX509CertsError","map","b64utob64","verifyX5chain","coseSign1","rawValue","verifyMdocSignature","
|
|
1
|
+
{"version":3,"names":["_ioReactNativeIso","require","_jsrsasign","_ioReactNativeCrypto","_errors","_errors2","_crypto","_utils","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","verify","token","x509CertRoot","_issuerSigned$issuerA","issuerSigned","CBOR","decodeIssuerSigned","IoWalletError","issuerAuth","unprotectedHeader","x5chain","Array","isArray","length","MissingX509CertsError","map","b64utob64","verifyX5chain","coseSign1","rawValue","verifyMdocSignature","options","arguments","undefined","connectTimeout","readTimeout","requireCrl","x509ValidationResult","verifyCertificateChain","isValid","X509ValidationError","validationStatus","errorMessage","x509ValidationStatus","x509ErrorMessage","cert","pemcert","convertBase64DerToPem","jwk","getSigninJwkFromCert","x","y","signatureCorrect","COSE","Error"],"sourceRoot":"../../../src","sources":["mdoc/index.ts"],"mappings":";;;;;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,oBAAA,GAAAF,OAAA;AAMA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AAAAO,MAAA,CAAAC,IAAA,CAAAF,MAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,M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IAAI,CAACI,gBAAgB,EAAE,MAAM,IAAIE,KAAK,CAAC,wBAAwB,CAAC;AAClE,CAAC"}
|
|
@@ -3,12 +3,48 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.getParsedCredentialClaimKey = void 0;
|
|
6
|
+
exports.getVerificationFromParsedCredential = exports.getVerification = exports.getParsedCredentialClaimKey = void 0;
|
|
7
|
+
var _ioReactNativeIso = require("@pagopa/io-react-native-iso18013");
|
|
8
|
+
var _types = require("../sd-jwt/types");
|
|
9
|
+
var _const = require("./const");
|
|
7
10
|
/**
|
|
8
11
|
* @param namespace The mdoc credential `namespace`
|
|
9
12
|
* @param key The claim attribute key
|
|
10
13
|
* @returns A string consisting of the concatenation of the namespace and the claim key, separated by a colon
|
|
11
14
|
*/
|
|
12
15
|
const getParsedCredentialClaimKey = (namespace, key) => `${namespace}:${key}`;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Extract and validate the `verification` claim from an mdoc parsed credential.
|
|
19
|
+
*
|
|
20
|
+
* This method is **synchronous**, so it requires a credential that was already parsed.
|
|
21
|
+
*
|
|
22
|
+
* @param parsedCredential The parsed mdoc credential
|
|
23
|
+
* @returns The verification claim or undefined if it wasn't found
|
|
24
|
+
*/
|
|
13
25
|
exports.getParsedCredentialClaimKey = getParsedCredentialClaimKey;
|
|
26
|
+
const getVerificationFromParsedCredential = parsedCredential => {
|
|
27
|
+
var _parsedCredential$ver;
|
|
28
|
+
const verificationKey = getParsedCredentialClaimKey(`${_const.MDOC_DEFAULT_NAMESPACE}.IT`, "verification");
|
|
29
|
+
const verification = (_parsedCredential$ver = parsedCredential[verificationKey]) === null || _parsedCredential$ver === void 0 ? void 0 : _parsedCredential$ver.value;
|
|
30
|
+
return verification ? _types.Verification.parse(verification) : undefined;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Extract and validate the `verification` claim from an MDOC credential.
|
|
35
|
+
*
|
|
36
|
+
* This method is **asynchronous**. See {@link getVerificationFromParsedCredential} for the synchronous version.
|
|
37
|
+
*
|
|
38
|
+
* @param token The raw MDOC credential
|
|
39
|
+
* @returns The verification claim or undefined if it wasn't found
|
|
40
|
+
*/
|
|
41
|
+
exports.getVerificationFromParsedCredential = getVerificationFromParsedCredential;
|
|
42
|
+
const getVerification = async token => {
|
|
43
|
+
var _namespace$find;
|
|
44
|
+
const issuerSigned = await _ioReactNativeIso.CBOR.decodeIssuerSigned(token);
|
|
45
|
+
const namespace = issuerSigned.nameSpaces[`${_const.MDOC_DEFAULT_NAMESPACE}.IT`];
|
|
46
|
+
const verification = namespace === null || namespace === void 0 || (_namespace$find = namespace.find(x => x.elementIdentifier === "verification")) === null || _namespace$find === void 0 ? void 0 : _namespace$find.elementValue;
|
|
47
|
+
return verification ? _types.Verification.parse(verification) : undefined;
|
|
48
|
+
};
|
|
49
|
+
exports.getVerification = getVerification;
|
|
14
50
|
//# sourceMappingURL=utils.js.map
|