@civic/auth 0.4.8-alpha.1 → 0.4.8-beta.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.
Files changed (52) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/dist/nextjs/config.d.ts +8 -27
  3. package/dist/nextjs/config.d.ts.map +1 -1
  4. package/dist/nextjs/config.js +1 -32
  5. package/dist/nextjs/config.js.map +1 -1
  6. package/dist/nextjs/hooks/useUserCookie.d.ts +2 -1
  7. package/dist/nextjs/hooks/useUserCookie.d.ts.map +1 -1
  8. package/dist/nextjs/hooks/useUserCookie.js +37 -19
  9. package/dist/nextjs/hooks/useUserCookie.js.map +1 -1
  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 +9 -7
  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 +3 -9
  16. package/dist/nextjs/routeHandler.js.map +1 -1
  17. package/dist/nextjs/utils.d.ts.map +1 -1
  18. package/dist/nextjs/utils.js +2 -1
  19. package/dist/nextjs/utils.js.map +1 -1
  20. package/dist/services/PKCE.d.ts.map +1 -1
  21. package/dist/services/PKCE.js +1 -6
  22. package/dist/services/PKCE.js.map +1 -1
  23. package/dist/shared/components/BlockDisplay.d.ts.map +1 -1
  24. package/dist/shared/components/BlockDisplay.js +3 -6
  25. package/dist/shared/components/BlockDisplay.js.map +1 -1
  26. package/dist/shared/components/CivicAuthIframe.d.ts.map +1 -1
  27. package/dist/shared/components/CivicAuthIframe.js +3 -6
  28. package/dist/shared/components/CivicAuthIframe.js.map +1 -1
  29. package/dist/shared/components/CivicAuthIframeContainer.d.ts.map +1 -1
  30. package/dist/shared/components/CivicAuthIframeContainer.js +2 -2
  31. package/dist/shared/components/CivicAuthIframeContainer.js.map +1 -1
  32. package/dist/shared/components/CivicAuthLogoutIframeContainer.d.ts.map +1 -1
  33. package/dist/shared/components/CivicAuthLogoutIframeContainer.js +2 -6
  34. package/dist/shared/components/CivicAuthLogoutIframeContainer.js.map +1 -1
  35. package/dist/shared/hooks/useSignIn.js +1 -1
  36. package/dist/shared/hooks/useSignIn.js.map +1 -1
  37. package/dist/shared/lib/BrowserCookieStorage.d.ts +8 -0
  38. package/dist/shared/lib/BrowserCookieStorage.d.ts.map +1 -1
  39. package/dist/shared/lib/BrowserCookieStorage.js +19 -3
  40. package/dist/shared/lib/BrowserCookieStorage.js.map +1 -1
  41. package/dist/shared/providers/SessionProvider.d.ts.map +1 -1
  42. package/dist/shared/providers/SessionProvider.js +2 -1
  43. package/dist/shared/providers/SessionProvider.js.map +1 -1
  44. package/dist/shared/version.d.ts +1 -1
  45. package/dist/shared/version.d.ts.map +1 -1
  46. package/dist/shared/version.js +1 -1
  47. package/dist/shared/version.js.map +1 -1
  48. package/package.json +18 -19
  49. package/dist/lib/cookies.d.ts +0 -7
  50. package/dist/lib/cookies.d.ts.map +0 -1
  51. package/dist/lib/cookies.js +0 -26
  52. package/dist/lib/cookies.js.map +0 -1
@@ -27,6 +27,11 @@ const cookieStringFromSettings = (settings) => {
27
27
  }
28
28
  return cookieSettings.trim();
29
29
  };
30
+ /**
31
+ * BrowserCookieStorage is a cookie storage implementation that works in the browser.
32
+ * It uses the document.cookie API to set and get cookies.
33
+ * Although retrieval of browser cookies is synchronous, the API is designed to be async for compatibility with other storage implementations.
34
+ */
30
35
  export class BrowserCookieStorage extends CookieStorage {
31
36
  constructor(config = {}) {
32
37
  super({
@@ -36,21 +41,32 @@ export class BrowserCookieStorage extends CookieStorage {
36
41
  ...config,
37
42
  });
38
43
  }
39
- async get(key) {
44
+ // Synchronous methods
45
+ getSync(key) {
40
46
  const encodedValue = documentObj()
41
47
  .cookie.split(";")
42
48
  .map(split("="))
43
49
  .find(([cookieKey]) => cookieKey?.trim() === key)?.[1];
44
50
  return encodedValue ? decodeURIComponent(encodedValue) : null;
45
51
  }
46
- async set(key, value, cookieConfigOverride = {}) {
52
+ setSync(key, value, cookieConfigOverride = {}) {
47
53
  const encodedValue = encodeURIComponent(value);
48
54
  const settings = { ...this.settings, ...cookieConfigOverride };
49
55
  const cookieString = cookieStringFromSettings(settings);
50
56
  documentObj().cookie = `${key}=${encodedValue}; ${cookieString}`;
51
57
  }
52
- async delete(key) {
58
+ deleteSync(key) {
53
59
  documentObj().cookie = `${key}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;`;
54
60
  }
61
+ // Async methods (for API compatibility)
62
+ async get(key) {
63
+ return this.getSync(key);
64
+ }
65
+ async set(key, value, cookieConfigOverride = {}) {
66
+ this.setSync(key, value, cookieConfigOverride);
67
+ }
68
+ async delete(key) {
69
+ this.deleteSync(key);
70
+ }
55
71
  }
56
72
  //# sourceMappingURL=BrowserCookieStorage.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BrowserCookieStorage.js","sourceRoot":"","sources":["../../../src/shared/lib/BrowserCookieStorage.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,GAEd,MAAM,yBAAyB,CAAC;AAGjC,4CAA4C;AAC5C,SAAS,WAAW;IAClB,IAAI,OAAO,UAAU,CAAC,MAAM,KAAK,WAAW;QAAE,OAAO,UAAU,CAAC,QAAQ,CAAC;IACzE,MAAM,KAAK,GAAG,IAAI,KAAK,EAAE,CAAC,KAAK,CAAC;IAChC,MAAM,IAAI,KAAK,CACb,gDAAgD,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CACzE,CAAC;AACJ,CAAC;AAED,MAAM,KAAK,GAAG,CAAC,SAAiB,EAAE,EAAE,CAAC,CAAC,GAAW,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;AAE3E,MAAM,wBAAwB,GAAG,CAAC,QAA+B,EAAU,EAAE;IAC3E,IAAI,cAAc,GAAG,EAAE,CAAC;IAExB,IAAI,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C,EAAE;QAEhD,MAAM,YAAY,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC;QAC/C,MAAM,QAAQ,GAAG,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,GAAG,oBAAoB,EAAE,CAAC;QAC/D,MAAM,YAAY,GAAG,wBAAwB,CAAC,QAAQ,CAAC,CAAC;QACxD,WAAW,EAAE,CAAC,MAAM,GAAG,GAAG,GAAG,IAAI,YAAY,KAAK,YAAY,EAAE,CAAC;IACnE,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,GAAW;QACtB,WAAW,EAAE,CAAC,MAAM,GAAG,GAAG,GAAG,mDAAmD,CAAC;IACnF,CAAC;CACF","sourcesContent":["import {\n CookieStorage,\n type CookieStorageSettings,\n} from \"@/shared/lib/storage.js\";\nimport type { CookieConfig } from \"./types.js\";\n\n// Ensure only runs in a browser environment\nfunction documentObj() {\n if (typeof globalThis.window !== \"undefined\") return globalThis.document;\n const stack = new Error().stack;\n throw new Error(\n \"Document is not available in this environment:\" + JSON.stringify(stack),\n );\n}\n\nconst split = (separator: string) => (str: string) => str.split(separator);\n\nconst cookieStringFromSettings = (settings: CookieStorageSettings): string => {\n let cookieSettings = \"\";\n\n if (settings.path) {\n cookieSettings += `Path=${settings.path}; `;\n }\n if (settings.expires) {\n cookieSettings += `Expires=${settings.expires}; `;\n }\n if (settings.secure) {\n cookieSettings += `Secure; `;\n }\n if (settings.httpOnly) {\n // HttpOnly cannot be set from client-side JavaScript, so this clause can be omitted.\n console.warn(\n \"HttpOnly cannot be set on client-side cookies. Ignoring this setting.\",\n );\n }\n if (settings.sameSite) {\n cookieSettings += `SameSite=${settings.sameSite}; `;\n }\n return cookieSettings.trim();\n};\nexport class BrowserCookieStorage extends CookieStorage {\n constructor(config: Partial<CookieStorageSettings> = {}) {\n super({\n // sensible browser defaults\n secure: false,\n httpOnly: false,\n ...config,\n });\n }\n\n async get(key: string): Promise<string | null> {\n const encodedValue = documentObj()\n .cookie.split(\";\")\n .map(split(\"=\"))\n .find(([cookieKey]) => cookieKey?.trim() === key)?.[1];\n\n return encodedValue ? decodeURIComponent(encodedValue) : null;\n }\n\n async set(\n key: string,\n value: string,\n cookieConfigOverride: Partial<CookieConfig> = {},\n ): Promise<void> {\n const encodedValue = encodeURIComponent(value);\n const settings = { ...this.settings, ...cookieConfigOverride };\n const cookieString = cookieStringFromSettings(settings);\n documentObj().cookie = `${key}=${encodedValue}; ${cookieString}`;\n }\n\n async delete(key: string): Promise<void> {\n documentObj().cookie = `${key}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;`;\n }\n}\n"]}
1
+ {"version":3,"file":"BrowserCookieStorage.js","sourceRoot":"","sources":["../../../src/shared/lib/BrowserCookieStorage.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,GAEd,MAAM,yBAAyB,CAAC;AAGjC,4CAA4C;AAC5C,SAAS,WAAW;IAClB,IAAI,OAAO,UAAU,CAAC,MAAM,KAAK,WAAW;QAAE,OAAO,UAAU,CAAC,QAAQ,CAAC;IACzE,MAAM,KAAK,GAAG,IAAI,KAAK,EAAE,CAAC,KAAK,CAAC;IAChC,MAAM,IAAI,KAAK,CACb,gDAAgD,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CACzE,CAAC;AACJ,CAAC;AAED,MAAM,KAAK,GAAG,CAAC,SAAiB,EAAE,EAAE,CAAC,CAAC,GAAW,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;AAE3E,MAAM,wBAAwB,GAAG,CAAC,QAA+B,EAAU,EAAE;IAC3E,IAAI,cAAc,GAAG,EAAE,CAAC;IAExB,IAAI,QAAQ,CAAC,IAAI,EAAE,CAAC;QAClB,cAAc,IAAI,QAAQ,QAAQ,CAAC,IAAI,IAAI,CAAC;IAC9C,CAAC;IACD,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC;QACrB,cAAc,IAAI,WAAW,QAAQ,CAAC,OAAO,IAAI,CAAC;I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,QAAQ,CAAC,CAAC;QACxD,WAAW,EAAE,CAAC,MAAM,GAAG,GAAG,GAAG,IAAI,YAAY,KAAK,YAAY,EAAE,CAAC;IACnE,CAAC;IAED,UAAU,CAAC,GAAW;QACpB,WAAW,EAAE,CAAC,MAAM,GAAG,GAAG,GAAG,mDAAmD,CAAC;IACnF,CAAC;IAED,wCAAwC;IACxC,KAAK,CAAC,GAAG,CAAC,GAAW;QACnB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC;IAED,KAAK,CAAC,GAAG,CACP,GAAW,EACX,KAAa,EACb,uBAA8C,EAAE;QAEhD,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,EAAE,oBAAoB,CAAC,CAAC;IACjD,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,GAAW;QACtB,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IACvB,CAAC;CACF","sourcesContent":["import {\n CookieStorage,\n type CookieStorageSettings,\n} from \"@/shared/lib/storage.js\";\nimport type { CookieConfig } from \"./types.js\";\n\n// Ensure only runs in a browser environment\nfunction documentObj() {\n if (typeof globalThis.window !== \"undefined\") return globalThis.document;\n const stack = new Error().stack;\n throw new Error(\n \"Document is not available in this environment:\" + JSON.stringify(stack),\n );\n}\n\nconst split = (separator: string) => (str: string) => str.split(separator);\n\nconst cookieStringFromSettings = (settings: CookieStorageSettings): string => {\n let cookieSettings = \"\";\n\n if (settings.path) {\n cookieSettings += `Path=${settings.path}; `;\n }\n if (settings.expires) {\n cookieSettings += `Expires=${settings.expires}; `;\n }\n if (settings.secure) {\n cookieSettings += `Secure; `;\n }\n if (settings.httpOnly) {\n // HttpOnly cannot be set from client-side JavaScript, so this clause can be omitted.\n console.warn(\n \"HttpOnly cannot be set on client-side cookies. Ignoring this setting.\",\n );\n }\n if (settings.sameSite) {\n cookieSettings += `SameSite=${settings.sameSite}; `;\n }\n return cookieSettings.trim();\n};\n/**\n * BrowserCookieStorage is a cookie storage implementation that works in the browser.\n * It uses the document.cookie API to set and get cookies.\n * Although retrieval of browser cookies is synchronous, the API is designed to be async for compatibility with other storage implementations.\n */\nexport class BrowserCookieStorage extends CookieStorage {\n constructor(config: Partial<CookieStorageSettings> = {}) {\n super({\n // sensible browser defaults\n secure: false,\n httpOnly: false,\n ...config,\n });\n }\n\n // Synchronous methods\n getSync(key: string): string | null {\n const encodedValue = documentObj()\n .cookie.split(\";\")\n .map(split(\"=\"))\n .find(([cookieKey]) => cookieKey?.trim() === key)?.[1];\n\n return encodedValue ? decodeURIComponent(encodedValue) : null;\n }\n\n setSync(\n key: string,\n value: string,\n cookieConfigOverride: Partial<CookieConfig> = {},\n ): void {\n const encodedValue = encodeURIComponent(value);\n const settings = { ...this.settings, ...cookieConfigOverride };\n const cookieString = cookieStringFromSettings(settings);\n documentObj().cookie = `${key}=${encodedValue}; ${cookieString}`;\n }\n\n deleteSync(key: string): void {\n documentObj().cookie = `${key}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;`;\n }\n\n // Async methods (for API compatibility)\n async get(key: string): Promise<string | null> {\n return this.getSync(key);\n }\n\n async set(\n key: string,\n value: string,\n cookieConfigOverride: Partial<CookieConfig> = {},\n ): Promise<void> {\n this.setSync(key, value, cookieConfigOverride);\n }\n\n async delete(key: string): Promise<void> {\n this.deleteSync(key);\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"SessionProvider.d.ts","sourceRoot":"","sources":["../../../src/shared/providers/SessionProvider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAwB,MAAM,OAAO,CAAC;AAE7C,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,EAAE,WAAW,GAAG,IAAI,CAAC;IACzB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;CACpB,CAAC;AAaF,QAAA,MAAM,cAAc,sCAAuD,CAAC;AAE5E,KAAK,kBAAkB,GAAG;IACxB,QAAQ,EAAE,SAAS,CAAC;IACpB,IAAI,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IAC1B,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC;IACrB,SAAS,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,QAAA,MAAM,eAAe,2BAA4B,kBAAkB,qDAYlE,CAAC;AAEF,YAAY,EAAE,kBAAkB,EAAE,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,CAAC"}
1
+ {"version":3,"file":"SessionProvider.d.ts","sourceRoot":"","sources":["../../../src/shared/providers/SessionProvider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAwB,MAAM,OAAO,CAAC;AAE7C,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,EAAE,WAAW,GAAG,IAAI,CAAC;IACzB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;CACpB,CAAC;AAcF,QAAA,MAAM,cAAc,sCAAuD,CAAC;AAE5E,KAAK,kBAAkB,GAAG;IACxB,QAAQ,EAAE,SAAS,CAAC;IACpB,IAAI,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IAC1B,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC;IACrB,SAAS,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,QAAA,MAAM,eAAe,2BAA4B,kBAAkB,qDAYlE,CAAC;AAEF,YAAY,EAAE,kBAAkB,EAAE,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,CAAC"}
@@ -9,7 +9,8 @@ const defaultSession = {
9
9
  displayMode: "iframe",
10
10
  },
11
11
  error: null,
12
- isLoading: false,
12
+ // initialise in loading state
13
+ isLoading: true,
13
14
  };
14
15
  // Context for exposing session specifically to the TokenProvider
15
16
  const SessionContext = createContext(defaultSession);
@@ -1 +1 @@
1
- {"version":3,"file":"SessionProvider.js","sourceRoot":"","sources":["../../../src/shared/providers/SessionProvider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAGb,OAAO,KAAK,EAAE,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAO7C,MAAM,cAAc,GAA0B;IAC5C,IAAI,EAAE;QACJ,aAAa,EAAE,KAAK;QACpB,OAAO,EAAE,SAAS;QAClB,WAAW,EAAE,SAAS;QACtB,WAAW,EAAE,QAAQ;KACtB;IACD,KAAK,EAAE,IAAI;IACX,SAAS,EAAE,KAAK;CACjB,CAAC;AAEF,iEAAiE;AACjE,MAAM,cAAc,GAAG,aAAa,CAAwB,cAAc,CAAC,CAAC;AAS5E,MAAM,eAAe,GAAG,CAAC,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAsB,EAAE,EAAE;IACrE,OAAO,CACL,KAAC,cAAc,CAAC,QAAQ,IACtB,KAAK,EAAE;YACL,GAAG,KAAK;YACR,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,IAAI;YACxB,KAAK,EAAE,KAAK,CAAC,KAAK,IAAI,IAAI;SAC3B,YAEA,QAAQ,GACe,CAC3B,CAAC;AACJ,CAAC,CAAC;AAGF,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,CAAC","sourcesContent":["\"use client\";\nimport type { SessionData } from \"@/types.js\";\nimport type { ReactNode } from \"react\";\nimport React, { createContext } from \"react\";\n\nexport type SessionProviderOutput = {\n data: SessionData | null;\n error: Error | null;\n isLoading: boolean;\n};\nconst defaultSession: SessionProviderOutput = {\n data: {\n authenticated: false,\n idToken: undefined,\n accessToken: undefined,\n displayMode: \"iframe\",\n },\n error: null,\n isLoading: false,\n};\n\n// Context for exposing session specifically to the TokenProvider\nconst SessionContext = createContext<SessionProviderOutput>(defaultSession);\n\ntype SessionContextType = {\n children: ReactNode;\n data?: SessionData | null;\n error?: Error | null;\n isLoading: boolean;\n};\n\nconst SessionProvider = ({ children, ...props }: SessionContextType) => {\n return (\n <SessionContext.Provider\n value={{\n ...props,\n data: props.data || null,\n error: props.error || null,\n }}\n >\n {children}\n </SessionContext.Provider>\n );\n};\n\nexport type { SessionContextType };\nexport { SessionProvider, SessionContext };\n"]}
1
+ {"version":3,"file":"SessionProvider.js","sourceRoot":"","sources":["../../../src/shared/providers/SessionProvider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAGb,OAAO,KAAK,EAAE,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAO7C,MAAM,cAAc,GAA0B;IAC5C,IAAI,EAAE;QACJ,aAAa,EAAE,KAAK;QACpB,OAAO,EAAE,SAAS;QAClB,WAAW,EAAE,SAAS;QACtB,WAAW,EAAE,QAAQ;KACtB;IACD,KAAK,EAAE,IAAI;IACX,8BAA8B;IAC9B,SAAS,EAAE,IAAI;CAChB,CAAC;AAEF,iEAAiE;AACjE,MAAM,cAAc,GAAG,aAAa,CAAwB,cAAc,CAAC,CAAC;AAS5E,MAAM,eAAe,GAAG,CAAC,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAsB,EAAE,EAAE;IACrE,OAAO,CACL,KAAC,cAAc,CAAC,QAAQ,IACtB,KAAK,EAAE;YACL,GAAG,KAAK;YACR,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,IAAI;YACxB,KAAK,EAAE,KAAK,CAAC,KAAK,IAAI,IAAI;SAC3B,YAEA,QAAQ,GACe,CAC3B,CAAC;AACJ,CAAC,CAAC;AAGF,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,CAAC","sourcesContent":["\"use client\";\nimport type { SessionData } from \"@/types.js\";\nimport type { ReactNode } from \"react\";\nimport React, { createContext } from \"react\";\n\nexport type SessionProviderOutput = {\n data: SessionData | null;\n error: Error | null;\n isLoading: boolean;\n};\nconst defaultSession: SessionProviderOutput = {\n data: {\n authenticated: false,\n idToken: undefined,\n accessToken: undefined,\n displayMode: \"iframe\",\n },\n error: null,\n // initialise in loading state\n isLoading: true,\n};\n\n// Context for exposing session specifically to the TokenProvider\nconst SessionContext = createContext<SessionProviderOutput>(defaultSession);\n\ntype SessionContextType = {\n children: ReactNode;\n data?: SessionData | null;\n error?: Error | null;\n isLoading: boolean;\n};\n\nconst SessionProvider = ({ children, ...props }: SessionContextType) => {\n return (\n <SessionContext.Provider\n value={{\n ...props,\n data: props.data || null,\n error: props.error || null,\n }}\n >\n {children}\n </SessionContext.Provider>\n );\n};\n\nexport type { SessionContextType };\nexport { SessionProvider, SessionContext };\n"]}
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "@civic/auth:0.4.8-alpha.1";
1
+ export declare const VERSION = "@civic/auth:0.4.8-beta.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,8BAA8B,CAAC"}
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/shared/version.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,OAAO,6BAA6B,CAAC"}
@@ -1,3 +1,3 @@
1
1
  // This is an auto-generated file. Do not edit.
2
- export const VERSION = "@civic/auth:0.4.8-alpha.1";
2
+ export const VERSION = "@civic/auth:0.4.8-beta.0";
3
3
  //# sourceMappingURL=version.js.map
@@ -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,2BAA2B,CAAC","sourcesContent":["// This is an auto-generated file. Do not edit.\n\nexport const VERSION = \"@civic/auth:0.4.8-alpha.1\";\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/shared/version.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAE/C,MAAM,CAAC,MAAM,OAAO,GAAG,0BAA0B,CAAC","sourcesContent":["// This is an auto-generated file. Do not edit.\n\nexport const VERSION = \"@civic/auth:0.4.8-beta.0\";\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@civic/auth",
3
- "version": "0.4.8-alpha.1",
3
+ "version": "0.4.8-beta.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -37,21 +37,8 @@
37
37
  "require": "./dist/server/index.js"
38
38
  }
39
39
  },
40
- "scripts": {
41
- "prebuild": "pnpm generate-version",
42
- "build": "tsc -p tsconfig.build.json --noEmit false $(if [ \"$WATCH_MODE\" = \"true\" ]; then echo \"--watch\"; fi) && tsc-alias -p tsconfig.build.json",
43
- "prepublishOnly": "pnpm generate-version && node ../../etc/scripts/prompt-changelog.js && pnpm build",
44
- "dev": "if [ \"$WATCH_MODE\" = \"true\" ]; then pnpm build; else echo \"WATCH_MODE is not set to true. Skipping build.\"; fi",
45
- "pretest": "pnpm generate-version",
46
- "test": "vitest",
47
- "lint": "eslint \"src/**/*.ts*\" \"test/**/*.ts*\" --max-warnings 0",
48
- "lint:fix": "pnpm lint --fix",
49
- "test:update": "vitest --update",
50
- "generate-version": "npx tsx ./generateVersion.ts"
51
- },
52
40
  "dependencies": {
53
41
  "@emotion/react": "^11.14.0",
54
- "@civic/iframe-resizer": "workspace:*",
55
42
  "debug": "^4.3.7",
56
43
  "eventemitter3": "^5.0.1",
57
44
  "jose": "^5.9.4",
@@ -59,11 +46,10 @@
59
46
  "picomatch": "^4.0.2",
60
47
  "ts-deepmerge": "^7.0.2",
61
48
  "usehooks-ts": "^3.1.0",
62
- "uuid": "^10.0.0"
49
+ "uuid": "^10.0.0",
50
+ "@civic/iframe-resizer": "0.1.2"
63
51
  },
64
52
  "devDependencies": {
65
- "@repo/eslint-config": "workspace:*",
66
- "@repo/typescript-config": "workspace:*",
67
53
  "@rollup/plugin-typescript": "^12.1.1",
68
54
  "@testing-library/jest-dom": "^6.5.0",
69
55
  "@testing-library/react": "16.0.1",
@@ -88,7 +74,9 @@
88
74
  "tsx": "^4.19.1",
89
75
  "vite": "^5",
90
76
  "vite-plugin-dts": "^4.2.3",
91
- "vitest": "^2.1.8"
77
+ "vitest": "^2.1.8",
78
+ "@repo/eslint-config": "0.0.0",
79
+ "@repo/typescript-config": "0.0.0"
92
80
  },
93
81
  "peerDependencies": {
94
82
  "next": "^14.2.25 || >=15.2.3",
@@ -101,5 +89,16 @@
101
89
  "react": {
102
90
  "optional": false
103
91
  }
92
+ },
93
+ "scripts": {
94
+ "prebuild": "pnpm generate-version",
95
+ "build": "tsc -p tsconfig.build.json --noEmit false $(if [ \"$WATCH_MODE\" = \"true\" ]; then echo \"--watch\"; fi) && tsc-alias -p tsconfig.build.json",
96
+ "dev": "if [ \"$WATCH_MODE\" = \"true\" ]; then pnpm build; else echo \"WATCH_MODE is not set to true. Skipping build.\"; fi",
97
+ "pretest": "pnpm generate-version",
98
+ "test": "vitest",
99
+ "lint": "eslint \"src/**/*.ts*\" \"test/**/*.ts*\" --max-warnings 0",
100
+ "lint:fix": "pnpm lint --fix",
101
+ "test:update": "vitest --update",
102
+ "generate-version": "npx tsx ./generateVersion.ts"
104
103
  }
105
- }
104
+ }
@@ -1,7 +0,0 @@
1
- declare const getWindowCookieValue: (requests: {
2
- key: string;
3
- window: Window;
4
- parseJson?: boolean;
5
- }[]) => Record<string, string | Record<string, unknown>> | null;
6
- export { getWindowCookieValue };
7
- //# sourceMappingURL=cookies.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cookies.d.ts","sourceRoot":"","sources":["../../src/lib/cookies.ts"],"names":[],"mappings":"AACA,QAAA,MAAM,oBAAoB,aACd;IACR,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,EAAE,4DAqBJ,CAAC;AAEF,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
@@ -1,26 +0,0 @@
1
- // TODO REMOVE IN FAVOUR OF BrowserCookieStorage.get
2
- const getWindowCookieValue = (requests) => {
3
- const cookie = window.document.cookie;
4
- if (!cookie)
5
- return null;
6
- const cookies = cookie.split(";");
7
- const response = {};
8
- for (const c of cookies) {
9
- const [name, value] = c.trim().split("=");
10
- const request = requests.find((r) => r.key === name);
11
- if (value && request) {
12
- try {
13
- const decodeURIComponentValue = decodeURIComponent(value);
14
- response[request.key] = request.parseJson
15
- ? JSON.parse(decodeURIComponentValue)
16
- : decodeURIComponentValue;
17
- }
18
- catch {
19
- response[request.key] = value;
20
- }
21
- }
22
- }
23
- return response;
24
- };
25
- export { getWindowCookieValue };
26
- //# sourceMappingURL=cookies.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cookies.js","sourceRoot":"","sources":["../../src/lib/cookies.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,MAAM,oBAAoB,GAAG,CAC3B,QAIG,EACH,EAAE;IACF,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;IACtC,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IACzB,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAClC,MAAM,QAAQ,GAAqD,EAAE,CAAC;IACtE,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;QACxB,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC1C,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,IAAI,CAAC,CAAC;QACrD,IAAI,KAAK,IAAI,OAAO,EAAE,CAAC;YACrB,IAAI,CAAC;gBACH,MAAM,uBAAuB,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC;gBAC1D,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,SAAS;oBACvC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,uBAAuB,CAAC;oBACrC,CAAC,CAAC,uBAAuB,CAAC;YAC9B,CAAC;YAAC,MAAM,CAAC;gBACP,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;YAChC,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AAEF,OAAO,EAAE,oBAAoB,EAAE,CAAC","sourcesContent":["// TODO REMOVE IN FAVOUR OF BrowserCookieStorage.get\nconst getWindowCookieValue = (\n requests: {\n key: string;\n window: Window;\n parseJson?: boolean;\n }[],\n) => {\n const cookie = window.document.cookie;\n if (!cookie) return null;\n const cookies = cookie.split(\";\");\n const response: Record<string, string | Record<string, unknown>> = {};\n for (const c of cookies) {\n const [name, value] = c.trim().split(\"=\");\n const request = requests.find((r) => r.key === name);\n if (value && request) {\n try {\n const decodeURIComponentValue = decodeURIComponent(value);\n response[request.key] = request.parseJson\n ? JSON.parse(decodeURIComponentValue)\n : decodeURIComponentValue;\n } catch {\n response[request.key] = value;\n }\n }\n }\n return response;\n};\n\nexport { getWindowCookieValue };\n"]}