From dade8c6aa8df00915df5e34b32b86b9d262bf3f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jannes=20Philipp=20M=C3=B6nnighoff?= Date: Thu, 20 Jun 2024 15:52:20 +0200 Subject: [PATCH] feat: Add flag `isSubscription` to return value of method `checkAccess` (#56) This allows the consuming app to handle time pass based access different from subscription based access (e.g. show individual UI). --- Supertab.test.ts | 23 +++++++++++++++++++++++ src/index.ts | 1 + 2 files changed, 24 insertions(+) diff --git a/Supertab.test.ts b/Supertab.test.ts index 28c62d9..0fc0255 100644 --- a/Supertab.test.ts +++ b/Supertab.test.ts @@ -428,6 +428,29 @@ describe("Supertab", () => { expect(await client.checkAccess()).toEqual({ access: { validTo: new Date(1700119519 * 1000), + isSubscription: false, + }, + }); + }); + + test("set flag `isSubscription` for subscription based access", async () => { + const { client } = setup(); + + server.withClientConfig(accessClientConfig); + + server.withAccessCheck({ + access: { + status: "Granted", + contentKey: "test-content-key", + validTo: 1700119519, + subscriptionId: "test-subscription-id", + }, + }); + + expect(await client.checkAccess()).toEqual({ + access: { + validTo: new Date(1700119519 * 1000), + isSubscription: true, }, }); }); diff --git a/src/index.ts b/src/index.ts index db26daa..e6dd614 100644 --- a/src/index.ts +++ b/src/index.ts @@ -226,6 +226,7 @@ export class Supertab { validTo: access.access.validTo ? new Date(access.access.validTo * 1000) : undefined, + isSubscription: !!access.access.subscriptionId, }, }; }