@lovable.dev/cloud-auth-js 1.1.0 → 1.1.2-dev.1
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.cjs +49 -3
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +49 -3
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -88,6 +88,14 @@ function processOAuthResponse(data, expectedState) {
|
|
|
88
88
|
error: null
|
|
89
89
|
};
|
|
90
90
|
}
|
|
91
|
+
function isDevice() {
|
|
92
|
+
const ua = navigator.userAgent;
|
|
93
|
+
if (/iPhone|iPad|iPod|Android/i.test(ua))
|
|
94
|
+
return true;
|
|
95
|
+
if (/Macintosh/i.test(ua) && navigator.maxTouchPoints > 1)
|
|
96
|
+
return true;
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
91
99
|
function generateState() {
|
|
92
100
|
if (typeof crypto !== "undefined" && crypto.getRandomValues) {
|
|
93
101
|
return [...crypto.getRandomValues(new Uint8Array(16))].map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
@@ -105,9 +113,8 @@ function createAuth(config = {}) {
|
|
|
105
113
|
isInIframe = true;
|
|
106
114
|
}
|
|
107
115
|
const ua = navigator.userAgent;
|
|
108
|
-
const isMobile = /iPhone|iPad|iPod|Android/i.test(ua);
|
|
109
116
|
const isMobileApp = /LovableApp\//.test(ua);
|
|
110
|
-
const isDesktopApp = /lovable
|
|
117
|
+
const isDesktopApp = !isMobileApp && /lovable/i.test(ua);
|
|
111
118
|
const state = generateState();
|
|
112
119
|
let redirectUri = opts.redirect_uri ?? window.location.origin;
|
|
113
120
|
if (isMobileApp && isInIframe) {
|
|
@@ -132,7 +139,7 @@ function createAuth(config = {}) {
|
|
|
132
139
|
const effectiveOrigins = isDesktopApp ? [...supportedOAuthOrigins, window.location.origin] : supportedOAuthOrigins;
|
|
133
140
|
const { messagePromise, cleanup } = startWebMessageListener(effectiveOrigins);
|
|
134
141
|
let popup;
|
|
135
|
-
if (
|
|
142
|
+
if (isDevice()) {
|
|
136
143
|
popup = window.open(url, "_blank");
|
|
137
144
|
} else {
|
|
138
145
|
const { width, height, left, top } = getPopupDimensions(isInIframe);
|
|
@@ -187,7 +194,46 @@ function createAuth(config = {}) {
|
|
|
187
194
|
};
|
|
188
195
|
}
|
|
189
196
|
|
|
197
|
+
// package.json
|
|
198
|
+
var package_default = {
|
|
199
|
+
name: "@lovable.dev/cloud-auth-js",
|
|
200
|
+
version: "1.1.2-dev.1",
|
|
201
|
+
description: "Lovable Cloud Auth JS",
|
|
202
|
+
main: "./dist/index.cjs",
|
|
203
|
+
module: "./dist/index.js",
|
|
204
|
+
types: "./dist/index.d.ts",
|
|
205
|
+
type: "module",
|
|
206
|
+
files: [
|
|
207
|
+
"dist"
|
|
208
|
+
],
|
|
209
|
+
scripts: {
|
|
210
|
+
build: "tsup src/index.ts --format cjs,esm --dts --outDir dist",
|
|
211
|
+
dev: "tsup src/index.ts --format cjs,esm --dts --watch",
|
|
212
|
+
test: "vitest run",
|
|
213
|
+
typecheck: "tsgo --noEmit",
|
|
214
|
+
prepublishOnly: "npm run clean && npm run build",
|
|
215
|
+
clean: "rimraf dist"
|
|
216
|
+
},
|
|
217
|
+
keywords: [
|
|
218
|
+
"lovable",
|
|
219
|
+
"oauth",
|
|
220
|
+
"authentication"
|
|
221
|
+
],
|
|
222
|
+
license: "MIT",
|
|
223
|
+
devDependencies: {
|
|
224
|
+
"@types/node": "^22",
|
|
225
|
+
jsdom: "^26",
|
|
226
|
+
rimraf: "^5.0.0",
|
|
227
|
+
tsup: "^7.2.0",
|
|
228
|
+
typescript: "^5",
|
|
229
|
+
vitest: "^4.1.0"
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
|
|
190
233
|
// src/index.ts
|
|
234
|
+
if (typeof window !== "undefined") {
|
|
235
|
+
window.__lovable_cloud_auth_js_version = package_default.version;
|
|
236
|
+
}
|
|
191
237
|
function createLovableAuth(config = {}) {
|
|
192
238
|
return createAuth(config);
|
|
193
239
|
}
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -62,6 +62,14 @@ function processOAuthResponse(data, expectedState) {
|
|
|
62
62
|
error: null
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
|
+
function isDevice() {
|
|
66
|
+
const ua = navigator.userAgent;
|
|
67
|
+
if (/iPhone|iPad|iPod|Android/i.test(ua))
|
|
68
|
+
return true;
|
|
69
|
+
if (/Macintosh/i.test(ua) && navigator.maxTouchPoints > 1)
|
|
70
|
+
return true;
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
65
73
|
function generateState() {
|
|
66
74
|
if (typeof crypto !== "undefined" && crypto.getRandomValues) {
|
|
67
75
|
return [...crypto.getRandomValues(new Uint8Array(16))].map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
@@ -79,9 +87,8 @@ function createAuth(config = {}) {
|
|
|
79
87
|
isInIframe = true;
|
|
80
88
|
}
|
|
81
89
|
const ua = navigator.userAgent;
|
|
82
|
-
const isMobile = /iPhone|iPad|iPod|Android/i.test(ua);
|
|
83
90
|
const isMobileApp = /LovableApp\//.test(ua);
|
|
84
|
-
const isDesktopApp = /lovable
|
|
91
|
+
const isDesktopApp = !isMobileApp && /lovable/i.test(ua);
|
|
85
92
|
const state = generateState();
|
|
86
93
|
let redirectUri = opts.redirect_uri ?? window.location.origin;
|
|
87
94
|
if (isMobileApp && isInIframe) {
|
|
@@ -106,7 +113,7 @@ function createAuth(config = {}) {
|
|
|
106
113
|
const effectiveOrigins = isDesktopApp ? [...supportedOAuthOrigins, window.location.origin] : supportedOAuthOrigins;
|
|
107
114
|
const { messagePromise, cleanup } = startWebMessageListener(effectiveOrigins);
|
|
108
115
|
let popup;
|
|
109
|
-
if (
|
|
116
|
+
if (isDevice()) {
|
|
110
117
|
popup = window.open(url, "_blank");
|
|
111
118
|
} else {
|
|
112
119
|
const { width, height, left, top } = getPopupDimensions(isInIframe);
|
|
@@ -161,7 +168,46 @@ function createAuth(config = {}) {
|
|
|
161
168
|
};
|
|
162
169
|
}
|
|
163
170
|
|
|
171
|
+
// package.json
|
|
172
|
+
var package_default = {
|
|
173
|
+
name: "@lovable.dev/cloud-auth-js",
|
|
174
|
+
version: "1.1.2-dev.1",
|
|
175
|
+
description: "Lovable Cloud Auth JS",
|
|
176
|
+
main: "./dist/index.cjs",
|
|
177
|
+
module: "./dist/index.js",
|
|
178
|
+
types: "./dist/index.d.ts",
|
|
179
|
+
type: "module",
|
|
180
|
+
files: [
|
|
181
|
+
"dist"
|
|
182
|
+
],
|
|
183
|
+
scripts: {
|
|
184
|
+
build: "tsup src/index.ts --format cjs,esm --dts --outDir dist",
|
|
185
|
+
dev: "tsup src/index.ts --format cjs,esm --dts --watch",
|
|
186
|
+
test: "vitest run",
|
|
187
|
+
typecheck: "tsgo --noEmit",
|
|
188
|
+
prepublishOnly: "npm run clean && npm run build",
|
|
189
|
+
clean: "rimraf dist"
|
|
190
|
+
},
|
|
191
|
+
keywords: [
|
|
192
|
+
"lovable",
|
|
193
|
+
"oauth",
|
|
194
|
+
"authentication"
|
|
195
|
+
],
|
|
196
|
+
license: "MIT",
|
|
197
|
+
devDependencies: {
|
|
198
|
+
"@types/node": "^22",
|
|
199
|
+
jsdom: "^26",
|
|
200
|
+
rimraf: "^5.0.0",
|
|
201
|
+
tsup: "^7.2.0",
|
|
202
|
+
typescript: "^5",
|
|
203
|
+
vitest: "^4.1.0"
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
|
|
164
207
|
// src/index.ts
|
|
208
|
+
if (typeof window !== "undefined") {
|
|
209
|
+
window.__lovable_cloud_auth_js_version = package_default.version;
|
|
210
|
+
}
|
|
165
211
|
function createLovableAuth(config = {}) {
|
|
166
212
|
return createAuth(config);
|
|
167
213
|
}
|