Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V6 #44

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open

V6 #44

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
1 change: 0 additions & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"useTabs": false,
"semi": true,
"singleQuote": false,
"quoteProps": "preserve",
"trailingComma": "none",
"bracketSpacing": true,
"arrowParens": "avoid"
Expand Down
32 changes: 32 additions & 0 deletions examples/tanstack-router-file-based/public/oidc-callback.htm
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!doctype html>
<html>

<body>
<!-- oidc-spa file. Do not remove, do not edit -->
<script>

const authResponse = {};

for (const [key, value] of new URL(location.href).searchParams) {
authResponse[key] = value;
}

const stateData = JSON.parse(localStorage.getItem(`oidc.${authResponse.state}`)).data;

if (stateData.isSilentSso) {
console.log("Posting message to parent window");
parent.postMessage(authResponse, location.origin);
} else {
const redirectUrl = new URL(stateData.redirectUrl);

for (const [key, value] of Object.entries(authResponse)) {
redirectUrl.searchParams.set(`oidc-spa.${key}`, value);
}

location.replace(redirectUrl.href);
}

</script>
</body>

</html>
8 changes: 0 additions & 8 deletions examples/tanstack-router-file-based/public/silent-sso.htm

This file was deleted.

2 changes: 1 addition & 1 deletion examples/tanstack-router-file-based/src/oidc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const {

issuerUri: import.meta.env.VITE_OIDC_ISSUER,
clientId: import.meta.env.VITE_OIDC_CLIENT_ID,
publicUrl: import.meta.env.BASE_URL,
BASE_URL: import.meta.env.BASE_URL,
/**
* This parameter is optional.
*
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "oidc-spa",
"version": "5.7.0",
"version": "6.0.0-rc.1",
"description": "Openidconnect client for Single Page Applications",
"repository": {
"type": "git",
Expand Down Expand Up @@ -63,7 +63,7 @@
"prettier": "^2.8.8",
"react": "^18.2.0",
"ts-node": "^10.9.1",
"tsafe": "^1.7.5",
"tsafe": "^1.8.5",
"tsx": "^4.15.5",
"typescript": "^5.5.4",
"webpack": "5.93.0",
Expand Down
12 changes: 6 additions & 6 deletions scripts/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const startTime = Date.now();
const distDirPath = pathJoin(__dirname, "..", "dist");

if (fs.existsSync(distDirPath)) {
fs.rmSync(distDirPath, { "recursive": true });
fs.rmSync(distDirPath, { recursive: true });
}

run("npx tsc");
Expand All @@ -25,7 +25,7 @@ run("npx tsc");

assert(typeof version === "string");

const filePath = pathJoin(distDirPath, "oidc.js");
const filePath = pathJoin(distDirPath, "oidc", "createOidc.js");

const content = fs.readFileSync(filePath).toString("utf8");

Expand All @@ -40,7 +40,7 @@ const extraBundleFileBasenames = new Set<string>();

(["backend", "frontend"] as const)
.map(backendOrFrontend => ({
"vendorDirPath": pathJoin(distDirPath, "vendor", backendOrFrontend),
vendorDirPath: pathJoin(distDirPath, "vendor", backendOrFrontend),
backendOrFrontend
}))
.forEach(({ backendOrFrontend, vendorDirPath }) =>
Expand All @@ -60,7 +60,7 @@ const extraBundleFileBasenames = new Set<string>();
const cacheDirPath = pathJoin(__dirname, "..", "node_modules", ".cache", "scripts");

if (!fs.existsSync(cacheDirPath)) {
fs.mkdirSync(cacheDirPath, { "recursive": true });
fs.mkdirSync(cacheDirPath, { recursive: true });
}

const webpackConfigJsFilePath = pathJoin(cacheDirPath, "webpack.config.js");
Expand Down Expand Up @@ -130,7 +130,7 @@ const extraBundleFileBasenames = new Set<string>();
}
});

fs.rmSync(webpackOutputDirPath, { "recursive": true });
fs.rmSync(webpackOutputDirPath, { recursive: true });

fs.writeFileSync(
filePath,
Expand All @@ -148,5 +148,5 @@ console.log(`✓ built in ${((Date.now() - startTime) / 1000).toFixed(2)}s`);

function run(command: string) {
console.log(`$ ${command}`);
child_process.execSync(command, { "stdio": "inherit" });
child_process.execSync(command, { stdio: "inherit" });
}
30 changes: 15 additions & 15 deletions scripts/link-in-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ fs.writeFileSync(

return {
...packageJsonParsed,
"main": packageJsonParsed["main"]?.replace(/^dist\//, ""),
"types": packageJsonParsed["types"]?.replace(/^dist\//, ""),
"module": packageJsonParsed["module"]?.replace(/^dist\//, ""),
"bin": !("bin" in packageJsonParsed)
main: packageJsonParsed["main"]?.replace(/^dist\//, ""),
types: packageJsonParsed["types"]?.replace(/^dist\//, ""),
module: packageJsonParsed["module"]?.replace(/^dist\//, ""),
bin: !("bin" in packageJsonParsed)
? undefined
: Object.fromEntries(
Object.entries(packageJsonParsed["bin"]).map(([key, value]) => [
key,
(value as string).replace(/^dist\//, "")
])
),
"exports": !("exports" in packageJsonParsed)
exports: !("exports" in packageJsonParsed)
? undefined
: Object.fromEntries(
Object.entries(packageJsonParsed["exports"]).map(([key, value]) => [
Expand Down Expand Up @@ -66,7 +66,7 @@ const commonThirdPartyDeps = (() => {

const yarnGlobalDirPath = pathJoin(rootDirPath, ".yarn_home");

fs.rmSync(yarnGlobalDirPath, { "recursive": true, "force": true });
fs.rmSync(yarnGlobalDirPath, { recursive: true, force: true });
fs.mkdirSync(yarnGlobalDirPath);

const execYarnLink = (params: { targetModuleName?: string; cwd: string }) => {
Expand All @@ -82,9 +82,9 @@ const execYarnLink = (params: { targetModuleName?: string; cwd: string }) => {

execSync(cmd, {
cwd,
"env": {
env: {
...process.env,
"HOME": yarnGlobalDirPath
HOME: yarnGlobalDirPath
}
});
};
Expand Down Expand Up @@ -112,7 +112,7 @@ if (testAppPaths.length === 0) {
process.exit(-1);
}

testAppPaths.forEach(testAppPath => execSync("yarn install", { "cwd": testAppPath }));
testAppPaths.forEach(testAppPath => execSync("yarn install", { cwd: testAppPath }));

console.log("=== Linking common dependencies ===");

Expand All @@ -134,26 +134,26 @@ commonThirdPartyDeps.forEach(commonThirdPartyDep => {
]
);

execYarnLink({ "cwd": localInstallPath });
execYarnLink({ cwd: localInstallPath });
});

commonThirdPartyDeps.forEach(commonThirdPartyDep =>
testAppPaths.forEach(testAppPath =>
execYarnLink({
"cwd": testAppPath,
"targetModuleName": commonThirdPartyDep
cwd: testAppPath,
targetModuleName: commonThirdPartyDep
})
)
);

console.log("=== Linking in house dependencies ===");

execYarnLink({ "cwd": pathJoin(rootDirPath, "dist") });
execYarnLink({ cwd: pathJoin(rootDirPath, "dist") });

testAppPaths.forEach(testAppPath =>
execYarnLink({
"cwd": testAppPath,
"targetModuleName": JSON.parse(
cwd: testAppPath,
targetModuleName: JSON.parse(
fs.readFileSync(pathJoin(rootDirPath, "package.json")).toString("utf8")
)["name"]
})
Expand Down
28 changes: 14 additions & 14 deletions scripts/link-in-examples.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ fs.writeFileSync(

return {
...packageJsonParsed,
"main": packageJsonParsed["main"]?.replace(/^dist\//, ""),
"types": packageJsonParsed["types"]?.replace(/^dist\//, ""),
"module": packageJsonParsed["module"]?.replace(/^dist\//, ""),
"bin": !("bin" in packageJsonParsed)
main: packageJsonParsed["main"]?.replace(/^dist\//, ""),
types: packageJsonParsed["types"]?.replace(/^dist\//, ""),
module: packageJsonParsed["module"]?.replace(/^dist\//, ""),
bin: !("bin" in packageJsonParsed)
? undefined
: Object.fromEntries(
Object.entries(packageJsonParsed["bin"]).map(([key, value]) => [
key,
(value as string).replace(/^dist\//, "")
])
),
"exports": !("exports" in packageJsonParsed)
exports: !("exports" in packageJsonParsed)
? undefined
: Object.fromEntries(
Object.entries(packageJsonParsed["exports"]).map(([key, value]) => [
Expand Down Expand Up @@ -64,7 +64,7 @@ const commonThirdPartyDeps = (() => {

const yarnHomeDirPath = pathJoin(projectDirPath, ".yarn_home");

fs.rmSync(yarnHomeDirPath, { "recursive": true, "force": true });
fs.rmSync(yarnHomeDirPath, { recursive: true, force: true });

fs.mkdirSync(yarnHomeDirPath);

Expand All @@ -79,9 +79,9 @@ const execYarnLink = (params: { targetModuleName?: string; cwd: string }) => {

execSync(cmd, {
cwd,
"env": {
env: {
...process.env,
"HOME": yarnHomeDirPath
HOME: yarnHomeDirPath
}
});
};
Expand Down Expand Up @@ -125,24 +125,24 @@ commonThirdPartyDeps.forEach(commonThirdPartyDep => {
]
);

execYarnLink({ "cwd": localInstallPath });
execYarnLink({ cwd: localInstallPath });

testAppNames.forEach(testAppName =>
execYarnLink({
"cwd": getTestAppPath(testAppName),
"targetModuleName": commonThirdPartyDep
cwd: getTestAppPath(testAppName),
targetModuleName: commonThirdPartyDep
})
);
});

console.log("=== Linking in house dependencies ===");

execYarnLink({ "cwd": pathJoin(projectDirPath, "dist") });
execYarnLink({ cwd: pathJoin(projectDirPath, "dist") });

testAppNames.forEach(testAppName =>
execYarnLink({
"cwd": getTestAppPath(testAppName),
"targetModuleName": JSON.parse(
cwd: getTestAppPath(testAppName),
targetModuleName: JSON.parse(
fs.readFileSync(pathJoin(projectDirPath, "package.json")).toString("utf8")
)["name"]
})
Expand Down
Loading
Loading