Skip to content

Commit 678eb2a

Browse files
authored
Add option for Get or Post JAR method on Init Transaction (#139)
* Initial implementation * Renamed jar_method to request_uri_method
1 parent 54d0315 commit 678eb2a

10 files changed

Lines changed: 66 additions & 22 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export type InitializedTransaction = {
22
client_id: string,
33
request_uri: string,
4+
request_uri_method: 'get' | 'post',
45
transaction_id: string
56
}

src/app/core/models/TransactionInitializationRequest.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export type TransactionInitializationRequest =
88
export type BaseTransactionInitializationRequest = {
99
type: 'id_token' | 'vp_token' | 'vp_token id_token';
1010
nonce: string;
11+
request_uri_method: 'get' | 'post';
1112
};
1213

1314
export type PresentationQuery =

src/app/core/services/dcql-service.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,15 @@ import {
2020
export class DCQLService {
2121
dcqlPresentationRequest(
2222
selectedAttestations: AttestationSelection[],
23-
selectedAttributes: { [id: string]: string[] }
23+
selectedAttributes: { [id: string]: string[] },
24+
selectedRequestUriMethod: 'get' | 'post'
2425
): DCQLTransactionRequest {
2526
let dcqlQueries: CredentialQuery[] = selectedAttestations.map(
2627
(attestation, index) =>
2728
this.dcqlQueryOf(
2829
`query_${index}`,
2930
attestation.type,
30-
attestation.format!!,
31+
attestation.format!,
3132
attestation.attributeSelectionMethod ===
3233
AttributeSelectionMethod.ALL_ATTRIBUTES
3334
? []
@@ -38,9 +39,10 @@ export class DCQLService {
3839
return {
3940
type: 'vp_token',
4041
dcql_query: {
41-
credentials: dcqlQueries!,
42+
credentials: dcqlQueries,
4243
},
4344
nonce: uuidv4(),
45+
request_uri_method: selectedRequestUriMethod,
4446
};
4547
}
4648

src/app/core/services/presentation-definition-service.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ export class PresentationDefinitionService {
2828
presentationDefinitionRequest(
2929
selectedAttestations: AttestationSelection[],
3030
selectedAttributes: { [id: string]: string[] },
31-
vpFormatsPerType: { [key: string]: SdJwtVcVpFormat | MsoMdocVpFormat }
31+
vpFormatsPerType: { [key: string]: SdJwtVcVpFormat | MsoMdocVpFormat },
32+
selectedRequestURIMethod: 'get' | 'post'
3233
): PresentationDefinitionTransactionRequest {
3334
let inputDescriptors: InputDescriptor[] = [];
3435

@@ -56,9 +57,10 @@ export class PresentationDefinitionService {
5657
type: 'vp_token',
5758
presentation_definition: {
5859
id: uuidv4(),
59-
input_descriptors: inputDescriptors!,
60+
input_descriptors: inputDescriptors,
6061
},
6162
nonce: uuidv4(),
63+
request_uri_method: selectedRequestURIMethod,
6264
};
6365
}
6466

src/app/features/invoke-wallet/components/qr-code/qr-code.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export class QrCodeComponent implements OnInit, OnDestroy {
8080

8181
ngOnInit(): void {
8282
this.transaction = JSON.parse(
83-
this.localStorageService.get(ACTIVE_TRANSACTION)!!
83+
this.localStorageService.get(ACTIVE_TRANSACTION)!
8484
);
8585
if (!this.transaction) {
8686
this.navigateService.goHome();
@@ -134,8 +134,8 @@ export class QrCodeComponent implements OnInit, OnDestroy {
134134
return concludedTransaction;
135135
}
136136

137-
private buildQrCode(data: { client_id: string, request_uri: string, transaction_id: string }): string {
138-
return `${this.scheme}?client_id=${encodeURIComponent(data.client_id)}&request_uri=${encodeURIComponent(data.request_uri)}`;
137+
private buildQrCode(data: { client_id: string, request_uri: string, request_uri_method: 'get' | 'post', transaction_id: string }): string {
138+
return `${this.scheme}?client_id=${encodeURIComponent(data.client_id)}&request_uri=${encodeURIComponent(data.request_uri)}&request_uri_method=${encodeURIComponent(data.request_uri_method)}`;
139139
}
140140

141141
openLogs() {

src/app/features/presentation-request-preparation/components/attribute-selection/attribute-selection.component.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ export class AttributeSelectionComponent implements OnChanges {
6767
}
6868

6969
private updateSelectionMap(dialogResult: DialogResult) {
70-
console.log("Dialog result: ", dialogResult);
7170
if (dialogResult.selectedFields.length > 0) {
7271
this.selectedFieldsByType[dialogResult.attestationType as string] = dialogResult.selectedFields;
7372
} else {

src/app/features/presentation-request-preparation/components/selectable-attestation-attributes/selectable-attestation-attributes.component.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ export class SelectableAttestationAttributesComponent implements OnInit {
6161

6262
handle(data: FormSelectableField) {
6363
const value = data.value;
64-
console.log('Selected field: ', value);
6564
if (!this.exists(value)) {
6665
this.selectedFields.push(value);
6766
} else if (this.exists(value)) {

src/app/features/presentation-request-preparation/home/home.component.html

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,31 @@ <h4>Define your presentation request</h4>
3434

3535
<mat-step>
3636
<div style="padding-top: 10px">
37-
<ng-template matStepLabel>...select presentation query type and submit</ng-template>
37+
<ng-template matStepLabel>...select request options and submit</ng-template>
3838

39-
<div class="query-type-container">
39+
<div class="config-option-container">
40+
<div class="config-option-label">
41+
Presentation Query Type
42+
</div>
4043
<mat-button-toggle-group [formControl]="queryTypeControl"
4144
(valueChange)="handleQueryTypeChangedEvent($event)"
4245
aria-label="Presentation query type" >
4346
<mat-button-toggle value="prex">Presentation Exchange</mat-button-toggle>
4447
<mat-button-toggle value="dcql">DCQL</mat-button-toggle>
4548
</mat-button-toggle-group>
4649
</div>
50+
51+
<div class="config-option-container">
52+
<div class="config-option-label">
53+
Request URI Method
54+
</div>
55+
<mat-button-toggle-group [formControl]="requestUriMethodControl"
56+
(valueChange)="handleRequestUriMethodChangedEvent($event)"
57+
aria-label="Request URI Method" >
58+
<mat-button-toggle value="get">Get</mat-button-toggle>
59+
<mat-button-toggle value="post">Post</mat-button-toggle>
60+
</mat-button-toggle-group>
61+
</div>
4762

4863
<mat-expansion-panel>
4964

src/app/features/presentation-request-preparation/home/home.component.scss

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,12 @@
1515
}
1616
}
1717

18-
.query-type-container {
19-
margin-bottom: 10px
18+
.config-option-container {
19+
margin-bottom: 16px;
20+
21+
.config-option-label {
22+
margin-bottom: 8px;
23+
}
2024
}
2125

2226
span#as-pre {

src/app/features/presentation-request-preparation/home/home.component.ts

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,22 @@ export class HomeComponent implements OnInit, OnDestroy {
6868
actions: BodyAction[] = HOME_ACTIONS;
6969

7070
queryTypeControl = new FormControl('prex');
71+
requestUriMethodControl = new FormControl('get');
7172

72-
private _formBuilder = inject(FormBuilder);
73+
74+
private readonly _formBuilder = inject(FormBuilder);
7375
formGroup = this._formBuilder.group({
7476
selectAttestationCtrl: ['', Validators.required],
7577
});
7678

7779
selectedAttestations: AttestationSelection[] | null = null;
7880
selectedAttributes: { [id: string]: string[] } | null = null;
7981
selectedPresentationType: 'dcql' | 'prex' = 'prex';
82+
selectedRequestUriMethod: 'get' | 'post' = 'get';
8083

8184
initializationRequest: TransactionInitializationRequest | null = null;
8285

83-
private destroy$ = new Subject<void>();
86+
private readonly destroy$ = new Subject<void>();
8487
vpFormatsPerType: { [key: string]: SdJwtVcVpFormat | MsoMdocVpFormat } = {};
8588

8689
ngOnInit(): void {
@@ -113,7 +116,8 @@ export class HomeComponent implements OnInit, OnDestroy {
113116
this.initializationRequest = this.prepareInitializationRequest(
114117
this.selectedPresentationType,
115118
this.selectedAttestations!,
116-
this.selectedAttributes
119+
this.selectedAttributes,
120+
this.selectedRequestUriMethod
117121
);
118122
} else {
119123
this.selectedAttributes = null;
@@ -126,8 +130,24 @@ export class HomeComponent implements OnInit, OnDestroy {
126130
if (this.selectedAttestations && this.selectedAttributes) {
127131
this.initializationRequest = this.prepareInitializationRequest(
128132
this.selectedPresentationType,
129-
this.selectedAttestations!,
130-
this.selectedAttributes
133+
this.selectedAttestations,
134+
this.selectedAttributes,
135+
this.selectedRequestUriMethod
136+
);
137+
} else {
138+
this.initializationRequest = null;
139+
}
140+
}
141+
142+
handleRequestUriMethodChangedEvent($event: string) {
143+
this.selectedRequestUriMethod = $event as 'get' | 'post';
144+
145+
if (this.selectedAttestations && this.selectedAttributes) {
146+
this.initializationRequest = this.prepareInitializationRequest(
147+
this.selectedPresentationType,
148+
this.selectedAttestations,
149+
this.selectedAttributes,
150+
this.selectedRequestUriMethod
131151
);
132152
} else {
133153
this.initializationRequest = null;
@@ -137,12 +157,13 @@ export class HomeComponent implements OnInit, OnDestroy {
137157
private prepareInitializationRequest(
138158
presentationQueryType: 'dcql' | 'prex',
139159
selectedAttestations: AttestationSelection[],
140-
selectedAttributes: { [id: string]: string[] }
160+
selectedAttributes: { [id: string]: string[] },
161+
selectedRequestUriMethod: 'get' | 'post'
141162
): TransactionInitializationRequest {
142163
if (presentationQueryType === 'dcql') {
143-
return this.dcqlService.dcqlPresentationRequest(selectedAttestations, selectedAttributes);
164+
return this.dcqlService.dcqlPresentationRequest(selectedAttestations, selectedAttributes, selectedRequestUriMethod);
144165
} else {
145-
return this.presentationDefinitionService.presentationDefinitionRequest(selectedAttestations, selectedAttributes, this.vpFormatsPerType);
166+
return this.presentationDefinitionService.presentationDefinitionRequest(selectedAttestations, selectedAttributes, this.vpFormatsPerType, selectedRequestUriMethod);
146167
}
147168
}
148169

0 commit comments

Comments
 (0)