@prismicio/e2e-tests-utils 2.0.0-alpha.7 → 2.0.0-alpha.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.
@@ -20,7 +20,7 @@ async function login(baseUrl, email, password) {
20
20
  throw new Error("Could not obtain OAuth token, check your credentials");
21
21
  }
22
22
  profiler.done({ message: "logged in via OAuth" });
23
- const token = response.data.access_token;
23
+ const token = response.data.token;
24
24
  return { token, cookies: response.headers["set-cookie"] };
25
25
  }
26
26
  function transformUrl(baseUrl, subdomainPrefix) {
@@ -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 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;;"}
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<{ 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.token;\n\n\treturn { token, cookies: response.headers[\"set-cookie\"] };\n}\n\nfunction transformUrl(baseUrl: string, subdomainPrefix: string): string {\n\ttry {\n\t\tconst url = new URL(baseUrl);\n\t\tconst domainParts = url.hostname.split(\".\");\n\n\t\t// Ensure we retain only the main domain (e.g., \"platform-wroom.com\")\n\t\tconst mainDomain = domainParts.slice(-2).join(\".\"); // Keeps last two parts of domain\n\n\t\t// Construct the new hostname with the custom prefix\n\t\tconst transformedHostname = `${subdomainPrefix}.${mainDomain}`;\n\n\t\t// Construct and return the full URL with the new hostname\n\t\treturn `${url.protocol}//${transformedHostname}`;\n\t} catch (error) {\n\t\tthrow 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;AACzD,MAAA;AACG,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,WACtC,OAAO;AACf,UAAM,IAAI,MAAM,gBAAgB,OAAO,EAAE;AAAA,EAC1C;AACD;;"}
@@ -18,7 +18,7 @@ async function login(baseUrl, email, password) {
18
18
  throw new Error("Could not obtain OAuth token, check your credentials");
19
19
  }
20
20
  profiler.done({ message: "logged in via OAuth" });
21
- const token = response.data.access_token;
21
+ const token = response.data.token;
22
22
  return { token, cookies: response.headers["set-cookie"] };
23
23
  }
24
24
  function transformUrl(baseUrl, subdomainPrefix) {
@@ -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 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;"}
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<{ 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.token;\n\n\treturn { token, cookies: response.headers[\"set-cookie\"] };\n}\n\nfunction transformUrl(baseUrl: string, subdomainPrefix: string): string {\n\ttry {\n\t\tconst url = new URL(baseUrl);\n\t\tconst domainParts = url.hostname.split(\".\");\n\n\t\t// Ensure we retain only the main domain (e.g., \"platform-wroom.com\")\n\t\tconst mainDomain = domainParts.slice(-2).join(\".\"); // Keeps last two parts of domain\n\n\t\t// Construct the new hostname with the custom prefix\n\t\tconst transformedHostname = `${subdomainPrefix}.${mainDomain}`;\n\n\t\t// Construct and return the full URL with the new hostname\n\t\treturn `${url.protocol}//${transformedHostname}`;\n\t} catch (error) {\n\t\tthrow 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;AACzD,MAAA;AACG,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,WACtC,OAAO;AACf,UAAM,IAAI,MAAM,gBAAgB,OAAO,EAAE;AAAA,EAC1C;AACD;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismicio/e2e-tests-utils",
3
- "version": "2.0.0-alpha.7",
3
+ "version": "2.0.0-alpha.8",
4
4
  "description": "A collection of utilities for to manage Prismic test data",
5
5
  "keywords": [
6
6
  "typescript",
@@ -16,7 +16,7 @@ export async function login(
16
16
 
17
17
  const url = transformUrl(baseUrl, "auth.internal");
18
18
 
19
- const response = await axios.post<{ access_token: string }>(
19
+ const response = await axios.post<{ token: string }>(
20
20
  `${url}/login-e2e`,
21
21
  payload,
22
22
  {
@@ -34,25 +34,25 @@ export async function login(
34
34
  }
35
35
 
36
36
  profiler.done({ message: "logged in via OAuth" });
37
- const token = response.data.access_token;
37
+ const token = response.data.token;
38
38
 
39
39
  return { token, cookies: response.headers["set-cookie"] };
40
40
  }
41
41
 
42
42
  function transformUrl(baseUrl: string, subdomainPrefix: string): string {
43
- try {
44
- const url = new URL(baseUrl);
45
- const domainParts = url.hostname.split('.');
43
+ try {
44
+ const url = new URL(baseUrl);
45
+ const domainParts = url.hostname.split(".");
46
46
 
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
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
- // Construct the new hostname with the custom prefix
51
- const transformedHostname = `${subdomainPrefix}.${mainDomain}`;
50
+ // Construct the new hostname with the custom prefix
51
+ const transformedHostname = `${subdomainPrefix}.${mainDomain}`;
52
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}`)
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}`);
57
57
  }
58
58
  }