New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@nhost/nhost-js

Package Overview
Dependencies
Maintainers
3
Versions
172
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nhost/nhost-js - npm Package Compare versions

Comparing version 2.0.7 to 2.0.8

2

dist/clients/functions/index.d.ts

@@ -15,3 +15,3 @@ import { NhostClientConstructorParams } from '../../utils/types';

constructor(params: NhostFunctionsConstructorParams);
call<T = unknown, D = any>(url: string, data: D, config?: NhostFunctionCallConfig): Promise<NhostFunctionCallResponse<T>>;
call<T = unknown, D = any>(url: string, data: D | null, config?: NhostFunctionCallConfig): Promise<NhostFunctionCallResponse<T>>;
/**

@@ -18,0 +18,0 @@ * Use `nhost.functions.setAccessToken` to a set an access token to be used in subsequent functions requests. Note that if you're signin in users with `nhost.auth.signIn()` the access token will be set automatically.

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("@nhost/hasura-auth-js"),g=require("@nhost/hasura-storage-js"),C=require("isomorphic-unfetch"),S=require("@nhost/graphql-js"),A=/^((?<protocol>http[s]?):\/\/)?(?<host>localhost)(:(?<port>(\d+|__\w+__)))?$/;function h(t,e){const{backendUrl:s,subdomain:n,region:u}=t;if(s)return`${s}/v1/${e}`;if(!n)throw new Error("Either `backendUrl` or `subdomain` must be set.");const i=n.match(A);if(i!=null&&i.groups){const{protocol:r="http",host:o,port:d=1337}=i.groups,c=q(e);return c||`${r}://${o}:${d}/v1/${e}`}if(!u)throw new Error('`region` must be set when using a `subdomain` other than "localhost".');return`https://${n}.${e}.${u}.nhost.run/v1`}function y(){return typeof window<"u"}function m(){return typeof process<"u"&&process.env}function q(t){return y()||!m()?null:process.env[`NHOST_${t.toUpperCase()}_URL`]}function v(t,e){const n=e.startsWith("/")?e:`/${e}`;return t+n}function b(t){const e="subdomain"in t||"backendUrl"in t?h(t,"auth"):t.authUrl;if(!e)throw new Error("Please provide `subdomain` or `authUrl`.");return new f.HasuraAuthClient({url:e,...t})}function w(t){const e="subdomain"in t||"backendUrl"in t?h(t,"functions"):t.functionsUrl;if(!e)throw new Error("Please provide `subdomain` or `functionsUrl`.");return new p({url:e,...t})}class p{constructor(e){const{url:s,adminSecret:n}=e;this.url=s,this.accessToken=null,this.adminSecret=n}async call(e,s,n){const u={"Content-Type":"application/json",...this.generateAccessTokenHeaders(),...n==null?void 0:n.headers},i=v(this.url,e);try{const r=await C(i,{body:JSON.stringify(s),headers:u,method:"POST"});if(!r.ok)throw new Error(r.statusText);let o;return r.headers.get("content-type")==="application/json"?o=await r.json():o=await r.text(),{res:{data:o,status:r.status,statusText:r.statusText},error:null}}catch(r){const o=r;return{res:null,error:{message:o.message,status:o.name==="AbortError"?0:500,error:o.name==="AbortError"?"abort-error":"unknown"}}}}setAccessToken(e){if(!e){this.accessToken=null;return}this.accessToken=e}generateAccessTokenHeaders(){return this.adminSecret?{"x-hasura-admin-secret":this.adminSecret}:this.accessToken?{Authorization:`Bearer ${this.accessToken}`}:{}}}function k(t){const e="subdomain"in t||"backendUrl"in t?h(t,"graphql"):t.graphqlUrl;if(!e)throw new Error("Please provide `subdomain` or `graphqlUrl`.");return new S.NhostGraphqlClient({url:e,...t})}function T(t){const e="subdomain"in t||"backendUrl"in t?h(t,"storage"):t.storageUrl;if(!e)throw new Error("Please provide `subdomain` or `storageUrl`.");return new g.HasuraStorageClient({url:e,...t})}const E=t=>new U(t);class U{constructor({refreshIntervalTime:e,clientStorage:s,clientStorageType:n,autoRefreshToken:u,autoSignIn:i,adminSecret:r,devTools:o,start:d=!0,...c}){this.auth=b({refreshIntervalTime:e,clientStorage:s,clientStorageType:n,autoRefreshToken:u,autoSignIn:i,start:d,...c}),this.storage=T({adminSecret:r,...c}),this.functions=w({adminSecret:r,...c}),this.graphql=k({adminSecret:r,...c}),this.auth.onAuthStateChanged((a,l)=>{a==="SIGNED_OUT"&&(this.storage.setAccessToken(void 0),this.functions.setAccessToken(void 0),this.graphql.setAccessToken(void 0))}),this.auth.onTokenChanged(a=>{const l=a==null?void 0:a.accessToken;this.storage.setAccessToken(l),this.functions.setAccessToken(l),this.graphql.setAccessToken(l)}),this._adminSecret=r,this.devTools=o}get adminSecret(){return this._adminSecret}set adminSecret(e){this._adminSecret=e,this.storage.setAdminSecret(e)}}exports.NhostClient=U;exports.NhostFunctionsClient=p;exports.createAuthClient=b;exports.createFunctionsClient=w;exports.createGraphqlClient=k;exports.createNhostClient=E;exports.createStorageClient=T;for(const t in f)t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:()=>f[t]});for(const t in g)t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:()=>g[t]});
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("@nhost/hasura-auth-js"),g=require("@nhost/hasura-storage-js"),C=require("isomorphic-unfetch"),S=require("@nhost/graphql-js"),A=/^((?<protocol>http[s]?):\/\/)?(?<host>localhost)(:(?<port>(\d+|__\w+__)))?$/;function d(t,e){const{backendUrl:s,subdomain:r,region:a}=t;if(s)return`${s}/v1/${e}`;if(!r)throw new Error("Either `backendUrl` or `subdomain` must be set.");const c=r.match(A);if(c!=null&&c.groups){const{protocol:i="http",host:n,port:o=1337}=c.groups,u=v(e);return u||`${i}://${n}:${o}/v1/${e}`}if(!a)throw new Error('`region` must be set when using a `subdomain` other than "localhost".');return`https://${r}.${e}.${a}.nhost.run/v1`}function m(){return typeof window<"u"}function q(){return typeof process<"u"&&process.env}function v(t){return m()||!q()?null:process.env[`NHOST_${t.toUpperCase()}_URL`]}function y(t,e){const r=e.startsWith("/")?e:`/${e}`;return t+r}function b(t){const e="subdomain"in t||"backendUrl"in t?d(t,"auth"):t.authUrl;if(!e)throw new Error("Please provide `subdomain` or `authUrl`.");return new f.HasuraAuthClient({url:e,...t})}function w(t){const e="subdomain"in t||"backendUrl"in t?d(t,"functions"):t.functionsUrl;if(!e)throw new Error("Please provide `subdomain` or `functionsUrl`.");return new p({url:e,...t})}class p{constructor(e){const{url:s,adminSecret:r}=e;this.url=s,this.accessToken=null,this.adminSecret=r}async call(e,s,r){var i;const a={"Content-Type":"application/json",...this.generateAccessTokenHeaders(),...r==null?void 0:r.headers},c=y(this.url,e);try{const n=await C(c,{body:s?JSON.stringify(s):null,headers:a,method:"POST"});if(!n.ok)throw new Error(n.statusText);let o;return(i=n.headers.get("content-type"))!=null&&i.includes("application/json")?o=await n.json():o=await n.text(),{res:{data:o,status:n.status,statusText:n.statusText},error:null}}catch(n){const o=n;return{res:null,error:{message:o.message,status:o.name==="AbortError"?0:500,error:o.name==="AbortError"?"abort-error":"unknown"}}}}setAccessToken(e){if(!e){this.accessToken=null;return}this.accessToken=e}generateAccessTokenHeaders(){return this.adminSecret?{"x-hasura-admin-secret":this.adminSecret}:this.accessToken?{Authorization:`Bearer ${this.accessToken}`}:{}}}function k(t){const e="subdomain"in t||"backendUrl"in t?d(t,"graphql"):t.graphqlUrl;if(!e)throw new Error("Please provide `subdomain` or `graphqlUrl`.");return new S.NhostGraphqlClient({url:e,...t})}function T(t){const e="subdomain"in t||"backendUrl"in t?d(t,"storage"):t.storageUrl;if(!e)throw new Error("Please provide `subdomain` or `storageUrl`.");return new g.HasuraStorageClient({url:e,...t})}const E=t=>new U(t);class U{constructor({refreshIntervalTime:e,clientStorage:s,clientStorageType:r,autoRefreshToken:a,autoSignIn:c,adminSecret:i,devTools:n,start:o=!0,...u}){this.auth=b({refreshIntervalTime:e,clientStorage:s,clientStorageType:r,autoRefreshToken:a,autoSignIn:c,start:o,...u}),this.storage=T({adminSecret:i,...u}),this.functions=w({adminSecret:i,...u}),this.graphql=k({adminSecret:i,...u}),this.auth.onAuthStateChanged((l,h)=>{l==="SIGNED_OUT"&&(this.storage.setAccessToken(void 0),this.functions.setAccessToken(void 0),this.graphql.setAccessToken(void 0))}),this.auth.onTokenChanged(l=>{const h=l==null?void 0:l.accessToken;this.storage.setAccessToken(h),this.functions.setAccessToken(h),this.graphql.setAccessToken(h)}),this._adminSecret=i,this.devTools=n}get adminSecret(){return this._adminSecret}set adminSecret(e){this._adminSecret=e,this.storage.setAdminSecret(e)}}exports.NhostClient=U;exports.NhostFunctionsClient=p;exports.createAuthClient=b;exports.createFunctionsClient=w;exports.createGraphqlClient=k;exports.createNhostClient=E;exports.createStorageClient=T;for(const t in f)t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:()=>f[t]});for(const t in g)t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:()=>g[t]});
//# sourceMappingURL=index.cjs.js.map

@@ -6,18 +6,18 @@ import { HasuraAuthClient as f } from "@nhost/hasura-auth-js";

import w from "isomorphic-unfetch";
import { NhostGraphqlClient as b } from "@nhost/graphql-js";
const T = /^((?<protocol>http[s]?):\/\/)?(?<host>localhost)(:(?<port>(\d+|__\w+__)))?$/;
function l(t, e) {
const { backendUrl: s, subdomain: n, region: u } = t;
import { NhostGraphqlClient as T } from "@nhost/graphql-js";
const b = /^((?<protocol>http[s]?):\/\/)?(?<host>localhost)(:(?<port>(\d+|__\w+__)))?$/;
function d(t, e) {
const { backendUrl: s, subdomain: r, region: a } = t;
if (s)
return `${s}/v1/${e}`;
if (!n)
if (!r)
throw new Error("Either `backendUrl` or `subdomain` must be set.");
const i = n.match(T);
if (i != null && i.groups) {
const { protocol: r = "http", host: o, port: d = 1337 } = i.groups, c = U(e);
return c || `${r}://${o}:${d}/v1/${e}`;
const c = r.match(b);
if (c != null && c.groups) {
const { protocol: i = "http", host: n, port: o = 1337 } = c.groups, u = U(e);
return u || `${i}://${n}:${o}/v1/${e}`;
}
if (!u)
if (!a)
throw new Error('`region` must be set when using a `subdomain` other than "localhost".');
return `https://${n}.${e}.${u}.nhost.run/v1`;
return `https://${r}.${e}.${a}.nhost.run/v1`;
}

@@ -34,7 +34,7 @@ function k() {

function m(t, e) {
const n = e.startsWith("/") ? e : `/${e}`;
return t + n;
const r = e.startsWith("/") ? e : `/${e}`;
return t + r;
}
function A(t) {
const e = "subdomain" in t || "backendUrl" in t ? l(t, "auth") : t.authUrl;
const e = "subdomain" in t || "backendUrl" in t ? d(t, "auth") : t.authUrl;
if (!e)

@@ -45,3 +45,3 @@ throw new Error("Please provide `subdomain` or `authUrl`.");

function S(t) {
const e = "subdomain" in t || "backendUrl" in t ? l(t, "functions") : t.functionsUrl;
const e = "subdomain" in t || "backendUrl" in t ? d(t, "functions") : t.functionsUrl;
if (!e)

@@ -53,26 +53,27 @@ throw new Error("Please provide `subdomain` or `functionsUrl`.");

constructor(e) {
const { url: s, adminSecret: n } = e;
this.url = s, this.accessToken = null, this.adminSecret = n;
const { url: s, adminSecret: r } = e;
this.url = s, this.accessToken = null, this.adminSecret = r;
}
async call(e, s, n) {
const u = {
async call(e, s, r) {
var i;
const a = {
"Content-Type": "application/json",
...this.generateAccessTokenHeaders(),
...n == null ? void 0 : n.headers
}, i = m(this.url, e);
...r == null ? void 0 : r.headers
}, c = m(this.url, e);
try {
const r = await w(i, {
body: JSON.stringify(s),
headers: u,
const n = await w(c, {
body: s ? JSON.stringify(s) : null,
headers: a,
method: "POST"
});
if (!r.ok)
throw new Error(r.statusText);
if (!n.ok)
throw new Error(n.statusText);
let o;
return r.headers.get("content-type") === "application/json" ? o = await r.json() : o = await r.text(), {
res: { data: o, status: r.status, statusText: r.statusText },
return (i = n.headers.get("content-type")) != null && i.includes("application/json") ? o = await n.json() : o = await n.text(), {
res: { data: o, status: n.status, statusText: n.statusText },
error: null
};
} catch (r) {
const o = r;
} catch (n) {
const o = n;
return {

@@ -104,9 +105,9 @@ res: null,

function E(t) {
const e = "subdomain" in t || "backendUrl" in t ? l(t, "graphql") : t.graphqlUrl;
const e = "subdomain" in t || "backendUrl" in t ? d(t, "graphql") : t.graphqlUrl;
if (!e)
throw new Error("Please provide `subdomain` or `graphqlUrl`.");
return new b({ url: e, ...t });
return new T({ url: e, ...t });
}
function v(t) {
const e = "subdomain" in t || "backendUrl" in t ? l(t, "storage") : t.storageUrl;
const e = "subdomain" in t || "backendUrl" in t ? d(t, "storage") : t.storageUrl;
if (!e)

@@ -121,9 +122,9 @@ throw new Error("Please provide `subdomain` or `storageUrl`.");

clientStorage: s,
clientStorageType: n,
autoRefreshToken: u,
autoSignIn: i,
adminSecret: r,
devTools: o,
start: d = !0,
...c
clientStorageType: r,
autoRefreshToken: a,
autoSignIn: c,
adminSecret: i,
devTools: n,
start: o = !0,
...u
}) {

@@ -133,13 +134,13 @@ this.auth = A({

clientStorage: s,
clientStorageType: n,
autoRefreshToken: u,
autoSignIn: i,
start: d,
...c
}), this.storage = v({ adminSecret: r, ...c }), this.functions = S({ adminSecret: r, ...c }), this.graphql = E({ adminSecret: r, ...c }), this.auth.onAuthStateChanged((a, h) => {
a === "SIGNED_OUT" && (this.storage.setAccessToken(void 0), this.functions.setAccessToken(void 0), this.graphql.setAccessToken(void 0));
}), this.auth.onTokenChanged((a) => {
const h = a == null ? void 0 : a.accessToken;
clientStorageType: r,
autoRefreshToken: a,
autoSignIn: c,
start: o,
...u
}), this.storage = v({ adminSecret: i, ...u }), this.functions = S({ adminSecret: i, ...u }), this.graphql = E({ adminSecret: i, ...u }), this.auth.onAuthStateChanged((l, h) => {
l === "SIGNED_OUT" && (this.storage.setAccessToken(void 0), this.functions.setAccessToken(void 0), this.graphql.setAccessToken(void 0));
}), this.auth.onTokenChanged((l) => {
const h = l == null ? void 0 : l.accessToken;
this.storage.setAccessToken(h), this.functions.setAccessToken(h), this.graphql.setAccessToken(h);
}), this._adminSecret = r, this.devTools = o;
}), this._adminSecret = i, this.devTools = n;
}

@@ -146,0 +147,0 @@ get adminSecret() {

{
"name": "@nhost/nhost-js",
"version": "2.0.7",
"version": "2.0.8",
"description": "Nhost JavaScript SDK",

@@ -5,0 +5,0 @@ "license": "MIT",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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