@authdog/remix-node 0.0.2 → 0.0.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.
package/dist/index.d.ts CHANGED
@@ -1,6 +1,16 @@
1
1
  import * as _remix_run_node from '@remix-run/node';
2
2
 
3
- declare const remixAuthLoader: ({ request, context }: {
3
+ declare const validateAndParsePublicKey: (publicKey: string) => any;
4
+ declare const fetchUserData: (identityHost: string, environmentId: string, token: string) => Promise<any>;
5
+ declare const createAuthResponse: (authenticatedUser: any, token: string, environmentId: string, request: Request) => _remix_run_node.TypedResponse<{
6
+ user: any;
7
+ isAuthenticated: boolean;
8
+ }>;
9
+ declare const authenticateWithCookies: (request: Request, publicKeyObj: any) => Promise<_remix_run_node.TypedResponse<{
10
+ user: any;
11
+ isAuthenticated: boolean;
12
+ }> | null>;
13
+ declare const remixAuthLoader: ({ request, context, }: {
4
14
  request: Request;
5
15
  context: Record<string, any>;
6
16
  }) => Promise<_remix_run_node.TypedResponse<{
@@ -10,4 +20,4 @@ declare const remixAuthLoader: ({ request, context }: {
10
20
  loading: boolean;
11
21
  }>>;
12
22
 
13
- export { remixAuthLoader };
23
+ export { authenticateWithCookies, createAuthResponse, fetchUserData, remixAuthLoader, validateAndParsePublicKey };
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import{json as a}from"@remix-run/node";var l=async({request:i,context:u})=>{var p;let d=process.env.PK_AUTHDOG;if(!d)throw new Error("Public key is not defined");if(!d.startsWith("pk_"))throw new Error("Invalid public key");let e=JSON.parse(Buffer.from(d.replace("pk_",""),"base64").toString("utf-8")),h=new URL(i.url).searchParams.get("token");if(h){let r=await fetch(`${e==null?void 0:e.identityHost}/oidc/${e==null?void 0:e.environmentId}/userinfo`,{headers:{authorization:`Bearer ${h}`}});if(!r.ok)throw new Error("Failed to fetch user info");let o=await r.json();if(o!=null&&o.meta&&((p=o==null?void 0:o.meta)==null?void 0:p.code)===200){let c=a({user:o.user,isAuthenticated:!0}),n=new Headers(c.headers),t=JSON.stringify(o==null?void 0:o.user),s=h;n.append("Set-Cookie",`user_session_${e==null?void 0:e.environmentId}=${encodeURIComponent(t)}; Path=/; HttpOnly; Secure; SameSite=Strict`),n.append("Set-Cookie",`user_session_hash_${e==null?void 0:e.environmentId}=${encodeURIComponent(s)}; Path=/; HttpOnly; Secure; SameSite=Strict`),n.append("Location",new URL(i.url).toString().replace(/([?&])token=[^&]*/,"$1").replace(/([?&])$/,"").replace(/([?&])$/,"")),u[`user_session_${e==null?void 0:e.environmentId}`]=t,u[`user_session_hash_${e==null?void 0:e.environmentId}`]=s;let m=new URL(i.url);return m.searchParams.delete("token"),n.append("Location",m.toString()),n.append("Cache-Control","no-store, no-cache, must-revalidate, proxy-revalidate"),n.append("Pragma","no-cache"),n.append("Expires","0"),n.append("Vary","Cookie"),n.append("Content-Type","application/json"),n.append("Access-Control-Allow-Origin","*"),n.append("Access-Control-Allow-Credentials","true"),a({user:o.user,isAuthenticated:!0},{headers:n})}}else try{let r=i.headers.get("Cookie");if(!r)return a({user:null,isAuthenticated:!1});let c=r.split(";").map(n=>{let[t,s]=n.trim().split("=");return{name:t,value:s}}).find(n=>n.name===`user_session_hash_${e==null?void 0:e.environmentId}`);if(c){let n=c.value,t=await fetch(`${e==null?void 0:e.identityHost}/oidc/${e==null?void 0:e.environmentId}/userinfo`,{headers:{authorization:`Bearer ${n}`}});if(!t.ok)throw new Error("Failed to fetch user info");let s=await t.json();return a({user:s.user,isAuthenticated:!0})}}catch(r){console.error("Error authenticating with cookies:",r)}return a({loading:!0})};export{l as remixAuthLoader};
1
+ import{json as i}from"@remix-run/node";import{parseCookies as h}from"@authdog/node-commons";var f=r=>{if(!r)throw new Error("Public key is not defined");if(!r.startsWith("pk_"))throw new Error("Invalid public key");return JSON.parse(Buffer.from(r.replace("pk_",""),"base64").toString("utf-8"))},u=async(r,s,t)=>{let e=await fetch(`${r}/oidc/${s}/userinfo`,{headers:{authorization:`Bearer ${t}`}});if(!e.ok)throw new Error("Failed to fetch user info");return e.json()},m=(r,s,t,e)=>{let a=i({user:r.user,isAuthenticated:!0}),n=new Headers(a.headers),o=JSON.stringify(r==null?void 0:r.user),c=s;n.append("Set-Cookie",`user_session_${t}=${encodeURIComponent(o)}; Path=/; HttpOnly; Secure; SameSite=Strict`),n.append("Set-Cookie",`user_session_hash_${t}=${encodeURIComponent(c)}; Path=/; HttpOnly; Secure; SameSite=Strict`);let d=new URL(e.url);return d.searchParams.delete("token"),n.append("Location",d.toString()),n.append("Cache-Control","no-store, no-cache, must-revalidate, proxy-revalidate"),n.append("Pragma","no-cache"),n.append("Expires","0"),n.append("Vary","Cookie"),n.append("Content-Type","application/json"),n.append("Access-Control-Allow-Origin","*"),n.append("Access-Control-Allow-Credentials","true"),i({user:r.user,isAuthenticated:!0},{headers:n})},p=async(r,s)=>{try{let t=r.headers.get("Cookie"),e=h(t);if(e.length===0)return i({user:null,isAuthenticated:!1});let a=e.find(n=>n.name===`user_session_hash_${s==null?void 0:s.environmentId}`);if(a){let n=a.value,o=await u(s==null?void 0:s.identityHost,s==null?void 0:s.environmentId,n);return i({user:o.user,isAuthenticated:!0})}}catch(t){console.error("Error authenticating with cookies:",t)}return null},k=async({request:r,context:s})=>{var n;let t=process.env.PK_AUTHDOG,e=f(t),a=new URL(r.url).searchParams.get("token");if(a){let o=await u(e==null?void 0:e.identityHost,e==null?void 0:e.environmentId,a);if(o!=null&&o.meta&&((n=o==null?void 0:o.meta)==null?void 0:n.code)===200){let c=JSON.stringify(o==null?void 0:o.user);return s[`user_session_${e==null?void 0:e.environmentId}`]=c,s[`user_session_hash_${e==null?void 0:e.environmentId}`]=a,m(o,a,e==null?void 0:e.environmentId,r)}}else{let o=await p(r,e);if(o)return o}return i({loading:!0})};export{p as authenticateWithCookies,m as createAuthResponse,u as fetchUserData,k as remixAuthLoader,f as validateAndParsePublicKey};
2
2
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import {\n json\n} from \"@remix-run/node\";\n\nexport const remixAuthLoader = async ({ request, context }: { request: Request; context: Record<string, any> }) => { \n const publicKey = process.env.PK_AUTHDOG as string;\n \n if (!publicKey) {\n throw new Error(\"Public key is not defined\");\n }\n \n if (!publicKey.startsWith(\"pk_\")) {\n throw new Error(\"Invalid public key\");\n }\n \n // Decode Base64-encoded publicKey\n const publicKeyObj = JSON.parse(\n Buffer.from(publicKey.replace(\"pk_\", \"\"), \"base64\").toString(\"utf-8\"),\n );\n \n // First check if we have a token in the URL\n const tokenFromUri = new URL(request.url).searchParams.get(\"token\");\n \n if (tokenFromUri) {\n // Handle token from URL\n const userData = await fetch(\n `${publicKeyObj?.identityHost}/oidc/${publicKeyObj?.environmentId}/userinfo`,\n {\n headers: {\n authorization: `Bearer ${tokenFromUri}`,\n },\n },\n );\n \n if (!userData.ok) {\n throw new Error(\"Failed to fetch user info\");\n }\n \n const authenticatedUser = await userData.json();\n \n // console.log(\"authenticatedUser\", authenticatedUser);\n \n if (authenticatedUser?.meta && authenticatedUser?.meta?.code === 200) {\n // Create response with cookies\n const response = json({\n user: authenticatedUser.user,\n isAuthenticated: true,\n });\n \n // Set cookies in the response headers\n const headers = new Headers(response.headers);\n \n // Serialize the user object separately\n const userSessionValue = JSON.stringify(authenticatedUser?.user);\n const userSessionHashValue = tokenFromUri;\n \n // Create cookie instances\n // const userSessionCookie = createCookie(`user_session_${publicKeyObj?.environmentId}`, {\n // path: \"/\",\n // httpOnly: true,\n // secure: true,\n // sameSite: \"strict\",\n // });\n \n // const userSessionHashCookie = createCookie(`user_session_hash_${publicKeyObj?.environmentId}`, {\n // path: \"/\",\n // httpOnly: true,\n // secure: true,\n // sameSite: \"strict\",\n // });\n \n headers.append(\n \"Set-Cookie\",\n `user_session_${publicKeyObj?.environmentId}=${encodeURIComponent(userSessionValue)}; Path=/; HttpOnly; Secure; SameSite=Strict`,\n // await userSessionCookie.serialize(userSessionValue)\n );\n headers.append(\n \"Set-Cookie\",\n `user_session_hash_${publicKeyObj?.environmentId}=${encodeURIComponent(userSessionHashValue)}; Path=/; HttpOnly; Secure; SameSite=Strict`,\n // await userSessionHashCookie.serialize(userSessionHashValue)\n );\n \n // newUrl = url without token\n \n // newUrl.searchParams.delete(\"token\");\n \n headers.append(\n \"Location\",\n // same uri without token\n new URL(request.url)\n .toString()\n .replace(/([?&])token=[^&]*/, \"$1\")\n .replace(/([?&])$/, \"\")\n .replace(/([?&])$/, \"\"),\n // new URL(request.url).toString()\n // .replace(/([?&])token=[^&]*/, \"$1\")\n );\n \n // Store in context for later use\n context[`user_session_${publicKeyObj?.environmentId}`] = userSessionValue;\n context[`user_session_hash_${publicKeyObj?.environmentId}`] =\n userSessionHashValue;\n \n // redirect to new URL without token\n const newUrl = new URL(request.url);\n newUrl.searchParams.delete(\"token\");\n headers.append(\"Location\", newUrl.toString());\n \n headers.append(\n \"Cache-Control\",\n \"no-store, no-cache, must-revalidate, proxy-revalidate\",\n );\n headers.append(\"Pragma\", \"no-cache\");\n headers.append(\"Expires\", \"0\");\n headers.append(\"Vary\", \"Cookie\");\n headers.append(\"Content-Type\", \"application/json\");\n headers.append(\"Access-Control-Allow-Origin\", \"*\");\n headers.append(\"Access-Control-Allow-Credentials\", \"true\");\n \n return json(\n {\n user: authenticatedUser.user,\n isAuthenticated: true,\n },\n {\n headers,\n },\n );\n \n // return json({\n // user: authenticatedUser.user,\n // isAuthenticated: true\n // }, {\n // headers\n // });\n }\n \n // return json({\n // user: null,\n // isAuthenticated: false\n // });\n } else {\n // Try to authenticate using cookies\n try {\n // Get cookies from request\n const cookieHeader = request.headers.get(\"Cookie\");\n \n // console.log(cookieHeader);\n \n if (!cookieHeader) {\n return json({\n user: null,\n isAuthenticated: false,\n });\n }\n \n // Parse cookies\n const cookies = cookieHeader.split(\";\").map((cookie) => {\n const [name, value] = cookie.trim().split(\"=\");\n return { name, value };\n });\n \n // console.log(\"cookies\", cookies);\n \n // Find our specific cookies\n // const userSessionCookie = cookies.find(c => c.name === `user_session_${publicKeyObj?.environmentId}`);\n const userSessionHashCookie = cookies.find(\n (c) => c.name === `user_session_hash_${publicKeyObj?.environmentId}`,\n );\n \n if (userSessionHashCookie) {\n // console.log(\"has cookies\");\n \n // Decode the URL-encoded cookie values\n const userSessionHashValue = userSessionHashCookie.value;\n \n // console.log(\"userSessionValue\", userSessionValue);\n // console.log(\"userSessionHashValue\", userSessionHashValue);\n \n const userData = await fetch(\n `${publicKeyObj?.identityHost}/oidc/${publicKeyObj?.environmentId}/userinfo`,\n {\n headers: {\n authorization: `Bearer ${userSessionHashValue}`,\n },\n },\n );\n if (!userData.ok) {\n throw new Error(\"Failed to fetch user info\");\n }\n const authenticatedUser = await userData.json();\n \n return json({\n user: authenticatedUser.user,\n isAuthenticated: true,\n });\n }\n } catch (error) {\n console.error(\"Error authenticating with cookies:\", error);\n }\n }\n \n return json({\n loading: true,\n });\n };"],"mappings":"AAAA,OACI,QAAAA,MACG,kBAEA,IAAMC,EAAkB,MAAO,CAAE,QAAAC,EAAS,QAAAC,CAAQ,IAA0D,CAJnH,IAAAC,EAKI,IAAMC,EAAY,QAAQ,IAAI,WAE9B,GAAI,CAACA,EACH,MAAM,IAAI,MAAM,2BAA2B,EAG7C,GAAI,CAACA,EAAU,WAAW,KAAK,EAC7B,MAAM,IAAI,MAAM,oBAAoB,EAItC,IAAMC,EAAe,KAAK,MACxB,OAAO,KAAKD,EAAU,QAAQ,MAAO,EAAE,EAAG,QAAQ,EAAE,SAAS,OAAO,CACtE,EAGME,EAAe,IAAI,IAAIL,EAAQ,GAAG,EAAE,aAAa,IAAI,OAAO,EAElE,GAAIK,EAAc,CAEhB,IAAMC,EAAW,MAAM,MACrB,GAAGF,GAAA,YAAAA,EAAc,YAAY,SAASA,GAAA,YAAAA,EAAc,aAAa,YACjE,CACE,QAAS,CACP,cAAe,UAAUC,CAAY,EACvC,CACF,CACF,EAEA,GAAI,CAACC,EAAS,GACZ,MAAM,IAAI,MAAM,2BAA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AE,CACF,CACF,CAQF,CAMF,KAEE,IAAI,CAEF,IAAMI,EAAeb,EAAQ,QAAQ,IAAI,QAAQ,EAIjD,GAAI,CAACa,EACH,OAAOf,EAAK,CACV,KAAM,KACN,gBAAiB,EACnB,CAAC,EAaH,IAAMgB,EATUD,EAAa,MAAM,GAAG,EAAE,IAAKE,GAAW,CACtD,GAAM,CAACC,EAAMC,CAAK,EAAIF,EAAO,KAAK,EAAE,MAAM,GAAG,EAC7C,MAAO,CAAE,KAAAC,EAAM,MAAAC,CAAM,CACvB,CAAC,EAMqC,KACnCC,GAAMA,EAAE,OAAS,qBAAqBd,GAAA,YAAAA,EAAc,aAAa,EACpE,EAEA,GAAIU,EAAuB,CAIzB,IAAMH,EAAuBG,EAAsB,MAK7CR,EAAW,MAAM,MACrB,GAAGF,GAAA,YAAAA,EAAc,YAAY,SAASA,GAAA,YAAAA,EAAc,aAAa,YACjE,CACE,QAAS,CACP,cAAe,UAAUO,CAAoB,EAC/C,CACF,CACF,EACA,GAAI,CAACL,EAAS,GACZ,MAAM,IAAI,MAAM,2BAA2B,EAE7C,IAAMC,EAAoB,MAAMD,EAAS,KAAK,EAE9C,OAAOR,EAAK,CACV,KAAMS,EAAkB,KACxB,gBAAiB,EACnB,CAAC,CACH,CACF,OAASY,EAAO,CACd,QAAQ,MAAM,qCAAsCA,CAAK,CAC3D,CAGF,OAAOrB,EAAK,CACV,QAAS,EACX,CAAC,CACH","names":["json","remixAuthLoader","request","context","_a","publicKey","publicKeyObj","tokenFromUri","userData","authenticatedUser","response","headers","userSessionValue","userSessionHashValue","newUrl","cookieHeader","userSessionHashCookie","cookie","name","value","c","error"]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { json } from \"@remix-run/node\";\n\nimport { parseCookies } from \"@authdog/node-commons\";\n\n// Helper function to validate and parse the public key\nexport const validateAndParsePublicKey = (publicKey: string) => {\n if (!publicKey) {\n throw new Error(\"Public key is not defined\");\n }\n\n if (!publicKey.startsWith(\"pk_\")) {\n throw new Error(\"Invalid public key\");\n }\n\n // Decode Base64-encoded publicKey\n return JSON.parse(\n Buffer.from(publicKey.replace(\"pk_\", \"\"), \"base64\").toString(\"utf-8\"),\n );\n};\n\n// Function to fetch user data from the identity host\nexport const fetchUserData = async (\n identityHost: string,\n environmentId: string,\n token: string,\n) => {\n const userData = await fetch(\n `${identityHost}/oidc/${environmentId}/userinfo`,\n {\n headers: {\n authorization: `Bearer ${token}`,\n },\n },\n );\n\n if (!userData.ok) {\n throw new Error(\"Failed to fetch user info\");\n }\n\n return userData.json();\n};\n\n// Function to create authentication response with cookies\nexport const createAuthResponse = (\n authenticatedUser: any,\n token: string,\n environmentId: string,\n request: Request,\n) => {\n // Create response with cookies\n const response = json({\n user: authenticatedUser.user,\n isAuthenticated: true,\n });\n\n // Set cookies in the response headers\n const headers = new Headers(response.headers);\n\n // Serialize the user object separately\n const userSessionValue = JSON.stringify(authenticatedUser?.user);\n const userSessionHashValue = token;\n\n headers.append(\n \"Set-Cookie\",\n `user_session_${environmentId}=${encodeURIComponent(userSessionValue)}; Path=/; HttpOnly; Secure; SameSite=Strict`,\n );\n headers.append(\n \"Set-Cookie\",\n `user_session_hash_${environmentId}=${encodeURIComponent(userSessionHashValue)}; Path=/; HttpOnly; Secure; SameSite=Strict`,\n );\n\n // Remove token from URL\n const newUrl = new URL(request.url);\n newUrl.searchParams.delete(\"token\");\n headers.append(\"Location\", newUrl.toString());\n\n // Add cache control headers\n headers.append(\n \"Cache-Control\",\n \"no-store, no-cache, must-revalidate, proxy-revalidate\",\n );\n headers.append(\"Pragma\", \"no-cache\");\n headers.append(\"Expires\", \"0\");\n headers.append(\"Vary\", \"Cookie\");\n headers.append(\"Content-Type\", \"application/json\");\n headers.append(\"Access-Control-Allow-Origin\", \"*\");\n headers.append(\"Access-Control-Allow-Credentials\", \"true\");\n\n return json(\n {\n user: authenticatedUser.user,\n isAuthenticated: true,\n },\n {\n headers,\n },\n );\n};\n\n// Function to authenticate with cookies\nexport const authenticateWithCookies = async (\n request: Request,\n publicKeyObj: any,\n) => {\n try {\n // Get cookies from request\n const cookieHeader = request.headers.get(\"Cookie\");\n const cookies = parseCookies(cookieHeader);\n\n if (cookies.length === 0) {\n return json({\n user: null,\n isAuthenticated: false,\n });\n }\n\n // Find our specific cookies\n const userSessionHashCookie = cookies.find(\n (c) => c.name === `user_session_hash_${publicKeyObj?.environmentId}`,\n );\n\n if (userSessionHashCookie) {\n const userSessionHashValue = userSessionHashCookie.value;\n const authenticatedUser = await fetchUserData(\n publicKeyObj?.identityHost,\n publicKeyObj?.environmentId,\n userSessionHashValue,\n );\n\n return json({\n user: authenticatedUser.user,\n isAuthenticated: true,\n });\n }\n } catch (error) {\n console.error(\"Error authenticating with cookies:\", error);\n }\n\n return null;\n};\n\n// Main loader function\nexport const remixAuthLoader = async ({\n request,\n context,\n}: {\n request: Request;\n context: Record<string, any>;\n}) => {\n const publicKey = process.env.PK_AUTHDOG as string;\n const publicKeyObj = validateAndParsePublicKey(publicKey);\n\n // First check if we have a token in the URL\n const tokenFromUri = new URL(request.url).searchParams.get(\"token\");\n\n if (tokenFromUri) {\n // Handle token from URL\n const authenticatedUser = await fetchUserData(\n publicKeyObj?.identityHost,\n publicKeyObj?.environmentId,\n tokenFromUri,\n );\n\n if (authenticatedUser?.meta && authenticatedUser?.meta?.code === 200) {\n // Store in context for later use\n const userSessionValue = JSON.stringify(authenticatedUser?.user);\n context[`user_session_${publicKeyObj?.environmentId}`] = userSessionValue;\n context[`user_session_hash_${publicKeyObj?.environmentId}`] =\n tokenFromUri;\n\n return createAuthResponse(\n authenticatedUser,\n tokenFromUri,\n publicKeyObj?.environmentId,\n request,\n );\n }\n } else {\n // Try to authenticate using cookies\n const cookieAuthResult = await authenticateWithCookies(\n request,\n publicKeyObj,\n );\n if (cookieAuthResult) {\n return cookieAuthResult;\n }\n }\n\n return json({\n loading: true,\n });\n};\n"],"mappings":"AAAA,OAAS,QAAAA,MAAY,kBAErB,OAAS,gBAAAC,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Aa,EAAE,EAAIJ,EACzDW,EAAQ,qBAAqBP,GAAA,YAAAA,EAAc,aAAa,EAAE,EACxDS,EAEKlB,EACLC,EACAiB,EACAT,GAAA,YAAAA,EAAc,cACdP,CACF,CACF,CACF,KAAO,CAEL,IAAMiB,EAAmB,MAAMX,EAC7BN,EACAO,CACF,EACA,GAAIU,EACF,OAAOA,CAEX,CAEA,OAAO5B,EAAK,CACV,QAAS,EACX,CAAC,CACH","names":["json","parseCookies","validateAndParsePublicKey","publicKey","fetchUserData","identityHost","environmentId","token","userData","createAuthResponse","authenticatedUser","request","response","headers","userSessionValue","userSessionHashValue","newUrl","authenticateWithCookies","publicKeyObj","cookieHeader","cookies","userSessionHashCookie","c","error","remixAuthLoader","context","_a","tokenFromUri","cookieAuthResult"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@authdog/remix-node",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "Authdog Remix SDK",
5
5
  "type": "module",
6
6
  "source": "src/index.ts",
@@ -20,7 +20,8 @@
20
20
  "access": "public"
21
21
  },
22
22
  "dependencies": {
23
- "@remix-run/node": "^2.15.2"
23
+ "@remix-run/node": "^2.15.2",
24
+ "@authdog/node-commons": "0.0.17"
24
25
  },
25
26
  "scripts": {
26
27
  "format": "prettier --config .prettierrc.json --write \"**/*.{ts,md}\"",