diff --git a/src/core/client/embed/StreamEmbed.ts b/src/core/client/embed/StreamEmbed.ts index 6f89de186..58aac27fa 100644 --- a/src/core/client/embed/StreamEmbed.ts +++ b/src/core/client/embed/StreamEmbed.ts @@ -1,6 +1,9 @@ import { EventEmitter2 } from "eventemitter2"; import qs from "query-string"; +import ensureNoEndSlash from "talk-common/utils/ensureNoEndSlash"; +import urls from "talk-framework/helpers/urls"; + import { Decorator, withAutoHeight, @@ -15,13 +18,6 @@ import PymControl, { defaultPymControlFactory, PymControlFactory, } from "./PymControl"; -import { ensureNoEndSlash } from "./utils"; - -// This is importing the url helper from the framework using a relative path -// import because the ts paths are not configured to use the framework for this -// target. -// TODO: (wyattjoh) replace with import from framework when we include it in the config. -import urls from "../framework/helpers/urls"; export interface StreamEmbedConfig { storyID?: string; diff --git a/src/core/client/embed/tsconfig.json b/src/core/client/embed/tsconfig.json index ce6279923..3229d8a13 100644 --- a/src/core/client/embed/tsconfig.json +++ b/src/core/client/embed/tsconfig.json @@ -3,7 +3,11 @@ "compilerOptions": { "lib": ["dom", "es5"], "types": ["jest", "node"], - "paths": {} + "baseUrl": "./", + "paths": { + "talk-common/*": ["../../common/*"], + "talk-framework/*": ["../framework/*"] + } }, "include": [ "./**/*", diff --git a/src/core/client/embed/utils/index.ts b/src/core/client/embed/utils/index.ts index 18b20360b..13c551665 100644 --- a/src/core/client/embed/utils/index.ts +++ b/src/core/client/embed/utils/index.ts @@ -1,6 +1,4 @@ export { default as buildURL } from "./buildURL"; -export { default as ensureEndSlash } from "./ensureEndSlash"; -export { default as ensureNoEndSlash } from "./ensureNoEndSlash"; export { default as startsWith } from "./startsWith"; export { default as prefixStorage } from "./prefixStorage"; export { default as parseHashQuery } from "./parseHashQuery"; diff --git a/src/core/client/embed/utils/ensureEndSlash.spec.ts b/src/core/common/utils/ensureEndSlash.spec.ts similarity index 100% rename from src/core/client/embed/utils/ensureEndSlash.spec.ts rename to src/core/common/utils/ensureEndSlash.spec.ts diff --git a/src/core/client/embed/utils/ensureEndSlash.ts b/src/core/common/utils/ensureEndSlash.ts similarity index 100% rename from src/core/client/embed/utils/ensureEndSlash.ts rename to src/core/common/utils/ensureEndSlash.ts diff --git a/src/core/client/embed/utils/ensureNoEndSlash.spec.ts b/src/core/common/utils/ensureNoEndSlash.spec.ts similarity index 100% rename from src/core/client/embed/utils/ensureNoEndSlash.spec.ts rename to src/core/common/utils/ensureNoEndSlash.spec.ts diff --git a/src/core/client/embed/utils/ensureNoEndSlash.ts b/src/core/common/utils/ensureNoEndSlash.ts similarity index 100% rename from src/core/client/embed/utils/ensureNoEndSlash.ts rename to src/core/common/utils/ensureNoEndSlash.ts diff --git a/src/core/common/utils/index.ts b/src/core/common/utils/index.ts index 4d6df9fc5..dade47431 100644 --- a/src/core/common/utils/index.ts +++ b/src/core/common/utils/index.ts @@ -3,3 +3,5 @@ export { default as animationFrame } from "./animationFrame"; export { default as pascalCase } from "./pascalCase"; export { default as oncePerFrame } from "./oncePerFrame"; export { default as isBeforeDate } from "./isBeforeDate"; +export { default as ensureEndSlash } from "./ensureEndSlash"; +export { default as ensureNoEndSlash } from "./ensureNoEndSlash"; diff --git a/src/core/server/app/middleware/passport/strategies/oidc/discover.ts b/src/core/server/app/middleware/passport/strategies/oidc/discover.ts index 3fe4679a6..844969bd3 100644 --- a/src/core/server/app/middleware/passport/strategies/oidc/discover.ts +++ b/src/core/server/app/middleware/passport/strategies/oidc/discover.ts @@ -1,6 +1,8 @@ import fetch from "node-fetch"; import { URL } from "url"; +import { ensureNoEndSlash } from "talk-common/utils"; + /** * Configuration that Talk is expecting. */ @@ -35,8 +37,7 @@ export async function discover( // Any provider MUST provide a .well-known url that is JSON parsable based // on the issuer: https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderConfig const configurationURL = - issuer.origin + - issuer.pathname.replace(/\/$/, "") + + ensureNoEndSlash(issuer.origin + issuer.pathname) + "/.well-known/openid-configuration"; const res = await fetch(configurationURL);