@embeddable.com/sdk-core 3.12.0-next.2 → 3.12.0-next.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embeddable.com/sdk-core",
3
- "version": "3.12.0-next.2",
3
+ "version": "3.12.0-next.3",
4
4
  "description": "Core Embeddable SDK module responsible for web-components bundling and publishing.",
5
5
  "keywords": [
6
6
  "embeddable",
package/src/login.ts CHANGED
@@ -46,11 +46,20 @@ export default async () => {
46
46
 
47
47
  await open(deviceCodeResponse.data["verification_uri_complete"]);
48
48
 
49
+ let isTerminated = false;
50
+ const signalHandler = () => {
51
+ isTerminated = true;
52
+ authenticationSpinner.fail("Authentication process interrupted");
53
+ process.exit(0);
54
+ };
55
+ process.on("SIGTERM", signalHandler);
56
+ process.on("SIGINT", signalHandler);
57
+
49
58
  /**
50
59
  * This is a recommended way to poll, since it take some time for a user to enter a `user_code` in a browser.
51
60
  * deviceCodeResponse.data['interval'] is a recommended/calculated polling interval specified in seconds.
52
61
  */
53
- while (true) {
62
+ while (!isTerminated) {
54
63
  try {
55
64
  const tokenResponse = await axios.post(
56
65
  `https://${config.authDomain}/oauth/token`,
@@ -75,6 +84,10 @@ export default async () => {
75
84
  await sleep(deviceCodeResponse.data["interval"] * 1000);
76
85
  }
77
86
  }
87
+
88
+ // Clean up signal handlers
89
+ process.off("SIGTERM", signalHandler);
90
+ process.off("SIGINT", signalHandler);
78
91
  } catch (error: unknown) {
79
92
  authenticationSpinner.fail("Authentication failed. Please try again.");
80
93
  await logError({ command: "login", breadcrumbs, error });