@pagopa/io-react-native-wallet 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +52 -19
- package/lib/commonjs/index.js +13 -24
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/pid/issuing.js +22 -28
- package/lib/commonjs/pid/issuing.js.map +1 -1
- package/lib/commonjs/rp/__test__/index.test.js +2 -2
- package/lib/commonjs/rp/__test__/index.test.js.map +1 -1
- package/lib/commonjs/rp/index.js +5 -19
- 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 +95 -4
- package/lib/commonjs/trust/types.js.map +1 -1
- package/lib/commonjs/wallet-instance-attestation/issuing.js +5 -13
- package/lib/commonjs/wallet-instance-attestation/issuing.js.map +1 -1
- package/lib/module/index.js +2 -5
- package/lib/module/index.js.map +1 -1
- package/lib/module/pid/issuing.js +16 -23
- package/lib/module/pid/issuing.js.map +1 -1
- package/lib/module/rp/__test__/index.test.js +2 -2
- package/lib/module/rp/__test__/index.test.js.map +1 -1
- package/lib/module/rp/index.js +2 -17
- 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 +94 -2
- package/lib/module/trust/types.js.map +1 -1
- package/lib/module/wallet-instance-attestation/issuing.js +5 -13
- package/lib/module/wallet-instance-attestation/issuing.js.map +1 -1
- package/lib/typescript/index.d.ts +2 -5
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/pid/issuing.d.ts +3 -12
- package/lib/typescript/pid/issuing.d.ts.map +1 -1
- package/lib/typescript/rp/index.d.ts +4 -12
- package/lib/typescript/rp/index.d.ts.map +1 -1
- package/lib/typescript/rp/types.d.ts +4 -1256
- package/lib/typescript/rp/types.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 +8637 -5
- package/lib/typescript/trust/types.d.ts.map +1 -1
- package/lib/typescript/wallet-instance-attestation/issuing.d.ts +2 -1
- 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 +1 -1
- package/src/index.ts +11 -12
- package/src/pid/issuing.ts +24 -30
- package/src/rp/__test__/index.test.ts +2 -2
- package/src/rp/index.ts +8 -22
- package/src/rp/types.ts +0 -24
- package/src/trust/index.ts +106 -5
- package/src/trust/types.ts +114 -3
- package/src/wallet-instance-attestation/issuing.ts +10 -15
- package/lib/commonjs/pid/metadata.js +0 -52
- package/lib/commonjs/pid/metadata.js.map +0 -1
- package/lib/module/pid/metadata.js +0 -44
- package/lib/module/pid/metadata.js.map +0 -1
- package/lib/typescript/pid/metadata.d.ts +0 -1412
- package/lib/typescript/pid/metadata.d.ts.map +0 -1
- package/src/pid/metadata.ts +0 -51
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["
|
1
|
+
{"version":3,"names":["_types","require","z","_interopRequireWildcard","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","RequestObject","object","header","typ","literal","optional","alg","string","kid","trust_chain","array","payload","iss","iat","UnixTime","exp","state","nonce","response_uri","response_type","response_mode","client_id","client_id_scheme","scope","exports","QRCodePayload","protocol","resource","clientId","requestURI"],"sourceRoot":"../../../src","sources":["rp/types.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,CAAA,GAAAC,uBAAA,CAAAF,OAAA;AAAyB,SAAAG,yBAAAC,WAAA,eAAAC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,GAAAA,aAAA"}
|
@@ -3,7 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.getEntityConfiguration =
|
6
|
+
exports.getWalletProviderEntityConfiguration = exports.getTrustAnchorEntityConfiguration = exports.getRelyingPartyEntityConfiguration = exports.getEntityConfiguration = exports.getCredentialIssuerEntityConfiguration = void 0;
|
7
7
|
Object.defineProperty(exports, "verifyTrustChain", {
|
8
8
|
enumerable: true,
|
9
9
|
get: function () {
|
@@ -15,18 +15,27 @@ var _types = require("./types");
|
|
15
15
|
var _errors = require("../utils/errors");
|
16
16
|
var _chain = require("./chain");
|
17
17
|
/**
|
18
|
-
* Fetch and parse
|
18
|
+
* Fetch and parse the entity configuration document for a given federation entity.
|
19
|
+
* This is an inner method to serve public interfaces.
|
20
|
+
*
|
21
|
+
* To add another entity configuration type (example: Foo entity type):
|
22
|
+
* - create its zod schema and type by inherit from the base type (example: FooEntityConfiguration = BaseEntityConfiguration.and(...))
|
23
|
+
* - add such type to EntityConfiguration union
|
24
|
+
* - add an overload to this function
|
25
|
+
* - create a public function which use such type (example: getFooEntityConfiguration = (url, options) => Promise<FooEntityConfiguration>)
|
19
26
|
*
|
20
27
|
* @param entityBaseUrl The base url of the entity.
|
28
|
+
* @param schema The expected schema of the entity configuration, according to the kind of entity we are fetching from.
|
21
29
|
* @param options.appFetch An optional instance of the http client to be used.
|
22
30
|
* @returns The parsed entity configuration object
|
23
31
|
* @throws {IoWalletError} If the http request fails
|
24
32
|
* @throws Parse error if the document is not in the expected shape.
|
25
33
|
*/
|
26
|
-
|
34
|
+
|
35
|
+
async function fetchAndParseEntityConfiguration(entityBaseUrl, schema) {
|
27
36
|
let {
|
28
37
|
appFetch = fetch
|
29
|
-
} = arguments.length >
|
38
|
+
} = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
30
39
|
const wellKnownUrl = `${entityBaseUrl}/.well-known/openid-federation`;
|
31
40
|
const response = await appFetch(wellKnownUrl, {
|
32
41
|
method: "GET"
|
@@ -34,11 +43,21 @@ async function getEntityConfiguration(entityBaseUrl) {
|
|
34
43
|
if (response.status === 200) {
|
35
44
|
const responseText = await response.text();
|
36
45
|
const responseJwt = (0, _ioReactNativeJwt.decode)(responseText);
|
37
|
-
return
|
46
|
+
return schema.parse({
|
38
47
|
header: responseJwt.protectedHeader,
|
39
48
|
payload: responseJwt.payload
|
40
49
|
});
|
41
50
|
}
|
42
51
|
throw new _errors.IoWalletError(`Unable to obtain Entity Configuration at ${wellKnownUrl}. Response code: ${response.status}`);
|
43
52
|
}
|
53
|
+
const getWalletProviderEntityConfiguration = (entityBaseUrl, options) => fetchAndParseEntityConfiguration(entityBaseUrl, _types.WalletProviderEntityConfiguration, options);
|
54
|
+
exports.getWalletProviderEntityConfiguration = getWalletProviderEntityConfiguration;
|
55
|
+
const getCredentialIssuerEntityConfiguration = (entityBaseUrl, options) => fetchAndParseEntityConfiguration(entityBaseUrl, _types.CredentialIssuerEntityConfiguration, options);
|
56
|
+
exports.getCredentialIssuerEntityConfiguration = getCredentialIssuerEntityConfiguration;
|
57
|
+
const getTrustAnchorEntityConfiguration = (entityBaseUrl, options) => fetchAndParseEntityConfiguration(entityBaseUrl, _types.TrustAnchorEntityConfiguration, options);
|
58
|
+
exports.getTrustAnchorEntityConfiguration = getTrustAnchorEntityConfiguration;
|
59
|
+
const getRelyingPartyEntityConfiguration = (entityBaseUrl, options) => fetchAndParseEntityConfiguration(entityBaseUrl, _types.RelyingPartyEntityConfiguration, options);
|
60
|
+
exports.getRelyingPartyEntityConfiguration = getRelyingPartyEntityConfiguration;
|
61
|
+
const getEntityConfiguration = (entityBaseUrl, options) => fetchAndParseEntityConfiguration(entityBaseUrl, _types.EntityConfiguration, options);
|
62
|
+
exports.getEntityConfiguration = getEntityConfiguration;
|
44
63
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_ioReactNativeJwt","require","_types","_errors","_chain","
|
1
|
+
{"version":3,"names":["_ioReactNativeJwt","require","_types","_errors","_chain","fetchAndParseEntityConfiguration","entityBaseUrl","schema","appFetch","fetch","arguments","length","undefined","wellKnownUrl","response","method","status","responseText","text","responseJwt","decodeJwt","parse","header","protectedHeader","payload","IoWalletError","getWalletProviderEntityConfiguration","options","WalletProviderEntityConfiguration","exports","getCredentialIssuerEntityConfiguration","CredentialIssuerEntityConfiguration","getTrustAnchorEntityConfiguration","TrustAnchorEntityConfiguration","getRelyingPartyEntityConfiguration","RelyingPartyEntityConfiguration","getEntityConfiguration","EntityConfiguration"],"sourceRoot":"../../../src","sources":["trust/index.ts"],"mappings":";;;;;;;;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAOA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAoCA,eAAeI,gCAAgCA,CAC7CC,aAAqB,EACrBC,MAK8B,EAM9B;EAAA,IALA;IACEC,QAAQ,GAAGC;EAGb,CAAC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EAEN,MAAMG,YAAY,GAAI,GAAEP,aAAc,gCAA+B;EAErE,MAAMQ,QAAQ,GAAG,MAAMN,QAAQ,CAACK,YAAY,EAAE;IAC5CE,MAAM,EAAE;EACV,CAAC,CAAC;EAEF,IAAID,QAAQ,CAACE,MAAM,KAAK,GAAG,EAAE;IAC3B,MAAMC,YAAY,GAAG,MAAMH,QAAQ,CAACI,IAAI,CAAC,CAAC;IAC1C,MAAMC,WAAW,GAAG,IAAAC,wBAAS,EAACH,YAAY,CAAC;IAC3C,OAAOV,MAAM,CAACc,KAAK,CAAC;MAClBC,MAAM,EAAEH,WAAW,CAACI,eAAe;MACnCC,OAAO,EAAEL,WAAW,CAACK;IACvB,CAAC,CAAC;EACJ;EAEA,MAAM,IAAIC,qBAAa,CACpB,4CAA2CZ,YAAa,oBAAmBC,QAAQ,CAACE,MAAO,EAC9F,CAAC;AACH;AAEO,MAAMU,oCAAoC,GAAGA,CAClDpB,aAAqE,EACrEqB,OAAgE,KAEhEtB,gCAAgC,CAC9BC,aAAa,EACbsB,wCAAiC,EACjCD,OACF,CAAC;AAACE,OAAA,CAAAH,oCAAA,GAAAA,oCAAA;AAEG,MAAMI,sCAAsC,GAAGA,CACpDxB,aAAqE,EACrEqB,OAAgE,KAEhEtB,gCAAgC,CAC9BC,aAAa,EACbyB,0CAAmC,EACnCJ,OACF,CAAC;AAACE,OAAA,CAAAC,sCAAA,GAAAA,sCAAA;AAEG,MAAME,iCAAiC,GAAGA,CAC/C1B,aAAqE,EACrEqB,OAAgE,KAEhEtB,gCAAgC,CAC9BC,aAAa,EACb2B,qCAA8B,EAC9BN,OACF,CAAC;AAACE,OAAA,CAAAG,iCAAA,GAAAA,iCAAA;AAEG,MAAME,kCAAkC,GAAGA,CAChD5B,aAAqE,EACrEqB,OAAgE,KAEhEtB,gCAAgC,CAC9BC,aAAa,EACb6B,sCAA+B,EAC/BR,OACF,CAAC;AAACE,OAAA,CAAAK,kCAAA,GAAAA,kCAAA;AAEG,MAAME,sBAAsB,GAAGA,CACpC9B,aAAqE,EACrEqB,OAAgE,KAEhEtB,gCAAgC,CAACC,aAAa,EAAE+B,0BAAmB,EAAEV,OAAO,CAAC;AAACE,OAAA,CAAAO,sBAAA,GAAAA,sBAAA"}
|
@@ -3,7 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.TrustMark = exports.TrustAnchorEntityConfiguration = exports.EntityStatement = exports.EntityConfigurationHeader = exports.EntityConfiguration = void 0;
|
6
|
+
exports.WalletProviderEntityConfiguration = exports.TrustMark = exports.TrustAnchorEntityConfiguration = exports.RelyingPartyEntityConfiguration = exports.EntityStatement = exports.EntityConfigurationHeader = exports.EntityConfiguration = exports.CredentialIssuerEntityConfiguration = void 0;
|
7
7
|
var _types = require("../sd-jwt/types");
|
8
8
|
var _jwk = require("../utils/jwk");
|
9
9
|
var z = _interopRequireWildcard(require("zod"));
|
@@ -13,7 +13,29 @@ const TrustMark = z.object({
|
|
13
13
|
id: z.string(),
|
14
14
|
trust_mark: z.string()
|
15
15
|
});
|
16
|
+
|
17
|
+
// Display metadata for a credential, used by the issuer to
|
18
|
+
// instruct the Wallet Solution on how to render the credential correctly
|
16
19
|
exports.TrustMark = TrustMark;
|
20
|
+
const CredentialDisplayMetadata = z.object({
|
21
|
+
name: z.string(),
|
22
|
+
locale: z.string(),
|
23
|
+
logo: z.object({
|
24
|
+
url: z.string(),
|
25
|
+
alt_text: z.string()
|
26
|
+
}),
|
27
|
+
background_color: z.string(),
|
28
|
+
text_color: z.string()
|
29
|
+
});
|
30
|
+
|
31
|
+
// Metadata for a credentia which i supported by a Issuer
|
32
|
+
|
33
|
+
const SupportedCredentialMetadata = z.object({
|
34
|
+
format: z.literal("vc+sd-jwt"),
|
35
|
+
cryptographic_binding_methods_supported: z.array(z.string()),
|
36
|
+
cryptographic_suites_supported: z.array(z.string()),
|
37
|
+
display: z.array(CredentialDisplayMetadata)
|
38
|
+
});
|
17
39
|
const EntityStatement = z.object({
|
18
40
|
header: z.object({
|
19
41
|
typ: z.literal("entity-statement+jwt"),
|
@@ -37,8 +59,10 @@ const EntityConfigurationHeader = z.object({
|
|
37
59
|
alg: z.string(),
|
38
60
|
kid: z.string()
|
39
61
|
});
|
62
|
+
|
63
|
+
// Structuire common to every Entity Configuration document
|
40
64
|
exports.EntityConfigurationHeader = EntityConfigurationHeader;
|
41
|
-
const
|
65
|
+
const BaseEntityConfiguration = z.object({
|
42
66
|
header: EntityConfigurationHeader,
|
43
67
|
payload: z.object({
|
44
68
|
exp: _types.UnixTime,
|
@@ -64,7 +88,74 @@ const EntityConfiguration = z.object({
|
|
64
88
|
authority_hints: z.array(z.string()).optional()
|
65
89
|
}).passthrough()
|
66
90
|
});
|
67
|
-
|
68
|
-
|
91
|
+
|
92
|
+
// Entity configuration for a Trust Anchor (it has no specific metadata section)
|
93
|
+
|
94
|
+
const TrustAnchorEntityConfiguration = BaseEntityConfiguration;
|
95
|
+
|
96
|
+
// Entity configuration for a Credential Issuer
|
69
97
|
exports.TrustAnchorEntityConfiguration = TrustAnchorEntityConfiguration;
|
98
|
+
const CredentialIssuerEntityConfiguration = BaseEntityConfiguration.and(z.object({
|
99
|
+
payload: z.object({
|
100
|
+
jwks: z.object({
|
101
|
+
keys: z.array(_jwk.JWK)
|
102
|
+
}),
|
103
|
+
metadata: z.object({
|
104
|
+
openid_credential_issuer: z.object({
|
105
|
+
credential_issuer: z.string(),
|
106
|
+
authorization_endpoint: z.string(),
|
107
|
+
token_endpoint: z.string(),
|
108
|
+
pushed_authorization_request_endpoint: z.string(),
|
109
|
+
dpop_signing_alg_values_supported: z.array(z.string()),
|
110
|
+
credential_endpoint: z.string(),
|
111
|
+
credentials_supported: z.array(SupportedCredentialMetadata),
|
112
|
+
jwks: z.object({
|
113
|
+
keys: z.array(_jwk.JWK)
|
114
|
+
})
|
115
|
+
})
|
116
|
+
})
|
117
|
+
})
|
118
|
+
}));
|
119
|
+
|
120
|
+
// Entity configuration for a Wallet Provider
|
121
|
+
exports.CredentialIssuerEntityConfiguration = CredentialIssuerEntityConfiguration;
|
122
|
+
const WalletProviderEntityConfiguration = BaseEntityConfiguration.and(z.object({
|
123
|
+
payload: z.object({
|
124
|
+
metadata: z.object({
|
125
|
+
wallet_provider: z.object({
|
126
|
+
token_endpoint: z.string(),
|
127
|
+
attested_security_context_values_supported: z.array(z.string()).optional(),
|
128
|
+
grant_types_supported: z.array(z.string()),
|
129
|
+
token_endpoint_auth_methods_supported: z.array(z.string()),
|
130
|
+
token_endpoint_auth_signing_alg_values_supported: z.array(z.string()),
|
131
|
+
jwks: z.object({
|
132
|
+
keys: z.array(_jwk.JWK)
|
133
|
+
})
|
134
|
+
}).passthrough()
|
135
|
+
})
|
136
|
+
})
|
137
|
+
}));
|
138
|
+
|
139
|
+
// Entity configuration for a Relying Party
|
140
|
+
exports.WalletProviderEntityConfiguration = WalletProviderEntityConfiguration;
|
141
|
+
const RelyingPartyEntityConfiguration = BaseEntityConfiguration.and(z.object({
|
142
|
+
payload: z.object({
|
143
|
+
metadata: z.object({
|
144
|
+
wallet_relying_party: z.object({
|
145
|
+
application_type: z.string().optional(),
|
146
|
+
client_id: z.string().optional(),
|
147
|
+
client_name: z.string().optional(),
|
148
|
+
jwks: z.array(_jwk.JWK),
|
149
|
+
contacts: z.array(z.string()).optional()
|
150
|
+
}).passthrough()
|
151
|
+
})
|
152
|
+
})
|
153
|
+
}));
|
154
|
+
|
155
|
+
// Maps any entity configuration by the union of every possible shapes
|
156
|
+
exports.RelyingPartyEntityConfiguration = RelyingPartyEntityConfiguration;
|
157
|
+
const EntityConfiguration = z.union([WalletProviderEntityConfiguration, CredentialIssuerEntityConfiguration, TrustAnchorEntityConfiguration, RelyingPartyEntityConfiguration], {
|
158
|
+
description: "Any kind of Entity Configuration allowed in the ecosystem"
|
159
|
+
});
|
160
|
+
exports.EntityConfiguration = EntityConfiguration;
|
70
161
|
//# sourceMappingURL=types.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_types","require","_jwk","z","_interopRequireWildcard","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","TrustMark","object","id","string","trust_mark","exports","
|
1
|
+
{"version":3,"names":["_types","require","_jwk","z","_interopRequireWildcard","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","TrustMark","object","id","string","trust_mark","exports","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","JWK","trust_marks","iat","number","exp","EntityConfigurationHeader","BaseEntityConfiguration","UnixTime","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,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,CAAA,GAAAC,uBAAA,CAAAH,OAAA;AAAyB,SAAAI,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAF,wBAAAM,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KAAA,GAAAR,wBAAA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AA,mBAAA"}
|
@@ -10,7 +10,7 @@ var _types = require("./types");
|
|
10
10
|
var _reactNativeUuid = _interopRequireDefault(require("react-native-uuid"));
|
11
11
|
var _errors = require("../utils/errors");
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13
|
-
async function getAttestationRequest(wiaCryptoContext,
|
13
|
+
async function getAttestationRequest(wiaCryptoContext, walletProviderEntityConfiguration) {
|
14
14
|
const jwk = await wiaCryptoContext.getPublicKey();
|
15
15
|
const parsedJwk = _jwk.JWK.parse(jwk);
|
16
16
|
const keyThumbprint = await (0, _ioReactNativeJwt.thumbprint)(parsedJwk);
|
@@ -20,7 +20,7 @@ async function getAttestationRequest(wiaCryptoContext, walletProviderBaseUrl) {
|
|
20
20
|
};
|
21
21
|
return new _ioReactNativeJwt.SignJWT(wiaCryptoContext).setPayload({
|
22
22
|
iss: keyThumbprint,
|
23
|
-
aud:
|
23
|
+
aud: walletProviderEntityConfiguration.payload.iss,
|
24
24
|
jti: `${_reactNativeUuid.default.v4()}`,
|
25
25
|
nonce: `${_reactNativeUuid.default.v4()}`,
|
26
26
|
cnf: {
|
@@ -29,14 +29,6 @@ async function getAttestationRequest(wiaCryptoContext, walletProviderBaseUrl) {
|
|
29
29
|
}).setProtectedHeader({
|
30
30
|
kid: publicKey.kid,
|
31
31
|
typ: "wiar+jwt"
|
32
|
-
}).setPayload({
|
33
|
-
iss: keyThumbprint,
|
34
|
-
sub: walletProviderBaseUrl,
|
35
|
-
jti: `${_reactNativeUuid.default.v4()}`,
|
36
|
-
type: "WalletInstanceAttestationRequest",
|
37
|
-
cnf: {
|
38
|
-
jwk: (0, _jwk.fixBase64EncodingOnKey)(publicKey)
|
39
|
-
}
|
40
32
|
}).setIssuedAt().setExpirationTime("1h").sign();
|
41
33
|
}
|
42
34
|
|
@@ -53,8 +45,8 @@ const getAttestation = _ref => {
|
|
53
45
|
wiaCryptoContext,
|
54
46
|
appFetch = fetch
|
55
47
|
} = _ref;
|
56
|
-
return async
|
57
|
-
const signedAttestationRequest = await getAttestationRequest(wiaCryptoContext,
|
48
|
+
return async walletProviderEntityConfiguration => {
|
49
|
+
const signedAttestationRequest = await getAttestationRequest(wiaCryptoContext, walletProviderEntityConfiguration);
|
58
50
|
const decodedRequest = (0, _ioReactNativeJwt.decode)(signedAttestationRequest);
|
59
51
|
const parsedRequest = _types.WalletInstanceAttestationRequestJwt.parse({
|
60
52
|
payload: decodedRequest.payload,
|
@@ -62,7 +54,7 @@ const getAttestation = _ref => {
|
|
62
54
|
});
|
63
55
|
const publicKey = parsedRequest.payload.cnf.jwk;
|
64
56
|
await (0, _ioReactNativeJwt.verify)(signedAttestationRequest, publicKey);
|
65
|
-
const tokenUrl =
|
57
|
+
const tokenUrl = walletProviderEntityConfiguration.payload.metadata.wallet_provider.token_endpoint;
|
66
58
|
const requestBody = {
|
67
59
|
grant_type: "urn:ietf:params:oauth:client-assertion-type:jwt-client-attestation",
|
68
60
|
assertion: signedAttestationRequest
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_ioReactNativeJwt","require","_jwk","_types","_reactNativeUuid","_interopRequireDefault","_errors","obj","__esModule","default","getAttestationRequest","wiaCryptoContext","
|
1
|
+
{"version":3,"names":["_ioReactNativeJwt","require","_jwk","_types","_reactNativeUuid","_interopRequireDefault","_errors","obj","__esModule","default","getAttestationRequest","wiaCryptoContext","walletProviderEntityConfiguration","jwk","getPublicKey","parsedJwk","JWK","parse","keyThumbprint","thumbprint","publicKey","kid","SignJWT","setPayload","iss","aud","payload","jti","uuid","v4","nonce","cnf","fixBase64EncodingOnKey","setProtectedHeader","typ","setIssuedAt","setExpirationTime","sign","getAttestation","_ref","appFetch","fetch","signedAttestationRequest","decodedRequest","decodeJwt","parsedRequest","WalletInstanceAttestationRequestJwt","header","protectedHeader","verifyJwt","tokenUrl","metadata","wallet_provider","token_endpoint","requestBody","grant_type","assertion","response","method","headers","body","JSON","stringify","status","text","WalletInstanceAttestationIssuingError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cAAA"}
|
package/lib/module/index.js
CHANGED
@@ -6,10 +6,7 @@ import * as RP from "./rp";
|
|
6
6
|
import * as Errors from "./utils/errors";
|
7
7
|
import * as WalletInstanceAttestation from "./wallet-instance-attestation";
|
8
8
|
import * as RelyingPartySolution from "./rp";
|
9
|
-
import {
|
10
|
-
import { verifyTrustChain, getEntityConfiguration } from "./trust";
|
11
|
-
import { EntityConfiguration, EntityStatement, TrustAnchorEntityConfiguration } from "./trust/types";
|
9
|
+
import { verifyTrustChain, getEntityConfiguration, getCredentialIssuerEntityConfiguration, getRelyingPartyEntityConfiguration, getTrustAnchorEntityConfiguration, getWalletProviderEntityConfiguration } from "./trust";
|
12
10
|
import { createCryptoContextFor } from "./utils/crypto";
|
13
|
-
|
14
|
-
export { PID, RP, WalletInstanceAttestation, Errors, RelyingPartySolution, verifyTrustChain, getEntityConfiguration, EntityConfiguration, EntityStatement, RpEntityConfiguration, PidIssuerEntityConfiguration, TrustAnchorEntityConfiguration, createCryptoContextFor };
|
11
|
+
export { PID, RP, WalletInstanceAttestation, Errors, RelyingPartySolution, verifyTrustChain, getEntityConfiguration, getCredentialIssuerEntityConfiguration, getRelyingPartyEntityConfiguration, getTrustAnchorEntityConfiguration, getWalletProviderEntityConfiguration, createCryptoContextFor };
|
15
12
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["PID","RP","Errors","WalletInstanceAttestation","RelyingPartySolution","
|
1
|
+
{"version":3,"names":["PID","RP","Errors","WalletInstanceAttestation","RelyingPartySolution","verifyTrustChain","getEntityConfiguration","getCredentialIssuerEntityConfiguration","getRelyingPartyEntityConfiguration","getTrustAnchorEntityConfiguration","getWalletProviderEntityConfiguration","createCryptoContextFor"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA;AACA;AACA,OAAO,gCAAgC;AAEvC,OAAO,KAAKA,GAAG,MAAM,OAAO;AAC5B,OAAO,KAAKC,EAAE,MAAM,MAAM;AAC1B,OAAO,KAAKC,MAAM,MAAM,gBAAgB;AACxC,OAAO,KAAKC,yBAAyB,MAAM,+BAA+B;AAC1E,OAAO,KAAKC,oBAAoB,MAAM,MAAM;AAC5C,SACEC,gBAAgB,EAChBC,sBAAsB,EACtBC,sCAAsC,EACtCC,kCAAkC,EAClCC,iCAAiC,EACjCC,oCAAoC,QAC/B,SAAS;AAChB,SAASC,sBAAsB,QAAQ,gBAAgB;AAEvD,SACEX,GAAG,EACHC,EAAE,EACFE,yBAAyB,EACzBD,MAAM,EACNE,oBAAoB,EACpBC,gBAAgB,EAChBC,sBAAsB,EACtBC,sCAAsC,EACtCC,kCAAkC,EAClCC,iCAAiC,EACjCC,oCAAoC,EACpCC,sBAAsB"}
|
@@ -3,25 +3,13 @@ import { JWK } from "../utils/jwk";
|
|
3
3
|
import uuid from "react-native-uuid";
|
4
4
|
import { PidIssuingError } from "../utils/errors";
|
5
5
|
import { createDPopToken } from "../utils/dpop";
|
6
|
-
import
|
7
|
-
import { createCryptoContextFor, getEntityConfiguration as getGenericEntityConfiguration } from "..";
|
6
|
+
import * as WalletInstanceAttestation from "../wallet-instance-attestation";
|
8
7
|
import { generate, deleteKey } from "@pagopa/io-react-native-crypto";
|
9
8
|
import { SdJwt } from ".";
|
9
|
+
import { createCryptoContextFor } from "../utils/crypto";
|
10
10
|
// This is a temporary type that will be used for demo purposes only
|
11
11
|
|
12
|
-
|
13
|
-
* Obtain the PID provider entity configuration.
|
14
|
-
*/
|
15
|
-
export const getEntityConfiguration = function () {
|
16
|
-
let {
|
17
|
-
appFetch = fetch
|
18
|
-
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
19
|
-
return async relyingPartyBaseUrl => {
|
20
|
-
return getGenericEntityConfiguration(relyingPartyBaseUrl, {
|
21
|
-
appFetch: appFetch
|
22
|
-
}).then(PidIssuerEntityConfiguration.parse);
|
23
|
-
};
|
24
|
-
};
|
12
|
+
const assertionType = "urn:ietf:params:oauth:client-assertion-type:jwt-client-attestation";
|
25
13
|
|
26
14
|
/**
|
27
15
|
* Make a PAR request to the PID issuer and return the response url
|
@@ -37,17 +25,21 @@ const getPar = _ref => {
|
|
37
25
|
// The signature can be verified by reading the public key from the key set shippet with the it will ship the Wallet Instance Attestation;
|
38
26
|
// key is matched by its kid, which is supposed to be the thumbprint of its public key.
|
39
27
|
const keyThumbprint = await wiaCryptoContext.getPublicKey().then(JWK.parse).then(thumbprint);
|
28
|
+
const iss = WalletInstanceAttestation.decode(walletInstanceAttestation).payload.cnf.jwk.kid;
|
40
29
|
const codeChallenge = await sha256ToBase64(codeVerifier);
|
41
30
|
const signedJwtForPar = await new SignJWT(wiaCryptoContext).setProtectedHeader({
|
42
31
|
kid: keyThumbprint
|
43
32
|
}).setPayload({
|
44
|
-
|
33
|
+
iss,
|
34
|
+
aud: pidProviderEntityConfiguration.payload.iss,
|
35
|
+
jti: `${uuid.v4()}`,
|
36
|
+
client_assertion_type: assertionType,
|
45
37
|
authorization_details: [{
|
46
|
-
|
47
|
-
type:
|
38
|
+
credential_definition: {
|
39
|
+
type: "PersonIdentificationData"
|
48
40
|
},
|
49
41
|
format: "vc+sd-jwt",
|
50
|
-
type: "
|
42
|
+
type: "openid_credential"
|
51
43
|
}],
|
52
44
|
response_type: "code",
|
53
45
|
code_challenge_method: "s256",
|
@@ -62,7 +54,7 @@ const getPar = _ref => {
|
|
62
54
|
client_id: clientId,
|
63
55
|
code_challenge: codeChallenge,
|
64
56
|
code_challenge_method: "S256",
|
65
|
-
client_assertion_type:
|
57
|
+
client_assertion_type: assertionType,
|
66
58
|
client_assertion: walletInstanceAttestation,
|
67
59
|
request: signedJwtForPar
|
68
60
|
};
|
@@ -123,7 +115,7 @@ export const authorizeIssuing = _ref2 => {
|
|
123
115
|
client_id: clientId,
|
124
116
|
code: authorizationCode,
|
125
117
|
code_verifier: codeVerifier,
|
126
|
-
client_assertion_type:
|
118
|
+
client_assertion_type: assertionType,
|
127
119
|
client_assertion: walletInstanceAttestation,
|
128
120
|
redirect_uri: walletProviderBaseUrl
|
129
121
|
};
|
@@ -159,7 +151,8 @@ export const authorizeIssuing = _ref2 => {
|
|
159
151
|
*/
|
160
152
|
const createNonceProof = async (nonce, issuer, audience, ctx) => {
|
161
153
|
return new SignJWT(ctx).setPayload({
|
162
|
-
nonce
|
154
|
+
nonce,
|
155
|
+
jwk: await ctx.getPublicKey()
|
163
156
|
}).setProtectedHeader({
|
164
157
|
type: "openid4vci-proof+jwt"
|
165
158
|
}).setAudience(audience).setIssuer(issuer).setIssuedAt().setExpirationTime("1h").sign();
|
@@ -195,7 +188,7 @@ export const getCredential = _ref3 => {
|
|
195
188
|
const credentialUrl = pidProviderEntityConfiguration.payload.metadata.openid_credential_issuer.credential_endpoint;
|
196
189
|
const requestBody = {
|
197
190
|
credential_definition: JSON.stringify({
|
198
|
-
type: ["
|
191
|
+
type: ["PersonIdentificationData"]
|
199
192
|
}),
|
200
193
|
format: "vc+sd-jwt",
|
201
194
|
proof: JSON.stringify({
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["sha256ToBase64","SignJWT","thumbprint","JWK","uuid","PidIssuingError","createDPopToken","
|
1
|
+
{"version":3,"names":["sha256ToBase64","SignJWT","thumbprint","JWK","uuid","PidIssuingError","createDPopToken","WalletInstanceAttestation","generate","deleteKey","SdJwt","createCryptoContextFor","assertionType","getPar","_ref","wiaCryptoContext","appFetch","fetch","clientId","codeVerifier","walletProviderBaseUrl","pidProviderEntityConfiguration","walletInstanceAttestation","keyThumbprint","getPublicKey","then","parse","iss","decode","payload","cnf","jwk","kid","codeChallenge","signedJwtForPar","setProtectedHeader","setPayload","aud","jti","v4","client_assertion_type","authorization_details","credential_definition","type","format","response_type","code_challenge_method","redirect_uri","state","client_id","code_challenge","setIssuedAt","setExpirationTime","sign","parUrl","metadata","openid_credential_issuer","pushed_authorization_request_endpoint","requestBody","client_assertion","request","formBody","URLSearchParams","response","method","headers","body","toString","status","result","json","request_uri","text","authorizeIssuing","_ref2","_","authorizationCode","tokenUrl","token_endpoint","keytag","ephemeralContext","signedDPop","htm","htu","grant_type","code","code_verifier","DPoP","c_nonce","access_token","accessToken","nonce","createNonceProof","issuer","audience","ctx","setAudience","setIssuer","getCredential","_ref3","pidCryptoContext","_ref4","cieData","signedDPopForPid","signedNonceProof","credentialUrl","credential_endpoint","JSON","stringify","proof","jwt","proof_type","Authorization","pidResponse","validatePid","credential","pidJwt","decoded","pidKey","holderBindedKey","sdJwt"],"sourceRoot":"../../../src","sources":["pid/issuing.ts"],"mappings":"AAAA,SACEA,cAAc,EAEdC,OAAO,EACPC,UAAU,QACL,6BAA6B;AACpC,SAASC,GAAG,QAAQ,cAAc;AAClC,OAAOC,IAAI,MAAM,mBAAmB;AACpC,SAASC,eAAe,QAAQ,iBAAiB;AACjD,SAASC,eAAe,QAAQ,eAAe;AAE/C,OAAO,KAAKC,yBAAyB,MAAM,gCAAgC;AAC3E,SAASC,QAAQ,EAAEC,SAAS,QAAQ,gCAAgC;AACpE,SAASC,KAAK,QAAQ,GAAG;AACzB,SAASC,sBAAsB,QAAQ,iBAAiB;AACxD;;AAwBA,MAAMC,aAAa,GACjB,oEAAoE;;AAEtE;AACA;AACA;AACA,MAAMC,MAAM,GACVC,IAAA;EAAA,IAAC;IACCC,gBAAgB;IAChBC,QAAQ,GAAGC;EAIb,CAAC,GAAAH,IAAA;EAAA,OACD,OACEI,QAAgB,EAChBC,YAAoB,EACpBC,qBAA6B,EAC7BC,8BAAmE,EACnEC,yBAAiC,KACb;IACpB;IACA;IACA;IACA;IACA,MAAMC,aAAa,GAAG,MAAMR,gBAAgB,CACzCS,YAAY,CAAC,CAAC,CACdC,IAAI,CAACtB,GAAG,CAACuB,KAAK,CAAC,CACfD,IAAI,CAACvB,UAAU,CAAC;IAEnB,MAAMyB,GAAG,GAAGpB,yBAAyB,CAACqB,MAAM,CAACN,yBAAyB,CAAC,CACpEO,OAAO,CAACC,GAAG,CAACC,GAAG,CAACC,GAAG;IAE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AAGF,OAAO,CAACG,KAAK,CAAC3F,OAAO,CAACC,GAAG,CAACC,GAAG;EAErD,IAAI,CAAC,MAAM7B,UAAU,CAACoH,MAAM,CAAC,OAAO,MAAMpH,UAAU,CAACqH,eAAe,CAAC,CAAC,EAAE;IACtE,MAAM,IAAIlH,eAAe,CACtB,uGAAsGsG,IAAI,CAACC,SAAS,CACnHU,MACF,CAAE,kCAAiCX,IAAI,CAACC,SAAS,CAACW,eAAe,CAAE,EACrE,CAAC;EACH;AACF,CAAC"}
|
@@ -1,6 +1,6 @@
|
|
1
|
+
import { RelyingPartyEntityConfiguration } from "../../trust/types";
|
1
2
|
import * as RelyingPartySolution from "..";
|
2
3
|
import { AuthRequestDecodeError } from "../../utils/errors";
|
3
|
-
import { RpEntityConfiguration } from "../types";
|
4
4
|
describe("decodeAuthRequestQR", () => {
|
5
5
|
it("should return authentication request URL", async () => {
|
6
6
|
const qrcode = "ZXVkaXc6Ly9hdXRob3JpemU/Y2xpZW50X2lkPWh0dHBzOi8vdmVyaWZpZXIuZXhhbXBsZS5vcmcmcmVxdWVzdF91cmk9aHR0cHM6Ly92ZXJpZmllci5leGFtcGxlLm9yZy9yZXF1ZXN0X3VyaQ==";
|
@@ -156,7 +156,7 @@ describe("RpEntityConfiguration", () => {
|
|
156
156
|
authority_hints: ["https://demo.federation.eudi.wallet.developers.italia.it"]
|
157
157
|
}
|
158
158
|
};
|
159
|
-
const result =
|
159
|
+
const result = RelyingPartyEntityConfiguration.safeParse(pp);
|
160
160
|
if (result.success === false) {
|
161
161
|
throw result.error;
|
162
162
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["
|
1
|
+
{"version":3,"names":["RelyingPartyEntityConfiguration","RelyingPartySolution","AuthRequestDecodeError","describe","it","qrcode","result","decodeAuthRequestQR","expect","requestURI","toEqual","toThrowError","pp","header","alg","kid","typ","payload","exp","iat","iss","sub","jwks","keys","kty","e","n","metadata","federation_entity","organization_name","homepage_uri","policy_uri","logo_uri","contacts","wallet_relying_party","application_type","authorization_encrypted_response_alg","authorization_encrypted_response_enc","authorization_signed_response_alg","client_id","client_name","default_acr_values","default_max_age","id_token_encrypted_response_alg","id_token_encrypted_response_enc","id_token_signed_response_alg","presentation_definitions","id","input_descriptors","format","constraints","fields","filter","const","type","path","intent_to_retain","limit_disclosure","jwt","mso_mdoc","redirect_uris","request_uris","require_auth_time","subject_type","vp_formats","jwt_vp_json","crv","d","use","x","y","p","q","authority_hints","safeParse","success","error","toBe"],"sourceRoot":"../../../../src","sources":["rp/__test__/index.test.ts"],"mappings":"AAAA,SAASA,+BAA+B,QAAQ,mBAAmB;AACnE,OAAO,KAAKC,oBAAoB,MAAM,IAAI;AAC1C,SAASC,sBAAsB,QAAQ,oBAAoB;AAE3DC,QAAQ,CAAC,qBAAqB,EAAE,MAAM;EACpCC,EAAE,CAAC,0CAA0C,EAAE,YAAY;IACzD,MAAMC,MAAM,GACV,sJAAsJ;IACxJ,MAAMC,MAAM,GAAGL,oBAAoB,CAACM,mBAAmB,CAACF,MAAM,CAAC;IAC/DG,MAAM,CAACF,MAAM,CAACG,UAAU,CAAC,CAACC,OAAO,CAC/B,0CACF,CAAC;EACH,CAAC,CAAC;EACFN,EAAE,CAAC,wCAAwC,EAAE,YAAY;IACvD,MAAMC,MAAM,GAAG,0BAA0B;IACzCG,MAAM,CAAC,MAAMP,oBAAoB,CAACM,mBAAmB,CAACF,MAAM,CAAC,CAAC,CAACM,YAAY,CACzET,sBACF,CAAC;EACH,CAAC,CAAC;AACJ,CAAC,CAAC;AAEFC,QAAQ,CAAC,uBAAuB,EAAE,MAAM;EACtCC,EAAE,CAAC,2BAA2B,EAAE,YAAY;IAC1C,MAAMQ,EAAE,GAAG;MACTC,MAAM,EAAE;QACNC,GAAG,EAAE,OAAO;QACZC,GAAG,EAAE,6CAA6C;QAClDC,GAAG,EAAE;MACP,CAAC;MACDC,OAAO,EAAE;QACPC,GAAG,EAAE,UAAU;QACfC,GAAG,EAAE,UAAU;QACf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;IACApE,MAAM,CAACF,MAAM,CAACqE,OAAO,CAAC,CAACE,IAAI,CAAC,IAAI,CAAC;EACnC,CAAC,CAAC;AACJ,CAAC,CAAC"}
|
package/lib/module/rp/index.js
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
import { AuthRequestDecodeError, IoWalletError, NoSuitableKeysFoundInEntityConfiguration } from "../utils/errors";
|
2
2
|
import { decode as decodeJwt, decodeBase64, sha256ToBase64, SignJWT, EncryptJwe, verify } from "@pagopa/io-react-native-jwt";
|
3
|
-
import { QRCodePayload, RequestObject
|
3
|
+
import { QRCodePayload, RequestObject } from "./types";
|
4
4
|
import uuid from "react-native-uuid";
|
5
5
|
import { disclose } from "../sd-jwt";
|
6
|
-
import { getEntityConfiguration as getGenericEntityConfiguration } from "../trust";
|
7
6
|
import { createDPopToken } from "../utils/dpop";
|
8
|
-
import
|
7
|
+
import * as WalletInstanceAttestation from "../wallet-instance-attestation";
|
9
8
|
|
10
9
|
/**
|
11
10
|
* Select a RSA public key from those provided by the RP to encrypt.
|
@@ -24,20 +23,6 @@ const chooseRSAPublicKeyToEncrypt = entity => {
|
|
24
23
|
throw new NoSuitableKeysFoundInEntityConfiguration("Encrypt with RP public key");
|
25
24
|
};
|
26
25
|
|
27
|
-
/**
|
28
|
-
* Obtain the relying party entity configuration.
|
29
|
-
*/
|
30
|
-
export const getEntityConfiguration = function () {
|
31
|
-
let {
|
32
|
-
appFetch = fetch
|
33
|
-
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
34
|
-
return async relyingPartyBaseUrl => {
|
35
|
-
return getGenericEntityConfiguration(relyingPartyBaseUrl, {
|
36
|
-
appFetch: appFetch
|
37
|
-
}).then(RpEntityConfiguration.parse);
|
38
|
-
};
|
39
|
-
};
|
40
|
-
|
41
26
|
/**
|
42
27
|
* Decode a QR code content to an authentication request url.
|
43
28
|
* @function
|