@bundleup/core 0.0.2 → 0.0.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/dist/client.d.mts CHANGED
@@ -3,6 +3,6 @@ interface AuthenticateWithPopupOptions {
3
3
  height?: number;
4
4
  debug?: boolean;
5
5
  }
6
- declare function authenticateWithPopup(token: string, options?: AuthenticateWithPopupOptions): Promise<void>;
6
+ declare function authenticateWithPopup(token: string, options?: AuthenticateWithPopupOptions): Promise<Record<string, any>>;
7
7
 
8
8
  export { AuthenticateWithPopupOptions, authenticateWithPopup };
package/dist/client.d.ts CHANGED
@@ -3,6 +3,6 @@ interface AuthenticateWithPopupOptions {
3
3
  height?: number;
4
4
  debug?: boolean;
5
5
  }
6
- declare function authenticateWithPopup(token: string, options?: AuthenticateWithPopupOptions): Promise<void>;
6
+ declare function authenticateWithPopup(token: string, options?: AuthenticateWithPopupOptions): Promise<Record<string, any>>;
7
7
 
8
8
  export { AuthenticateWithPopupOptions, authenticateWithPopup };
package/dist/client.js CHANGED
@@ -45,6 +45,8 @@ function authenticateWithPopup(token, options = {}) {
45
45
  }
46
46
  const width = options?.width ?? 500;
47
47
  const height = options?.height ?? 600;
48
+ const left = window.screenX + (window.outerWidth - width) / 2;
49
+ const top = window.screenY + (window.outerHeight - height) / 2.5;
48
50
  const debug = options?.debug ?? false;
49
51
  const client = isClient();
50
52
  const log = logger(debug);
@@ -60,7 +62,7 @@ function authenticateWithPopup(token, options = {}) {
60
62
  const popup = window.open(
61
63
  `https://auth.bundleup.io/${token}`,
62
64
  "bundleup-auth",
63
- `width=${width},height=${height},scrollbars=yes,resizable=yes`
65
+ `width=${width},height=${height},left=${left},top=${top},scrollbars=yes,resizable=yes`
64
66
  );
65
67
  if (!popup) {
66
68
  log("Failed to open popup window. Please check popup blocker settings.");
@@ -77,16 +79,15 @@ function authenticateWithPopup(token, options = {}) {
77
79
  if (!event.data?.type) {
78
80
  return;
79
81
  }
80
- log("Received authentication message", event.data);
81
82
  cleanup();
82
83
  popup.close();
83
- if (event.data.type === "bundleup-auth-success") {
84
+ if (event.data.type === "bundleup:success") {
84
85
  log("Authentication successful");
85
- return resolve();
86
+ return resolve(event.data.data);
86
87
  }
87
- if (event.data.type === "bundleup-auth-error") {
88
- log("Authentication failed", event.data.error);
89
- return reject(new Error(event.data.error || "Authentication failed"));
88
+ if (event.data.type === "bundleup:error") {
89
+ log("Authentication failed", event.data.message);
90
+ return reject(new Error(event.data.message || "Authentication failed"));
90
91
  }
91
92
  };
92
93
  const checkClosed = setInterval(() => {
package/dist/client.mjs CHANGED
@@ -11,6 +11,8 @@ function authenticateWithPopup(token, options = {}) {
11
11
  }
12
12
  const width = options?.width ?? 500;
13
13
  const height = options?.height ?? 600;
14
+ const left = window.screenX + (window.outerWidth - width) / 2;
15
+ const top = window.screenY + (window.outerHeight - height) / 2.5;
14
16
  const debug = options?.debug ?? false;
15
17
  const client = isClient();
16
18
  const log = logger(debug);
@@ -26,7 +28,7 @@ function authenticateWithPopup(token, options = {}) {
26
28
  const popup = window.open(
27
29
  `https://auth.bundleup.io/${token}`,
28
30
  "bundleup-auth",
29
- `width=${width},height=${height},scrollbars=yes,resizable=yes`
31
+ `width=${width},height=${height},left=${left},top=${top},scrollbars=yes,resizable=yes`
30
32
  );
31
33
  if (!popup) {
32
34
  log("Failed to open popup window. Please check popup blocker settings.");
@@ -43,16 +45,15 @@ function authenticateWithPopup(token, options = {}) {
43
45
  if (!event.data?.type) {
44
46
  return;
45
47
  }
46
- log("Received authentication message", event.data);
47
48
  cleanup();
48
49
  popup.close();
49
- if (event.data.type === "bundleup-auth-success") {
50
+ if (event.data.type === "bundleup:success") {
50
51
  log("Authentication successful");
51
- return resolve();
52
+ return resolve(event.data.data);
52
53
  }
53
- if (event.data.type === "bundleup-auth-error") {
54
- log("Authentication failed", event.data.error);
55
- return reject(new Error(event.data.error || "Authentication failed"));
54
+ if (event.data.type === "bundleup:error") {
55
+ log("Authentication failed", event.data.message);
56
+ return reject(new Error(event.data.message || "Authentication failed"));
56
57
  }
57
58
  };
58
59
  const checkClosed = setInterval(() => {
package/dist/server.js CHANGED
@@ -49,7 +49,7 @@ var BundleUp = class {
49
49
  return logger(!!this.config.debug)(message, ...args);
50
50
  }
51
51
  async createConnection(integrationId, options) {
52
- this.log(`Creating connection for integration: ${integrationId}`, options);
52
+ this.log(`Creating connection for integration: ${integrationId}`);
53
53
  if (!integrationId) {
54
54
  this.log("Integration ID is missing");
55
55
  throw new Error("Integration ID is required to create a connection");
@@ -63,18 +63,22 @@ var BundleUp = class {
63
63
  },
64
64
  body: JSON.stringify({
65
65
  integrationId,
66
- externalId: options.externalId ?? void 0,
67
- metadata: options.metadata ?? {}
66
+ externalId: options.externalId || void 0,
67
+ metadata: options.metadata || {}
68
68
  })
69
69
  });
70
70
  if (!response.ok) {
71
- this.log(`Authentication request failed: ${response.status} ${response.statusText}`);
72
- throw new Error(`Authentication request failed: ${response.status} ${response.statusText}`);
71
+ this.log(
72
+ `Authentication request failed: ${response.status} ${response.statusText}`
73
+ );
74
+ throw new Error(
75
+ `Authentication request failed: ${response.status} ${response.statusText}`
76
+ );
73
77
  }
74
78
  const data = await response.json();
75
79
  if (!data.token) {
76
- this.log("Invalid response: token not found");
77
- throw new Error("Invalid response: token not found");
80
+ this.log("Invalid response: could not create token", data);
81
+ throw new Error("Invalid response: could not create token");
78
82
  }
79
83
  this.log("Authentication token received successfully");
80
84
  return data;
package/dist/server.mjs CHANGED
@@ -17,7 +17,7 @@ var BundleUp = class {
17
17
  return logger(!!this.config.debug)(message, ...args);
18
18
  }
19
19
  async createConnection(integrationId, options) {
20
- this.log(`Creating connection for integration: ${integrationId}`, options);
20
+ this.log(`Creating connection for integration: ${integrationId}`);
21
21
  if (!integrationId) {
22
22
  this.log("Integration ID is missing");
23
23
  throw new Error("Integration ID is required to create a connection");
@@ -31,18 +31,22 @@ var BundleUp = class {
31
31
  },
32
32
  body: JSON.stringify({
33
33
  integrationId,
34
- externalId: options.externalId ?? void 0,
35
- metadata: options.metadata ?? {}
34
+ externalId: options.externalId || void 0,
35
+ metadata: options.metadata || {}
36
36
  })
37
37
  });
38
38
  if (!response.ok) {
39
- this.log(`Authentication request failed: ${response.status} ${response.statusText}`);
40
- throw new Error(`Authentication request failed: ${response.status} ${response.statusText}`);
39
+ this.log(
40
+ `Authentication request failed: ${response.status} ${response.statusText}`
41
+ );
42
+ throw new Error(
43
+ `Authentication request failed: ${response.status} ${response.statusText}`
44
+ );
41
45
  }
42
46
  const data = await response.json();
43
47
  if (!data.token) {
44
- this.log("Invalid response: token not found");
45
- throw new Error("Invalid response: token not found");
48
+ this.log("Invalid response: could not create token", data);
49
+ throw new Error("Invalid response: could not create token");
46
50
  }
47
51
  this.log("Authentication token received successfully");
48
52
  return data;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bundleup/core",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "Core package for BundleUp",
5
5
  "exports": {
6
6
  "./client": {