@prismicio/e2e-tests-utils 2.0.0-alpha.6 → 2.0.0-alpha.7
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.
|
@@ -27,7 +27,8 @@ function transformUrl(baseUrl, subdomainPrefix) {
|
|
|
27
27
|
try {
|
|
28
28
|
const url = new URL(baseUrl);
|
|
29
29
|
const domainParts = url.hostname.split(".");
|
|
30
|
-
const
|
|
30
|
+
const mainDomain = domainParts.slice(-2).join(".");
|
|
31
|
+
const transformedHostname = `${subdomainPrefix}.${mainDomain}`;
|
|
31
32
|
return `${url.protocol}//${transformedHostname}`;
|
|
32
33
|
} catch (error) {
|
|
33
34
|
throw new Error(`Invalid URL: ${baseUrl}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authentication.cjs","sources":["../../../src/utils/authentication.ts"],"sourcesContent":["import axios from \"axios\";\n\nimport { logHttpResponse, logger } from \"./log\";\n\nexport async function login(\n\tbaseUrl: string,\n\temail: string,\n\tpassword: string,\n): Promise<{ token: string; cookies: string[] | undefined }> {\n\tconst profiler = logger.startTimer();\n\n\tconst payload = {\n\t\temail,\n\t\tpassword,\n\t};\n\n\tconst url = transformUrl(baseUrl, \"auth.internal\");\n\n\tconst response = await axios.post<{ access_token: string }>(\n\t\t`${url}/login-e2e`,\n\t\tpayload,\n\t\t{\n\t\t\theaders: {\n\t\t\t\t\"User-Agent\": \"prismic-cli/prismic-e2e-tests-utils\",\n\t\t\t\tAuthorization:\n\t\t\t\t\t\"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3NDE3ODQ5NDEsImF1ZCI6ImF1dGgwLWFjdGlvbnMiLCJpc3MiOiJwcmlzbWljLmlvIn0.1UPoVMXJSTWtsyNzK5XYftK_mW0ScVuXwCK69nsyf5c\",\n\t\t\t},\n\t\t},\n\t);\n\n\tif (response.status !== 200) {\n\t\tlogHttpResponse(response);\n\t\tthrow new Error(\"Could not obtain OAuth token, check your credentials\");\n\t}\n\n\tprofiler.done({ message: \"logged in via OAuth\" });\n\tconst token = response.data.access_token;\n\n\treturn { token, cookies: response.headers[\"set-cookie\"] };\n}\n\nfunction transformUrl(baseUrl: string, subdomainPrefix: string): string {\n
|
|
1
|
+
{"version":3,"file":"authentication.cjs","sources":["../../../src/utils/authentication.ts"],"sourcesContent":["import axios from \"axios\";\n\nimport { logHttpResponse, logger } from \"./log\";\n\nexport async function login(\n\tbaseUrl: string,\n\temail: string,\n\tpassword: string,\n): Promise<{ token: string; cookies: string[] | undefined }> {\n\tconst profiler = logger.startTimer();\n\n\tconst payload = {\n\t\temail,\n\t\tpassword,\n\t};\n\n\tconst url = transformUrl(baseUrl, \"auth.internal\");\n\n\tconst response = await axios.post<{ access_token: string }>(\n\t\t`${url}/login-e2e`,\n\t\tpayload,\n\t\t{\n\t\t\theaders: {\n\t\t\t\t\"User-Agent\": \"prismic-cli/prismic-e2e-tests-utils\",\n\t\t\t\tAuthorization:\n\t\t\t\t\t\"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3NDE3ODQ5NDEsImF1ZCI6ImF1dGgwLWFjdGlvbnMiLCJpc3MiOiJwcmlzbWljLmlvIn0.1UPoVMXJSTWtsyNzK5XYftK_mW0ScVuXwCK69nsyf5c\",\n\t\t\t},\n\t\t},\n\t);\n\n\tif (response.status !== 200) {\n\t\tlogHttpResponse(response);\n\t\tthrow new Error(\"Could not obtain OAuth token, check your credentials\");\n\t}\n\n\tprofiler.done({ message: \"logged in via OAuth\" });\n\tconst token = response.data.access_token;\n\n\treturn { token, cookies: response.headers[\"set-cookie\"] };\n}\n\nfunction transformUrl(baseUrl: string, subdomainPrefix: string): string {\n try {\n const url = new URL(baseUrl);\n const domainParts = url.hostname.split('.');\n\n // Ensure we retain only the main domain (e.g., \"platform-wroom.com\")\n const mainDomain = domainParts.slice(-2).join('.'); // Keeps last two parts of domain\n\n // Construct the new hostname with the custom prefix\n const transformedHostname = `${subdomainPrefix}.${mainDomain}`;\n\n // Construct and return the full URL with the new hostname\n return `${url.protocol}//${transformedHostname}`;\n } catch (error) {\n throw new Error(`Invalid URL: ${baseUrl}`)\n\t}\n}\n"],"names":["logger","logHttpResponse"],"mappings":";;;;AAIsB,eAAA,MACrB,SACA,OACA,UAAgB;AAEV,QAAA,WAAWA,WAAO;AAExB,QAAM,UAAU;AAAA,IACf;AAAA,IACA;AAAA,EAAA;AAGK,QAAA,MAAM,aAAa,SAAS,eAAe;AAEjD,QAAM,WAAW,MAAM,MAAM,KAC5B,GAAG,GAAG,cACN,SACA;AAAA,IACC,SAAS;AAAA,MACR,cAAc;AAAA,MACd,eACC;AAAA,IACD;AAAA,EAAA,CACD;AAGE,MAAA,SAAS,WAAW,KAAK;AAC5BC,QAAA,gBAAgB,QAAQ;AAClB,UAAA,IAAI,MAAM,sDAAsD;AAAA,EACvE;AAEA,WAAS,KAAK,EAAE,SAAS,sBAAuB,CAAA;AAC1C,QAAA,QAAQ,SAAS,KAAK;AAE5B,SAAO,EAAE,OAAO,SAAS,SAAS,QAAQ,YAAY;AACvD;AAEA,SAAS,aAAa,SAAiB,iBAAuB;AACxD,MAAA;AACI,UAAA,MAAM,IAAI,IAAI,OAAO;AAC3B,UAAM,cAAc,IAAI,SAAS,MAAM,GAAG;AAG1C,UAAM,aAAa,YAAY,MAAM,EAAE,EAAE,KAAK,GAAG;AAGjD,UAAM,sBAAsB,GAAG,eAAe,IAAI,UAAU;AAG5D,WAAO,GAAG,IAAI,QAAQ,KAAK,mBAAmB;AAAA,WACvC,OAAO;AACd,UAAM,IAAI,MAAM,gBAAgB,OAAO,EAAE;AAAA,EAC5C;AACD;;"}
|
|
@@ -25,7 +25,8 @@ function transformUrl(baseUrl, subdomainPrefix) {
|
|
|
25
25
|
try {
|
|
26
26
|
const url = new URL(baseUrl);
|
|
27
27
|
const domainParts = url.hostname.split(".");
|
|
28
|
-
const
|
|
28
|
+
const mainDomain = domainParts.slice(-2).join(".");
|
|
29
|
+
const transformedHostname = `${subdomainPrefix}.${mainDomain}`;
|
|
29
30
|
return `${url.protocol}//${transformedHostname}`;
|
|
30
31
|
} catch (error) {
|
|
31
32
|
throw new Error(`Invalid URL: ${baseUrl}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authentication.js","sources":["../../../src/utils/authentication.ts"],"sourcesContent":["import axios from \"axios\";\n\nimport { logHttpResponse, logger } from \"./log\";\n\nexport async function login(\n\tbaseUrl: string,\n\temail: string,\n\tpassword: string,\n): Promise<{ token: string; cookies: string[] | undefined }> {\n\tconst profiler = logger.startTimer();\n\n\tconst payload = {\n\t\temail,\n\t\tpassword,\n\t};\n\n\tconst url = transformUrl(baseUrl, \"auth.internal\");\n\n\tconst response = await axios.post<{ access_token: string }>(\n\t\t`${url}/login-e2e`,\n\t\tpayload,\n\t\t{\n\t\t\theaders: {\n\t\t\t\t\"User-Agent\": \"prismic-cli/prismic-e2e-tests-utils\",\n\t\t\t\tAuthorization:\n\t\t\t\t\t\"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3NDE3ODQ5NDEsImF1ZCI6ImF1dGgwLWFjdGlvbnMiLCJpc3MiOiJwcmlzbWljLmlvIn0.1UPoVMXJSTWtsyNzK5XYftK_mW0ScVuXwCK69nsyf5c\",\n\t\t\t},\n\t\t},\n\t);\n\n\tif (response.status !== 200) {\n\t\tlogHttpResponse(response);\n\t\tthrow new Error(\"Could not obtain OAuth token, check your credentials\");\n\t}\n\n\tprofiler.done({ message: \"logged in via OAuth\" });\n\tconst token = response.data.access_token;\n\n\treturn { token, cookies: response.headers[\"set-cookie\"] };\n}\n\nfunction transformUrl(baseUrl: string, subdomainPrefix: string): string {\n
|
|
1
|
+
{"version":3,"file":"authentication.js","sources":["../../../src/utils/authentication.ts"],"sourcesContent":["import axios from \"axios\";\n\nimport { logHttpResponse, logger } from \"./log\";\n\nexport async function login(\n\tbaseUrl: string,\n\temail: string,\n\tpassword: string,\n): Promise<{ token: string; cookies: string[] | undefined }> {\n\tconst profiler = logger.startTimer();\n\n\tconst payload = {\n\t\temail,\n\t\tpassword,\n\t};\n\n\tconst url = transformUrl(baseUrl, \"auth.internal\");\n\n\tconst response = await axios.post<{ access_token: string }>(\n\t\t`${url}/login-e2e`,\n\t\tpayload,\n\t\t{\n\t\t\theaders: {\n\t\t\t\t\"User-Agent\": \"prismic-cli/prismic-e2e-tests-utils\",\n\t\t\t\tAuthorization:\n\t\t\t\t\t\"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3NDE3ODQ5NDEsImF1ZCI6ImF1dGgwLWFjdGlvbnMiLCJpc3MiOiJwcmlzbWljLmlvIn0.1UPoVMXJSTWtsyNzK5XYftK_mW0ScVuXwCK69nsyf5c\",\n\t\t\t},\n\t\t},\n\t);\n\n\tif (response.status !== 200) {\n\t\tlogHttpResponse(response);\n\t\tthrow new Error(\"Could not obtain OAuth token, check your credentials\");\n\t}\n\n\tprofiler.done({ message: \"logged in via OAuth\" });\n\tconst token = response.data.access_token;\n\n\treturn { token, cookies: response.headers[\"set-cookie\"] };\n}\n\nfunction transformUrl(baseUrl: string, subdomainPrefix: string): string {\n try {\n const url = new URL(baseUrl);\n const domainParts = url.hostname.split('.');\n\n // Ensure we retain only the main domain (e.g., \"platform-wroom.com\")\n const mainDomain = domainParts.slice(-2).join('.'); // Keeps last two parts of domain\n\n // Construct the new hostname with the custom prefix\n const transformedHostname = `${subdomainPrefix}.${mainDomain}`;\n\n // Construct and return the full URL with the new hostname\n return `${url.protocol}//${transformedHostname}`;\n } catch (error) {\n throw new Error(`Invalid URL: ${baseUrl}`)\n\t}\n}\n"],"names":[],"mappings":";;AAIsB,eAAA,MACrB,SACA,OACA,UAAgB;AAEV,QAAA,WAAW,OAAO;AAExB,QAAM,UAAU;AAAA,IACf;AAAA,IACA;AAAA,EAAA;AAGK,QAAA,MAAM,aAAa,SAAS,eAAe;AAEjD,QAAM,WAAW,MAAM,MAAM,KAC5B,GAAG,GAAG,cACN,SACA;AAAA,IACC,SAAS;AAAA,MACR,cAAc;AAAA,MACd,eACC;AAAA,IACD;AAAA,EAAA,CACD;AAGE,MAAA,SAAS,WAAW,KAAK;AAC5B,oBAAgB,QAAQ;AAClB,UAAA,IAAI,MAAM,sDAAsD;AAAA,EACvE;AAEA,WAAS,KAAK,EAAE,SAAS,sBAAuB,CAAA;AAC1C,QAAA,QAAQ,SAAS,KAAK;AAE5B,SAAO,EAAE,OAAO,SAAS,SAAS,QAAQ,YAAY;AACvD;AAEA,SAAS,aAAa,SAAiB,iBAAuB;AACxD,MAAA;AACI,UAAA,MAAM,IAAI,IAAI,OAAO;AAC3B,UAAM,cAAc,IAAI,SAAS,MAAM,GAAG;AAG1C,UAAM,aAAa,YAAY,MAAM,EAAE,EAAE,KAAK,GAAG;AAGjD,UAAM,sBAAsB,GAAG,eAAe,IAAI,UAAU;AAG5D,WAAO,GAAG,IAAI,QAAQ,KAAK,mBAAmB;AAAA,WACvC,OAAO;AACd,UAAM,IAAI,MAAM,gBAAgB,OAAO,EAAE;AAAA,EAC5C;AACD;"}
|
package/package.json
CHANGED
|
@@ -40,16 +40,19 @@ export async function login(
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
function transformUrl(baseUrl: string, subdomainPrefix: string): string {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
try {
|
|
44
|
+
const url = new URL(baseUrl);
|
|
45
|
+
const domainParts = url.hostname.split('.');
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
// Ensure we retain only the main domain (e.g., "platform-wroom.com")
|
|
48
|
+
const mainDomain = domainParts.slice(-2).join('.'); // Keeps last two parts of domain
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
// Construct the new hostname with the custom prefix
|
|
51
|
+
const transformedHostname = `${subdomainPrefix}.${mainDomain}`;
|
|
52
|
+
|
|
53
|
+
// Construct and return the full URL with the new hostname
|
|
54
|
+
return `${url.protocol}//${transformedHostname}`;
|
|
55
|
+
} catch (error) {
|
|
56
|
+
throw new Error(`Invalid URL: ${baseUrl}`)
|
|
54
57
|
}
|
|
55
58
|
}
|