@pagopa/io-react-native-wallet 3.3.0 → 3.4.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 (163) hide show
  1. package/README.md +1 -1
  2. package/lib/commonjs/credential/issuance/README.md +32 -14
  3. package/lib/commonjs/credential/issuance/api/IssuerConfig.js +1 -0
  4. package/lib/commonjs/credential/issuance/api/IssuerConfig.js.map +1 -1
  5. package/lib/commonjs/credential/issuance/common/06-verify-and-parse-credential.sdjwt.js +5 -3
  6. package/lib/commonjs/credential/issuance/common/06-verify-and-parse-credential.sdjwt.js.map +1 -1
  7. package/lib/commonjs/credential/issuance/v1.0.0/02-start-user-authorization.js +2 -1
  8. package/lib/commonjs/credential/issuance/v1.0.0/02-start-user-authorization.js.map +1 -1
  9. package/lib/commonjs/credential/issuance/v1.0.0/03-complete-user-authorization.js +8 -5
  10. package/lib/commonjs/credential/issuance/v1.0.0/03-complete-user-authorization.js.map +1 -1
  11. package/lib/commonjs/credential/issuance/v1.0.0/index.js +2 -1
  12. package/lib/commonjs/credential/issuance/v1.0.0/index.js.map +1 -1
  13. package/lib/commonjs/credential/issuance/v1.0.0/mappers.js +3 -1
  14. package/lib/commonjs/credential/issuance/v1.0.0/mappers.js.map +1 -1
  15. package/lib/commonjs/credential/issuance/v1.3.3/02-start-user-authorization.js +1 -1
  16. package/lib/commonjs/credential/issuance/v1.3.3/02-start-user-authorization.js.map +1 -1
  17. package/lib/commonjs/credential/issuance/v1.3.3/03-complete-user-authorization.js +108 -69
  18. package/lib/commonjs/credential/issuance/v1.3.3/03-complete-user-authorization.js.map +1 -1
  19. package/lib/commonjs/credential/issuance/v1.3.3/05-obtain-credential.js +1 -1
  20. package/lib/commonjs/credential/issuance/v1.3.3/05-obtain-credential.js.map +1 -1
  21. package/lib/commonjs/credential/issuance/v1.3.3/index.js +2 -1
  22. package/lib/commonjs/credential/issuance/v1.3.3/index.js.map +1 -1
  23. package/lib/commonjs/credential/issuance/v1.3.3/mappers.js +9 -10
  24. package/lib/commonjs/credential/issuance/v1.3.3/mappers.js.map +1 -1
  25. package/lib/commonjs/credential/presentation/api/types.js.map +1 -1
  26. package/lib/commonjs/credential/presentation/common/utils/http.js +9 -4
  27. package/lib/commonjs/credential/presentation/common/utils/http.js.map +1 -1
  28. package/lib/commonjs/credential/presentation/v1.0.0/07-send-authorization-response.js +3 -1
  29. package/lib/commonjs/credential/presentation/v1.0.0/07-send-authorization-response.js.map +1 -1
  30. package/lib/commonjs/credential/presentation/v1.3.3/05-verify-request-object.js +11 -10
  31. package/lib/commonjs/credential/presentation/v1.3.3/05-verify-request-object.js.map +1 -1
  32. package/lib/commonjs/credential/presentation/v1.3.3/07-send-authorization-response.js +2 -0
  33. package/lib/commonjs/credential/presentation/v1.3.3/07-send-authorization-response.js.map +1 -1
  34. package/lib/commonjs/credential/presentation/v1.3.3/mappers.js +1 -1
  35. package/lib/commonjs/credential/presentation/v1.3.3/mappers.js.map +1 -1
  36. package/lib/commonjs/credentials-catalogue/api/DigitalCredentialsCatalogue.js +2 -1
  37. package/lib/commonjs/credentials-catalogue/api/DigitalCredentialsCatalogue.js.map +1 -1
  38. package/lib/commonjs/credentials-catalogue/common/get-status-l10n-ids.js +23 -0
  39. package/lib/commonjs/credentials-catalogue/common/get-status-l10n-ids.js.map +1 -0
  40. package/lib/commonjs/credentials-catalogue/v1.0.0/index.js +3 -1
  41. package/lib/commonjs/credentials-catalogue/v1.0.0/index.js.map +1 -1
  42. package/lib/commonjs/credentials-catalogue/v1.3.3/index.js +3 -1
  43. package/lib/commonjs/credentials-catalogue/v1.3.3/index.js.map +1 -1
  44. package/lib/commonjs/utils/config.js +9 -1
  45. package/lib/commonjs/utils/config.js.map +1 -1
  46. package/lib/module/credential/issuance/README.md +32 -14
  47. package/lib/module/credential/issuance/api/IssuerConfig.js +1 -0
  48. package/lib/module/credential/issuance/api/IssuerConfig.js.map +1 -1
  49. package/lib/module/credential/issuance/common/06-verify-and-parse-credential.sdjwt.js +5 -3
  50. package/lib/module/credential/issuance/common/06-verify-and-parse-credential.sdjwt.js.map +1 -1
  51. package/lib/module/credential/issuance/v1.0.0/02-start-user-authorization.js +2 -1
  52. package/lib/module/credential/issuance/v1.0.0/02-start-user-authorization.js.map +1 -1
  53. package/lib/module/credential/issuance/v1.0.0/03-complete-user-authorization.js +6 -4
  54. package/lib/module/credential/issuance/v1.0.0/03-complete-user-authorization.js.map +1 -1
  55. package/lib/module/credential/issuance/v1.0.0/index.js +3 -2
  56. package/lib/module/credential/issuance/v1.0.0/index.js.map +1 -1
  57. package/lib/module/credential/issuance/v1.0.0/mappers.js +3 -1
  58. package/lib/module/credential/issuance/v1.0.0/mappers.js.map +1 -1
  59. package/lib/module/credential/issuance/v1.3.3/02-start-user-authorization.js +1 -1
  60. package/lib/module/credential/issuance/v1.3.3/02-start-user-authorization.js.map +1 -1
  61. package/lib/module/credential/issuance/v1.3.3/03-complete-user-authorization.js +108 -70
  62. package/lib/module/credential/issuance/v1.3.3/03-complete-user-authorization.js.map +1 -1
  63. package/lib/module/credential/issuance/v1.3.3/05-obtain-credential.js +1 -1
  64. package/lib/module/credential/issuance/v1.3.3/05-obtain-credential.js.map +1 -1
  65. package/lib/module/credential/issuance/v1.3.3/index.js +3 -2
  66. package/lib/module/credential/issuance/v1.3.3/index.js.map +1 -1
  67. package/lib/module/credential/issuance/v1.3.3/mappers.js +9 -10
  68. package/lib/module/credential/issuance/v1.3.3/mappers.js.map +1 -1
  69. package/lib/module/credential/presentation/api/types.js.map +1 -1
  70. package/lib/module/credential/presentation/common/utils/http.js +9 -4
  71. package/lib/module/credential/presentation/common/utils/http.js.map +1 -1
  72. package/lib/module/credential/presentation/v1.0.0/07-send-authorization-response.js +3 -1
  73. package/lib/module/credential/presentation/v1.0.0/07-send-authorization-response.js.map +1 -1
  74. package/lib/module/credential/presentation/v1.3.3/05-verify-request-object.js +11 -10
  75. package/lib/module/credential/presentation/v1.3.3/05-verify-request-object.js.map +1 -1
  76. package/lib/module/credential/presentation/v1.3.3/07-send-authorization-response.js +2 -0
  77. package/lib/module/credential/presentation/v1.3.3/07-send-authorization-response.js.map +1 -1
  78. package/lib/module/credential/presentation/v1.3.3/mappers.js +1 -1
  79. package/lib/module/credential/presentation/v1.3.3/mappers.js.map +1 -1
  80. package/lib/module/credentials-catalogue/api/DigitalCredentialsCatalogue.js +1 -1
  81. package/lib/module/credentials-catalogue/api/DigitalCredentialsCatalogue.js.map +1 -1
  82. package/lib/module/credentials-catalogue/common/get-status-l10n-ids.js +16 -0
  83. package/lib/module/credentials-catalogue/common/get-status-l10n-ids.js.map +1 -0
  84. package/lib/module/credentials-catalogue/v1.0.0/index.js +3 -1
  85. package/lib/module/credentials-catalogue/v1.0.0/index.js.map +1 -1
  86. package/lib/module/credentials-catalogue/v1.3.3/index.js +3 -1
  87. package/lib/module/credentials-catalogue/v1.3.3/index.js.map +1 -1
  88. package/lib/module/utils/config.js +7 -0
  89. package/lib/module/utils/config.js.map +1 -1
  90. package/lib/typescript/credential/issuance/api/02-start-user-authorization.d.ts +1 -0
  91. package/lib/typescript/credential/issuance/api/02-start-user-authorization.d.ts.map +1 -1
  92. package/lib/typescript/credential/issuance/api/03-complete-user-authorization.d.ts +19 -5
  93. package/lib/typescript/credential/issuance/api/03-complete-user-authorization.d.ts.map +1 -1
  94. package/lib/typescript/credential/issuance/api/IssuerConfig.d.ts +1 -0
  95. package/lib/typescript/credential/issuance/api/IssuerConfig.d.ts.map +1 -1
  96. package/lib/typescript/credential/issuance/common/06-verify-and-parse-credential.sdjwt.d.ts.map +1 -1
  97. package/lib/typescript/credential/issuance/v1.0.0/02-start-user-authorization.d.ts.map +1 -1
  98. package/lib/typescript/credential/issuance/v1.0.0/03-complete-user-authorization.d.ts +2 -1
  99. package/lib/typescript/credential/issuance/v1.0.0/03-complete-user-authorization.d.ts.map +1 -1
  100. package/lib/typescript/credential/issuance/v1.0.0/index.d.ts.map +1 -1
  101. package/lib/typescript/credential/issuance/v1.0.0/mappers.d.ts +1 -0
  102. package/lib/typescript/credential/issuance/v1.0.0/mappers.d.ts.map +1 -1
  103. package/lib/typescript/credential/issuance/v1.3.3/03-complete-user-authorization.d.ts +2 -1
  104. package/lib/typescript/credential/issuance/v1.3.3/03-complete-user-authorization.d.ts.map +1 -1
  105. package/lib/typescript/credential/issuance/v1.3.3/index.d.ts.map +1 -1
  106. package/lib/typescript/credential/issuance/v1.3.3/mappers.d.ts +7 -4
  107. package/lib/typescript/credential/issuance/v1.3.3/mappers.d.ts.map +1 -1
  108. package/lib/typescript/credential/presentation/api/05-verify-request-object.d.ts +1 -1
  109. package/lib/typescript/credential/presentation/api/types.d.ts +3 -7
  110. package/lib/typescript/credential/presentation/api/types.d.ts.map +1 -1
  111. package/lib/typescript/credential/presentation/common/utils/http.d.ts +1 -1
  112. package/lib/typescript/credential/presentation/common/utils/http.d.ts.map +1 -1
  113. package/lib/typescript/credential/presentation/v1.3.3/05-verify-request-object.d.ts.map +1 -1
  114. package/lib/typescript/credential/presentation/v1.3.3/07-send-authorization-response.d.ts.map +1 -1
  115. package/lib/typescript/credential/presentation/v1.3.3/mappers.d.ts +8 -8
  116. package/lib/typescript/credential/presentation/v1.3.3/types.d.ts +8 -8
  117. package/lib/typescript/credentials-catalogue/api/DigitalCredentialsCatalogue.d.ts +6 -0
  118. package/lib/typescript/credentials-catalogue/api/DigitalCredentialsCatalogue.d.ts.map +1 -1
  119. package/lib/typescript/credentials-catalogue/api/index.d.ts +14 -2
  120. package/lib/typescript/credentials-catalogue/api/index.d.ts.map +1 -1
  121. package/lib/typescript/credentials-catalogue/common/get-status-l10n-ids.d.ts +9 -0
  122. package/lib/typescript/credentials-catalogue/common/get-status-l10n-ids.d.ts.map +1 -0
  123. package/lib/typescript/credentials-catalogue/v1.0.0/index.d.ts.map +1 -1
  124. package/lib/typescript/credentials-catalogue/v1.3.3/index.d.ts.map +1 -1
  125. package/lib/typescript/trust/v1.3.3/types.d.ts +6 -4
  126. package/lib/typescript/trust/v1.3.3/types.d.ts.map +1 -1
  127. package/lib/typescript/utils/config.d.ts +4 -0
  128. package/lib/typescript/utils/config.d.ts.map +1 -1
  129. package/package.json +6 -6
  130. package/src/credential/issuance/README.md +32 -14
  131. package/src/credential/issuance/api/02-start-user-authorization.ts +1 -0
  132. package/src/credential/issuance/api/03-complete-user-authorization.ts +26 -5
  133. package/src/credential/issuance/api/IssuerConfig.ts +1 -0
  134. package/src/credential/issuance/common/06-verify-and-parse-credential.sdjwt.ts +8 -4
  135. package/src/credential/issuance/v1.0.0/02-start-user-authorization.ts +7 -1
  136. package/src/credential/issuance/v1.0.0/03-complete-user-authorization.ts +16 -4
  137. package/src/credential/issuance/v1.0.0/index.ts +4 -2
  138. package/src/credential/issuance/v1.0.0/mappers.ts +5 -0
  139. package/src/credential/issuance/v1.3.3/02-start-user-authorization.ts +1 -1
  140. package/src/credential/issuance/v1.3.3/03-complete-user-authorization.ts +138 -94
  141. package/src/credential/issuance/v1.3.3/05-obtain-credential.ts +1 -1
  142. package/src/credential/issuance/v1.3.3/index.ts +4 -2
  143. package/src/credential/issuance/v1.3.3/mappers.ts +9 -10
  144. package/src/credential/presentation/api/05-verify-request-object.ts +1 -1
  145. package/src/credential/presentation/api/types.ts +3 -7
  146. package/src/credential/presentation/common/utils/http.ts +2 -2
  147. package/src/credential/presentation/v1.0.0/07-send-authorization-response.ts +1 -1
  148. package/src/credential/presentation/v1.3.3/05-verify-request-object.ts +15 -14
  149. package/src/credential/presentation/v1.3.3/07-send-authorization-response.ts +2 -0
  150. package/src/credential/presentation/v1.3.3/mappers.ts +1 -1
  151. package/src/credentials-catalogue/api/DigitalCredentialsCatalogue.ts +4 -1
  152. package/src/credentials-catalogue/api/index.ts +15 -0
  153. package/src/credentials-catalogue/common/get-status-l10n-ids.ts +25 -0
  154. package/src/credentials-catalogue/v1.0.0/index.ts +2 -0
  155. package/src/credentials-catalogue/v1.3.3/index.ts +2 -0
  156. package/src/utils/config.ts +7 -0
  157. package/lib/commonjs/credential/presentation/common/utils.js +0 -28
  158. package/lib/commonjs/credential/presentation/common/utils.js.map +0 -1
  159. package/lib/module/credential/presentation/common/utils.js +0 -21
  160. package/lib/module/credential/presentation/common/utils.js.map +0 -1
  161. package/lib/typescript/credential/presentation/common/utils.d.ts +0 -11
  162. package/lib/typescript/credential/presentation/common/utils.d.ts.map +0 -1
  163. package/src/credential/presentation/common/utils.ts +0 -30
@@ -7,7 +7,11 @@ import {
7
7
  import { hasStatusOrThrow } from "../../../utils/misc";
8
8
  import parseUrl from "parse-url";
9
9
  import type { DcqlQuery } from "dcql";
10
- import { IssuerResponseError, ValidationFailed } from "../../../utils/errors";
10
+ import {
11
+ IssuerResponseError,
12
+ UnimplementedFeatureError,
13
+ ValidationFailed,
14
+ } from "../../../utils/errors";
11
15
  import {
12
16
  decode,
13
17
  SignJWT,
@@ -70,7 +74,7 @@ export const buildAuthorizationUrl: IssuanceApi["buildAuthorizationUrl"] =
70
74
  return { authUrl };
71
75
  };
72
76
 
73
- export const completeUserAuthorizationWithQueryMode: IssuanceApi["completeUserAuthorizationWithQueryMode"] =
77
+ export const completePidUserAuthorizationWithQueryMode: IssuanceApi["completePidUserAuthorizationWithQueryMode"] =
74
78
  async (authRedirectUrl) => {
75
79
  Logger.log(
76
80
  LogLevel.DEBUG,
@@ -81,6 +85,14 @@ export const completeUserAuthorizationWithQueryMode: IssuanceApi["completeUserAu
81
85
  return parseAuthorizationResponse(query);
82
86
  };
83
87
 
88
+ export const completeEaaUserAuthorizationWithQueryMode: IssuanceApi["completeEaaUserAuthorizationWithQueryMode"] =
89
+ () => {
90
+ throw new UnimplementedFeatureError(
91
+ "completeEaaUserAuthorizationWithQueryMode",
92
+ "1.0.0"
93
+ );
94
+ };
95
+
84
96
  export const getRequestedCredentialToBePresented: IssuanceApi["getRequestedCredentialToBePresented"] =
85
97
  async (issuerRequestUri, clientId, issuerConf, appFetch = fetch) => {
86
98
  Logger.log(
@@ -130,7 +142,7 @@ export const completeUserAuthorizationWithFormPostJwtMode: IssuanceApi["complete
130
142
  requestObject,
131
143
  _issuerConfig,
132
144
  pid,
133
- { wiaCryptoContext, pidKeyTag, appFetch = fetch }
145
+ { wiaCryptoContext, appFetch = fetch }
134
146
  ) => {
135
147
  Logger.log(
136
148
  LogLevel.DEBUG,
@@ -139,7 +151,7 @@ export const completeUserAuthorizationWithFormPostJwtMode: IssuanceApi["complete
139
151
 
140
152
  const dcqlQueryResult = await RemotePresentationFlow.evaluateDcqlQuery(
141
153
  requestObject.dcql_query as DcqlQuery,
142
- [[pidKeyTag, pid]]
154
+ [pid]
143
155
  );
144
156
 
145
157
  const authRequestObject = {
@@ -3,7 +3,8 @@ import { evaluateIssuerTrust } from "./01-evaluate-issuer-trust";
3
3
  import { startUserAuthorization } from "./02-start-user-authorization";
4
4
  import {
5
5
  continueUserAuthorizationWithMRTDPoPChallenge,
6
- completeUserAuthorizationWithQueryMode,
6
+ completePidUserAuthorizationWithQueryMode,
7
+ completeEaaUserAuthorizationWithQueryMode,
7
8
  completeUserAuthorizationWithFormPostJwtMode,
8
9
  buildAuthorizationUrl,
9
10
  getRequestedCredentialToBePresented,
@@ -20,7 +21,8 @@ export const Issuance: IssuanceApi = {
20
21
  evaluateIssuerTrust,
21
22
  startUserAuthorization,
22
23
  buildAuthorizationUrl,
23
- completeUserAuthorizationWithQueryMode,
24
+ completePidUserAuthorizationWithQueryMode,
25
+ completeEaaUserAuthorizationWithQueryMode,
24
26
  continueUserAuthorizationWithMRTDPoPChallenge,
25
27
  getRequestedCredentialToBePresented,
26
28
  completeUserAuthorizationWithFormPostJwtMode,
@@ -9,6 +9,7 @@ export const mapToIssuerConfig = createMapper<
9
9
  const {
10
10
  oauth_authorization_server,
11
11
  openid_credential_issuer,
12
+ openid_credential_verifier,
12
13
  federation_entity,
13
14
  } = x.payload.metadata;
14
15
  return {
@@ -28,5 +29,9 @@ export const mapToIssuerConfig = createMapper<
28
29
  openid_credential_issuer.status_attestation_endpoint,
29
30
  nonce_endpoint: openid_credential_issuer.nonce_endpoint,
30
31
  federation_entity,
32
+ encrypted_response_enc_values_supported:
33
+ openid_credential_verifier?.authorization_encrypted_response_enc
34
+ ? [openid_credential_verifier.authorization_encrypted_response_enc]
35
+ : undefined,
31
36
  };
32
37
  });
@@ -88,7 +88,7 @@ export const startUserAuthorization: IssuanceApi["startUserAuthorization"] =
88
88
  signJwt,
89
89
  },
90
90
  clientAttestation: walletInstanceAttestation,
91
- authorizationServer: issuerConf.authorization_endpoint,
91
+ authorizationServer: issuerConf.credential_issuer,
92
92
  signer: wiaSigner,
93
93
  jti: uuidv4(),
94
94
  });
@@ -6,30 +6,33 @@ import {
6
6
  import parseUrl from "parse-url";
7
7
  import type { DcqlQuery } from "dcql";
8
8
  import {
9
- fetchAuthorizationRequest,
9
+ createAuthorizationResponse,
10
10
  parseAuthorizeRequest,
11
+ fetchAuthorizationResponse,
12
+ type CreateAuthorizationResponseResult,
11
13
  } from "@pagopa/io-wallet-oid4vp";
12
14
  import { sendAuthorizationResponseAndExtractCode } from "@pagopa/io-wallet-oid4vci";
15
+ import type { jsonWebKeySet } from "@pagopa/io-wallet-oid-federation";
13
16
  import { parseMrtdChallenge } from "@pagopa/io-wallet-oauth2";
14
- import { SignJWT, type CryptoContext } from "@pagopa/io-react-native-jwt";
15
17
  import { AuthorizationError, AuthorizationIdpError } from "../common/errors";
16
18
  import { LogLevel, Logger } from "../../../utils/logging";
17
19
  import { RemotePresentation as RemotePresentationFlow } from "../../presentation/v1.3.3";
18
- import { partialCallbacks } from "../../../utils/callbacks";
19
- import { sdkConfigV1_3 } from "../../../utils/config";
20
20
  import {
21
- IoWalletError,
22
- sdkUnexpectedStatusCodeToIssuerError,
23
- } from "../../../utils/errors";
24
- import type { IssuanceApi } from "../api";
21
+ createVerifyJwtFromJwks,
22
+ partialCallbacks,
23
+ } from "../../../utils/callbacks";
24
+ import { sdkConfigV1_3, sdkConfigV1_4 } from "../../../utils/config";
25
+ import { IoWalletError, IssuerResponseError } from "../../../utils/errors";
26
+ import type { IssuanceApi, IssuerConfig } from "../api";
25
27
  import { mapToRequestObject } from "./mappers";
26
- import type { RemotePresentation } from "../../presentation";
28
+ import type { RequestObject } from "../../presentation";
29
+ import { hasStatusOrThrow } from "../../../utils/misc";
27
30
 
28
31
  export const continueUserAuthorizationWithMRTDPoPChallenge: IssuanceApi["continueUserAuthorizationWithMRTDPoPChallenge"] =
29
32
  async (authRedirectUrl) => {
30
33
  Logger.log(
31
34
  LogLevel.DEBUG,
32
- `The requested credential is a PersonIdentificationData and requires MRTD PoP, starting MRTD PoP validation from auth redirect`
35
+ "The requested credential is a PID and requires MRTD PoP, starting MRTD PoP validation from auth redirect"
33
36
  );
34
37
  try {
35
38
  const parsedChallenge = parseMrtdChallenge({
@@ -65,11 +68,11 @@ export const buildAuthorizationUrl: IssuanceApi["buildAuthorizationUrl"] =
65
68
  return { authUrl };
66
69
  };
67
70
 
68
- export const completeUserAuthorizationWithQueryMode: IssuanceApi["completeUserAuthorizationWithQueryMode"] =
71
+ export const completePidUserAuthorizationWithQueryMode: IssuanceApi["completePidUserAuthorizationWithQueryMode"] =
69
72
  async (authRedirectUrl) => {
70
73
  Logger.log(
71
74
  LogLevel.DEBUG,
72
- `The requested credential is a PersonIdentificationData, completing the user authorization with query mode`
75
+ "The requested credential is a PID, completing the user authorization with query mode"
73
76
  );
74
77
  const query = parseUrl(authRedirectUrl).query;
75
78
 
@@ -80,7 +83,7 @@ export const getRequestedCredentialToBePresented: IssuanceApi["getRequestedCrede
80
83
  async (issuerRequestUri, clientId, issuerConf, appFetch = fetch) => {
81
84
  Logger.log(
82
85
  LogLevel.DEBUG,
83
- `The requeste credential is not a PersonIdentificationData, requesting the credential to be presented`
86
+ "The requested credential is not a PID, requesting the credential to be presented"
84
87
  );
85
88
 
86
89
  const authzRequestEndpoint = issuerConf.authorization_endpoint;
@@ -94,61 +97,39 @@ export const getRequestedCredentialToBePresented: IssuanceApi["getRequestedCrede
94
97
  `Requesting the request object to ${authzRequestEndpoint}?${params.toString()}`
95
98
  );
96
99
 
97
- const authRequest = await fetchAuthorizationRequest({
98
- authorizeRequestUrl: `${authzRequestEndpoint}?${params.toString()}`,
99
- callbacks: {
100
- fetch: appFetch,
101
- },
102
- }).catch(sdkUnexpectedStatusCodeToIssuerError);
100
+ const requestObjectJwt = await appFetch(
101
+ `${authzRequestEndpoint}?${params.toString()}`,
102
+ { method: "GET" }
103
+ )
104
+ .then(hasStatusOrThrow(200, IssuerResponseError))
105
+ .then((res) => res.text());
103
106
 
104
107
  const parsedAuthRequest = await parseAuthorizeRequest({
105
108
  config: sdkConfigV1_3,
106
- requestObjectJwt: authRequest.requestObjectJwt,
107
- callbacks: partialCallbacks,
109
+ requestObjectJwt,
110
+ callbacks: {
111
+ verifyJwt: createVerifyJwtFromJwks(issuerConf.keys),
112
+ },
108
113
  });
109
114
 
110
115
  return mapToRequestObject(parsedAuthRequest);
111
116
  };
112
117
 
118
+ // NOTE: this function is not used in the 1.3 issuance flow. It may be removed in the future.
113
119
  export const completeUserAuthorizationWithFormPostJwtMode: IssuanceApi["completeUserAuthorizationWithFormPostJwtMode"] =
114
- async (
115
- requestObject,
116
- issuerConfig,
117
- pid,
118
- { wiaCryptoContext, pidKeyTag, appFetch = fetch }
119
- ) => {
120
+ async (requestObject, issuerConfig, pid, { appFetch = fetch }) => {
120
121
  Logger.log(
121
122
  LogLevel.DEBUG,
122
- `The requeste credential is not a PersonIdentificationData, completing the user authorization with form_post.jwt mode`
123
- );
124
-
125
- const dcqlQueryResult = await RemotePresentationFlow.evaluateDcqlQuery(
126
- requestObject.dcql_query as DcqlQuery,
127
- [[pidKeyTag, pid]]
123
+ "The requested credential is not a PID, completing the user authorization with form_post.jwt mode"
128
124
  );
129
125
 
130
- const authRequestObject = {
131
- nonce: requestObject.nonce,
132
- clientId: requestObject.client_id,
133
- responseUri: requestObject.response_uri,
134
- };
135
-
136
- const remotePresentation =
137
- await RemotePresentationFlow.prepareRemotePresentations(
138
- dcqlQueryResult,
139
- authRequestObject
140
- );
141
-
142
- const authzResponsePayload = await createAuthzResponsePayload({
143
- state: requestObject.state,
144
- remotePresentation,
145
- wiaCryptoContext,
126
+ const authzResponse = await processPidPresentationAndCreateAuthzResponse({
127
+ requestObject,
128
+ issuerConfig,
129
+ pid,
146
130
  });
147
131
 
148
- Logger.log(
149
- LogLevel.DEBUG,
150
- `Authz response payload: ${authzResponsePayload}`
151
- );
132
+ Logger.log(LogLevel.DEBUG, `Authz response: ${authzResponse}`);
152
133
 
153
134
  const issuerSigKey = issuerConfig.keys.find((key) => key.use === "sig");
154
135
  if (!issuerSigKey) {
@@ -158,13 +139,13 @@ export const completeUserAuthorizationWithFormPostJwtMode: IssuanceApi["complete
158
139
  }
159
140
 
160
141
  return sendAuthorizationResponseAndExtractCode({
161
- authorizationResponseJarm: authzResponsePayload,
142
+ authorizationResponseJarm: authzResponse.jarm.responseJwe,
162
143
  callbacks: {
163
144
  ...partialCallbacks,
164
145
  fetch: appFetch,
165
146
  },
166
147
  iss: requestObject.iss,
167
- state: requestObject.state!,
148
+ state: requestObject.state ?? "",
168
149
  presentationResponseUri: requestObject.response_uri,
169
150
  signer: {
170
151
  alg: "ES256",
@@ -174,6 +155,62 @@ export const completeUserAuthorizationWithFormPostJwtMode: IssuanceApi["complete
174
155
  });
175
156
  };
176
157
 
158
+ export const completeEaaUserAuthorizationWithQueryMode: IssuanceApi["completeEaaUserAuthorizationWithQueryMode"] =
159
+ async (
160
+ requestObject,
161
+ issuerConfig,
162
+ pid,
163
+ clientRedirectUri,
164
+ { appFetch = fetch } = {}
165
+ ) => {
166
+ Logger.log(
167
+ LogLevel.DEBUG,
168
+ "The requested credential is not a PID, completing the user authorization with query mode"
169
+ );
170
+
171
+ const authzResponse = await processPidPresentationAndCreateAuthzResponse({
172
+ requestObject,
173
+ issuerConfig,
174
+ pid,
175
+ });
176
+
177
+ Logger.log(LogLevel.DEBUG, `Authz response: ${authzResponse}`);
178
+
179
+ const { redirect_uri } = await fetchAuthorizationResponse({
180
+ authorizationResponseJarm: authzResponse.jarm.responseJwe,
181
+ presentationResponseUri: requestObject.response_uri,
182
+ callbacks: {
183
+ ...partialCallbacks,
184
+ fetch: appFetch,
185
+ },
186
+ });
187
+
188
+ if (!redirect_uri) {
189
+ const errorMessage =
190
+ "The authorization server did not return a redirect_uri to continue the authorization flow";
191
+ Logger.log(LogLevel.ERROR, errorMessage);
192
+ throw new AuthorizationError(errorMessage);
193
+ }
194
+
195
+ const response = await appFetch(redirect_uri).catch(() => null);
196
+
197
+ if (!response || !response.ok) {
198
+ const errorMessage = `An error occurred while completing the authorization flow. Ensure ${clientRedirectUri} is a valid HTTP url for redirect`;
199
+ Logger.log(LogLevel.ERROR, errorMessage);
200
+ throw new AuthorizationError(errorMessage);
201
+ }
202
+
203
+ const finalRedirectUri = response.url;
204
+
205
+ if (!finalRedirectUri || !finalRedirectUri.startsWith(clientRedirectUri)) {
206
+ const errorMessage = `The authorization server did not redirect to the provided client redirect URI. Expected: ${clientRedirectUri}, got: ${finalRedirectUri}`;
207
+ Logger.log(LogLevel.ERROR, errorMessage);
208
+ throw new AuthorizationError(errorMessage);
209
+ }
210
+
211
+ return parseAuthorizationResponse(parseUrl(finalRedirectUri).query);
212
+ };
213
+
177
214
  /**
178
215
  * Parse the authorization response and return the result which contains code, state and iss.
179
216
  * @throws {AuthorizationError} if an error occurs during the parsing process
@@ -207,45 +244,52 @@ export const parseAuthorizationResponse = (
207
244
  };
208
245
 
209
246
  /**
210
- * Creates the authorization response payload to be sent.
211
- * This payload includes the state and the VP tokens for the presented credentials.
212
- * The payload is encoded in Base64.
213
- * @param state - The state parameter from the request object (optional).
214
- * @param remotePresentation The presentations to send, each with their VP token
215
- * @returns The Base64 encoded authorization response payload.
247
+ * Utility function to process the DCQL query for PID presentation and to create the authorization response to send to the Issuer.
248
+ * @param params.requestObject - The request object containing the DCQL query
249
+ * @param params.issuerConfig - The Issuer unified configuration
250
+ * @param params.pid - The PID credential to be presented, as a tuple of [keyTag, credential]
251
+ * @returns The authorization response containing the JARM to be sent to the Issuer
216
252
  */
217
- const createAuthzResponsePayload = async ({
218
- state,
219
- remotePresentation,
220
- wiaCryptoContext,
253
+ const processPidPresentationAndCreateAuthzResponse = async ({
254
+ requestObject,
255
+ issuerConfig,
256
+ pid,
221
257
  }: {
222
- state?: string;
223
- remotePresentation: RemotePresentation;
224
- wiaCryptoContext: CryptoContext;
225
- }): Promise<string> => {
226
- const { kid } = await wiaCryptoContext.getPublicKey();
227
-
228
- return new SignJWT(wiaCryptoContext)
229
- .setProtectedHeader({
230
- typ: "jwt",
231
- kid,
232
- })
233
- .setPayload({
234
- /**
235
- * TODO [SIW-2264]: `state` coming from `requestObject` is marked as `optional`
236
- * At the moment, it is not entirely clear whether this value can indeed be omitted
237
- * and, if so, what the consequences of its absence might be.
238
- */
239
- ...(state ? { state } : {}),
240
- vp_token: remotePresentation.presentations.reduce(
241
- (vp_token, { credentialId, vpToken }) => ({
242
- ...vp_token,
243
- [credentialId]: [vpToken],
244
- }),
245
- {}
246
- ),
247
- })
248
- .setIssuedAt()
249
- .setExpirationTime("1h")
250
- .sign();
258
+ requestObject: RequestObject;
259
+ issuerConfig: IssuerConfig;
260
+ pid: [keyTag: string, credential: string];
261
+ }): Promise<CreateAuthorizationResponseResult> => {
262
+ const dcqlQueryResult = await RemotePresentationFlow.evaluateDcqlQuery(
263
+ requestObject.dcql_query as DcqlQuery,
264
+ [pid]
265
+ );
266
+
267
+ const remotePresentation =
268
+ await RemotePresentationFlow.prepareRemotePresentations(dcqlQueryResult, {
269
+ clientId: requestObject.client_id,
270
+ nonce: requestObject.nonce,
271
+ responseUri: requestObject.response_uri,
272
+ });
273
+
274
+ const vp_token = remotePresentation.presentations.reduce(
275
+ (acc, { credentialId, vpToken }) => ({ ...acc, [credentialId]: [vpToken] }),
276
+ {} as Record<string, string[]>
277
+ );
278
+
279
+ return createAuthorizationResponse({
280
+ // The SDK 1.4 config is used here in order to resolve the encryption data from the Request Object
281
+ // client_metadata, otherwise OpenID Federation clients always ignore client_metadata as per 1.3.3 specs.
282
+ config: sdkConfigV1_4,
283
+ requestObject,
284
+ rpJwks: {
285
+ jwks: { keys: issuerConfig.keys } as jsonWebKeySet,
286
+ encrypted_response_enc_values_supported:
287
+ issuerConfig.encrypted_response_enc_values_supported,
288
+ },
289
+ vp_token,
290
+ callbacks: {
291
+ encryptJwe: partialCallbacks.encryptJwe,
292
+ generateRandom: partialCallbacks.generateRandom,
293
+ },
294
+ });
251
295
  };
@@ -112,7 +112,7 @@ export const requestCredentials = async ({
112
112
  },
113
113
  clientId,
114
114
  credential_identifier: credentialIdentifier,
115
- issuerIdentifier: issuerConf.credential_issuer,
115
+ issuerIdentifier: issuerConf.credential_endpoint,
116
116
  maxBatchSize: issuerConf.credential_issuance_batch_size,
117
117
  nonce: c_nonce,
118
118
  keyAttestation: keyAttestationJwt,
@@ -3,7 +3,8 @@ import { evaluateIssuerTrust } from "./01-evaluate-issuer-trust";
3
3
  import { startUserAuthorization } from "./02-start-user-authorization";
4
4
  import {
5
5
  continueUserAuthorizationWithMRTDPoPChallenge,
6
- completeUserAuthorizationWithQueryMode,
6
+ completePidUserAuthorizationWithQueryMode,
7
+ completeEaaUserAuthorizationWithQueryMode,
7
8
  completeUserAuthorizationWithFormPostJwtMode,
8
9
  buildAuthorizationUrl,
9
10
  getRequestedCredentialToBePresented,
@@ -20,7 +21,8 @@ export const Issuance: IssuanceApi = {
20
21
  evaluateIssuerTrust,
21
22
  startUserAuthorization,
22
23
  buildAuthorizationUrl,
23
- completeUserAuthorizationWithQueryMode,
24
+ completePidUserAuthorizationWithQueryMode,
25
+ completeEaaUserAuthorizationWithQueryMode,
24
26
  continueUserAuthorizationWithMRTDPoPChallenge,
25
27
  getRequestedCredentialToBePresented,
26
28
  completeUserAuthorizationWithFormPostJwtMode,
@@ -41,6 +41,7 @@ export const mapToIssuerConfig = createMapper<
41
41
  const {
42
42
  oauth_authorization_server,
43
43
  openid_credential_issuer,
44
+ openid_credential_verifier,
44
45
  federation_entity,
45
46
  } = x.metadata;
46
47
 
@@ -67,10 +68,12 @@ export const mapToIssuerConfig = createMapper<
67
68
  pushed_authorization_request_endpoint:
68
69
  oauth_authorization_server.pushed_authorization_request_endpoint,
69
70
  token_endpoint: oauth_authorization_server.token_endpoint,
70
- nonce_endpoint: openid_credential_issuer.nonce_endpoint!,
71
+ nonce_endpoint: openid_credential_issuer.nonce_endpoint ?? "",
71
72
  federation_entity: federation_entity ?? {},
72
73
  credential_issuance_batch_size:
73
74
  openid_credential_issuer.batch_credential_issuance?.batch_size,
75
+ encrypted_response_enc_values_supported:
76
+ openid_credential_verifier?.encrypted_response_enc_values_supported,
74
77
  };
75
78
  },
76
79
  { outputSchema: IssuerConfig } // Output validation for extra-safety
@@ -79,13 +82,9 @@ export const mapToIssuerConfig = createMapper<
79
82
  export const mapToRequestObject = createMapper<
80
83
  ParsedAuthorizeRequestResult,
81
84
  RequestObject
82
- >(({ payload }) => ({
83
- iss: payload.iss ?? "UNKNOWN_ISSUER",
84
- client_id: payload.client_id,
85
- dcql_query: payload.dcql_query,
86
- nonce: payload.nonce,
87
- response_uri: payload.response_uri,
88
- state: payload.state,
89
- response_mode: payload.response_mode,
90
- response_type: payload.response_type,
85
+ >(({ header, payload }) => ({
86
+ ...payload,
87
+ iss: payload.iss ?? "",
88
+ trust_chain: header.trust_chain,
89
+ x5c: header.x5c as string[] | undefined,
91
90
  }));
@@ -7,7 +7,7 @@ export interface VerifyRequestObjectApi {
7
7
  * @since 1.0.0
8
8
  *
9
9
  * @param requestObjectEncodedJwt The Request Object in JWT format
10
- * @param params.clientId The client ID to verify
10
+ * @param params.clientId The client ID to verify (it may include a prefix)
11
11
  * @param params.rpConf Optional Relying Party configuration (OpenID Federation clients only)
12
12
  * @param params.state Optional state
13
13
  * @returns The verified Request Object
@@ -72,13 +72,9 @@ export type RemotePresentationDetails = {
72
72
  type ClientMetadata = {
73
73
  jwks: jsonWebKeySet;
74
74
  encrypted_response_enc_values_supported: string[];
75
- client_id: string;
76
- client_name: string;
77
- logo_uri: string;
78
- application_type: "web";
79
- request_uris: string[];
80
- response_uris: string[];
81
75
  vp_formats_supported: Record<string, { "sd-jwt_alg_values"?: string[] }>;
76
+ client_name?: string;
77
+ logo_uri?: string;
82
78
  };
83
79
 
84
80
  /**
@@ -88,7 +84,7 @@ export type RequestObject = {
88
84
  iss: string;
89
85
  response_uri: string;
90
86
  nonce: string;
91
- state: string;
87
+ state?: string;
92
88
  client_id: string;
93
89
  dcql_query: Record<string, unknown>;
94
90
  response_type: "vp_token";
@@ -9,11 +9,11 @@ import type { DirectAuthorizationBodyPayload } from "../../v1.0.0/types";
9
9
  * @returns A URL-encoded string suitable for an `application/x-www-form-urlencoded` POST body.
10
10
  */
11
11
  export const buildDirectPostBody = async (
12
- requestObject: RequestObject,
12
+ { state }: RequestObject,
13
13
  payload: DirectAuthorizationBodyPayload
14
14
  ): Promise<string> => {
15
15
  const formUrlEncodedBody = new URLSearchParams({
16
- state: requestObject.state,
16
+ ...(state && { state }),
17
17
  ...Object.entries(payload).reduce(
18
18
  (acc, [key, value]) => ({
19
19
  ...acc,
@@ -81,7 +81,7 @@ export const buildDirectPostJwtBody = async (
81
81
  // Build the x-www-form-urlencoded form body
82
82
  const formBody = new URLSearchParams({
83
83
  response: encryptedResponse,
84
- state: requestObject.state,
84
+ ...(requestObject.state && { state: requestObject.state }),
85
85
  });
86
86
  return formBody.toString();
87
87
  };
@@ -14,7 +14,7 @@ import { mapToRequestObject } from "./mappers";
14
14
  import type { RawRequestObject } from "./types";
15
15
 
16
16
  export const verifyRequestObject: RemotePresentationApi["verifyRequestObject"] =
17
- async (requestObjectEncodedJwt, { clientId, rpConf }) => {
17
+ async (requestObjectEncodedJwt, { clientId: fullClientId, rpConf }) => {
18
18
  const parsedRequestObject = await sdkParseAuthorizeRequest({
19
19
  config: sdkConfigV1_3,
20
20
  requestObjectJwt: requestObjectEncodedJwt,
@@ -25,17 +25,22 @@ export const verifyRequestObject: RemotePresentationApi["verifyRequestObject"] =
25
25
 
26
26
  const rawRequestObject = parsedRequestObject as RawRequestObject;
27
27
 
28
- const clientIdPrefix = extractClientIdPrefix(clientId);
28
+ const { prefix, clientId } = extractClientIdPrefix(fullClientId);
29
29
 
30
- if (clientIdPrefix === ClientIdPrefix.X509_HASH) {
30
+ if (prefix === ClientIdPrefix.X509_HASH) {
31
31
  validateX509HashClient(rawRequestObject.header.x5c, clientId);
32
32
  }
33
33
 
34
34
  if (
35
- clientIdPrefix === ClientIdPrefix.OPENID_FEDERATION ||
36
- clientIdPrefix === ClientIdPrefix.NONE
35
+ prefix === ClientIdPrefix.OPENID_FEDERATION ||
36
+ prefix === ClientIdPrefix.NONE
37
37
  ) {
38
- validateOpenIDFederationClient(rawRequestObject, clientId, rpConf);
38
+ validateOpenIDFederationClient(
39
+ rawRequestObject,
40
+ fullClientId,
41
+ clientId,
42
+ rpConf
43
+ );
39
44
  }
40
45
 
41
46
  return {
@@ -45,6 +50,7 @@ export const verifyRequestObject: RemotePresentationApi["verifyRequestObject"] =
45
50
 
46
51
  const validateOpenIDFederationClient = (
47
52
  requestObject: RawRequestObject,
53
+ fullClientId: string,
48
54
  clientId: string,
49
55
  rpConf: RelyingPartyConfig | undefined
50
56
  ) => {
@@ -55,8 +61,8 @@ const validateOpenIDFederationClient = (
55
61
  }
56
62
 
57
63
  const isClientIdMatch =
58
- clientId === requestObject.payload.client_id &&
59
- stripOpenIdFederationPrefix(clientId) === rpConf.subject;
64
+ fullClientId === requestObject.payload.client_id &&
65
+ clientId === rpConf.subject;
60
66
 
61
67
  if (!isClientIdMatch) {
62
68
  throw new InvalidRequestObjectError(
@@ -67,10 +73,8 @@ const validateOpenIDFederationClient = (
67
73
 
68
74
  const validateX509HashClient = (
69
75
  certificateChain: string[],
70
- clientId: string
76
+ x509Hash: string
71
77
  ) => {
72
- const [, x509Hash] = clientId.split(":");
73
-
74
78
  const calculatedHash = QuickCrypto.createHash("sha-256")
75
79
  .update(certificateChain[0]!, "base64")
76
80
  .digest("base64url");
@@ -81,6 +85,3 @@ const validateX509HashClient = (
81
85
  );
82
86
  }
83
87
  };
84
-
85
- const stripOpenIdFederationPrefix = (clientId: string) =>
86
- clientId.replace("openid_federation:", "");
@@ -17,6 +17,7 @@ import { AuthorizationResponse } from "./types";
17
17
  import { buildDirectPostBody } from "../common/utils/http";
18
18
  import { prepareVpToken } from "../../../sd-jwt";
19
19
  import { createCryptoContextFor } from "../../../utils/crypto";
20
+ import { sdkConfigV1_3 } from "../../../utils/config";
20
21
  import { prepareVpTokenMdoc } from "../../../mdoc";
21
22
 
22
23
  /**
@@ -126,6 +127,7 @@ export const sendAuthorizationResponse: RemotePresentationApi["sendAuthorization
126
127
  );
127
128
 
128
129
  const { jarm } = await sdkCreateAuthorizationResponse({
130
+ config: sdkConfigV1_3,
129
131
  requestObject,
130
132
  rpJwks,
131
133
  vp_token,
@@ -21,7 +21,7 @@ export const mapToRelyingPartyConfig = createMapper<
21
21
 
22
22
  export const mapToRequestObject = createMapper<RawRequestObject, RequestObject>(
23
23
  ({ payload, header }) => ({
24
- iss: payload.iss,
24
+ iss: payload.iss ?? "",
25
25
  client_id: payload.client_id,
26
26
  dcql_query: payload.dcql_query,
27
27
  nonce: payload.nonce,