@pollar/core 0.4.3 → 0.4.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/index.js CHANGED
@@ -1124,6 +1124,7 @@ function withSignal(promise, signal) {
1124
1124
  }
1125
1125
  async function login(options, deps) {
1126
1126
  const { api, basePath, apiKey, signal, emitState, storeSession, clearSession } = deps;
1127
+ const oauthPopup = options.provider === "google" || options.provider === "github" ? window.open("about:blank", "_blank") : null;
1127
1128
  emitState("authentication", STATE_VAR_CODES.authentication.CREATE_SESSION_START, "info", StateStatus.LOADING);
1128
1129
  const createSessionResponse = await api.POST("/auth/session", { signal });
1129
1130
  if (!emitResponse(
@@ -1133,6 +1134,7 @@ async function login(options, deps) {
1133
1134
  STATE_VAR_CODES.authentication.CREATE_SESSION_ERROR,
1134
1135
  emitState
1135
1136
  )) {
1137
+ oauthPopup?.close();
1136
1138
  return;
1137
1139
  }
1138
1140
  const clientSessionId = createSessionResponse.data.content.clientSessionId;
@@ -1162,7 +1164,11 @@ async function login(options, deps) {
1162
1164
  url.searchParams.set("api_key", apiKey);
1163
1165
  url.searchParams.set("client_session_id", clientSessionId);
1164
1166
  url.searchParams.set("redirect_uri", window.location.origin);
1165
- window.open(url.toString(), "_blank");
1167
+ if (oauthPopup) {
1168
+ oauthPopup.location.href = url.toString();
1169
+ } else {
1170
+ window.open(url.toString(), "_blank");
1171
+ }
1166
1172
  break;
1167
1173
  }
1168
1174
  case "wallet": {