@pagopa/io-react-native-wallet 0.4.3 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +128 -19
- package/lib/commonjs/index.js +16 -23
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/pid/index.js +3 -8
- package/lib/commonjs/pid/index.js.map +1 -1
- package/lib/commonjs/pid/issuing.js +153 -176
- package/lib/commonjs/pid/issuing.js.map +1 -1
- package/lib/commonjs/rp/__test__/index.test.js +7 -5
- package/lib/commonjs/rp/__test__/index.test.js.map +1 -1
- package/lib/commonjs/rp/index.js +145 -155
- package/lib/commonjs/rp/index.js.map +1 -1
- package/lib/commonjs/rp/types.js +1 -21
- package/lib/commonjs/rp/types.js.map +1 -1
- package/lib/commonjs/trust/index.js +24 -5
- package/lib/commonjs/trust/index.js.map +1 -1
- package/lib/commonjs/trust/types.js +102 -9
- package/lib/commonjs/trust/types.js.map +1 -1
- package/lib/commonjs/utils/crypto.js +46 -0
- package/lib/commonjs/utils/crypto.js.map +1 -0
- package/lib/commonjs/utils/dpop.js +14 -7
- package/lib/commonjs/utils/dpop.js.map +1 -1
- package/lib/commonjs/wallet-instance-attestation/index.js +3 -3
- package/lib/commonjs/wallet-instance-attestation/issuing.js +42 -60
- package/lib/commonjs/wallet-instance-attestation/issuing.js.map +1 -1
- package/lib/module/index.js +4 -6
- package/lib/module/index.js.map +1 -1
- package/lib/module/pid/index.js +1 -1
- package/lib/module/pid/index.js.map +1 -1
- package/lib/module/pid/issuing.js +152 -180
- package/lib/module/pid/issuing.js.map +1 -1
- package/lib/module/rp/__test__/index.test.js +3 -3
- package/lib/module/rp/__test__/index.test.js.map +1 -1
- package/lib/module/rp/index.js +141 -154
- package/lib/module/rp/index.js.map +1 -1
- package/lib/module/rp/types.js +0 -20
- package/lib/module/rp/types.js.map +1 -1
- package/lib/module/trust/index.js +19 -5
- package/lib/module/trust/index.js.map +1 -1
- package/lib/module/trust/types.js +100 -7
- package/lib/module/trust/types.js.map +1 -1
- package/lib/module/utils/crypto.js +40 -0
- package/lib/module/utils/crypto.js.map +1 -0
- package/lib/module/utils/dpop.js +13 -5
- package/lib/module/utils/dpop.js.map +1 -1
- package/lib/module/wallet-instance-attestation/index.js +2 -2
- package/lib/module/wallet-instance-attestation/index.js.map +1 -1
- package/lib/module/wallet-instance-attestation/issuing.js +40 -58
- package/lib/module/wallet-instance-attestation/issuing.js.map +1 -1
- package/lib/typescript/index.d.ts +4 -6
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/pid/index.d.ts +1 -1
- package/lib/typescript/pid/index.d.ts.map +1 -1
- package/lib/typescript/pid/issuing.d.ts +43 -88
- package/lib/typescript/pid/issuing.d.ts.map +1 -1
- package/lib/typescript/rp/index.d.ts +41 -87
- package/lib/typescript/rp/index.d.ts.map +1 -1
- package/lib/typescript/rp/types.d.ts +10 -906
- package/lib/typescript/rp/types.d.ts.map +1 -1
- package/lib/typescript/sd-jwt/index.d.ts +1 -1
- package/lib/typescript/sd-jwt/index.d.ts.map +1 -1
- package/lib/typescript/trust/index.d.ts +806 -3
- package/lib/typescript/trust/index.d.ts.map +1 -1
- package/lib/typescript/trust/types.d.ts +9655 -297
- package/lib/typescript/trust/types.d.ts.map +1 -1
- package/lib/typescript/utils/crypto.d.ts +10 -0
- package/lib/typescript/utils/crypto.d.ts.map +1 -0
- package/lib/typescript/utils/dpop.d.ts +10 -2
- package/lib/typescript/utils/dpop.d.ts.map +1 -1
- package/lib/typescript/wallet-instance-attestation/index.d.ts +2 -2
- package/lib/typescript/wallet-instance-attestation/index.d.ts.map +1 -1
- package/lib/typescript/wallet-instance-attestation/issuing.d.ts +18 -31
- package/lib/typescript/wallet-instance-attestation/issuing.d.ts.map +1 -1
- package/lib/typescript/wallet-instance-attestation/types.d.ts +4 -4
- package/package.json +2 -2
- package/src/index.ts +14 -13
- package/src/pid/index.ts +1 -1
- package/src/pid/issuing.ts +233 -232
- package/src/rp/__test__/index.test.ts +3 -3
- package/src/rp/index.ts +172 -194
- package/src/rp/types.ts +0 -24
- package/src/sd-jwt/index.ts +1 -1
- package/src/trust/index.ts +106 -5
- package/src/trust/types.ts +152 -34
- package/src/utils/crypto.ts +41 -0
- package/src/utils/dpop.ts +17 -7
- package/src/wallet-instance-attestation/index.ts +2 -2
- package/src/wallet-instance-attestation/issuing.ts +51 -63
- package/lib/commonjs/pid/metadata.js +0 -49
- package/lib/commonjs/pid/metadata.js.map +0 -1
- package/lib/module/pid/metadata.js +0 -41
- package/lib/module/pid/metadata.js.map +0 -1
- package/lib/typescript/pid/metadata.d.ts +0 -482
- package/lib/typescript/pid/metadata.d.ts.map +0 -1
- package/src/pid/metadata.ts +0 -46
@@ -5,6 +5,28 @@ export const TrustMark = z.object({
|
|
5
5
|
id: z.string(),
|
6
6
|
trust_mark: z.string()
|
7
7
|
});
|
8
|
+
|
9
|
+
// Display metadata for a credential, used by the issuer to
|
10
|
+
// instruct the Wallet Solution on how to render the credential correctly
|
11
|
+
const CredentialDisplayMetadata = z.object({
|
12
|
+
name: z.string(),
|
13
|
+
locale: z.string(),
|
14
|
+
logo: z.object({
|
15
|
+
url: z.string(),
|
16
|
+
alt_text: z.string()
|
17
|
+
}),
|
18
|
+
background_color: z.string(),
|
19
|
+
text_color: z.string()
|
20
|
+
});
|
21
|
+
|
22
|
+
// Metadata for a credentia which i supported by a Issuer
|
23
|
+
|
24
|
+
const SupportedCredentialMetadata = z.object({
|
25
|
+
format: z.literal("vc+sd-jwt"),
|
26
|
+
cryptographic_binding_methods_supported: z.array(z.string()),
|
27
|
+
cryptographic_suites_supported: z.array(z.string()),
|
28
|
+
display: z.array(CredentialDisplayMetadata)
|
29
|
+
});
|
8
30
|
export const EntityStatement = z.object({
|
9
31
|
header: z.object({
|
10
32
|
typ: z.literal("entity-statement+jwt"),
|
@@ -22,12 +44,15 @@ export const EntityStatement = z.object({
|
|
22
44
|
exp: z.number()
|
23
45
|
})
|
24
46
|
});
|
25
|
-
export const
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
47
|
+
export const EntityConfigurationHeader = z.object({
|
48
|
+
typ: z.literal("entity-statement+jwt"),
|
49
|
+
alg: z.string(),
|
50
|
+
kid: z.string()
|
51
|
+
});
|
52
|
+
|
53
|
+
// Structuire common to every Entity Configuration document
|
54
|
+
const BaseEntityConfiguration = z.object({
|
55
|
+
header: EntityConfigurationHeader,
|
31
56
|
payload: z.object({
|
32
57
|
exp: UnixTime,
|
33
58
|
iat: UnixTime,
|
@@ -50,7 +75,75 @@ export const EntityConfiguration = z.object({
|
|
50
75
|
}).passthrough()
|
51
76
|
}).passthrough(),
|
52
77
|
authority_hints: z.array(z.string()).optional()
|
78
|
+
}).passthrough()
|
79
|
+
});
|
80
|
+
|
81
|
+
// Entity configuration for a Trust Anchor (it has no specific metadata section)
|
82
|
+
|
83
|
+
export const TrustAnchorEntityConfiguration = BaseEntityConfiguration;
|
84
|
+
|
85
|
+
// Entity configuration for a Credential Issuer
|
86
|
+
|
87
|
+
export const CredentialIssuerEntityConfiguration = BaseEntityConfiguration.and(z.object({
|
88
|
+
payload: z.object({
|
89
|
+
jwks: z.object({
|
90
|
+
keys: z.array(JWK)
|
91
|
+
}),
|
92
|
+
metadata: z.object({
|
93
|
+
openid_credential_issuer: z.object({
|
94
|
+
credential_issuer: z.string(),
|
95
|
+
authorization_endpoint: z.string(),
|
96
|
+
token_endpoint: z.string(),
|
97
|
+
pushed_authorization_request_endpoint: z.string(),
|
98
|
+
dpop_signing_alg_values_supported: z.array(z.string()),
|
99
|
+
credential_endpoint: z.string(),
|
100
|
+
credentials_supported: z.array(SupportedCredentialMetadata),
|
101
|
+
jwks: z.object({
|
102
|
+
keys: z.array(JWK)
|
103
|
+
})
|
104
|
+
})
|
105
|
+
})
|
106
|
+
})
|
107
|
+
}));
|
108
|
+
|
109
|
+
// Entity configuration for a Wallet Provider
|
110
|
+
|
111
|
+
export const WalletProviderEntityConfiguration = BaseEntityConfiguration.and(z.object({
|
112
|
+
payload: z.object({
|
113
|
+
metadata: z.object({
|
114
|
+
wallet_provider: z.object({
|
115
|
+
token_endpoint: z.string(),
|
116
|
+
attested_security_context_values_supported: z.array(z.string()).optional(),
|
117
|
+
grant_types_supported: z.array(z.string()),
|
118
|
+
token_endpoint_auth_methods_supported: z.array(z.string()),
|
119
|
+
token_endpoint_auth_signing_alg_values_supported: z.array(z.string()),
|
120
|
+
jwks: z.object({
|
121
|
+
keys: z.array(JWK)
|
122
|
+
})
|
123
|
+
}).passthrough()
|
124
|
+
})
|
125
|
+
})
|
126
|
+
}));
|
127
|
+
|
128
|
+
// Entity configuration for a Relying Party
|
129
|
+
|
130
|
+
export const RelyingPartyEntityConfiguration = BaseEntityConfiguration.and(z.object({
|
131
|
+
payload: z.object({
|
132
|
+
metadata: z.object({
|
133
|
+
wallet_relying_party: z.object({
|
134
|
+
application_type: z.string().optional(),
|
135
|
+
client_id: z.string().optional(),
|
136
|
+
client_name: z.string().optional(),
|
137
|
+
jwks: z.array(JWK),
|
138
|
+
contacts: z.array(z.string()).optional()
|
139
|
+
}).passthrough()
|
140
|
+
})
|
53
141
|
})
|
142
|
+
}));
|
143
|
+
|
144
|
+
// Maps any entity configuration by the union of every possible shapes
|
145
|
+
|
146
|
+
export const EntityConfiguration = z.union([WalletProviderEntityConfiguration, CredentialIssuerEntityConfiguration, TrustAnchorEntityConfiguration, RelyingPartyEntityConfiguration], {
|
147
|
+
description: "Any kind of Entity Configuration allowed in the ecosystem"
|
54
148
|
});
|
55
|
-
export const TrustAnchorEntityConfiguration = EntityConfiguration;
|
56
149
|
//# sourceMappingURL=types.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["UnixTime","JWK","z","TrustMark","object","id","string","trust_mark","
|
1
|
+
{"version":3,"names":["UnixTime","JWK","z","TrustMark","object","id","string","trust_mark","CredentialDisplayMetadata","name","locale","logo","url","alt_text","background_color","text_color","SupportedCredentialMetadata","format","literal","cryptographic_binding_methods_supported","array","cryptographic_suites_supported","display","EntityStatement","header","typ","alg","kid","payload","iss","sub","jwks","keys","trust_marks","iat","number","exp","EntityConfigurationHeader","BaseEntityConfiguration","metadata","federation_entity","federation_fetch_endpoint","optional","federation_list_endpoint","federation_resolve_endpoint","federation_trust_mark_status_endpoint","federation_trust_mark_list_endpoint","homepage_uri","policy_uri","logo_uri","contacts","passthrough","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","WalletProviderEntityConfiguration","wallet_provider","attested_security_context_values_supported","grant_types_supported","token_endpoint_auth_methods_supported","token_endpoint_auth_signing_alg_values_supported","RelyingPartyEntityConfiguration","wallet_relying_party","application_type","client_id","client_name","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;AACA;AAEA,MAAME,yBAAyB,GAAGN,CAAC,CAACE,MAAM,CAAC;EACzCK,IAAI,EAAEP,CAAC,CAACI,MAAM,CAAC,CAAC;EAChBI,MAAM,EAAER,CAAC,CAACI,MAAM,CAAC,CAAC;EAClBK,IAAI,EAAET,CAAC,CAACE,MAAM,CAAC;IACbQ,GAAG,EAAEV,CAAC,CAACI,MAAM,CAAC,CAAC;IACfO,QAAQ,EAAEX,CAAC,CAACI,MAAM,CAAC;EACrB,CAAC,CAAC;EACFQ,gBAAgB,EAAEZ,CAAC,CAACI,MAAM,CAAC,CAAC;EAC5BS,UAAU,EAAEb,CAAC,CAACI,MAAM,CAAC;AACvB,CA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MACjBmE,oBAAoB,EAAErE,CAAC,CACpBE,MAAM,CAAC;QACNoE,gBAAgB,EAAEtE,CAAC,CAACI,MAAM,CAAC,CAAC,CAACoC,QAAQ,CAAC,CAAC;QACvC+B,SAAS,EAAEvE,CAAC,CAACI,MAAM,CAAC,CAAC,CAACoC,QAAQ,CAAC,CAAC;QAChCgC,WAAW,EAAExE,CAAC,CAACI,MAAM,CAAC,CAAC,CAACoC,QAAQ,CAAC,CAAC;QAClCX,IAAI,EAAE7B,CAAC,CAACkB,KAAK,CAACnB,GAAG,CAAC;QAClBiD,QAAQ,EAAEhD,CAAC,CAACkB,KAAK,CAAClB,CAAC,CAACI,MAAM,CAAC,CAAC,CAAC,CAACoC,QAAQ,CAAC;MACzC,CAAC,CAAC,CACDS,WAAW,CAAC;IACjB,CAAC;EACH,CAAC;AACH,CAAC,CACH,CAAC;;AAED;;AAEA,OAAO,MAAMwB,mBAAmB,GAAGzE,CAAC,CAAC0E,KAAK,CACxC,CACEZ,iCAAiC,EACjCV,mCAAmC,EACnCD,8BAA8B,EAC9BiB,+BAA+B,CAChC,EACD;EACEO,WAAW,EAAE;AACf,CACF,CAAC"}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
import { getPublicKey, sign } from "@pagopa/io-react-native-crypto";
|
2
|
+
import { thumbprint } from "@pagopa/io-react-native-jwt";
|
3
|
+
import { fixBase64EncodingOnKey } from "./jwk";
|
4
|
+
|
5
|
+
/**
|
6
|
+
* Create a CryptoContext bound to a key pair.
|
7
|
+
* Key pair is supposed to exist already in the device's keychain.
|
8
|
+
* It's identified by its unique keytag.
|
9
|
+
*
|
10
|
+
* @returns the crypto context
|
11
|
+
*/
|
12
|
+
export const createCryptoContextFor = keytag => {
|
13
|
+
return {
|
14
|
+
/**
|
15
|
+
* Retrieve the public key of the pair.
|
16
|
+
* If the key pair doesn't exist yet, an error is raised
|
17
|
+
* @returns The public key.
|
18
|
+
*/
|
19
|
+
async getPublicKey() {
|
20
|
+
return getPublicKey(keytag).then(fixBase64EncodingOnKey).then(async jwk => ({
|
21
|
+
...jwk,
|
22
|
+
// Keys in the TEE are not stored with their KID, which is supposed to be assigned when they are included in JWK sets.
|
23
|
+
// (that is, KID is not a propoerty of the key itself, but it's property used to identify a key in a set).
|
24
|
+
// We assume the convention we use the thumbprint of the public key as KID, thus for easy development we decided to evaluate KID here
|
25
|
+
// However the values is an arbitrary string that might be anything
|
26
|
+
kid: await thumbprint(jwk)
|
27
|
+
}));
|
28
|
+
},
|
29
|
+
/**
|
30
|
+
* Get a signature for a provided value.
|
31
|
+
* If the key pair doesn't exist yet, an error is raised.
|
32
|
+
* @param value
|
33
|
+
* @returns The signature for the value
|
34
|
+
*/
|
35
|
+
async getSignature(value) {
|
36
|
+
return sign(value, keytag);
|
37
|
+
}
|
38
|
+
};
|
39
|
+
};
|
40
|
+
//# sourceMappingURL=crypto.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["getPublicKey","sign","thumbprint","fixBase64EncodingOnKey","createCryptoContextFor","keytag","then","jwk","kid","getSignature","value"],"sourceRoot":"../../../src","sources":["utils/crypto.ts"],"mappings":"AAAA,SAASA,YAAY,EAAEC,IAAI,QAAQ,gCAAgC;AACnE,SAASC,UAAU,QAA4B,6BAA6B;AAC5E,SAASC,sBAAsB,QAAQ,OAAO;;AAE9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,sBAAsB,GAAIC,MAAc,IAAoB;EACvE,OAAO;IACL;AACJ;AACA;AACA;AACA;IACI,MAAML,YAAYA,CAAA,EAAG;MACnB,OAAOA,YAAY,CAACK,MAAM,CAAC,CACxBC,IAAI,CAACH,sBAAsB,CAAC,CAC5BG,IAAI,CAAC,MAAOC,GAAG,KAAM;QACpB,GAAGA,GAAG;QACN;QACA;QACA;QACA;QACAC,GAAG,EAAE,MAAMN,UAAU,CAACK,GAAG;MAC3B,CAAC,CAAC,CAAC;IACP,CAAC;IACD;AACJ;AACA;AACA;AACA;AACA;IACI,MAAME,YAAYA,CAACC,KAAa,EAAE;MAChC,OAAOT,IAAI,CAACS,KAAK,EAAEL,MAAM,CAAC;IAC5B;EACF,CAAC;AACH,CAAC"}
|
package/lib/module/utils/dpop.js
CHANGED
@@ -1,12 +1,20 @@
|
|
1
1
|
import * as z from "zod";
|
2
2
|
import { SignJWT } from "@pagopa/io-react-native-jwt";
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
|
4
|
+
/**
|
5
|
+
* Create a signed DPoP token
|
6
|
+
*
|
7
|
+
* @param payload The payload to be included in the token.
|
8
|
+
* @param crypto The crypto context that handles the key bound to the DPoP.
|
9
|
+
*
|
10
|
+
* @returns The signed crypto token.
|
11
|
+
*/
|
12
|
+
export const createDPopToken = async (payload, crypto) => {
|
13
|
+
const jwk = await crypto.getPublicKey();
|
14
|
+
return new SignJWT(crypto).setPayload(payload).setProtectedHeader({
|
6
15
|
typ: "dpop+jwt",
|
7
16
|
jwk
|
8
|
-
}).setIssuedAt().setExpirationTime("1h").
|
9
|
-
return dPop;
|
17
|
+
}).setIssuedAt().setExpirationTime("1h").sign();
|
10
18
|
};
|
11
19
|
export const DPoPPayload = z.object({
|
12
20
|
jti: z.string(),
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["z","SignJWT","
|
1
|
+
{"version":3,"names":["z","SignJWT","createDPopToken","payload","crypto","jwk","getPublicKey","setPayload","setProtectedHeader","typ","setIssuedAt","setExpirationTime","sign","DPoPPayload","object","jti","string","htm","union","literal","htu","ath","optional"],"sourceRoot":"../../../src","sources":["utils/dpop.ts"],"mappings":"AAAA,OAAO,KAAKA,CAAC,MAAM,KAAK;AAExB,SAASC,OAAO,QAA4B,6BAA6B;;AAEzE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,eAAe,GAAG,MAAAA,CAC7BC,OAAoB,EACpBC,MAAqB,KACD;EACpB,MAAMC,GAAG,GAAG,MAAMD,MAAM,CAACE,YAAY,CAAC,CAAC;EACvC,OAAO,IAAIL,OAAO,CAACG,MAAM,CAAC,CACvBG,UAAU,CAACJ,OAAO,CAAC,CACnBK,kBAAkB,CAAC;IAClBC,GAAG,EAAE,UAAU;IACfJ;EACF,CAAC,CAAC,CACDK,WAAW,CAAC,CAAC,CACbC,iBAAiB,CAAC,IAAI,CAAC,CACvBC,IAAI,CAAC,CAAC;AACX,CAAC;AAGD,OAAO,MAAMC,WAAW,GAAGb,CAAC,CAACc,MAAM,CAAC;EAClCC,GAAG,EAAEf,CAAC,CAACgB,MAAM,CAAC,CAAC;EACfC,GAAG,EAAEjB,CAAC,CAACkB,KAAK,CAAC,CAAClB,CAAC,CAACmB,OAAO,CAAC,MAAM,CAAC,EAAEnB,CAAC,CAACmB,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;EACnDC,GAAG,EAAEpB,CAAC,CAACgB,MAAM,CAAC,CAAC;EACfK,GAAG,EAAErB,CAAC,CAACgB,MAAM,CAAC,CAAC,CAACM,QAAQ,CAAC;AAC3B,CAAC,CAAC"}
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import { WalletInstanceAttestationJwt } from "./types";
|
2
2
|
import { decode as decodeJwt } from "@pagopa/io-react-native-jwt";
|
3
3
|
import { verify as verifyJwt } from "@pagopa/io-react-native-jwt";
|
4
|
-
import {
|
5
|
-
export {
|
4
|
+
import { getAttestation } from "./issuing";
|
5
|
+
export { getAttestation };
|
6
6
|
/**
|
7
7
|
* Decode a given JWT to get the parsed Wallet Instance Attestation object they define.
|
8
8
|
* It ensures provided data is in a valid shape.
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["WalletInstanceAttestationJwt","decode","decodeJwt","verify","verifyJwt","
|
1
|
+
{"version":3,"names":["WalletInstanceAttestationJwt","decode","decodeJwt","verify","verifyJwt","getAttestation","token","decodedJwt","parse","header","protectedHeader","payload","decoded","pubKey","cnf","jwk"],"sourceRoot":"../../../src","sources":["wallet-instance-attestation/index.ts"],"mappings":"AAAA,SAASA,4BAA4B,QAAQ,SAAS;AACtD,SAASC,MAAM,IAAIC,SAAS,QAAQ,6BAA6B;AACjE,SAASC,MAAM,IAAIC,SAAS,QAAQ,6BAA6B;AAEjE,SAASC,cAAc,QAAQ,WAAW;AAC1C,SAASA,cAAc;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASJ,MAAMA,CAACK,KAAa,EAAgC;EAClE;EACA,MAAMC,UAAU,GAAGL,SAAS,CAACI,KAAK,CAAC;EACnC;EACA,OAAON,4BAA4B,CAACQ,KAAK,CAAC;IACxCC,MAAM,EAAEF,UAAU,CAACG,eAAe;IAClCC,OAAO,EAAEJ,UAAU,CAACI;EACtB,CAAC,CAAC;AACJ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeR,MAAMA,CAC1BG,KAAa,EAC0B;EACvC,MAAMM,OAAO,GAAGX,MAAM,CAACK,KAAK,CAAC;EAC7B,MAAMO,MAAM,GAAGD,OAAO,CAACD,OAAO,CAACG,GAAG,CAACC,GAAG;EAEtC,MAAMX,SAAS,CAACE,KAAK,EAAEO,MAAM,CAAC;EAE9B,OAAOD,OAAO;AAChB"}
|
@@ -5,61 +5,43 @@ import { JWK, fixBase64EncodingOnKey } from "../utils/jwk";
|
|
5
5
|
import { WalletInstanceAttestationRequestJwt } from "./types";
|
6
6
|
import uuid from "react-native-uuid";
|
7
7
|
import { WalletInstanceAttestationIssuingError } from "../utils/errors";
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
...parsedJwk,
|
30
|
-
kid: keyThumbprint
|
31
|
-
};
|
32
|
-
const walletInstanceAttestationRequest = new SignJWT({
|
33
|
-
iss: keyThumbprint,
|
34
|
-
aud: this.walletProviderBaseUrl,
|
35
|
-
jti: `${uuid.v4()}`,
|
36
|
-
nonce: `${uuid.v4()}`,
|
37
|
-
cnf: {
|
38
|
-
jwk: fixBase64EncodingOnKey(publicKey)
|
39
|
-
}
|
40
|
-
}).setProtectedHeader({
|
41
|
-
alg: "ES256",
|
42
|
-
kid: publicKey.kid,
|
43
|
-
typ: "wiar+jwt"
|
44
|
-
}).setIssuedAt().setExpirationTime("1h").toSign();
|
45
|
-
return walletInstanceAttestationRequest;
|
46
|
-
}
|
8
|
+
async function getAttestationRequest(wiaCryptoContext, walletProviderEntityConfiguration) {
|
9
|
+
const jwk = await wiaCryptoContext.getPublicKey();
|
10
|
+
const parsedJwk = JWK.parse(jwk);
|
11
|
+
const keyThumbprint = await thumbprint(parsedJwk);
|
12
|
+
const publicKey = {
|
13
|
+
...parsedJwk,
|
14
|
+
kid: keyThumbprint
|
15
|
+
};
|
16
|
+
return new SignJWT(wiaCryptoContext).setPayload({
|
17
|
+
iss: keyThumbprint,
|
18
|
+
aud: walletProviderEntityConfiguration.payload.iss,
|
19
|
+
jti: `${uuid.v4()}`,
|
20
|
+
nonce: `${uuid.v4()}`,
|
21
|
+
cnf: {
|
22
|
+
jwk: fixBase64EncodingOnKey(publicKey)
|
23
|
+
}
|
24
|
+
}).setProtectedHeader({
|
25
|
+
kid: publicKey.kid,
|
26
|
+
typ: "wiar+jwt"
|
27
|
+
}).setIssuedAt().setExpirationTime("1h").sign();
|
28
|
+
}
|
47
29
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
async
|
62
|
-
const signedAttestationRequest = await
|
30
|
+
/**
|
31
|
+
* Request a Wallet Instance Attestation (WIA) to the Wallet provider
|
32
|
+
*
|
33
|
+
* @param params.wiaCryptoContext The key pair associated with the WIA. Will be use to prove the ownership of the attestation.
|
34
|
+
* @param params.appFetch (optional) Http client
|
35
|
+
* @param walletProviderBaseUrl Base url for the Wallet Provider
|
36
|
+
* @returns The retrieved Wallet Instance Attestation token
|
37
|
+
*/
|
38
|
+
export const getAttestation = _ref => {
|
39
|
+
let {
|
40
|
+
wiaCryptoContext,
|
41
|
+
appFetch = fetch
|
42
|
+
} = _ref;
|
43
|
+
return async walletProviderEntityConfiguration => {
|
44
|
+
const signedAttestationRequest = await getAttestationRequest(wiaCryptoContext, walletProviderEntityConfiguration);
|
63
45
|
const decodedRequest = decodeJwt(signedAttestationRequest);
|
64
46
|
const parsedRequest = WalletInstanceAttestationRequestJwt.parse({
|
65
47
|
payload: decodedRequest.payload,
|
@@ -67,12 +49,12 @@ export class Issuing {
|
|
67
49
|
});
|
68
50
|
const publicKey = parsedRequest.payload.cnf.jwk;
|
69
51
|
await verifyJwt(signedAttestationRequest, publicKey);
|
70
|
-
const tokenUrl =
|
52
|
+
const tokenUrl = walletProviderEntityConfiguration.payload.metadata.wallet_provider.token_endpoint;
|
71
53
|
const requestBody = {
|
72
54
|
grant_type: "urn:ietf:params:oauth:client-assertion-type:jwt-client-attestation",
|
73
55
|
assertion: signedAttestationRequest
|
74
56
|
};
|
75
|
-
const response = await
|
57
|
+
const response = await appFetch(tokenUrl, {
|
76
58
|
method: "POST",
|
77
59
|
headers: {
|
78
60
|
"Content-Type": "application/json"
|
@@ -83,6 +65,6 @@ export class Issuing {
|
|
83
65
|
return await response.text();
|
84
66
|
}
|
85
67
|
throw new WalletInstanceAttestationIssuingError("Unable to obtain wallet instance attestation from wallet provider", `Response code: ${response.status}`);
|
86
|
-
}
|
87
|
-
}
|
68
|
+
};
|
69
|
+
};
|
88
70
|
//# sourceMappingURL=issuing.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["decode","decodeJwt","verify","verifyJwt","SignJWT","thumbprint","JWK","fixBase64EncodingOnKey","WalletInstanceAttestationRequestJwt","uuid","WalletInstanceAttestationIssuingError","
|
1
|
+
{"version":3,"names":["decode","decodeJwt","verify","verifyJwt","SignJWT","thumbprint","JWK","fixBase64EncodingOnKey","WalletInstanceAttestationRequestJwt","uuid","WalletInstanceAttestationIssuingError","getAttestationRequest","wiaCryptoContext","walletProviderEntityConfiguration","jwk","getPublicKey","parsedJwk","parse","keyThumbprint","publicKey","kid","setPayload","iss","aud","payload","jti","v4","nonce","cnf","setProtectedHeader","typ","setIssuedAt","setExpirationTime","sign","getAttestation","_ref","appFetch","fetch","signedAttestationRequest","decodedRequest","parsedRequest","header","protectedHeader","tokenUrl","metadata","wallet_provider","token_endpoint","requestBody","grant_type","assertion","response","method","headers","body","JSON","stringify","status","text"],"sourceRoot":"../../../src","sources":["wallet-instance-attestation/issuing.ts"],"mappings":"AAAA,SAEEA,MAAM,IAAIC,SAAS,QACd,6BAA6B;AACpC,SAASC,MAAM,IAAIC,SAAS,QAAQ,6BAA6B;AACjE,SAASC,OAAO,EAAEC,UAAU,QAAQ,6BAA6B;AACjE,SAASC,GAAG,EAAEC,sBAAsB,QAAQ,cAAc;AAC1D,SAASC,mCAAmC,QAAQ,SAAS;AAC7D,OAAOC,IAAI,MAAM,mBAAmB;AACpC,SAASC,qCAAqC,QAAQ,iBAAiB;AAGvE,eAAeC,qBAAqBA,CAClCC,gBAA+B,EAC/BC,iCAAoE,EACnD;EACjB,MAAMC,GAAG,GAAG,MAAMF,gBAAgB,CAACG,YAAY,CAAC,CAAC;EACjD,MAAMC,SAAS,GAAGV,GAAG,CAACW,KAAK,CAACH,GAAG,CAAC;EAChC,MAAMI,aAAa,GAAG,MAAMb,UAAU,CAACW,SAAS,CAAC;EACjD,MAAMG,SAAS,GAAG;IAAE,GAAGH,SAAS;IAAEI,GAAG,EAAEF;EAAc,CAAC;EAEtD,OAAO,IAAId,OAAO,CAACQ,gBAAgB,CAAC,CACjCS,UAAU,CAAC;IACVC,GAAG,EAAEJ,aAAa;IA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,GAAG,MAAMd,QAAQ,CAACO,QAAQ,EAAE;MACxCQ,MAAM,EAAE,MAAM;MACdC,OAAO,EAAE;QACP,cAAc,EAAE;MAClB,CAAC;MACDC,IAAI,EAAEC,IAAI,CAACC,SAAS,CAACR,WAAW;IAClC,CAAC,CAAC;IAEF,IAAIG,QAAQ,CAACM,MAAM,KAAK,GAAG,EAAE;MAC3B,OAAO,MAAMN,QAAQ,CAACO,IAAI,CAAC,CAAC;IAC9B;IAEA,MAAM,IAAI/C,qCAAqC,CAC7C,mEAAmE,EAClE,kBAAiBwC,QAAQ,CAACM,MAAO,EACpC,CAAC;EACH,CAAC;AAAA"}
|
@@ -3,10 +3,8 @@ import * as PID from "./pid";
|
|
3
3
|
import * as RP from "./rp";
|
4
4
|
import * as Errors from "./utils/errors";
|
5
5
|
import * as WalletInstanceAttestation from "./wallet-instance-attestation";
|
6
|
-
import
|
7
|
-
import {
|
8
|
-
import {
|
9
|
-
|
10
|
-
import { EntityConfiguration, EntityStatement, TrustAnchorEntityConfiguration } from "./trust/types";
|
11
|
-
export { PID, RP, WalletInstanceAttestation, Errors, getUnsignedDPop, RelyingPartySolution, verifyTrustChain, getEntityConfiguration, EntityConfiguration, EntityStatement, RpEntityConfiguration, TrustAnchorEntityConfiguration, };
|
6
|
+
import * as RelyingPartySolution from "./rp";
|
7
|
+
import { verifyTrustChain, getEntityConfiguration, getCredentialIssuerEntityConfiguration, getRelyingPartyEntityConfiguration, getTrustAnchorEntityConfiguration, getWalletProviderEntityConfiguration } from "./trust";
|
8
|
+
import { createCryptoContextFor } from "./utils/crypto";
|
9
|
+
export { PID, RP, WalletInstanceAttestation, Errors, RelyingPartySolution, verifyTrustChain, getEntityConfiguration, getCredentialIssuerEntityConfiguration, getRelyingPartyEntityConfiguration, getTrustAnchorEntityConfiguration, getWalletProviderEntityConfiguration, createCryptoContextFor, };
|
12
10
|
//# sourceMappingURL=index.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,gCAAgC,CAAC;AAExC,OAAO,KAAK,GAAG,MAAM,OAAO,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,MAAM,CAAC;AAC3B,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAC;AACzC,OAAO,KAAK,yBAAyB,MAAM,+BAA+B,CAAC;AAC3E,OAAO,
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,gCAAgC,CAAC;AAExC,OAAO,KAAK,GAAG,MAAM,OAAO,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,MAAM,CAAC;AAC3B,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAC;AACzC,OAAO,KAAK,yBAAyB,MAAM,+BAA+B,CAAC;AAC3E,OAAO,KAAK,oBAAoB,MAAM,MAAM,CAAC;AAC7C,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,sCAAsC,EACtC,kCAAkC,EAClC,iCAAiC,EACjC,oCAAoC,EACrC,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAExD,OAAO,EACL,GAAG,EACH,EAAE,EACF,yBAAyB,EACzB,MAAM,EACN,oBAAoB,EACpB,gBAAgB,EAChB,sBAAsB,EACtB,sCAAsC,EACtC,kCAAkC,EAClC,iCAAiC,EACjC,oCAAoC,EACpC,sBAAsB,GACvB,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/pid/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,UAAU,CAAC;AAClC,OAAO,
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/pid/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,UAAU,CAAC;AAClC,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC"}
|
@@ -1,14 +1,19 @@
|
|
1
|
-
|
2
|
-
import {
|
1
|
+
/// <reference types="react-native" />
|
2
|
+
import { type CryptoContext } from "@pagopa/io-react-native-jwt";
|
3
|
+
import { CredentialIssuerEntityConfiguration } from "../trust/types";
|
3
4
|
export type CieData = {
|
4
5
|
birthDate: string;
|
5
6
|
fiscalCode: string;
|
6
7
|
name: string;
|
7
8
|
surname: string;
|
8
9
|
};
|
9
|
-
export type
|
10
|
-
|
11
|
-
|
10
|
+
export type AuthorizationConf = {
|
11
|
+
accessToken: string;
|
12
|
+
nonce: string;
|
13
|
+
clientId: string;
|
14
|
+
authorizationCode: string;
|
15
|
+
codeVerifier: string;
|
16
|
+
walletProviderBaseUrl: string;
|
12
17
|
};
|
13
18
|
export type PidResponse = {
|
14
19
|
credential: string;
|
@@ -16,87 +21,37 @@ export type PidResponse = {
|
|
16
21
|
c_nonce_expires_in: number;
|
17
22
|
format: string;
|
18
23
|
};
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
*
|
53
|
-
* @function
|
54
|
-
* @param jwk the public key for which the DPoP is to be created
|
55
|
-
*
|
56
|
-
* @returns Unsigned JWT for DPoP
|
57
|
-
*
|
58
|
-
*/
|
59
|
-
getUnsignedDPoP(jwk: JWK): Promise<string>;
|
60
|
-
/**
|
61
|
-
* Make an auth token request to the PID issuer
|
62
|
-
*
|
63
|
-
* @function
|
64
|
-
* @returns a token response
|
65
|
-
*
|
66
|
-
*/
|
67
|
-
getAuthToken(): Promise<TokenResponse>;
|
68
|
-
/**
|
69
|
-
* Return the unsigned jwt for nonce proof of possession
|
70
|
-
*
|
71
|
-
* @function
|
72
|
-
* @param nonce the nonce
|
73
|
-
*
|
74
|
-
* @returns Unsigned JWT for nonce proof
|
75
|
-
*
|
76
|
-
*/
|
77
|
-
getUnsignedNonceProof(nonce: string): Promise<string>;
|
78
|
-
/**
|
79
|
-
* Make the credential issuing request to the PID issuer
|
80
|
-
*
|
81
|
-
* @function
|
82
|
-
* @param unsignedDPopForPid The unsigned JWT for PID DPoP
|
83
|
-
* @param dPopPidSignature The JWT for PID DPoP signature
|
84
|
-
* @param unsignedNonceProof The unsigned JWT for nonce proof
|
85
|
-
* @param nonceProofSignature The JWT for nonce proof signature
|
86
|
-
* @param accessToken The access token obtained with getAuthToken
|
87
|
-
* @param cieData Personal data read by the CIE
|
88
|
-
*
|
89
|
-
* @returns a credential
|
90
|
-
*
|
91
|
-
*/
|
92
|
-
getCredential(unsignedDPopForPid: string, dPopPidSignature: string, unsignedNonceProof: string, nonceProofSignature: string, accessToken: string, cieData: CieData): Promise<PidResponse>;
|
93
|
-
/**
|
94
|
-
* Obtain the PID issuer metadata
|
95
|
-
*
|
96
|
-
* @function
|
97
|
-
* @returns PID issuer metadata
|
98
|
-
*
|
99
|
-
*/
|
100
|
-
getEntityConfiguration(): Promise<PidIssuerEntityConfiguration>;
|
101
|
-
}
|
24
|
+
/**
|
25
|
+
* Start the issuing flow by generating an authorization request to the PID Provider. Obtain from the PID Provider an access token to be used to complete the issuing flow.
|
26
|
+
*
|
27
|
+
* @param params.wiaCryptoContext The key pair associated with the WIA. Will be use to prove the ownership of the attestation.
|
28
|
+
* @param params.appFetch (optional) Http client
|
29
|
+
* @param walletInstanceAttestation Wallet Instance Attestation token.
|
30
|
+
* @param walletProviderBaseUrl Base url for the Wallet Provider
|
31
|
+
* @param pidProviderEntityConfiguration The Entity Configuration of the PID Provider, from which discover public endooints.
|
32
|
+
* @returns The access token along with the values that identify the issuing session.
|
33
|
+
*/
|
34
|
+
export declare const authorizeIssuing: ({ wiaCryptoContext, appFetch, }: {
|
35
|
+
wiaCryptoContext: CryptoContext;
|
36
|
+
appFetch?: {
|
37
|
+
(input: RequestInfo, init?: RequestInit | undefined): Promise<Response>;
|
38
|
+
(input: RequestInfo, init?: RequestInit | undefined): Promise<Response>;
|
39
|
+
} | undefined;
|
40
|
+
}) => (walletInstanceAttestation: string, walletProviderBaseUrl: string, pidProviderEntityConfiguration: CredentialIssuerEntityConfiguration) => Promise<AuthorizationConf>;
|
41
|
+
/**
|
42
|
+
* Complete the issuing flow and get the PID credential.
|
43
|
+
*
|
44
|
+
* @param params.pidCryptoContext The key pair associated with the PID. Will be use to prove the ownership of the credential.
|
45
|
+
* @param params.appFetch (optional) Http client
|
46
|
+
* @param authConf The authorization configuration retrieved with the access token
|
47
|
+
* @param cieData Data red from the CIE login process
|
48
|
+
* @returns The PID credential token
|
49
|
+
*/
|
50
|
+
export declare const getCredential: ({ pidCryptoContext, appFetch, }: {
|
51
|
+
pidCryptoContext: CryptoContext;
|
52
|
+
appFetch?: {
|
53
|
+
(input: RequestInfo, init?: RequestInit | undefined): Promise<Response>;
|
54
|
+
(input: RequestInfo, init?: RequestInit | undefined): Promise<Response>;
|
55
|
+
} | undefined;
|
56
|
+
}) => ({ nonce, accessToken, clientId, walletProviderBaseUrl }: AuthorizationConf, pidProviderEntityConfiguration: CredentialIssuerEntityConfiguration, cieData: CieData) => Promise<PidResponse>;
|
102
57
|
//# sourceMappingURL=issuing.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"issuing.d.ts","sourceRoot":"","sources":["../../../src/pid/issuing.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"issuing.d.ts","sourceRoot":"","sources":["../../../src/pid/issuing.ts"],"names":[],"mappings":";AAAA,OAAO,EAEL,KAAK,aAAa,EAGnB,MAAM,6BAA6B,CAAC;AAKrC,OAAO,EAAE,mCAAmC,EAAE,MAAM,gBAAgB,CAAC;AAMrE,MAAM,MAAM,OAAO,GAAG;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,qBAAqB,EAAE,MAAM,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAoGF;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB;sBAKP,aAAa;;;;;kCAIJ,MAAM,yBACV,MAAM,kCACG,mCAAmC,KAClE,QAAQ,iBAAiB,CAoE3B,CAAC;AA0BJ;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa;sBAKJ,aAAa;;;;;gEAI0B,iBAAiB,kCAC1C,mCAAmC,WAC1D,OAAO,KACf,QAAQ,WAAW,CAuDrB,CAAC"}
|