@pagopa/io-react-native-wallet 0.13.1 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/commonjs/cie/component.js +180 -0
- package/lib/commonjs/cie/component.js.map +1 -0
- package/lib/commonjs/cie/error.js +44 -0
- package/lib/commonjs/cie/error.js.map +1 -0
- package/lib/commonjs/cie/index.js +32 -0
- package/lib/commonjs/cie/index.js.map +1 -0
- package/lib/commonjs/cie/manager.js +142 -0
- package/lib/commonjs/cie/manager.js.map +1 -0
- package/lib/commonjs/client/index.js +5 -2
- package/lib/commonjs/client/index.js.map +1 -1
- package/lib/commonjs/credential/issuance/04-complete-user-authorization.js +144 -19
- package/lib/commonjs/credential/issuance/04-complete-user-authorization.js.map +1 -1
- package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js +12 -4
- package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
- package/lib/commonjs/credential/issuance/index.js +18 -0
- package/lib/commonjs/credential/issuance/index.js.map +1 -1
- package/lib/commonjs/credential/issuance/types.js +9 -1
- package/lib/commonjs/credential/issuance/types.js.map +1 -1
- package/lib/commonjs/index.js +3 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/trust/types.js +5 -3
- package/lib/commonjs/trust/types.js.map +1 -1
- package/lib/commonjs/utils/decoder.js +28 -19
- package/lib/commonjs/utils/decoder.js.map +1 -1
- package/lib/module/cie/component.js +171 -0
- package/lib/module/cie/component.js.map +1 -0
- package/lib/module/cie/error.js +36 -0
- package/lib/module/cie/error.js.map +1 -0
- package/lib/module/cie/index.js +4 -0
- package/lib/module/cie/index.js.map +1 -0
- package/lib/module/cie/manager.js +133 -0
- package/lib/module/cie/manager.js.map +1 -0
- package/lib/module/client/index.js +5 -2
- package/lib/module/client/index.js.map +1 -1
- package/lib/module/credential/issuance/04-complete-user-authorization.js +141 -18
- package/lib/module/credential/issuance/04-complete-user-authorization.js.map +1 -1
- package/lib/module/credential/issuance/07-verify-and-parse-credential.js +12 -4
- package/lib/module/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
- package/lib/module/credential/issuance/index.js +2 -2
- package/lib/module/credential/issuance/index.js.map +1 -1
- package/lib/module/credential/issuance/types.js +7 -0
- package/lib/module/credential/issuance/types.js.map +1 -1
- package/lib/module/index.js +2 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/trust/types.js +5 -3
- package/lib/module/trust/types.js.map +1 -1
- package/lib/module/utils/decoder.js +28 -19
- package/lib/module/utils/decoder.js.map +1 -1
- package/lib/typescript/cie/component.d.ts +46 -0
- package/lib/typescript/cie/component.d.ts.map +1 -0
- package/lib/typescript/cie/error.d.ts +31 -0
- package/lib/typescript/cie/error.d.ts.map +1 -0
- package/lib/typescript/cie/index.d.ts +4 -0
- package/lib/typescript/cie/index.d.ts.map +1 -0
- package/lib/typescript/cie/manager.d.ts +5 -0
- package/lib/typescript/cie/manager.d.ts.map +1 -0
- package/lib/typescript/client/index.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts +48 -1
- package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts +1 -0
- package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/index.d.ts +3 -3
- package/lib/typescript/credential/issuance/index.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/types.d.ts +10 -0
- package/lib/typescript/credential/issuance/types.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +2 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/trust/index.d.ts +14 -14
- package/lib/typescript/trust/types.d.ts +142 -142
- package/lib/typescript/trust/types.d.ts.map +1 -1
- package/lib/typescript/utils/decoder.d.ts.map +1 -1
- package/package.json +6 -2
- package/src/cie/component.tsx +216 -0
- package/src/cie/error.ts +58 -0
- package/src/cie/index.ts +4 -0
- package/src/cie/manager.ts +183 -0
- package/src/client/index.ts +4 -1
- package/src/credential/issuance/04-complete-user-authorization.ts +216 -21
- package/src/credential/issuance/07-verify-and-parse-credential.ts +14 -6
- package/src/credential/issuance/index.ts +10 -0
- package/src/credential/issuance/types.ts +7 -0
- package/src/index.ts +2 -0
- package/src/trust/types.ts +8 -6
- package/src/utils/decoder.ts +28 -19
- package/lib/commonjs/credential/issuance/03-start-credential-issuance.js +0 -287
- package/lib/commonjs/credential/issuance/03-start-credential-issuance.js.map +0 -1
- package/lib/module/credential/issuance/03-start-credential-issuance.js +0 -276
- package/lib/module/credential/issuance/03-start-credential-issuance.js.map +0 -1
- package/lib/typescript/credential/issuance/03-start-credential-issuance.d.ts +0 -41
- package/lib/typescript/credential/issuance/03-start-credential-issuance.d.ts.map +0 -1
- package/src/credential/issuance/03-start-credential-issuance.ts +0 -407
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["CieEvent","WebViewComponent","CieError","CieErrorType"],"sourceRoot":"../../../src","sources":["cie/index.ts"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,gBAAgB,QAAQ,aAAa;AACxD,SAASC,QAAQ,EAAEC,YAAY,QAAQ,SAAS;AAEhD,SAASF,gBAAgB,EAAEC,QAAQ,EAAEC,YAAY,EAAEH,QAAQ"}
|
@@ -0,0 +1,133 @@
|
|
1
|
+
import cieManager from "@pagopa/react-native-cie";
|
2
|
+
import { Platform } from "react-native";
|
3
|
+
import { CieEvent } from "./component";
|
4
|
+
import { CieError, CieErrorType } from "./error";
|
5
|
+
const BASE_UAT_URL = "https://collaudo.idserver.servizicie.interno.gov.it/idp/";
|
6
|
+
export const startCieAndroid = (useCieUat, ciePin, onError, onEvent, cieAuthorizationUri, continueWithUrl) => {
|
7
|
+
try {
|
8
|
+
cieManager.removeAllListeners();
|
9
|
+
cieManager.start().then(async () => {
|
10
|
+
cieManager.onEvent(handleCieEvent(onError, onEvent));
|
11
|
+
cieManager.onError(e => {
|
12
|
+
console.error(e);
|
13
|
+
return onError(new CieError({
|
14
|
+
message: e.message
|
15
|
+
}));
|
16
|
+
});
|
17
|
+
cieManager.onSuccess(handleCieSuccess(continueWithUrl));
|
18
|
+
await cieManager.setPin(ciePin);
|
19
|
+
cieManager.setAuthenticationUrl(cieAuthorizationUri);
|
20
|
+
cieManager.enableLog(useCieUat);
|
21
|
+
cieManager.setCustomIdpUrl(useCieUat ? getCieUatEndpoint() : null);
|
22
|
+
await cieManager.startListeningNFC();
|
23
|
+
onEvent(CieEvent.waiting_card);
|
24
|
+
}).catch(onError);
|
25
|
+
} catch (e) {
|
26
|
+
onError(new CieError({
|
27
|
+
message: `Unable to start CIE NFC manager on Android: ${e}`,
|
28
|
+
type: CieErrorType.NFC_ERROR
|
29
|
+
}));
|
30
|
+
}
|
31
|
+
};
|
32
|
+
export const startCieiOS = async (useCieUat, ciePin, onError, onEvent, cieAuthorizationUri, continueWithUrl) => {
|
33
|
+
try {
|
34
|
+
cieManager.removeAllListeners();
|
35
|
+
cieManager.onEvent(handleCieEvent(onError, onEvent));
|
36
|
+
cieManager.onError(e => onError(new CieError({
|
37
|
+
message: e.message
|
38
|
+
})));
|
39
|
+
cieManager.onSuccess(handleCieSuccess(continueWithUrl));
|
40
|
+
cieManager.enableLog(useCieUat);
|
41
|
+
cieManager.setCustomIdpUrl(useCieUat ? getCieUatEndpoint() : null);
|
42
|
+
await cieManager.setPin(ciePin);
|
43
|
+
cieManager.setAuthenticationUrl(cieAuthorizationUri);
|
44
|
+
cieManager.start().then(async () => {
|
45
|
+
await cieManager.startListeningNFC();
|
46
|
+
onEvent(CieEvent.waiting_card);
|
47
|
+
}).catch(onError);
|
48
|
+
} catch (e) {
|
49
|
+
onError(new CieError({
|
50
|
+
message: `Unable to start CIE NFC manager on iOS: ${e}`,
|
51
|
+
type: CieErrorType.NFC_ERROR
|
52
|
+
}));
|
53
|
+
}
|
54
|
+
};
|
55
|
+
const handleCieEvent = (onError, onEvent) => event => {
|
56
|
+
switch (event.event) {
|
57
|
+
// Reading starts
|
58
|
+
case "ON_TAG_DISCOVERED":
|
59
|
+
onEvent(CieEvent.reading);
|
60
|
+
break;
|
61
|
+
// "Function not supported" seems to be TAG_ERROR_NFC_NOT_SUPPORTED
|
62
|
+
// for the iOS SDK
|
63
|
+
case "Function not supported":
|
64
|
+
case "TAG_ERROR_NFC_NOT_SUPPORTED":
|
65
|
+
case "ON_TAG_DISCOVERED_NOT_CIE":
|
66
|
+
onError(new CieError({
|
67
|
+
message: `Invalid CIE card: ${event.event}`,
|
68
|
+
type: CieErrorType.TAG_NOT_VALID
|
69
|
+
}));
|
70
|
+
break;
|
71
|
+
case "AUTHENTICATION_ERROR":
|
72
|
+
case "ON_NO_INTERNET_CONNECTION":
|
73
|
+
onError(new CieError({
|
74
|
+
message: `Authentication error or no internet connection`,
|
75
|
+
type: CieErrorType.AUTHENTICATION_ERROR
|
76
|
+
}));
|
77
|
+
break;
|
78
|
+
case "EXTENDED_APDU_NOT_SUPPORTED":
|
79
|
+
onError(new CieError({
|
80
|
+
message: `APDU not supported`,
|
81
|
+
type: CieErrorType.NFC_ERROR
|
82
|
+
}));
|
83
|
+
break;
|
84
|
+
case "Transmission Error":
|
85
|
+
case "ON_TAG_LOST":
|
86
|
+
onError(new CieError({
|
87
|
+
message: `Trasmission error`,
|
88
|
+
type: CieErrorType.NFC_ERROR
|
89
|
+
}));
|
90
|
+
break;
|
91
|
+
|
92
|
+
// The card is temporarily locked. Unlock is available by CieID app
|
93
|
+
case "PIN Locked":
|
94
|
+
case "ON_CARD_PIN_LOCKED":
|
95
|
+
onError(new CieError({
|
96
|
+
message: `PIN locked`,
|
97
|
+
type: CieErrorType.PIN_LOCKED
|
98
|
+
}));
|
99
|
+
break;
|
100
|
+
case "ON_PIN_ERROR":
|
101
|
+
onError(new CieError({
|
102
|
+
message: `PIN locked`,
|
103
|
+
type: CieErrorType.PIN_ERROR,
|
104
|
+
attemptsLeft: event.attemptsLeft
|
105
|
+
}));
|
106
|
+
break;
|
107
|
+
|
108
|
+
// CIE is Expired or Revoked
|
109
|
+
case "CERTIFICATE_EXPIRED":
|
110
|
+
onError(new CieError({
|
111
|
+
message: `Certificate expired`,
|
112
|
+
type: CieErrorType.CERTIFICATE_ERROR
|
113
|
+
}));
|
114
|
+
break;
|
115
|
+
case "CERTIFICATE_REVOKED":
|
116
|
+
onError(new CieError({
|
117
|
+
message: `Certificate revoked`,
|
118
|
+
type: CieErrorType.CERTIFICATE_ERROR
|
119
|
+
}));
|
120
|
+
break;
|
121
|
+
default:
|
122
|
+
break;
|
123
|
+
}
|
124
|
+
};
|
125
|
+
const handleCieSuccess = continueWithUrl => url => {
|
126
|
+
continueWithUrl(decodeURIComponent(url));
|
127
|
+
};
|
128
|
+
const getCieUatEndpoint = () => Platform.select({
|
129
|
+
ios: `${BASE_UAT_URL}Authn/SSL/Login2`,
|
130
|
+
android: BASE_UAT_URL,
|
131
|
+
default: null
|
132
|
+
});
|
133
|
+
//# sourceMappingURL=manager.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["cieManager","Platform","CieEvent","CieError","CieErrorType","BASE_UAT_URL","startCieAndroid","useCieUat","ciePin","onError","onEvent","cieAuthorizationUri","continueWithUrl","removeAllListeners","start","then","handleCieEvent","e","console","error","message","onSuccess","handleCieSuccess","setPin","setAuthenticationUrl","enableLog","setCustomIdpUrl","getCieUatEndpoint","startListeningNFC","waiting_card","catch","type","NFC_ERROR","startCieiOS","event","reading","TAG_NOT_VALID","AUTHENTICATION_ERROR","PIN_LOCKED","PIN_ERROR","attemptsLeft","CERTIFICATE_ERROR","url","decodeURIComponent","select","ios","android","default"],"sourceRoot":"../../../src","sources":["cie/manager.ts"],"mappings":"AAAA,OAAOA,UAAU,MAAgC,0BAA0B;AAC3E,SAASC,QAAQ,QAAQ,cAAc;AACvC,SAASC,QAAQ,QAAuC,aAAa;AACrE,SAASC,QAAQ,EAAEC,YAAY,QAAQ,SAAS;AAEhD,MAAMC,YAAY,GAAG,0DAA0D;AAI/E,OAAO,MAAMC,eAAe,GAAGA,CAC7BC,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L,IAAIN,QAAQ,CAAC;QACXiB,OAAO,EAAG,qBAAoB;QAC9BW,IAAI,EAAE3B,YAAY,CAACqC;MACrB,CAAC,CACH,CAAC;MAED;IAEF;MACE;EACJ;AACF,CAAC;AAEH,MAAMnB,gBAAgB,GACnBV,eAAgC,IAAM8B,GAAW,IAAK;EACrD9B,eAAe,CAAC+B,kBAAkB,CAACD,GAAG,CAAC,CAAC;AAC1C,CAAC;AAEH,MAAMf,iBAAiB,GAAGA,CAAA,KACxB1B,QAAQ,CAAC2C,MAAM,CAAC;EACdC,GAAG,EAAG,GAAExC,YAAa,kBAAiB;EACtCyC,OAAO,EAAEzC,YAAY;EACrB0C,OAAO,EAAE;AACX,CAAC,CAAC"}
|
@@ -21,10 +21,13 @@ export const getWalletProviderClient = context => {
|
|
21
21
|
} = context;
|
22
22
|
return createWalletProviderApiClient((method, url, params) => appFetch(url, {
|
23
23
|
method,
|
24
|
-
body: params ? JSON.stringify(params.body) : undefined
|
24
|
+
body: params ? JSON.stringify(params.body) : undefined,
|
25
|
+
headers: {
|
26
|
+
"Content-Type": "application/json"
|
27
|
+
}
|
25
28
|
}).then(validateResponse).then(res => {
|
26
29
|
const contentType = res.headers.get("content-type");
|
27
|
-
if (contentType
|
30
|
+
if (contentType !== null && contentType !== void 0 && contentType.includes("application/json")) {
|
28
31
|
return res.json();
|
29
32
|
}
|
30
33
|
return res.text();
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["WalletProviderResponseError","ProblemDetail","createApiClient","createWalletProviderApiClient","validateResponse","response","ok","problemDetail","parse","json","title","type","detail","status","getWalletProviderClient","context","walletProviderBaseUrl","appFetch","fetch","method","url","params","body","JSON","stringify","undefined","then","res","contentType","
|
1
|
+
{"version":3,"names":["WalletProviderResponseError","ProblemDetail","createApiClient","createWalletProviderApiClient","validateResponse","response","ok","problemDetail","parse","json","title","type","detail","status","getWalletProviderClient","context","walletProviderBaseUrl","appFetch","fetch","method","url","params","body","JSON","stringify","undefined","headers","then","res","contentType","get","includes","text"],"sourceRoot":"../../../src","sources":["client/index.ts"],"mappings":"AAAA,SAASA,2BAA2B,QAAQ,iBAAiB;AAC7D,SACEC,aAAa,EACbC,eAAe,IAAIC,6BAA6B,QAC3C,6BAA6B;AAKpC,MAAMC,gBAAgB,GAAG,MAAOC,QAAkB,IAAK;EACrD,IAAI,CAACA,QAAQ,CAACC,EAAE,EAAE;IAChB,IAAIC,aAA4B,GAAG,CAAC,CAAC;IACrC,IAAI;MACFA,aAAa,GAAGN,aAAa,CAACO,KAAK,CAAC,MAAMH,QAAQ,CAACI,IAAI,CAAC,CAAC,CAAC;IAC5D,CAAC,CAAC,MAAM;MACNF,aAAa,GAAG;QACdG,KAAK,EAAE;MACT,CAAC;IACH;IAEA,MAAM,IAAIV,2BAA2B,CACnCO,aAAa,CAACG,KAAK,IAAI,uCAAuC,EAC9DH,aAAa,CAACI,IAAI,EAClBJ,aAAa,CAACK,MAAM,EACpBP,QAAQ,CAACQ,MACX,CAAC;EACH;EACA,OAAOR,QAAQ;AACjB,CAAC;AAED,OAAO,MAAMS,uBAAuB,GAAIC,OAGvC,IAAK;EACJ,MAAM;IAAEC,qBAAqB;IAAEC,QAAQ,GAAGC;EAAM,CAAC,GAAGH,OAAO;EAE3D,OAAOZ,6BAA6B,CAClC,CAACgB,MAAM,EAAEC,GAAG,EAAEC,MAAM,KAClBJ,QAAQ,CAACG,GAAG,EAAE;IACZD,MAAM;IACNG,IAAI,EAAED,MAAM,GAAGE,IAAI,CAACC,SAAS,CAACH,MAAM,CAACC,IAAI,CAAC,GAAGG,SAAS;IACtDC,OAAO,EAAE;MACP,cAAc,EAAE;IAClB;EACF,CAAC,CAAC,CACCC,IAAI,CAACvB,gBAAgB,CAAC,CACtBuB,IAAI,CAAEC,GAAG,IAAK;IACb,MAAMC,WAAW,GAAGD,GAAG,CAACF,OAAO,CAACI,GAAG,CAAC,cAAc,CAAC;IACnD,IAAID,WAAW,aAAXA,WAAW,eAAXA,WAAW,CAAEE,QAAQ,CAAC,kBAAkB,CAAC,EAAE;MAC7C,OAAOH,GAAG,CAACnB,IAAI,CAAC,CAAC;IACnB;IACA,OAAOmB,GAAG,CAACI,IAAI,CAAC,CAAC;EACnB,CAAC,CAAC,EACNhB,qBACF,CAAC;AACH,CAAC"}
|
@@ -1,8 +1,13 @@
|
|
1
1
|
import { AuthorizationErrorShape, AuthorizationResultShape } from "../../utils/auth";
|
2
|
-
import { until } from "../../utils/misc";
|
2
|
+
import { hasStatus, until } from "../../utils/misc";
|
3
3
|
import parseUrl from "parse-url";
|
4
|
-
import { AuthorizationError, AuthorizationIdpError } from "../../utils/errors";
|
4
|
+
import { AuthorizationError, AuthorizationIdpError, ValidationFailed } from "../../utils/errors";
|
5
5
|
import { Linking } from "react-native";
|
6
|
+
import { decode, encodeBase64, SignJWT } from "@pagopa/io-react-native-jwt";
|
7
|
+
import { RequestObject } from "../presentation/types";
|
8
|
+
import uuid from "react-native-uuid";
|
9
|
+
import { ResponseUriResultShape } from "./types";
|
10
|
+
import { getJwtFromFormPost } from "../../../src/utils/decoder";
|
6
11
|
|
7
12
|
/**
|
8
13
|
* The interface of the phase to complete User authorization via strong identification when the response mode is "query" and the request credential is a PersonIdentificationData.
|
@@ -26,11 +31,6 @@ import { Linking } from "react-native";
|
|
26
31
|
* @returns the authorization response which contains code, state and iss
|
27
32
|
*/
|
28
33
|
export const completeUserAuthorizationWithQueryMode = async (issuerRequestUri, clientId, issuerConf, idpHint, redirectUri, authorizationContext) => {
|
29
|
-
/**
|
30
|
-
* Starts the authorization flow which dependes on the response mode and the request credential.
|
31
|
-
* If the response mode is "query" the authorization flow is handled differently via the authorization context which opens an in-app browser capable of catching the redirectSchema.
|
32
|
-
* The form_post.jwt mode is not currently supported.
|
33
|
-
*/
|
34
34
|
const authzRequestEndpoint = issuerConf.oauth_authorization_server.authorization_endpoint;
|
35
35
|
const params = new URLSearchParams({
|
36
36
|
client_id: clientId,
|
@@ -66,21 +66,144 @@ export const completeUserAuthorizationWithQueryMode = async (issuerRequestUri, c
|
|
66
66
|
throw new AuthorizationError("Invalid authentication redirect url");
|
67
67
|
}
|
68
68
|
}
|
69
|
-
const
|
70
|
-
|
71
|
-
|
72
|
-
|
69
|
+
const query = parseUrl(authRedirectUrl).query;
|
70
|
+
return parseAuthroizationResponse(query);
|
71
|
+
};
|
72
|
+
|
73
|
+
/**
|
74
|
+
* WARNING: This function must be called after {@link startUserAuthorization}. The next function to be called is {@link completeUserAuthorizationWithFormPostJwtMode}.
|
75
|
+
* The interface of the phase to complete User authorization via presentation of existing credentials when the response mode is "form_post.jwt".
|
76
|
+
* It is used as a first step to complete the user authorization by obtaining the requested credential to be presented from the authorization server.
|
77
|
+
* The information is obtained by performing a GET request to the authorization endpoint with request_uri and client_id parameters.
|
78
|
+
* @param issuerRequestUri the URI of the issuer where the request is sent
|
79
|
+
* @param clientId Identifies the current client across all the requests of the issuing flow returned by {@link startUserAuthorization}
|
80
|
+
* @param issuerConf The issuer configuration returned by {@link evaluateIssuerTrust}
|
81
|
+
* @param appFetch (optional) fetch api implementation. Default: built-in fetch
|
82
|
+
* @throws {ValidationFailed} if an error while validating the response
|
83
|
+
* @returns the request object which contains the credential to be presented in order to obtain the requested credential
|
84
|
+
*/
|
85
|
+
export const getRequestedCredentialToBePresented = async function (issuerRequestUri, clientId, issuerConf) {
|
86
|
+
let appFetch = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : fetch;
|
87
|
+
const authzRequestEndpoint = issuerConf.oauth_authorization_server.authorization_endpoint;
|
88
|
+
const params = new URLSearchParams({
|
89
|
+
client_id: clientId,
|
90
|
+
request_uri: issuerRequestUri
|
91
|
+
});
|
92
|
+
const requestObject = await appFetch(`${authzRequestEndpoint}?${params.toString()}`, {
|
93
|
+
method: "GET"
|
94
|
+
}).then(hasStatus(200)).then(res => res.text()).then(jws => decode(jws)).then(reqObj => RequestObject.safeParse(reqObj.payload));
|
95
|
+
if (!requestObject.success) {
|
96
|
+
throw new ValidationFailed("Request Object validation failed", requestObject.error.message);
|
97
|
+
}
|
98
|
+
return requestObject.data;
|
99
|
+
};
|
100
|
+
|
101
|
+
/**
|
102
|
+
* WARNING: This function must be called after {@link startUserAuthorization}. The next function to be called is {@link completeUserAuthorizationWithFormPostJwtMode}.
|
103
|
+
* The interface of the phase to complete User authorization via presentation of existing credentials when the response mode is "form_post.jwt".
|
104
|
+
* It is used as a first step to complete the user authorization by obtaining the requested credential to be presented from the authorization server.
|
105
|
+
* The information is obtained by performing a GET request to the authorization endpoint with request_uri and client_id parameters.
|
106
|
+
* @param issuerRequestUri the URI of the issuer where the request is sent
|
107
|
+
* @param clientId Identifies the current client across all the requests of the issuing flow returned by {@link startUserAuthorization}
|
108
|
+
* @param issuerConf The issuer configuration returned by {@link evaluateIssuerTrust}
|
109
|
+
* @param context.walletInstanceAccestation the Wallet Instance's attestation to be presented
|
110
|
+
* @param context.pid the PID to be presented
|
111
|
+
* @param context.wiaCryptoContext The Wallet Instance's crypto context associated with the walletInstanceAttestation parameter
|
112
|
+
* @param context.pidCryptoContext The PID crypto context associated with the pid parameter
|
113
|
+
* @param context.appFetch (optional) fetch api implementation. Default: built-in fetch
|
114
|
+
* @throws {ValidationFailed} if an error while validating the response
|
115
|
+
* @returns the authorization response which contains code, state and iss
|
116
|
+
*/
|
117
|
+
export const completeUserAuthorizationWithFormPostJwtMode = async (requestObject, ctx) => {
|
118
|
+
const {
|
119
|
+
wiaCryptoContext,
|
120
|
+
pidCryptoContext,
|
121
|
+
pid,
|
122
|
+
walletInstanceAttestation,
|
123
|
+
appFetch = fetch
|
124
|
+
} = ctx;
|
125
|
+
const wiaWpToken = await new SignJWT(wiaCryptoContext).setProtectedHeader({
|
126
|
+
alg: "ES256",
|
127
|
+
typ: "JWT"
|
128
|
+
}).setPayload({
|
129
|
+
vp: walletInstanceAttestation,
|
130
|
+
jti: uuid.v4().toString(),
|
131
|
+
nonce: requestObject.nonce
|
132
|
+
}).setIssuedAt().setExpirationTime("5m").setAudience(requestObject.response_uri).sign();
|
133
|
+
const pidWpToken = await new SignJWT(pidCryptoContext).setProtectedHeader({
|
134
|
+
alg: "ES256",
|
135
|
+
typ: "JWT"
|
136
|
+
}).setPayload({
|
137
|
+
vp: pid,
|
138
|
+
jti: uuid.v4().toString(),
|
139
|
+
nonce: requestObject.nonce
|
140
|
+
}).setIssuedAt().setExpirationTime("5m").setAudience(requestObject.response_uri).sign();
|
141
|
+
|
142
|
+
/* The path parameter refers to the vp_token variable of the authzResponsePayload and must point to the plain credential which
|
143
|
+
* is cointaned in the `vp` property of the signed jwt token payload
|
144
|
+
*/
|
145
|
+
const presentationSubmission = {
|
146
|
+
definition_id: `${uuid.v4()}`,
|
147
|
+
id: `${uuid.v4()}`,
|
148
|
+
descriptor_map: [{
|
149
|
+
id: "PersonIdentificationData",
|
150
|
+
path: "$.vp_token[0].vp",
|
151
|
+
format: "vc+sd-jwt"
|
152
|
+
}, {
|
153
|
+
id: "WalletAttestation",
|
154
|
+
path: "$.vp_token[1].vp",
|
155
|
+
format: "jwt"
|
156
|
+
}]
|
157
|
+
};
|
158
|
+
const authzResponsePayload = encodeBase64(JSON.stringify({
|
159
|
+
state: requestObject.state,
|
160
|
+
presentation_submission: presentationSubmission,
|
161
|
+
vp_token: [pidWpToken, wiaWpToken]
|
162
|
+
}));
|
163
|
+
|
164
|
+
// Note: according to the spec, the response should be encrypted with the public key of the RP however this is not implemented yet
|
165
|
+
// https://openid.net/specs/openid-4-verifiable-presentations-1_0.html#name-signed-and-encrypted-response
|
166
|
+
// const rsaPublicJwk = chooseRSAPublicKeyToEncrypt(rpConf);
|
167
|
+
// const encrypted = await new EncryptJwe(authzResponsePayload, {
|
168
|
+
// alg: "RSA-OAEP-256",
|
169
|
+
// enc: "A256CBC-HS512",
|
170
|
+
// kid: rsaPublicJwk.kid,
|
171
|
+
// }).encrypt(rsaPublicJwk);
|
172
|
+
|
173
|
+
const body = new URLSearchParams({
|
174
|
+
response: authzResponsePayload
|
175
|
+
}).toString();
|
176
|
+
const resUriRes = await appFetch(requestObject.response_uri, {
|
177
|
+
method: "POST",
|
178
|
+
headers: {
|
179
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
180
|
+
},
|
181
|
+
body
|
182
|
+
}).then(hasStatus(200)).then(reqUri => reqUri.json());
|
183
|
+
const responseUri = ResponseUriResultShape.safeParse(resUriRes);
|
184
|
+
if (!responseUri.success) {
|
185
|
+
throw new ValidationFailed("Response Uri validation failed", responseUri.error.message);
|
186
|
+
}
|
187
|
+
return await appFetch(responseUri.data.redirect_uri).then(hasStatus(200)).then(res => res.text()).then(getJwtFromFormPost).then(cbRes => parseAuthroizationResponse(cbRes.decodedJwt.payload));
|
188
|
+
};
|
189
|
+
|
190
|
+
/**
|
191
|
+
* Parse the authorization response and return the result which contains code, state and iss.
|
192
|
+
* @throws {AuthorizationError} if an error occurs during the parsing process
|
193
|
+
* @throws {AuthorizationIdpError} if an error occurs during the parsing process and the error is related to the IDP
|
194
|
+
* @param authRes the authorization response to be parsed
|
195
|
+
* @returns the authorization result which contains code, state and iss
|
196
|
+
*/
|
197
|
+
export const parseAuthroizationResponse = authRes => {
|
198
|
+
const authResParsed = AuthorizationResultShape.safeParse(authRes);
|
199
|
+
if (!authResParsed.success) {
|
200
|
+
const authErr = AuthorizationErrorShape.safeParse(authRes);
|
73
201
|
if (!authErr.success) {
|
74
|
-
throw new AuthorizationError(
|
202
|
+
throw new AuthorizationError(authResParsed.error.message); // an error occured while parsing the result and the error
|
75
203
|
}
|
76
204
|
|
77
205
|
throw new AuthorizationIdpError(authErr.data.error, authErr.data.error_description);
|
78
206
|
}
|
79
|
-
return
|
80
|
-
};
|
81
|
-
|
82
|
-
// TODO: SIW-1120 implement generic credential issuance flow
|
83
|
-
export const completeUserAuthorizationWithFormPostJwtMode = () => {
|
84
|
-
throw new Error("Not implemented");
|
207
|
+
return authResParsed.data;
|
85
208
|
};
|
86
209
|
//# sourceMappingURL=04-complete-user-authorization.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["AuthorizationErrorShape","AuthorizationResultShape","until","parseUrl","AuthorizationError","AuthorizationIdpError","Linking","completeUserAuthorizationWithQueryMode","issuerRequestUri","clientId","issuerConf","idpHint","redirectUri","authorizationContext","authzRequestEndpoint","oauth_authorization_server","authorization_endpoint","params","URLSearchParams","client_id","request_uri","idphint","authUrl","authRedirectUrl","redirectSchema","URL","protocol","replace","authorize","catch","e","message","addEventListener","_ref","url","includes","openAuthUrlInBrowser","openURL","unitAuthRedirectIsNotUndefined","undefined","Promise","all","
|
1
|
+
{"version":3,"names":["AuthorizationErrorShape","AuthorizationResultShape","hasStatus","until","parseUrl","AuthorizationError","AuthorizationIdpError","ValidationFailed","Linking","decode","encodeBase64","SignJWT","RequestObject","uuid","ResponseUriResultShape","getJwtFromFormPost","completeUserAuthorizationWithQueryMode","issuerRequestUri","clientId","issuerConf","idpHint","redirectUri","authorizationContext","authzRequestEndpoint","oauth_authorization_server","authorization_endpoint","params","URLSearchParams","client_id","request_uri","idphint","authUrl","authRedirectUrl","redirectSchema","URL","protocol","replace","authorize","catch","e","message","addEventListener","_ref","url","includes","openAuthUrlInBrowser","openURL","unitAuthRedirectIsNotUndefined","undefined","Promise","all","query","parseAuthroizationResponse","getRequestedCredentialToBePresented","appFetch","arguments","length","fetch","requestObject","toString","method","then","res","text","jws","reqObj","safeParse","payload","success","error","data","completeUserAuthorizationWithFormPostJwtMode","ctx","wiaCryptoContext","pidCryptoContext","pid","walletInstanceAttestation","wiaWpToken","setProtectedHeader","alg","typ","setPayload","vp","jti","v4","nonce","setIssuedAt","setExpirationTime","setAudience","response_uri","sign","pidWpToken","presentationSubmission","definition_id","id","descriptor_map","path","format","authzResponsePayload","JSON","stringify","state","presentation_submission","vp_token","body","response","resUriRes","headers","reqUri","json","responseUri","redirect_uri","cbRes","decodedJwt","authRes","authResParsed","authErr","error_description"],"sourceRoot":"../../../../src","sources":["credential/issuance/04-complete-user-authorization.ts"],"mappings":"AAAA,SACEA,uBAAuB,EAC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AAC9C,KAAK,CAAC7B,OAAO,CAAC,CAAC,CAAC;IAC7D;;IACA,MAAM,IAAIlC,qBAAqB,CAC7B8G,OAAO,CAAC9C,IAAI,CAACD,KAAK,EAClB+C,OAAO,CAAC9C,IAAI,CAAC+C,iBACf,CAAC;EACH;EACA,OAAOF,aAAa,CAAC7C,IAAI;AAC3B,CAAC"}
|
@@ -6,11 +6,12 @@ import { verify as verifySdJwt } from "../../sd-jwt";
|
|
6
6
|
|
7
7
|
// handy alias
|
8
8
|
|
9
|
-
const parseCredentialSdJwt = (credentials_supported, _ref)
|
9
|
+
const parseCredentialSdJwt = function (credentials_supported, _ref) {
|
10
10
|
let {
|
11
11
|
sdJwt,
|
12
12
|
disclosures
|
13
13
|
} = _ref;
|
14
|
+
let ignoreMissingAttributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
14
15
|
const credentialSubject = credentials_supported[sdJwt.payload.vct];
|
15
16
|
if (!credentialSubject) {
|
16
17
|
throw new IoWalletError("Credential type not supported by the issuer");
|
@@ -20,6 +21,10 @@ const parseCredentialSdJwt = (credentials_supported, _ref) => {
|
|
20
21
|
}
|
21
22
|
|
22
23
|
// transfrom a record { key: value } in an iterable of pairs [key, value]
|
24
|
+
if (!credentialSubject.claims) {
|
25
|
+
throw new IoWalletError("Missing claims in the credential subject"); // TODO [SIW-1268]: should not be optional
|
26
|
+
}
|
27
|
+
|
23
28
|
const attrDefinitions = Object.entries(credentialSubject.claims);
|
24
29
|
|
25
30
|
// the key of the attribute defintion must match the disclosure's name
|
@@ -33,7 +38,9 @@ const parseCredentialSdJwt = (credentials_supported, _ref) => {
|
|
33
38
|
if (attrsNotInDisclosures.length > 0) {
|
34
39
|
const missing = attrsNotInDisclosures.map(_ => _[0 /* key */]).join(", ");
|
35
40
|
const received = disclosures.map(_ => _[1 /* name */]).join(", ");
|
36
|
-
|
41
|
+
if (!ignoreMissingAttributes) {
|
42
|
+
throw new IoWalletError(`Some attributes are missing in the credential. Missing: [${missing}], received: [${received}]`);
|
43
|
+
}
|
37
44
|
}
|
38
45
|
|
39
46
|
// attributes that are defined in the issuer configuration
|
@@ -117,10 +124,11 @@ async function verifyCredentialSdJwt(rawCredential, issuerKeys, holderBindingCon
|
|
117
124
|
|
118
125
|
const verifyAndParseCredentialSdJwt = async (issuerConf, credential, _, _ref8) => {
|
119
126
|
let {
|
120
|
-
credentialCryptoContext
|
127
|
+
credentialCryptoContext,
|
128
|
+
ignoreMissingAttributes
|
121
129
|
} = _ref8;
|
122
130
|
const decoded = await verifyCredentialSdJwt(credential, issuerConf.openid_credential_issuer.jwks.keys, credentialCryptoContext);
|
123
|
-
const parsedCredential = parseCredentialSdJwt(issuerConf.openid_credential_issuer.credential_configurations_supported, decoded);
|
131
|
+
const parsedCredential = parseCredentialSdJwt(issuerConf.openid_credential_issuer.credential_configurations_supported, decoded, ignoreMissingAttributes);
|
124
132
|
return {
|
125
133
|
parsedCredential
|
126
134
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["IoWalletError","SdJwt4VC","verify","verifySdJwt","parseCredentialSdJwt","credentials_supported","_ref","sdJwt","disclosures","credentialSubject","payload","vct","format","header","typ","attrDefinitions","Object","entries","
|
1
|
+
{"version":3,"names":["IoWalletError","SdJwt4VC","verify","verifySdJwt","parseCredentialSdJwt","credentials_supported","_ref","sdJwt","disclosures","ignoreMissingAttributes","arguments","length","undefined","credentialSubject","payload","vct","format","header","typ","claims","attrDefinitions","Object","entries","attrsNotInDisclosures","filter","_ref2","attrKey","some","_ref3","name","missing","map","_","join","received","definedValues","fromEntries","_ref4","_disclosures$find","definition","value","find","_ref5","display","reduce","names","_ref6","locale","undefinedValues","keys","includes","_ref7","key","verifyCredentialSdJwt","rawCredential","issuerKeys","holderBindingContext","decodedCredential","holderBindingKey","Promise","all","getPublicKey","cnf","jwk","kid","verifyAndParseCredentialSdJwt","issuerConf","credential","_ref8","credentialCryptoContext","decoded","openid_credential_issuer","jwks","parsedCredential","credential_configurations_supported","verifyAndParseCredential","context"],"sourceRoot":"../../../../src","sources":["credential/issuance/07-verify-and-parse-credential.ts"],"mappings":"AAEA,SAASA,aAAa,QAAQ,oBAAoB;AAClD,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,MAAM,IAAIC,WAAW,QAAQ,cAAc;;AAepD;;AAkBA;;AAKA,MAAMC,oBAAoB,GAAG,SAAAA,CAE3BC,qBAAgI,EAAAC,IAAA,EAG3G;EAAA,IAFrB;IAAEC,KAAK;IAAEC;EAAoC,CAAC,GAAAF,IAAA;EAAA,IAC9CG,uBAAgC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,KAAK;EAExC,MAAMG,iBAAiB,GAAGR,qBAAqB,CAACE,KAAK,CAACO,OAAO,CAACC,GAAG,CAAC;EAElE,IAAI,CAACF,iBAAiB,EAAE;IACtB,MAAM,IAAIb,aAAa,CAAC,6CAA6C,CAAC;EACxE;EAEA,IAAIa,iBAAiB,CAACG,MAAM,KAAKT,KAAK,CAACU,MAAM,CAACC,GAAG,EAAE;IACjD,MAAM,IAAIlB,aAAa,CACpB,gEAA+Da,iBAAiB,CAACG,MAAO,gBAAeT,KAAK,CAACU,MAAM,CAACC,GAAI,KAC3H,CAAC;EACH;;EAEA;EACA,IAAI,CAACL,iBAAiB,CAACM,MAAM,EAAE;IAC7B,MAAM,IAAInB,aAAa,CAAC,0CAA0C,CAAC,CAAC,CAAC;EACvE;;EACA,MAAMoB,eAAe,GAAGC,MAAM,CAACC,OAAO,CAACT,iBAAiB,CAACM,MAAM,CAAC;;EAEhE;EACA,MAAMI,qBAAqB,GAAGH,eAAe,CAACI,MAAM,CAClDC,KAAA;IAAA,IAAC,CAACC,OAAO,CAAC,GAAAD,KAAA;IAAA,OAAK,CAACjB,WAAW,CAACmB,IAAI,CAACC,KAAA;MAAA,IAAC,GAAGC,IAAI,CAAC,GAAAD,KAAA;MAAA,OAAKC,IAAI,KAAKH,OAAO;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CAACC,GAAG,CAACC,GAAI,EAC9H,CAAC;EACH;EAEA,OAAOP,iBAAiB;AAC1B;;AAEA;;AAQA,MAAMQ,6BAAsD,GAAG,MAAAA,CAC7DC,UAAU,EACVC,UAAU,EACVnC,CAAC,EAAAoC,KAAA,KAEE;EAAA,IADH;IAAEC,uBAAuB;IAAE5D;EAAwB,CAAC,GAAA2D,KAAA;EAEpD,MAAME,OAAO,GAAG,MAAMjB,qBAAqB,CACzCc,UAAU,EACVD,UAAU,CAACK,wBAAwB,CAACC,IAAI,CAACvB,IAAI,EAC7CoB,uBACF,CAAC;EAED,MAAMI,gBAAgB,GAAGrE,oBAAoB,CAC3C8D,UAAU,CAACK,wBAAwB,CAACG,mCAAmC,EACvEJ,OAAO,EACP7D,uBACF,CAAC;EAED,OAAO;IAAEgE;EAAiB,CAAC;AAC7B,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAME,wBAAkD,GAAG,MAAAA,CAChET,UAAU,EACVC,UAAU,EACVnD,MAAM,EACN4D,OAAO,KACJ;EACH,IAAI5D,MAAM,KAAK,WAAW,EAAE;IAC1B,OAAOiD,6BAA6B,CAClCC,UAAU,EACVC,UAAU,EACVnD,MAAM,EACN4D,OACF,CAAC;EACH;EAEA,MAAM,IAAI5E,aAAa,CAAE,kCAAiCgB,MAAO,EAAC,CAAC;AACrE,CAAC"}
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import { evaluateIssuerTrust } from "./02-evaluate-issuer-trust";
|
2
2
|
import { startUserAuthorization } from "./03-start-user-authorization";
|
3
|
-
import { completeUserAuthorizationWithQueryMode } from "./04-complete-user-authorization";
|
3
|
+
import { completeUserAuthorizationWithQueryMode, completeUserAuthorizationWithFormPostJwtMode, parseAuthroizationResponse, getRequestedCredentialToBePresented } from "./04-complete-user-authorization";
|
4
4
|
import { authorizeAccess } from "./05-authorize-access";
|
5
5
|
import { obtainCredential } from "./06-obtain-credential";
|
6
6
|
import { verifyAndParseCredential } from "./07-verify-and-parse-credential";
|
7
|
-
export { evaluateIssuerTrust, startUserAuthorization, completeUserAuthorizationWithQueryMode, authorizeAccess, obtainCredential, verifyAndParseCredential };
|
7
|
+
export { evaluateIssuerTrust, startUserAuthorization, completeUserAuthorizationWithQueryMode, getRequestedCredentialToBePresented, completeUserAuthorizationWithFormPostJwtMode, authorizeAccess, obtainCredential, verifyAndParseCredential, parseAuthroizationResponse };
|
8
8
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["evaluateIssuerTrust","startUserAuthorization","completeUserAuthorizationWithQueryMode","authorizeAccess","obtainCredential","verifyAndParseCredential"],"sourceRoot":"../../../../src","sources":["credential/issuance/index.ts"],"mappings":"AACA,SACEA,mBAAmB,QAEd,4BAA4B;AACnC,SACEC,sBAAsB,QAEjB,+BAA+B;AACtC,SACEC,sCAAsC,
|
1
|
+
{"version":3,"names":["evaluateIssuerTrust","startUserAuthorization","completeUserAuthorizationWithQueryMode","completeUserAuthorizationWithFormPostJwtMode","parseAuthroizationResponse","getRequestedCredentialToBePresented","authorizeAccess","obtainCredential","verifyAndParseCredential"],"sourceRoot":"../../../../src","sources":["credential/issuance/index.ts"],"mappings":"AACA,SACEA,mBAAmB,QAEd,4BAA4B;AACnC,SACEC,sBAAsB,QAEjB,+BAA+B;AACtC,SACEC,sCAAsC,EACtCC,4CAA4C,EAC5CC,0BAA0B,EAI1BC,mCAAmC,QAC9B,kCAAkC;AACzC,SAASC,eAAe,QAA8B,uBAAuB;AAC7E,SACEC,gBAAgB,QAEX,wBAAwB;AAC/B,SACEC,wBAAwB,QAEnB,kCAAkC;AAEzC,SACER,mBAAmB,EACnBC,sBAAsB,EACtBC,sCAAsC,EACtCG,mCAAmC,EACnCF,4CAA4C,EAC5CG,eAAe,EACfC,gBAAgB,EAChBC,wBAAwB,EACxBJ,0BAA0B"}
|
@@ -15,4 +15,11 @@ export const CredentialResponse = z.object({
|
|
15
15
|
credential: z.string(),
|
16
16
|
format: SupportedCredentialFormat
|
17
17
|
});
|
18
|
+
|
19
|
+
/**
|
20
|
+
* Shape from parsing a response given by a request uri during the EAA credential issuance flow with response mode "form_post.jwt".
|
21
|
+
*/
|
22
|
+
export const ResponseUriResultShape = z.object({
|
23
|
+
redirect_uri: z.string()
|
24
|
+
});
|
18
25
|
//# sourceMappingURL=types.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["AuthorizationDetail","z","SupportedCredentialFormat","TokenResponse","object","access_token","string","authorization_details","array","c_nonce","c_nonce_expires_in","number","expires_in","token_type","CredentialResponse","credential","format"],"sourceRoot":"../../../../src","sources":["credential/issuance/types.ts"],"mappings":"AAAA,SAASA,mBAAmB,QAAQ,iBAAiB;AACrD,OAAO,KAAKC,CAAC,MAAM,KAAK;AACxB,SAASC,yBAAyB,QAAQ,SAAS;AAInD,OAAO,MAAMC,aAAa,GAAGF,CAAC,CAACG,MAAM,CAAC;EACpCC,YAAY,EAAEJ,CAAC,CAACK,MAAM,CAAC,CAAC;EACxBC,qBAAqB,EAAEN,CAAC,CAACO,KAAK,CAACR,mBAAmB,CAAC;EACnDS,OAAO,EAAER,CAAC,CAACK,MAAM,CAAC,CAAC;EACnBI,kBAAkB,EAAET,CAAC,CAACU,MAAM,CAAC,CAAC;EAC9BC,UAAU,EAAEX,CAAC,CAACU,MAAM,CAAC,CAAC;EACtBE,UAAU,EAAEZ,CAAC,CAACK,MAAM,CAAC;AACvB,CAAC,CAAC;AAIF,OAAO,MAAMQ,kBAAkB,GAAGb,CAAC,CAACG,MAAM,CAAC;EACzCK,OAAO,EAAER,CAAC,CAACK,MAAM,CAAC,CAAC;EACnBI,kBAAkB,EAAET,CAAC,CAACU,MAAM,CAAC,CAAC;EAC9BI,UAAU,EAAEd,CAAC,CAACK,MAAM,CAAC,CAAC;EACtBU,MAAM,EAAEd;AACV,CAAC,CAAC"}
|
1
|
+
{"version":3,"names":["AuthorizationDetail","z","SupportedCredentialFormat","TokenResponse","object","access_token","string","authorization_details","array","c_nonce","c_nonce_expires_in","number","expires_in","token_type","CredentialResponse","credential","format","ResponseUriResultShape","redirect_uri"],"sourceRoot":"../../../../src","sources":["credential/issuance/types.ts"],"mappings":"AAAA,SAASA,mBAAmB,QAAQ,iBAAiB;AACrD,OAAO,KAAKC,CAAC,MAAM,KAAK;AACxB,SAASC,yBAAyB,QAAQ,SAAS;AAInD,OAAO,MAAMC,aAAa,GAAGF,CAAC,CAACG,MAAM,CAAC;EACpCC,YAAY,EAAEJ,CAAC,CAACK,MAAM,CAAC,CAAC;EACxBC,qBAAqB,EAAEN,CAAC,CAACO,KAAK,CAACR,mBAAmB,CAAC;EACnDS,OAAO,EAAER,CAAC,CAACK,MAAM,CAAC,CAAC;EACnBI,kBAAkB,EAAET,CAAC,CAACU,MAAM,CAAC,CAAC;EAC9BC,UAAU,EAAEX,CAAC,CAACU,MAAM,CAAC,CAAC;EACtBE,UAAU,EAAEZ,CAAC,CAACK,MAAM,CAAC;AACvB,CAAC,CAAC;AAIF,OAAO,MAAMQ,kBAAkB,GAAGb,CAAC,CAACG,MAAM,CAAC;EACzCK,OAAO,EAAER,CAAC,CAACK,MAAM,CAAC,CAAC;EACnBI,kBAAkB,EAAET,CAAC,CAACU,MAAM,CAAC,CAAC;EAC9BI,UAAU,EAAEd,CAAC,CAACK,MAAM,CAAC,CAAC;EACtBU,MAAM,EAAEd;AACV,CAAC,CAAC;;AAEF;AACA;AACA;AACA,OAAO,MAAMe,sBAAsB,GAAGhB,CAAC,CAACG,MAAM,CAAC;EAC7Cc,YAAY,EAAEjB,CAAC,CAACK,MAAM,CAAC;AACzB,CAAC,CAAC"}
|
package/lib/module/index.js
CHANGED
@@ -9,7 +9,8 @@ import * as Errors from "./utils/errors";
|
|
9
9
|
import * as WalletInstanceAttestation from "./wallet-instance-attestation";
|
10
10
|
import * as Trust from "./trust";
|
11
11
|
import * as WalletInstance from "./wallet-instance";
|
12
|
+
import * as Cie from "./cie";
|
12
13
|
import { AuthorizationDetail, AuthorizationDetails } from "./utils/par";
|
13
14
|
import { createCryptoContextFor } from "./utils/crypto";
|
14
|
-
export { SdJwt, PID, Credential, WalletInstanceAttestation, WalletInstance, Errors, Trust, createCryptoContextFor, AuthorizationDetail, AuthorizationDetails, fixBase64EncodingOnKey };
|
15
|
+
export { SdJwt, PID, Credential, WalletInstanceAttestation, WalletInstance, Errors, Trust, createCryptoContextFor, AuthorizationDetail, AuthorizationDetails, fixBase64EncodingOnKey, Cie };
|
15
16
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["fixBase64EncodingOnKey","Credential","PID","SdJwt","Errors","WalletInstanceAttestation","Trust","WalletInstance","AuthorizationDetail","AuthorizationDetails","createCryptoContextFor"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AACA,SAASA,sBAAsB,QAAQ,aAAa;AACpD;AACA;AACA,OAAO,gCAAgC;AAEvC,OAAO,KAAKC,UAAU,MAAM,cAAc;AAC1C,OAAO,KAAKC,GAAG,MAAM,OAAO;AAC5B,OAAO,KAAKC,KAAK,MAAM,UAAU;AACjC,OAAO,KAAKC,MAAM,MAAM,gBAAgB;AACxC,OAAO,KAAKC,yBAAyB,MAAM,+BAA+B;AAC1E,OAAO,KAAKC,KAAK,MAAM,SAAS;AAChC,OAAO,KAAKC,cAAc,MAAM,mBAAmB;AACnD,SAASC,mBAAmB,EAAEC,oBAAoB,QAAQ,aAAa;AACvE,SAASC,sBAAsB,QAAQ,gBAAgB;AAGvD,
|
1
|
+
{"version":3,"names":["fixBase64EncodingOnKey","Credential","PID","SdJwt","Errors","WalletInstanceAttestation","Trust","WalletInstance","Cie","AuthorizationDetail","AuthorizationDetails","createCryptoContextFor"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AACA,SAASA,sBAAsB,QAAQ,aAAa;AACpD;AACA;AACA,OAAO,gCAAgC;AAEvC,OAAO,KAAKC,UAAU,MAAM,cAAc;AAC1C,OAAO,KAAKC,GAAG,MAAM,OAAO;AAC5B,OAAO,KAAKC,KAAK,MAAM,UAAU;AACjC,OAAO,KAAKC,MAAM,MAAM,gBAAgB;AACxC,OAAO,KAAKC,yBAAyB,MAAM,+BAA+B;AAC1E,OAAO,KAAKC,KAAK,MAAM,SAAS;AAChC,OAAO,KAAKC,cAAc,MAAM,mBAAmB;AACnD,OAAO,KAAKC,GAAG,MAAM,OAAO;AAC5B,SAASC,mBAAmB,EAAEC,oBAAoB,QAAQ,aAAa;AACvE,SAASC,sBAAsB,QAAQ,gBAAgB;AAGvD,SACER,KAAK,EACLD,GAAG,EACHD,UAAU,EACVI,yBAAyB,EACzBE,cAAc,EACdH,MAAM,EACNE,KAAK,EACLK,sBAAsB,EACtBF,mBAAmB,EACnBC,oBAAoB,EACpBV,sBAAsB,EACtBQ,GAAG"}
|
@@ -39,8 +39,9 @@ const CredentialIssuerDisplayMetadata = z.object({
|
|
39
39
|
logo: z.object({
|
40
40
|
url: z.string(),
|
41
41
|
alt_text: z.string()
|
42
|
-
})
|
42
|
+
}).optional() // TODO [SIW-1268]: should not be optional
|
43
43
|
});
|
44
|
+
|
44
45
|
const ClaimsMetadata = z.record(z.object({
|
45
46
|
value_type: z.string(),
|
46
47
|
display: z.array(z.object({
|
@@ -55,7 +56,8 @@ const SupportedCredentialMetadata = z.object({
|
|
55
56
|
format: z.union([z.literal("vc+sd-jwt"), z.literal("vc+mdoc-cbor")]),
|
56
57
|
scope: z.string(),
|
57
58
|
display: z.array(CredentialDisplayMetadata),
|
58
|
-
claims: ClaimsMetadata,
|
59
|
+
claims: ClaimsMetadata.optional(),
|
60
|
+
// TODO [SIW-1268]: should not be optional
|
59
61
|
cryptographic_binding_methods_supported: z.array(z.string()),
|
60
62
|
credential_signing_alg_values_supported: z.array(z.string())
|
61
63
|
});
|
@@ -174,7 +176,7 @@ export const CredentialIssuerEntityConfiguration = BaseEntityConfiguration.and(z
|
|
174
176
|
/** Credential Issuers act as Relying Party
|
175
177
|
when they require the presentation of other credentials.
|
176
178
|
This does not apply for PID issuance, which requires CIE authz. */
|
177
|
-
|
179
|
+
wallet_relying_party: RelyingPartyMetadata.optional()
|
178
180
|
})
|
179
181
|
})
|
180
182
|
}));
|