Skip to content

Commit c9b4d6f

Browse files
committed
fix: session and state to correlationId mapping bugfixes
1 parent dd6f740 commit c9b4d6f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+474
-337
lines changed

packages/callback-example/lib/__tests__/issuerCallback.spec.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
CNonceState,
88
CredentialConfigurationSupportedV1_0_13,
99
CredentialIssuerMetadataV1_0_13,
10+
CredentialOfferSession,
1011
CredentialRequest,
1112
IssuerCredentialSubjectDisplay,
1213
IssueStatus,
@@ -15,9 +16,13 @@ import {
1516
OpenId4VCIVersion,
1617
ProofOfPossession,
1718
} from '@sphereon/oid4vci-common'
18-
import { CredentialOfferSession } from '@sphereon/oid4vci-common'
19-
import { AuthorizationServerMetadataBuilder, CredentialSupportedBuilderV1_13, VcIssuer, VcIssuerBuilder } from '@sphereon/oid4vci-issuer'
20-
import { MemoryStates } from '@sphereon/oid4vci-issuer'
19+
import {
20+
AuthorizationServerMetadataBuilder,
21+
CredentialSupportedBuilderV1_13,
22+
MemoryStates,
23+
VcIssuer,
24+
VcIssuerBuilder,
25+
} from '@sphereon/oid4vci-issuer'
2126
import { CredentialDataSupplierResult } from '@sphereon/oid4vci-issuer/dist/types'
2227
import { ICredential, IProofPurpose, IProofType, W3CVerifiableCredential } from '@sphereon/ssi-types'
2328
import { DIDDocument } from 'did-resolver'
@@ -57,7 +62,7 @@ const authorizationServerMetadata = new AuthorizationServerMetadataBuilder()
5762
.withScopesSupported(['openid', 'abcdef'])
5863
.build()
5964

60-
async function verifyCallbackFunction(args: { jwt: string; kid?: string }): Promise<JwtVerifyResult<DIDDocument>> {
65+
async function verifyCallbackFunction(args: { jwt: string; kid?: string }): Promise<JwtVerifyResult> {
6166
const result = await jose.jwtVerify(args.jwt, keypair.publicKey)
6267
const kid = result.protectedHeader.kid ?? args.kid
6368
const did = kid!.split('#')[0]
@@ -93,7 +98,7 @@ afterAll(async () => {
9398
await new Promise((resolve) => setTimeout((v: void) => resolve(v), 500))
9499
})
95100
describe('issuerCallback', () => {
96-
let vcIssuer: VcIssuer<DIDDocument>
101+
let vcIssuer: VcIssuer
97102
const state = 'existing-state'
98103
const clientId = 'sphereon:wallet'
99104

@@ -156,7 +161,7 @@ describe('issuerCallback', () => {
156161

157162
const nonces = new MemoryStates<CNonceState>()
158163
await nonces.set('test_value', { cNonce: 'test_value', createdAt: +new Date(), issuerState: 'existing-state' })
159-
vcIssuer = new VcIssuerBuilder<DIDDocument>()
164+
vcIssuer = new VcIssuerBuilder()
160165
.withAuthorizationServers('https://authorization-server')
161166
.withCredentialEndpoint('https://credential-endpoint')
162167
.withCredentialIssuer(IDENTIPROOF_ISSUER_URL)

packages/client/lib/CredentialRequestClient.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
CredentialRequestWithoutProofV1_0_13,
66
CredentialResponse,
77
DPoPResponseParams,
8+
ExperimentalSubjectIssuance,
89
getCredentialRequestForVersion,
910
getUniformFormat,
1011
isDeferredCredentialResponse,
@@ -17,7 +18,6 @@ import {
1718
UniformCredentialRequest,
1819
URL_NOT_VALID,
1920
} from '@sphereon/oid4vci-common';
20-
import { ExperimentalSubjectIssuance } from '@sphereon/oid4vci-common';
2121
import { CredentialFormat, DIDDocument } from '@sphereon/ssi-types';
2222
import Debug from 'debug';
2323

@@ -53,7 +53,7 @@ export type CreateCredentialRequestOpts<DIDDoc = DIDDocument> = {
5353
};
5454

5555
export async function buildProof<DIDDoc = DIDDocument>(
56-
proofInput: ProofOfPossessionBuilder<DIDDoc> | ProofOfPossession,
56+
proofInput: ProofOfPossessionBuilder | ProofOfPossession,
5757
opts: {
5858
version: OpenId4VCIVersion;
5959
cNonce?: string;
@@ -111,7 +111,7 @@ export class CredentialRequestClient {
111111
}): Promise<OpenIDResponse<CredentialResponse, DPoPResponseParams> & { access_token: string }> {
112112
const { credentialIdentifier, credentialTypes, format, context, subjectIssuance } = opts;
113113

114-
const request = await this.createCredentialRequestWithoutProof<DIDDoc>({
114+
const request = await this.createCredentialRequestWithoutProof({
115115
credentialTypes,
116116
context,
117117
format,
@@ -123,7 +123,7 @@ export class CredentialRequestClient {
123123
}
124124

125125
public async acquireCredentialsUsingProof<DIDDoc = DIDDocument>(opts: {
126-
proofInput: ProofOfPossessionBuilder<DIDDoc> | ProofOfPossession;
126+
proofInput: ProofOfPossessionBuilder | ProofOfPossession;
127127
credentialIdentifier?: string;
128128
credentialTypes?: string | string[];
129129
context?: string[];
@@ -133,7 +133,7 @@ export class CredentialRequestClient {
133133
}): Promise<OpenIDResponse<CredentialResponse, DPoPResponseParams> & { access_token: string }> {
134134
const { credentialIdentifier, credentialTypes, proofInput, format, context, subjectIssuance } = opts;
135135

136-
const request = await this.createCredentialRequest<DIDDoc>({
136+
const request = await this.createCredentialRequest({
137137
proofInput,
138138
credentialTypes,
139139
context,
@@ -246,22 +246,22 @@ export class CredentialRequestClient {
246246
}
247247

248248
public async createCredentialRequestWithoutProof<DIDDoc = DIDDocument>(
249-
opts: CreateCredentialRequestOpts<DIDDoc>,
249+
opts: CreateCredentialRequestOpts,
250250
): Promise<CredentialRequestWithoutProofV1_0_13> {
251251
return await this.createCredentialRequestImpl(opts);
252252
}
253253

254254
public async createCredentialRequest<DIDDoc = DIDDocument>(
255-
opts: CreateCredentialRequestOpts<DIDDoc> & {
256-
proofInput: ProofOfPossessionBuilder<DIDDoc> | ProofOfPossession;
255+
opts: CreateCredentialRequestOpts & {
256+
proofInput: ProofOfPossessionBuilder | ProofOfPossession;
257257
},
258258
): Promise<CredentialRequestV1_0_13> {
259259
return await this.createCredentialRequestImpl(opts);
260260
}
261261

262262
private async createCredentialRequestImpl<DIDDoc = DIDDocument>(
263-
opts: CreateCredentialRequestOpts<DIDDoc> & {
264-
proofInput?: ProofOfPossessionBuilder<DIDDoc> | ProofOfPossession;
263+
opts: CreateCredentialRequestOpts & {
264+
proofInput?: ProofOfPossessionBuilder | ProofOfPossession;
265265
},
266266
): Promise<CredentialRequestV1_0_13> {
267267
const { proofInput, credentialIdentifier: credential_identifier } = opts;

packages/client/lib/CredentialRequestClientV1_0_11.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ export class CredentialRequestClientV1_0_11 {
6262
this._credentialRequestOpts = { ...builder };
6363
}
6464

65-
public async acquireCredentialsUsingProof<DIDDoc>(opts: {
66-
proofInput: ProofOfPossessionBuilder<DIDDoc> | ProofOfPossession;
65+
public async acquireCredentialsUsingProof(opts: {
66+
proofInput: ProofOfPossessionBuilder | ProofOfPossession;
6767
credentialTypes?: string | string[];
6868
context?: string[];
6969
format?: CredentialFormat | OID4VCICredentialFormat;
@@ -153,8 +153,8 @@ export class CredentialRequestClientV1_0_11 {
153153
});
154154
}
155155

156-
public async createCredentialRequest<DIDDoc>(opts: {
157-
proofInput: ProofOfPossessionBuilder<DIDDoc> | ProofOfPossession;
156+
public async createCredentialRequest(opts: {
157+
proofInput: ProofOfPossessionBuilder | ProofOfPossession;
158158
credentialTypes?: string | string[];
159159
context?: string[];
160160
format?: CredentialFormat | OID4VCICredentialFormat;

packages/client/lib/OpenID4VCIClient.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export class OpenID4VCIClient {
130130
pkce,
131131
authorizationRequest,
132132
createAuthorizationRequestURL,
133-
endpointMetadata
133+
endpointMetadata,
134134
}: {
135135
credentialIssuer: string;
136136
kid?: string;
@@ -140,7 +140,7 @@ export class OpenID4VCIClient {
140140
createAuthorizationRequestURL?: boolean;
141141
authorizationRequest?: AuthorizationRequestOpts; // Can be provided here, or when manually calling createAuthorizationUrl
142142
pkce?: PKCEOpts;
143-
endpointMetadata?: EndpointMetadataResult
143+
endpointMetadata?: EndpointMetadataResult;
144144
}) {
145145
const client = new OpenID4VCIClient({
146146
kid,
@@ -149,7 +149,7 @@ export class OpenID4VCIClient {
149149
credentialIssuer,
150150
pkce,
151151
authorizationRequest,
152-
endpointMetadata
152+
endpointMetadata,
153153
});
154154
if (retrieveServerMetadata === undefined || retrieveServerMetadata) {
155155
await client.retrieveServerMetadata();
@@ -176,7 +176,7 @@ export class OpenID4VCIClient {
176176
createAuthorizationRequestURL,
177177
authorizationRequest,
178178
resolveOfferUri,
179-
endpointMetadata
179+
endpointMetadata,
180180
}: {
181181
uri: string;
182182
kid?: string;
@@ -187,7 +187,7 @@ export class OpenID4VCIClient {
187187
pkce?: PKCEOpts;
188188
clientId?: string;
189189
authorizationRequest?: AuthorizationRequestOpts; // Can be provided here, or when manually calling createAuthorizationUrl
190-
endpointMetadata?: EndpointMetadataResult
190+
endpointMetadata?: EndpointMetadataResult;
191191
}): Promise<OpenID4VCIClient> {
192192
const credentialOfferClient = await CredentialOfferClient.fromURI(uri, { resolve: resolveOfferUri });
193193
const client = new OpenID4VCIClient({
@@ -197,7 +197,7 @@ export class OpenID4VCIClient {
197197
clientId: clientId ?? authorizationRequest?.clientId ?? credentialOfferClient.clientId,
198198
pkce,
199199
authorizationRequest,
200-
endpointMetadata
200+
endpointMetadata,
201201
});
202202

203203
if (retrieveServerMetadata === undefined || retrieveServerMetadata) {
@@ -383,7 +383,7 @@ export class OpenID4VCIClient {
383383
}: {
384384
credentialTypes: string | string[];
385385
context?: string[];
386-
proofCallbacks: ProofOfPossessionCallbacks<any>;
386+
proofCallbacks: ProofOfPossessionCallbacks;
387387
format?: CredentialFormat | OID4VCICredentialFormat;
388388
kid?: string;
389389
jwk?: JWK;

packages/client/lib/OpenID4VCIClientV1_0_11.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ export class OpenID4VCIClientV1_0_11 {
362362
}: {
363363
credentialTypes: string | string[];
364364
context?: string[];
365-
proofCallbacks: ProofOfPossessionCallbacks<any>;
365+
proofCallbacks: ProofOfPossessionCallbacks;
366366
format?: CredentialFormat | OID4VCICredentialFormat;
367367
kid?: string;
368368
jwk?: JWK;

packages/client/lib/OpenID4VCIClientV1_0_13.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import {
2929
ProofOfPossessionCallbacks,
3030
toAuthorizationResponsePayload,
3131
} from '@sphereon/oid4vci-common';
32-
import { CredentialFormat, DIDDocument } from '@sphereon/ssi-types';
32+
import { CredentialFormat } from '@sphereon/ssi-types';
3333
import Debug from 'debug';
3434

3535
import { AccessTokenClient } from './AccessTokenClient';
@@ -371,7 +371,7 @@ export class OpenID4VCIClientV1_0_13 {
371371
credentialIdentifier?: string;
372372
credentialTypes?: string | string[];
373373
context?: string[];
374-
proofCallbacks: ProofOfPossessionCallbacks<any>;
374+
proofCallbacks: ProofOfPossessionCallbacks;
375375
format?: CredentialFormat | OID4VCICredentialFormat;
376376
kid?: string;
377377
jwk?: JWK;
@@ -402,7 +402,7 @@ export class OpenID4VCIClientV1_0_13 {
402402
credentialIdentifier?: string;
403403
credentialTypes?: string | string[];
404404
context?: string[];
405-
proofCallbacks?: ProofOfPossessionCallbacks<any>;
405+
proofCallbacks?: ProofOfPossessionCallbacks;
406406
format?: CredentialFormat | OID4VCICredentialFormat;
407407
kid?: string;
408408
jwk?: JWK;
@@ -521,7 +521,7 @@ export class OpenID4VCIClientV1_0_13 {
521521
}
522522
}
523523
const request = proofBuilder
524-
? await credentialRequestClient.createCredentialRequest<DIDDocument>({
524+
? await credentialRequestClient.createCredentialRequest({
525525
proofInput: proofBuilder,
526526
credentialTypes,
527527
context,
@@ -530,7 +530,7 @@ export class OpenID4VCIClientV1_0_13 {
530530
credentialIdentifier,
531531
subjectIssuance,
532532
})
533-
: await credentialRequestClient.createCredentialRequestWithoutProof<DIDDocument>({
533+
: await credentialRequestClient.createCredentialRequestWithoutProof({
534534
credentialTypes,
535535
context,
536536
format,

packages/client/lib/ProofOfPossessionBuilder.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616

1717
export class ProofOfPossessionBuilder<DIDDoc = never> {
1818
private readonly proof?: ProofOfPossession;
19-
private readonly callbacks?: ProofOfPossessionCallbacks<DIDDoc>;
19+
private readonly callbacks?: ProofOfPossessionCallbacks;
2020
private readonly version: OpenId4VCIVersion;
2121
private readonly mode: PoPMode = 'pop';
2222

@@ -40,7 +40,7 @@ export class ProofOfPossessionBuilder<DIDDoc = never> {
4040
mode = 'pop',
4141
}: {
4242
proof?: ProofOfPossession;
43-
callbacks?: ProofOfPossessionCallbacks<DIDDoc>;
43+
callbacks?: ProofOfPossessionCallbacks;
4444
accessTokenResponse?: AccessTokenResponse;
4545
jwt?: Jwt;
4646
version: OpenId4VCIVersion;
@@ -60,49 +60,49 @@ export class ProofOfPossessionBuilder<DIDDoc = never> {
6060
}
6161
}
6262

63-
static manual<DIDDoc>({
63+
static manual({
6464
jwt,
6565
callbacks,
6666
version,
6767
mode = 'JWT',
6868
}: {
6969
jwt?: Jwt;
70-
callbacks: ProofOfPossessionCallbacks<DIDDoc>;
70+
callbacks: ProofOfPossessionCallbacks;
7171
version: OpenId4VCIVersion;
7272
mode?: PoPMode;
73-
}): ProofOfPossessionBuilder<DIDDoc> {
73+
}): ProofOfPossessionBuilder {
7474
return new ProofOfPossessionBuilder({ callbacks, jwt, version, mode });
7575
}
7676

77-
static fromJwt<DIDDoc>({
77+
static fromJwt({
7878
jwt,
7979
callbacks,
8080
version,
8181
mode = 'pop',
8282
}: {
8383
jwt: Jwt;
84-
callbacks: ProofOfPossessionCallbacks<DIDDoc>;
84+
callbacks: ProofOfPossessionCallbacks;
8585
version: OpenId4VCIVersion;
8686
mode?: PoPMode;
87-
}): ProofOfPossessionBuilder<DIDDoc> {
87+
}): ProofOfPossessionBuilder {
8888
return new ProofOfPossessionBuilder({ callbacks, jwt, version, mode });
8989
}
9090

91-
static fromAccessTokenResponse<DIDDoc>({
91+
static fromAccessTokenResponse({
9292
accessTokenResponse,
9393
callbacks,
9494
version,
9595
mode = 'pop',
9696
}: {
9797
accessTokenResponse: AccessTokenResponse;
98-
callbacks: ProofOfPossessionCallbacks<DIDDoc>;
98+
callbacks: ProofOfPossessionCallbacks;
9999
version: OpenId4VCIVersion;
100100
mode?: PoPMode;
101-
}): ProofOfPossessionBuilder<DIDDoc> {
101+
}): ProofOfPossessionBuilder {
102102
return new ProofOfPossessionBuilder({ callbacks, accessTokenResponse, version, mode });
103103
}
104104

105-
static fromProof<DIDDoc>(proof: ProofOfPossession, version: OpenId4VCIVersion): ProofOfPossessionBuilder<DIDDoc> {
105+
static fromProof(proof: ProofOfPossession, version: OpenId4VCIVersion): ProofOfPossessionBuilder {
106106
return new ProofOfPossessionBuilder({ proof, version });
107107
}
108108

packages/client/lib/__tests__/CredentialRequestClientBuilder.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ interface KeyPair {
5757
privateKey: KeyObject;
5858
}
5959

60-
async function proofOfPossessionVerifierCallbackFunction(args: { jwt: string; kid?: string }): Promise<JwtVerifyResult<unknown>> {
60+
async function proofOfPossessionVerifierCallbackFunction(args: { jwt: string; kid?: string }): Promise<JwtVerifyResult> {
6161
const result = await jose.jwtVerify(args.jwt, keypair.publicKey);
6262
const kid = result.protectedHeader.kid ?? args.kid;
6363
const did = kid!.split('#')[0];

packages/client/lib/__tests__/SphereonE2E.spec.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ describe('ismapolis bug report #63, https://github.com/Sphereon-Opensource/OID4V
155155
.sign(edPrivateKey);
156156
}
157157

158-
const callbacks: ProofOfPossessionCallbacks<never> = {
158+
const callbacks: ProofOfPossessionCallbacks = {
159159
signCallback: signCallback,
160160
};
161161

packages/common/lib/jwt/Jwt.types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { JwtHeader as jwtDecodeJwtHeader, JwtPayload as jwtDecodePayload } from 'jwt-decode';
22

33
import { JWK } from '.';
4+
45
export type JwtHeader = jwtDecodeJwtHeader & {
56
alg?: string;
67
x5c?: string[];

packages/did-auth-siop-adapter/lib/DidJwtAdapter.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { AuthorizationRequestPayload, IDTokenPayload, JwtIssuerWithContext, RequestObjectPayload } from '@sphereon/did-auth-siop'
2-
import { JwtVerifier } from '@sphereon/did-auth-siop'
1+
import { AuthorizationRequestPayload, IDTokenPayload, JwtIssuerWithContext, JwtVerifier, RequestObjectPayload } from '@sphereon/did-auth-siop'
32
import { JwtHeader, JwtPayload } from '@sphereon/oid4vc-common'
43
import { Resolvable } from 'did-resolver'
54

0 commit comments

Comments
 (0)