@econneq/gql-auth 1.2.3 → 1.2.4
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/authServer.d.ts +1 -1
- package/dist/authServer.d.ts.map +1 -1
- package/dist/authServer.js +1 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +21 -15
- package/dist/upload-gql.d.ts.map +1 -1
- package/dist/upload-gql.js +2 -1
- package/package.json +1 -1
package/dist/authServer.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { JwtPayload } from ".";
|
|
2
2
|
export declare const getServerToken: () => Promise<string | null>;
|
|
3
3
|
export declare const getServerUser: () => Promise<JwtPayload | null>;
|
|
4
|
-
export declare const getPermissions: (list: string[], access: number, action
|
|
4
|
+
export declare const getPermissions: (list: string[], access: number, action?: string) => boolean;
|
|
5
5
|
//# sourceMappingURL=authServer.d.ts.map
|
package/dist/authServer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authServer.d.ts","sourceRoot":"","sources":["../src/authServer.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,GAAG,CAAC;AAE/B,eAAO,MAAM,cAAc,8BAG1B,CAAC;AAEF,eAAO,MAAM,aAAa,kCAUzB,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,MAAM,MAAM,EAAE,EAAE,QAAQ,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"authServer.d.ts","sourceRoot":"","sources":["../src/authServer.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,GAAG,CAAC;AAE/B,eAAO,MAAM,cAAc,8BAG1B,CAAC;AAEF,eAAO,MAAM,aAAa,kCAUzB,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,MAAM,MAAM,EAAE,EAAE,QAAQ,MAAM,EAAE,SAAS,MAAM,YAqB7E,CAAC"}
|
package/dist/authServer.js
CHANGED
|
@@ -24,7 +24,7 @@ export const getPermissions = (list, access, action) => {
|
|
|
24
24
|
return list.some(entry => {
|
|
25
25
|
// If only num is provided, check if entry starts with that number followed by non-digits
|
|
26
26
|
if (access && !action) {
|
|
27
|
-
const regex = new RegExp(`^${access}
|
|
27
|
+
const regex = new RegExp(`^${access}(?!\\d)`);
|
|
28
28
|
return regex.test(entry);
|
|
29
29
|
}
|
|
30
30
|
// If both are provided, check for the exact combination
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAA2B,MAAM,gBAAgB,CAAC;AAGvE,wBAA8B,eAAe,CAC3C,OAAO,CAAC,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,EACjD,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,EACtB,MAAM,CAAC,EAAE;IACP,UAAU,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC3E,MAAM,EAAE,MAAM,CAAC;CAChB,GACA,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAA2B,MAAM,gBAAgB,CAAC;AAGvE,wBAA8B,eAAe,CAC3C,OAAO,CAAC,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,EACjD,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,EACtB,MAAM,CAAC,EAAE;IACP,UAAU,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC3E,MAAM,EAAE,MAAM,CAAC;CAChB,GACA,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAkE9B"}
|
package/dist/client.js
CHANGED
|
@@ -8,30 +8,36 @@ export default async function getApolloClient(options, domain, config) {
|
|
|
8
8
|
const { Subdomains } = config;
|
|
9
9
|
const apiKey = process.env.API_KEY || "";
|
|
10
10
|
const protocol = process.env.NEXT_PUBLIC_PROTOCOL || process.env.PROTOCOL;
|
|
11
|
-
const hostInt = process.env.NEXT_PUBLIC_INTERNAL_API_URL || process.env.INTERNAL_API_URL;
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
throw new Error("Env (INTERNAL_API_URL) is required");
|
|
15
|
-
if (!hostExt)
|
|
16
|
-
throw new Error("Env (EXTERNAL_API_URL) is required");
|
|
11
|
+
const hostInt = process.env.NEXT_PUBLIC_INTERNAL_API_URL || process.env.INTERNAL_API_URL; // e.g api:8000 (docker) or 127.0.0.1:8100 (VPS host) or localhost:8001 (local host)
|
|
12
|
+
const urlDomain = process.env.NEXT_PUBLIC_DOMAIN_URL || process.env.DOMAIN_URL; // e.g e-conneq.com
|
|
13
|
+
const urlBackEnd = process.env.NEXT_PUBLIC_BACKEND_URL || process.env.BACKEND_URL; // e.g https://admin.e-conneq.com
|
|
17
14
|
if (!protocol)
|
|
18
15
|
throw new Error("Env (PROTOCOL) is required");
|
|
16
|
+
if (!hostInt)
|
|
17
|
+
throw new Error("Env (INTERNAL_API_URL) is required");
|
|
18
|
+
if (!urlDomain)
|
|
19
|
+
throw new Error("Env (DOMAIN_URL) is required");
|
|
20
|
+
if (!urlBackEnd)
|
|
21
|
+
throw new Error("Env (BACKEND_URL) is required");
|
|
22
|
+
const tenant = domain
|
|
23
|
+
? Subdomains.find((s) => s.subdomain.toLowerCase() === domain.toLowerCase())
|
|
24
|
+
: null;
|
|
19
25
|
let uri;
|
|
20
26
|
let baseUrl;
|
|
21
|
-
|
|
27
|
+
const sourceHost = `${protocol}${tenant?.subdomain || "public"}.${urlDomain}`;
|
|
22
28
|
if (isServer) {
|
|
23
|
-
|
|
29
|
+
// Use the internal host for the physical connection
|
|
24
30
|
baseUrl = `http://${hostInt}`;
|
|
25
|
-
|
|
31
|
+
uri = `${baseUrl}/graphql/`;
|
|
26
32
|
}
|
|
27
33
|
else {
|
|
28
34
|
uri = "/api/graphql";
|
|
29
|
-
|
|
30
|
-
|
|
35
|
+
// Use the EXTERNAL host for the logical Identity (Host Header)
|
|
36
|
+
baseUrl = `${urlBackEnd}`;
|
|
31
37
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
38
|
+
console.log("uri", uri);
|
|
39
|
+
console.log("baseUrl", baseUrl);
|
|
40
|
+
console.log("sourceHost", sourceHost);
|
|
35
41
|
const csrfToken = options?.csrfToken || (!isServer ? Cookies.get("csrftoken") : "");
|
|
36
42
|
const headers = {
|
|
37
43
|
'Content-Type': 'application/json',
|
|
@@ -44,7 +50,7 @@ export default async function getApolloClient(options, domain, config) {
|
|
|
44
50
|
'X-Widget-ID': tenant?.widgetID || "",
|
|
45
51
|
}),
|
|
46
52
|
'Referer': baseUrl,
|
|
47
|
-
'Host': isServer ?
|
|
53
|
+
'Host': isServer ? sourceHost : window.location.host,
|
|
48
54
|
};
|
|
49
55
|
return new ApolloClient({
|
|
50
56
|
link: new HttpLink({
|
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;QAC9F,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;CACH,CAAC;AAEF,wBAAsB,qBAAqB,CAAC,EAC1C,KAAK,EACL,SAAS,EACT,OAAO,EACP,KAAK,EACL,MAAM,EACN,MAAM,EACP,EAAE,iBAAiB,
|
|
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;QAC9F,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;CACH,CAAC;AAEF,wBAAsB,qBAAqB,CAAC,EAC1C,KAAK,EACL,SAAS,EACT,OAAO,EACP,KAAK,EACL,MAAM,EACN,MAAM,EACP,EAAE,iBAAiB,gBAsEnB"}
|
package/dist/upload-gql.js
CHANGED
|
@@ -6,7 +6,8 @@ export async function uploadGraphQLMutation({ query, variables, fileMap, token,
|
|
|
6
6
|
const host = production ? process.env.INTERNAL_API_URL : process.env.EXTERNAL_API_URL;
|
|
7
7
|
let API_LINK;
|
|
8
8
|
if (isServer) {
|
|
9
|
-
API_LINK =
|
|
9
|
+
// API_LINK = `$http://${host}/graphql/`;
|
|
10
|
+
API_LINK = `/api/graphql/`;
|
|
10
11
|
}
|
|
11
12
|
else {
|
|
12
13
|
API_LINK = `/api/graphql`;
|