Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@clerk/fastify

Package Overview
Dependencies
Maintainers
9
Versions
2235
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@clerk/fastify - npm Package Compare versions

Comparing version 0.1.12-staging.6 to 0.1.12-staging.7

2

dist/esm/index.js
var b=Object.create;var k=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var L=Object.getPrototypeOf,I=Object.prototype.hasOwnProperty;var H=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var N=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of O(t))!I.call(e,n)&&n!==o&&k(e,n,{get:()=>t[n],enumerable:!(r=T(t,n))||r.enumerable});return e};var U=(e,t,o)=>(o=e!=null?b(L(e)):{},N(t||!e||!e.__esModule?k(o,"default",{value:e,enumerable:!0}):o,e));var R=H(y=>{"use strict";y.parse=D;y.serialize=M;var Y=Object.prototype.toString,u=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;function D(e,t){if(typeof e!="string")throw new TypeError("argument str must be a string");for(var o={},r=t||{},n=r.decode||j,s=0;s<e.length;){var i=e.indexOf("=",s);if(i===-1)break;var a=e.indexOf(";",s);if(a===-1)a=e.length;else if(a<i){s=e.lastIndexOf(";",i-1)+1;continue}var p=e.slice(s,i).trim();if(o[p]===void 0){var f=e.slice(i+1,a).trim();f.charCodeAt(0)===34&&(f=f.slice(1,-1)),o[p]=W(f,n)}s=a+1}return o}function M(e,t,o){var r=o||{},n=r.encode||B;if(typeof n!="function")throw new TypeError("option encode is invalid");if(!u.test(e))throw new TypeError("argument name is invalid");var s=n(t);if(s&&!u.test(s))throw new TypeError("argument val is invalid");var i=e+"="+s;if(r.maxAge!=null){var a=r.maxAge-0;if(isNaN(a)||!isFinite(a))throw new TypeError("option maxAge is invalid");i+="; Max-Age="+Math.floor(a)}if(r.domain){if(!u.test(r.domain))throw new TypeError("option domain is invalid");i+="; Domain="+r.domain}if(r.path){if(!u.test(r.path))throw new TypeError("option path is invalid");i+="; Path="+r.path}if(r.expires){var p=r.expires;if(!V(p)||isNaN(p.valueOf()))throw new TypeError("option expires is invalid");i+="; Expires="+p.toUTCString()}if(r.httpOnly&&(i+="; HttpOnly"),r.secure&&(i+="; Secure"),r.priority){var f=typeof r.priority=="string"?r.priority.toLowerCase():r.priority;switch(f){case"low":i+="; Priority=Low";break;case"medium":i+="; Priority=Medium";break;case"high":i+="; Priority=High";break;default:throw new TypeError("option priority is invalid")}}if(r.sameSite){var c=typeof r.sameSite=="string"?r.sameSite.toLowerCase():r.sameSite;switch(c){case!0:i+="; SameSite=Strict";break;case"lax":i+="; SameSite=Lax";break;case"strict":i+="; SameSite=Strict";break;case"none":i+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}}return i}function j(e){return e.indexOf("%")!==-1?decodeURIComponent(e):e}function B(e){return encodeURIComponent(e)}function V(e){return Y.call(e)==="[object Date]"||e instanceof Date}function W(e,t){try{return t(e)}catch{return e}}});import q from"fastify-plugin";var x=U(R());import{Clerk as $}from"@clerk/backend";import{constants as z}from"@clerk/backend";var w=process.env.CLERK_API_URL||"https://api.clerk.dev",C=process.env.CLERK_API_VERSION||"v1",A=process.env.CLERK_API_KEY||"",d=process.env.CLERK_SECRET_KEY||"",m=process.env.CLERK_FRONTEND_API||"",v=process.env.CLERK_PUBLISHABLE_KEY||"",S=process.env.CLERK_JWT_KEY||"",{Cookies:g,Headers:l}=z;var _=$,h=_({secretKey:d,apiUrl:w,apiVersion:C,jwtKey:S});var E=e=>(Array.isArray(e)?e[0]:e)||void 0;var P=e=>async(t,o)=>{let r=(0,x.parse)(t.raw.headers.cookie||""),n=e.secretKey||d,s=e.publishableKey||v,i=r[g.Session],a=t.headers.authorization?.replace("Bearer ",""),p=E(t.headers["x-forwarded-port"]),f=E(t.headers["x-forwarded-host"]),c=await h.authenticateRequest({...e,secretKey:n,publishableKey:s,apiKey:A,frontendApi:m,cookieToken:i,headerToken:a,clientUat:r[g.ClientUat],origin:t.headers.origin||void 0,host:t.headers.host,forwardedPort:p,forwardedHost:f,referrer:t.headers.referer||void 0,userAgent:t.headers["user-agent"]||void 0});if(c.isUnknown){o.code(401).header(l.AuthReason,c.reason).header(l.AuthMessage,c.message).send();return}if(c.isInterstitial){let K=h.localInterstitial({publishableKey:s,frontendApi:m});o.code(401).header(l.AuthReason,c.reason).header(l.AuthMessage,c.message).type("text/html").send(K);return}t.auth=c.toAuth()};var G=(e,t,o)=>{e.decorateRequest("auth",null),e.addHook("preHandler",P(t)),o()},Q=q(G,{name:"@clerk/fastify",fastify:"4.x"});var X=e=>`\u{1F512} Clerk: ${e.trim()}
For more info, check out the docs: https://clerk.dev/docs,
For more info, check out the docs: https://clerk.com/docs,
or come say hi in our discord server: https://rebrand.ly/clerk-discord

@@ -5,0 +5,0 @@ `,F=X(`The "clerkPlugin" should be registered before using the "getAuth".

"use strict";var U=Object.create;var d=Object.defineProperty;var Y=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var M=Object.getPrototypeOf,j=Object.prototype.hasOwnProperty;var B=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),V=(e,t)=>{for(var o in t)d(e,o,{get:t[o],enumerable:!0})},w=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of D(t))!j.call(e,n)&&n!==o&&d(e,n,{get:()=>t[n],enumerable:!(r=Y(t,n))||r.enumerable});return e};var C=(e,t,o)=>(o=e!=null?U(M(e)):{},w(t||!e||!e.__esModule?d(o,"default",{value:e,enumerable:!0}):o,e)),W=e=>w(d({},"__esModule",{value:!0}),e);var A=B(m=>{"use strict";m.parse=J;m.serialize=$;var z=Object.prototype.toString,h=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;function J(e,t){if(typeof e!="string")throw new TypeError("argument str must be a string");for(var o={},r=t||{},n=r.decode||q,s=0;s<e.length;){var i=e.indexOf("=",s);if(i===-1)break;var a=e.indexOf(";",s);if(a===-1)a=e.length;else if(a<i){s=e.lastIndexOf(";",i-1)+1;continue}var p=e.slice(s,i).trim();if(o[p]===void 0){var f=e.slice(i+1,a).trim();f.charCodeAt(0)===34&&(f=f.slice(1,-1)),o[p]=X(f,n)}s=a+1}return o}function $(e,t,o){var r=o||{},n=r.encode||G;if(typeof n!="function")throw new TypeError("option encode is invalid");if(!h.test(e))throw new TypeError("argument name is invalid");var s=n(t);if(s&&!h.test(s))throw new TypeError("argument val is invalid");var i=e+"="+s;if(r.maxAge!=null){var a=r.maxAge-0;if(isNaN(a)||!isFinite(a))throw new TypeError("option maxAge is invalid");i+="; Max-Age="+Math.floor(a)}if(r.domain){if(!h.test(r.domain))throw new TypeError("option domain is invalid");i+="; Domain="+r.domain}if(r.path){if(!h.test(r.path))throw new TypeError("option path is invalid");i+="; Path="+r.path}if(r.expires){var p=r.expires;if(!Q(p)||isNaN(p.valueOf()))throw new TypeError("option expires is invalid");i+="; Expires="+p.toUTCString()}if(r.httpOnly&&(i+="; HttpOnly"),r.secure&&(i+="; Secure"),r.priority){var f=typeof r.priority=="string"?r.priority.toLowerCase():r.priority;switch(f){case"low":i+="; Priority=Low";break;case"medium":i+="; Priority=Medium";break;case"high":i+="; Priority=High";break;default:throw new TypeError("option priority is invalid")}}if(r.sameSite){var c=typeof r.sameSite=="string"?r.sameSite.toLowerCase():r.sameSite;switch(c){case!0:i+="; SameSite=Strict";break;case"lax":i+="; SameSite=Lax";break;case"strict":i+="; SameSite=Strict";break;case"none":i+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}}return i}function q(e){return e.indexOf("%")!==-1?decodeURIComponent(e):e}function G(e){return encodeURIComponent(e)}function Q(e){return z.call(e)==="[object Date]"||e instanceof Date}function X(e,t){try{return t(e)}catch{return e}}});var re={};V(re,{clerkClient:()=>u,clerkPlugin:()=>L,createClerkClient:()=>k,getAuth:()=>H});module.exports=W(re);var O=C(require("fastify-plugin"));var b=C(A());var K=require("@clerk/backend");var v=require("@clerk/backend"),S=process.env.CLERK_API_URL||"https://api.clerk.dev",_=process.env.CLERK_API_VERSION||"v1",x=process.env.CLERK_API_KEY||"",y=process.env.CLERK_SECRET_KEY||"",g=process.env.CLERK_FRONTEND_API||"",P=process.env.CLERK_PUBLISHABLE_KEY||"",F=process.env.CLERK_JWT_KEY||"",{Cookies:E,Headers:l}=v.constants;var k=K.Clerk,u=k({secretKey:y,apiUrl:S,apiVersion:_,jwtKey:F});var R=e=>(Array.isArray(e)?e[0]:e)||void 0;var T=e=>async(t,o)=>{let r=(0,b.parse)(t.raw.headers.cookie||""),n=e.secretKey||y,s=e.publishableKey||P,i=r[E.Session],a=t.headers.authorization?.replace("Bearer ",""),p=R(t.headers["x-forwarded-port"]),f=R(t.headers["x-forwarded-host"]),c=await u.authenticateRequest({...e,secretKey:n,publishableKey:s,apiKey:x,frontendApi:g,cookieToken:i,headerToken:a,clientUat:r[E.ClientUat],origin:t.headers.origin||void 0,host:t.headers.host,forwardedPort:p,forwardedHost:f,referrer:t.headers.referer||void 0,userAgent:t.headers["user-agent"]||void 0});if(c.isUnknown){o.code(401).header(l.AuthReason,c.reason).header(l.AuthMessage,c.message).send();return}if(c.isInterstitial){let N=u.localInterstitial({publishableKey:s,frontendApi:g});o.code(401).header(l.AuthReason,c.reason).header(l.AuthMessage,c.message).type("text/html").send(N);return}t.auth=c.toAuth()};var ee=(e,t,o)=>{e.decorateRequest("auth",null),e.addHook("preHandler",T(t)),o()},L=(0,O.default)(ee,{name:"@clerk/fastify",fastify:"4.x"});var te=e=>`\u{1F512} Clerk: ${e.trim()}
For more info, check out the docs: https://clerk.dev/docs,
For more info, check out the docs: https://clerk.com/docs,
or come say hi in our discord server: https://rebrand.ly/clerk-discord

@@ -5,0 +5,0 @@ `,I=te(`The "clerkPlugin" should be registered before using the "getAuth".

{
"name": "@clerk/fastify",
"version": "0.1.12-staging.6",
"version": "0.1.12-staging.7",
"license": "MIT",
"description": "Clerk.dev SDK for Fastify",
"description": "Clerk SDK for Fastify",
"keywords": [

@@ -30,4 +30,4 @@ "auth",

"dependencies": {
"@clerk/backend": "^0.14.0-staging.0",
"@clerk/types": "^3.31.0-staging.5",
"@clerk/backend": "^0.14.0-staging.1",
"@clerk/types": "^3.31.0-staging.6",
"cookies": "0.8.0"

@@ -58,5 +58,5 @@ },

},
"homepage": "https://clerk.dev/",
"homepage": "https://clerk.com/",
"sideEffects": false,
"gitHead": "00bc852a38c1bc5fc46e9f433c7279c9884108ba"
"gitHead": "f4788ffa77f6b0d00b2f261c4627b35f6f55aaf6"
}
<p align="center">
<a href="https://clerk.dev?utm_source=github&utm_medium=clerk_fastify" target="_blank" rel="noopener noreferrer">
<img src="https://images.clerk.dev/static/logo-light-mode-400x400.png" height="64">
<a href="https://clerk.com?utm_source=github&utm_medium=clerk_fastify" target="_blank" rel="noopener noreferrer">
<img src="https://images.clerk.com/static/logo-light-mode-400x400.png" height="64">
</a>

@@ -13,3 +13,3 @@ <br />

[![Chat on Discord](https://img.shields.io/discord/856971667393609759.svg?logo=discord)](https://discord.com/invite/b5rXHjAg7A)
[![Clerk documentation](https://img.shields.io/badge/documentation-clerk-green.svg)](https://clerk.dev/docs?utm_source=github&utm_medium=clerk_fastify)
[![Clerk documentation](https://img.shields.io/badge/documentation-clerk-green.svg)](https://clerk.com/docs?utm_source=github&utm_medium=clerk_fastify)
[![Follow on Twitter](https://img.shields.io/twitter/follow/ClerkDev?style=social)](https://twitter.com/intent/follow?screen_name=ClerkDev)

@@ -31,8 +31,8 @@

[Clerk](https://clerk.dev?utm_source=github&utm_medium=clerk_fastify) is the easiest way to add authentication and user management to your Fastify application. To gain a better understanding of the Clerk Backend API and SDK, refer to
the <a href="https://clerk.dev/docs/reference/node/getting-started?utm_source=github&utm_medium=clerk_fastify" target="_blank">Node SDK</a> and <a href="https://reference.clerk.dev/reference/backend-api-reference" target="_blank">Backend API</a> documentation.
[Clerk](https://clerk.com?utm_source=github&utm_medium=clerk_fastify) is the easiest way to add authentication and user management to your Fastify application. To gain a better understanding of the Clerk Backend API and SDK, refer to
the <a href="https://clerk.com/docs/reference/node/getting-started?utm_source=github&utm_medium=clerk_fastify" target="_blank">Node SDK</a> and <a href="https://clerk.com/docs/reference/backend-api" target="_blank">Backend API</a> documentation.
## Getting Started
To use this plugin you should first create a Clerk application and retrieve a `Secret Key` and a `Publishable Key` for you application (see [here](https://clerk.dev/docs/reference/node/getting-started#set-c-l-e-r-k-s-e-c-r-e-t-key)) to be used as environment variables `CLERK_PUBLISHABLE_KEY` & `CLERK_SECRET_KEY`.
To use this plugin you should first create a Clerk application and retrieve a `Secret Key` and a `Publishable Key` for you application (see [here](https://clerk.com/docs/reference/node/getting-started#set-c-l-e-r-k-s-e-c-r-e-t-key)) to be used as environment variables `CLERK_PUBLISHABLE_KEY` & `CLERK_SECRET_KEY`.

@@ -58,3 +58,3 @@ ### Prerequisites

Retrieve your Backend API key from the [API Keys](https://dashboard.clerk.dev/last-active?path=api-keys) screen in your Clerk dashboard and set it as an environment variable in a `.env` file:
Retrieve your Backend API key from the [API Keys](https://dashboard.clerk.com/last-active?path=api-keys) screen in your Clerk dashboard and set it as an environment variable in a `.env` file:

@@ -146,3 +146,3 @@ ```sh

- Open a [GitHub support issue](https://github.com/clerkinc/javascript/issues/new?assignees=&labels=question&template=ask_a_question.md&title=Support%3A+)
- Contact options listed on [our Support page](https://clerk.dev/support?utm_source=github&utm_medium=clerk_fastify)
- Contact options listed on [our Support page](https://clerk.com/support?utm_source=github&utm_medium=clerk_fastify)

@@ -149,0 +149,0 @@ ## Security

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc