@lovable.dev/cloud-auth-js 1.1.3-dev.17 → 1.1.3-rc.0

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/README.md CHANGED
@@ -43,7 +43,7 @@ Creates a Lovable auth instance.
43
43
  | Option | Type | Default | Description |
44
44
  | ----------------------- | ---------- | ------------------------------- | ------------------------------------- |
45
45
  | `oauthBrokerUrl` | `string` | `"/~oauth/initiate"` | OAuth broker initiate URL |
46
- | `supportedOAuthOrigins` | `string[]` | `["https://oauth.lovable.app", "https://lovable.dev"]` | Allowed origins for OAuth postMessage |
46
+ | `supportedOAuthOrigins` | `string[]` | `["https://oauth.lovable.app", "https://lovable.dev"]` | Allowed origins for OAuth postMessage. Inside the Lovable mobile/desktop apps, the page's own origin is also accepted — the native side injects the token post from the page's own context. |
47
47
 
48
48
  ### `signInWithOAuth(provider, options?)`
49
49
 
package/dist/index.cjs CHANGED
@@ -117,7 +117,7 @@ function createAuth(config = {}) {
117
117
  const isDesktopApp = !isMobileApp && /lovable/i.test(ua);
118
118
  const state = generateState();
119
119
  let redirectUri = opts.redirect_uri ?? window.location.origin;
120
- if (isMobileApp && isInIframe) {
120
+ if (isMobileApp) {
121
121
  redirectUri = DEFAULT_MOBILE_DEEP_LINK_REDIRECT_URI;
122
122
  } else if (isDesktopApp && isInIframe) {
123
123
  redirectUri = DEFAULT_DESKTOP_LOCALHOST_REDIRECT_URI;
@@ -128,7 +128,7 @@ function createAuth(config = {}) {
128
128
  redirect_uri: redirectUri,
129
129
  state
130
130
  });
131
- if (!isInIframe) {
131
+ if (!isInIframe && !isMobileApp) {
132
132
  window.location.href = `${oauthBrokerUrl}?${params.toString()}`;
133
133
  return { error: null, redirected: true };
134
134
  }
@@ -136,7 +136,7 @@ function createAuth(config = {}) {
136
136
  params.set("response_mode", "web_message");
137
137
  }
138
138
  const url = `${oauthBrokerUrl}?${params.toString()}`;
139
- const effectiveOrigins = isDesktopApp ? [...supportedOAuthOrigins, window.location.origin] : supportedOAuthOrigins;
139
+ const effectiveOrigins = isDesktopApp || isMobileApp ? [...supportedOAuthOrigins, window.location.origin] : supportedOAuthOrigins;
140
140
  const { messagePromise, cleanup } = startWebMessageListener(effectiveOrigins);
141
141
  let popup;
142
142
  if (isDevice()) {
package/dist/index.js CHANGED
@@ -91,7 +91,7 @@ function createAuth(config = {}) {
91
91
  const isDesktopApp = !isMobileApp && /lovable/i.test(ua);
92
92
  const state = generateState();
93
93
  let redirectUri = opts.redirect_uri ?? window.location.origin;
94
- if (isMobileApp && isInIframe) {
94
+ if (isMobileApp) {
95
95
  redirectUri = DEFAULT_MOBILE_DEEP_LINK_REDIRECT_URI;
96
96
  } else if (isDesktopApp && isInIframe) {
97
97
  redirectUri = DEFAULT_DESKTOP_LOCALHOST_REDIRECT_URI;
@@ -102,7 +102,7 @@ function createAuth(config = {}) {
102
102
  redirect_uri: redirectUri,
103
103
  state
104
104
  });
105
- if (!isInIframe) {
105
+ if (!isInIframe && !isMobileApp) {
106
106
  window.location.href = `${oauthBrokerUrl}?${params.toString()}`;
107
107
  return { error: null, redirected: true };
108
108
  }
@@ -110,7 +110,7 @@ function createAuth(config = {}) {
110
110
  params.set("response_mode", "web_message");
111
111
  }
112
112
  const url = `${oauthBrokerUrl}?${params.toString()}`;
113
- const effectiveOrigins = isDesktopApp ? [...supportedOAuthOrigins, window.location.origin] : supportedOAuthOrigins;
113
+ const effectiveOrigins = isDesktopApp || isMobileApp ? [...supportedOAuthOrigins, window.location.origin] : supportedOAuthOrigins;
114
114
  const { messagePromise, cleanup } = startWebMessageListener(effectiveOrigins);
115
115
  let popup;
116
116
  if (isDevice()) {
package/package.json CHANGED
@@ -1,7 +1,12 @@
1
1
  {
2
2
  "name": "@lovable.dev/cloud-auth-js",
3
- "version": "1.1.3-dev.17",
3
+ "version": "1.1.3-rc.0",
4
4
  "description": "Lovable legacy OAuth broker JS",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/lovablelabs/lovable.git",
8
+ "directory": "npm-packages/cloud-auth-js"
9
+ },
5
10
  "main": "./dist/index.cjs",
6
11
  "module": "./dist/index.js",
7
12
  "types": "./dist/index.d.ts",
@@ -16,14 +21,6 @@
16
21
  "files": [
17
22
  "dist"
18
23
  ],
19
- "scripts": {
20
- "build": "tsup src/index.ts --format cjs,esm --dts --outDir dist",
21
- "dev": "tsup src/index.ts --format cjs,esm --dts --watch",
22
- "test": "vitest run",
23
- "typecheck": "tsgo --noEmit",
24
- "prepublishOnly": "npm run clean && npm run build",
25
- "clean": "rimraf dist"
26
- },
27
24
  "keywords": [
28
25
  "lovable",
29
26
  "oauth",
@@ -37,5 +34,12 @@
37
34
  "tsup": "^7.2.0",
38
35
  "typescript": "^5",
39
36
  "vitest": "^4.1.0"
37
+ },
38
+ "scripts": {
39
+ "build": "tsup src/index.ts --format cjs,esm --dts --outDir dist",
40
+ "dev": "tsup src/index.ts --format cjs,esm --dts --watch",
41
+ "test": "vitest run",
42
+ "typecheck": "tsgo --noEmit",
43
+ "clean": "rimraf dist"
40
44
  }
41
- }
45
+ }