Skip to content

Commit dc5fe5c

Browse files
authored
Merge pull request #7440 from LibreSign/backport/7439/stable32
[stable32] fix: align signer and file UUID contracts
2 parents 8c9c2f9 + cf7e803 commit dc5fe5c

42 files changed

Lines changed: 673 additions & 317 deletions

Some content is hidden

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

lib/ResponseDefinitions.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
* @psalm-type LibresignSettings = array{
2323
* canSign: bool,
2424
* canRequestSign: bool,
25-
* signerFileUuid: ?string,
2625
* phoneNumber: string,
2726
* hasSignatureFile: bool,
2827
* isApprover?: bool,
@@ -159,7 +158,7 @@
159158
* notify?: LibresignNotify[],
160159
* userId?: string,
161160
* sign_date?: ?string,
162-
* sign_uuid?: string,
161+
* sign_request_uuid?: string,
163162
* hash_algorithm?: string,
164163
* me: bool,
165164
* status: 0|1|2,
@@ -405,7 +404,6 @@
405404
* requested_by: LibresignRequestedBy,
406405
* file?: string,
407406
* url?: string,
408-
* signUuid?: string|null,
409407
* mime?: string,
410408
* pages?: list<LibresignValidationPage>,
411409
* metadata?: LibresignValidateMetadata,
@@ -466,7 +464,6 @@
466464
* statusText: string,
467465
* nodeType: 'file'|'envelope',
468466
* created_at: string,
469-
* signUuid?: ?string,
470467
* metadata: LibresignValidateMetadata,
471468
* docmdpLevel: int,
472469
* signatureFlow: 'none'|'parallel'|'ordered_numeric',
@@ -515,7 +512,6 @@
515512
* message: string,
516513
* name: non-falsy-string,
517514
* nodeType: 'file'|'envelope',
518-
* signUuid?: string|null,
519515
* metadata: LibresignValidateMetadata,
520516
* signatureFlow: 'none'|'parallel'|'ordered_numeric',
521517
* }

lib/Service/File/FileListService.php

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -278,13 +278,10 @@ private function formatSingleFileData(
278278
$meSignRequestId,
279279
);
280280
$file['signers'][] = $signerData;
281-
if (!empty($signerData['me']) && !isset($file['signUuid'])) {
282-
$file['signUuid'] = $signerData['sign_uuid'];
281+
if (!empty($signerData['me']) && isset($signerData['sign_request_uuid']) && !isset($file['url'])) {
282+
$file['url'] = $this->urlGenerator->linkToRoute('libresign.page.getPdfFile', ['uuid' => $signerData['sign_request_uuid']]);
283283
}
284284
}
285-
if (isset($file['signUuid'])) {
286-
$file['url'] = $this->urlGenerator->linkToRoute('libresign.page.getPdfFile', ['uuid' => $file['signUuid']]);
287-
}
288285

289286
$file['statusText'] = $this->fileMapper->getTextOfStatus((int)$file['status']);
290287

@@ -344,14 +341,6 @@ private function formatSingleFileSummary(
344341
&& !array_filter($mySigners, fn (SignRequest $signer) => $signer->getSigned() !== null)
345342
&& (!$isOrderedNumeric || array_filter($mySigners, fn (SignRequest $signer) => ($signer->getSigningOrder() ?: 1) === $minOrder));
346343

347-
$signUuid = null;
348-
foreach ($mySigners as $signer) {
349-
if ($signer->getUuid() !== '') {
350-
$signUuid = $signer->getUuid();
351-
break;
352-
}
353-
}
354-
355344
/** @var LibresignFileSummary */
356345
return [
357346
'id' => $fileEntity->getId(),
@@ -362,7 +351,6 @@ private function formatSingleFileSummary(
362351
'statusText' => $this->fileMapper->getTextOfStatus($fileEntity->getStatus()),
363352
'nodeType' => $nodeType,
364353
'created_at' => $fileEntity->getCreatedAt()->setTimezone(new \DateTimeZone('UTC'))->format(DateTimeInterface::ATOM),
365-
'signUuid' => $signUuid,
366354
'metadata' => $metadata,
367355
'docmdpLevel' => $fileEntity->getDocmdpLevel(),
368356
'signatureFlow' => SignatureFlow::fromNumeric($fileEntity->getSignatureFlow())->value,
@@ -468,7 +456,7 @@ private function formatSignerData(
468456
foreach ($temp as $methods) {
469457
$data['signatureMethods'] = array_merge($data['signatureMethods'], $methods);
470458
}
471-
$data['sign_uuid'] = $signer->getUuid();
459+
$data['sign_request_uuid'] = $signer->getUuid();
472460
}
473461

474462
if ($signer->getSigned()) {
@@ -622,14 +610,14 @@ public function formatFileWithChildren(File $mainEntity, array $childFiles, ?IUs
622610
: $this->signRequestMapper->getVisibleElementsFromSigners($signRequestEntities);
623611

624612
$signers = [];
625-
$signUuid = null;
613+
$currentSignerRequestUuid = null;
626614
foreach ($signRequestEntities as $signer) {
627615
if ($user) {
628616
$signerData = $this->formatSignerData($signer, $identifyMethods, $visibleElementsData, $metadata, $user);
629617
$signers[] = $signerData;
630618

631-
if ($signUuid === null && !empty($signerData['me']) && isset($signerData['sign_uuid'])) {
632-
$signUuid = $signerData['sign_uuid'];
619+
if ($currentSignerRequestUuid === null && !empty($signerData['me']) && isset($signerData['sign_request_uuid'])) {
620+
$currentSignerRequestUuid = $signerData['sign_request_uuid'];
633621
}
634622
} else {
635623
$signers[] = $this->formatSignerDataBasic($signer, $identifyMethods, $visibleElementsData);
@@ -675,9 +663,8 @@ public function formatFileWithChildren(File $mainEntity, array $childFiles, ?IUs
675663

676664
$response['visibleElements'] = $this->collectVisibleElementsFromSigners($signers);
677665

678-
if ($signUuid !== null) {
679-
$response['signUuid'] = $signUuid;
680-
$response['url'] = $this->urlGenerator->linkToRoute('libresign.page.getPdfFile', ['uuid' => $signUuid]);
666+
if ($currentSignerRequestUuid !== null) {
667+
$response['url'] = $this->urlGenerator->linkToRoute('libresign.page.getPdfFile', ['uuid' => $currentSignerRequestUuid]);
681668
}
682669

683670
if ($mainEntity->getNodeType() === 'envelope') {

lib/Service/File/SettingsLoader.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ public function getUserIdentificationSettings(?IUser $user, ?SignRequest $signRe
144144
return [
145145
'canSign' => false,
146146
'canRequestSign' => false,
147-
'signerFileUuid' => null,
148147
'phoneNumber' => '',
149148
'hasSignatureFile' => false,
150149
'needIdentificationDocuments' => in_array($status, [

lib/Service/File/SignersLoader.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,9 @@ public function loadLibreSignSigners(
178178
}
179179

180180
if ($fileData->signers[$index]->me) {
181-
$fileData->signers[$index]->sign_uuid = $signer->getUuid();
181+
$fileData->signers[$index]->sign_request_uuid = $signer->getUuid();
182182
if (!$signer->getSigned() && isset($fileData->settings)) {
183183
$fileData->settings['canSign'] = true;
184-
$fileData->settings['signerFileUuid'] = $signer->getUuid();
185184
}
186185
$fileData->signers[$index]->signatureMethods = [];
187186
foreach ($identifyMethods as $methods) {

lib/Service/FileService.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ private function initializeFileData(): void {
107107
$this->fileData->nodeId = 0;
108108
$this->fileData->nodeType = 'file';
109109
$this->fileData->created_at = '';
110-
$this->fileData->signUuid = null;
111110
$this->fileData->metadata = [];
112111
$this->fileData->signatureFlow = SignatureFlow::PARALLEL->value;
113112
$this->fileData->signers = [];
@@ -217,7 +216,6 @@ public function showSettings(bool $show = true): self {
217216
$this->fileData->settings = [
218217
'canSign' => false,
219218
'canRequestSign' => false,
220-
'signerFileUuid' => null,
221219
'phoneNumber' => '',
222220
];
223221
} else {
@@ -410,16 +408,18 @@ private function loadSignRequestData(): void {
410408
return;
411409
}
412410

413-
$this->fileData->url = $this->urlGenerator->linkToRoute('libresign.page.getPdfFile', ['uuid' => $this->fileData->uuid]);
411+
$pdfRouteUuid = $this->fileData->uuid;
414412

415413
if (!empty($this->fileData->signers) && is_array($this->fileData->signers)) {
416414
foreach ($this->fileData->signers as $signer) {
417-
if (!empty($signer->me) && isset($signer->sign_uuid)) {
418-
$this->fileData->signUuid = $signer->sign_uuid;
415+
if (!empty($signer->me) && isset($signer->sign_request_uuid)) {
416+
$pdfRouteUuid = $signer->sign_request_uuid;
419417
break;
420418
}
421419
}
422420
}
421+
422+
$this->fileData->url = $this->urlGenerator->linkToRoute('libresign.page.getPdfFile', ['uuid' => $pdfRouteUuid]);
423423
}
424424

425425
private function loadFileMetadata(): void {

openapi-full.json

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -889,10 +889,6 @@
889889
"envelope"
890890
]
891891
},
892-
"signUuid": {
893-
"type": "string",
894-
"nullable": true
895-
},
896892
"metadata": {
897893
"$ref": "#/components/schemas/ValidateMetadata"
898894
},
@@ -1350,10 +1346,6 @@
13501346
"created_at": {
13511347
"type": "string"
13521348
},
1353-
"signUuid": {
1354-
"type": "string",
1355-
"nullable": true
1356-
},
13571349
"metadata": {
13581350
"$ref": "#/components/schemas/ValidateMetadata"
13591351
},
@@ -2125,7 +2117,6 @@
21252117
"required": [
21262118
"canSign",
21272119
"canRequestSign",
2128-
"signerFileUuid",
21292120
"phoneNumber",
21302121
"hasSignatureFile",
21312122
"needIdentificationDocuments",
@@ -2138,10 +2129,6 @@
21382129
"canRequestSign": {
21392130
"type": "boolean"
21402131
},
2141-
"signerFileUuid": {
2142-
"type": "string",
2143-
"nullable": true
2144-
},
21452132
"phoneNumber": {
21462133
"type": "string"
21472134
},
@@ -2400,7 +2387,7 @@
24002387
"type": "string",
24012388
"nullable": true
24022389
},
2403-
"sign_uuid": {
2390+
"sign_request_uuid": {
24042391
"type": "string"
24052392
},
24062393
"hash_algorithm": {
@@ -2818,10 +2805,6 @@
28182805
"url": {
28192806
"type": "string"
28202807
},
2821-
"signUuid": {
2822-
"type": "string",
2823-
"nullable": true
2824-
},
28252808
"mime": {
28262809
"type": "string"
28272810
},

openapi.json

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -605,10 +605,6 @@
605605
"envelope"
606606
]
607607
},
608-
"signUuid": {
609-
"type": "string",
610-
"nullable": true
611-
},
612608
"metadata": {
613609
"$ref": "#/components/schemas/ValidateMetadata"
614610
},
@@ -951,10 +947,6 @@
951947
"created_at": {
952948
"type": "string"
953949
},
954-
"signUuid": {
955-
"type": "string",
956-
"nullable": true
957-
},
958950
"metadata": {
959951
"$ref": "#/components/schemas/ValidateMetadata"
960952
},
@@ -1584,7 +1576,6 @@
15841576
"required": [
15851577
"canSign",
15861578
"canRequestSign",
1587-
"signerFileUuid",
15881579
"phoneNumber",
15891580
"hasSignatureFile",
15901581
"needIdentificationDocuments",
@@ -1597,10 +1588,6 @@
15971588
"canRequestSign": {
15981589
"type": "boolean"
15991590
},
1600-
"signerFileUuid": {
1601-
"type": "string",
1602-
"nullable": true
1603-
},
16041591
"phoneNumber": {
16051592
"type": "string"
16061593
},
@@ -1802,7 +1789,7 @@
18021789
"type": "string",
18031790
"nullable": true
18041791
},
1805-
"sign_uuid": {
1792+
"sign_request_uuid": {
18061793
"type": "string"
18071794
},
18081795
"hash_algorithm": {
@@ -2206,10 +2193,6 @@
22062193
"url": {
22072194
"type": "string"
22082195
},
2209-
"signUuid": {
2210-
"type": "string",
2211-
"nullable": true
2212-
},
22132196
"mime": {
22142197
"type": "string"
22152198
},

playwright/support/nc-provisioning.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ type SignatureElementResponse = {
2727
}>
2828
}
2929

30-
async function ocsRequest(
30+
async function ocsRequest<T = unknown>(
3131
request: APIRequestContext,
3232
method: 'GET' | 'POST' | 'PUT' | 'DELETE',
3333
path: string,
3434
adminUser = process.env.NEXTCLOUD_ADMIN_USER ?? 'admin',
3535
adminPassword = process.env.NEXTCLOUD_ADMIN_PASSWORD ?? 'admin',
3636
body?: Record<string, string>,
3737
jsonBody?: unknown,
38-
): Promise<OcsResponse> {
38+
): Promise<OcsResponse<T>> {
3939
const url = `./ocs/v2.php${path}`
4040
const auth = 'Basic ' + Buffer.from(`${adminUser}:${adminPassword}`).toString('base64')
4141
const headers: Record<string, string> = {
@@ -59,9 +59,9 @@ async function ocsRequest(
5959

6060
const text = await response.text()
6161
if (!text) {
62-
return { ocs: { meta: { status: 'ok', statuscode: response.status(), message: '' }, data: {} } } as OcsResponse
62+
return { ocs: { meta: { status: 'ok', statuscode: response.status(), message: '' }, data: {} as T } }
6363
}
64-
return JSON.parse(text) as OcsResponse
64+
return JSON.parse(text) as OcsResponse<T>
6565
}
6666

6767
export async function clearSignatureElements(

src/components/Request/VisibleElements.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ import PdfEditor from '../PdfEditor/PdfEditor.vue'
101101
import Signer from '../Signers/Signer.vue'
102102
103103
import { FILE_STATUS } from '../../constants.js'
104+
import { getSigningRouteUuid } from '../../utils/signRequestUuid.ts'
104105
import { useFilesStore } from '../../store/files.js'
105106
import {
106107
aggregateVisibleElementsByFiles,
@@ -522,7 +523,7 @@ const pdfEditorSigners = computed<SignerSummaryRecord[]>(() => (Array.isArray(do
522523
const status = computed(() => Number(document.value.status))
523524
const isDraft = computed(() => status.value === FILE_STATUS.DRAFT)
524525
const canSave = computed(() => ([FILE_STATUS.DRAFT, FILE_STATUS.ABLE_TO_SIGN, FILE_STATUS.PARTIAL_SIGNED] as number[]).includes(status.value))
525-
const canSign = computed(() => status.value === FILE_STATUS.ABLE_TO_SIGN && (document.value?.settings?.signerFileUuid ?? '').length > 0)
526+
const canSign = computed(() => status.value === FILE_STATUS.ABLE_TO_SIGN && !!getSigningRouteUuid(document.value))
526527
const variantOfSaveButton = computed(() => canSave.value ? 'primary' : 'secondary')
527528
const variantOfSignButton = computed(() => canSave.value ? 'secondary' : 'primary')
528529
const statusLabel = computed(() => document.value.statusText || '')
@@ -820,7 +821,7 @@ function handleDeleteSigner(object: unknown) {
820821
}
821822
822823
async function goToSign() {
823-
const uuid = document.value.settings?.signerFileUuid
824+
const uuid = getSigningRouteUuid(document.value)
824825
if (await save()) {
825826
const route = instance?.proxy?.$router.resolve({ name: 'SignPDF', params: { uuid } })
826827
if (route?.href) {

0 commit comments

Comments
 (0)