From ef42500e9d46049a2f1ada195e5ddc3fa6289972 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81sd=C3=ADs=20Erna=20Gu=C3=B0mundsd=C3=B3ttir?= Date: Fri, 20 Dec 2024 13:45:19 +0000 Subject: [PATCH 1/4] fix(my-pages): Health - Organ donation string mix (#17326) --- .../health/src/screens/OrganDonation/OrganDonation.tsx | 4 ++-- .../src/screens/OrganDonation/components/RegistrationForm.tsx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/portals/my-pages/health/src/screens/OrganDonation/OrganDonation.tsx b/libs/portals/my-pages/health/src/screens/OrganDonation/OrganDonation.tsx index 7ef00c370fb5..f99e0cf5b1a0 100644 --- a/libs/portals/my-pages/health/src/screens/OrganDonation/OrganDonation.tsx +++ b/libs/portals/my-pages/health/src/screens/OrganDonation/OrganDonation.tsx @@ -43,8 +43,8 @@ const OrganDonation = () => { iAmOrganDonorWithExceptionsText: formatMessage( m.iAmOrganDonorWithExceptionsText, ), - iAmNotOrganDonorText: formatMessage(m.iAmOrganDonorText), - iAmOrganDonorText: formatMessage(m.iAmNotOrganDonorText), + iAmNotOrganDonorText: formatMessage(m.iAmNotOrganDonorText), + iAmOrganDonorText: formatMessage(m.iAmOrganDonorText), iAmOrganDonorWithExceptions: formatMessage(m.iAmOrganDonorWithExceptions), iAmOrganDonor: formatMessage(m.iAmOrganDonor), iAmNotOrganDonor: formatMessage(m.iAmNotOrganDonor), diff --git a/libs/portals/my-pages/health/src/screens/OrganDonation/components/RegistrationForm.tsx b/libs/portals/my-pages/health/src/screens/OrganDonation/components/RegistrationForm.tsx index 4b4db5a87fcf..f06005e5afae 100644 --- a/libs/portals/my-pages/health/src/screens/OrganDonation/components/RegistrationForm.tsx +++ b/libs/portals/my-pages/health/src/screens/OrganDonation/components/RegistrationForm.tsx @@ -87,7 +87,7 @@ export const OrganRegistrationForm = () => { const formData = new FormData(e.currentTarget) const data = Object.fromEntries(formData.entries()) const idKey = 'selected-limitations-' - const otherLimitations = data['otherLimitatons'].toString() + const otherLimitations = data['otherLimitatons']?.toString() const limitations = Object.keys(data) .filter((key) => key.includes(idKey)) .map((key) => key.replace(idKey, '').toLowerCase()) From 73efe537b6daa434c0c224ffad882b612a8ed876 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sigr=C3=BAn=20Tinna=20Gissurard=C3=B3ttir?= <39527334+sigruntg@users.noreply.github.com> Date: Fri, 20 Dec 2024 14:04:18 +0000 Subject: [PATCH 2/4] fix(register-new-macine): making street registration optional (#17332) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- .../templates/aosh/register-new-machine/src/lib/dataSchema.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/application/templates/aosh/register-new-machine/src/lib/dataSchema.ts b/libs/application/templates/aosh/register-new-machine/src/lib/dataSchema.ts index 12432ed6ecf9..c921799ac33b 100644 --- a/libs/application/templates/aosh/register-new-machine/src/lib/dataSchema.ts +++ b/libs/application/templates/aosh/register-new-machine/src/lib/dataSchema.ts @@ -252,7 +252,7 @@ export const NewMachineAnswersSchema = z.object({ streetRegistration: z .object({ registerToTraffic: z.enum([YES, NO]), - size: z.enum(['1', '2', '3']), + size: z.enum(['1', '2', '3']).optional(), }) .optional(), }), From 18269879537a47ae8be7ba20a93b645e0e90a697 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gunnlaugur=20Gu=C3=B0mundsson?= <34029342+GunnlaugurG@users.noreply.github.com> Date: Fri, 20 Dec 2024 15:03:19 +0000 Subject: [PATCH 3/4] feat(auth-admin): Allow non super users to publish super user fields (#17290) --- .../app/v2/clients/test/me-clients.spec.ts | 24 ++++++++++++------- .../clients/admin/admin-clients.service.ts | 17 +------------ 2 files changed, 17 insertions(+), 24 deletions(-) diff --git a/apps/services/auth/admin-api/src/app/v2/clients/test/me-clients.spec.ts b/apps/services/auth/admin-api/src/app/v2/clients/test/me-clients.spec.ts index 58235d12f2b1..3e73048f6aca 100644 --- a/apps/services/auth/admin-api/src/app/v2/clients/test/me-clients.spec.ts +++ b/apps/services/auth/admin-api/src/app/v2/clients/test/me-clients.spec.ts @@ -431,23 +431,26 @@ describe('MeClientsController with auth', () => { slidingRefreshTokenLifetime: typeSpecificDefaults.slidingRefreshTokenLifetime ?? clientBaseAttributes.slidingRefreshTokenLifetime, - accessTokenLifetime: clientBaseAttributes.accessTokenLifetime, + accessTokenLifetime: + typeSpecificDefaults.accessTokenLifetime ?? + clientBaseAttributes.accessTokenLifetime, allowOfflineAccess: clientBaseAttributes.allowOfflineAccess, redirectUris: [], postLogoutRedirectUris: [], requireApiScopes: false, requireConsent: false, - requirePkce: true, - supportTokenExchange: false, + requirePkce: + typeSpecificDefaults.requirePkce ?? clientBaseAttributes.requirePkce, + supportTokenExchange: typeSpecificDefaults.supportTokenExchange, supportsCustomDelegation: false, supportsLegalGuardians: false, supportsPersonalRepresentatives: false, supportsProcuringHolders: false, promptDelegations: false, - customClaims: [], + customClaims: typeSpecificDefaults.customClaims ?? [], singleSession: false, supportedDelegationTypes: [], - allowedAcr: [defaultAcrValue], + allowedAcr: typeSpecificDefaults.allowedAcr ?? [defaultAcrValue], }) // Assert - db record @@ -468,9 +471,14 @@ describe('MeClientsController with auth', () => { absoluteRefreshTokenLifetime: typeSpecificDefaults.absoluteRefreshTokenLifetime ?? clientBaseAttributes.absoluteRefreshTokenLifetime, - accessTokenLifetime: clientBaseAttributes.accessTokenLifetime, - allowOfflineAccess: clientBaseAttributes.allowOfflineAccess, - requirePkce: clientBaseAttributes.requirePkce, + accessTokenLifetime: + typeSpecificDefaults.accessTokenLifetime ?? + clientBaseAttributes.accessTokenLifetime, + allowOfflineAccess: + typeSpecificDefaults.allowOfflineAccess ?? + clientBaseAttributes.allowOfflineAccess, + requirePkce: + typeSpecificDefaults.requirePkce ?? clientBaseAttributes.requirePkce, refreshTokenExpiration: translateRefreshTokenExpiration( typeSpecificDefaults.refreshTokenExpiration, ), diff --git a/libs/auth-api-lib/src/lib/clients/admin/admin-clients.service.ts b/libs/auth-api-lib/src/lib/clients/admin/admin-clients.service.ts index f919f1611294..474cf26dbee2 100644 --- a/libs/auth-api-lib/src/lib/clients/admin/admin-clients.service.ts +++ b/libs/auth-api-lib/src/lib/clients/admin/admin-clients.service.ts @@ -173,21 +173,6 @@ export class AdminClientsService { throw new BadRequestException('Invalid client id') } - // If user is not super admin, we remove the super admin fields from the input to default to the client base attributes - if (!this.isSuperAdmin(user)) { - clientDto = { - clientId: clientDto.clientId, - clientType: clientDto.clientType, - clientName: clientDto.clientName, - // Remove defined super admin fields - ...omit(clientDto, superUserFields), - // Remove personal representative from delegation types since it is not allowed for non-super admins - supportedDelegationTypes: delegationTypeSuperUserFilter( - clientDto.supportedDelegationTypes ?? [], - ), - } - } - const { customClaims, displayName, @@ -600,7 +585,7 @@ export class AdminClientsService { client.supportedDelegationTypes?.map( (clientDelegationType) => clientDelegationType.delegationType, ) ?? [], - allowedAcr: client.allowedAcr ?? [], + allowedAcr: client.allowedAcr.map((v) => v.toString()) ?? [], } } From 8d0e0926502da14f8806b7337778d13fab6afbbe Mon Sep 17 00:00:00 2001 From: juni-haukur <158475136+juni-haukur@users.noreply.github.com> Date: Fri, 20 Dec 2024 15:53:28 +0000 Subject: [PATCH 4/4] fix(inheritance-report): Send uploaded files data to syslumenn (#17325) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- .../inheritance-report.module.ts | 2 + .../inheritance-report.service.ts | 53 ++++++++++++++++++- .../inheritance-report/src/lib/dataSchema.ts | 8 +++ 3 files changed, 62 insertions(+), 1 deletion(-) diff --git a/libs/application/template-api-modules/src/lib/modules/templates/inheritance-report/inheritance-report.module.ts b/libs/application/template-api-modules/src/lib/modules/templates/inheritance-report/inheritance-report.module.ts index 3e22223815d3..b69ac6eeb172 100644 --- a/libs/application/template-api-modules/src/lib/modules/templates/inheritance-report/inheritance-report.module.ts +++ b/libs/application/template-api-modules/src/lib/modules/templates/inheritance-report/inheritance-report.module.ts @@ -5,12 +5,14 @@ import { SyslumennClientModule } from '@island.is/clients/syslumenn' import { InheritanceReportService } from './inheritance-report.service' import { NationalRegistryXRoadModule } from '@island.is/api/domains/national-registry-x-road' +import { AwsModule } from '@island.is/nest/aws' @Module({ imports: [ SharedTemplateAPIModule, SyslumennClientModule, NationalRegistryXRoadModule, + AwsModule, ], providers: [InheritanceReportService], exports: [InheritanceReportService], diff --git a/libs/application/template-api-modules/src/lib/modules/templates/inheritance-report/inheritance-report.service.ts b/libs/application/template-api-modules/src/lib/modules/templates/inheritance-report/inheritance-report.service.ts index 3edd5317d203..ca260f1cf23d 100644 --- a/libs/application/template-api-modules/src/lib/modules/templates/inheritance-report/inheritance-report.service.ts +++ b/libs/application/template-api-modules/src/lib/modules/templates/inheritance-report/inheritance-report.service.ts @@ -1,5 +1,6 @@ import { Inject, Injectable } from '@nestjs/common' import { + Attachment, DataUploadResponse, Person, PersonType, @@ -18,6 +19,7 @@ import { inheritanceReportSchema } from '@island.is/application/templates/inheri import type { Logger } from '@island.is/logging' import { expandAnswers } from './utils/mappers' import { NationalRegistryXRoadService } from '@island.is/api/domains/national-registry-x-road' +import { S3Service } from '@island.is/nest/aws' type InheritanceSchema = zinfer @@ -27,6 +29,7 @@ export class InheritanceReportService extends BaseTemplateApiService { @Inject(LOGGER_PROVIDER) private logger: Logger, private readonly syslumennService: SyslumennService, private readonly nationalRegistryService: NationalRegistryXRoadService, + private readonly s3Service: S3Service, ) { super(ApplicationTypes.INHERITANCE_REPORT) } @@ -105,9 +108,44 @@ export class InheritanceReportService extends BaseTemplateApiService { const uploadDataName = 'erfdafjarskysla1.0' const uploadDataId = 'erfdafjarskysla1.0' + const attachments: Attachment[] = [] + + if (answers?.heirsAdditionalInfoPrivateTransferFiles) { + attachments.push( + ...(await Promise.all( + answers.heirsAdditionalInfoPrivateTransferFiles.map(async (file) => { + const content = await this.getFileContentBase64(file.key) + return { + name: file.name, + content, + } + }), + )), + ) + } + + if (answers?.heirsAdditionalInfoFilesOtherDocuments) { + attachments.push( + ...(await Promise.all( + answers.heirsAdditionalInfoFilesOtherDocuments.map(async (file) => { + const content = await this.getFileContentBase64(file.key) + return { + name: file.name, + content, + } + }), + )), + ) + } const result: DataUploadResponse = await this.syslumennService - .uploadData([person], undefined, uploadData, uploadDataName, uploadDataId) + .uploadData( + [person], + attachments, + uploadData, + uploadDataName, + uploadDataId, + ) .catch((e) => { return { success: false, @@ -131,4 +169,17 @@ export class InheritanceReportService extends BaseTemplateApiService { const spouse = await this.nationalRegistryService.getSpouse(auth.nationalId) return { ...spouse, fullName: spouse?.name } } + + async getFileContentBase64(fileName: string): Promise { + try { + const fileContent = await this.s3Service.getFileContent( + fileName, + 'base64', + ) + return fileContent || '' + } catch (e) { + this.logger.warn('[estate]: Failed to get file content - ', e) + return 'err' + } + } } diff --git a/libs/application/templates/inheritance-report/src/lib/dataSchema.ts b/libs/application/templates/inheritance-report/src/lib/dataSchema.ts index 2e369699cc60..054423f72638 100644 --- a/libs/application/templates/inheritance-report/src/lib/dataSchema.ts +++ b/libs/application/templates/inheritance-report/src/lib/dataSchema.ts @@ -676,6 +676,14 @@ export const inheritanceReportSchema = z.object({ }), heirsAdditionalInfo: z.string().optional(), + heirsAdditionalInfoPrivateTransferFiles: z + .object({ key: z.string(), name: z.string() }) + .array() + .optional(), + heirsAdditionalInfoFilesOtherDocuments: z + .object({ key: z.string(), name: z.string() }) + .array() + .optional(), spouse: z .object({