@civic/auth 0.9.0 → 0.9.1-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/dist/lib/logger.d.ts +6 -0
- package/dist/lib/logger.d.ts.map +1 -1
- package/dist/lib/logger.js +7 -0
- package/dist/lib/logger.js.map +1 -1
- package/dist/nextjs/config.d.ts +2 -4
- package/dist/nextjs/config.d.ts.map +1 -1
- package/dist/nextjs/config.js +4 -57
- package/dist/nextjs/config.js.map +1 -1
- package/dist/react-router-7/components/UserButton.d.ts +13 -0
- package/dist/react-router-7/components/UserButton.d.ts.map +1 -0
- package/dist/react-router-7/components/UserButton.js +108 -0
- package/dist/react-router-7/components/UserButton.js.map +1 -0
- package/dist/react-router-7/components/UserButtonPresentation.d.ts +10 -0
- package/dist/react-router-7/components/UserButtonPresentation.d.ts.map +1 -0
- package/dist/react-router-7/components/UserButtonPresentation.js +19 -0
- package/dist/react-router-7/components/UserButtonPresentation.js.map +1 -0
- package/dist/react-router-7/config.d.ts +69 -0
- package/dist/react-router-7/config.d.ts.map +1 -0
- package/dist/react-router-7/config.js +88 -0
- package/dist/react-router-7/config.js.map +1 -0
- package/dist/react-router-7/cookies.d.ts +40 -0
- package/dist/react-router-7/cookies.d.ts.map +1 -0
- package/dist/react-router-7/cookies.js +125 -0
- package/dist/react-router-7/cookies.js.map +1 -0
- package/dist/react-router-7/index.d.ts +10 -0
- package/dist/react-router-7/index.d.ts.map +1 -0
- package/dist/react-router-7/index.js +12 -0
- package/dist/react-router-7/index.js.map +1 -0
- package/dist/react-router-7/routeHandler.d.ts +51 -0
- package/dist/react-router-7/routeHandler.d.ts.map +1 -0
- package/dist/react-router-7/routeHandler.js +323 -0
- package/dist/react-router-7/routeHandler.js.map +1 -0
- package/dist/react-router-7/useUser.d.ts +43 -0
- package/dist/react-router-7/useUser.d.ts.map +1 -0
- package/dist/react-router-7/useUser.js +92 -0
- package/dist/react-router-7/useUser.js.map +1 -0
- package/dist/reactjs/core/GlobalAuthManager.d.ts +2 -1
- package/dist/reactjs/core/GlobalAuthManager.d.ts.map +1 -1
- package/dist/reactjs/core/GlobalAuthManager.js +16 -2
- package/dist/reactjs/core/GlobalAuthManager.js.map +1 -1
- package/dist/server/ServerAuthenticationResolver.d.ts.map +1 -1
- package/dist/server/ServerAuthenticationResolver.js +4 -0
- package/dist/server/ServerAuthenticationResolver.js.map +1 -1
- package/dist/server/config.d.ts +11 -3
- package/dist/server/config.d.ts.map +1 -1
- package/dist/server/config.js.map +1 -1
- package/dist/server/login.d.ts.map +1 -1
- package/dist/server/login.js +5 -0
- package/dist/server/login.js.map +1 -1
- package/dist/server/logout.d.ts.map +1 -1
- package/dist/server/logout.js +5 -0
- package/dist/server/logout.js.map +1 -1
- package/dist/server/session.d.ts.map +1 -1
- package/dist/server/session.js +5 -0
- package/dist/server/session.js.map +1 -1
- package/dist/services/AuthenticationService.d.ts.map +1 -1
- package/dist/services/AuthenticationService.js +0 -5
- package/dist/services/AuthenticationService.js.map +1 -1
- package/dist/services/PKCE.d.ts.map +1 -1
- package/dist/services/PKCE.js +4 -1
- package/dist/services/PKCE.js.map +1 -1
- package/dist/shared/hooks/useCivicAuthConfig.d.ts +1 -1
- package/dist/shared/hooks/useCivicAuthConfig.d.ts.map +1 -1
- package/dist/shared/lib/AuthenticationRefresherImpl.d.ts.map +1 -1
- package/dist/shared/lib/AuthenticationRefresherImpl.js +4 -0
- package/dist/shared/lib/AuthenticationRefresherImpl.js.map +1 -1
- package/dist/shared/lib/cookieConfig.d.ts +46 -0
- package/dist/shared/lib/cookieConfig.d.ts.map +1 -0
- package/dist/shared/lib/cookieConfig.js +99 -0
- package/dist/shared/lib/cookieConfig.js.map +1 -0
- package/dist/shared/version.d.ts +1 -1
- package/dist/shared/version.d.ts.map +1 -1
- package/dist/shared/version.js +1 -1
- package/dist/shared/version.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/vanillajs/auth/CivicAuth.d.ts +1 -1
- package/dist/vanillajs/auth/CivicAuth.d.ts.map +1 -1
- package/dist/vanillajs/auth/CivicAuth.js +36 -9
- package/dist/vanillajs/auth/CivicAuth.js.map +1 -1
- package/dist/vanillajs/auth/config/ConfigProcessor.js +1 -1
- package/dist/vanillajs/auth/config/ConfigProcessor.js.map +1 -1
- package/dist/vanillajs/auth/handlers/MessageHandler.d.ts.map +1 -1
- package/dist/vanillajs/auth/handlers/MessageHandler.js +3 -0
- package/dist/vanillajs/auth/handlers/MessageHandler.js.map +1 -1
- package/dist/vanillajs/auth/types/AuthTypes.d.ts +31 -12
- package/dist/vanillajs/auth/types/AuthTypes.d.ts.map +1 -1
- package/dist/vanillajs/auth/types/AuthTypes.js.map +1 -1
- package/package.json +13 -1
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { MAX_COOKIE_AGE_SECONDS } from "../../constants.js";
|
|
2
|
+
import { CodeVerifier, OAuthTokenTypes, UserStorage, } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Creates a standardized cookie configuration for NextJS
|
|
5
|
+
*/
|
|
6
|
+
export function createCookieConfig(options = {}) {
|
|
7
|
+
const { secure = true, sameSite = "strict", defaultMaxAge = 60 * 60, // 1 hour
|
|
8
|
+
refreshTokenMaxAge = MAX_COOKIE_AGE_SECONDS, httpOnly = true, path = "/", } = options;
|
|
9
|
+
const baseCookieConfig = {
|
|
10
|
+
secure,
|
|
11
|
+
sameSite,
|
|
12
|
+
path,
|
|
13
|
+
maxAge: defaultMaxAge,
|
|
14
|
+
};
|
|
15
|
+
return {
|
|
16
|
+
tokens: {
|
|
17
|
+
[OAuthTokenTypes.ID_TOKEN]: {
|
|
18
|
+
...baseCookieConfig,
|
|
19
|
+
httpOnly,
|
|
20
|
+
},
|
|
21
|
+
[OAuthTokenTypes.ACCESS_TOKEN]: {
|
|
22
|
+
...baseCookieConfig,
|
|
23
|
+
httpOnly,
|
|
24
|
+
},
|
|
25
|
+
[OAuthTokenTypes.REFRESH_TOKEN]: {
|
|
26
|
+
...baseCookieConfig,
|
|
27
|
+
httpOnly,
|
|
28
|
+
maxAge: refreshTokenMaxAge,
|
|
29
|
+
},
|
|
30
|
+
[OAuthTokenTypes.OIDC_SESSION_EXPIRES_AT]: {
|
|
31
|
+
...baseCookieConfig,
|
|
32
|
+
httpOnly: false, // we need this to be available client-side
|
|
33
|
+
},
|
|
34
|
+
[CodeVerifier.COOKIE_NAME]: {
|
|
35
|
+
...baseCookieConfig,
|
|
36
|
+
httpOnly,
|
|
37
|
+
},
|
|
38
|
+
[CodeVerifier.APP_URL]: {
|
|
39
|
+
...baseCookieConfig,
|
|
40
|
+
httpOnly,
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
user: {
|
|
44
|
+
...baseCookieConfig,
|
|
45
|
+
httpOnly: false, // we need this to be available client-side
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Creates a standardized cookie configuration for React Router with UserStorage
|
|
51
|
+
*/
|
|
52
|
+
export function createReactRouterCookieConfigWithUserStorage(options = {}) {
|
|
53
|
+
const basicConfig = createCookieConfig(options);
|
|
54
|
+
const { secure = true, sameSite = "strict", defaultMaxAge = 60 * 60, // 1 hour
|
|
55
|
+
path = "/", } = options;
|
|
56
|
+
return {
|
|
57
|
+
...basicConfig,
|
|
58
|
+
tokens: {
|
|
59
|
+
...basicConfig.tokens,
|
|
60
|
+
[UserStorage.USER]: {
|
|
61
|
+
secure,
|
|
62
|
+
sameSite,
|
|
63
|
+
path,
|
|
64
|
+
maxAge: defaultMaxAge,
|
|
65
|
+
httpOnly: false, // we need this to be available client-side
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Creates cookie configuration optimized for NextJS
|
|
72
|
+
*/
|
|
73
|
+
export function createNextJSCookieConfig() {
|
|
74
|
+
const isProduction = process.env.NODE_ENV !== "development";
|
|
75
|
+
return createCookieConfig({
|
|
76
|
+
secure: isProduction,
|
|
77
|
+
sameSite: "strict",
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Creates cookie configuration optimized for React Router (iframe compatibility)
|
|
82
|
+
*/
|
|
83
|
+
export function createReactRouterCookieConfig() {
|
|
84
|
+
return createReactRouterCookieConfigWithUserStorage({
|
|
85
|
+
secure: true, // Required for iframe compatibility
|
|
86
|
+
sameSite: "none", // Required for cross-site iframe requests
|
|
87
|
+
refreshTokenMaxAge: 60 * 60 * 24 * 30, // 30 days for refresh token
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Creates cookie configuration for development environments
|
|
92
|
+
*/
|
|
93
|
+
export function createDevelopmentCookieConfig() {
|
|
94
|
+
return createCookieConfig({
|
|
95
|
+
secure: false,
|
|
96
|
+
sameSite: "lax",
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=cookieConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cookieConfig.js","sourceRoot":"","sources":["../../../src/shared/lib/cookieConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EACL,YAAY,EACZ,eAAe,EACf,WAAW,GAGZ,MAAM,YAAY,CAAC;AA6BpB;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAChC,UAA+B,EAAE;IAEjC,MAAM,EACJ,MAAM,GAAG,IAAI,EACb,QAAQ,GAAG,QAAQ,EACnB,aAAa,GAAG,EAAE,GAAG,EAAE,EAAE,SAAS;IAClC,kBAAkB,GAAG,sBAAsB,EAC3C,QAAQ,GAAG,IAAI,EACf,IAAI,GAAG,GAAG,GACX,GAAG,OAAO,CAAC;IAEZ,MAAM,gBAAgB,GAAiB;QACrC,MAAM;QACN,QAA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E,2CAA2C;aAC7D;SACF;KACF,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,wBAAwB;IACtC,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,CAAC;IAE5D,OAAO,kBAAkB,CAAC;QACxB,MAAM,EAAE,YAAY;QACpB,QAAQ,EAAE,QAAQ;KACnB,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,6BAA6B;IAC3C,OAAO,4CAA4C,CAAC;QAClD,MAAM,EAAE,IAAI,EAAE,oCAAoC;QAClD,QAAQ,EAAE,MAAM,EAAE,0CAA0C;QAC5D,kBAAkB,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,4BAA4B;KACpE,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,6BAA6B;IAC3C,OAAO,kBAAkB,CAAC;QACxB,MAAM,EAAE,KAAK;QACb,QAAQ,EAAE,KAAK;KAChB,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { MAX_COOKIE_AGE_SECONDS } from \"@/constants.js\";\nimport {\n CodeVerifier,\n OAuthTokenTypes,\n UserStorage,\n type CookieConfig,\n type TokensCookieConfig,\n} from \"./types.js\";\n\nexport interface CookieConfigOptions {\n /** Whether cookies should be secure (HTTPS only) */\n secure?: boolean;\n /** SameSite attribute for cookies */\n sameSite?: \"strict\" | \"lax\" | \"none\";\n /** Default max age in seconds for most cookies */\n defaultMaxAge?: number;\n /** Max age in seconds for refresh tokens */\n refreshTokenMaxAge?: number;\n /** Whether to use httpOnly for most cookies */\n httpOnly?: boolean;\n /** Path for cookies */\n path?: string;\n}\n\nexport interface CookiesConfigObject {\n tokens: TokensCookieConfig;\n user: CookieConfig;\n}\n\nexport interface ReactRouterCookiesConfigObject {\n tokens: TokensCookieConfig & {\n [UserStorage.USER]: CookieConfig;\n };\n user: CookieConfig;\n}\n\n/**\n * Creates a standardized cookie configuration for NextJS\n */\nexport function createCookieConfig(\n options: CookieConfigOptions = {},\n): CookiesConfigObject {\n const {\n secure = true,\n sameSite = \"strict\",\n defaultMaxAge = 60 * 60, // 1 hour\n refreshTokenMaxAge = MAX_COOKIE_AGE_SECONDS,\n httpOnly = true,\n path = \"/\",\n } = options;\n\n const baseCookieConfig: CookieConfig = {\n secure,\n sameSite,\n path,\n maxAge: defaultMaxAge,\n };\n\n return {\n tokens: {\n [OAuthTokenTypes.ID_TOKEN]: {\n ...baseCookieConfig,\n httpOnly,\n },\n [OAuthTokenTypes.ACCESS_TOKEN]: {\n ...baseCookieConfig,\n httpOnly,\n },\n [OAuthTokenTypes.REFRESH_TOKEN]: {\n ...baseCookieConfig,\n httpOnly,\n maxAge: refreshTokenMaxAge,\n },\n [OAuthTokenTypes.OIDC_SESSION_EXPIRES_AT]: {\n ...baseCookieConfig,\n httpOnly: false, // we need this to be available client-side\n },\n [CodeVerifier.COOKIE_NAME]: {\n ...baseCookieConfig,\n httpOnly,\n },\n [CodeVerifier.APP_URL]: {\n ...baseCookieConfig,\n httpOnly,\n },\n },\n user: {\n ...baseCookieConfig,\n httpOnly: false, // we need this to be available client-side\n },\n };\n}\n\n/**\n * Creates a standardized cookie configuration for React Router with UserStorage\n */\nexport function createReactRouterCookieConfigWithUserStorage(\n options: CookieConfigOptions = {},\n): ReactRouterCookiesConfigObject {\n const basicConfig = createCookieConfig(options);\n const {\n secure = true,\n sameSite = \"strict\",\n defaultMaxAge = 60 * 60, // 1 hour\n path = \"/\",\n } = options;\n\n return {\n ...basicConfig,\n tokens: {\n ...basicConfig.tokens,\n [UserStorage.USER]: {\n secure,\n sameSite,\n path,\n maxAge: defaultMaxAge,\n httpOnly: false, // we need this to be available client-side\n },\n },\n };\n}\n\n/**\n * Creates cookie configuration optimized for NextJS\n */\nexport function createNextJSCookieConfig(): CookiesConfigObject {\n const isProduction = process.env.NODE_ENV !== \"development\";\n\n return createCookieConfig({\n secure: isProduction,\n sameSite: \"strict\",\n });\n}\n\n/**\n * Creates cookie configuration optimized for React Router (iframe compatibility)\n */\nexport function createReactRouterCookieConfig(): ReactRouterCookiesConfigObject {\n return createReactRouterCookieConfigWithUserStorage({\n secure: true, // Required for iframe compatibility\n sameSite: \"none\", // Required for cross-site iframe requests\n refreshTokenMaxAge: 60 * 60 * 24 * 30, // 30 days for refresh token\n });\n}\n\n/**\n * Creates cookie configuration for development environments\n */\nexport function createDevelopmentCookieConfig(): CookiesConfigObject {\n return createCookieConfig({\n secure: false,\n sameSite: \"lax\",\n });\n}\n"]}
|
package/dist/shared/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "@civic/auth:0.9.0";
|
|
1
|
+
export declare const VERSION = "@civic/auth:0.9.1-alpha.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/shared/version.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/shared/version.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,OAAO,8BAA8B,CAAC"}
|
package/dist/shared/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/shared/version.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAE/C,MAAM,CAAC,MAAM,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/shared/version.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAE/C,MAAM,CAAC,MAAM,OAAO,GAAG,2BAA2B,CAAC","sourcesContent":["// This is an auto-generated file. Do not edit.\n\nexport const VERSION = \"@civic/auth:0.9.1-alpha.0\";\n"]}
|
package/dist/types.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export declare enum AuthStatus {
|
|
|
10
10
|
}
|
|
11
11
|
type DisplayMode = "iframe" | "redirect" | "new_tab" | "custom_tab";
|
|
12
12
|
type ColorMode = "light" | "dark" | "auto";
|
|
13
|
-
export type FrameworkType = "vanillajs" | "reactjs" | "nextjs" | "server";
|
|
13
|
+
export type FrameworkType = "vanillajs" | "reactjs" | "nextjs" | "server" | "react-router";
|
|
14
14
|
interface AuthSessionService {
|
|
15
15
|
loadAuthorizationUrl(authorizationURL: string, displayMode: DisplayMode): void;
|
|
16
16
|
getAuthorizationUrl(scopes: string[], overrideDisplayMode: DisplayMode, nonce?: string): Promise<string>;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAEvC,KAAK,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAC7C,KAAK,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAEzC,oBAAY,UAAU;IACpB,aAAa,kBAAkB;IAC/B,eAAe,oBAAoB;IACnC,cAAc,mBAAmB;IACjC,KAAK,UAAU;IACf,WAAW,gBAAgB;CAC5B;AAED,KAAK,WAAW,GAAG,QAAQ,GAAG,UAAU,GAAG,SAAS,GAAG,YAAY,CAAC;AAEpE,KAAK,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;AAG3C,MAAM,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAEvC,KAAK,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAC7C,KAAK,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAEzC,oBAAY,UAAU;IACpB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AG,OAAO,CAAC"}
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAKA,MAAM,CAAN,IAAY,UAMX;AAND,WAAY,UAAU;IACpB,6CAA+B,CAAA;IAC/B,iDAAmC,CAAA;IACnC,+CAAiC,CAAA;IACjC,6BAAe,CAAA;IACf,yCAA2B,CAAA;AAC7B,CAAC,EANW,UAAU,KAAV,UAAU,QAMrB;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAKA,MAAM,CAAN,IAAY,UAMX;AAND,WAAY,UAAU;IACpB,6CAA+B,CAAA;IAC/B,iDAAmC,CAAA;IACnC,+CAAiC,CAAA;IACjC,6BAAe,CAAA;IACf,yCAA2B,CAAA;AAC7B,CAAC,EANW,UAAU,KAAV,UAAU,QAMrB;AA+ID,MAAM,SAAS,GAAG;IAChB,KAAK;IACL,SAAS;IACT,aAAa;IACb,cAAc;IACd,iBAAiB;CACT,CAAC;AAsGX,OAAO,EAAE,SAAS,EAAE,CAAC","sourcesContent":["import type { JWTPayload } from \"jose\";\n\ntype UnknownObject = Record<string, unknown>;\ntype EmptyObject = Record<string, never>;\n\nexport enum AuthStatus {\n AUTHENTICATED = \"authenticated\",\n UNAUTHENTICATED = \"unauthenticated\",\n AUTHENTICATING = \"authenticating\",\n ERROR = \"error\",\n SIGNING_OUT = \"signing_out\",\n}\n// Display modes for the auth flow\ntype DisplayMode = \"iframe\" | \"redirect\" | \"new_tab\" | \"custom_tab\";\n\ntype ColorMode = \"light\" | \"dark\" | \"auto\";\n\n// Framework types for analytics\nexport type FrameworkType =\n | \"vanillajs\"\n | \"reactjs\"\n | \"nextjs\"\n | \"server\"\n | \"react-router\";\n\n// Combined Auth and Session Service\ninterface AuthSessionService {\n // TODO DK NOTES: Should be in BrowserAuthSessionService, not relevant on backend\n loadAuthorizationUrl(\n authorizationURL: string,\n displayMode: DisplayMode,\n ): void;\n // TODO DK NOTES: overrideDisplayMode parameter not appropriate here - also - do we need both this and the above in the interface?\n getAuthorizationUrl(\n scopes: string[],\n overrideDisplayMode: DisplayMode,\n nonce?: string,\n ): Promise<string>;\n // TODO DK NOTES: display mode should be in browser version only. Also, do we need this and the above two in the top-level interface?\n signIn(\n displayMode: DisplayMode,\n scopes: string[],\n nonce?: string,\n ): Promise<void>;\n // TODO DK NOTES: Input should be an auth code - do not assume it comes via an url\n tokenExchange(responseUrl: string): Promise<SessionData>;\n // TODO DK NOTES: Should be async for flexibility\n getSessionData(): SessionData;\n // TODO DK NOTES: Should be async for flexibility\n updateSessionData(data: SessionData): void;\n getUserInfoService(): Promise<UserInfoService>;\n}\n\n// Token Service\ninterface TokenService {\n exchangeCodeForTokens(authCode: string): Promise<Tokens>;\n validateIdToken(idToken: string, nonce: string): boolean;\n refreshAccessToken(refreshToken: string): Promise<Tokens>;\n}\n\n// User Info Service\ninterface UserInfoService {\n getUserInfo<T extends UnknownObject>(\n accessToken: string,\n idToken: string | null,\n ): Promise<User<T> | null>;\n}\n\n// Resource Service\ninterface ResourceService {\n getProtectedResource(accessToken: string): Promise<unknown>;\n}\n\n// Auth Request (for internal use in AuthSessionService)\ntype AuthRequest = {\n clientId: string;\n redirectUri: string;\n state: string;\n nonce: string;\n scope: string;\n};\n\ntype Endpoints = {\n jwks: string;\n auth: string;\n token: string;\n userinfo: string;\n challenge?: string;\n endsession: string;\n};\n\ntype Config = {\n oauthServer: string;\n endpoints?: Endpoints;\n};\n\ntype SessionData = {\n authenticated: boolean; // TODO can this be inferred from the presence of the tokens?\n state?: string;\n accessToken?: string;\n refreshToken?: string;\n idToken?: string;\n oidcSessionExpiresAt?: number;\n codeVerifier?: string;\n displayMode?: DisplayMode;\n openerUrl?: string;\n};\n\ntype OIDCTokenResponseBody = {\n id_token: string;\n access_token?: string; // Access token is now optional\n oidc_session_expires_at?: number;\n refresh_token?: string;\n expires_in?: number;\n token_type?: string;\n scope?: string;\n};\n\ntype ParsedTokens = {\n id_token: JWTPayload;\n access_token?: JWTPayload;\n refresh_token?: string;\n};\n\n// The format we expose to the frontend via hooks\ntype ForwardedTokens = Record<\n string,\n {\n idToken?: string;\n accessToken?: string;\n refreshToken?: string;\n }\n>;\n\n// The format in the JWT payload\ntype ForwardedTokensJWT = Record<\n string,\n {\n id_token?: string;\n access_token?: string;\n refresh_token?: string;\n scope?: string;\n }\n>;\n\ntype IdTokenPayload = JWTPayload & {\n forwardedTokens?: ForwardedTokensJWT;\n email?: string;\n name?: string;\n picture?: string;\n nonce: string;\n at_hash: string;\n};\n\nconst tokenKeys = [\n \"sub\",\n \"idToken\",\n \"accessToken\",\n \"refreshToken\",\n \"forwardedTokens\",\n] as const;\n\nexport type OAuthTokens = {\n idToken?: string;\n accessToken?: string;\n refreshToken?: string;\n};\n// Derive the Tokens type from the array\ntype Tokens = {\n [K in (typeof tokenKeys)[number]]: K extends \"forwardedTokens\"\n ? ForwardedTokens\n : string;\n};\n\n// Base user interface\ntype BaseUser = {\n id: string;\n email?: string;\n username?: string;\n name?: string;\n given_name?: string;\n family_name?: string;\n picture?: string;\n updated_at?: Date;\n};\n\ntype User<T extends UnknownObject | EmptyObject = EmptyObject> =\n T extends EmptyObject ? BaseUser : BaseUser & T;\n\ntype OpenIdConfiguration = {\n authorization_endpoint: string;\n claims_parameter_supported: boolean;\n claims_supported: string[];\n code_challenge_methods_supported: string[];\n end_session_endpoint: string;\n grant_types_supported: string[];\n issuer: string;\n jwks_uri: string;\n authorization_response_iss_parameter_supported: boolean;\n response_modes_supported: string[];\n response_types_supported: string[];\n scopes_supported: string[];\n subject_types_supported: string[];\n token_endpoint_auth_methods_supported: string[];\n token_endpoint_auth_signing_alg_values_supported: string[];\n token_endpoint: string;\n id_token_signing_alg_values_supported: string[];\n pushed_authorization_request_endpoint: string;\n request_parameter_supported: boolean;\n request_uri_parameter_supported: boolean;\n userinfo_endpoint: string;\n claim_types_supported: string[];\n};\n\ntype LoginPostMessage = {\n source: string;\n type: string;\n clientId: string;\n data:\n | {\n url: string;\n }\n | LoginAppDesignOptions;\n};\n\nexport type IframeAuthMessage = {\n source: \"civicloginApp\";\n type: \"auth_error\" | \"auth_error_try_again\";\n clientId: string;\n data: {\n url?: string;\n error?: string;\n };\n};\n\nexport type LoginAppDesignOptions = {\n colorMode: ColorMode;\n};\nexport type {\n LoginPostMessage,\n AuthSessionService,\n TokenService,\n UserInfoService,\n ResourceService,\n AuthRequest,\n Tokens,\n Endpoints,\n Config,\n SessionData,\n OIDCTokenResponseBody,\n ParsedTokens,\n BaseUser,\n User,\n DisplayMode,\n UnknownObject,\n EmptyObject,\n ForwardedTokens,\n ForwardedTokensJWT,\n IdTokenPayload,\n OpenIdConfiguration,\n ColorMode,\n};\nexport { tokenKeys };\nexport interface AuthStorage {\n get(key: string): Promise<string | null>;\n set(key: string, value: string): Promise<void>;\n delete(key: string): Promise<void>;\n}\n\nexport type IframeMode = \"embedded\" | \"modal\";\n"]}
|
|
@@ -162,7 +162,7 @@ export declare class CivicAuth {
|
|
|
162
162
|
* Get current session tokens including decoded forwarded tokens
|
|
163
163
|
* This method extracts and decodes forwarded tokens from the ID token JWT
|
|
164
164
|
*/
|
|
165
|
-
getTokensWithForwardedTokens(): Promise<import("../
|
|
165
|
+
getTokensWithForwardedTokens(): Promise<import("../index.js").ExtractedTokens>;
|
|
166
166
|
/**
|
|
167
167
|
* Check if user is authenticated
|
|
168
168
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CivicAuth.d.ts","sourceRoot":"","sources":["../../../src/vanillajs/auth/CivicAuth.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"CivicAuth.d.ts","sourceRoot":"","sources":["../../../src/vanillajs/auth/CivicAuth.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,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AAC;IA2GpC;;;OAGG;YACW,wBAAwB;CAsEvC;AAGD,YAAY,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -135,15 +135,24 @@ export class CivicAuth {
|
|
|
135
135
|
});
|
|
136
136
|
// Initialize SessionManager with auth config
|
|
137
137
|
if (this.sessionManager) {
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
138
|
+
const loginUrl = this.config.loginUrl || this.loginUrl;
|
|
139
|
+
// Construct authConfig based on our discriminated union pattern
|
|
140
|
+
const authConfig = loginUrl && !this.config.clientId
|
|
141
|
+
? {
|
|
142
|
+
// Backend integration mode: loginUrl required, clientId optional
|
|
143
|
+
loginUrl,
|
|
144
|
+
redirectUrl: this.config.redirectUrl,
|
|
145
|
+
oauthServer: this.config.oauthServerBaseUrl,
|
|
146
|
+
backendEndpoints: this.config.backendEndpoints,
|
|
147
|
+
}
|
|
148
|
+
: {
|
|
149
|
+
// Standard OAuth mode: clientId required, loginUrl optional
|
|
150
|
+
clientId: this.config.clientId,
|
|
151
|
+
loginUrl,
|
|
152
|
+
redirectUrl: this.config.redirectUrl,
|
|
153
|
+
oauthServer: this.config.oauthServerBaseUrl,
|
|
154
|
+
backendEndpoints: this.config.backendEndpoints,
|
|
155
|
+
};
|
|
147
156
|
this.logger.info("🔧 Initializing SessionManager", { authConfig });
|
|
148
157
|
await this.sessionManager.initializeWithAuthConfig(authConfig);
|
|
149
158
|
}
|
|
@@ -303,6 +312,10 @@ export class CivicAuth {
|
|
|
303
312
|
if (!this.endpoints) {
|
|
304
313
|
throw new CivicAuthError("OAuth endpoints not initialized. Please wait for initialization to complete.", CivicAuthErrorCode.ENDPOINTS_NOT_INITIALIZED);
|
|
305
314
|
}
|
|
315
|
+
// Ensure clientId is present for OAuth flow (it should be according to our discriminated union)
|
|
316
|
+
if (!this.config.clientId) {
|
|
317
|
+
throw new CivicAuthError("ClientId is required for OAuth flow when loginUrl is not provided.", CivicAuthErrorCode.CONFIG_REQUIRED);
|
|
318
|
+
}
|
|
306
319
|
const pkceProducer = new GenericPublicClientPKCEProducer(this.storage);
|
|
307
320
|
const codeChallenge = await pkceProducer.getCodeChallenge();
|
|
308
321
|
const state = this.config.initialState ||
|
|
@@ -470,6 +483,7 @@ export class CivicAuth {
|
|
|
470
483
|
if (!this.iframeAuthHandler || !this.messageHandler) {
|
|
471
484
|
throw new Error("Iframe handler not initialized");
|
|
472
485
|
}
|
|
486
|
+
this.config.displayMode = "redirect";
|
|
473
487
|
this.iframeAuthHandler.forceHideIframe();
|
|
474
488
|
const rebuiltUrl = await this.buildAuthUrl();
|
|
475
489
|
this.config.events?.emit(AuthEvent.SIGN_IN_ERROR, {
|
|
@@ -713,6 +727,15 @@ export class CivicAuth {
|
|
|
713
727
|
redirectUrl: this.config.redirectUrl,
|
|
714
728
|
});
|
|
715
729
|
try {
|
|
730
|
+
// Only handle OAuth callback if not using backend integration
|
|
731
|
+
if (!this.config.clientId && this.config.loginUrl) {
|
|
732
|
+
this.logger.info("📞 Backend integration mode - skipping OAuth callback handling");
|
|
733
|
+
return;
|
|
734
|
+
}
|
|
735
|
+
// Ensure clientId is available for OAuth callback
|
|
736
|
+
if (!this.config.clientId) {
|
|
737
|
+
throw new Error("ClientId is required for OAuth callback handling");
|
|
738
|
+
}
|
|
716
739
|
const callbackHandled = await handleOAuthRedirectPage({
|
|
717
740
|
clientId: this.config.clientId,
|
|
718
741
|
oauthServer: this.config.oauthServerBaseUrl,
|
|
@@ -959,6 +982,10 @@ export class CivicAuth {
|
|
|
959
982
|
// Store logout state for cleanup after redirect
|
|
960
983
|
// This matches the React implementation - only store state for redirect flow
|
|
961
984
|
await this.storage.set(LOGOUT_STATE, state);
|
|
985
|
+
// Ensure clientId is available for OAuth logout
|
|
986
|
+
if (!this.config.clientId) {
|
|
987
|
+
throw new Error("ClientId is required for OAuth logout flow");
|
|
988
|
+
}
|
|
962
989
|
// Generate logout URL
|
|
963
990
|
const logoutUrl = await generateOauthLogoutUrl({
|
|
964
991
|
clientId: this.config.clientId,
|