Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Fix entity configuration #21

Merged
merged 4 commits into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"FederationEntityPolicyUri": "FEDERATION_ENTITY_PRIVACY_URI",
"FederationEntityTosUri": "FEDERATION_ENTITY_TOS_URI",
"FederationEntityLogoUri": "FEDERATION_ENTITY_LOGO_URI"
"FederationEntityTrustAnchorUri": "FEDERATION_ENTITY_TRUST_ANCHOR_URI",
"WalletKeys": "ARRAY_OF_WALLET_KEYS_IN_JWK_FORMAT_BASE64_ENCODED"
}
}
1 change: 1 addition & 0 deletions apps/io-func-wallet-solution-backend/src/app/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const getFederationEntityConfigFromEnvironment: RE.ReaderEither<
policyUri: readFromEnvironment("FederationEntityPolicyUri"),
tosUri: readFromEnvironment("FederationEntityTosUri"),
logoUri: readFromEnvironment("FederationEntityLogoUri"),
trustAnchorUri: readFromEnvironment("FederationEntityTrustAnchorUri"),
}),
RE.chainEitherKW(
validate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@ import { EntityConfigurationPayload } from "../entity-configuration";
export const EntityConfigurationJwtModel = t.type({
iss: t.string,
sub: t.string,
authority_hints: t.array(t.string),
jwks: t.type({
keys: t.array(JwkPublicKey),
}),
metadata: t.type({
eudi_wallet_provider: t.type({
jwks: t.array(JwkPublicKey),
wallet_provider: t.type({
jwks: t.type({
keys: t.array(JwkPublicKey),
}),
token_endpoint: t.string,
asc_values_supported: t.array(t.string),
grant_types_supported: t.array(t.string),
Expand All @@ -35,9 +41,15 @@ export const EntityConfigurationToJwtModel: E.Encoder<
encode: ({ iss, sub, walletProviderMetadata, federationEntity }) => ({
iss,
sub,
authority_hints: [federationEntity.trustAnchorUri],
jwks: {
keys: walletProviderMetadata.jwks,
},
metadata: {
eudi_wallet_provider: {
jwks: walletProviderMetadata.jwks,
wallet_provider: {
jwks: {
keys: walletProviderMetadata.jwks,
},
token_endpoint: walletProviderMetadata.tokenEndpoint,
asc_values_supported: walletProviderMetadata.ascValues,
grant_types_supported: walletProviderMetadata.grantTypesSupported,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const WalletInstanceAttestationToJwtModel: E.Encoder<
type,
federationEntity,
asc,
publicJwk,
walletInstancePublicKey,
algValueSupported,
}) => ({
iss,
Expand All @@ -58,7 +58,7 @@ export const WalletInstanceAttestationToJwtModel: E.Encoder<
logo_uri: federationEntity.logoUri,
asc,
cnf: {
jwk: publicJwk,
jwk: walletInstancePublicKey,
},
authorization_endpoint: "eudiw",
response_types_supported: ["vp_token"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const FederationEntityMetadata = t.type({
policyUri: UrlFromString,
tosUri: UrlFromString,
logoUri: UrlFromString,
trustAnchorUri: UrlFromString,
});

export type FederationEntityMetadata = t.TypeOf<
Expand All @@ -44,6 +45,7 @@ export const FederationEntity = t.type({
policyUri: t.string,
tosUri: t.string,
logoUri: t.string,
trustAnchorUri: t.string,
});

const WalletProviderMetadataPayload = t.type({
Expand Down Expand Up @@ -106,6 +108,7 @@ export const getEntityConfiguration =
policyUri: federationEntityMetadata.policyUri.href,
tosUri: federationEntityMetadata.tosUri.href,
logoUri: federationEntityMetadata.logoUri.href,
trustAnchorUri: federationEntityMetadata.trustAnchorUri.href,
},
},
EntityConfigurationToJwtModel.encode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ const federationEntityMetadata: FederationEntityMetadata = {
logoUri: new URL(
"https://wallet-provider.example.org/logo.svg"
) as unknown as ValidUrl,
trustAnchorUri: new URL(
"https://trust-anchor.example.org/logo.svg"
) as unknown as ValidUrl,
};

describe("CreateWalletInstanceAttestationHandler", async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const WalletInstanceAttestationPayload = t.type({
type: t.literal("WalletInstanceAttestation"),
federationEntity: FederationEntity,
asc: t.string,
publicJwk: JwkPublicKey,
walletInstancePublicKey: JwkPublicKey,
algValueSupported: t.array(t.string),
});

Expand Down Expand Up @@ -58,9 +58,10 @@ export const createWalletInstanceAttestation =
policyUri: federationEntityMetadata.policyUri.href,
tosUri: federationEntityMetadata.tosUri.href,
logoUri: federationEntityMetadata.logoUri.href,
trustAnchorUri: federationEntityMetadata.trustAnchorUri.href,
},
asc: pipe(federationEntityMetadata.basePath, getLoAUri(LoA.basic)),
publicJwk,
walletInstancePublicKey: request.payload.cnf.jwk,
algValueSupported: supportedSignAlgorithms,
},
WalletInstanceAttestationToJwtModel.encode,
Expand Down