Skip to content

Commit

Permalink
feat: Add flag isSubscription to return value of method `checkAcces…
Browse files Browse the repository at this point in the history
…s` (#56)

This allows the consuming app to handle time pass based access different
from subscription based access (e.g. show individual UI).
  • Loading branch information
jmcodingde authored Jun 20, 2024
1 parent 58af28b commit dade8c6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
23 changes: 23 additions & 0 deletions Supertab.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
});
});
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ export class Supertab {
validTo: access.access.validTo
? new Date(access.access.validTo * 1000)
: undefined,
isSubscription: !!access.access.subscriptionId,
},
};
}
Expand Down

0 comments on commit dade8c6

Please sign in to comment.