From 6f3f858d813bc11c8f39fbb098183be9dea0056b Mon Sep 17 00:00:00 2001 From: Rory Powell Date: Tue, 22 Nov 2022 22:24:45 +0000 Subject: [PATCH] Account portal <-> backend-core fixes --- packages/backend-core/src/security/sessions.ts | 1 + packages/types/src/sdk/auth.ts | 2 ++ packages/types/src/sdk/featureFlag.ts | 7 +++++++ packages/types/src/sdk/index.ts | 1 + packages/types/src/sdk/koa.ts | 9 ++++++--- 5 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 packages/types/src/sdk/featureFlag.ts diff --git a/packages/backend-core/src/security/sessions.ts b/packages/backend-core/src/security/sessions.ts index 33230afc60..48e75b0d60 100644 --- a/packages/backend-core/src/security/sessions.ts +++ b/packages/backend-core/src/security/sessions.ts @@ -89,6 +89,7 @@ export async function createASession( userId, } await client.store(key, session, EXPIRY_SECONDS) + return session } export async function updateSessionTTL(session: Session) { diff --git a/packages/types/src/sdk/auth.ts b/packages/types/src/sdk/auth.ts index 766d18a606..edcaf197e2 100644 --- a/packages/types/src/sdk/auth.ts +++ b/packages/types/src/sdk/auth.ts @@ -1,4 +1,5 @@ import { BBContext } from "./koa" +import { Hosting } from "./hosting" export interface AuthToken { userId: string @@ -10,6 +11,7 @@ export interface CreateSession { sessionId: string tenantId: string csrfToken?: string + hosting?: Hosting } export interface Session extends CreateSession { diff --git a/packages/types/src/sdk/featureFlag.ts b/packages/types/src/sdk/featureFlag.ts new file mode 100644 index 0000000000..53aa4842c4 --- /dev/null +++ b/packages/types/src/sdk/featureFlag.ts @@ -0,0 +1,7 @@ +export enum FeatureFlag { + LICENSING = "LICENSING", +} + +export interface TenantFeatureFlags { + [key: string]: FeatureFlag[] +} diff --git a/packages/types/src/sdk/index.ts b/packages/types/src/sdk/index.ts index a32c8e2077..e5512b062b 100644 --- a/packages/types/src/sdk/index.ts +++ b/packages/types/src/sdk/index.ts @@ -10,3 +10,4 @@ export * from "./auth" export * from "./locks" export * from "./db" export * from "./middleware" +export * from "./featureFlag" diff --git a/packages/types/src/sdk/koa.ts b/packages/types/src/sdk/koa.ts index ffbb1cf053..a9d3cc4231 100644 --- a/packages/types/src/sdk/koa.ts +++ b/packages/types/src/sdk/koa.ts @@ -1,15 +1,18 @@ import { Context, Request } from "koa" -import { User, Role, UserRoles } from "../documents" -import { License } from "../sdk" +import { User, Role, UserRoles, Account } from "../documents" +import { FeatureFlag, License } from "../sdk" export interface ContextUser extends Omit { globalId?: string - license: License + license?: License userId?: string roleId?: string | null role?: Role roles?: UserRoles csrfToken?: string + featureFlags?: FeatureFlag[] + accountPortalAccess?: boolean + account?: Account } export interface BBRequest extends Request {