Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:Sphereon-Opensource/OID4VC into …
Browse files Browse the repository at this point in the history
…develop
  • Loading branch information
auer-martin committed Nov 25, 2024
2 parents c654a7b + dd8528d commit 50e6272
Show file tree
Hide file tree
Showing 42 changed files with 199 additions and 307 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"node": ">=18"
},
"resolutions": {
"@sphereon/ssi-types": "0.30.2-feature.mdoc.funke2.367",
"node-fetch": "2.6.12"
},
"prettier": {
Expand Down
11 changes: 2 additions & 9 deletions packages/callback-example/lib/__tests__/issuerCallback.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,7 @@ import {
ProofOfPossession,
} from '@sphereon/oid4vci-common'
import { CredentialOfferSession } from '@sphereon/oid4vci-common'
import {
AuthorizationServerMetadataBuilder,
CredentialSupportedBuilderV1_13,
VcIssuer,
VcIssuerBuilder
} from '@sphereon/oid4vci-issuer'
import { AuthorizationServerMetadataBuilder, CredentialSupportedBuilderV1_13, VcIssuer, VcIssuerBuilder } from '@sphereon/oid4vci-issuer'
import { MemoryStates } from '@sphereon/oid4vci-issuer'
import { CredentialDataSupplierResult } from '@sphereon/oid4vci-issuer/dist/types'
import { ICredential, IProofPurpose, IProofType, W3CVerifiableCredential } from '@sphereon/ssi-types'
Expand Down Expand Up @@ -52,7 +47,6 @@ async function proofOfPossessionCallbackFunction(args: Jwt, kid?: string): Promi
.sign(keypair.privateKey)
}


const authorizationServerMetadata = new AuthorizationServerMetadataBuilder()
.withIssuer(IDENTIPROOF_ISSUER_URL)
.withCredentialEndpoint('http://localhost:3456/test/credential-endpoint')
Expand All @@ -61,8 +55,7 @@ const authorizationServerMetadata = new AuthorizationServerMetadataBuilder()
.withTokenEndpointAuthMethodsSupported(['none', 'client_secret_basic', 'client_secret_jwt', 'client_secret_post'])
.withResponseTypesSupported(['code', 'token', 'id_token'])
.withScopesSupported(['openid', 'abcdef'])
.build();

.build()

async function verifyCallbackFunction(args: { jwt: string; kid?: string }): Promise<JwtVerifyResult<DIDDocument>> {
const result = await jose.jwtVerify(args.jwt, keypair.publicKey)
Expand Down
2 changes: 1 addition & 1 deletion packages/callback-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@sphereon/oid4vci-client": "workspace:*",
"@sphereon/oid4vci-common": "workspace:*",
"@sphereon/oid4vci-issuer": "workspace:*",
"@sphereon/ssi-types": "0.30.2-next.279",
"@sphereon/ssi-types": "0.30.2-feature.mdoc.funke2.367",
"jose": "^4.10.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/client/lib/MetadataClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export class MetadataClient {
: (authMetadata as CredentialIssuerMetadataV1_0_13);
}
debug(`Issuer ${issuer} token endpoint ${token_endpoint}, credential endpoint ${credential_endpoint}`);

return {
issuer,
token_endpoint,
Expand Down
4 changes: 2 additions & 2 deletions packages/client/lib/OpenID4VCIClientV1_0_13.ts
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ export class OpenID4VCIClientV1_0_13 {
console.log(`Not all credential types ${JSON.stringify(credentialTypes)} are present in metadata for ${this.getIssuer()}`);
// throw Error(`Not all credential types ${JSON.stringify(credentialTypes)} are supported by issuer ${this.getIssuer()}`);
}
} else if (metadata.credential_configurations_supported && typeof(metadata.credential_configurations_supported) === 'object') {
} else if (metadata.credential_configurations_supported && typeof metadata.credential_configurations_supported === 'object') {
let typeSupported = false;
Object.values(metadata.credential_configurations_supported).forEach((supportedCredential) => {
const subTypes = getTypesFromCredentialSupported(supportedCredential);
Expand All @@ -482,7 +482,7 @@ export class OpenID4VCIClientV1_0_13 {
) {
typeSupported = true;
}
})
});

if (!typeSupported) {
throw Error(`Not all credential types ${JSON.stringify(credentialTypes)} are supported by issuer ${this.getIssuer()}`);
Expand Down
8 changes: 1 addition & 7 deletions packages/client/lib/__tests__/SdJwt.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@ import {
import nock from 'nock';

import { OpenID4VCIClientV1_0_13 } from '..';
import {
AuthorizationServerMetadataBuilder,
createAccessTokenResponse,
IssuerMetadataBuilderV1_13,
VcIssuerBuilder
} from '../../../issuer'
import { AuthorizationServerMetadataBuilder, createAccessTokenResponse, IssuerMetadataBuilderV1_13, VcIssuerBuilder } from '../../../issuer';

export const UNIT_TEST_TIMEOUT = 30000;

Expand Down Expand Up @@ -42,7 +37,6 @@ const authorizationServerMetadata = new AuthorizationServerMetadataBuilder()
.withScopesSupported(['openid', 'abcdef'])
.build();


const vcIssuer = new VcIssuerBuilder()
.withIssuerMetadata(issuerMetadata)
.withAuthorizationMetadata(authorizationServerMetadata)
Expand Down
1 change: 0 additions & 1 deletion packages/client/lib/__tests__/SphereonE2E.spec.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,3 @@ describe('ismapolis bug report #63, https://github.com/Sphereon-Opensource/OID4V
console.log(JSON.stringify(credentialResponse.credential));
});
});

2 changes: 1 addition & 1 deletion packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"dependencies": {
"@sphereon/oid4vc-common": "workspace:*",
"@sphereon/oid4vci-common": "workspace:*",
"@sphereon/ssi-types": "0.30.2-next.279",
"@sphereon/ssi-types": "0.30.2-feature.mdoc.funke2.367",
"cross-fetch": "^3.1.8",
"debug": "^4.3.5"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/common/lib/jwt/Jwk.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ export interface JWK extends BaseJWK {
}

export type JWKS = {
keys: JWK[]
}
keys: JWK[];
};
32 changes: 16 additions & 16 deletions packages/common/lib/oauth/DynamicClientRegistration.types.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { JWKS } from '../jwt'
import { JWKS } from '../jwt';

// https://www.rfc-editor.org/rfc/rfc7591.html#section-2
export interface DynamicRegistrationClientMetadata {
redirect_uris?: string[]
token_endpoint_auth_method?: string
grant_types?: string
response_types?: string
client_name?: string
client_uri?: string
logo_uri?: string
scope?: string
contacts?: string[]
tos_uri?: string
policy_uri?: string
jwks_uri?: string
jwks?: JWKS
software_id?: string
software_version?: string
redirect_uris?: string[];
token_endpoint_auth_method?: string;
grant_types?: string;
response_types?: string;
client_name?: string;
client_uri?: string;
logo_uri?: string;
scope?: string;
contacts?: string[];
tos_uri?: string;
policy_uri?: string;
jwks_uri?: string;
jwks?: JWKS;
software_id?: string;
software_version?: string;
}
2 changes: 1 addition & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"build:clean": "tsc --build --clean && tsc --build"
},
"dependencies": {
"@sphereon/ssi-types": "0.30.2-next.279",
"@sphereon/ssi-types": "0.30.2-feature.mdoc.funke2.367",
"jwt-decode": "^4.0.0",
"sha.js": "^2.4.11",
"uint8arrays": "3.1.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/did-auth-siop-adapter/lib/did/DidJWT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,9 @@ export function getSubDidFromPayload(payload: JWTPayload, header?: JWTHeader): s

export function isIssSelfIssued(payload: JWTPayload): boolean {
return (
(payload.iss && (payload.iss.includes(ResponseIss.SELF_ISSUED_V1)) ||
(payload.iss && payload.iss.includes(ResponseIss.SELF_ISSUED_V1)) ||
(payload.iss && payload.iss.includes(ResponseIss.SELF_ISSUED_V2)) ||
payload.iss === payload.sub)
payload.iss === payload.sub
)
}

Expand Down
35 changes: 10 additions & 25 deletions packages/issuer-rest/lib/__tests__/ClientIssuerIT.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@ import {
JWTPayload,
OpenId4VCIVersion,
PRE_AUTH_CODE_LITERAL,
PRE_AUTH_GRANT_LITERAL
PRE_AUTH_GRANT_LITERAL,
} from '@sphereon/oid4vci-common'
import {
AuthorizationServerMetadataBuilder
} from '@sphereon/oid4vci-issuer'
import { AuthorizationServerMetadataBuilder } from '@sphereon/oid4vci-issuer'
import { VcIssuer } from '@sphereon/oid4vci-issuer/dist/VcIssuer'
import { CredentialSupportedBuilderV1_13, VcIssuerBuilder } from '@sphereon/oid4vci-issuer/dist/builder'
import { MemoryStates } from '@sphereon/oid4vci-issuer/dist/state-manager'
Expand Down Expand Up @@ -57,7 +55,6 @@ describe('VcIssuer', () => {
// const clientId = 'sphereon:wallet'
const preAuthorizedCode = 'test_code'


const authorizationServerMetadata = new AuthorizationServerMetadataBuilder()
.withIssuer(ISSUER_URL)
.withCredentialEndpoint('http://localhost:3456/test/credential-endpoint')
Expand All @@ -66,7 +63,7 @@ describe('VcIssuer', () => {
.withTokenEndpointAuthMethodsSupported(['none', 'client_secret_basic', 'client_secret_jwt', 'client_secret_post'])
.withResponseTypesSupported(['code', 'token', 'id_token'])
.withScopesSupported(['openid', 'abcdef'])
.build();
.build()
/*const preAuthorizedCode1 = 'SplxlOBeZQQYbYS6WxSbIA1'
const preAuthorizedCode2 = 'SplxlOBeZQQYbYS6WxSbIA2'
const preAuthorizedCode3 = 'SplxlOBeZQQYbYS6WxSbIA3'
Expand Down Expand Up @@ -269,25 +266,13 @@ describe('VcIssuer', () => {
it('should retrieve server metadata', async () => {
await expect(client.retrieveServerMetadata()).resolves.toEqual({
authorizationServerMetadata: {
'authorization_endpoint': 'https://token-endpoint.example.com/authorize',
'credential_endpoint': 'http://localhost:3456/test/credential-endpoint',
'issuer': 'http://localhost:3456/test',
'response_types_supported': [
'code',
'token',
'id_token'
],
'scopes_supported': [
'openid',
'abcdef'
],
'token_endpoint': 'http://localhost:3456/test/token',
'token_endpoint_auth_methods_supported': [
'none',
'client_secret_basic',
'client_secret_jwt',
'client_secret_post'
]
authorization_endpoint: 'https://token-endpoint.example.com/authorize',
credential_endpoint: 'http://localhost:3456/test/credential-endpoint',
issuer: 'http://localhost:3456/test',
response_types_supported: ['code', 'token', 'id_token'],
scopes_supported: ['openid', 'abcdef'],
token_endpoint: 'http://localhost:3456/test/token',
token_endpoint_auth_methods_supported: ['none', 'client_secret_basic', 'client_secret_jwt', 'client_secret_post'],
},
authorizationServerType: 'OID4VCI',
authorization_endpoint: 'https://token-endpoint.example.com/authorize',
Expand Down
35 changes: 15 additions & 20 deletions packages/issuer-rest/lib/__tests__/IssuerTokenServer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ import {
URIState,
} from '@sphereon/oid4vci-common'
import { VcIssuer } from '@sphereon/oid4vci-issuer'
import {
AuthorizationServerMetadataBuilder
} from '@sphereon/oid4vci-issuer'
import { AuthorizationServerMetadataBuilder } from '@sphereon/oid4vci-issuer'
import { MemoryStates } from '@sphereon/oid4vci-issuer/dist/state-manager'
import { ExpressBuilder, ExpressSupport } from '@sphereon/ssi-express-support'
import { DIDDocument } from 'did-resolver'
Expand All @@ -24,8 +22,6 @@ import requests from 'supertest'

import { OID4VCIServer } from '../OID4VCIServer'



const authorizationServerMetadata = new AuthorizationServerMetadataBuilder()
.withIssuer('test-issuer')
.withCredentialEndpoint('http://localhost:3456/test/credential-endpoint')
Expand All @@ -34,8 +30,7 @@ const authorizationServerMetadata = new AuthorizationServerMetadataBuilder()
.withTokenEndpointAuthMethodsSupported(['none', 'client_secret_basic', 'client_secret_jwt', 'client_secret_post'])
.withResponseTypesSupported(['code', 'token', 'id_token'])
.withScopesSupported(['openid', 'abcdef'])
.build();

.build()

describe('OID4VCIServer', () => {
let app: Express
Expand Down Expand Up @@ -123,11 +118,11 @@ describe('OID4VCIServer', () => {
display: [
{
name: 'given name',
locale: 'en-US'
}
]
}
}
locale: 'en-US',
},
],
},
},
},
format: 'jwt_vc_json',
credential_signing_alg_values_supported: ['ES256K'],
Expand All @@ -138,22 +133,22 @@ describe('OID4VCIServer', () => {
locale: 'en-US',
logo: {
url: 'https://exampleuniversity.com/public/logo.png',
alt_text: 'a square logo of a university'
alt_text: 'a square logo of a university',
},
background_color: '#12107c',
text_color: '#FFFFFF'
}
]
}
}
text_color: '#FFFFFF',
},
],
},
},
} as CredentialIssuerMetadataOptsV1_0_13,
authorizationServerMetadata,
{
cNonceExpiresIn: 300,
credentialOfferSessions,
cNonces: new MemoryStates<CNonceState>(),
uris: new MemoryStates<URIState>()
}
uris: new MemoryStates<URIState>(),
},
)

expressSupport = ExpressBuilder.fromServerOpts({
Expand Down
5 changes: 2 additions & 3 deletions packages/issuer-rest/lib/oid4vci-api-functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
trimEnd,
trimStart,
validateJWT,
WellKnownEndpoints
WellKnownEndpoints,
} from '@sphereon/oid4vci-common'
import { ITokenEndpointOpts, LOG, VcIssuer } from '@sphereon/oid4vci-issuer'
import { env, ISingleEndpointOpts, sendErrorResponse } from '@sphereon/ssi-express-support'
Expand All @@ -33,11 +33,10 @@ import {
ICreateCredentialOfferEndpointOpts,
ICreateCredentialOfferURIResponse,
IGetCredentialOfferEndpointOpts,
IGetIssueStatusEndpointOpts
IGetIssueStatusEndpointOpts,
} from './OID4VCIServer'
import { validateRequestBody } from './expressUtils'


const expiresIn = process.env.EXPIRES_IN ? parseInt(process.env.EXPIRES_IN) : 90

export function getIssueStatusEndpoint<DIDDoc extends object>(router: Router, issuer: VcIssuer<DIDDoc>, opts: IGetIssueStatusEndpointOpts) {
Expand Down
4 changes: 2 additions & 2 deletions packages/issuer-rest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"@sphereon/oid4vc-common": "workspace:*",
"@sphereon/oid4vci-common": "workspace:*",
"@sphereon/oid4vci-issuer": "workspace:*",
"@sphereon/ssi-express-support": "0.30.2-next.279",
"@sphereon/ssi-types": "0.30.2-next.279",
"@sphereon/ssi-express-support": "0.30.2-feature.mdoc.funke2.367",
"@sphereon/ssi-types": "0.30.2-feature.mdoc.funke2.367",
"body-parser": "^1.20.2",
"cookie-parser": "^1.4.6",
"cors": "^2.8.5",
Expand Down
27 changes: 5 additions & 22 deletions packages/issuer/lib/VcIssuer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,30 +38,13 @@ import {
toUniformCredentialOfferRequest,
TxCode,
TYP_ERROR,
URIState
URIState,
} from '@sphereon/oid4vci-common'
import {
CompactSdJwtVc,
CredentialMapper,
InitiatorType,
SubSystem,
System,
W3CVerifiableCredential
} from '@sphereon/ssi-types'
import { CompactSdJwtVc, CredentialMapper, InitiatorType, SubSystem, System, W3CVerifiableCredential } from '@sphereon/ssi-types'

import {
assertValidPinNumber,
createCredentialOfferObject,
createCredentialOfferURIFromObject,
CredentialOfferGrantInput
} from './functions'
import { assertValidPinNumber, createCredentialOfferObject, createCredentialOfferURIFromObject, CredentialOfferGrantInput } from './functions'
import { LookupStateManager } from './state-manager'
import {
CredentialDataSupplier,
CredentialDataSupplierArgs,
CredentialIssuanceInput,
CredentialSignerCallback
} from './types'
import { CredentialDataSupplier, CredentialDataSupplierArgs, CredentialIssuanceInput, CredentialSignerCallback } from './types'

export class VcIssuer<DIDDoc extends object> {
private readonly _issuerMetadata: CredentialIssuerMetadataOptsV1_0_13
Expand Down Expand Up @@ -683,7 +666,7 @@ export class VcIssuer<DIDDoc extends object> {
public get issuerMetadata() {
return this._issuerMetadata
}

public get authorizationServerMetadata() {
return this._authorizationServerMetadata
}
Expand Down
Loading

0 comments on commit 50e6272

Please sign in to comment.