@pagopa/io-react-native-wallet 2.0.0-next.4 → 2.0.0-next.5
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/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js +3 -3
- package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
- package/lib/commonjs/credential/status/{02-status-attestation.js → 02-status-assertion.js} +28 -22
- package/lib/commonjs/credential/status/02-status-assertion.js.map +1 -0
- package/lib/commonjs/credential/status/03-verify-and-parse-status-assertion.js +85 -0
- package/lib/commonjs/credential/status/03-verify-and-parse-status-assertion.js.map +1 -0
- package/lib/commonjs/credential/status/README.md +22 -20
- package/lib/commonjs/credential/status/index.js +6 -6
- package/lib/commonjs/credential/status/index.js.map +1 -1
- package/lib/commonjs/credential/status/types.js +48 -15
- package/lib/commonjs/credential/status/types.js.map +1 -1
- package/lib/commonjs/utils/credentials.js +33 -0
- package/lib/commonjs/utils/credentials.js.map +1 -0
- package/lib/commonjs/utils/crypto.js +1 -7
- package/lib/commonjs/utils/crypto.js.map +1 -1
- package/lib/commonjs/utils/jwk.js +12 -0
- package/lib/commonjs/utils/jwk.js.map +1 -1
- package/lib/module/credential/issuance/07-verify-and-parse-credential.js +4 -4
- package/lib/module/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
- package/lib/module/credential/status/{02-status-attestation.js → 02-status-assertion.js} +28 -22
- package/lib/module/credential/status/02-status-assertion.js.map +1 -0
- package/lib/module/credential/status/03-verify-and-parse-status-assertion.js +78 -0
- package/lib/module/credential/status/03-verify-and-parse-status-assertion.js.map +1 -0
- package/lib/module/credential/status/README.md +22 -20
- package/lib/module/credential/status/index.js +3 -3
- package/lib/module/credential/status/index.js.map +1 -1
- package/lib/module/credential/status/types.js +43 -12
- package/lib/module/credential/status/types.js.map +1 -1
- package/lib/module/utils/credentials.js +26 -0
- package/lib/module/utils/credentials.js.map +1 -0
- package/lib/module/utils/crypto.js +2 -8
- package/lib/module/utils/crypto.js.map +1 -1
- package/lib/module/utils/jwk.js +11 -1
- package/lib/module/utils/jwk.js.map +1 -1
- package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts.map +1 -1
- package/lib/typescript/credential/status/02-status-assertion.d.ts +23 -0
- package/lib/typescript/credential/status/02-status-assertion.d.ts.map +1 -0
- package/lib/typescript/credential/status/03-verify-and-parse-status-assertion.d.ts +21 -0
- package/lib/typescript/credential/status/03-verify-and-parse-status-assertion.d.ts.map +1 -0
- package/lib/typescript/credential/status/index.d.ts +4 -4
- package/lib/typescript/credential/status/index.d.ts.map +1 -1
- package/lib/typescript/credential/status/types.d.ts +495 -18
- package/lib/typescript/credential/status/types.d.ts.map +1 -1
- package/lib/typescript/utils/credentials.d.ts +11 -0
- package/lib/typescript/utils/credentials.d.ts.map +1 -0
- package/lib/typescript/utils/crypto.d.ts.map +1 -1
- package/lib/typescript/utils/jwk.d.ts +7 -0
- package/lib/typescript/utils/jwk.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/credential/issuance/07-verify-and-parse-credential.ts +4 -6
- package/src/credential/status/{02-status-attestation.ts → 02-status-assertion.ts} +37 -28
- package/src/credential/status/03-verify-and-parse-status-assertion.ts +109 -0
- package/src/credential/status/README.md +22 -20
- package/src/credential/status/index.ts +7 -14
- package/src/credential/status/types.ts +62 -15
- package/src/utils/credentials.ts +29 -0
- package/src/utils/crypto.ts +12 -20
- package/src/utils/jwk.ts +15 -1
- package/lib/commonjs/credential/status/02-status-attestation.js.map +0 -1
- package/lib/commonjs/credential/status/03-verify-and-parse-status-attestation.js +0 -55
- package/lib/commonjs/credential/status/03-verify-and-parse-status-attestation.js.map +0 -1
- package/lib/module/credential/status/02-status-attestation.js.map +0 -1
- package/lib/module/credential/status/03-verify-and-parse-status-attestation.js +0 -49
- package/lib/module/credential/status/03-verify-and-parse-status-attestation.js.map +0 -1
- package/lib/typescript/credential/status/02-status-attestation.d.ts +0 -19
- package/lib/typescript/credential/status/02-status-attestation.d.ts.map +0 -1
- package/lib/typescript/credential/status/03-verify-and-parse-status-attestation.d.ts +0 -24
- package/lib/typescript/credential/status/03-verify-and-parse-status-attestation.d.ts.map +0 -1
- package/src/credential/status/03-verify-and-parse-status-attestation.ts +0 -70
@@ -1,8 +1,8 @@
|
|
1
1
|
import { IoWalletError } from "../../utils/errors";
|
2
|
-
import { SdJwt4VC } from "../../sd-jwt
|
3
|
-
import { verify as verifySdJwt } from "../../sd-jwt";
|
2
|
+
import { SdJwt4VC, verify as verifySdJwt } from "../../sd-jwt";
|
4
3
|
import { getValueFromDisclosures } from "../../sd-jwt/converters";
|
5
|
-
import {
|
4
|
+
import { isSameThumbprint } from "../../utils/jwk";
|
5
|
+
import { Logger, LogLevel } from "../../utils/logging";
|
6
6
|
|
7
7
|
// The credential as a collection of attributes in plain value
|
8
8
|
|
@@ -120,7 +120,7 @@ async function verifyCredentialSdJwt(rawCredential, issuerKeys, holderBindingCon
|
|
120
120
|
const {
|
121
121
|
cnf
|
122
122
|
} = decodedCredential.sdJwt.payload;
|
123
|
-
if (!
|
123
|
+
if (!(await isSameThumbprint(cnf.jwk, holderBindingKey))) {
|
124
124
|
const message = `Failed to verify holder binding, expected kid: ${holderBindingKey.kid}, got: ${decodedCredential.sdJwt.payload.cnf.jwk.kid}`;
|
125
125
|
Logger.log(LogLevel.ERROR, message);
|
126
126
|
throw new IoWalletError(message);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["IoWalletError","SdJwt4VC","verify","verifySdJwt","getValueFromDisclosures","
|
1
|
+
{"version":3,"names":["IoWalletError","SdJwt4VC","verify","verifySdJwt","getValueFromDisclosures","isSameThumbprint","Logger","LogLevel","parseCredentialSdJwt","credentialConfig","_ref","sdJwt","disclosures","ignoreMissingAttributes","arguments","length","undefined","includeUndefinedAttributes","format","header","typ","message","log","ERROR","claims","attrDefinitions","attrsNotInDisclosures","filter","definition","some","_ref2","name","path","missing","map","_","join","received","definedValues","Object","fromEntries","_ref3","_disclosures$find","value","find","_ref4","attrKey","display","reduce","names","_ref5","locale","undefinedValues","keys","includes","_ref6","key","verifyCredentialSdJwt","rawCredential","issuerKeys","holderBindingContext","decodedCredential","holderBindingKey","Promise","all","getPublicKey","cnf","payload","jwk","kid","verifyAndParseCredentialSdJwt","issuerConf","credential","credentialConfigurationId","_ref7","credentialCryptoContext","decoded","openid_credential_issuer","jwks","DEBUG","JSON","stringify","credential_configurations_supported","parsedCredential","maybeIssuedAt","expiration","Date","exp","issuedAt","verifyAndParseCredential","context","_issuerConf$openid_cr"],"sourceRoot":"../../../../src","sources":["credential/issuance/07-verify-and-parse-credential.ts"],"mappings":"AAGA,SAASA,aAAa,QAAQ,oBAAoB;AAClD,SAASC,QAAQ,EAAEC,MAAM,IAAIC,WAAW,QAAQ,cAAc;AAC9D,SAASC,uBAAuB,QAAQ,yBAAyB;AACjE,SAASC,gBAAgB,QAAkB,iBAAiB;AAE5D,SAASC,MAAM,EAAEC,QAAQ,QAAQ,qBAAqB;;AA2BtD;;AAkBA;;AAKA,MAAMC,oBAAoB,GAAG,SAAAA,CAE3BC,gBAAgC,EAAAC,IAAA,EAIX;EAAA,IAHrB;IAAEC,KAAK;IAAEC;EAAoC,CAAC,GAAAF,IAAA;EAAA,IAC9CG,uBAAgC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,KAAK;EAAA,IACxCG,0BAAmC,GAAAH,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,KAAK;EAE3C,IAAIL,gBAAgB,CAACS,MAAM,KAAKP,KAAK,CAACQ,MAAM,CAACC,GAAG,EAAE;IAChD,MAAMC,OAAO,GAAI,gEAA+DZ,gBAAgB,CAACS,MAAO,gBAAeP,KAAK,CAACQ,MAAM,CAACC,GAAI,GAAE;IAC1Id,MAAM,CAACgB,GAAG,CAACf,QAAQ,CAACgB,KAAK,EAAEF,OAAO,CAAC;IACnC,M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M,KAAK,WAAW,EAAE;IAC1BZ,MAAM,CAACgB,GAAG,CAACf,QAAQ,CAACwE,KAAK,EAAE,wCAAwC,CAAC;IACpE,OAAOT,6BAA6B,CAClCC,UAAU,EACVC,UAAU,EACVC,yBAAyB,EACzBiB,OACF,CAAC;EACH;EAEA,MAAMrE,OAAO,GAAI,kCAAiCH,MAAO,EAAC;EAC1DZ,MAAM,CAACgB,GAAG,CAACf,QAAQ,CAACgB,KAAK,EAAEF,OAAO,CAAC;EACnC,MAAM,IAAIrB,aAAa,CAACqB,OAAO,CAAC;AAClC,CAAC"}
|
@@ -1,36 +1,44 @@
|
|
1
1
|
import { getCredentialHashWithouDiscloures, hasStatusOrThrow } from "../../utils/misc";
|
2
2
|
import { SignJWT } from "@pagopa/io-react-native-jwt";
|
3
3
|
import { v4 as uuidv4 } from "uuid";
|
4
|
-
import {
|
4
|
+
import { StatusAssertionResponse } from "./types";
|
5
5
|
import { IssuerResponseError, IssuerResponseErrorCodes, ResponseErrorBuilder, UnexpectedStatusCodeError } from "../../utils/errors";
|
6
|
-
import {
|
6
|
+
import { Logger, LogLevel } from "../../utils/logging";
|
7
|
+
import { extractJwkFromCredential } from "../../utils/credentials";
|
7
8
|
/**
|
8
|
-
*
|
9
|
-
* Verify the status of the credential attestation.
|
9
|
+
* Get the status assertion of a digital credential.
|
10
10
|
* @param issuerConf - The issuer's configuration
|
11
11
|
* @param credential - The credential to be verified
|
12
|
-
* @param
|
12
|
+
* @param format - The format of the credential, e.g. "sd-jwt"
|
13
|
+
* @param context.credentialCryptoContext - The credential's crypto context
|
14
|
+
* @param context.wiaCryptoContext - The Wallet Attestation's crypto context
|
13
15
|
* @param context.appFetch (optional) fetch api implementation. Default: built-in fetch
|
14
16
|
* @throws {IssuerResponseError} with a specific code for more context
|
15
|
-
* @returns The credential status
|
17
|
+
* @returns The credential status assertion
|
16
18
|
*/
|
17
|
-
export const
|
18
|
-
|
19
|
-
|
19
|
+
export const statusAssertion = async (issuerConf, credential, format, ctx) => {
|
20
|
+
const {
|
21
|
+
credentialCryptoContext,
|
22
|
+
wiaCryptoContext,
|
23
|
+
appFetch = fetch
|
24
|
+
} = ctx;
|
25
|
+
const jwk = await extractJwkFromCredential(credential, format);
|
26
|
+
const issuerJwk = await wiaCryptoContext.getPublicKey();
|
20
27
|
const credentialHash = await getCredentialHashWithouDiscloures(credential);
|
21
28
|
const statusAttUrl = issuerConf.openid_credential_issuer.status_attestation_endpoint;
|
22
29
|
const credentialPop = await new SignJWT(credentialCryptoContext).setPayload({
|
30
|
+
iss: issuerJwk.kid,
|
23
31
|
aud: statusAttUrl,
|
24
32
|
jti: uuidv4().toString(),
|
25
33
|
credential_hash: credentialHash,
|
26
|
-
credential_hash_alg: "
|
34
|
+
credential_hash_alg: "sha-256"
|
27
35
|
}).setProtectedHeader({
|
28
36
|
alg: "ES256",
|
29
|
-
typ: "status-
|
37
|
+
typ: "status-assertion-request+jwt",
|
30
38
|
kid: jwk.kid
|
31
39
|
}).setIssuedAt().setExpirationTime("5m").sign();
|
32
40
|
const body = {
|
33
|
-
|
41
|
+
status_assertion_requests: [credentialPop]
|
34
42
|
};
|
35
43
|
Logger.log(LogLevel.DEBUG, `Credential pop: ${credentialPop}`);
|
36
44
|
const result = await appFetch(statusAttUrl, {
|
@@ -39,28 +47,26 @@ export const statusAttestation = async function (issuerConf, credential, credent
|
|
39
47
|
"Content-Type": "application/json"
|
40
48
|
},
|
41
49
|
body: JSON.stringify(body)
|
42
|
-
}).then(hasStatusOrThrow(
|
50
|
+
}).then(hasStatusOrThrow(200)).then(raw => raw.json()).then(json => StatusAssertionResponse.parse(json)).catch(handleStatusAssertionError);
|
51
|
+
const [statusAttestationJwt] = result.status_assertion_responses;
|
43
52
|
return {
|
44
|
-
|
53
|
+
statusAssertion: statusAttestationJwt
|
45
54
|
};
|
46
55
|
};
|
47
56
|
|
48
57
|
/**
|
49
|
-
* Handle the status
|
58
|
+
* Handle the status assertion error by mapping it to a custom exception.
|
50
59
|
* If the error is not an instance of {@link UnexpectedStatusCodeError}, it is thrown as is.
|
51
60
|
* @param e - The error to be handled
|
52
61
|
* @throws {IssuerResponseError} with a specific code for more context
|
53
62
|
*/
|
54
|
-
const
|
63
|
+
const handleStatusAssertionError = e => {
|
55
64
|
if (!(e instanceof UnexpectedStatusCodeError)) {
|
56
65
|
throw e;
|
57
66
|
}
|
58
|
-
throw new ResponseErrorBuilder(IssuerResponseError).handle(
|
59
|
-
code: IssuerResponseErrorCodes.CredentialInvalidStatus,
|
60
|
-
message: "Invalid status found for the given credential"
|
61
|
-
}).handle("*", {
|
67
|
+
throw new ResponseErrorBuilder(IssuerResponseError).handle("*", {
|
62
68
|
code: IssuerResponseErrorCodes.StatusAttestationRequestFailed,
|
63
|
-
message: `Unable to obtain the status
|
69
|
+
message: `Unable to obtain the status assertion for the given credential`
|
64
70
|
}).buildFrom(e);
|
65
71
|
};
|
66
|
-
//# sourceMappingURL=02-status-
|
72
|
+
//# sourceMappingURL=02-status-assertion.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["getCredentialHashWithouDiscloures","hasStatusOrThrow","SignJWT","v4","uuidv4","StatusAssertionResponse","IssuerResponseError","IssuerResponseErrorCodes","ResponseErrorBuilder","UnexpectedStatusCodeError","Logger","LogLevel","extractJwkFromCredential","statusAssertion","issuerConf","credential","format","ctx","credentialCryptoContext","wiaCryptoContext","appFetch","fetch","jwk","issuerJwk","getPublicKey","credentialHash","statusAttUrl","openid_credential_issuer","status_attestation_endpoint","credentialPop","setPayload","iss","kid","aud","jti","toString","credential_hash","credential_hash_alg","setProtectedHeader","alg","typ","setIssuedAt","setExpirationTime","sign","body","status_assertion_requests","log","DEBUG","result","method","headers","JSON","stringify","then","raw","json","parse","catch","handleStatusAssertionError","statusAttestationJwt","status_assertion_responses","e","handle","code","StatusAttestationRequestFailed","message","buildFrom"],"sourceRoot":"../../../../src","sources":["credential/status/02-status-assertion.ts"],"mappings":"AAAA,SACEA,iCAAiC,EACjCC,gB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ors";
|
2
|
+
import { decode as decodeJwt, verify } from "@pagopa/io-react-native-jwt";
|
3
|
+
import { ParsedStatusAssertionResponse, StatusType } from "./types";
|
4
|
+
import { Logger, LogLevel } from "../../utils/logging";
|
5
|
+
import { extractJwkFromCredential } from "../../utils/credentials";
|
6
|
+
import { isSameThumbprint } from "../../utils/jwk";
|
7
|
+
/**
|
8
|
+
* Given a status assertion, verifies that:
|
9
|
+
* - It's in the supported format;
|
10
|
+
* - The assertion is correctly signed;
|
11
|
+
* - It's bound to the given key.
|
12
|
+
* @param issuerConf The Issuer configuration returned by {@link evaluateIssuerTrust}
|
13
|
+
* @param statusAssertion The encoded status assertion returned by {@link statusAssertion}
|
14
|
+
* @param context.credentialCryptoContext The crypto context used to obtain the credential in {@link obtainCredential}
|
15
|
+
* @returns A parsed status assertion
|
16
|
+
* @throws {IoWalletError} If the credential signature is not verified with the Issuer key set
|
17
|
+
* @throws {IssuerResponseError} If the status assertion contains an error or the credential status is invalid
|
18
|
+
*/
|
19
|
+
export const verifyAndParseStatusAssertion = async (issuerConf, rawStatusAssertion, credential, format) => {
|
20
|
+
const {
|
21
|
+
statusAssertion
|
22
|
+
} = rawStatusAssertion;
|
23
|
+
await verify(statusAssertion, issuerConf.openid_credential_issuer.jwks.keys);
|
24
|
+
const decodedJwt = decodeJwt(statusAssertion);
|
25
|
+
const parsedStatusAssertion = ParsedStatusAssertionResponse.parse({
|
26
|
+
header: decodedJwt.protectedHeader,
|
27
|
+
payload: decodedJwt.payload
|
28
|
+
});
|
29
|
+
Logger.log(LogLevel.DEBUG, `Parsed status assertion: ${JSON.stringify(parsedStatusAssertion)}`);
|
30
|
+
|
31
|
+
// Errors are transmitted in the JWT and use a 200 HTTP status code
|
32
|
+
if (isStatusAssertionError(parsedStatusAssertion)) {
|
33
|
+
throw new IssuerResponseError({
|
34
|
+
code: IssuerResponseErrorCodes.CredentialInvalidStatus,
|
35
|
+
message: "The status assertion contains an error",
|
36
|
+
statusCode: 200,
|
37
|
+
reason: buildErrorReason(parsedStatusAssertion)
|
38
|
+
});
|
39
|
+
}
|
40
|
+
const {
|
41
|
+
cnf,
|
42
|
+
credential_status_type
|
43
|
+
} = parsedStatusAssertion.payload;
|
44
|
+
const holderBindingKey = await extractJwkFromCredential(credential, format);
|
45
|
+
if (!(await isSameThumbprint(cnf.jwk, holderBindingKey))) {
|
46
|
+
const errorMessage = `Failed to verify holder binding for status assertion: the thumbprints of keys ${cnf.jwk.kid} and ${holderBindingKey.kid} do not match`;
|
47
|
+
Logger.log(LogLevel.ERROR, errorMessage);
|
48
|
+
throw new IoWalletError(errorMessage);
|
49
|
+
}
|
50
|
+
if (credential_status_type !== StatusType.VALID) {
|
51
|
+
throw new IssuerResponseError({
|
52
|
+
code: IssuerResponseErrorCodes.CredentialInvalidStatus,
|
53
|
+
message: "Invalid status found for the given credential",
|
54
|
+
statusCode: 200,
|
55
|
+
reason: buildErrorReason(parsedStatusAssertion)
|
56
|
+
});
|
57
|
+
}
|
58
|
+
return {
|
59
|
+
parsedStatusAssertion
|
60
|
+
};
|
61
|
+
};
|
62
|
+
const isStatusAssertionError = assertion => assertion.header.typ === "status-assertion-error+jwt";
|
63
|
+
|
64
|
+
/**
|
65
|
+
* Build an object containing the details on the error to use as the IssuerResponseError's reason
|
66
|
+
* @param assertion The status assertion response, both success or failure
|
67
|
+
* @returns The error's reason object
|
68
|
+
*/
|
69
|
+
const buildErrorReason = _ref => {
|
70
|
+
let {
|
71
|
+
payload
|
72
|
+
} = _ref;
|
73
|
+
return "error" in payload ? payload : {
|
74
|
+
error: payload.credential_status_detail.state,
|
75
|
+
error_description: payload.credential_status_detail.description
|
76
|
+
};
|
77
|
+
};
|
78
|
+
//# sourceMappingURL=03-verify-and-parse-status-assertion.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["IoWalletError","IssuerResponseError","IssuerResponseErrorCodes","decode","decodeJwt","verify","ParsedStatusAssertionResponse","StatusType","Logger","LogLevel","extractJwkFromCredential","isSameThumbprint","verifyAndParseStatusAssertion","issuerConf","rawStatusAssertion","credential","format","statusAssertion","openid_credential_issuer","jwks","keys","decodedJwt","parsedStatusAssertion","parse","header","protectedHeader","payload","log","DEBUG","JSON","stringify","isStatusAssertionError","code","CredentialInvalidStatus","message","statusCode","reason","buildErrorReason","cnf","credential_status_type","holderBindingKey","jwk","errorMessage","kid","ERROR","VALID","assertion","typ","_ref","error","credential_status_detail","state","error_description","description"],"sourceRoot":"../../../../src","sources":["credential/status/03-verify-and-parse-status-assertion.ts"],"mappings":"AACA,SACEA,aAAa,EACbC,mBAAmB,EACnBC,wBAAwB,QACnB,oBAAoB;AAC3B,SAASC,MAAM,IAAIC,SAAS,EAAEC,MAAM,QAAQ,6BAA6B;AAEzE,SAIEC,6BAA6B,EAC7BC,UAAU,QACL,SAAS;AAChB,SAASC,MAAM,EAAEC,QAAQ,QAAQ,qBAAqB;AAEtD,SAASC,wBAAwB,QAAQ,yBAAyB;AAClE,SAASC,gBAAgB,QAAQ,iBAAiB;AASlD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,6BAA4D,GACvE,MAAAA,CAAOC,UAAU,EAAEC,kBAAkB,EAAEC,UAAU,EAAEC,MAAM,KAAK;EAC5D,MAAM;IAAEC;EAAgB,CAAC,GAAGH,kBAAkB;EAE9C,MAAMT,MAAM,CACVY,eAAe,EACfJ,UAAU,CAACK,wBAAwB,CAACC,IAAI,CAACC,IAC3C,CAAC;EAED,MAAMC,UAAU,GAAGjB,SAAS,CAACa,eAAe,CAAC;EAC7C,MAAMK,qBAAqB,GAAGhB,6BAA6B,CAACiB,KAAK,CAAC;IAChEC,MAAM,EAAEH,UAAU,CAACI,eAAe;IAClCC,OAAO,EAAEL,UAAU,CAACK;EACtB,CAAC,CAAC;EAEFlB,MAAM,CAACmB,GAAG,CACRlB,QAAQ,CAACmB,KAAK,EACb,4BAA2BC,IAAI,CAACC,SAAS,CAACR,qBAAqB,CAAE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GAAAsB,IAAA;EAAA,OAC9B,OAAO,IAAItB,OAAO,GACdA,OAAO,GACP;IACEuB,KAAK,EAAEvB,OAAO,CAACwB,wBAAwB,CAAEC,KAAK;IAC9CC,iBAAiB,EAAE1B,OAAO,CAACwB,wBAAwB,CAAEG;EACvD,CAAC;AAAA"}
|
@@ -1,16 +1,16 @@
|
|
1
|
-
# Credential Status
|
1
|
+
# Credential Status Assertion
|
2
2
|
|
3
|
-
This flow is used to obtain a credential status
|
4
|
-
The credential status
|
5
|
-
The status
|
3
|
+
This flow is used to obtain a credential status assertion from its credential issuer. Each step in the flow is imported from the related file which is named with a sequential number.
|
4
|
+
The credential status assertion is a JWT which contains the credential status which indicates if the credential is valid or not (see [OAuth Status Assertions](https://italia.github.io/eid-wallet-it-docs/versione-corrente/en/credential-revocation.html#oauth-status-assertions)).
|
5
|
+
The status assertion is supposed to be stored securely along with the credential. It has a limited lifetime and should be refreshed periodically according to the `exp` field in the JWT payload.
|
6
6
|
|
7
7
|
## Sequence Diagram
|
8
8
|
|
9
9
|
```mermaid
|
10
10
|
graph TD;
|
11
11
|
0[startFlow]
|
12
|
-
1[
|
13
|
-
2[
|
12
|
+
1[statusAssertion]
|
13
|
+
2[verifyAndParseStatusAssertion]
|
14
14
|
|
15
15
|
0 --> 1
|
16
16
|
1 --> 2
|
@@ -21,14 +21,14 @@ graph TD;
|
|
21
21
|
|
22
22
|
The following errors are mapped to a `IssuerResponseError` with specific codes.
|
23
23
|
|
24
|
-
|
|
25
|
-
|
26
|
-
|`
|
24
|
+
|Error Code|Description|
|
25
|
+
|----------|-----------|
|
26
|
+
|`ERR_CREDENTIAL_INVALID_STATUS`|This error is thrown when the status assertion for a given credential is invalid. It might contain more details in the `reason` property.|
|
27
27
|
|
28
28
|
## Example
|
29
29
|
|
30
30
|
<details>
|
31
|
-
<summary>Credential status
|
31
|
+
<summary>Credential status assertion flow</summary>
|
32
32
|
|
33
33
|
```ts
|
34
34
|
// Start the issuance flow
|
@@ -42,24 +42,26 @@ const { issuerUrl } = startFlow();
|
|
42
42
|
// Evaluate issuer trust
|
43
43
|
const { issuerConf } = await Credential.Status.evaluateIssuerTrust(issuerUrl);
|
44
44
|
|
45
|
-
// Get the credential
|
46
|
-
const res = await Credential.Status.
|
45
|
+
// Get the credential assertion
|
46
|
+
const res = await Credential.Status.statusAssertion(
|
47
47
|
issuerConf,
|
48
48
|
credential,
|
49
|
-
|
49
|
+
format,
|
50
|
+
{ credentialCryptoContext, wiaCryptoContext }
|
50
51
|
);
|
51
52
|
|
52
|
-
// Verify and parse the status
|
53
|
-
const {
|
54
|
-
await Credential.Status.
|
53
|
+
// Verify and parse the status assertion
|
54
|
+
const { parsedStatusAssertion } =
|
55
|
+
await Credential.Status.verifyAndParseStatusAssertion(
|
55
56
|
issuerConf,
|
56
|
-
res.
|
57
|
-
|
57
|
+
res.statusAssertion,
|
58
|
+
credential,
|
59
|
+
format
|
58
60
|
);
|
59
61
|
|
60
62
|
return {
|
61
|
-
|
62
|
-
|
63
|
+
statusAssertion: res.statusAssertion,
|
64
|
+
parsedStatusAssertion,
|
63
65
|
};
|
64
66
|
```
|
65
67
|
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import {
|
1
|
+
import { statusAssertion } from "./02-status-assertion";
|
2
2
|
import { evaluateIssuerTrust } from "../issuance";
|
3
|
-
import {
|
4
|
-
export { evaluateIssuerTrust,
|
3
|
+
import { verifyAndParseStatusAssertion } from "./03-verify-and-parse-status-assertion";
|
4
|
+
export { evaluateIssuerTrust, statusAssertion, verifyAndParseStatusAssertion };
|
5
5
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["
|
1
|
+
{"version":3,"names":["statusAssertion","evaluateIssuerTrust","verifyAndParseStatusAssertion"],"sourceRoot":"../../../../src","sources":["credential/status/index.ts"],"mappings":"AACA,SAASA,eAAe,QAA8B,uBAAuB;AAC7E,SAASC,mBAAmB,QAAkC,aAAa;AAC3E,SACEC,6BAA6B,QAExB,wCAAwC;AAE/C,SAASD,mBAAmB,EAAED,eAAe,EAAEE,6BAA6B"}
|
@@ -3,31 +3,33 @@ import { JWK } from "../../utils/jwk";
|
|
3
3
|
import * as z from "zod";
|
4
4
|
|
5
5
|
/**
|
6
|
-
* Shape from parsing a status
|
6
|
+
* Shape from parsing a status assertion response in case of 201.
|
7
7
|
*/
|
8
|
-
export const
|
9
|
-
|
8
|
+
export const StatusAssertionResponse = z.object({
|
9
|
+
status_assertion_responses: z.array(z.string())
|
10
10
|
});
|
11
11
|
|
12
12
|
/**
|
13
|
-
* Type from parsing a status
|
14
|
-
* Inferred from {@link
|
13
|
+
* Type from parsing a status assertion response in case of 201.
|
14
|
+
* Inferred from {@link StatusAssertionResponse}.
|
15
15
|
*/
|
16
16
|
|
17
17
|
/**
|
18
|
-
*
|
18
|
+
* Shape for parsing a successful status assertion in a JWT.
|
19
19
|
*/
|
20
|
-
|
21
|
-
/**
|
22
|
-
* Shape for parsing a status attestation in a JWT.
|
23
|
-
*/
|
24
|
-
export const ParsedStatusAttestation = z.object({
|
20
|
+
export const ParsedStatusAssertion = z.object({
|
25
21
|
header: z.object({
|
26
|
-
typ: z.literal("status-
|
22
|
+
typ: z.literal("status-assertion+jwt"),
|
27
23
|
alg: z.string(),
|
28
24
|
kid: z.string().optional()
|
29
25
|
}),
|
30
26
|
payload: z.object({
|
27
|
+
iss: z.string(),
|
28
|
+
credential_status_type: z.string(),
|
29
|
+
credential_status_detail: z.object({
|
30
|
+
state: z.string(),
|
31
|
+
description: z.string()
|
32
|
+
}).optional(),
|
31
33
|
credential_hash_alg: z.string(),
|
32
34
|
credential_hash: z.string(),
|
33
35
|
cnf: z.object({
|
@@ -37,4 +39,33 @@ export const ParsedStatusAttestation = z.object({
|
|
37
39
|
iat: UnixTime
|
38
40
|
})
|
39
41
|
});
|
42
|
+
/**
|
43
|
+
* The JWT that contains the errors occurred for the status assertion request.
|
44
|
+
* @see https://italia.github.io/eid-wallet-it-docs/versione-corrente/en/credential-revocation.html#http-status-assertion-response
|
45
|
+
*/
|
46
|
+
export const ParsedStatusAssertionError = z.object({
|
47
|
+
header: z.object({
|
48
|
+
typ: z.literal("status-assertion-error+jwt"),
|
49
|
+
alg: z.string(),
|
50
|
+
kid: z.string().optional()
|
51
|
+
}),
|
52
|
+
payload: z.object({
|
53
|
+
credential_hash_alg: z.string(),
|
54
|
+
credential_hash: z.string(),
|
55
|
+
error: z.string(),
|
56
|
+
error_description: z.string()
|
57
|
+
})
|
58
|
+
});
|
59
|
+
|
60
|
+
/**
|
61
|
+
* The status assertion response that might include either a successful assertion or an error
|
62
|
+
*/
|
63
|
+
|
64
|
+
export const ParsedStatusAssertionResponse = z.union([ParsedStatusAssertion, ParsedStatusAssertionError]);
|
65
|
+
export let StatusType = /*#__PURE__*/function (StatusType) {
|
66
|
+
StatusType["VALID"] = "0x00";
|
67
|
+
StatusType["INVALID"] = "0x01";
|
68
|
+
StatusType["SUSPENDED"] = "0x02";
|
69
|
+
return StatusType;
|
70
|
+
}({});
|
40
71
|
//# sourceMappingURL=types.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["UnixTime","JWK","z","
|
1
|
+
{"version":3,"names":["UnixTime","JWK","z","StatusAssertionResponse","object","status_assertion_responses","array","string","ParsedStatusAssertion","header","typ","literal","alg","kid","optional","payload","iss","credential_status_type","credential_status_detail","state","description","credential_hash_alg","credential_hash","cnf","jwk","exp","iat","ParsedStatusAssertionError","error","error_description","ParsedStatusAssertionResponse","union","StatusType"],"sourceRoot":"../../../../src","sources":["credential/status/types.ts"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,GAAG,QAAQ,iBAAiB;AACrC,OAAO,KAAKC,CAAC,MAAM,KAAK;;AAExB;AACA;AACA;AACA,OAAO,MAAMC,uBAAuB,GAAGD,CAAC,CAACE,MAAM,CAAC;EAC9CC,0BAA0B,EAAEH,CAAC,CAACI,KAAK,CAACJ,CAAC,CAACK,MAAM,C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,MAAM,CAAC,CAAC,CAACO,QAAQ,CAAC;EAC3B,CAAC,CAAC;EACFC,OAAO,EAAEb,CAAC,CAACE,MAAM,CAAC;IAChBiB,mBAAmB,EAAEnB,CAAC,CAACK,MAAM,CAAC,CAAC;IAC/Be,eAAe,EAAEpB,CAAC,CAACK,MAAM,CAAC,CAAC;IAC3BqB,KAAK,EAAE1B,CAAC,CAACK,MAAM,CAAC,CAAC;IACjBsB,iBAAiB,EAAE3B,CAAC,CAACK,MAAM,CAAC;EAC9B,CAAC;AACH,CAAC,CAAC;;AAEF;AACA;AACA;;AAIA,OAAO,MAAMuB,6BAA6B,GAAG5B,CAAC,CAAC6B,KAAK,CAAC,CACnDvB,qBAAqB,EACrBmB,0BAA0B,CAC3B,CAAC;AAEF,WAAYK,UAAU,0BAAVA,UAAU;EAAVA,UAAU;EAAVA,UAAU;EAAVA,UAAU;EAAA,OAAVA,UAAU;AAAA"}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import { decode } from "../sd-jwt";
|
2
|
+
import { thumbprint } from "@pagopa/io-react-native-jwt";
|
3
|
+
import { IoWalletError } from "./errors";
|
4
|
+
const SD_JWT = ["vc+sd-jwt", "dc+sd-jwt"];
|
5
|
+
|
6
|
+
/**
|
7
|
+
* Extracts a JWK from a credential.
|
8
|
+
* @param credential - The credential string, which can be in SD-JWT or CBOR format.
|
9
|
+
* @param format - The format of the credential
|
10
|
+
* @return A Promise that resolves to a JWK object if the credential is in SD-JWT format and contains a JWK, or undefined otherwise.
|
11
|
+
*/
|
12
|
+
export const extractJwkFromCredential = async (credential, format) => {
|
13
|
+
if (SD_JWT.includes(format)) {
|
14
|
+
// 1. SD-JWT case
|
15
|
+
const decoded = decode(credential);
|
16
|
+
const jwk = decoded.sdJwt.payload.cnf.jwk;
|
17
|
+
if (jwk) {
|
18
|
+
return {
|
19
|
+
...jwk,
|
20
|
+
kid: await thumbprint(jwk)
|
21
|
+
};
|
22
|
+
}
|
23
|
+
}
|
24
|
+
throw new IoWalletError(`Credential format ${format} not supported`);
|
25
|
+
};
|
26
|
+
//# sourceMappingURL=credentials.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["decode","thumbprint","IoWalletError","SD_JWT","extractJwkFromCredential","credential","format","includes","decoded","jwk","sdJwt","payload","cnf","kid"],"sourceRoot":"../../../src","sources":["utils/credentials.ts"],"mappings":"AAAA,SAASA,MAAM,QAAQ,WAAW;AAClC,SAASC,UAAU,QAAQ,6BAA6B;AAIxD,SAASC,aAAa,QAAQ,UAAU;AAExC,MAAMC,MAAM,GAAG,CAAC,WAAW,EAAE,WAAW,CAAC;;AAEzC;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,wBAAwB,GAAG,MAAAA,CACtCC,UAA+C,EAC/CC,MAAuC,KACtB;EACjB,IAAIH,MAAM,CAACI,QAAQ,CAACD,MAAM,CAAC,EAAE;IAC3B;IACA,MAAME,OAAO,GAAGR,MAAM,CAACK,UAAU,CAAC;IAClC,MAAMI,GAAG,GAAGD,OAAO,CAACE,KAAK,CAACC,OAAO,CAACC,GAAG,CAACH,GAAG;IACzC,IAAIA,GAAG,EAAE;MACP,OAAO;QAAE,GAAGA,GAAG;QAAEI,GAAG,EAAE,MAAMZ,UAAU,CAACQ,GAAG;MAAE,CAAC;IAC/C;EACF;EACA,MAAM,IAAIP,aAAa,CAAE,qBAAoBI,MAAO,gBAAe,CAAC;AACtE,CAAC"}
|
@@ -1,7 +1,6 @@
|
|
1
|
-
import {
|
1
|
+
import { deleteKey, generate, getPublicKeyFixed, sign } from "@pagopa/io-react-native-crypto";
|
2
2
|
import { v4 as uuidv4 } from "uuid";
|
3
3
|
import { thumbprint } from "@pagopa/io-react-native-jwt";
|
4
|
-
import { fixBase64EncodingOnKey } from "./jwk";
|
5
4
|
|
6
5
|
/**
|
7
6
|
* Create a CryptoContext bound to a key pair.
|
@@ -12,13 +11,8 @@ import { fixBase64EncodingOnKey } from "./jwk";
|
|
12
11
|
*/
|
13
12
|
export const createCryptoContextFor = keytag => {
|
14
13
|
return {
|
15
|
-
/**
|
16
|
-
* Retrieve the public key of the pair.
|
17
|
-
* If the key pair doesn't exist yet, an error is raised
|
18
|
-
* @returns The public key.
|
19
|
-
*/
|
20
14
|
async getPublicKey() {
|
21
|
-
return
|
15
|
+
return getPublicKeyFixed(keytag).then(async jwk => ({
|
22
16
|
...jwk,
|
23
17
|
// Keys in the TEE are not stored with their KID, which is supposed to be assigned when they are included in JWK sets.
|
24
18
|
// (that is, KID is not a propoerty of the key itself, but it's property used to identify a key in a set).
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["
|
1
|
+
{"version":3,"names":["deleteKey","generate","getPublicKeyFixed","sign","v4","uuidv4","thumbprint","createCryptoContextFor","keytag","getPublicKey","then","jwk","kid","getSignature","value","withEphemeralKey","fn","ephemeralContext","finally"],"sourceRoot":"../../../src","sources":["utils/crypto.ts"],"mappings":"AAAA,SACEA,SAAS,EACTC,QAAQ,EACRC,iBAAiB,EACjBC,IAAI,QACC,gCAAgC;AACvC,SAASC,EAAE,IAAIC,MAAM,QAAQ,MAAM;AACnC,SAA6BC,UAAU,QAAQ,6BAA6B;;AAE5E;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,sBAAsB,GAAIC,MAAc,IAAoB;EACvE,OAAO;IACL,MAAMC,YAAYA,CAAA,EAAG;MACnB,OAAOP,iBAAiB,CAACM,MAAM,CAAC,CAACE,IAAI,CAAC,MAAOC,GAAG,KAAM;QACpD,GAAGA,GAAG;QACN;QACA;QACA;QACA;QACAC,GAAG,EAAE,MAAMN,UAAU,CAACK,GAAG;MAC3B,CAAC,CAAC,CAAC;IACL,CAAC;IACD;AACJ;AACA;AACA;AACA;AACA;IACI,MAAME,YAAYA,CAACC,KAAa,EAAE;MAChC,OAAOX,IAAI,CAACW,KAAK,EAAEN,MAAM,CAAC;IAC5B;EACF,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMO,gBAAgB,GAAG,MAC9BC,EAAmD,IACpC;EACf;EACA,MAAMR,MAAM,GAAI,aAAYH,MAAM,CAAC,CAAE,EAAC;EACtC,MAAMJ,QAAQ,CAACO,MAAM,CAAC;EACtB,MAAMS,gBAAgB,GAAGV,sBAAsB,CAACC,MAAM,CAAC;EACvD,OAAOQ,EAAE,CAACC,gBAAgB,CAAC,CAACC,OAAO,CAAC,MAAMlB,SAAS,CAACQ,MAAM,CAAC,CAAC;AAC9D,CAAC"}
|
package/lib/module/utils/jwk.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { removePadding } from "@pagopa/io-react-native-jwt";
|
1
|
+
import { removePadding, thumbprint } from "@pagopa/io-react-native-jwt";
|
2
2
|
import { z } from "zod";
|
3
3
|
export const JWK = z.object({
|
4
4
|
/** JWK "alg" (Algorithm) Parameter. */
|
@@ -72,4 +72,14 @@ export function fixBase64EncodingOnKey(key) {
|
|
72
72
|
export const JWKS = z.object({
|
73
73
|
keys: z.array(JWK)
|
74
74
|
});
|
75
|
+
/**
|
76
|
+
* Utility function that checks if two JWKs have the same thumbprint.
|
77
|
+
* @param jwkA The first JWK
|
78
|
+
* @param jwkB The second JWK
|
79
|
+
* @returns Whether the thumbprints match
|
80
|
+
*/
|
81
|
+
export const isSameThumbprint = async (jwkA, jwkB) => {
|
82
|
+
const [thumbprintJwkA, thumbprintJwkB] = await Promise.all([thumbprint(jwkA), thumbprint(jwkB)]);
|
83
|
+
return thumbprintJwkA === thumbprintJwkB;
|
84
|
+
};
|
75
85
|
//# sourceMappingURL=jwk.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["removePadding","z","JWK","object","alg","string","optional","crv","d","dp","dq","e","ext","boolean","k","key_ops","array","kid","kty","union","literal","n","p","q","qi","use","x","y","x5c","x5t","x5u","fixBase64EncodingOnKey","key","pk","JWKS","keys"],"sourceRoot":"../../../src","sources":["utils/jwk.ts"],"mappings":"AAAA,SAAiBA,aAAa,QAAQ,6BAA6B;
|
1
|
+
{"version":3,"names":["removePadding","thumbprint","z","JWK","object","alg","string","optional","crv","d","dp","dq","e","ext","boolean","k","key_ops","array","kid","kty","union","literal","n","p","q","qi","use","x","y","x5c","x5t","x5u","fixBase64EncodingOnKey","key","pk","JWKS","keys","isSameThumbprint","jwkA","jwkB","thumbprintJwkA","thumbprintJwkB","Promise","all"],"sourceRoot":"../../../src","sources":["utils/jwk.ts"],"mappings":"AAAA,SAAiBA,aAAa,EAAEC,UAAU,QAAQ,6BAA6B;AAC/E,SAASC,CAAC,QAAQ,KAAK;AAGvB,OAAO,MAAMC,GAAG,GAAGD,CAAC,CAACE,MAAM,CAAC;EAC1B;EACAC,GAAG,EAAEH,CAAC,CAACI,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC;EAC1BC,GAAG,EAAEN,CAAC,CAACI,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC;EAC1BE,CAAC,EAAEP,CAAC,CAACI,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC;EACxBG,EAAE,EAAER,CAAC,CAACI,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC;EACzBI,EAAE,EAAET,CAAC,CAACI,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC;EACzBK,CAAC,EAAEV,CAAC,CAACI,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC;EACxB;EACAM,GAAG,EAAEX,CAAC,CAACY,OAAO,CAAC,CAAC,CAACP,QAAQ,CAAC,CAAC;EAC3BQ,CAAC,EAAEb,CAAC,CAACI,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC;EACxB;EACAS,OAAO,EAAEd,CAAC,CAACe,KAAK,CAACf,CAAC,CAACI,MAAM,CAAC,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC;EACvC;EACAW,GAAG,EAAEhB,CAAC,CAACI,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC,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C;IAAEU,CAAC;IAAE,GAAGY;EAAG,CAAC,GAAGD,GAAG;EAEjC,OAAO;IACL,GAAGC,EAAE;IACL,IAAIP,CAAC,GAAG;MAAEA,CAAC,EAAE3B,aAAa,CAAC2B,CAAC;IAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACrC,IAAIC,CAAC,GAAG;MAAEA,CAAC,EAAE5B,aAAa,CAAC4B,CAAC;IAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACrC,IAAIhB,CAAC,GAAG;MAAEA,CAAC,EAAEZ,aAAa,CAACY,CAAC;IAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACrC,IAAIU,CAAC,GAAG;MAAEA,CAAC,EAAEtB,aAAa,CAACsB,CAAC;IAAE,CAAC,GAAG,CAAC,CAAC;EACtC,CAAC;AACH;AAGA,OAAO,MAAMa,IAAI,GAAGjC,CAAC,CAACE,MAAM,CAAC;EAC3BgC,IAAI,EAAElC,CAAC,CAACe,KAAK,CAACd,GAAG;AACnB,CAAC,CAAC;AAIF;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMkC,gBAAgB,GAAG,MAAAA,CAAOC,IAAS,EAAEC,IAAS,KAAK;EAC9D,MAAM,CAACC,cAAc,EAAEC,cAAc,CAAC,GAAG,MAAMC,OAAO,CAACC,GAAG,CAAC,CACzD1C,UAAU,CAACqC,IAAI,CAAC,EAChBrC,UAAU,CAACsC,IAAI,CAAC,CACjB,CAAC;EACF,OAAOC,cAAc,KAAKC,cAAc;AAC1C,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"07-verify-and-parse-credential.d.ts","sourceRoot":"","sources":["../../../../src/credential/issuance/07-verify-and-parse-credential.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;
|
1
|
+
{"version":3,"file":"07-verify-and-parse-credential.d.ts","sourceRoot":"","sources":["../../../../src/credential/issuance/07-verify-and-parse-credential.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAKtE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG/D,KAAK,UAAU,GAAG,GAAG,CAAC,mBAAmB,CAAC,CAAC,YAAY,CAAC,CAAC;AAIzD,MAAM,MAAM,wBAAwB,GAAG,CACrC,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,GAAG,CAAC,gBAAgB,CAAC,CAAC,YAAY,CAAC,EAC/C,yBAAyB,EAAE,MAAM,EACjC,OAAO,EAAE;IACP,uBAAuB,EAAE,aAAa,CAAC;IACvC;;OAEG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC;;OAEG;IACH,0BAA0B,CAAC,EAAE,OAAO,CAAC;CACtC,KACE,OAAO,CAAC;IACX,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,UAAU,EAAE,IAAI,CAAC;IACjB,QAAQ,EAAE,IAAI,GAAG,SAAS,CAAC;CAC5B,CAAC,CAAC;AAGH,KAAK,gBAAgB,GAAG,MAAM;AAC5B,oBAAoB;AACpB,MAAM,EACN;IACE,2CAA2C;IAC3C,IAAI,EACA,yBAAyB,CAAC,MAAM,CAC9B,MAAM,EACN,MAAM,CACP,GACD,4BAA4B,CAAC,MAAM,GACnC,SAAS,CAAC;IACd,wCAAwC;IACxC,KAAK,EAAE,OAAO,CAAC;CAChB,CACF,CAAC;AAsLF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,wBAAwB,EAAE,wBAwBtC,CAAC"}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import { type Out } from "../../utils/misc";
|
2
|
+
import type { EvaluateIssuerTrust, ObtainCredential } from "../issuance";
|
3
|
+
import { type CryptoContext } from "@pagopa/io-react-native-jwt";
|
4
|
+
export type StatusAssertion = (issuerConf: Out<EvaluateIssuerTrust>["issuerConf"], credential: Out<ObtainCredential>["credential"], format: Out<ObtainCredential>["format"], context: {
|
5
|
+
credentialCryptoContext: CryptoContext;
|
6
|
+
wiaCryptoContext: CryptoContext;
|
7
|
+
appFetch?: GlobalFetch["fetch"];
|
8
|
+
}) => Promise<{
|
9
|
+
statusAssertion: string;
|
10
|
+
}>;
|
11
|
+
/**
|
12
|
+
* Get the status assertion of a digital credential.
|
13
|
+
* @param issuerConf - The issuer's configuration
|
14
|
+
* @param credential - The credential to be verified
|
15
|
+
* @param format - The format of the credential, e.g. "sd-jwt"
|
16
|
+
* @param context.credentialCryptoContext - The credential's crypto context
|
17
|
+
* @param context.wiaCryptoContext - The Wallet Attestation's crypto context
|
18
|
+
* @param context.appFetch (optional) fetch api implementation. Default: built-in fetch
|
19
|
+
* @throws {IssuerResponseError} with a specific code for more context
|
20
|
+
* @returns The credential status assertion
|
21
|
+
*/
|
22
|
+
export declare const statusAssertion: StatusAssertion;
|
23
|
+
//# sourceMappingURL=02-status-assertion.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"02-status-assertion.d.ts","sourceRoot":"","sources":["../../../../src/credential/status/02-status-assertion.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,GAAG,EACT,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,EAAE,KAAK,aAAa,EAAW,MAAM,6BAA6B,CAAC;AAY1E,MAAM,MAAM,eAAe,GAAG,CAC5B,UAAU,EAAE,GAAG,CAAC,mBAAmB,CAAC,CAAC,YAAY,CAAC,EAClD,UAAU,EAAE,GAAG,CAAC,gBAAgB,CAAC,CAAC,YAAY,CAAC,EAC/C,MAAM,EAAE,GAAG,CAAC,gBAAgB,CAAC,CAAC,QAAQ,CAAC,EACvC,OAAO,EAAE;IACP,uBAAuB,EAAE,aAAa,CAAC;IACvC,gBAAgB,EAAE,aAAa,CAAC;IAChC,QAAQ,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;CACjC,KACE,OAAO,CAAC;IACX,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC,CAAC;AAEH;;;;;;;;;;GAUG;AACH,eAAO,MAAM,eAAe,EAAE,eAoD7B,CAAC"}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import type { Out } from "../../utils/misc";
|
2
|
+
import type { EvaluateIssuerTrust, StatusAssertion } from ".";
|
3
|
+
import { ParsedStatusAssertion } from "./types";
|
4
|
+
import type { ObtainCredential } from "../issuance";
|
5
|
+
export type VerifyAndParseStatusAssertion = (issuerConf: Out<EvaluateIssuerTrust>["issuerConf"], statusAssertion: Out<StatusAssertion>, credential: Out<ObtainCredential>["credential"], format: Out<ObtainCredential>["format"]) => Promise<{
|
6
|
+
parsedStatusAssertion: ParsedStatusAssertion;
|
7
|
+
}>;
|
8
|
+
/**
|
9
|
+
* Given a status assertion, verifies that:
|
10
|
+
* - It's in the supported format;
|
11
|
+
* - The assertion is correctly signed;
|
12
|
+
* - It's bound to the given key.
|
13
|
+
* @param issuerConf The Issuer configuration returned by {@link evaluateIssuerTrust}
|
14
|
+
* @param statusAssertion The encoded status assertion returned by {@link statusAssertion}
|
15
|
+
* @param context.credentialCryptoContext The crypto context used to obtain the credential in {@link obtainCredential}
|
16
|
+
* @returns A parsed status assertion
|
17
|
+
* @throws {IoWalletError} If the credential signature is not verified with the Issuer key set
|
18
|
+
* @throws {IssuerResponseError} If the status assertion contains an error or the credential status is invalid
|
19
|
+
*/
|
20
|
+
export declare const verifyAndParseStatusAssertion: VerifyAndParseStatusAssertion;
|
21
|
+
//# sourceMappingURL=03-verify-and-parse-status-assertion.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"03-verify-and-parse-status-assertion.d.ts","sourceRoot":"","sources":["../../../../src/credential/status/03-verify-and-parse-status-assertion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAO5C,OAAO,KAAK,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,GAAG,CAAC;AAC9D,OAAO,EAEL,qBAAqB,EAItB,MAAM,SAAS,CAAC;AAEjB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAIpD,MAAM,MAAM,6BAA6B,GAAG,CAC1C,UAAU,EAAE,GAAG,CAAC,mBAAmB,CAAC,CAAC,YAAY,CAAC,EAClD,eAAe,EAAE,GAAG,CAAC,eAAe,CAAC,EACrC,UAAU,EAAE,GAAG,CAAC,gBAAgB,CAAC,CAAC,YAAY,CAAC,EAC/C,MAAM,EAAE,GAAG,CAAC,gBAAgB,CAAC,CAAC,QAAQ,CAAC,KACpC,OAAO,CAAC;IAAE,qBAAqB,EAAE,qBAAqB,CAAA;CAAE,CAAC,CAAC;AAE/D;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,6BAA6B,EAAE,6BAiDzC,CAAC"}
|