@pagopa/io-react-native-wallet 0.9.2 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/commonjs/credential/issuance/06-obtain-credential.js +2 -34
- package/lib/commonjs/credential/issuance/06-obtain-credential.js.map +1 -1
- package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js +169 -0
- package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js.map +1 -0
- package/lib/commonjs/credential/issuance/08-confirm-credential.js +6 -0
- package/lib/commonjs/credential/issuance/08-confirm-credential.js.map +1 -0
- package/lib/commonjs/credential/issuance/const.js +6 -1
- package/lib/commonjs/credential/issuance/const.js.map +1 -1
- package/lib/commonjs/credential/issuance/index.js +7 -0
- package/lib/commonjs/credential/issuance/index.js.map +1 -1
- package/lib/commonjs/index.js +3 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/sd-jwt/__test__/index.test.js +33 -1
- package/lib/commonjs/sd-jwt/__test__/index.test.js.map +1 -1
- package/lib/commonjs/sd-jwt/index.js +15 -6
- package/lib/commonjs/sd-jwt/index.js.map +1 -1
- package/lib/commonjs/sd-jwt/types.js +1 -1
- package/lib/commonjs/trust/types.js +5 -0
- package/lib/commonjs/trust/types.js.map +1 -1
- package/lib/commonjs/utils/misc.js +2 -2
- package/lib/commonjs/utils/misc.js.map +1 -1
- package/lib/module/credential/issuance/06-obtain-credential.js +3 -34
- package/lib/module/credential/issuance/06-obtain-credential.js.map +1 -1
- package/lib/module/credential/issuance/07-verify-and-parse-credential.js +163 -0
- package/lib/module/credential/issuance/07-verify-and-parse-credential.js.map +1 -0
- package/lib/module/credential/issuance/08-confirm-credential.js +2 -0
- package/lib/module/credential/issuance/08-confirm-credential.js.map +1 -0
- package/lib/module/credential/issuance/const.js +2 -0
- package/lib/module/credential/issuance/const.js.map +1 -1
- package/lib/module/credential/issuance/index.js +2 -1
- package/lib/module/credential/issuance/index.js.map +1 -1
- package/lib/module/index.js +2 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/sd-jwt/__test__/index.test.js +33 -1
- package/lib/module/sd-jwt/__test__/index.test.js.map +1 -1
- package/lib/module/sd-jwt/index.js +10 -6
- package/lib/module/sd-jwt/index.js.map +1 -1
- package/lib/module/sd-jwt/types.js +1 -1
- package/lib/module/trust/types.js +5 -0
- package/lib/module/trust/types.js.map +1 -1
- package/lib/module/utils/misc.js +2 -2
- package/lib/module/utils/misc.js.map +1 -1
- package/lib/typescript/credential/issuance/06-obtain-credential.d.ts +2 -1
- package/lib/typescript/credential/issuance/06-obtain-credential.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts +36 -0
- package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts.map +1 -0
- package/lib/typescript/credential/issuance/08-confirm-credential.d.ts +11 -0
- package/lib/typescript/credential/issuance/08-confirm-credential.d.ts.map +1 -0
- package/lib/typescript/credential/issuance/const.d.ts +3 -0
- package/lib/typescript/credential/issuance/const.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/index.d.ts +4 -3
- package/lib/typescript/credential/issuance/index.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/sd-jwt/index.d.ts +222 -5
- package/lib/typescript/sd-jwt/index.d.ts.map +1 -1
- package/lib/typescript/sd-jwt/types.d.ts +1 -1
- package/lib/typescript/trust/index.d.ts +8 -0
- package/lib/typescript/trust/index.d.ts.map +1 -1
- package/lib/typescript/trust/types.d.ts +232 -0
- package/lib/typescript/trust/types.d.ts.map +1 -1
- package/lib/typescript/utils/misc.d.ts +1 -1
- package/lib/typescript/utils/misc.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/credential/issuance/06-obtain-credential.ts +3 -51
- package/src/credential/issuance/07-verify-and-parse-credential.ts +229 -0
- package/src/credential/issuance/08-confirm-credential.ts +14 -0
- package/src/credential/issuance/const.ts +6 -0
- package/src/credential/issuance/index.ts +7 -1
- package/src/index.ts +2 -0
- package/src/sd-jwt/__test__/index.test.ts +32 -1
- package/src/sd-jwt/index.ts +14 -8
- package/src/sd-jwt/types.ts +1 -1
- package/src/trust/types.ts +4 -0
- package/src/utils/misc.ts +4 -2
@@ -10,9 +10,9 @@ var _errors = require("./errors");
|
|
10
10
|
* @param status The expected status
|
11
11
|
* @returns The given response object
|
12
12
|
*/
|
13
|
-
const hasStatus = status => res => {
|
13
|
+
const hasStatus = status => async res => {
|
14
14
|
if (res.status !== status) {
|
15
|
-
throw new _errors.IoWalletError(`Http request failed. Expected ${status}, got ${res.status}, url: ${res.url}`);
|
15
|
+
throw new _errors.IoWalletError(`Http request failed. Expected ${status}, got ${res.status}, url: ${res.url} with response: ${await res.text()}`);
|
16
16
|
}
|
17
17
|
return res;
|
18
18
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_errors","require","hasStatus","status","res","IoWalletError","url","exports"],"sourceRoot":"../../../src","sources":["utils/misc.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAEA;AACA;AACA;AACA;AACA;AACO,MAAMC,SAAS,GACnBC,MAAc,
|
1
|
+
{"version":3,"names":["_errors","require","hasStatus","status","res","IoWalletError","url","text","exports"],"sourceRoot":"../../../src","sources":["utils/misc.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAEA;AACA;AACA;AACA;AACA;AACO,MAAMC,SAAS,GACnBC,MAAc,IACf,MAAOC,GAAa,IAAwB;EAC1C,IAAIA,GAAG,CAACD,MAAM,KAAKA,MAAM,EAAE;IACzB,MAAM,IAAIE,qBAAa,CACpB,iCAAgCF,MAAO,SAAQC,GAAG,CAACD,MAAO,UACzDC,GAAG,CAACE,GACL,mBAAkB,MAAMF,GAAG,CAACG,IAAI,CAAC,CAAE,EACtC,CAAC;EACH;EACA,OAAOH,GAAG;AACZ,CAAC;;AAEH;AACA;AAAAI,OAAA,CAAAN,SAAA,GAAAA,SAAA"}
|
@@ -1,11 +1,10 @@
|
|
1
1
|
import * as z from "zod";
|
2
2
|
import uuid from "react-native-uuid";
|
3
3
|
import { SignJWT } from "@pagopa/io-react-native-jwt";
|
4
|
-
import { verify as verifySdJwt } from "../../sd-jwt";
|
5
4
|
import { createDPopToken } from "../../utils/dpop";
|
6
5
|
import { hasStatus } from "../../utils/misc";
|
7
|
-
import {
|
8
|
-
|
6
|
+
import { SupportedCredentialFormat } from "./const";
|
7
|
+
|
9
8
|
/**
|
10
9
|
* Return the signed jwt for nonce proof of possession
|
11
10
|
*/
|
@@ -17,35 +16,9 @@ export const createNonceProof = async (nonce, issuer, audience, ctx) => {
|
|
17
16
|
type: "openid4vci-proof+jwt"
|
18
17
|
}).setAudience(audience).setIssuer(issuer).setIssuedAt().setExpirationTime("1h").sign();
|
19
18
|
};
|
20
|
-
|
21
|
-
/**
|
22
|
-
* Given a credential, verify it's in the supported format
|
23
|
-
* and the credential is correctly signed
|
24
|
-
* and it's bound to the given key
|
25
|
-
*
|
26
|
-
* @param rawCredential The received credential
|
27
|
-
* @param issuerKeys The set of public keys of the issuer,
|
28
|
-
* which will be used to verify the signature
|
29
|
-
* @param holderBindingContext The access to the holder's key
|
30
|
-
*
|
31
|
-
* @throws If the signature verification fails
|
32
|
-
* @throws If the credential is not in the SdJwt4VC format
|
33
|
-
* @throws If the holder binding is not properly configured
|
34
|
-
*
|
35
|
-
*/
|
36
|
-
async function verifyCredential(rawCredential, issuerKeys, holderBindingContext) {
|
37
|
-
const [{
|
38
|
-
sdJwt
|
39
|
-
}, holderBindingKey] =
|
40
|
-
// parallel for optimization
|
41
|
-
await Promise.all([verifySdJwt(rawCredential, issuerKeys, SdJwt4VC), holderBindingContext.getPublicKey()]);
|
42
|
-
if (!sdJwt.payload.cnf.jwk.kid || sdJwt.payload.cnf.jwk.kid !== holderBindingKey.kid) {
|
43
|
-
throw new IoWalletError(`Failed to verify holder binding, expected kid: ${holderBindingKey.kid}, got: ${sdJwt.payload.cnf.jwk.kid}`);
|
44
|
-
}
|
45
|
-
}
|
46
19
|
const CredentialEndpointResponse = z.object({
|
47
20
|
credential: z.string(),
|
48
|
-
format:
|
21
|
+
format: SupportedCredentialFormat
|
49
22
|
});
|
50
23
|
/**
|
51
24
|
* Fetch a credential from the issuer
|
@@ -105,10 +78,6 @@ export const obtainCredential = async (issuerConf, accessToken, nonce, clientId,
|
|
105
78
|
},
|
106
79
|
body: formBody.toString()
|
107
80
|
}).then(hasStatus(200)).then(res => res.json()).then(CredentialEndpointResponse.parse);
|
108
|
-
|
109
|
-
/** validate the received credential signature
|
110
|
-
is correct and refers to the public keys of the issuer */
|
111
|
-
await verifyCredential(credential, issuerConf.openid_credential_issuer.jwks.keys, credentialCryptoContext);
|
112
81
|
return {
|
113
82
|
credential,
|
114
83
|
format
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["z","uuid","SignJWT","
|
1
|
+
{"version":3,"names":["z","uuid","SignJWT","createDPopToken","hasStatus","SupportedCredentialFormat","createNonceProof","nonce","issuer","audience","ctx","setPayload","jwk","getPublicKey","setProtectedHeader","type","setAudience","setIssuer","setIssuedAt","setExpirationTime","sign","CredentialEndpointResponse","object","credential","string","format","obtainCredential","issuerConf","accessToken","clientId","credentialType","context","credentialCryptoContext","walletProviderBaseUrl","appFetch","fetch","credentialUrl","openid_credential_issuer","credential_endpoint","signedDPopForPid","htm","htu","jti","v4","signedNonceProof","formBody","URLSearchParams","credential_definition","JSON","stringify","proof","jwt","proof_type","method","headers","DPoP","Authorization","body","toString","then","res","json","parse"],"sourceRoot":"../../../../src","sources":["credential/issuance/06-obtain-credential.ts"],"mappings":"AAAA,OAAO,KAAKA,CAAC,MAAM,KAAK;AACxB,OAAOC,IAAI,MAAM,mBAAmB;AACpC,SAASC,OAAO,QAA4B,6BAA6B;AACzE,SAASC,eAAe,QAAQ,kBAAkB;AAGlD,SAASC,SAAS,QAAkB,kBAAkB;AAGtD,SAASC,yBAAyB,QAAQ,SAAS;;AAEnD;AACA;AACA;AACA,OAAO,MAAMC,gBAAgB,GAA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F,CAAC;;EAED;EACA,MAAMa,QAAQ,GAAG,IAAIC,eAAe,CAAC;IACnCC,qBAAqB,EAAEC,IAAI,CAACC,SAAS,CAAC;MACpClC,IAAI,EAAE,CAACe,cAAc;IACvB,CAAC,CAAC;IACFL,MAAM,EAAE,WAAW;IACnByB,KAAK,EAAEF,IAAI,CAACC,SAAS,CAAC;MACpBE,GAAG,EAAEP,gBAAgB;MACrBQ,UAAU,EAAE;IACd,CAAC;EACH,CAAC,CAAC;EAEF,MAAM;IAAE7B,UAAU;IAAEE;EAAO,CAAC,GAAG,MAAMS,QAAQ,CAACE,aAAa,EAAE;IAC3DiB,MAAM,EAAE,MAAM;IACdC,OAAO,EAAE;MACP,cAAc,EAAE,mCAAmC;MACnDC,IAAI,EAAEhB,gBAAgB;MACtBiB,aAAa,EAAE5B;IACjB,CAAC;IACD6B,IAAI,EAAEZ,QAAQ,CAACa,QAAQ,CAAC;EAC1B,CAAC,CAAC,CACCC,IAAI,CAACvD,SAAS,CAAC,GAAG,CAAC,CAAC,CACpBuD,IAAI,CAAEC,GAAG,IAAKA,GAAG,CAACC,IAAI,CAAC,CAAC,CAAC,CACzBF,IAAI,CAACtC,0BAA0B,CAACyC,KAAK,CAAC;EAEzC,OAAO;IAAEvC,UAAU;IAAEE;EAAO,CAAC;AAC/B,CAAC"}
|
@@ -0,0 +1,163 @@
|
|
1
|
+
import { IoWalletError } from "../../utils/errors";
|
2
|
+
import { SdJwt4VC } from "../../sd-jwt/types";
|
3
|
+
import { verify as verifySdJwt } from "../../sd-jwt";
|
4
|
+
|
5
|
+
// The credential as a collection of attributes in plain value
|
6
|
+
|
7
|
+
// handy alias
|
8
|
+
|
9
|
+
const parseCredentialSdJwt = function (credentials_supported, _ref) {
|
10
|
+
var _credentials_supporte;
|
11
|
+
let {
|
12
|
+
sdJwt,
|
13
|
+
disclosures
|
14
|
+
} = _ref;
|
15
|
+
let ignoreMissingAttributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
16
|
+
// find the definition that matches the received credential's type
|
17
|
+
// warning: if more then a defintion is found, the first is retrieved
|
18
|
+
const credentialSubject = (_credentials_supporte = credentials_supported.find(c => c.credential_definition.type.includes(sdJwt.payload.type))) === null || _credentials_supporte === void 0 ? void 0 : _credentials_supporte.credential_definition.credentialSubject;
|
19
|
+
|
20
|
+
// the received credential matches no supported credential, throw an exception
|
21
|
+
if (!credentialSubject) {
|
22
|
+
const expected = credentials_supported.flatMap(_ => _.credential_definition.type).join(", ");
|
23
|
+
throw new IoWalletError(`Received credential is of an unknwown type. Expected one of [${expected}], received '${sdJwt.payload.type}', `);
|
24
|
+
}
|
25
|
+
|
26
|
+
// transfrom a record { key: value } in an iterable of pairs [key, value]
|
27
|
+
const attrDefinitions = Object.entries(credentialSubject);
|
28
|
+
|
29
|
+
// every mandatory attribute must be present in the credential's disclosures
|
30
|
+
// the key of the attribute defintion must match the disclosure's name
|
31
|
+
const attrsNotInDisclosures = attrDefinitions.filter(_ref2 => {
|
32
|
+
let [attrKey, {
|
33
|
+
mandatory
|
34
|
+
}] = _ref2;
|
35
|
+
return mandatory && !disclosures.some(_ref3 => {
|
36
|
+
let [, name] = _ref3;
|
37
|
+
return name === attrKey;
|
38
|
+
});
|
39
|
+
});
|
40
|
+
if (attrsNotInDisclosures.length > 0) {
|
41
|
+
const missing = attrsNotInDisclosures.map(_ => _[0 /* key */]).join(", ");
|
42
|
+
const received = disclosures.map(_ => _[1 /* name */]).join(", ");
|
43
|
+
// the rationale of this condition is that we may want to be permissive
|
44
|
+
// on incomplete credentials in the test phase of the project.
|
45
|
+
// we might want to be strict once in production, hence remove this condition
|
46
|
+
if (!ignoreMissingAttributes) {
|
47
|
+
throw new IoWalletError(`Some attributes are missing in the credential. Missing: [${missing}], received: [${received}]`);
|
48
|
+
}
|
49
|
+
}
|
50
|
+
|
51
|
+
// attributes that are defined in the issuer configuration
|
52
|
+
// and are present in the disclosure set
|
53
|
+
const definedValues = attrDefinitions
|
54
|
+
// retrieve the value from the disclosure set
|
55
|
+
.map(_ref4 => {
|
56
|
+
var _disclosures$find;
|
57
|
+
let [attrKey, definition] = _ref4;
|
58
|
+
return [attrKey, {
|
59
|
+
...definition,
|
60
|
+
value: (_disclosures$find = disclosures.find(_ => _[1 /* name */] === attrKey)) === null || _disclosures$find === void 0 ? void 0 : _disclosures$find[2 /* value */]
|
61
|
+
}];
|
62
|
+
})
|
63
|
+
// add a human readable attribute name, with i18n, in the form { locale: name }
|
64
|
+
// example: { "it-IT": "Nome", "en-EN": "Name", "es-ES": "Nombre" }
|
65
|
+
.map(_ref5 => {
|
66
|
+
let [attrKey, {
|
67
|
+
display,
|
68
|
+
...definition
|
69
|
+
}] = _ref5;
|
70
|
+
return [attrKey, {
|
71
|
+
...definition,
|
72
|
+
name: display.reduce((names, _ref6) => {
|
73
|
+
let {
|
74
|
+
locale,
|
75
|
+
name
|
76
|
+
} = _ref6;
|
77
|
+
return {
|
78
|
+
...names,
|
79
|
+
[locale]: name
|
80
|
+
};
|
81
|
+
}, {})
|
82
|
+
}];
|
83
|
+
});
|
84
|
+
|
85
|
+
// attributes that are in the disclosure set
|
86
|
+
// but are not defined in the issuer configuration
|
87
|
+
const undefinedValues = disclosures.filter(_ => !Object.keys(definedValues).includes(_[1])).map(_ref7 => {
|
88
|
+
let [, key, value] = _ref7;
|
89
|
+
return [key, {
|
90
|
+
value,
|
91
|
+
mandatory: false,
|
92
|
+
name: key
|
93
|
+
}];
|
94
|
+
});
|
95
|
+
return {
|
96
|
+
...Object.fromEntries(definedValues),
|
97
|
+
...Object.fromEntries(undefinedValues)
|
98
|
+
};
|
99
|
+
};
|
100
|
+
|
101
|
+
/**
|
102
|
+
* Given a credential, verify it's in the supported format
|
103
|
+
* and the credential is correctly signed
|
104
|
+
* and it's bound to the given key
|
105
|
+
*
|
106
|
+
* @param rawCredential The received credential
|
107
|
+
* @param issuerKeys The set of public keys of the issuer,
|
108
|
+
* which will be used to verify the signature
|
109
|
+
* @param holderBindingContext The access to the holder's key
|
110
|
+
*
|
111
|
+
* @throws If the signature verification fails
|
112
|
+
* @throws If the credential is not in the SdJwt4VC format
|
113
|
+
* @throws If the holder binding is not properly configured
|
114
|
+
*
|
115
|
+
*/
|
116
|
+
async function verifyCredentialSdJwt(rawCredential, issuerKeys, holderBindingContext) {
|
117
|
+
const [decodedCredential, holderBindingKey] =
|
118
|
+
// parallel for optimization
|
119
|
+
await Promise.all([verifySdJwt(rawCredential, issuerKeys, SdJwt4VC), holderBindingContext.getPublicKey()]);
|
120
|
+
const {
|
121
|
+
cnf
|
122
|
+
} = decodedCredential.sdJwt.payload;
|
123
|
+
if (!cnf.jwk.kid || cnf.jwk.kid !== holderBindingKey.kid) {
|
124
|
+
throw new IoWalletError(`Failed to verify holder binding, expected kid: ${holderBindingKey.kid}, got: ${decodedCredential.sdJwt.payload.cnf.jwk.kid}`);
|
125
|
+
}
|
126
|
+
return decodedCredential;
|
127
|
+
}
|
128
|
+
|
129
|
+
// utility type that specialize VerifyAndParseCredential for given format
|
130
|
+
|
131
|
+
const verifyAndParseCredentialSdJwt = async (issuerConf, credential, _, _ref8) => {
|
132
|
+
let {
|
133
|
+
credentialCryptoContext,
|
134
|
+
ignoreMissingAttributes
|
135
|
+
} = _ref8;
|
136
|
+
const decoded = await verifyCredentialSdJwt(credential, issuerConf.openid_credential_issuer.jwks.keys, credentialCryptoContext);
|
137
|
+
const parsedCredential = parseCredentialSdJwt(issuerConf.openid_credential_issuer.credentials_supported, decoded, ignoreMissingAttributes);
|
138
|
+
return {
|
139
|
+
parsedCredential
|
140
|
+
};
|
141
|
+
};
|
142
|
+
|
143
|
+
/**
|
144
|
+
* Verify and parse an encoded credential
|
145
|
+
*
|
146
|
+
* @param issuerConf The Issuer configuration
|
147
|
+
* @param credential The encoded credential
|
148
|
+
* @param format The format of the credentual
|
149
|
+
* @param context.credentialCryptoContext The context to access the key the Credential will be bound to
|
150
|
+
* @param context.ignoreMissingAttributes (optional) Whether to fail if a defined attribute is note present in the credentual. Default: false
|
151
|
+
* @returns A parsed credential with attributes in plain value
|
152
|
+
* @throws If the credential signature is not verified with the Issuer key set
|
153
|
+
* @throws If the credential is not bound to the provided user key
|
154
|
+
* @throws If the credential data fail to parse
|
155
|
+
*/
|
156
|
+
export const verifyAndParseCredential = async (issuerConf, credential, format, context) => {
|
157
|
+
if (format === "vc+sd-jwt") {
|
158
|
+
return verifyAndParseCredentialSdJwt(issuerConf, credential, format, context);
|
159
|
+
}
|
160
|
+
const _ = format;
|
161
|
+
throw new IoWalletError(`Unsupported credential format: ${_}`);
|
162
|
+
};
|
163
|
+
//# sourceMappingURL=07-verify-and-parse-credential.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["IoWalletError","SdJwt4VC","verify","verifySdJwt","parseCredentialSdJwt","credentials_supported","_ref","_credentials_supporte","sdJwt","disclosures","ignoreMissingAttributes","arguments","length","undefined","credentialSubject","find","c","credential_definition","type","includes","payload","expected","flatMap","_","join","attrDefinitions","Object","entries","attrsNotInDisclosures","filter","_ref2","attrKey","mandatory","some","_ref3","name","missing","map","received","definedValues","_ref4","_disclosures$find","definition","value","_ref5","display","reduce","names","_ref6","locale","undefinedValues","keys","_ref7","key","fromEntries","verifyCredentialSdJwt","rawCredential","issuerKeys","holderBindingContext","decodedCredential","holderBindingKey","Promise","all","getPublicKey","cnf","jwk","kid","verifyAndParseCredentialSdJwt","issuerConf","credential","_ref8","credentialCryptoContext","decoded","openid_credential_issuer","jwks","parsedCredential","verifyAndParseCredential","format","context"],"sourceRoot":"../../../../src","sources":["credential/issuance/07-verify-and-parse-credential.ts"],"mappings":"AAGA,SAASA,aAAa,QAAQ,oBAAoB;AAClD,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,MAAM,IAAIC,WAAW,QAAQ,cAAc;;AAcpD;;AAmBA;;AAKA,MAAMC,oBAAoB,GAAG,SAAAA,CAE3BC,qBAAkH,EAAAC,IAAA,EAG7F;EAAA,IAAAC,qBAAA;EAAA,IAFrB;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EAAA+C,KAAA,KAEE;EAAA,IADH;IAAEC,uBAAuB;IAAE7D;EAAwB,CAAC,GAAA4D,KAAA;EAEpD,MAAME,OAAO,GAAG,MAAMjB,qBAAqB,CACzCc,UAAU,EACVD,UAAU,CAACK,wBAAwB,CAACC,IAAI,CAACvB,IAAI,EAC7CoB,uBACF,CAAC;EAED,MAAMI,gBAAgB,GAAGvE,oBAAoB,CAC3CgE,UAAU,CAACK,wBAAwB,CAACpE,qBAAqB,EACzDmE,OAAO,EACP9D,uBACF,CAAC;EAED,OAAO;IAAEiE;EAAiB,CAAC;AAC7B,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,wBAAkD,GAAG,MAAAA,CAChER,UAAU,EACVC,UAAU,EACVQ,MAAM,EACNC,OAAO,KACJ;EACH,IAAID,MAAM,KAAK,WAAW,EAAE;IAC1B,OAAOV,6BAA6B,CAClCC,UAAU,EACVC,UAAU,EACVQ,MAAM,EACNC,OACF,CAAC;EACH;EAEA,MAAMvD,CAAQ,GAAGsD,MAAM;EACvB,MAAM,IAAI7E,aAAa,CAAE,kCAAiCuB,CAAE,EAAC,CAAC;AAChE,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["credential/issuance/08-confirm-credential.ts"],"mappings":""}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["ASSERTION_TYPE"],"sourceRoot":"../../../../src","sources":["credential/issuance/const.ts"],"mappings":"AAAA,OAAO,
|
1
|
+
{"version":3,"names":["z","ASSERTION_TYPE","SupportedCredentialFormat","literal"],"sourceRoot":"../../../../src","sources":["credential/issuance/const.ts"],"mappings":"AAAA,OAAO,KAAKA,CAAC,MAAM,KAAK;AACxB,OAAO,MAAMC,cAAc,GACzB,oEAAoE;AAKtE,OAAO,MAAMC,yBAAyB,GAAGF,CAAC,CAACG,OAAO,CAAC,WAAW,CAAC"}
|
@@ -2,5 +2,6 @@ import { evaluateIssuerTrust } from "./02-evaluate-issuer-trust";
|
|
2
2
|
import { startUserAuthorization } from "./03-start-user-authorization";
|
3
3
|
import { authorizeAccess } from "./05-authorize-access";
|
4
4
|
import { obtainCredential } from "./06-obtain-credential";
|
5
|
-
|
5
|
+
import { verifyAndParseCredential } from "./07-verify-and-parse-credential";
|
6
|
+
export { evaluateIssuerTrust, startUserAuthorization, authorizeAccess, obtainCredential, verifyAndParseCredential };
|
6
7
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["evaluateIssuerTrust","startUserAuthorization","authorizeAccess","obtainCredential"],"sourceRoot":"../../../../src","sources":["credential/issuance/index.ts"],"mappings":"AACA,SACEA,mBAAmB,QAEd,4BAA4B;AACnC,SACEC,sBAAsB,QAEjB,+BAA+B;AAEtC,SAASC,eAAe,QAA8B,uBAAuB;AAC7E,SACEC,gBAAgB,QAEX,wBAAwB;
|
1
|
+
{"version":3,"names":["evaluateIssuerTrust","startUserAuthorization","authorizeAccess","obtainCredential","verifyAndParseCredential"],"sourceRoot":"../../../../src","sources":["credential/issuance/index.ts"],"mappings":"AACA,SACEA,mBAAmB,QAEd,4BAA4B;AACnC,SACEC,sBAAsB,QAEjB,+BAA+B;AAEtC,SAASC,eAAe,QAA8B,uBAAuB;AAC7E,SACEC,gBAAgB,QAEX,wBAAwB;AAC/B,SACEC,wBAAwB,QAEnB,kCAAkC;AAGzC,SACEJ,mBAAmB,EACnBC,sBAAsB,EACtBC,eAAe,EACfC,gBAAgB,EAChBC,wBAAwB"}
|
package/lib/module/index.js
CHANGED
@@ -3,10 +3,11 @@
|
|
3
3
|
import "react-native-url-polyfill/auto";
|
4
4
|
import * as Credential from "./credential";
|
5
5
|
import * as PID from "./pid";
|
6
|
+
import * as SdJwt from "./sd-jwt";
|
6
7
|
import * as Errors from "./utils/errors";
|
7
8
|
import * as WalletInstanceAttestation from "./wallet-instance-attestation";
|
8
9
|
import * as Trust from "./trust";
|
9
10
|
import { AuthorizationDetail, AuthorizationDetails } from "./utils/par";
|
10
11
|
import { createCryptoContextFor } from "./utils/crypto";
|
11
|
-
export { PID, Credential, WalletInstanceAttestation, Errors, Trust, createCryptoContextFor, AuthorizationDetail, AuthorizationDetails };
|
12
|
+
export { SdJwt, PID, Credential, WalletInstanceAttestation, Errors, Trust, createCryptoContextFor, AuthorizationDetail, AuthorizationDetails };
|
12
13
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["Credential","PID","Errors","WalletInstanceAttestation","Trust","AuthorizationDetail","AuthorizationDetails","createCryptoContextFor"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA;AACA;AACA,OAAO,gCAAgC;AAEvC,OAAO,KAAKA,UAAU,MAAM,cAAc;AAC1C,OAAO,KAAKC,GAAG,MAAM,OAAO;AAC5B,OAAO,KAAKC,MAAM,MAAM,gBAAgB;AACxC,OAAO,KAAKC,yBAAyB,MAAM,+BAA+B;AAC1E,OAAO,KAAKC,KAAK,MAAM,SAAS;AAChC,SAASC,mBAAmB,EAAEC,oBAAoB,QAAQ,aAAa;AACvE,SAASC,sBAAsB,QAAQ,gBAAgB;AAEvD,SACEN,GAAG,EACHD,UAAU,
|
1
|
+
{"version":3,"names":["Credential","PID","SdJwt","Errors","WalletInstanceAttestation","Trust","AuthorizationDetail","AuthorizationDetails","createCryptoContextFor"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA;AACA;AACA,OAAO,gCAAgC;AAEvC,OAAO,KAAKA,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,SAASC,mBAAmB,EAAEC,oBAAoB,QAAQ,aAAa;AACvE,SAASC,sBAAsB,QAAQ,gBAAgB;AAEvD,SACEN,KAAK,EACLD,GAAG,EACHD,UAAU,EACVI,yBAAyB,EACzBD,MAAM,EACNE,KAAK,EACLG,sBAAsB,EACtBF,mBAAmB,EACnBC,oBAAoB"}
|
@@ -1,8 +1,9 @@
|
|
1
|
+
import { z } from "zod";
|
1
2
|
import { decode, disclose } from "../index";
|
2
3
|
import { encodeBase64, decodeBase64 } from "@pagopa/io-react-native-jwt";
|
3
4
|
import { SdJwt4VC } from "../types";
|
4
5
|
|
5
|
-
// Examples from https://www.ietf.org/id/draft-terbu-sd-jwt-vc-02.html#name-example-4
|
6
|
+
// Examples from https://www.ietf.org/archive/id/draft-terbu-sd-jwt-vc-02.html#name-example-4
|
6
7
|
// but adapted to adhere to format declared in https://italia.github.io/eudi-wallet-it-docs/versione-corrente/en/pid-eaa-data-model.html#id2
|
7
8
|
// In short, the token is a Frankenstein composed as follows:
|
8
9
|
// - the header is taken from the italian specification, with kid and alg valued according to the signing keys
|
@@ -75,6 +76,37 @@ describe("decode", () => {
|
|
75
76
|
}))
|
76
77
|
});
|
77
78
|
});
|
79
|
+
it("should decode with default decoder", () => {
|
80
|
+
const result = decode(token);
|
81
|
+
expect(result).toEqual({
|
82
|
+
sdJwt,
|
83
|
+
disclosures: disclosures.map((decoded, i) => ({
|
84
|
+
decoded,
|
85
|
+
encoded: tokenizedDisclosures[i]
|
86
|
+
}))
|
87
|
+
});
|
88
|
+
});
|
89
|
+
it("should accept only decoders that extend SdJwt4VC", () => {
|
90
|
+
const validDecoder = SdJwt4VC.and(z.object({
|
91
|
+
payload: z.object({
|
92
|
+
customField: z.string()
|
93
|
+
})
|
94
|
+
}));
|
95
|
+
const invalidDecoder = z.object({
|
96
|
+
payload: z.object({
|
97
|
+
customField: z.string()
|
98
|
+
})
|
99
|
+
});
|
100
|
+
try {
|
101
|
+
// ts is fine
|
102
|
+
decode(token, validDecoder);
|
103
|
+
// @ts-expect-error break types
|
104
|
+
decode(token, invalidDecoder);
|
105
|
+
} catch (error) {
|
106
|
+
// ignore actual result, just focus on types
|
107
|
+
// spot the error during type checking phase
|
108
|
+
}
|
109
|
+
});
|
78
110
|
});
|
79
111
|
describe("disclose", () => {
|
80
112
|
it("should encode a valid sdjwt (one claim)", async () => {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["decode","disclose","encodeBase64","decodeBase64","SdJwt4VC","token","unsigned","signature","signed","tokenizedDisclosures","sdJwt","header","typ","alg","kid","trust_chain","payload","iss","sub","jti","iat","exp","status","cnf","jwk","kty","use","n","e","type","verified_claims","verification","_sd","trust_framework","assurance_level","claims","_sd_alg","disclosures","street_address","locality","region","country","it","expect","JSON","parse","stringify","toEqual","join","toBe","describe","result","map","decoded","i","encoded","expected","paths","claim","path","fn","rejects","any","Error"],"sourceRoot":"../../../../src","sources":["sd-jwt/__test__/index.test.ts"],"mappings":"AAAA,SAASA,MAAM,EAAEC,QAAQ,QAAQ,UAAU;AAE3C,SAASC,YAAY,EAAEC,YAAY,QAAQ,6BAA6B;AACxE,SAASC,QAAQ,QAAQ,UAAU;;AAEnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,KAAK,GACT,kvEAAkvE;AAEpvE,MAAMC,QAAQ,GACZ,87CAA87C;AAEh8C,MAAMC,SAAS,GACb,wFAAwF;AAE1F,MAAMC,MAAM,GAAI,GAAEF,QAAS,IAAGC,SAAU,EAAC;AAEzC,MAAME,oBAAoB,GAAG,CAC3B,kEAAkE,EAClE,kEAAkE,EAClE,gFAAgF,EAChF,oFAAoF,EACpF,yEAAyE,EACzE,gEAAgE,EAChE,gEAAgE,EAChE,gEAAgE,EAChE,qLAAqL,CACtL;AAED,MAAMC,KAAK,GAAG;EACZC,MAAM,EAAE;IACNC,GAAG,EAAE,WAAW;IAChBC,GAAG,EAAE,OAAO;IACZC,GAAG,EAAE,kCAAkC;IACvCC,WAAW,EAAE,CACX,kCA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SAAS,EACT;EACEC,cAAc,EAAE,aAAa;EAC7BC,QAAQ,EAAE,SAAS;EACnBC,MAAM,EAAE,UAAU;EAClBC,OAAO,EAAE;AACX,CAAC,CACF,CACF;AACDC,EAAE,CAAC,kCAAkC,EAAE,MAAM;EAC3CC,MAAM,CACJC,IAAI,CAACC,KAAK,CAAC1C,YAAY,CAACD,YAAY,CAAC0C,IAAI,CAACE,SAAS,CAACpC,KAAK,CAACC,MAAM,CAAC,CAAC,CAAC,CACrE,CAAC,CAACoC,OAAO,CAACrC,KAAK,CAACC,MAAM,CAAC;EACvBgC,MAAM,CAAC,CAACnC,MAAM,EAAE,GAAGC,oBAAoB,CAAC,CAACuC,IAAI,CAAC,GAAG,CAAC,CAAC,CAACC,IAAI,CAAC5C,KAAK,CAAC;AACjE,CAAC,CAAC;AAEF6C,QAAQ,CAAC,QAAQ,EAAE,MAAM;EACvBR,EAAE,CAAC,6BAA6B,EAAE,MAAM;IACtC,MAAMS,MAAM,GAAGnD,MAAM,CAACK,KAAK,EAAED,QAAQ,CAAC;IACtCuC,MAAM,CAACQ,MAAM,CAAC,CAACJ,OAAO,CAAC;MACrBrC,KAAK;MACL2B,WAAW,EAAEA,WAAW,CAACe,GAAG,CAAC,CAACC,OAAO,EAAEC,CAAC,MAAM;QAC5CD,OAAO;QACPE,OAAO,EAAE9C,oBAAoB,CAAC6C,CAAC;MACjC,CAAC,CAAC;IACJ,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC;
|
1
|
+
{"version":3,"names":["z","decode","disclose","encodeBase64","decodeBase64","SdJwt4VC","token","unsigned","signature","signed","tokenizedDisclosures","sdJwt","header","typ","alg","kid","trust_chain","payload","iss","sub","jti","iat","exp","status","cnf","jwk","kty","use","n","e","type","verified_claims","verification","_sd","trust_framework","assurance_level","claims","_sd_alg","disclosures","street_address","locality","region","country","it","expect","JSON","parse","stringify","toEqual","join","toBe","describe","result","map","decoded","i","encoded","validDecoder","and","object","customField","string","invalidDecoder","error","expected","paths","claim","path","fn","rejects","any","Error"],"sourceRoot":"../../../../src","sources":["sd-jwt/__test__/index.test.ts"],"mappings":"AAAA,SAASA,CAAC,QAAQ,KAAK;AACvB,SAASC,MAAM,EAAEC,QAAQ,QAAQ,UAAU;AAE3C,SAASC,YAAY,EAAEC,YAAY,QAAQ,6BAA6B;AACxE,SAASC,QAAQ,QAAQ,UAAU;;AAEnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,KAAK,GACT,kvEAAkvE;AAEpvE,MAAMC,QAAQ,GACZ,87CAA87C;AAEh8C,MAAMC,SAAS,GACb,wFAAwF;AAE1F,MAAMC,MAAM,GAAI,GAAEF,QAAS,IAAGC,SAAU,EAAC;AAEzC,MAAME,oBAAoB,GAAG,CAC3B,kEAAkE,EAClE,kEAAkE,EAClE,gFAAgF,EAChF,oFAAoF,EACpF,yEAAyE,EACzE,gEAAgE,EAChE,gEAAgE,EAChE,gEAAgE,EAChE,qLAAqL,CACtL;AAED,MAAMC,KAAK,GAAG;EACZC,MAAM,EAAE;IACNC,GAAG,EAAE,WAAW;IAChBC,GAAG,EAAE,OAAO;IACZC,GAAG,EAAE,kCAAkC;IACvCC,WAAW,EAAE,CACX,kCAAkC,EAClC,kCAAkC,EAClC,kCAAkC;EAEtC,CAAC;EACDC,OAAO,EAAE;IACPC,GAAG,EAAE,4BAA4B;IACjCC,GAAG,EAAE,sCAAsC;IAC3CC,GAAG,EAAE,+CAA+C;IACpDC,GAAG,EAAE,UAAU;IACfC,GAAG,EAAE,UAAU;IACfC,MAAM,EAAE,4BAA4B;IACpCC,GAAG,EAAE;MACHC,GAAG,EAAE;QACHC,GAAG,EAAE,KAAK;QACVC,GAAG,EAAE,KAAK;QACVC,CAAC,EAAE,QAAQ;QACXC,CAAC,EAAE,MAAM;QACTd,GAAG,EAAE;MACP;IACF,CAAC;IACDe,IAAI,EAAE,0BAA0B;IAChCC,eAAe,EAAE;MACfC,YAAY,EAAE;QACZC,GAAG,EAAE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C,IAAI,EAAE;MACR,CAAC;IAEL,CAAC;IAEDvB,MAAM,CAACQ,MAAM,CAAC,CAACJ,OAAO,CAACgB,QAAQ,CAAC;EAClC,CAAC,CAAC;EAEFrB,EAAE,CAAC,8BAA8B,EAAE,YAAY;IAC7C,MAAMyB,EAAE,GAAG,MAAAA,CAAA,KAAYlE,QAAQ,CAACI,KAAK,EAAE,CAAC,SAAS,CAAC,CAAC;IAEnD,MAAMsC,MAAM,CAACwB,EAAE,CAAC,CAAC,CAAC,CAACC,OAAO,CAACrB,OAAO,CAACJ,MAAM,CAAC0B,GAAG,CAACC,KAAK,CAAC,CAAC;EACvD,CAAC,CAAC;AACJ,CAAC,CAAC"}
|
@@ -22,12 +22,12 @@ const decodeDisclosure = encoded => {
|
|
22
22
|
*
|
23
23
|
* @function
|
24
24
|
* @param token The encoded token that represents a valid sd-jwt for verifiable credentials
|
25
|
-
* @param
|
25
|
+
* @param customSchema (optional) Schema to use to parse the SD-JWT. Default: SdJwt4VC
|
26
26
|
*
|
27
27
|
* @returns The parsed SD-JWT token and the parsed disclosures
|
28
28
|
*
|
29
29
|
*/
|
30
|
-
export const decode = (token,
|
30
|
+
export const decode = (token, customSchema) => {
|
31
31
|
// token are expected in the form "sd-jwt~disclosure0~disclosure1~...~disclosureN~"
|
32
32
|
if (token.slice(-1) === "~") {
|
33
33
|
token = token.slice(0, -1);
|
@@ -37,7 +37,10 @@ export const decode = (token, schema) => {
|
|
37
37
|
// get the sd-jwt as object
|
38
38
|
// validate it's a valid SD-JWT for Verifiable Credentials
|
39
39
|
const decodedJwt = decodeJwt(rawSdJwt);
|
40
|
-
|
40
|
+
|
41
|
+
// use a custom parsed if provided, otherwise use base SdJwt4VC
|
42
|
+
const parser = customSchema || SdJwt4VC;
|
43
|
+
const sdJwt = parser.parse({
|
41
44
|
header: decodedJwt.protectedHeader,
|
42
45
|
payload: decodedJwt.payload
|
43
46
|
});
|
@@ -130,15 +133,15 @@ export const disclose = async (token, claims) => {
|
|
130
133
|
*
|
131
134
|
* @param token The encoded token that represents a valid sd-jwt for verifiable credentials
|
132
135
|
* @param publicKey The single public key or an array of public keys to validate the signature.
|
133
|
-
* @param
|
136
|
+
* @param customSchema Schema to use to parse the SD-JWT
|
134
137
|
*
|
135
138
|
* @returns The parsed SD-JWT token and the parsed disclosures
|
136
139
|
*
|
137
140
|
*/
|
138
|
-
export const verify = async (token, publicKey,
|
141
|
+
export const verify = async (token, publicKey, customSchema) => {
|
139
142
|
// get decoded data
|
140
143
|
const [rawSdJwt = ""] = token.split("~");
|
141
|
-
const decoded = decode(token,
|
144
|
+
const decoded = decode(token, customSchema);
|
142
145
|
|
143
146
|
//Check signature
|
144
147
|
await verifyJwt(rawSdJwt, publicKey);
|
@@ -151,4 +154,5 @@ export const verify = async (token, publicKey, schema) => {
|
|
151
154
|
disclosures: decoded.disclosures.map(d => d.decoded)
|
152
155
|
};
|
153
156
|
};
|
157
|
+
export { SdJwt4VC };
|
154
158
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["decode","decodeJwt","verify","verifyJwt","sha256ToBase64","decodeBase64","Disclosure","SdJwt4VC","verifyDisclosure","ClaimsNotFoundBetweenDislosures","ClaimsNotFoundInToken","decodeDisclosure","encoded","decoded","parse","JSON","token","
|
1
|
+
{"version":3,"names":["decode","decodeJwt","verify","verifyJwt","sha256ToBase64","decodeBase64","Disclosure","SdJwt4VC","verifyDisclosure","ClaimsNotFoundBetweenDislosures","ClaimsNotFoundInToken","decodeDisclosure","encoded","decoded","parse","JSON","token","customSchema","slice","rawSdJwt","rawDisclosures","split","decodedJwt","parser","sdJwt","header","protectedHeader","payload","disclosures","map","disclose","claims","paths","Promise","all","claim","disclosure","find","_ref","name","hash","verified_claims","_sd","includes","index","indexOf","path","verification","filteredDisclosures","filter","d","disclosedToken","join","publicKey"],"sourceRoot":"../../../src","sources":["sd-jwt/index.ts"],"mappings":"AAEA,SAASA,MAAM,IAAIC,SAAS,QAAQ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e,CAACV,MAAM,CAACW,GAAG,CACpD;EAED,MAAMT,OAAO,CAACC,GAAG,CACfrB,OAAO,CAACe,WAAW,CAACC,GAAG,CACrB,MAAOO,UAAU,IAAK,MAAM5B,gBAAgB,CAAC4B,UAAU,EAAEL,MAAM,CACjE,CACF,CAAC;EAED,OAAO;IACLP,KAAK,EAAEX,OAAO,CAACW,KAAK;IACpBI,WAAW,EAAEf,OAAO,CAACe,WAAW,CAACC,GAAG,CAAEqB,CAAC,IAAKA,CAAC,CAACrC,OAAO;EACvD,CAAC;AACH,CAAC;AAED,SAASN,QAAQ"}
|
@@ -20,7 +20,7 @@ export const Disclosure = z.tuple([/* salt */z.string(), /* claim name */z.strin
|
|
20
20
|
* For such reason, we may find conveninent to have encoded and decode values stored explicitly in the same structure.
|
21
21
|
* Please note that `encoded` can always decode into `decode`, but `decode` may or may not be encoded with the same value of `encoded`
|
22
22
|
*
|
23
|
-
* @see https://www.ietf.org/id/draft-ietf-oauth-selective-disclosure-jwt-05.html#name-disclosures-for-object-prop
|
23
|
+
* @see https://www.ietf.org/archive/id/draft-ietf-oauth-selective-disclosure-jwt-05.html#name-disclosures-for-object-prop
|
24
24
|
*/
|
25
25
|
|
26
26
|
export const SdJwt4VC = z.object({
|
@@ -71,12 +71,17 @@ export const EntityConfigurationHeader = z.object({
|
|
71
71
|
alg: z.string(),
|
72
72
|
kid: z.string()
|
73
73
|
});
|
74
|
+
|
75
|
+
/**
|
76
|
+
* @see https://openid.net/specs/openid-connect-federation-1_0-29.html#name-federation-entity
|
77
|
+
*/
|
74
78
|
const FederationEntityMetadata = z.object({
|
75
79
|
federation_fetch_endpoint: z.string().optional(),
|
76
80
|
federation_list_endpoint: z.string().optional(),
|
77
81
|
federation_resolve_endpoint: z.string().optional(),
|
78
82
|
federation_trust_mark_status_endpoint: z.string().optional(),
|
79
83
|
federation_trust_mark_list_endpoint: z.string().optional(),
|
84
|
+
organization_name: z.string().optional(),
|
80
85
|
homepage_uri: z.string().optional(),
|
81
86
|
policy_uri: z.string().optional(),
|
82
87
|
logo_uri: z.string().optional(),
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["UnixTime","JWK","z","TrustMark","object","id","string","trust_mark","RelyingPartyMetadata","application_type","optional","client_id","client_name","jwks","keys","array","contacts","CredentialDisplayMetadata","name","locale","logo","url","alt_text","background_color","text_color","CredentialDefinitionMetadata","type","credentialSubject","record","mandatory","boolean","display","SupportedCredentialMetadata","format","literal","cryptographic_binding_methods_supported","cryptographic_suites_supported","credential_definition","EntityStatement","header","typ","alg","kid","payload","iss","sub","trust_marks","iat","number","exp","EntityConfigurationHeader","FederationEntityMetadata","federation_fetch_endpoint","federation_list_endpoint","federation_resolve_endpoint","federation_trust_mark_status_endpoint","federation_trust_mark_list_endpoint","homepage_uri","policy_uri","logo_uri","passthrough","BaseEntityConfiguration","metadata","federation_entity","authority_hints","TrustAnchorEntityConfiguration","CredentialIssuerEntityConfiguration","and","openid_credential_issuer","credential_issuer","authorization_endpoint","token_endpoint","pushed_authorization_request_endpoint","dpop_signing_alg_values_supported","credential_endpoint","credentials_supported","wallet_relying_party","RelyingPartyEntityConfiguration","WalletProviderEntityConfiguration","wallet_provider","attested_security_context_values_supported","grant_types_supported","token_endpoint_auth_methods_supported","token_endpoint_auth_signing_alg_values_supported","EntityConfiguration","union","description"],"sourceRoot":"../../../src","sources":["trust/types.ts"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,iBAAiB;AAC1C,SAASC,GAAG,QAAQ,cAAc;AAClC,OAAO,KAAKC,CAAC,MAAM,KAAK;AAExB,OAAO,MAAMC,SAAS,GAAGD,CAAC,CAACE,MAAM,CAAC;EAAEC,EAAE,EAAEH,CAAC,CAACI,MAAM,CAAC,CAAC;EAAEC,UAAU,EAAEL,CAAC,CAACI,MAAM,CAAC;AAAE,CAAC,CAAC;AAG7E,MAAME,oBAAoB,GAAGN,CAAC,CAACE,MAAM,CAAC;EACpCK,gBAAgB,EAAEP,CAAC,CAACI,MAAM,CA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C,CAAC;IACfC,GAAG,EAAE/C,CAAC,CAAC8C,MAAM,CAAC;EAChB,CAAC;AACH,CAAC,CAAC;AAKF,OAAO,MAAME,yBAAyB,GAAGhD,CAAC,CAACE,MAAM,CAAC;EAChDoC,GAAG,EAAEtC,CAAC,CAACgC,OAAO,CAAC,sBAAsB,CAAC;EACtCO,GAAG,EAAEvC,CAAC,CAACI,MAAM,CAAC,CAAC;EACfoC,GAAG,EAAExC,CAAC,CAACI,MAAM,CAAC;AAChB,CAAC,CAAC;
|
1
|
+
{"version":3,"names":["UnixTime","JWK","z","TrustMark","object","id","string","trust_mark","RelyingPartyMetadata","application_type","optional","client_id","client_name","jwks","keys","array","contacts","CredentialDisplayMetadata","name","locale","logo","url","alt_text","background_color","text_color","CredentialDefinitionMetadata","type","credentialSubject","record","mandatory","boolean","display","SupportedCredentialMetadata","format","literal","cryptographic_binding_methods_supported","cryptographic_suites_supported","credential_definition","EntityStatement","header","typ","alg","kid","payload","iss","sub","trust_marks","iat","number","exp","EntityConfigurationHeader","FederationEntityMetadata","federation_fetch_endpoint","federation_list_endpoint","federation_resolve_endpoint","federation_trust_mark_status_endpoint","federation_trust_mark_list_endpoint","organization_name","homepage_uri","policy_uri","logo_uri","passthrough","BaseEntityConfiguration","metadata","federation_entity","authority_hints","TrustAnchorEntityConfiguration","CredentialIssuerEntityConfiguration","and","openid_credential_issuer","credential_issuer","authorization_endpoint","token_endpoint","pushed_authorization_request_endpoint","dpop_signing_alg_values_supported","credential_endpoint","credentials_supported","wallet_relying_party","RelyingPartyEntityConfiguration","WalletProviderEntityConfiguration","wallet_provider","attested_security_context_values_supported","grant_types_supported","token_endpoint_auth_methods_supported","token_endpoint_auth_signing_alg_values_supported","EntityConfiguration","union","description"],"sourceRoot":"../../../src","sources":["trust/types.ts"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,iBAAiB;AAC1C,SAASC,GAAG,QAAQ,cAAc;AAClC,OAAO,KAAKC,CAAC,MAAM,KAAK;AAExB,OAA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,CAACE,MAAM,CAAC;MACjB4E,eAAe,EAAE9E,CAAC,CACfE,MAAM,CAAC;QACNoE,cAAc,EAAEtE,CAAC,CAACI,MAAM,CAAC,CAAC;QAC1B2E,0CAA0C,EAAE/E,CAAC,CAC1Ca,KAAK,CAACb,CAAC,CAACI,MAAM,CAAC,CAAC,CAAC,CACjBI,QAAQ,CAAC,CAAC;QACbwE,qBAAqB,EAAEhF,CAAC,CAACa,KAAK,CAACb,CAAC,CAACI,MAAM,CAAC,CAAC,CAAC;QAC1C6E,qCAAqC,EAAEjF,CAAC,CAACa,KAAK,CAACb,CAAC,CAACI,MAAM,CAAC,CAAC,CAAC;QAC1D8E,gDAAgD,EAAElF,CAAC,CAACa,KAAK,CACvDb,CAAC,CAACI,MAAM,CAAC,CACX,CAAC;QACDO,IAAI,EAAEX,CAAC,CAACE,MAAM,CAAC;UAAEU,IAAI,EAAEZ,CAAC,CAACa,KAAK,CAACd,GAAG;QAAE,CAAC;MACvC,CAAC,CAAC,CACD4D,WAAW,CAAC;IACjB,CAAC;EACH,CAAC;AACH,CAAC,CACH,CAAC;;AAED;;AAEA,OAAO,MAAMwB,mBAAmB,GAAGnF,CAAC,CAACoF,KAAK,CACxC,CACEP,iCAAiC,EACjCZ,mCAAmC,EACnCD,8BAA8B,EAC9BY,+BAA+B,CAChC,EACD;EACES,WAAW,EAAE;AACf,CACF,CAAC"}
|
package/lib/module/utils/misc.js
CHANGED
@@ -5,9 +5,9 @@ import { IoWalletError } from "./errors";
|
|
5
5
|
* @param status The expected status
|
6
6
|
* @returns The given response object
|
7
7
|
*/
|
8
|
-
export const hasStatus = status => res => {
|
8
|
+
export const hasStatus = status => async res => {
|
9
9
|
if (res.status !== status) {
|
10
|
-
throw new IoWalletError(`Http request failed. Expected ${status}, got ${res.status}, url: ${res.url}`);
|
10
|
+
throw new IoWalletError(`Http request failed. Expected ${status}, got ${res.status}, url: ${res.url} with response: ${await res.text()}`);
|
11
11
|
}
|
12
12
|
return res;
|
13
13
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["IoWalletError","hasStatus","status","res","url"],"sourceRoot":"../../../src","sources":["utils/misc.ts"],"mappings":"AAAA,SAASA,aAAa,QAAQ,UAAU;;AAExC;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,SAAS,GACnBC,MAAc,
|
1
|
+
{"version":3,"names":["IoWalletError","hasStatus","status","res","url","text"],"sourceRoot":"../../../src","sources":["utils/misc.ts"],"mappings":"AAAA,SAASA,aAAa,QAAQ,UAAU;;AAExC;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,SAAS,GACnBC,MAAc,IACf,MAAOC,GAAa,IAAwB;EAC1C,IAAIA,GAAG,CAACD,MAAM,KAAKA,MAAM,EAAE;IACzB,MAAM,IAAIF,aAAa,CACpB,iCAAgCE,MAAO,SAAQC,GAAG,CAACD,MAAO,UACzDC,GAAG,CAACC,GACL,mBAAkB,MAAMD,GAAG,CAACE,IAAI,CAAC,CAAE,EACtC,CAAC;EACH;EACA,OAAOF,GAAG;AACZ,CAAC;;AAEH;AACA"}
|
@@ -3,6 +3,7 @@ import type { StartFlow } from "./01-start-flow";
|
|
3
3
|
import { type Out } from "../../utils/misc";
|
4
4
|
import type { EvaluateIssuerTrust } from "./02-evaluate-issuer-trust";
|
5
5
|
import type { AuthorizeAccess } from "./05-authorize-access";
|
6
|
+
import { SupportedCredentialFormat } from "./const";
|
6
7
|
/**
|
7
8
|
* Return the signed jwt for nonce proof of possession
|
8
9
|
*/
|
@@ -13,7 +14,7 @@ export type ObtainCredential = (issuerConf: Out<EvaluateIssuerTrust>["issuerConf
|
|
13
14
|
appFetch?: GlobalFetch["fetch"];
|
14
15
|
}) => Promise<{
|
15
16
|
credential: string;
|
16
|
-
format:
|
17
|
+
format: SupportedCredentialFormat;
|
17
18
|
}>;
|
18
19
|
/**
|
19
20
|
* Fetch a credential from the issuer
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"06-obtain-credential.d.ts","sourceRoot":"","sources":["../../../../src/credential/issuance/06-obtain-credential.ts"],"names":[],"mappings":"AAEA,OAAO,EAAW,KAAK,aAAa,EAAE,MAAM,6BAA6B,CAAC;
|
1
|
+
{"version":3,"file":"06-obtain-credential.d.ts","sourceRoot":"","sources":["../../../../src/credential/issuance/06-obtain-credential.ts"],"names":[],"mappings":"AAEA,OAAO,EAAW,KAAK,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAG1E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAa,KAAK,GAAG,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AAEpD;;GAEG;AACH,eAAO,MAAM,gBAAgB,UACpB,MAAM,UACL,MAAM,YACJ,MAAM,OACX,aAAa,KACjB,QAAQ,MAAM,CAchB,CAAC;AAOF,MAAM,MAAM,gBAAgB,GAAG,CAC7B,UAAU,EAAE,GAAG,CAAC,mBAAmB,CAAC,CAAC,YAAY,CAAC,EAClD,WAAW,EAAE,GAAG,CAAC,eAAe,CAAC,CAAC,aAAa,CAAC,EAChD,KAAK,EAAE,GAAG,CAAC,eAAe,CAAC,CAAC,OAAO,CAAC,EACpC,QAAQ,EAAE,GAAG,CAAC,eAAe,CAAC,CAAC,UAAU,CAAC,EAC1C,cAAc,EAAE,GAAG,CAAC,SAAS,CAAC,CAAC,gBAAgB,CAAC,EAChD,OAAO,EAAE;IACP,uBAAuB,EAAE,aAAa,CAAC;IACvC,qBAAqB,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;CACjC,KACE,OAAO,CAAC;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,yBAAyB,CAAA;CAAE,CAAC,CAAC;AAExE;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,gBAAgB,EAAE,gBAgE9B,CAAC"}
|