@civic/auth 0.6.1-beta.1 → 0.6.1-beta.3

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.
Files changed (85) hide show
  1. package/dist/nextjs/config.d.ts.map +1 -1
  2. package/dist/nextjs/config.js +3 -1
  3. package/dist/nextjs/config.js.map +1 -1
  4. package/dist/nextjs/hooks/useUserCookie.d.ts.map +1 -1
  5. package/dist/nextjs/hooks/useUserCookie.js.map +1 -1
  6. package/dist/nextjs/providers/NextAuthProvider.d.ts.map +1 -1
  7. package/dist/nextjs/providers/NextAuthProvider.js +1 -0
  8. package/dist/nextjs/providers/NextAuthProvider.js.map +1 -1
  9. package/dist/shared/hooks/useSignIn.d.ts +9 -4
  10. package/dist/shared/hooks/useSignIn.d.ts.map +1 -1
  11. package/dist/shared/hooks/useSignIn.js +75 -42
  12. package/dist/shared/hooks/useSignIn.js.map +1 -1
  13. package/dist/shared/providers/AuthContext.d.ts +7 -2
  14. package/dist/shared/providers/AuthContext.d.ts.map +1 -1
  15. package/dist/shared/providers/AuthContext.js.map +1 -1
  16. package/dist/shared/providers/UserProvider.d.ts +5 -1
  17. package/dist/shared/providers/UserProvider.d.ts.map +1 -1
  18. package/dist/shared/providers/UserProvider.js.map +1 -1
  19. package/dist/shared/version.d.ts +1 -1
  20. package/dist/shared/version.js +1 -1
  21. package/dist/shared/version.js.map +1 -1
  22. package/dist/vanillajs/auth/AuthenticationEvents.d.ts.map +1 -1
  23. package/dist/vanillajs/auth/AuthenticationEvents.js +2 -2
  24. package/dist/vanillajs/auth/AuthenticationEvents.js.map +1 -1
  25. package/dist/vanillajs/auth/CivicAuth.d.ts +68 -107
  26. package/dist/vanillajs/auth/CivicAuth.d.ts.map +1 -1
  27. package/dist/vanillajs/auth/CivicAuth.js +389 -412
  28. package/dist/vanillajs/auth/CivicAuth.js.map +1 -1
  29. package/dist/vanillajs/auth/SessionManager.d.ts.map +1 -1
  30. package/dist/vanillajs/auth/SessionManager.js +2 -2
  31. package/dist/vanillajs/auth/SessionManager.js.map +1 -1
  32. package/dist/vanillajs/auth/TokenRefresher.d.ts.map +1 -1
  33. package/dist/vanillajs/auth/TokenRefresher.js +2 -2
  34. package/dist/vanillajs/auth/TokenRefresher.js.map +1 -1
  35. package/dist/vanillajs/auth/config/ConfigProcessor.d.ts +6 -0
  36. package/dist/vanillajs/auth/config/ConfigProcessor.d.ts.map +1 -0
  37. package/dist/vanillajs/auth/config/ConfigProcessor.js +59 -0
  38. package/dist/vanillajs/auth/config/ConfigProcessor.js.map +1 -0
  39. package/dist/vanillajs/auth/handlers/IframeAuthHandler.d.ts +40 -0
  40. package/dist/vanillajs/auth/handlers/IframeAuthHandler.d.ts.map +1 -0
  41. package/dist/vanillajs/auth/handlers/IframeAuthHandler.js +388 -0
  42. package/dist/vanillajs/auth/handlers/IframeAuthHandler.js.map +1 -0
  43. package/dist/vanillajs/auth/handlers/MessageHandler.d.ts +170 -0
  44. package/dist/vanillajs/auth/handlers/MessageHandler.d.ts.map +1 -0
  45. package/dist/vanillajs/auth/handlers/MessageHandler.js +367 -0
  46. package/dist/vanillajs/auth/handlers/MessageHandler.js.map +1 -0
  47. package/dist/vanillajs/auth/{OAuthCallbackHandler.d.ts → handlers/OAuthCallbackHandler.d.ts} +2 -2
  48. package/dist/vanillajs/auth/handlers/OAuthCallbackHandler.d.ts.map +1 -0
  49. package/dist/vanillajs/auth/handlers/OAuthCallbackHandler.js +301 -0
  50. package/dist/vanillajs/auth/handlers/OAuthCallbackHandler.js.map +1 -0
  51. package/dist/vanillajs/auth/handlers/PopupHandler.d.ts +108 -0
  52. package/dist/vanillajs/auth/handlers/PopupHandler.d.ts.map +1 -0
  53. package/dist/vanillajs/auth/handlers/PopupHandler.js +333 -0
  54. package/dist/vanillajs/auth/handlers/PopupHandler.js.map +1 -0
  55. package/dist/vanillajs/auth/types/AuthTypes.d.ts +128 -0
  56. package/dist/vanillajs/auth/types/AuthTypes.d.ts.map +1 -0
  57. package/dist/vanillajs/auth/types/AuthTypes.js +40 -0
  58. package/dist/vanillajs/auth/types/AuthTypes.js.map +1 -0
  59. package/dist/vanillajs/iframe/IframeManager.d.ts +33 -0
  60. package/dist/vanillajs/iframe/IframeManager.d.ts.map +1 -1
  61. package/dist/vanillajs/iframe/IframeManager.js +163 -36
  62. package/dist/vanillajs/iframe/IframeManager.js.map +1 -1
  63. package/dist/vanillajs/index.d.ts +2 -2
  64. package/dist/vanillajs/index.d.ts.map +1 -1
  65. package/dist/vanillajs/index.js +2 -2
  66. package/dist/vanillajs/index.js.map +1 -1
  67. package/dist/vanillajs/services/ApiService.d.ts.map +1 -1
  68. package/dist/vanillajs/services/ApiService.js +2 -2
  69. package/dist/vanillajs/services/ApiService.js.map +1 -1
  70. package/dist/vanillajs/types/index.d.ts +15 -10
  71. package/dist/vanillajs/types/index.d.ts.map +1 -1
  72. package/dist/vanillajs/types/index.js +15 -10
  73. package/dist/vanillajs/types/index.js.map +1 -1
  74. package/dist/vanillajs/utils/auth-utils.d.ts +2 -1
  75. package/dist/vanillajs/utils/auth-utils.d.ts.map +1 -1
  76. package/dist/vanillajs/utils/auth-utils.js +6 -3
  77. package/dist/vanillajs/utils/auth-utils.js.map +1 -1
  78. package/dist/vanillajs/utils/logger.d.ts +16 -15
  79. package/dist/vanillajs/utils/logger.d.ts.map +1 -1
  80. package/dist/vanillajs/utils/logger.js +35 -19
  81. package/dist/vanillajs/utils/logger.js.map +1 -1
  82. package/package.json +6 -1
  83. package/dist/vanillajs/auth/OAuthCallbackHandler.d.ts.map +0 -1
  84. package/dist/vanillajs/auth/OAuthCallbackHandler.js +0 -143
  85. package/dist/vanillajs/auth/OAuthCallbackHandler.js.map +0 -1
@@ -1,14 +1,19 @@
1
1
  export var AuthEvent;
2
2
  (function (AuthEvent) {
3
- AuthEvent["SIGN_IN_STARTED"] = "signInStarted";
4
- AuthEvent["SIGN_IN_COMPLETE"] = "signInComplete";
5
- AuthEvent["SIGN_IN_ERROR"] = "signInError";
6
- AuthEvent["SIGN_OUT_STARTED"] = "signOutStarted";
7
- AuthEvent["SIGN_OUT_COMPLETE"] = "signOutComplete";
8
- AuthEvent["SIGN_OUT_ERROR"] = "signOutError";
9
- AuthEvent["TOKEN_REFRESH_STARTED"] = "tokenRefreshStarted";
10
- AuthEvent["TOKEN_REFRESH_COMPLETE"] = "tokenRefreshComplete";
11
- AuthEvent["TOKEN_REFRESH_ERROR"] = "tokenRefreshError";
12
- AuthEvent["USER_SESSION_CHANGED"] = "userSessionChanged";
3
+ AuthEvent["INITIALIZED"] = "initialized";
4
+ AuthEvent["SIGN_IN_STARTED"] = "sign_in_started";
5
+ AuthEvent["SIGN_IN_COMPLETE"] = "sign_in_complete";
6
+ AuthEvent["SIGN_IN_ERROR"] = "sign_in_error";
7
+ AuthEvent["SIGN_OUT_STARTED"] = "sign_out_started";
8
+ AuthEvent["SIGN_OUT_COMPLETE"] = "sign_out_complete";
9
+ AuthEvent["SIGN_OUT_ERROR"] = "sign_out_error";
10
+ AuthEvent["TOKEN_REFRESH_STARTED"] = "token_refresh_started";
11
+ AuthEvent["TOKEN_REFRESH_COMPLETE"] = "token_refresh_complete";
12
+ AuthEvent["TOKEN_REFRESH_ERROR"] = "token_refresh_error";
13
+ AuthEvent["SESSION_EXPIRED"] = "session_expired";
14
+ AuthEvent["SESSION_RENEWED"] = "session_renewed";
15
+ AuthEvent["USER_INTERACTION_REQUIRED"] = "user_interaction_required";
16
+ AuthEvent["POPUP_REDIRECT_FALLBACK"] = "popup_redirect_fallback";
17
+ AuthEvent["USER_SESSION_CHANGED"] = "user_session_changed";
13
18
  })(AuthEvent || (AuthEvent = {}));
14
19
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/vanillajs/types/index.ts"],"names":[],"mappings":"AAcA,MAAM,CAAN,IAAY,SAWX;AAXD,WAAY,SAAS;IACnB,8CAAiC,CAAA;IACjC,gDAAmC,CAAA;IACnC,0CAA6B,CAAA;IAC7B,gDAAmC,CAAA;IACnC,kDAAqC,CAAA;IACrC,4CAA+B,CAAA;IAC/B,0DAA6C,CAAA;IAC7C,4DAA+C,CAAA;IAC/C,sDAAyC,CAAA;IACzC,wDAA2C,CAAA;AAC7C,CAAC,EAXW,SAAS,KAAT,SAAS,QAWpB","sourcesContent":["// Export other type files as they are created\nimport type { User } from \"../../types.js\";\n\nexport type { User };\n\nexport interface Session {\n accessToken?: string;\n idToken: string;\n refreshToken?: string;\n user?: User;\n expiresAt?: number; // Timestamp in milliseconds\n // any other session-related data\n}\n\nexport enum AuthEvent {\n SIGN_IN_STARTED = \"signInStarted\",\n SIGN_IN_COMPLETE = \"signInComplete\",\n SIGN_IN_ERROR = \"signInError\",\n SIGN_OUT_STARTED = \"signOutStarted\",\n SIGN_OUT_COMPLETE = \"signOutComplete\",\n SIGN_OUT_ERROR = \"signOutError\",\n TOKEN_REFRESH_STARTED = \"tokenRefreshStarted\",\n TOKEN_REFRESH_COMPLETE = \"tokenRefreshComplete\",\n TOKEN_REFRESH_ERROR = \"tokenRefreshError\",\n USER_SESSION_CHANGED = \"userSessionChanged\",\n}\n\nexport interface AuthResult {\n /** User information returned from authentication */\n user?: User;\n /** Signal text indicating the result */\n signalText?: string;\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/vanillajs/types/index.ts"],"names":[],"mappings":"AAcA,MAAM,CAAN,IAAY,SAgBX;AAhBD,WAAY,SAAS;IACnB,wCAA2B,CAAA;IAC3B,gDAAmC,CAAA;IACnC,kDAAqC,CAAA;IACrC,4CAA+B,CAAA;IAC/B,kDAAqC,CAAA;IACrC,oDAAuC,CAAA;IACvC,8CAAiC,CAAA;IACjC,4DAA+C,CAAA;IAC/C,8DAAiD,CAAA;IACjD,wDAA2C,CAAA;IAC3C,gDAAmC,CAAA;IACnC,gDAAmC,CAAA;IACnC,oEAAuD,CAAA;IACvD,gEAAmD,CAAA;IACnD,0DAA6C,CAAA;AAC/C,CAAC,EAhBW,SAAS,KAAT,SAAS,QAgBpB","sourcesContent":["// Export other type files as they are created\nimport type { User } from \"../../types.js\";\n\nexport type { User };\n\nexport interface Session {\n accessToken?: string;\n idToken: string;\n refreshToken?: string;\n user?: User;\n expiresAt?: number; // Timestamp in milliseconds\n // any other session-related data\n}\n\nexport enum AuthEvent {\n INITIALIZED = \"initialized\",\n SIGN_IN_STARTED = \"sign_in_started\",\n SIGN_IN_COMPLETE = \"sign_in_complete\",\n SIGN_IN_ERROR = \"sign_in_error\",\n SIGN_OUT_STARTED = \"sign_out_started\",\n SIGN_OUT_COMPLETE = \"sign_out_complete\",\n SIGN_OUT_ERROR = \"sign_out_error\",\n TOKEN_REFRESH_STARTED = \"token_refresh_started\",\n TOKEN_REFRESH_COMPLETE = \"token_refresh_complete\",\n TOKEN_REFRESH_ERROR = \"token_refresh_error\",\n SESSION_EXPIRED = \"session_expired\",\n SESSION_RENEWED = \"session_renewed\",\n USER_INTERACTION_REQUIRED = \"user_interaction_required\",\n POPUP_REDIRECT_FALLBACK = \"popup_redirect_fallback\",\n USER_SESSION_CHANGED = \"user_session_changed\",\n}\n\nexport interface AuthResult {\n /** User information returned from authentication */\n user?: User;\n /** Signal text indicating the result */\n signalText?: string;\n}\n"]}
@@ -7,7 +7,8 @@ interface BuildAuthUrlParams {
7
7
  codeChallenge: string;
8
8
  state: string;
9
9
  prompt?: string;
10
+ nonce?: string;
10
11
  }
11
- export declare function buildAuthUrl({ endpoints, clientId, redirectUrl, scopes, codeChallenge, state, prompt, }: BuildAuthUrlParams): string;
12
+ export declare function buildAuthUrl({ endpoints, clientId, redirectUrl, scopes, codeChallenge, state, prompt, nonce, }: BuildAuthUrlParams): string;
12
13
  export {};
13
14
  //# sourceMappingURL=auth-utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth-utils.d.ts","sourceRoot":"","sources":["../../../src/vanillajs/utils/auth-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,UAAU,kBAAkB;IAC1B,SAAS,EAAE,SAAS,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,YAAY,CAAC,EAC3B,SAAS,EACT,QAAQ,EACR,WAAW,EACX,MAAM,EACN,aAAa,EACb,KAAK,EACL,MAAM,GACP,EAAE,kBAAkB,GAAG,MAAM,CAe7B"}
1
+ {"version":3,"file":"auth-utils.d.ts","sourceRoot":"","sources":["../../../src/vanillajs/utils/auth-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,UAAU,kBAAkB;IAC1B,SAAS,EAAE,SAAS,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,YAAY,CAAC,EAC3B,SAAS,EACT,QAAQ,EACR,WAAW,EACX,MAAM,EACN,aAAa,EACb,KAAK,EACL,MAAM,EACN,KAAK,GACN,EAAE,kBAAkB,GAAG,MAAM,CAmB7B"}
@@ -1,4 +1,4 @@
1
- export function buildAuthUrl({ endpoints, clientId, redirectUrl, scopes, codeChallenge, state, prompt, }) {
1
+ export function buildAuthUrl({ endpoints, clientId, redirectUrl, scopes, codeChallenge, state, prompt, nonce, }) {
2
2
  const authUrl = new URL(endpoints.auth);
3
3
  authUrl.searchParams.append("client_id", clientId);
4
4
  authUrl.searchParams.append("redirect_uri", redirectUrl);
@@ -7,8 +7,11 @@ export function buildAuthUrl({ endpoints, clientId, redirectUrl, scopes, codeCha
7
7
  authUrl.searchParams.append("state", state);
8
8
  authUrl.searchParams.append("code_challenge", codeChallenge);
9
9
  authUrl.searchParams.append("code_challenge_method", "S256");
10
- if (prompt) {
11
- authUrl.searchParams.append("prompt", prompt);
10
+ // Required by the auth server for offline_access scope
11
+ authUrl.searchParams.append("prompt", prompt || "consent");
12
+ if (nonce) {
13
+ // nonce isn't supported by oslo, so we add it manually
14
+ authUrl.searchParams.append("nonce", nonce);
12
15
  }
13
16
  return authUrl.toString();
14
17
  }
@@ -1 +1 @@
1
- {"version":3,"file":"auth-utils.js","sourceRoot":"","sources":["../../../src/vanillajs/utils/auth-utils.ts"],"names":[],"mappings":"AAYA,MAAM,UAAU,YAAY,CAAC,EAC3B,SAAS,EACT,QAAQ,EACR,WAAW,EACX,MAAM,EACN,aAAa,EACb,KAAK,EACL,MAAM,GACa;IACnB,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACxC,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;IACnD,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC;IACzD,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;IACrD,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IACvD,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC5C,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,gBAAgB,EAAE,aAAa,CAAC,CAAC;IAC7D,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,uBAAuB,EAAE,MAAM,CAAC,CAAC;IAE7D,IAAI,MAAM,EAAE,CAAC;QACX,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAChD,CAAC;IAED,OAAO,OAAO,CAAC,QAAQ,EAAE,CAAC;AAC5B,CAAC","sourcesContent":["import type { Endpoints } from \"../../types.js\";\n\ninterface BuildAuthUrlParams {\n endpoints: Endpoints;\n clientId: string;\n redirectUrl: string;\n scopes: string[];\n codeChallenge: string;\n state: string;\n prompt?: string;\n}\n\nexport function buildAuthUrl({\n endpoints,\n clientId,\n redirectUrl,\n scopes,\n codeChallenge,\n state,\n prompt,\n}: BuildAuthUrlParams): string {\n const authUrl = new URL(endpoints.auth);\n authUrl.searchParams.append(\"client_id\", clientId);\n authUrl.searchParams.append(\"redirect_uri\", redirectUrl);\n authUrl.searchParams.append(\"response_type\", \"code\");\n authUrl.searchParams.append(\"scope\", scopes.join(\" \"));\n authUrl.searchParams.append(\"state\", state);\n authUrl.searchParams.append(\"code_challenge\", codeChallenge);\n authUrl.searchParams.append(\"code_challenge_method\", \"S256\");\n\n if (prompt) {\n authUrl.searchParams.append(\"prompt\", prompt);\n }\n\n return authUrl.toString();\n}\n"]}
1
+ {"version":3,"file":"auth-utils.js","sourceRoot":"","sources":["../../../src/vanillajs/utils/auth-utils.ts"],"names":[],"mappings":"AAaA,MAAM,UAAU,YAAY,CAAC,EAC3B,SAAS,EACT,QAAQ,EACR,WAAW,EACX,MAAM,EACN,aAAa,EACb,KAAK,EACL,MAAM,EACN,KAAK,GACc;IACnB,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACxC,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;IACnD,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC;IACzD,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;IACrD,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IACvD,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC5C,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,gBAAgB,EAAE,aAAa,CAAC,CAAC;IAC7D,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,uBAAuB,EAAE,MAAM,CAAC,CAAC;IAE7D,uDAAuD;IACvD,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,IAAI,SAAS,CAAC,CAAC;IAE3D,IAAI,KAAK,EAAE,CAAC;QACV,uDAAuD;QACvD,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC9C,CAAC;IAED,OAAO,OAAO,CAAC,QAAQ,EAAE,CAAC;AAC5B,CAAC","sourcesContent":["import type { Endpoints } from \"../../types.js\";\n\ninterface BuildAuthUrlParams {\n endpoints: Endpoints;\n clientId: string;\n redirectUrl: string;\n scopes: string[];\n codeChallenge: string;\n state: string;\n prompt?: string;\n nonce?: string;\n}\n\nexport function buildAuthUrl({\n endpoints,\n clientId,\n redirectUrl,\n scopes,\n codeChallenge,\n state,\n prompt,\n nonce,\n}: BuildAuthUrlParams): string {\n const authUrl = new URL(endpoints.auth);\n authUrl.searchParams.append(\"client_id\", clientId);\n authUrl.searchParams.append(\"redirect_uri\", redirectUrl);\n authUrl.searchParams.append(\"response_type\", \"code\");\n authUrl.searchParams.append(\"scope\", scopes.join(\" \"));\n authUrl.searchParams.append(\"state\", state);\n authUrl.searchParams.append(\"code_challenge\", codeChallenge);\n authUrl.searchParams.append(\"code_challenge_method\", \"S256\");\n\n // Required by the auth server for offline_access scope\n authUrl.searchParams.append(\"prompt\", prompt || \"consent\");\n\n if (nonce) {\n // nonce isn't supported by oslo, so we add it manually\n authUrl.searchParams.append(\"nonce\", nonce);\n }\n\n return authUrl.toString();\n}\n"]}
@@ -1,24 +1,24 @@
1
- import debug from "debug";
2
- export declare const loggers: {
3
- auth: debug.Debugger;
4
- api: debug.Debugger;
5
- storage: debug.Debugger;
6
- session: debug.Debugger;
7
- events: debug.Debugger;
8
- utils: debug.Debugger;
9
- iframe: debug.Debugger;
1
+ interface ConfigureLoggingFunction {
2
+ (config: {
3
+ enabled: boolean;
4
+ namespace?: string;
5
+ level?: "debug" | "info" | "warn" | "error";
6
+ }): void;
7
+ originalLog: ((...args: unknown[]) => void) | null;
8
+ }
9
+ export declare const createLogger: (subNamespace: string) => {
10
+ debug: (message: string, ...args: unknown[]) => void;
11
+ info: (message: string, ...args: unknown[]) => void;
12
+ warn: (message: string, ...args: unknown[]) => void;
13
+ error: (message: string, ...args: unknown[]) => void;
10
14
  };
11
- export declare const createLogger: (namespace: string) => {
15
+ export declare const createMainLogger: (namespace?: string) => {
12
16
  debug: (message: string, ...args: unknown[]) => void;
13
17
  info: (message: string, ...args: unknown[]) => void;
14
18
  warn: (message: string, ...args: unknown[]) => void;
15
19
  error: (message: string, ...args: unknown[]) => void;
16
20
  };
17
- export declare const configureLogging: (config: {
18
- enabled: boolean;
19
- namespace?: string;
20
- level?: "debug" | "info" | "warn" | "error";
21
- }) => void;
21
+ export declare const configureLogging: ConfigureLoggingFunction;
22
22
  export declare const setCurrentLogger: (logger: ReturnType<typeof createLogger>) => void;
23
23
  export declare const getCurrentLogger: () => {
24
24
  debug: (message: string, ...args: unknown[]) => void;
@@ -26,4 +26,5 @@ export declare const getCurrentLogger: () => {
26
26
  warn: (message: string, ...args: unknown[]) => void;
27
27
  error: (message: string, ...args: unknown[]) => void;
28
28
  };
29
+ export {};
29
30
  //# sourceMappingURL=logger.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/vanillajs/utils/logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MA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AE;CAE9C,CAAC;AAGF,eAAO,MAAM,gBAAgB,eAAe,MAAM;qBAI7B,MAAM,WAAW,OAAO,EAAE;oBAC3B,MAAM,WAAW,OAAO,EAAE;oBAC1B,MAAM,WAAW,OAAO,EAAE;qBACzB,MAAM,WAAW,OAAO,EAAE;CAE9C,CAAC;AAGF,eAAO,MAAM,gBAAgB,EAAE,wBA0C9B,CAAC;AASF,eAAO,MAAM,gBAAgB,WAAY,UAAU,CAAC,OAAO,YAAY,CAAC,SAEvE,CAAC;AAGF,eAAO,MAAM,gBAAgB;qBA5ER,MAAM,WAAW,OAAO,EAAE;oBAC3B,MAAM,WAAW,OAAO,EAAE;oBAC1B,MAAM,WAAW,OAAO,EAAE;qBACzB,MAAM,WAAW,OAAO,EAAE;CA+E9C,CAAC"}
@@ -1,16 +1,21 @@
1
1
  import debug from "debug";
2
- // Create namespaced loggers for different components
3
- export const loggers = {
4
- auth: debug("civic:auth"),
5
- api: debug("civic:auth:api"),
6
- storage: debug("civic:auth:storage"),
7
- session: debug("civic:auth:session"),
8
- events: debug("civic:auth:events"),
9
- utils: debug("civic:auth:utils"),
10
- iframe: debug("civic:auth:iframe"),
11
- };
2
+ // Global variable to store the current namespace base
3
+ let currentNamespaceBase = "vanillajs";
12
4
  // Helper function to create a logger with a specific namespace
13
- export const createLogger = (namespace) => {
5
+ export const createLogger = (subNamespace) => {
6
+ // Create hierarchical namespace: civic:auth:{main}:{sub}
7
+ const fullNamespace = `civic:auth:${currentNamespaceBase}:${subNamespace}`;
8
+ const logger = debug(fullNamespace);
9
+ return {
10
+ debug: (message, ...args) => logger(message, ...args),
11
+ info: (message, ...args) => logger(message, ...args),
12
+ warn: (message, ...args) => logger(message, ...args),
13
+ error: (message, ...args) => logger(message, ...args),
14
+ };
15
+ };
16
+ // Helper function to create the main logger (for CivicAuth class)
17
+ export const createMainLogger = (namespace = "vanillajs") => {
18
+ currentNamespaceBase = namespace;
14
19
  const logger = debug(`civic:auth:${namespace}`);
15
20
  return {
16
21
  debug: (message, ...args) => logger(message, ...args),
@@ -23,28 +28,39 @@ export const createLogger = (namespace) => {
23
28
  export const configureLogging = (config) => {
24
29
  if (typeof window === "undefined")
25
30
  return;
31
+ // Store the original debug.log function if not already stored
32
+ if (!configureLogging.originalLog) {
33
+ configureLogging.originalLog = debug.log;
34
+ }
26
35
  if (config.enabled) {
27
- // Enable specific namespace if provided, otherwise enable all civic:auth namespaces
28
- const namespace = config.namespace
29
- ? `civic:auth:${config.namespace}`
30
- : "civic:auth:*";
31
- debug.enable(namespace);
36
+ // DO NOT update currentNamespaceBase - it should always stay "vanillajs"
37
+ // The namespace property is ONLY for filtering, not for setting the base namespace
38
+ // Enable namespace pattern - if namespace provided, enable that namespace and all its sub-namespaces
39
+ const namespacePattern = config.namespace && config.namespace !== "*"
40
+ ? `civic:auth:vanillajs:${config.namespace}*` // Filter to specific sub-namespace
41
+ : "civic:auth:vanillajs*"; // Enable all vanillajs namespaces
42
+ debug.enable(namespacePattern);
32
43
  // Override debug's default log function to ensure it works in the browser
33
- const originalLog = debug.log;
34
44
  debug.log = (...args) => {
35
45
  if (typeof console !== "undefined") {
36
46
  console.log(...args);
37
47
  }
38
- if (originalLog) {
39
- originalLog.apply(debug, args);
48
+ if (configureLogging.originalLog) {
49
+ configureLogging.originalLog.apply(debug, args);
40
50
  }
41
51
  };
42
52
  }
43
53
  else {
44
54
  // Disable all debug logs
45
55
  debug.disable();
56
+ // Restore the original debug.log function to prevent any logs from showing
57
+ if (configureLogging.originalLog) {
58
+ debug.log = configureLogging.originalLog;
59
+ }
46
60
  }
47
61
  };
62
+ // Store the original debug.log function as a property of configureLogging
63
+ configureLogging.originalLog = null;
48
64
  // Global variable to store the current logger instance
49
65
  let currentLogger = null;
50
66
  // Function to set the current logger instance
@@ -1 +1 @@
1
- {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../src/vanillajs/utils/logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,qD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AAM,CAAC,SAAS,EAAE;YAClC,CAAC,CAAC,cAAc,CAAC;QACnB,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAExB,0EAA0E;QAC1E,MAAM,WAAW,GAAG,KAAK,CAAC,GAAG,CAAC;QAC9B,KAAK,CAAC,GAAG,GAAG,CAAC,GAAG,IAAI,EAAE,EAAE;YACtB,IAAI,OAAO,OAAO,KAAK,WAAW,EAAE,CAAC;gBACnC,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;YACvB,CAAC;YACD,IAAI,WAAW,EAAE,CAAC;gBAChB,WAAW,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;YACjC,CAAC;QACH,CAAC,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,yBAAyB;QACzB,KAAK,CAAC,OAAO,EAAE,CAAC;IAClB,CAAC;AACH,CAAC,CAAC;AAEF,uDAAuD;AACvD,IAAI,aAAa,GAA2C,IAAI,CAAC;AAEjE,8CAA8C;AAC9C,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,MAAuC,EAAE,EAAE;IAC1E,aAAa,GAAG,MAAM,CAAC;AACzB,CAAC,CAAC;AAEF,8CAA8C;AAC9C,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,EAAE;IACnC,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,yCAAyC;QACzC,aAAa,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO,aAAa,CAAC;AACvB,CAAC,CAAC","sourcesContent":["import debug from \"debug\";\n\n// Create namespaced loggers for different components\nexport const loggers = {\n auth: debug(\"civic:auth\"),\n api: debug(\"civic:auth:api\"),\n storage: debug(\"civic:auth:storage\"),\n session: debug(\"civic:auth:session\"),\n events: debug(\"civic:auth:events\"),\n utils: debug(\"civic:auth:utils\"),\n iframe: debug(\"civic:auth:iframe\"),\n};\n\n// Helper function to create a logger with a specific namespace\nexport const createLogger = (namespace: string) => {\n const logger = debug(`civic:auth:${namespace}`);\n return {\n debug: (message: string, ...args: unknown[]) => logger(message, ...args),\n info: (message: string, ...args: unknown[]) => logger(message, ...args),\n warn: (message: string, ...args: unknown[]) => logger(message, ...args),\n error: (message: string, ...args: unknown[]) => logger(message, ...args),\n };\n};\n\n// Function to configure logging based on config\nexport const configureLogging = (config: {\n enabled: boolean;\n namespace?: string;\n level?: \"debug\" | \"info\" | \"warn\" | \"error\";\n}) => {\n if (typeof window === \"undefined\") return;\n\n if (config.enabled) {\n // Enable specific namespace if provided, otherwise enable all civic:auth namespaces\n const namespace = config.namespace\n ? `civic:auth:${config.namespace}`\n : \"civic:auth:*\";\n debug.enable(namespace);\n\n // Override debug's default log function to ensure it works in the browser\n const originalLog = debug.log;\n debug.log = (...args) => {\n if (typeof console !== \"undefined\") {\n console.log(...args);\n }\n if (originalLog) {\n originalLog.apply(debug, args);\n }\n };\n } else {\n // Disable all debug logs\n debug.disable();\n }\n};\n\n// Global variable to store the current logger instance\nlet currentLogger: ReturnType<typeof createLogger> | null = null;\n\n// Function to set the current logger instance\nexport const setCurrentLogger = (logger: ReturnType<typeof createLogger>) => {\n currentLogger = logger;\n};\n\n// Function to get the current logger instance\nexport const getCurrentLogger = () => {\n if (!currentLogger) {\n // Create a default logger if none is set\n currentLogger = createLogger(\"default\");\n }\n return currentLogger;\n};\n"]}
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../src/vanillajs/utils/logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAY1B,sDAAsD;AACtD,IAAI,oBAAoB,GAAW,WAAW,CAAC;AAE/C,+DAA+D;AAC/D,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,YAAoB,EAAE,EAAE;IACnD,yDAAyD;IACzD,MAAM,aAAa,GAAG,cAAc,oBAAoB,IAAI,YAAY,EAAE,CAAC;IAC3E,MAAM,MAAM,GAAG,KAAK,CAAC,aAAa,CAAC,CAAC;IACpC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AC,MAAuC,EAAE,EAAE;IAC1E,aAAa,GAAG,MAAM,CAAC;AACzB,CAAC,CAAC;AAEF,8CAA8C;AAC9C,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,EAAE;IACnC,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,yCAAyC;QACzC,aAAa,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO,aAAa,CAAC;AACvB,CAAC,CAAC","sourcesContent":["import debug from \"debug\";\n\n// Type for the extended configureLogging function\ninterface ConfigureLoggingFunction {\n (config: {\n enabled: boolean;\n namespace?: string;\n level?: \"debug\" | \"info\" | \"warn\" | \"error\";\n }): void;\n originalLog: ((...args: unknown[]) => void) | null;\n}\n\n// Global variable to store the current namespace base\nlet currentNamespaceBase: string = \"vanillajs\";\n\n// Helper function to create a logger with a specific namespace\nexport const createLogger = (subNamespace: string) => {\n // Create hierarchical namespace: civic:auth:{main}:{sub}\n const fullNamespace = `civic:auth:${currentNamespaceBase}:${subNamespace}`;\n const logger = debug(fullNamespace);\n return {\n debug: (message: string, ...args: unknown[]) => logger(message, ...args),\n info: (message: string, ...args: unknown[]) => logger(message, ...args),\n warn: (message: string, ...args: unknown[]) => logger(message, ...args),\n error: (message: string, ...args: unknown[]) => logger(message, ...args),\n };\n};\n\n// Helper function to create the main logger (for CivicAuth class)\nexport const createMainLogger = (namespace: string = \"vanillajs\") => {\n currentNamespaceBase = namespace;\n const logger = debug(`civic:auth:${namespace}`);\n return {\n debug: (message: string, ...args: unknown[]) => logger(message, ...args),\n info: (message: string, ...args: unknown[]) => logger(message, ...args),\n warn: (message: string, ...args: unknown[]) => logger(message, ...args),\n error: (message: string, ...args: unknown[]) => logger(message, ...args),\n };\n};\n\n// Function to configure logging based on config\nexport const configureLogging: ConfigureLoggingFunction = (config: {\n enabled: boolean;\n namespace?: string;\n level?: \"debug\" | \"info\" | \"warn\" | \"error\";\n}) => {\n if (typeof window === \"undefined\") return;\n\n // Store the original debug.log function if not already stored\n if (!configureLogging.originalLog) {\n configureLogging.originalLog = debug.log;\n }\n\n if (config.enabled) {\n // DO NOT update currentNamespaceBase - it should always stay \"vanillajs\"\n // The namespace property is ONLY for filtering, not for setting the base namespace\n\n // Enable namespace pattern - if namespace provided, enable that namespace and all its sub-namespaces\n const namespacePattern =\n config.namespace && config.namespace !== \"*\"\n ? `civic:auth:vanillajs:${config.namespace}*` // Filter to specific sub-namespace\n : \"civic:auth:vanillajs*\"; // Enable all vanillajs namespaces\n\n debug.enable(namespacePattern);\n\n // Override debug's default log function to ensure it works in the browser\n debug.log = (...args: unknown[]) => {\n if (typeof console !== \"undefined\") {\n console.log(...args);\n }\n if (configureLogging.originalLog) {\n configureLogging.originalLog.apply(debug, args);\n }\n };\n } else {\n // Disable all debug logs\n debug.disable();\n\n // Restore the original debug.log function to prevent any logs from showing\n if (configureLogging.originalLog) {\n debug.log = configureLogging.originalLog;\n }\n }\n};\n\n// Store the original debug.log function as a property of configureLogging\nconfigureLogging.originalLog = null;\n\n// Global variable to store the current logger instance\nlet currentLogger: ReturnType<typeof createLogger> | null = null;\n\n// Function to set the current logger instance\nexport const setCurrentLogger = (logger: ReturnType<typeof createLogger>) => {\n currentLogger = logger;\n};\n\n// Function to get the current logger instance\nexport const getCurrentLogger = () => {\n if (!currentLogger) {\n // Create a default logger if none is set\n currentLogger = createLogger(\"default\");\n }\n return currentLogger;\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@civic/auth",
3
- "version": "0.6.1-beta.1",
3
+ "version": "0.6.1-beta.3",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -21,6 +21,11 @@
21
21
  "import": "./dist/reactjs/index.js",
22
22
  "require": "./dist/reactjs/index.js"
23
23
  },
24
+ "./vanillajs": {
25
+ "types": "./dist/vanillajs/index.d.ts",
26
+ "import": "./dist/vanillajs/index.js",
27
+ "require": "./dist/vanillajs/index.js"
28
+ },
24
29
  "./nextjs": {
25
30
  "types": "./dist/nextjs/index.d.ts",
26
31
  "import": "./dist/nextjs/index.js",
@@ -1 +0,0 @@
1
- {"version":3,"file":"OAuthCallbackHandler.d.ts","sourceRoot":"","sources":["../../../src/vanillajs/auth/OAuthCallbackHandler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAWH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,KAAK,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAEzE;;;GAGG;AACH,wBAAsB,WAAW,CAC/B,MAAM,EAAE,qBAAqB,EAC7B,cAAc,EAAE,WAAW,EAC3B,cAAc;;;;;CAAqB,GAClC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAyBxB;AAED,MAAM,WAAW,yBAAyB;IACxC,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE;QACX,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IACF,cAAc,EAAE,WAAW,CAAC;IAC5B,MAAM,CAAC,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC;CAC9C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,yBAAyB,GAChC,OAAO,CAAC,OAAO,CAAC,CAmElB"}
@@ -1,143 +0,0 @@
1
- /**
2
- * OAuth Callback Handler for Vanilla JavaScript Applications
3
- *
4
- * This module provides functionality for handling OAuth redirect/callback pages in vanilla JavaScript
5
- * applications using the Civic Auth system. It processes the OAuth authorization code flow completion
6
- * by exchanging authorization codes for access tokens and managing the authentication state.
7
- *
8
- * Key responsibilities:
9
- * - Process OAuth callback URL parameters (code, state)
10
- * - Exchange authorization codes for access tokens using PKCE
11
- * - Store tokens and user session data using shared utilities
12
- * - Create DOM signals for iframe-based authentication flows
13
- * - Handle error states and cleanup during the OAuth flow
14
- *
15
- * This module works in conjunction with:
16
- * - CivicAuth class for initiating OAuth flows
17
- * - SignalObserver for detecting authentication completion in iframes
18
- * - Shared token storage utilities for consistent state management
19
- *
20
- * @example
21
- * ```typescript
22
- * // In an OAuth callback page
23
- * import { handleOAuthRedirectPage, LocalStorageAdapter } from '@civic/auth/vanillajs';
24
- *
25
- * const handled = await handleOAuthRedirectPage({
26
- * clientId: 'your-client-id',
27
- * redirectUrl: 'https://your-app.com/callback',
28
- * oauthServer: 'https://auth.civic.com/oauth/',
29
- * textSignals: {
30
- * success: 'Authentication successful!',
31
- * error: 'Authentication failed!'
32
- * },
33
- * storageAdapter: new LocalStorageAdapter()
34
- * });
35
- * ```
36
- */
37
- import { exchangeTokens, buildOauth2Client, getEndpointsWithOverrides, storeTokens as sharedStoreTokens, } from "../../shared/lib/util.js";
38
- import { getUser } from "../../shared/lib/session.js";
39
- import { GenericUserSession } from "../../shared/lib/UserSession.js";
40
- import { CodeVerifier } from "../../shared/lib/types.js";
41
- import { getCurrentLogger } from "../utils/logger.js";
42
- import { GenericPublicClientPKCEProducer } from "../../services/PKCE.js";
43
- /**
44
- * Store tokens using the shared utilities from /shared/lib
45
- * This ensures consistency with the React implementation and also handles user session storage
46
- */
47
- export async function storeTokens(tokens, storageAdapter, loggerInstance = getCurrentLogger()) {
48
- try {
49
- // Use shared storeTokens utility for consistent token storage
50
- await sharedStoreTokens(storageAdapter, tokens);
51
- // Get user info using shared utilities
52
- const user = await getUser(storageAdapter);
53
- if (user) {
54
- // Store user session using shared utilities
55
- const userSession = new GenericUserSession(storageAdapter);
56
- await userSession.set(user);
57
- loggerInstance.info("CivicAuth: Tokens and user info stored successfully using shared utilities.");
58
- return user;
59
- }
60
- else {
61
- loggerInstance.warn("CivicAuth: Failed to extract user info from tokens.");
62
- return null;
63
- }
64
- }
65
- catch (error) {
66
- loggerInstance.error("CivicAuth: Error storing tokens:", error);
67
- throw error;
68
- }
69
- }
70
- /**
71
- * Handle OAuth redirect page processing for vanilla JavaScript applications.
72
- * This function processes the OAuth callback URL parameters and exchanges the authorization code for tokens.
73
- *
74
- * @param config - Configuration object for handling the OAuth redirect
75
- * @param config.clientId - OAuth client ID
76
- * @param config.redirectUrl - URL to redirect to after authentication
77
- * @param config.oauthServer - OAuth server base URL
78
- * @param config.textSignals - Text signals for success and error states
79
- * @param config.storageAdapter - Storage adapter for persisting auth state (required)
80
- * @param config.logger - Optional logger instance
81
- * @returns Promise<boolean> - Returns true if callback was handled, false otherwise
82
- *
83
- * @example
84
- * ```typescript
85
- * import { handleOAuthRedirectPage, LocalStorageAdapter } from '@civic/auth/vanillajs';
86
- *
87
- * const handled = await handleOAuthRedirectPage({
88
- * clientId: 'your-client-id',
89
- * redirectUrl: 'https://your-app.com/callback',
90
- * oauthServer: 'https://auth.civic.com/oauth/',
91
- * textSignals: {
92
- * success: 'Authentication successful!',
93
- * error: 'Authentication failed!'
94
- * },
95
- * storageAdapter: new LocalStorageAdapter()
96
- * });
97
- * ```
98
- */
99
- export async function handleOAuthRedirectPage(config) {
100
- const loggerInstance = config.logger || getCurrentLogger();
101
- const urlParams = new URLSearchParams(window.location.search);
102
- const code = urlParams.get("code");
103
- const state = urlParams.get("state");
104
- if (code && state) {
105
- loggerInstance.info("CivicAuth: OAuth callback detected with code:", code);
106
- // Use the provided storage adapter from config
107
- const storage = config.storageAdapter;
108
- const pkceProducer = new GenericPublicClientPKCEProducer(storage);
109
- try {
110
- const endpoints = await getEndpointsWithOverrides(config.oauthServer);
111
- const oauth2Client = buildOauth2Client(config.clientId, config.redirectUrl, endpoints);
112
- const tokenResponse = await exchangeTokens(code, state, pkceProducer, oauth2Client, config.oauthServer, endpoints);
113
- // Get userInfo from storeTokens using shared utilities
114
- const userInfo = await storeTokens(tokenResponse, storage, loggerInstance);
115
- loggerInstance.info("CivicAuth: Tokens stored successfully using shared utilities.");
116
- const signalElement = document.createElement("div");
117
- signalElement.id = "civic-auth-success-signal";
118
- signalElement.textContent = config.textSignals.success;
119
- if (userInfo) {
120
- // Embed userInfo if available
121
- signalElement.setAttribute("data-user-info", JSON.stringify(userInfo));
122
- }
123
- signalElement.style.display = "none";
124
- document.body.appendChild(signalElement);
125
- loggerInstance.info("CivicAuth: Appended success signal to body.");
126
- // Clean up the code verifier using shared utilities
127
- await storage.delete(CodeVerifier.COOKIE_NAME);
128
- }
129
- catch (error) {
130
- loggerInstance.error("CivicAuth: Token exchange error:", error);
131
- const errorSignalElement = document.createElement("div");
132
- errorSignalElement.id = "civic-auth-error-signal";
133
- const errorMessage = error instanceof Error ? error.message : "Unknown error";
134
- errorSignalElement.textContent = `${config.textSignals.error} (Error: ${errorMessage})`;
135
- errorSignalElement.style.display = "none";
136
- document.body.appendChild(errorSignalElement);
137
- return true;
138
- }
139
- return true;
140
- }
141
- return false;
142
- }
143
- //# sourceMappingURL=OAuthCallbackHandler.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"OAuthCallbackHandler.js","sourceRoot":"","sources":["../../../src/vanillajs/auth/OAuthCallbackHandler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,yBAAyB,EACzB,WAAW,IAAI,iBAAiB,GACjC,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,+BAA+B,EAAE,MAAM,wBAAwB,CAAC;AAGzE;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,MAA6B,EAC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,CAAC,CAAC;YAChE,MAAM,kBAAkB,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;YACzD,kBAAkB,CAAC,EAAE,GAAG,yBAAyB,CAAC;YAClD,MAAM,YAAY,GAChB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC;YAC3D,kBAAkB,CAAC,WAAW,GAAG,GAAG,MAAM,CAAC,WAAW,CAAC,KAAK,YAAY,YAAY,GAAG,CAAC;YACxF,kBAAkB,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC;YAC1C,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC;YAC9C,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["/**\n * OAuth Callback Handler for Vanilla JavaScript Applications\n *\n * This module provides functionality for handling OAuth redirect/callback pages in vanilla JavaScript\n * applications using the Civic Auth system. It processes the OAuth authorization code flow completion\n * by exchanging authorization codes for access tokens and managing the authentication state.\n *\n * Key responsibilities:\n * - Process OAuth callback URL parameters (code, state)\n * - Exchange authorization codes for access tokens using PKCE\n * - Store tokens and user session data using shared utilities\n * - Create DOM signals for iframe-based authentication flows\n * - Handle error states and cleanup during the OAuth flow\n *\n * This module works in conjunction with:\n * - CivicAuth class for initiating OAuth flows\n * - SignalObserver for detecting authentication completion in iframes\n * - Shared token storage utilities for consistent state management\n *\n * @example\n * ```typescript\n * // In an OAuth callback page\n * import { handleOAuthRedirectPage, LocalStorageAdapter } from '@civic/auth/vanillajs';\n *\n * const handled = await handleOAuthRedirectPage({\n * clientId: 'your-client-id',\n * redirectUrl: 'https://your-app.com/callback',\n * oauthServer: 'https://auth.civic.com/oauth/',\n * textSignals: {\n * success: 'Authentication successful!',\n * error: 'Authentication failed!'\n * },\n * storageAdapter: new LocalStorageAdapter()\n * });\n * ```\n */\n\nimport {\n exchangeTokens,\n buildOauth2Client,\n getEndpointsWithOverrides,\n storeTokens as sharedStoreTokens,\n} from \"../../shared/lib/util.js\";\nimport { getUser } from \"../../shared/lib/session.js\";\nimport { GenericUserSession } from \"../../shared/lib/UserSession.js\";\nimport { CodeVerifier } from \"../../shared/lib/types.js\";\nimport { getCurrentLogger } from \"../utils/logger.js\";\nimport { GenericPublicClientPKCEProducer } from \"../../services/PKCE.js\";\nimport type { AuthStorage, OIDCTokenResponseBody } from \"../../types.js\";\n\n/**\n * Store tokens using the shared utilities from /shared/lib\n * This ensures consistency with the React implementation and also handles user session storage\n */\nexport async function storeTokens(\n tokens: OIDCTokenResponseBody,\n storageAdapter: AuthStorage,\n loggerInstance = getCurrentLogger(),\n): Promise<object | null> {\n try {\n // Use shared storeTokens utility for consistent token storage\n await sharedStoreTokens(storageAdapter, tokens);\n\n // Get user info using shared utilities\n const user = await getUser(storageAdapter);\n if (user) {\n // Store user session using shared utilities\n const userSession = new GenericUserSession(storageAdapter);\n await userSession.set(user);\n loggerInstance.info(\n \"CivicAuth: Tokens and user info stored successfully using shared utilities.\",\n );\n return user;\n } else {\n loggerInstance.warn(\n \"CivicAuth: Failed to extract user info from tokens.\",\n );\n return null;\n }\n } catch (error) {\n loggerInstance.error(\"CivicAuth: Error storing tokens:\", error);\n throw error;\n }\n}\n\nexport interface HandleOAuthRedirectConfig {\n clientId: string;\n redirectUrl: string;\n oauthServer: string;\n textSignals: {\n success: string;\n error: string;\n };\n storageAdapter: AuthStorage;\n logger?: ReturnType<typeof getCurrentLogger>;\n}\n\n/**\n * Handle OAuth redirect page processing for vanilla JavaScript applications.\n * This function processes the OAuth callback URL parameters and exchanges the authorization code for tokens.\n *\n * @param config - Configuration object for handling the OAuth redirect\n * @param config.clientId - OAuth client ID\n * @param config.redirectUrl - URL to redirect to after authentication\n * @param config.oauthServer - OAuth server base URL\n * @param config.textSignals - Text signals for success and error states\n * @param config.storageAdapter - Storage adapter for persisting auth state (required)\n * @param config.logger - Optional logger instance\n * @returns Promise<boolean> - Returns true if callback was handled, false otherwise\n *\n * @example\n * ```typescript\n * import { handleOAuthRedirectPage, LocalStorageAdapter } from '@civic/auth/vanillajs';\n *\n * const handled = await handleOAuthRedirectPage({\n * clientId: 'your-client-id',\n * redirectUrl: 'https://your-app.com/callback',\n * oauthServer: 'https://auth.civic.com/oauth/',\n * textSignals: {\n * success: 'Authentication successful!',\n * error: 'Authentication failed!'\n * },\n * storageAdapter: new LocalStorageAdapter()\n * });\n * ```\n */\nexport async function handleOAuthRedirectPage(\n config: HandleOAuthRedirectConfig,\n): Promise<boolean> {\n const loggerInstance = config.logger || getCurrentLogger();\n const urlParams = new URLSearchParams(window.location.search);\n const code = urlParams.get(\"code\");\n const state = urlParams.get(\"state\");\n\n if (code && state) {\n loggerInstance.info(\"CivicAuth: OAuth callback detected with code:\", code);\n\n // Use the provided storage adapter from config\n const storage = config.storageAdapter;\n const pkceProducer = new GenericPublicClientPKCEProducer(storage);\n\n try {\n const endpoints = await getEndpointsWithOverrides(config.oauthServer);\n const oauth2Client = buildOauth2Client(\n config.clientId,\n config.redirectUrl,\n endpoints,\n );\n\n const tokenResponse = await exchangeTokens(\n code,\n state,\n pkceProducer,\n oauth2Client,\n config.oauthServer,\n endpoints,\n );\n\n // Get userInfo from storeTokens using shared utilities\n const userInfo = await storeTokens(\n tokenResponse,\n storage,\n loggerInstance,\n );\n loggerInstance.info(\n \"CivicAuth: Tokens stored successfully using shared utilities.\",\n );\n\n const signalElement = document.createElement(\"div\");\n signalElement.id = \"civic-auth-success-signal\";\n signalElement.textContent = config.textSignals.success;\n if (userInfo) {\n // Embed userInfo if available\n signalElement.setAttribute(\"data-user-info\", JSON.stringify(userInfo));\n }\n signalElement.style.display = \"none\";\n document.body.appendChild(signalElement);\n loggerInstance.info(\"CivicAuth: Appended success signal to body.\");\n\n // Clean up the code verifier using shared utilities\n await storage.delete(CodeVerifier.COOKIE_NAME);\n } catch (error) {\n loggerInstance.error(\"CivicAuth: Token exchange error:\", error);\n const errorSignalElement = document.createElement(\"div\");\n errorSignalElement.id = \"civic-auth-error-signal\";\n const errorMessage =\n error instanceof Error ? error.message : \"Unknown error\";\n errorSignalElement.textContent = `${config.textSignals.error} (Error: ${errorMessage})`;\n errorSignalElement.style.display = \"none\";\n document.body.appendChild(errorSignalElement);\n return true;\n }\n return true;\n }\n return false;\n}\n"]}