@clerk/testing
Advanced tools
Comparing version 0.1.0-snapshot.v1b21f39 to 1.0.0-canary.v6a67bc9
@@ -1,2 +0,2 @@ | ||
import{isProductionFromSecretKey as c,parsePublishableKey as a}from"@clerk/shared/keys";import _ from"dotenv";var l="https://api.clerk.com/v1/testing_tokens",K=async r=>{let p=n=>{r?.debug&&console.log(`Clerk: ${n}`)};p("Setting up Clerk..."),_.config({path:[".env.local",".env"]});let o=r?.publishableKey||process.env.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY||process.env.VITE_CLERK_PUBLISHABLE_KEY||process.env.CLERK_PUBLISHABLE_KEY||process.env.GATSBY_CLERK_PUBLISHABLE_KEY||process.env.REACT_APP_CLERK_PUBLISHABLE_KEY||process.env.EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY,e=process.env.CLERK_SECRET_KEY,t=process.env.CLERK_TESTING_TOKEN;if(!o)throw new Error("You need to set the CLERK_PUBLISHABLE_KEY environment variable.");if(!e&&!t)throw new Error("You need to set the CLERK_SECRET_KEY or the CLERK_TESTING_TOKEN environment variable.");if(e&&!t){if(c(e))throw new Error("You are using a secret key from a production instance, but this helper only works for development instances.");let n={method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"}};p("Fetching testing token from Clerk Backend API...");let s=process.env.CLERK_API_URL,E=s?`${s}/v1/testing_tokens`:l;await fetch(E,n).then(i=>i.json()).then(i=>{t=i.token}).catch(i=>{throw new Error("Failed to fetch testing token from Clerk API. Error: "+i)})}process.env.CLERK_FAPI=r?.frontendApiUrl||a(o)?.frontendApi,process.env.CLERK_TESTING_TOKEN=t};var L="__clerk_testing_token",T=async({page:r,options:p})=>{let o=p?.frontendApiUrl||process.env.CLERK_FAPI;if(!o)throw new Error("The Frontend API URL is required to bypass bot protection.");let e=`https://${o}/v1/**/*`;await r.route(e,(t,n)=>{let s=new URL(n.url()),E=process.env.CLERK_TESTING_TOKEN;E&&s.searchParams.set(L,E),t.continue({url:s.toString()})})};export{K as clerkSetup,T as setupClerkTestingToken}; | ||
import{isProductionFromSecretKey as c,parsePublishableKey as a}from"@clerk/shared/keys";import _ from"dotenv";var l="https://api.clerk.com/v1/testing_tokens",K=async o=>{let p=n=>{o?.debug&&console.log(`Clerk: ${n}`)};p("Setting up Clerk..."),_.config({path:[".env.local",".env"]});let r=o?.publishableKey||process.env.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY||process.env.VITE_CLERK_PUBLISHABLE_KEY||process.env.CLERK_PUBLISHABLE_KEY||process.env.GATSBY_CLERK_PUBLISHABLE_KEY||process.env.REACT_APP_CLERK_PUBLISHABLE_KEY||process.env.EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY,e=process.env.CLERK_SECRET_KEY,t=process.env.CLERK_TESTING_TOKEN;if(!r)throw new Error("You need to set the CLERK_PUBLISHABLE_KEY environment variable.");if(!e&&!t)throw new Error("You need to set the CLERK_SECRET_KEY or the CLERK_TESTING_TOKEN environment variable.");if(e&&!t){if(c(e))throw new Error("You are using a secret key from a production instance, but Testing Tokens only work in development instances.");let n={method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"}};p("Fetching testing token from Clerk Backend API...");let s=process.env.CLERK_API_URL,E=s?`${s}/v1/testing_tokens`:l;await fetch(E,n).then(i=>i.json()).then(i=>{t=i.token}).catch(i=>{throw new Error("Failed to fetch testing token from Clerk API. Error: "+i)})}process.env.CLERK_FAPI=o?.frontendApiUrl||a(r)?.frontendApi,process.env.CLERK_TESTING_TOKEN=t};var L="__clerk_testing_token",T=async({page:o,options:p})=>{let r=p?.frontendApiUrl||process.env.CLERK_FAPI;if(!r)throw new Error("The Frontend API URL is required to bypass bot protection.");let e=`https://${r}/v1/**/*`;await o.route(e,(t,n)=>{let s=new URL(n.url()),E=process.env.CLERK_TESTING_TOKEN;E&&s.searchParams.set(L,E),t.continue({url:s.toString()})})};export{K as clerkSetup,T as setupClerkTestingToken}; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict";var T=Object.create;var c=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var h=Object.getPrototypeOf,g=Object.prototype.hasOwnProperty;var u=(e,t)=>{for(var r in t)c(e,r,{get:t[r],enumerable:!0})},_=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of C(t))!g.call(e,o)&&o!==r&&c(e,o,{get:()=>t[o],enumerable:!(n=P(t,o))||n.enumerable});return e};var k=(e,t,r)=>(r=e!=null?T(h(e)):{},_(t||!e||!e.__esModule?c(r,"default",{value:e,enumerable:!0}):r,e)),A=e=>_(c({},"__esModule",{value:!0}),e);var R={};u(R,{clerkSetup:()=>K,setupClerkTestingToken:()=>L});module.exports=A(R);var a=require("@clerk/shared/keys"),l=k(require("dotenv")),f="https://api.clerk.com/v1/testing_tokens",K=async e=>{let t=s=>{e?.debug&&console.log(`Clerk: ${s}`)};t("Setting up Clerk..."),l.default.config({path:[".env.local",".env"]});let r=e?.publishableKey||process.env.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY||process.env.VITE_CLERK_PUBLISHABLE_KEY||process.env.CLERK_PUBLISHABLE_KEY||process.env.GATSBY_CLERK_PUBLISHABLE_KEY||process.env.REACT_APP_CLERK_PUBLISHABLE_KEY||process.env.EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY,n=process.env.CLERK_SECRET_KEY,o=process.env.CLERK_TESTING_TOKEN;if(!r)throw new Error("You need to set the CLERK_PUBLISHABLE_KEY environment variable.");if(!n&&!o)throw new Error("You need to set the CLERK_SECRET_KEY or the CLERK_TESTING_TOKEN environment variable.");if(n&&!o){if((0,a.isProductionFromSecretKey)(n))throw new Error("You are using a secret key from a production instance, but this helper only works for development instances.");let s={method:"POST",headers:{Authorization:`Bearer ${n}`,"Content-Type":"application/json"}};t("Fetching testing token from Clerk Backend API...");let i=process.env.CLERK_API_URL,E=i?`${i}/v1/testing_tokens`:f;await fetch(E,s).then(p=>p.json()).then(p=>{o=p.token}).catch(p=>{throw new Error("Failed to fetch testing token from Clerk API. Error: "+p)})}process.env.CLERK_FAPI=e?.frontendApiUrl||(0,a.parsePublishableKey)(r)?.frontendApi,process.env.CLERK_TESTING_TOKEN=o};var v="__clerk_testing_token",L=async({page:e,options:t})=>{let r=t?.frontendApiUrl||process.env.CLERK_FAPI;if(!r)throw new Error("The Frontend API URL is required to bypass bot protection.");let n=`https://${r}/v1/**/*`;await e.route(n,(o,s)=>{let i=new URL(s.url()),E=process.env.CLERK_TESTING_TOKEN;E&&i.searchParams.set(v,E),o.continue({url:i.toString()})})};0&&(module.exports={clerkSetup,setupClerkTestingToken}); | ||
"use strict";var T=Object.create;var c=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var g=Object.getPrototypeOf,h=Object.prototype.hasOwnProperty;var k=(e,t)=>{for(var o in t)c(e,o,{get:t[o],enumerable:!0})},_=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of C(t))!h.call(e,r)&&r!==o&&c(e,r,{get:()=>t[r],enumerable:!(n=P(t,r))||n.enumerable});return e};var u=(e,t,o)=>(o=e!=null?T(g(e)):{},_(t||!e||!e.__esModule?c(o,"default",{value:e,enumerable:!0}):o,e)),A=e=>_(c({},"__esModule",{value:!0}),e);var R={};k(R,{clerkSetup:()=>K,setupClerkTestingToken:()=>L});module.exports=A(R);var a=require("@clerk/shared/keys"),l=u(require("dotenv")),f="https://api.clerk.com/v1/testing_tokens",K=async e=>{let t=s=>{e?.debug&&console.log(`Clerk: ${s}`)};t("Setting up Clerk..."),l.default.config({path:[".env.local",".env"]});let o=e?.publishableKey||process.env.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY||process.env.VITE_CLERK_PUBLISHABLE_KEY||process.env.CLERK_PUBLISHABLE_KEY||process.env.GATSBY_CLERK_PUBLISHABLE_KEY||process.env.REACT_APP_CLERK_PUBLISHABLE_KEY||process.env.EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY,n=process.env.CLERK_SECRET_KEY,r=process.env.CLERK_TESTING_TOKEN;if(!o)throw new Error("You need to set the CLERK_PUBLISHABLE_KEY environment variable.");if(!n&&!r)throw new Error("You need to set the CLERK_SECRET_KEY or the CLERK_TESTING_TOKEN environment variable.");if(n&&!r){if((0,a.isProductionFromSecretKey)(n))throw new Error("You are using a secret key from a production instance, but Testing Tokens only work in development instances.");let s={method:"POST",headers:{Authorization:`Bearer ${n}`,"Content-Type":"application/json"}};t("Fetching testing token from Clerk Backend API...");let i=process.env.CLERK_API_URL,E=i?`${i}/v1/testing_tokens`:f;await fetch(E,s).then(p=>p.json()).then(p=>{r=p.token}).catch(p=>{throw new Error("Failed to fetch testing token from Clerk API. Error: "+p)})}process.env.CLERK_FAPI=e?.frontendApiUrl||(0,a.parsePublishableKey)(o)?.frontendApi,process.env.CLERK_TESTING_TOKEN=r};var v="__clerk_testing_token",L=async({page:e,options:t})=>{let o=t?.frontendApiUrl||process.env.CLERK_FAPI;if(!o)throw new Error("The Frontend API URL is required to bypass bot protection.");let n=`https://${o}/v1/**/*`;await e.route(n,(r,s)=>{let i=new URL(s.url()),E=process.env.CLERK_TESTING_TOKEN;E&&i.searchParams.set(v,E),r.continue({url:i.toString()})})};0&&(module.exports={clerkSetup,setupClerkTestingToken}); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@clerk/testing", | ||
"version": "0.1.0-snapshot.v1b21f39", | ||
"version": "1.0.0-canary.v6a67bc9", | ||
"description": "Utilities to help you create E2E test suites for apps using Clerk", | ||
@@ -53,3 +53,3 @@ "keywords": [ | ||
"@clerk/shared": "2.0.0", | ||
"@clerk/types": "4.1.0-snapshot.v1b21f39", | ||
"@clerk/types": "4.1.0-canary.v6a67bc9", | ||
"dotenv": "16.4.5" | ||
@@ -56,0 +56,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
+ Added@clerk/types@4.1.0-canary.v6a67bc9(transitive)
- Removed@clerk/types@4.1.0-snapshot.v1b21f39(transitive)