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

feature/SPRIND-116 #315

Open
wants to merge 22 commits into
base: funke
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"@sphereon/ssi-sdk-ext.did-resolver-jwk": "0.26.1-next.11",
"@sphereon/ssi-sdk-ext.did-resolver-key": "0.26.1-next.11",
"@sphereon/ssi-sdk-ext.did-utils": "0.26.1-next.11",
"@sphereon/ssi-sdk-ext.identifier-resolution": "0.26.1-next.11",
"@sphereon/ssi-sdk-ext.identifier-resolution": "file:../SSI-SDK-crypto-extensions/packages/identifier-resolution",
"@sphereon/ssi-sdk-ext.jwt-service": "0.26.1-next.11",
"@sphereon/ssi-sdk-ext.key-manager": "0.26.1-next.11",
"@sphereon/ssi-sdk-ext.key-utils": "0.26.1-next.11",
Expand Down
41 changes: 30 additions & 11 deletions src/machines/siopV2Machine.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import {PresentationDefinitionWithLocation, VerifiedAuthorizationRequest} from '@sphereon/did-auth-siop';
import {
ClientMetadataOpts,
PresentationDefinitionWithLocation,
VerifiedAuthorizationRequest,
} from '@sphereon/did-auth-siop';
import {DidAuthConfig, Identity, Party} from '@sphereon/ssi-sdk.data-store';
import {assign, createMachine, DoneInvokeEvent, interpret} from 'xstate';
import {translate} from '../localization/Localization';
Expand Down Expand Up @@ -28,18 +32,15 @@ import {
SiopV2MachineServices,
SiopV2MachineState,
SiopV2MachineStates,
SiopV2StateMachine,
} from '../types/machines/siopV2';
import {EvaluationResults, PEX, Status} from '@sphereon/pex';
import {ActionType, DefaultActionSubType, InitiatorType, LogLevel, OriginalVerifiableCredential, SubSystem, System} from '@sphereon/ssi-types';
import {UniqueDigitalCredential} from '@sphereon/ssi-sdk.credential-store';
import store from '../store';
import {storeActivityLogging} from '../store/actions/logging.actions';
import {
ExternalIdentifierOIDFEntityIdResult,
PublicKeyHex,
TrustedAnchor,
} from '@sphereon/ssi-sdk-ext.identifier-resolution/src/types/externalIdentifierTypes';
import {ExternalIdentifierOIDFEntityIdResult, TrustedAnchor} from '@sphereon/ssi-sdk-ext.identifier-resolution/src/types/externalIdentifierTypes';
import {JwsPayload} from '@sphereon/ssi-sdk-ext.jwt-service';
import {AuthorizationServerMetadata, CredentialIssuerMetadata} from '@sphereon/oid4vci-common';

const siopV2HasNoContactGuard = (_ctx: SiopV2MachineContext, _event: SiopV2MachineEventTypes): boolean => {
const {contact} = _ctx;
Expand Down Expand Up @@ -136,7 +137,10 @@ const siopV2IsOIDFOriginGuard = (_ctx: SiopV2MachineContext, _event: SiopV2Machi
return trustAnchors.length > 0 && authorizationRequestData?.clientIdScheme === 'entity_id';
};

const createSiopV2Machine = (opts: CreateSiopV2MachineOpts): SiopV2StateMachine => {
const createSiopV2Machine = (opts: CreateSiopV2MachineOpts): StateMachine<SiopV2MachineContext, any, SiopV2MachineEventTypes, {
value: any;
context: TContext
}, BaseActionObject, ServiceMap, ResolveTypegenMeta<TypegenDisabled, SiopV2MachineEventTypes, BaseActionObject, ServiceMap>> => {
const {url} = opts;
const initialContext: SiopV2MachineContext = {
url: new URL(url).toString(),
Expand Down Expand Up @@ -257,9 +261,24 @@ const createSiopV2Machine = (opts: CreateSiopV2MachineOpts): SiopV2StateMachine
src: SiopV2MachineServices.getFederationTrust,
onDone: {
target: SiopV2MachineStates.transitionFromSetup,
actions: assign({
trustedAnchors: (_ctx: SiopV2MachineContext, _event: DoneInvokeEvent<Array<TrustedAnchor>>) => _event.data,
}),
actions: [
assign({
trustedAnchors: (_ctx: SiopV2MachineContext, _event: DoneInvokeEvent<Array<TrustedAnchor>>) => _event.data
}),
assign({
oauth_authorization_server: (_ctx: SiopV2MachineContext, _event: DoneInvokeEvent<AuthorizationServerMetadata>) => _event.data,
openid_wallet_provider: (_ctx: SiopV2MachineContext, _event: DoneInvokeEvent<AuthorizationServerMetadata>) => _event.data,
}),
assign({
openid_credential_issuer: (_ctx: SiopV2MachineContext, _event: DoneInvokeEvent<CredentialIssuerMetadata>) => _event.data,
}),
assign({
openid_credential_verifier: (_ctx: SiopV2MachineContext, _event: DoneInvokeEvent<ClientMetadataOpts>) => _event.data
}),
assign({
federation_entity: (_ctx: SiopV2MachineContext, _event: DoneInvokeEvent<any>) => _event.data
})
]
},
onError: {
target: SiopV2MachineStates.handleError,
Expand Down
13 changes: 9 additions & 4 deletions src/services/machines/siopV2MachineService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {getContacts} from '../contactService';
import {IIdentifier} from '@veramo/core';
import {UniqueDigitalCredential} from '@sphereon/ssi-sdk.credential-store';
import {ActionType, DefaultActionSubType, InitiatorType, Loggers, LogLevel, SubSystem, System} from '@sphereon/ssi-types';
import {PublicKeyHex, TrustedAnchor} from '@sphereon/ssi-sdk-ext.identifier-resolution/src/types/externalIdentifierTypes';
import {storeActivityLogging} from '../../store/actions/logging.actions';

const logger = Loggers.DEFAULT.get('sphereon:siopV2MachineService');
Expand Down Expand Up @@ -222,7 +221,7 @@ export const sendResponse = async (

export const getFederationTrust = async (
context: Pick<SiopV2MachineContext, 'url' | 'authorizationRequestData' | 'trustAnchors'>,
): Promise<Array<TrustedAnchor>> => {
): Promise<Pick<SiopV2MachineContext, 'trustedAnchors' | 'federation_entity' | 'oauth_authorization_server' | 'openid_wallet_provider' | 'openid_credential_verifier' | 'openid_credential_issuer'>> => {
const {authorizationRequestData, trustAnchors} = context;

if (trustAnchors.length === 0) {
Expand All @@ -242,6 +241,12 @@ export const getFederationTrust = async (
trustAnchors: trustAnchors,
identifier: entityIdentifier,
});

return result.trustedAnchors;
return {
trustedAnchors: result.trustedAnchors,
federation_entity: result.jwtPayload.federation_entity,
openid_wallet_provider: result.jwtPayload.metadata.openid_wallet_provider,
oauth_authorization_server: result.jwtPayload.metadata.oauth_authorization_server,
openid_credential_issuer: result.jwtPayload.metadata.openid_credential_issuer,
openid_credential_verifier: result.jwtPayload.metadata.openid_credential_verifier
};
};
19 changes: 13 additions & 6 deletions src/types/machines/siopV2/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@ import {ReactNode} from 'react';
import {BaseActionObject, Interpreter, ResolveTypegenMeta, ServiceMap, State, StateMachine, TypegenDisabled} from 'xstate';
import {NativeStackNavigationProp} from '@react-navigation/native-stack';
import {IIdentifier} from '@veramo/core';
import {PresentationDefinitionWithLocation, RPRegistrationMetadataPayload, VerifiedAuthorizationRequest} from '@sphereon/did-auth-siop';
import {
ClientMetadataOpts,
PresentationDefinitionWithLocation,
RPRegistrationMetadataPayload,
VerifiedAuthorizationRequest,
} from '@sphereon/did-auth-siop';
import {DidAuthConfig, Party} from '@sphereon/ssi-sdk.data-store';
import {ErrorDetails} from '../../error';
import {UniqueDigitalCredential} from '@sphereon/ssi-sdk.credential-store';
import {
ExternalIdentifierOIDFEntityIdResult,
PublicKeyHex,
TrustedAnchor,
} from '@sphereon/ssi-sdk-ext.identifier-resolution/src/types/externalIdentifierTypes';
import {TrustedAnchor} from '@sphereon/ssi-sdk-ext.identifier-resolution/src/types/externalIdentifierTypes';
import {AuthorizationServerMetadata, CredentialIssuerMetadata} from '@sphereon/oid4vci-common';

export type SiopV2AuthorizationRequestData = {
correlationId: string;
Expand All @@ -36,6 +38,11 @@ export type SiopV2MachineContext = {
contactAlias: string;
selectedCredentials: Array<UniqueDigitalCredential>;
trustedAnchors?: Array<TrustedAnchor>;
federation_entity?: any
openid_wallet_provider?: AuthorizationServerMetadata
oauth_authorization_server?: AuthorizationServerMetadata
openid_credential_issuer?: CredentialIssuerMetadata
openid_credential_verifier?: ClientMetadataOpts
error?: ErrorDetails;
};

Expand Down
52 changes: 46 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3635,7 +3635,7 @@
varint "^6.0.0"
web-encoding "^1.1.5"

"@sphereon/[email protected]", "@sphereon/[email protected]", "@sphereon/[email protected]+c33024d":
"@sphereon/[email protected]", "@sphereon/[email protected]", "@sphereon/[email protected]+c33024d", "@sphereon/ssi-sdk-ext.did-utils@workspace:*":
version "0.26.1-next.11"
resolved "https://registry.yarnpkg.com/@sphereon/ssi-sdk-ext.did-utils/-/ssi-sdk-ext.did-utils-0.26.1-next.11.tgz#f459b7e0bc2dd7099f12f436f3987bb8f1c265db"
integrity sha512-c+nKP88CSBKtEmix2lXTHzngzhhcoXQGNFmjPOKPufk77Tqc2Y7GZC0aoFoa+pbmZW3ISL72ke3r50M8pHjdnw==
Expand Down Expand Up @@ -3689,6 +3689,21 @@
pkijs "^3.2.4"
uint8arrays "^3.1.1"

"@sphereon/ssi-sdk-ext.identifier-resolution@file:../SSI-SDK-crypto-extensions/packages/identifier-resolution":
version "0.26.0"
dependencies:
"@sphereon/ssi-sdk-ext.did-utils" "workspace:*"
"@sphereon/ssi-sdk-ext.key-utils" "workspace:*"
"@sphereon/ssi-sdk-ext.x509-utils" "workspace:*"
"@sphereon/ssi-sdk.agent-config" "0.30.2-feature.SDK.41.oidf.support.286"
"@sphereon/ssi-sdk.oidf-client" " 0.30.2-feature.SDK.41.oidf.support.286"
"@sphereon/ssi-types" "0.30.2-feature.SDK.41.oidf.support.286"
"@veramo/core" "4.2.0"
"@veramo/utils" "4.2.0"
debug "^4.3.4"
pkijs "^3.2.4"
uint8arrays "^3.1.1"

"@sphereon/[email protected]":
version "0.25.0"
resolved "https://registry.yarnpkg.com/@sphereon/ssi-sdk-ext.jwt-service/-/ssi-sdk-ext.jwt-service-0.25.0.tgz#614efaa52001214a7405b1e7a28b6d25a165296e"
Expand Down Expand Up @@ -3738,7 +3753,7 @@
"@veramo/key-manager" "4.2.0"
uint8arrays "^3.1.1"

"@sphereon/[email protected]", "@sphereon/[email protected]", "@sphereon/[email protected]+c33024d":
"@sphereon/[email protected]", "@sphereon/[email protected]", "@sphereon/[email protected]+c33024d", "@sphereon/ssi-sdk-ext.key-utils@workspace:*":
version "0.26.1-next.11"
resolved "https://registry.yarnpkg.com/@sphereon/ssi-sdk-ext.key-utils/-/ssi-sdk-ext.key-utils-0.26.1-next.11.tgz#d7eb22325d07e9a30441e7957d592b82e9e34079"
integrity sha512-Ac8KQfz/ud8jnOY14KBUtNzK3hx580GYbjAb2H+xKsn2JM/vskVSKHG84c50Ch7SJEc7umFM5FQPHB8mhc6OdA==
Expand Down Expand Up @@ -3775,7 +3790,7 @@
"@veramo/kms-local" "4.2.0"
text-encoding "^0.7.0"

"@sphereon/[email protected]", "@sphereon/[email protected]", "@sphereon/[email protected]+c33024d":
"@sphereon/[email protected]", "@sphereon/[email protected]", "@sphereon/[email protected]+c33024d", "@sphereon/ssi-sdk-ext.x509-utils@workspace:*":
version "0.26.1-next.11"
resolved "https://registry.yarnpkg.com/@sphereon/ssi-sdk-ext.x509-utils/-/ssi-sdk-ext.x509-utils-0.26.1-next.11.tgz#ad09a22d65cc1b990c66b67ec2030ae447b2c4ac"
integrity sha512-4YnJJc5XvCfDZ9iTI99BGvV5CanVHXLwoFgM4hM638PNR3/+J8+PpNzxMsbrviReY5CW/oHcUg7jknwRdv7yJg==
Expand Down Expand Up @@ -14054,7 +14069,16 @@ string-range@~1.2, string-range@~1.2.1:
resolved "https://registry.yarnpkg.com/string-range/-/string-range-1.2.2.tgz#a893ed347e72299bc83befbbf2a692a8d239d5dd"
integrity sha512-tYft6IFi8SjplJpxCUxyqisD3b+R2CSkomrtJYCkvuf1KuCAWgz7YXt4O0jip7efpfCemwHEzTEAO8EuOYgh3w==

"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
"string-width-cjs@npm:string-width@^4.2.0":
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
dependencies:
emoji-regex "^8.0.0"
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.1"

string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
Expand Down Expand Up @@ -14145,7 +14169,7 @@ string_decoder@~1.1.1:
dependencies:
safe-buffer "~5.1.0"

"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
Expand All @@ -14159,6 +14183,13 @@ strip-ansi@^5.0.0, strip-ansi@^5.2.0:
dependencies:
ansi-regex "^4.1.0"

strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
dependencies:
ansi-regex "^5.0.1"

strip-ansi@^7.0.1:
version "7.1.0"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45"
Expand Down Expand Up @@ -15265,7 +15296,7 @@ word-wrap@^1.2.5, word-wrap@~1.2.3:
resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.5.tgz#d2c45c6dd4fbce621a66f136cbe328afd0410b34"
integrity sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==

"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
Expand All @@ -15283,6 +15314,15 @@ wrap-ansi@^6.2.0:
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
dependencies:
ansi-styles "^4.0.0"
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^8.1.0:
version "8.1.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"
Expand Down