@blinkdotnew/dev-sdk 2.1.4 → 2.1.6
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.d.mts +0 -5
- package/dist/index.d.ts +0 -5
- package/dist/index.js +2 -66
- package/dist/index.mjs +2 -66
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1325,11 +1325,6 @@ declare class BlinkAuth {
|
|
|
1325
1325
|
* Uses expo-web-browser to open auth URL and polls for completion
|
|
1326
1326
|
*/
|
|
1327
1327
|
private signInWithProviderUniversal;
|
|
1328
|
-
/**
|
|
1329
|
-
* OAuth flow via parent window (for iframe context)
|
|
1330
|
-
* Delegates OAuth to parent window since OAuth providers block flows inside iframes
|
|
1331
|
-
*/
|
|
1332
|
-
private signInWithProviderViaParent;
|
|
1333
1328
|
/**
|
|
1334
1329
|
* Generic provider sign-in method (headless mode)
|
|
1335
1330
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -1325,11 +1325,6 @@ declare class BlinkAuth {
|
|
|
1325
1325
|
* Uses expo-web-browser to open auth URL and polls for completion
|
|
1326
1326
|
*/
|
|
1327
1327
|
private signInWithProviderUniversal;
|
|
1328
|
-
/**
|
|
1329
|
-
* OAuth flow via parent window (for iframe context)
|
|
1330
|
-
* Delegates OAuth to parent window since OAuth providers block flows inside iframes
|
|
1331
|
-
*/
|
|
1332
|
-
private signInWithProviderViaParent;
|
|
1333
1328
|
/**
|
|
1334
1329
|
* Generic provider sign-in method (headless mode)
|
|
1335
1330
|
*
|
package/dist/index.js
CHANGED
|
@@ -1469,6 +1469,7 @@ var BlinkAuth = class {
|
|
|
1469
1469
|
if (this.config.projectId) {
|
|
1470
1470
|
authUrl.searchParams.set("project_id", this.config.projectId);
|
|
1471
1471
|
}
|
|
1472
|
+
authUrl.searchParams.set("prompt", "select_account");
|
|
1472
1473
|
window.location.href = authUrl.toString();
|
|
1473
1474
|
}
|
|
1474
1475
|
/**
|
|
@@ -1966,67 +1967,6 @@ var BlinkAuth = class {
|
|
|
1966
1967
|
throw pollError;
|
|
1967
1968
|
}
|
|
1968
1969
|
}
|
|
1969
|
-
/**
|
|
1970
|
-
* OAuth flow via parent window (for iframe context)
|
|
1971
|
-
* Delegates OAuth to parent window since OAuth providers block flows inside iframes
|
|
1972
|
-
*/
|
|
1973
|
-
signInWithProviderViaParent(provider, options) {
|
|
1974
|
-
return new Promise((resolve, reject) => {
|
|
1975
|
-
const state = this.generateState();
|
|
1976
|
-
const redirectUrl = options?.redirectUrl || getLocationOrigin() || "";
|
|
1977
|
-
let timeoutId;
|
|
1978
|
-
let cleanedUp = false;
|
|
1979
|
-
const cleanup = () => {
|
|
1980
|
-
if (cleanedUp) return;
|
|
1981
|
-
cleanedUp = true;
|
|
1982
|
-
clearTimeout(timeoutId);
|
|
1983
|
-
window.removeEventListener("message", messageListener);
|
|
1984
|
-
};
|
|
1985
|
-
const messageListener = (event) => {
|
|
1986
|
-
const { type, access_token, refresh_token, expires_in, refresh_expires_in, issued_at, projectId, error } = event.data || {};
|
|
1987
|
-
if (type === "BLINK_AUTH_TOKENS") {
|
|
1988
|
-
if (projectId && projectId !== this.config.projectId) {
|
|
1989
|
-
return;
|
|
1990
|
-
}
|
|
1991
|
-
console.log("\u{1F4E5} Received auth tokens from parent window");
|
|
1992
|
-
this.setTokens({
|
|
1993
|
-
access_token,
|
|
1994
|
-
refresh_token,
|
|
1995
|
-
token_type: "Bearer",
|
|
1996
|
-
expires_in: expires_in || 3600,
|
|
1997
|
-
refresh_expires_in,
|
|
1998
|
-
issued_at: issued_at || Math.floor(Date.now() / 1e3)
|
|
1999
|
-
}, true).then(() => {
|
|
2000
|
-
cleanup();
|
|
2001
|
-
resolve(this.authState.user);
|
|
2002
|
-
}).catch((err) => {
|
|
2003
|
-
cleanup();
|
|
2004
|
-
reject(err);
|
|
2005
|
-
});
|
|
2006
|
-
} else if (type === "BLINK_AUTH_ERROR") {
|
|
2007
|
-
cleanup();
|
|
2008
|
-
reject(new BlinkAuthError(
|
|
2009
|
-
"POPUP_CANCELED" /* POPUP_CANCELED */,
|
|
2010
|
-
error || "Authentication failed"
|
|
2011
|
-
));
|
|
2012
|
-
}
|
|
2013
|
-
};
|
|
2014
|
-
window.addEventListener("message", messageListener);
|
|
2015
|
-
timeoutId = setTimeout(() => {
|
|
2016
|
-
cleanup();
|
|
2017
|
-
reject(new BlinkAuthError("AUTH_TIMEOUT" /* AUTH_TIMEOUT */, "Authentication timed out"));
|
|
2018
|
-
}, 3e5);
|
|
2019
|
-
console.log("\u{1F4E4} Sending OAuth request to parent window");
|
|
2020
|
-
window.parent.postMessage({
|
|
2021
|
-
type: "BLINK_AUTH_OAUTH_REQUEST",
|
|
2022
|
-
provider,
|
|
2023
|
-
projectId: this.config.projectId,
|
|
2024
|
-
redirectUrl,
|
|
2025
|
-
state,
|
|
2026
|
-
authUrl: this.authUrl
|
|
2027
|
-
}, "*");
|
|
2028
|
-
});
|
|
2029
|
-
}
|
|
2030
1970
|
/**
|
|
2031
1971
|
* Generic provider sign-in method (headless mode)
|
|
2032
1972
|
*
|
|
@@ -2073,10 +2013,7 @@ var BlinkAuth = class {
|
|
|
2073
2013
|
if (!hasWindow()) {
|
|
2074
2014
|
throw new BlinkAuthError("NETWORK_ERROR" /* NETWORK_ERROR */, "signInWithProvider requires a browser environment");
|
|
2075
2015
|
}
|
|
2076
|
-
|
|
2077
|
-
console.log("\u{1F5BC}\uFE0F In iframe, delegating OAuth to parent window");
|
|
2078
|
-
return this.signInWithProviderViaParent(provider, options);
|
|
2079
|
-
}
|
|
2016
|
+
const shouldPreferRedirect = isWeb && this.isIframe || typeof window !== "undefined" && window.crossOriginIsolated === true;
|
|
2080
2017
|
const state = this.generateState();
|
|
2081
2018
|
try {
|
|
2082
2019
|
const sessionStorage = getSessionStorage();
|
|
@@ -2096,7 +2033,6 @@ var BlinkAuth = class {
|
|
|
2096
2033
|
url.searchParams.set("opener_origin", getLocationOrigin() || "");
|
|
2097
2034
|
return url;
|
|
2098
2035
|
};
|
|
2099
|
-
const shouldPreferRedirect = typeof window !== "undefined" && window.crossOriginIsolated === true;
|
|
2100
2036
|
if (shouldPreferRedirect) {
|
|
2101
2037
|
window.location.href = buildAuthUrl("redirect").toString();
|
|
2102
2038
|
return new Promise(() => {
|
package/dist/index.mjs
CHANGED
|
@@ -1467,6 +1467,7 @@ var BlinkAuth = class {
|
|
|
1467
1467
|
if (this.config.projectId) {
|
|
1468
1468
|
authUrl.searchParams.set("project_id", this.config.projectId);
|
|
1469
1469
|
}
|
|
1470
|
+
authUrl.searchParams.set("prompt", "select_account");
|
|
1470
1471
|
window.location.href = authUrl.toString();
|
|
1471
1472
|
}
|
|
1472
1473
|
/**
|
|
@@ -1964,67 +1965,6 @@ var BlinkAuth = class {
|
|
|
1964
1965
|
throw pollError;
|
|
1965
1966
|
}
|
|
1966
1967
|
}
|
|
1967
|
-
/**
|
|
1968
|
-
* OAuth flow via parent window (for iframe context)
|
|
1969
|
-
* Delegates OAuth to parent window since OAuth providers block flows inside iframes
|
|
1970
|
-
*/
|
|
1971
|
-
signInWithProviderViaParent(provider, options) {
|
|
1972
|
-
return new Promise((resolve, reject) => {
|
|
1973
|
-
const state = this.generateState();
|
|
1974
|
-
const redirectUrl = options?.redirectUrl || getLocationOrigin() || "";
|
|
1975
|
-
let timeoutId;
|
|
1976
|
-
let cleanedUp = false;
|
|
1977
|
-
const cleanup = () => {
|
|
1978
|
-
if (cleanedUp) return;
|
|
1979
|
-
cleanedUp = true;
|
|
1980
|
-
clearTimeout(timeoutId);
|
|
1981
|
-
window.removeEventListener("message", messageListener);
|
|
1982
|
-
};
|
|
1983
|
-
const messageListener = (event) => {
|
|
1984
|
-
const { type, access_token, refresh_token, expires_in, refresh_expires_in, issued_at, projectId, error } = event.data || {};
|
|
1985
|
-
if (type === "BLINK_AUTH_TOKENS") {
|
|
1986
|
-
if (projectId && projectId !== this.config.projectId) {
|
|
1987
|
-
return;
|
|
1988
|
-
}
|
|
1989
|
-
console.log("\u{1F4E5} Received auth tokens from parent window");
|
|
1990
|
-
this.setTokens({
|
|
1991
|
-
access_token,
|
|
1992
|
-
refresh_token,
|
|
1993
|
-
token_type: "Bearer",
|
|
1994
|
-
expires_in: expires_in || 3600,
|
|
1995
|
-
refresh_expires_in,
|
|
1996
|
-
issued_at: issued_at || Math.floor(Date.now() / 1e3)
|
|
1997
|
-
}, true).then(() => {
|
|
1998
|
-
cleanup();
|
|
1999
|
-
resolve(this.authState.user);
|
|
2000
|
-
}).catch((err) => {
|
|
2001
|
-
cleanup();
|
|
2002
|
-
reject(err);
|
|
2003
|
-
});
|
|
2004
|
-
} else if (type === "BLINK_AUTH_ERROR") {
|
|
2005
|
-
cleanup();
|
|
2006
|
-
reject(new BlinkAuthError(
|
|
2007
|
-
"POPUP_CANCELED" /* POPUP_CANCELED */,
|
|
2008
|
-
error || "Authentication failed"
|
|
2009
|
-
));
|
|
2010
|
-
}
|
|
2011
|
-
};
|
|
2012
|
-
window.addEventListener("message", messageListener);
|
|
2013
|
-
timeoutId = setTimeout(() => {
|
|
2014
|
-
cleanup();
|
|
2015
|
-
reject(new BlinkAuthError("AUTH_TIMEOUT" /* AUTH_TIMEOUT */, "Authentication timed out"));
|
|
2016
|
-
}, 3e5);
|
|
2017
|
-
console.log("\u{1F4E4} Sending OAuth request to parent window");
|
|
2018
|
-
window.parent.postMessage({
|
|
2019
|
-
type: "BLINK_AUTH_OAUTH_REQUEST",
|
|
2020
|
-
provider,
|
|
2021
|
-
projectId: this.config.projectId,
|
|
2022
|
-
redirectUrl,
|
|
2023
|
-
state,
|
|
2024
|
-
authUrl: this.authUrl
|
|
2025
|
-
}, "*");
|
|
2026
|
-
});
|
|
2027
|
-
}
|
|
2028
1968
|
/**
|
|
2029
1969
|
* Generic provider sign-in method (headless mode)
|
|
2030
1970
|
*
|
|
@@ -2071,10 +2011,7 @@ var BlinkAuth = class {
|
|
|
2071
2011
|
if (!hasWindow()) {
|
|
2072
2012
|
throw new BlinkAuthError("NETWORK_ERROR" /* NETWORK_ERROR */, "signInWithProvider requires a browser environment");
|
|
2073
2013
|
}
|
|
2074
|
-
|
|
2075
|
-
console.log("\u{1F5BC}\uFE0F In iframe, delegating OAuth to parent window");
|
|
2076
|
-
return this.signInWithProviderViaParent(provider, options);
|
|
2077
|
-
}
|
|
2014
|
+
const shouldPreferRedirect = isWeb && this.isIframe || typeof window !== "undefined" && window.crossOriginIsolated === true;
|
|
2078
2015
|
const state = this.generateState();
|
|
2079
2016
|
try {
|
|
2080
2017
|
const sessionStorage = getSessionStorage();
|
|
@@ -2094,7 +2031,6 @@ var BlinkAuth = class {
|
|
|
2094
2031
|
url.searchParams.set("opener_origin", getLocationOrigin() || "");
|
|
2095
2032
|
return url;
|
|
2096
2033
|
};
|
|
2097
|
-
const shouldPreferRedirect = typeof window !== "undefined" && window.crossOriginIsolated === true;
|
|
2098
2034
|
if (shouldPreferRedirect) {
|
|
2099
2035
|
window.location.href = buildAuthUrl("redirect").toString();
|
|
2100
2036
|
return new Promise(() => {
|
package/package.json
CHANGED