Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion packages/runtime/src/useCases/common/Schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17337,12 +17337,25 @@ export const CreatePresentationTokenRequest: any = {
"properties": {
"attributeId": {
"type": "string"
},
"expiresAt": {
"$ref": "#/definitions/ISO8601DateTimeString"
},
"ephemeral": {
"type": "boolean"
}
},
"required": [
"attributeId"
"attributeId",
"expiresAt",
"ephemeral"
],
"additionalProperties": false
},
"ISO8601DateTimeString": {
"type": "string",
"errorMessage": "must match ISO8601 datetime format",
"pattern": "^([+-]?\\d{4}(?!\\d{2}\\b))((-?)((0[1-9]|1[0-2])(\\3([12]\\d|0[1-9]|3[01]))?|W([0-4]\\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\\d|[12]\\d{2}|3([0-5]\\d|6[1-6])))([T\\s]((([01]\\d|2[0-3])((:?)[0-5]\\d)?|24:?00)([.,]\\d+(?!:))?)?(\\17[0-5]\\d([.,]\\d+)?)?([zZ]|([+-])([01]\\d|2[0-3]):?([0-5]\\d)?)?)?)?$"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import { CoreDate, CoreId } from "@nmshd/core-types";
import { TokenDTO } from "@nmshd/runtime-types";
import { TokenController } from "@nmshd/transport";
import { Inject } from "@nmshd/typescript-ioc";
import { RuntimeErrors, SchemaRepository, SchemaValidator, UseCase } from "../../common";
import { ISO8601DateTimeString, RuntimeErrors, SchemaRepository, SchemaValidator, UseCase } from "../../common";
import { TokenMapper } from "../../transport/tokens/TokenMapper";

export interface CreatePresentationTokenRequest {
attributeId: string;
expiresAt: ISO8601DateTimeString;
ephemeral: boolean;
}

class Validator extends SchemaValidator<CreatePresentationTokenRequest> {
Expand All @@ -36,8 +38,8 @@ export class CreatePresentationTokenUseCase extends UseCase<CreatePresentationTo

const token = await this.tokenController.sendToken({
content: presentationTokenContent.toJSON(),
expiresAt: CoreDate.utc().add({ minutes: 1 }),
ephemeral: true
expiresAt: CoreDate.from(request.expiresAt),
ephemeral: request.ephemeral
});

return Result.ok(TokenMapper.toTokenDTO(token, true));
Expand Down
7 changes: 6 additions & 1 deletion packages/runtime/test/consumption/openid4vc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { SdJwtVcRecord } from "@credo-ts/core";
import { EudiploClient } from "@eudiplo/sdk-core";
import { AcceptProposeAttributeRequestItemParametersWithNewAttributeJSON, AcceptShareAuthorizationRequestRequestItemParametersJSON, decodeRecord } from "@nmshd/consumption";
import { RequestJSON, ShareAuthorizationRequestRequestItemJSON, VerifiableCredentialJSON, VerifiablePresentation } from "@nmshd/content";
import { CoreDate } from "@nmshd/core-types";
import axios, { AxiosInstance } from "axios";
import * as client from "openid-client";
import path from "path";
Expand Down Expand Up @@ -274,7 +275,11 @@ describe("EUDIPLO", () => {
).value;
expect((storedCredential.content.value as VerifiableCredentialJSON).displayInformation?.[0].name).toBe("test");

const presentationTokenResult = await runtimeServices1.consumption.openId4Vc.createPresentationToken({ attributeId: storedCredential.id });
const presentationTokenResult = await runtimeServices1.consumption.openId4Vc.createPresentationToken({
attributeId: storedCredential.id,
expiresAt: CoreDate.utc().add({ minutes: 1 }).toString(),
ephemeral: true
});
expect(presentationTokenResult).toBeSuccessful();

const presentationTokenContent = presentationTokenResult.value.content;
Expand Down
Loading