@civic/auth
Advanced tools
Comparing version 0.1.5-beta.3 to 0.1.5
@@ -8,3 +8,4 @@ import type { Endpoints } from "../types.ts"; | ||
endpointOverrides?: Partial<Endpoints> | undefined; | ||
postLogoutRedirectUrl?: string; | ||
}; | ||
//# sourceMappingURL=config.d.ts.map |
export { CookieStorage } from "../shared/lib/storage.js"; | ||
export type { SessionStorage, CookieStorageSettings, } from "../shared/lib/storage.js"; | ||
export { resolveOAuthAccessCode, isLoggedIn, buildLoginUrl, } from "../server/login.js"; | ||
export { resolveOAuthAccessCode, isLoggedIn, buildLoginUrl, buildLogoutRedirectUrl, } from "../server/login.js"; | ||
export type { AuthConfig } from "../server/config.js"; | ||
@@ -5,0 +5,0 @@ export { getUser } from "../shared/lib/session.js"; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.refreshTokens = exports.getUser = exports.buildLoginUrl = exports.isLoggedIn = exports.resolveOAuthAccessCode = exports.CookieStorage = void 0; | ||
exports.refreshTokens = exports.getUser = exports.buildLogoutRedirectUrl = exports.buildLoginUrl = exports.isLoggedIn = exports.resolveOAuthAccessCode = exports.CookieStorage = void 0; | ||
const index_js_1 = require("../shared/index.js"); | ||
@@ -12,2 +12,3 @@ console.log((0, index_js_1.printVersion)()); | ||
Object.defineProperty(exports, "buildLoginUrl", { enumerable: true, get: function () { return login_js_1.buildLoginUrl; } }); | ||
Object.defineProperty(exports, "buildLogoutRedirectUrl", { enumerable: true, get: function () { return login_js_1.buildLogoutRedirectUrl; } }); | ||
var session_js_1 = require("../shared/lib/session.js"); | ||
@@ -14,0 +15,0 @@ Object.defineProperty(exports, "getUser", { enumerable: true, get: function () { return session_js_1.getUser; } }); |
@@ -17,2 +17,6 @@ import type { AuthStorage, OIDCTokenResponseBody } from "../types.js"; | ||
}, storage: AuthStorage): Promise<URL>; | ||
export declare function buildLogoutRedirectUrl(config: Pick<AuthConfig, "clientId" | "postLogoutRedirectUrl"> & Partial<Pick<AuthConfig, "oauthServer">> & { | ||
scopes?: string[]; | ||
state?: string; | ||
}, storage: AuthStorage): Promise<URL>; | ||
//# sourceMappingURL=login.d.ts.map |
@@ -6,2 +6,3 @@ "use strict"; | ||
exports.buildLoginUrl = buildLoginUrl; | ||
exports.buildLogoutRedirectUrl = buildLogoutRedirectUrl; | ||
const constants_js_1 = require("../constants.js"); | ||
@@ -11,2 +12,3 @@ const AuthenticationService_js_1 = require("../services/AuthenticationService.js"); | ||
const ServerAuthenticationResolver_js_1 = require("../server/ServerAuthenticationResolver.js"); | ||
const types_js_1 = require("../shared/lib/types.js"); | ||
/** | ||
@@ -44,2 +46,20 @@ * Resolve an OAuth access code to a set of OIDC tokens | ||
} | ||
async function buildLogoutRedirectUrl(config, storage) { | ||
// generate a random state if not provided | ||
const state = config.state ?? Math.random().toString(36).substring(2); | ||
const scopes = config.scopes ?? constants_js_1.DEFAULT_SCOPES; | ||
const pkceProducer = new PKCE_js_1.GenericPublicClientPKCEProducer(storage); | ||
const authInitiator = new AuthenticationService_js_1.GenericAuthenticationInitiator({ | ||
...config, | ||
state, | ||
scopes, | ||
oauthServer: config.oauthServer ?? constants_js_1.DEFAULT_AUTH_SERVER, | ||
pkceConsumer: pkceProducer, | ||
redirectUrl: config.postLogoutRedirectUrl || "/", | ||
}); | ||
const idToken = await storage.get(types_js_1.OAuthTokens.ID_TOKEN); | ||
if (!idToken) | ||
throw new Error("No id_token found in storage"); | ||
return authInitiator.signOut(idToken); | ||
} | ||
//# sourceMappingURL=login.js.map |
@@ -1,2 +0,2 @@ | ||
export declare const VERSION = "@civic/auth:0.1.5-beta.3"; | ||
export declare const VERSION = "@civic/auth:0.1.5"; | ||
//# sourceMappingURL=version.d.ts.map |
@@ -5,3 +5,3 @@ "use strict"; | ||
exports.VERSION = void 0; | ||
exports.VERSION = "@civic/auth:0.1.5-beta.3"; | ||
exports.VERSION = "@civic/auth:0.1.5"; | ||
//# sourceMappingURL=version.js.map |
@@ -8,3 +8,4 @@ import type { Endpoints } from "../types.ts"; | ||
endpointOverrides?: Partial<Endpoints> | undefined; | ||
postLogoutRedirectUrl?: string; | ||
}; | ||
//# sourceMappingURL=config.d.ts.map |
export { CookieStorage } from "../shared/lib/storage.js"; | ||
export type { SessionStorage, CookieStorageSettings, } from "../shared/lib/storage.js"; | ||
export { resolveOAuthAccessCode, isLoggedIn, buildLoginUrl, } from "../server/login.js"; | ||
export { resolveOAuthAccessCode, isLoggedIn, buildLoginUrl, buildLogoutRedirectUrl, } from "../server/login.js"; | ||
export type { AuthConfig } from "../server/config.js"; | ||
@@ -5,0 +5,0 @@ export { getUser } from "../shared/lib/session.js"; |
import { printVersion } from "../shared/index.js"; | ||
console.log(printVersion()); | ||
export { CookieStorage } from "../shared/lib/storage.js"; | ||
export { resolveOAuthAccessCode, isLoggedIn, buildLoginUrl, } from "../server/login.js"; | ||
export { resolveOAuthAccessCode, isLoggedIn, buildLoginUrl, buildLogoutRedirectUrl, } from "../server/login.js"; | ||
export { getUser } from "../shared/lib/session.js"; | ||
export { refreshTokens } from "../server/refresh.js"; | ||
//# sourceMappingURL=index.js.map |
@@ -17,2 +17,6 @@ import type { AuthStorage, OIDCTokenResponseBody } from "../types.js"; | ||
}, storage: AuthStorage): Promise<URL>; | ||
export declare function buildLogoutRedirectUrl(config: Pick<AuthConfig, "clientId" | "postLogoutRedirectUrl"> & Partial<Pick<AuthConfig, "oauthServer">> & { | ||
scopes?: string[]; | ||
state?: string; | ||
}, storage: AuthStorage): Promise<URL>; | ||
//# sourceMappingURL=login.d.ts.map |
@@ -5,2 +5,3 @@ import { DEFAULT_AUTH_SERVER, DEFAULT_SCOPES } from "../constants.js"; | ||
import { ServerAuthenticationResolver } from "../server/ServerAuthenticationResolver.js"; | ||
import { OAuthTokens } from "../shared/lib/types.js"; | ||
/** | ||
@@ -38,2 +39,20 @@ * Resolve an OAuth access code to a set of OIDC tokens | ||
} | ||
export async function buildLogoutRedirectUrl(config, storage) { | ||
// generate a random state if not provided | ||
const state = config.state ?? Math.random().toString(36).substring(2); | ||
const scopes = config.scopes ?? DEFAULT_SCOPES; | ||
const pkceProducer = new GenericPublicClientPKCEProducer(storage); | ||
const authInitiator = new GenericAuthenticationInitiator({ | ||
...config, | ||
state, | ||
scopes, | ||
oauthServer: config.oauthServer ?? DEFAULT_AUTH_SERVER, | ||
pkceConsumer: pkceProducer, | ||
redirectUrl: config.postLogoutRedirectUrl || "/", | ||
}); | ||
const idToken = await storage.get(OAuthTokens.ID_TOKEN); | ||
if (!idToken) | ||
throw new Error("No id_token found in storage"); | ||
return authInitiator.signOut(idToken); | ||
} | ||
//# sourceMappingURL=login.js.map |
@@ -1,2 +0,2 @@ | ||
export declare const VERSION = "@civic/auth:0.1.5-beta.3"; | ||
export declare const VERSION = "@civic/auth:0.1.5"; | ||
//# sourceMappingURL=version.d.ts.map |
// This is an auto-generated file. Do not edit. | ||
export const VERSION = "@civic/auth:0.1.5-beta.3"; | ||
export const VERSION = "@civic/auth:0.1.5"; | ||
//# sourceMappingURL=version.js.map |
{ | ||
"name": "@civic/auth", | ||
"version": "0.1.5-beta.3", | ||
"version": "0.1.5", | ||
"type": "module", | ||
@@ -65,2 +65,16 @@ "main": "./dist/cjs/index.js", | ||
}, | ||
"scripts": { | ||
"prebuild": "rm -rf dist && pnpm generate-version", | ||
"build": "pnpm build:cjs && pnpm build:esm", | ||
"build:cjs": "tsc -p tsconfig.cjs.json --noEmit false && tsc-alias -p tsconfig.cjs.json", | ||
"build:esm": "tsc -p tsconfig.esm.json --noEmit false && tsc-alias -p tsconfig.esm.json", | ||
"prepublishOnly": "pnpm generate-version && node ../../etc/scripts/prompt-changelog.js && pnpm build", | ||
"dev": "tsc --watch", | ||
"pretest": "pnpm generate-version", | ||
"test": "vitest", | ||
"lint": "eslint \"src/**/*.ts*\" --max-warnings 0", | ||
"lint:fix": "pnpm lint --fix", | ||
"test:update": "vitest --update", | ||
"generate-version": "npx tsx ./generateVersion.ts" | ||
}, | ||
"dependencies": { | ||
@@ -75,2 +89,4 @@ "debug": "^4.3.7", | ||
"devDependencies": { | ||
"@repo/eslint-config": "workspace:*", | ||
"@repo/typescript-config": "workspace:*", | ||
"@rollup/plugin-typescript": "^12.1.1", | ||
@@ -99,22 +115,7 @@ "@testing-library/jest-dom": "^6.5.0", | ||
"vite-plugin-dts": "^4.2.3", | ||
"vitest": "^2.1.8", | ||
"@repo/typescript-config": "0.0.0", | ||
"@repo/eslint-config": "0.0.0" | ||
"vitest": "^2.1.8" | ||
}, | ||
"optionalDependency": { | ||
"next": "^14" | ||
}, | ||
"scripts": { | ||
"prebuild": "rm -rf dist && pnpm generate-version", | ||
"build": "pnpm build:cjs && pnpm build:esm", | ||
"build:cjs": "tsc -p tsconfig.cjs.json --noEmit false && tsc-alias -p tsconfig.cjs.json", | ||
"build:esm": "tsc -p tsconfig.esm.json --noEmit false && tsc-alias -p tsconfig.esm.json", | ||
"dev": "tsc --watch", | ||
"pretest": "pnpm generate-version", | ||
"test": "vitest", | ||
"lint": "eslint \"src/**/*.ts*\" --max-warnings 0", | ||
"lint:fix": "pnpm lint --fix", | ||
"test:update": "vitest --update", | ||
"generate-version": "npx tsx ./generateVersion.ts" | ||
} | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1363892
10245