@civic/auth 0.6.1-beta.2 → 0.6.1-beta.4

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 (93) hide show
  1. package/CHANGELOG.md +3 -0
  2. package/README.md +7 -0
  3. package/dist/nextjs/config.d.ts.map +1 -1
  4. package/dist/nextjs/config.js +1 -5
  5. package/dist/nextjs/config.js.map +1 -1
  6. package/dist/nextjs/hooks/useUserCookie.d.ts.map +1 -1
  7. package/dist/nextjs/hooks/useUserCookie.js.map +1 -1
  8. package/dist/nextjs/middleware.d.ts.map +1 -1
  9. package/dist/nextjs/middleware.js +51 -18
  10. package/dist/nextjs/middleware.js.map +1 -1
  11. package/dist/nextjs/providers/NextAuthProvider.d.ts.map +1 -1
  12. package/dist/nextjs/providers/NextAuthProvider.js +0 -1
  13. package/dist/nextjs/providers/NextAuthProvider.js.map +1 -1
  14. package/dist/nextjs/routeHandler.d.ts.map +1 -1
  15. package/dist/nextjs/routeHandler.js +8 -0
  16. package/dist/nextjs/routeHandler.js.map +1 -1
  17. package/dist/shared/hooks/useSignIn.d.ts +4 -9
  18. package/dist/shared/hooks/useSignIn.d.ts.map +1 -1
  19. package/dist/shared/hooks/useSignIn.js +42 -75
  20. package/dist/shared/hooks/useSignIn.js.map +1 -1
  21. package/dist/shared/providers/AuthContext.d.ts +2 -7
  22. package/dist/shared/providers/AuthContext.d.ts.map +1 -1
  23. package/dist/shared/providers/AuthContext.js.map +1 -1
  24. package/dist/shared/providers/UserProvider.d.ts +1 -5
  25. package/dist/shared/providers/UserProvider.d.ts.map +1 -1
  26. package/dist/shared/providers/UserProvider.js.map +1 -1
  27. package/dist/shared/version.d.ts +1 -1
  28. package/dist/shared/version.js +1 -1
  29. package/dist/shared/version.js.map +1 -1
  30. package/dist/vanillajs/auth/AuthenticationEvents.d.ts.map +1 -1
  31. package/dist/vanillajs/auth/AuthenticationEvents.js +2 -2
  32. package/dist/vanillajs/auth/AuthenticationEvents.js.map +1 -1
  33. package/dist/vanillajs/auth/CivicAuth.d.ts +107 -68
  34. package/dist/vanillajs/auth/CivicAuth.d.ts.map +1 -1
  35. package/dist/vanillajs/auth/CivicAuth.js +412 -389
  36. package/dist/vanillajs/auth/CivicAuth.js.map +1 -1
  37. package/dist/vanillajs/auth/{handlers/OAuthCallbackHandler.d.ts → OAuthCallbackHandler.d.ts} +2 -2
  38. package/dist/vanillajs/auth/OAuthCallbackHandler.d.ts.map +1 -0
  39. package/dist/vanillajs/auth/OAuthCallbackHandler.js +143 -0
  40. package/dist/vanillajs/auth/OAuthCallbackHandler.js.map +1 -0
  41. package/dist/vanillajs/auth/SessionManager.d.ts.map +1 -1
  42. package/dist/vanillajs/auth/SessionManager.js +2 -2
  43. package/dist/vanillajs/auth/SessionManager.js.map +1 -1
  44. package/dist/vanillajs/auth/TokenRefresher.d.ts.map +1 -1
  45. package/dist/vanillajs/auth/TokenRefresher.js +2 -2
  46. package/dist/vanillajs/auth/TokenRefresher.js.map +1 -1
  47. package/dist/vanillajs/iframe/IframeManager.d.ts +0 -33
  48. package/dist/vanillajs/iframe/IframeManager.d.ts.map +1 -1
  49. package/dist/vanillajs/iframe/IframeManager.js +36 -163
  50. package/dist/vanillajs/iframe/IframeManager.js.map +1 -1
  51. package/dist/vanillajs/index.d.ts +2 -2
  52. package/dist/vanillajs/index.d.ts.map +1 -1
  53. package/dist/vanillajs/index.js +2 -2
  54. package/dist/vanillajs/index.js.map +1 -1
  55. package/dist/vanillajs/services/ApiService.d.ts.map +1 -1
  56. package/dist/vanillajs/services/ApiService.js +2 -2
  57. package/dist/vanillajs/services/ApiService.js.map +1 -1
  58. package/dist/vanillajs/types/index.d.ts +10 -15
  59. package/dist/vanillajs/types/index.d.ts.map +1 -1
  60. package/dist/vanillajs/types/index.js +10 -15
  61. package/dist/vanillajs/types/index.js.map +1 -1
  62. package/dist/vanillajs/utils/auth-utils.d.ts +1 -2
  63. package/dist/vanillajs/utils/auth-utils.d.ts.map +1 -1
  64. package/dist/vanillajs/utils/auth-utils.js +3 -6
  65. package/dist/vanillajs/utils/auth-utils.js.map +1 -1
  66. package/dist/vanillajs/utils/logger.d.ts +15 -16
  67. package/dist/vanillajs/utils/logger.d.ts.map +1 -1
  68. package/dist/vanillajs/utils/logger.js +19 -35
  69. package/dist/vanillajs/utils/logger.js.map +1 -1
  70. package/package.json +1 -1
  71. package/dist/vanillajs/auth/config/ConfigProcessor.d.ts +0 -6
  72. package/dist/vanillajs/auth/config/ConfigProcessor.d.ts.map +0 -1
  73. package/dist/vanillajs/auth/config/ConfigProcessor.js +0 -59
  74. package/dist/vanillajs/auth/config/ConfigProcessor.js.map +0 -1
  75. package/dist/vanillajs/auth/handlers/IframeAuthHandler.d.ts +0 -40
  76. package/dist/vanillajs/auth/handlers/IframeAuthHandler.d.ts.map +0 -1
  77. package/dist/vanillajs/auth/handlers/IframeAuthHandler.js +0 -388
  78. package/dist/vanillajs/auth/handlers/IframeAuthHandler.js.map +0 -1
  79. package/dist/vanillajs/auth/handlers/MessageHandler.d.ts +0 -170
  80. package/dist/vanillajs/auth/handlers/MessageHandler.d.ts.map +0 -1
  81. package/dist/vanillajs/auth/handlers/MessageHandler.js +0 -367
  82. package/dist/vanillajs/auth/handlers/MessageHandler.js.map +0 -1
  83. package/dist/vanillajs/auth/handlers/OAuthCallbackHandler.d.ts.map +0 -1
  84. package/dist/vanillajs/auth/handlers/OAuthCallbackHandler.js +0 -301
  85. package/dist/vanillajs/auth/handlers/OAuthCallbackHandler.js.map +0 -1
  86. package/dist/vanillajs/auth/handlers/PopupHandler.d.ts +0 -108
  87. package/dist/vanillajs/auth/handlers/PopupHandler.d.ts.map +0 -1
  88. package/dist/vanillajs/auth/handlers/PopupHandler.js +0 -333
  89. package/dist/vanillajs/auth/handlers/PopupHandler.js.map +0 -1
  90. package/dist/vanillajs/auth/types/AuthTypes.d.ts +0 -128
  91. package/dist/vanillajs/auth/types/AuthTypes.d.ts.map +0 -1
  92. package/dist/vanillajs/auth/types/AuthTypes.js +0 -40
  93. package/dist/vanillajs/auth/types/AuthTypes.js.map +0 -1
@@ -8,21 +8,16 @@ export interface Session {
8
8
  expiresAt?: number;
9
9
  }
10
10
  export declare enum AuthEvent {
11
- INITIALIZED = "initialized",
12
- SIGN_IN_STARTED = "sign_in_started",
13
- SIGN_IN_COMPLETE = "sign_in_complete",
14
- SIGN_IN_ERROR = "sign_in_error",
15
- SIGN_OUT_STARTED = "sign_out_started",
16
- SIGN_OUT_COMPLETE = "sign_out_complete",
17
- SIGN_OUT_ERROR = "sign_out_error",
18
- TOKEN_REFRESH_STARTED = "token_refresh_started",
19
- TOKEN_REFRESH_COMPLETE = "token_refresh_complete",
20
- TOKEN_REFRESH_ERROR = "token_refresh_error",
21
- SESSION_EXPIRED = "session_expired",
22
- SESSION_RENEWED = "session_renewed",
23
- USER_INTERACTION_REQUIRED = "user_interaction_required",
24
- POPUP_REDIRECT_FALLBACK = "popup_redirect_fallback",
25
- USER_SESSION_CHANGED = "user_session_changed"
11
+ SIGN_IN_STARTED = "signInStarted",
12
+ SIGN_IN_COMPLETE = "signInComplete",
13
+ SIGN_IN_ERROR = "signInError",
14
+ SIGN_OUT_STARTED = "signOutStarted",
15
+ SIGN_OUT_COMPLETE = "signOutComplete",
16
+ SIGN_OUT_ERROR = "signOutError",
17
+ TOKEN_REFRESH_STARTED = "tokenRefreshStarted",
18
+ TOKEN_REFRESH_COMPLETE = "tokenRefreshComplete",
19
+ TOKEN_REFRESH_ERROR = "tokenRefreshError",
20
+ USER_SESSION_CHANGED = "userSessionChanged"
26
21
  }
27
22
  export interface AuthResult {
28
23
  /** User information returned from authentication */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/vanillajs/types/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAE3C,YAAY,EAAE,IAAI,EAAE,CAAC;AAErB,MAAM,WAAW,OAAO;IACtB,WAAW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B;IAC/C,mBAAmB,sBAAsB;IACzC,oBAAoB,uBAAuB;CAC5C;AAED,MAAM,WAAW,UAAU;IACzB,oDAAoD;IACpD,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,wCAAwC;IACxC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB"}
@@ -1,19 +1,14 @@
1
1
  export var AuthEvent;
2
2
  (function (AuthEvent) {
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";
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";
18
13
  })(AuthEvent || (AuthEvent = {}));
19
14
  //# 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,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"]}
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"]}
@@ -7,8 +7,7 @@ interface BuildAuthUrlParams {
7
7
  codeChallenge: string;
8
8
  state: string;
9
9
  prompt?: string;
10
- nonce?: string;
11
10
  }
12
- export declare function buildAuthUrl({ endpoints, clientId, redirectUrl, scopes, codeChallenge, state, prompt, nonce, }: BuildAuthUrlParams): string;
11
+ export declare function buildAuthUrl({ endpoints, clientId, redirectUrl, scopes, codeChallenge, state, prompt, }: BuildAuthUrlParams): string;
13
12
  export {};
14
13
  //# 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;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
+ {"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,4 +1,4 @@
1
- export function buildAuthUrl({ endpoints, clientId, redirectUrl, scopes, codeChallenge, state, prompt, nonce, }) {
1
+ export function buildAuthUrl({ endpoints, clientId, redirectUrl, scopes, codeChallenge, state, prompt, }) {
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,11 +7,8 @@ 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
- // 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);
10
+ if (prompt) {
11
+ authUrl.searchParams.append("prompt", prompt);
15
12
  }
16
13
  return authUrl.toString();
17
14
  }
@@ -1 +1 @@
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
+ {"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,24 +1,24 @@
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;
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;
14
10
  };
15
- export declare const createMainLogger: (namespace?: string) => {
11
+ export declare const createLogger: (namespace: string) => {
16
12
  debug: (message: string, ...args: unknown[]) => void;
17
13
  info: (message: string, ...args: unknown[]) => void;
18
14
  warn: (message: string, ...args: unknown[]) => void;
19
15
  error: (message: string, ...args: unknown[]) => void;
20
16
  };
21
- export declare const configureLogging: ConfigureLoggingFunction;
17
+ export declare const configureLogging: (config: {
18
+ enabled: boolean;
19
+ namespace?: string;
20
+ level?: "debug" | "info" | "warn" | "error";
21
+ }) => void;
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,5 +26,4 @@ export declare const getCurrentLogger: () => {
26
26
  warn: (message: string, ...args: unknown[]) => void;
27
27
  error: (message: string, ...args: unknown[]) => void;
28
28
  };
29
- export {};
30
29
  //# sourceMappingURL=logger.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/vanillajs/utils/logger.ts"],"names":[],"mappings":"AAGA,UAAU,wBAAwB;IAChC,CAAC,MAAM,EAAE;QACP,OAAO,EAAE,OAAO,CAAC;QACjB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;KAC7C,GAAG,IAAI,CAAC;IACT,WAAW,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC;CACpD;AAMD,eAAO,MAAM,YAAY,iBAAkB,MAAM;qBAK5B,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,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
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/vanillajs/utils/logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,eAAO,MAAM,OAAO;;;;;;;;CAQnB,CAAC;AAGF,eAAO,MAAM,YAAY,cAAe,MAAM;qBAGzB,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,WAAY;IACvC,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;CAC7C,SAwBA,CAAC;AAMF,eAAO,MAAM,gBAAgB,WAAY,UAAU,CAAC,OAAO,YAAY,CAAC,SAEvE,CAAC;AAGF,eAAO,MAAM,gBAAgB;qBA/CR,MAAM,WAAW,OAAO,EAAE;oBAC3B,MAAM,WAAW,OAAO,EAAE;oBAC1B,MAAM,WAAW,OAAO,EAAE;qBACzB,MAAM,WAAW,OAAO,EAAE;CAkD9C,CAAC"}
@@ -1,21 +1,16 @@
1
1
  import debug from "debug";
2
- // Global variable to store the current namespace base
3
- let currentNamespaceBase = "vanillajs";
4
- // Helper function to create a logger with a specific 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
- };
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"),
15
11
  };
16
- // Helper function to create the main logger (for CivicAuth class)
17
- export const createMainLogger = (namespace = "vanillajs") => {
18
- currentNamespaceBase = namespace;
12
+ // Helper function to create a logger with a specific namespace
13
+ export const createLogger = (namespace) => {
19
14
  const logger = debug(`civic:auth:${namespace}`);
20
15
  return {
21
16
  debug: (message, ...args) => logger(message, ...args),
@@ -28,39 +23,28 @@ export const createMainLogger = (namespace = "vanillajs") => {
28
23
  export const configureLogging = (config) => {
29
24
  if (typeof window === "undefined")
30
25
  return;
31
- // Store the original debug.log function if not already stored
32
- if (!configureLogging.originalLog) {
33
- configureLogging.originalLog = debug.log;
34
- }
35
26
  if (config.enabled) {
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);
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);
43
32
  // Override debug's default log function to ensure it works in the browser
33
+ const originalLog = debug.log;
44
34
  debug.log = (...args) => {
45
35
  if (typeof console !== "undefined") {
46
36
  console.log(...args);
47
37
  }
48
- if (configureLogging.originalLog) {
49
- configureLogging.originalLog.apply(debug, args);
38
+ if (originalLog) {
39
+ originalLog.apply(debug, args);
50
40
  }
51
41
  };
52
42
  }
53
43
  else {
54
44
  // Disable all debug logs
55
45
  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
- }
60
46
  }
61
47
  };
62
- // Store the original debug.log function as a property of configureLogging
63
- configureLogging.originalLog = null;
64
48
  // Global variable to store the current logger instance
65
49
  let currentLogger = null;
66
50
  // 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;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,OAAO;QACL,KAAK,EAAE,CAAC,OAAe,EAAE,GAAG,IAAe,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC;QACxE,IAAI,EAAE,CAAC,OAAe,EAAE,GAAG,IAAe,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC;QACvE,IAAI,EAAE,CAAC,OAAe,EAAE,GAAG,IAAe,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC;QACvE,KAAK,EAAE,CAAC,OAAe,EAAE,GAAG,IAAe,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC;KACzE,CAAC;AACJ,CAAC,CAAC;AAEF,kEAAkE;AAClE,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,YAAoB,WAAW,EAAE,EAAE;IAClE,oBAAoB,GAAG,SAAS,CAAC;IACjC,MAAM,MAAM,GAA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CAAC;gBACnC,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;YACvB,CAAC;YACD,IAAI,gBAAgB,CAAC,WAAW,EAAE,CAAC;gBACjC,gBAAgB,CAAC,WAAW,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;YAClD,CAAC;QACH,CAAC,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,yBAAyB;QACzB,KAAK,CAAC,OAAO,EAAE,CAAC;QAEhB,2EAA2E;QAC3E,IAAI,gBAAgB,CAAC,WAAW,EAAE,CAAC;YACjC,KAAK,CAAC,GAAG,GAAG,gBAAgB,CAAC,WAAW,CAAC;QAC3C,CAAC;IACH,CAAC;AACH,CAAC,CAAC;AAEF,0EAA0E;AAC1E,gBAAgB,CAAC,WAAW,GAAG,IAAI,CAAC;AAEpC,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// 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"]}
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../src/vanillajs/utils/logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,qDAAqD;AACrD,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,IAAI,EAAE,KAAK,CAAC,YAAY,CAAC;IACzB,GAAG,EAAE,KAAK,CAAC,gBAAgB,CAAC;IAC5B,OAAO,EAAE,KAAK,CAAC,oBAAoB,CAAC;IACpC,OAAO,EAAE,KAAK,CAAC,oBAAoB,CAAC;IACpC,MAAM,EAAE,KAAK,CAAC,mBAAmB,CAAC;IAClC,KAAK,EAAE,KAAK,CAAC,kBAAkB,CAAC;IAChC,MAAM,EAAE,KAAK,CAAC,mBAAmB,CAAC;CACnC,CAAC;AAEF,+DAA+D;AAC/D,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,SAAiB,EAAE,EAAE;IAChD,MAAM,MAAM,GAAG,KAAK,CAAC,cAAc,SAAS,EAAE,CAAC,CAAC;IAChD,OAAO;QACL,KAAK,EAAE,CAAC,OAAe,EAAE,GAAG,IAAe,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC;QACxE,IAAI,EAAE,CAAC,OAAe,EAAE,GAAG,IAAe,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC;QACvE,IAAI,EAAE,CAAC,OAAe,EAAE,GAAG,IAAe,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,IAAI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AAE,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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@civic/auth",
3
- "version": "0.6.1-beta.2",
3
+ "version": "0.6.1-beta.4",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -1,6 +0,0 @@
1
- import type { CivicAuthClientConfig, ProcessedCivicAuthConfig } from "../types/AuthTypes.js";
2
- /**
3
- * Process the configuration with defaults and validation
4
- */
5
- export declare function processConfigWithDefaults(config: CivicAuthClientConfig): ProcessedCivicAuthConfig;
6
- //# sourceMappingURL=ConfigProcessor.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ConfigProcessor.d.ts","sourceRoot":"","sources":["../../../../src/vanillajs/auth/config/ConfigProcessor.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,qBAAqB,EACrB,wBAAwB,EAEzB,MAAM,uBAAuB,CAAC;AAO/B;;GAEG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,qBAAqB,GAC5B,wBAAwB,CAgC1B"}
@@ -1,59 +0,0 @@
1
- import { LocalStorageAdapter } from "../../../browser/storage.js";
2
- import { DEFAULT_SCOPES } from "../../../constants.js";
3
- import { CivicAuthError, CivicAuthErrorCode, CIVIC_AUTH_CONSTANTS, } from "../types/AuthTypes.js";
4
- /**
5
- * Process the configuration with defaults and validation
6
- */
7
- export function processConfigWithDefaults(config) {
8
- // Validate required configuration
9
- validateRequiredConfig(config);
10
- const loggingConfig = {
11
- enabled: true,
12
- namespace: "*",
13
- level: "debug",
14
- ...config.logging,
15
- };
16
- return {
17
- ...config,
18
- redirectUrl: config.redirectUrl ||
19
- `${window.location.origin}${window.location.pathname}`,
20
- oauthServerBaseUrl: config.oauthServerBaseUrl || "https://auth.civic.com/oauth/",
21
- scopes: config.scopes || DEFAULT_SCOPES,
22
- textSignals: config.textSignals || {
23
- success: "Authentication successful!",
24
- error: "Authentication failed. Please try again.",
25
- },
26
- displayMode: config.displayMode || "iframe",
27
- authProcessTimeout: config.authProcessTimeout ||
28
- CIVIC_AUTH_CONSTANTS.DEFAULT_AUTH_PROCESS_TIMEOUT,
29
- iframeId: config.iframeId || CIVIC_AUTH_CONSTANTS.DEFAULT_IFRAME_ID,
30
- prompt: "consent",
31
- logging: loggingConfig,
32
- storageAdapter: config.storageAdapter || new LocalStorageAdapter(),
33
- };
34
- }
35
- /**
36
- * Validates required configuration properties
37
- */
38
- function validateRequiredConfig(config) {
39
- // Always required configurations
40
- const requiredConfigs = [{ key: "clientId", value: config.clientId }];
41
- // Validate always-required fields
42
- for (const { key, value } of requiredConfigs) {
43
- if (!value) {
44
- throw new CivicAuthError(`CivicAuth: ${key} is required.`, CivicAuthErrorCode.CONFIG_REQUIRED);
45
- }
46
- }
47
- // Conditional validation for targetContainerElement
48
- // Only required for embedded iframe mode
49
- const displayMode = config.displayMode || "iframe";
50
- const iframeDisplayMode = config.iframeDisplayMode;
51
- // Check if we need a container element
52
- const needsContainer = displayMode === "iframe" && iframeDisplayMode === "embedded";
53
- if (needsContainer && !config.targetContainerElement) {
54
- throw new CivicAuthError("CivicAuth: targetContainerElement is required for embedded iframe mode. " +
55
- "For modal iframe mode, set iframeDisplayMode to 'modal'. " +
56
- "For non-iframe modes, use displayMode 'redirect' or 'new_tab'.", CivicAuthErrorCode.CONFIG_REQUIRED);
57
- }
58
- }
59
- //# sourceMappingURL=ConfigProcessor.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ConfigProcessor.js","sourceRoot":"","sources":["../../../../src/vanillajs/auth/config/ConfigProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAMvD,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,uBAAuB,CAAC;AAE/B;;GAEG;AACH,MAAM,UAAU,yBAAyB,CACvC,MAA6B;IAE7B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,CACnC,CAAC;QACJ,CAAC;IACH,CAAC;IAED,oDAAoD;IACpD,yCAAyC;IACzC,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,IAAI,QAAQ,CAAC;IACnD,MAAM,iBAAiB,GAAG,MAAM,CAAC,iBAAiB,CAAC;IAEnD,uCAAuC;IACvC,MAAM,cAAc,GAClB,WAAW,KAAK,QAAQ,IAAI,iBAAiB,KAAK,UAAU,CAAC;IAE/D,IAAI,cAAc,IAAI,CAAC,MAAM,CAAC,sBAAsB,EAAE,CAAC;QACrD,MAAM,IAAI,cAAc,CACtB,0EAA0E;YACxE,2DAA2D;YAC3D,gEAAgE,EAClE,kBAAkB,CAAC,eAAe,CACnC,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["import { LocalStorageAdapter } from \"../../../browser/storage.js\";\nimport { DEFAULT_SCOPES } from \"../../../constants.js\";\nimport type {\n CivicAuthClientConfig,\n ProcessedCivicAuthConfig,\n LoggingConfig,\n} from \"../types/AuthTypes.js\";\nimport {\n CivicAuthError,\n CivicAuthErrorCode,\n CIVIC_AUTH_CONSTANTS,\n} from \"../types/AuthTypes.js\";\n\n/**\n * Process the configuration with defaults and validation\n */\nexport function processConfigWithDefaults(\n config: CivicAuthClientConfig,\n): ProcessedCivicAuthConfig {\n // Validate required configuration\n validateRequiredConfig(config);\n\n const loggingConfig: LoggingConfig = {\n enabled: true,\n namespace: \"*\",\n level: \"debug\" as const,\n ...config.logging,\n };\n\n return {\n ...config,\n redirectUrl:\n config.redirectUrl ||\n `${window.location.origin}${window.location.pathname}`,\n oauthServerBaseUrl:\n config.oauthServerBaseUrl || \"https://auth.civic.com/oauth/\",\n scopes: config.scopes || DEFAULT_SCOPES,\n textSignals: config.textSignals || {\n success: \"Authentication successful!\",\n error: \"Authentication failed. Please try again.\",\n },\n displayMode: config.displayMode || \"iframe\",\n authProcessTimeout:\n config.authProcessTimeout ||\n CIVIC_AUTH_CONSTANTS.DEFAULT_AUTH_PROCESS_TIMEOUT,\n iframeId: config.iframeId || CIVIC_AUTH_CONSTANTS.DEFAULT_IFRAME_ID,\n prompt: \"consent\",\n logging: loggingConfig,\n storageAdapter: config.storageAdapter || new LocalStorageAdapter(),\n };\n}\n\n/**\n * Validates required configuration properties\n */\nfunction validateRequiredConfig(config: CivicAuthClientConfig): void {\n // Always required configurations\n const requiredConfigs = [{ key: \"clientId\", value: config.clientId }];\n\n // Validate always-required fields\n for (const { key, value } of requiredConfigs) {\n if (!value) {\n throw new CivicAuthError(\n `CivicAuth: ${key} is required.`,\n CivicAuthErrorCode.CONFIG_REQUIRED,\n );\n }\n }\n\n // Conditional validation for targetContainerElement\n // Only required for embedded iframe mode\n const displayMode = config.displayMode || \"iframe\";\n const iframeDisplayMode = config.iframeDisplayMode;\n\n // Check if we need a container element\n const needsContainer =\n displayMode === \"iframe\" && iframeDisplayMode === \"embedded\";\n\n if (needsContainer && !config.targetContainerElement) {\n throw new CivicAuthError(\n \"CivicAuth: targetContainerElement is required for embedded iframe mode. \" +\n \"For modal iframe mode, set iframeDisplayMode to 'modal'. \" +\n \"For non-iframe modes, use displayMode 'redirect' or 'new_tab'.\",\n CivicAuthErrorCode.CONFIG_REQUIRED,\n );\n }\n}\n"]}
@@ -1,40 +0,0 @@
1
- import type { AuthResult } from "../../types/index.js";
2
- import type { ProcessedCivicAuthConfig } from "../types/AuthTypes.js";
3
- import { IframeManager } from "../../iframe/IframeManager.js";
4
- import type { createLogger } from "../../utils/logger.js";
5
- export interface IframeAuthHandlerConfig {
6
- config: ProcessedCivicAuthConfig;
7
- logger: ReturnType<typeof createLogger>;
8
- onAuthSuccess: (result: AuthResult) => void;
9
- onAuthError: (error: Error) => void;
10
- cleanup: () => void;
11
- messageHandler: (event: MessageEvent) => void;
12
- }
13
- export declare class IframeAuthHandler {
14
- private config;
15
- private logger;
16
- private onAuthSuccess;
17
- private onAuthError;
18
- private cleanup;
19
- private messageHandler;
20
- private iframeManager?;
21
- private iframeElement?;
22
- private signalObserver?;
23
- constructor(handlerConfig: IframeAuthHandlerConfig);
24
- handleIframeAuth(fullAuthUrl: string): Promise<HTMLIFrameElement>;
25
- getIframeManager(): IframeManager | undefined;
26
- getIframeElement(): HTMLIFrameElement | undefined;
27
- cleanupIframe(): void;
28
- private cleanupDynamicModalContainer;
29
- private createModalContainer;
30
- private getContainerElement;
31
- private determineIframeDisplayMode;
32
- private setupIframeEventHandlers;
33
- private checkAndHideNonLoginContent;
34
- private checkIframeRedirect;
35
- private setupSignalObserver;
36
- private setupIframeNavigationMonitoring;
37
- private processCallbackUrl;
38
- navigateIframe(url: string): void;
39
- }
40
- //# sourceMappingURL=IframeAuthHandler.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IframeAuthHandler.d.ts","sourceRoot":"","sources":["../../../../src/vanillajs/auth/handlers/IframeAuthHandler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAGtE,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAG1D,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,wBAAwB,CAAC;IACjC,MAAM,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;IACxC,aAAa,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;IAC5C,WAAW,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACpC,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,cAAc,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;CAC/C;AAED,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,MAAM,CAA2B;IACzC,OAAO,CAAC,MAAM,CAAiC;IAC/C,OAAO,CAAC,aAAa,CAA+B;IACpD,OAAO,CAAC,WAAW,C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