@econneq/gql-auth 1.2.6 → 1.2.8
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/client.js +2 -2
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/upload-gql.d.ts +0 -1
- package/dist/upload-gql.d.ts.map +1 -1
- package/dist/upload-gql.js +8 -8
- package/package.json +1 -1
package/dist/client.js
CHANGED
|
@@ -6,7 +6,7 @@ export default async function getApolloClient(options, domain, config) {
|
|
|
6
6
|
throw new Error("Configuration is required for getApolloClient");
|
|
7
7
|
const isServer = typeof window === "undefined";
|
|
8
8
|
const { Subdomains } = config;
|
|
9
|
-
const apiKey = process.env.API_KEY || "";
|
|
9
|
+
// const apiKey = process.env.API_KEY || "";
|
|
10
10
|
const urlDomain = process.env.NEXT_PUBLIC_DOMAIN_URL || process.env.DOMAIN_URL; // e.g e-conneq.com
|
|
11
11
|
const protocol = process.env.NEXT_PUBLIC_PROTOCOL || process.env.PROTOCOL; // e.g https:// or e.g http://
|
|
12
12
|
const urlBackEndInt = process.env.NEXT_PUBLIC_BACKEND_URL_INT || process.env.BACKEND_URL_INT; // e.g api:8000 (docker) or 127.0.0.1:8100 (VPS host) or localhost:8001 (local host)
|
|
@@ -39,7 +39,7 @@ export default async function getApolloClient(options, domain, config) {
|
|
|
39
39
|
const csrfToken = options?.csrfToken || (!isServer ? Cookies.get("csrftoken") : "");
|
|
40
40
|
const headers = {
|
|
41
41
|
'Content-Type': 'application/json',
|
|
42
|
-
'X-API-KEY': apiKey,
|
|
42
|
+
// 'X-API-KEY': apiKey,
|
|
43
43
|
...(options?.cookie && { 'Cookie': options.cookie }),
|
|
44
44
|
...(csrfToken && { 'X-CSRFToken': csrfToken }),
|
|
45
45
|
...(tenant && {
|
package/dist/index.d.ts
CHANGED
|
@@ -3,10 +3,7 @@ import { ApiFactory } from './api-factory.js';
|
|
|
3
3
|
import { uploadGraphQLMutation } from './upload-gql.js';
|
|
4
4
|
export { queryServerGraphQL, ApiFactory, uploadGraphQLMutation };
|
|
5
5
|
export type ConfigType = {
|
|
6
|
-
protocol: string;
|
|
7
|
-
RootApi: string;
|
|
8
6
|
Subdomains: SubdomainItem[];
|
|
9
|
-
apiKey: string;
|
|
10
7
|
fonts: string[];
|
|
11
8
|
};
|
|
12
9
|
export type SubdomainItem = {
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAExD,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,qBAAqB,EAAE,CAAC;AAIjE,MAAM,MAAM,UAAU,GAAG;IACvB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAExD,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,qBAAqB,EAAE,CAAC;AAIjE,MAAM,MAAM,UAAU,GAAG;IACvB,UAAU,EAAE,aAAa,EAAE,CAAC;IAC5B,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC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C,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,cAAc,EAAE,aAAa,EAAE,cAAc,EAC9C,MAAM,iBAAiB,CAAC"}
|
package/dist/upload-gql.d.ts
CHANGED
package/dist/upload-gql.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload-gql.d.ts","sourceRoot":"","sources":["../src/upload-gql.ts"],"names":[],"mappings":"AAAA,KAAK,iBAAiB,GAAG;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC/B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE;QACN,UAAU,EAAE;YAAE,SAAS,EAAE,MAAM,CAAC;YAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;YAAC,SAAS,EAAE,MAAM,CAAC;YAAC,QAAQ,EAAE,MAAM,CAAA;SAAE,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"upload-gql.d.ts","sourceRoot":"","sources":["../src/upload-gql.ts"],"names":[],"mappings":"AAAA,KAAK,iBAAiB,GAAG;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC/B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE;QACN,UAAU,EAAE;YAAE,SAAS,EAAE,MAAM,CAAC;YAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;YAAC,SAAS,EAAE,MAAM,CAAC;YAAC,QAAQ,EAAE,MAAM,CAAA;SAAE,EAAE,CAAC;KAC/F,CAAC;CACH,CAAC;AAEF,wBAAsB,qBAAqB,CAAC,EAC1C,KAAK,EACL,SAAS,EACT,OAAO,EACP,KAAK,EACL,MAAM,EACN,MAAM,EACP,EAAE,iBAAiB,gBAuEnB"}
|
package/dist/upload-gql.js
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
export async function uploadGraphQLMutation({ query, variables, fileMap, token, params, config }) {
|
|
2
2
|
const isServer = typeof window === "undefined";
|
|
3
|
-
const { Subdomains
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const host = production ? process.env.INTERNAL_API_URL : process.env.EXTERNAL_API_URL;
|
|
3
|
+
const { Subdomains } = config;
|
|
4
|
+
const BACKEND_URL_INT = process.env.BACKEND_URL_INT;
|
|
5
|
+
const API_KEY = process.env.API_KEY || "";
|
|
7
6
|
let API_LINK;
|
|
8
7
|
if (isServer) {
|
|
9
|
-
|
|
10
|
-
API_LINK = `/api/graphql/`;
|
|
8
|
+
API_LINK = `${BACKEND_URL_INT}/graphql/`;
|
|
11
9
|
}
|
|
12
10
|
else {
|
|
13
11
|
API_LINK = `/api/graphql`;
|
|
@@ -35,17 +33,19 @@ export async function uploadGraphQLMutation({ query, variables, fileMap, token,
|
|
|
35
33
|
// 3. Construct Headers
|
|
36
34
|
const headers = {
|
|
37
35
|
...(token ? { "Authorization": `Bearer ${token}` } : {}),
|
|
38
|
-
...(apiKey ? { "X-API-KEY": apiKey } : {}),
|
|
39
36
|
};
|
|
40
37
|
if (isServer) {
|
|
41
|
-
headers["Host"] =
|
|
38
|
+
headers["Host"] = BACKEND_URL_INT || "";
|
|
42
39
|
}
|
|
43
40
|
// Inject specific tenant metadata into headers for Django to read
|
|
44
41
|
if (tenantData) {
|
|
45
42
|
headers["X-Tenant-ID"] = String(tenantData.subdomain);
|
|
46
43
|
headers["X-Process-ID"] = tenantData.processId || "";
|
|
47
44
|
headers["X-Widget-ID"] = tenantData.widgetID || "";
|
|
45
|
+
headers["X-API-KEY"] = API_KEY || "";
|
|
48
46
|
}
|
|
47
|
+
if (!tenantData?.subdomain)
|
|
48
|
+
throw ("No Tenant Found ===================>");
|
|
49
49
|
const res = await fetch(API_LINK, {
|
|
50
50
|
method: "POST",
|
|
51
51
|
headers,
|