@meshagent/meshagent-ts-auth 0.35.6 → 0.35.8

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/CHANGELOG.md CHANGED
@@ -1,2 +1,6 @@
1
+ ## [0.35.8]
2
+ - `ensureLogin` now uses the current page as the OAuth callback (no stored marker/URL), strips OAuth query params on return, and refreshes the current user profile when already logged in.
3
+ - JavaScript/TypeScript storage download examples now use storage upload and decode bytes, and the docs example build ignores generated JS artifacts alongside TypeScript sources.
4
+
1
5
  ## [0.30.0]
2
6
  - Initial TypeScript/React auth package based on `meshagent-flutter-auth`.
package/README.md CHANGED
@@ -74,10 +74,10 @@ The simplest browser login flow is a single `await ensureLogin(...)` call.
74
74
  `ensureLogin(...)` handles all of these cases:
75
75
 
76
76
  - the user is already logged in, so it returns immediately
77
- - the current URL is the configured callback URL, or it carries the default Meshagent callback marker, and contains `?code=...`, so it exchanges the code, stores the session, loads the current user, and removes auth query params from the URL
77
+ - the current URL contains `?code=...` and matches the configured callback URL, or when `callbackUrl` is omitted matches the current page URL after auth query params are stripped, so it exchanges the code, stores the session, loads the current user, and removes auth query params from the URL
78
78
  - the user is not logged in yet, so it generates PKCE values, stores the verifier, and redirects to `/oauth/authorize`
79
79
 
80
- When you omit `callbackUrl`, `ensureLogin(...)` uses the current page as the callback URL and adds `ma_origin=meshagent_auth` so it can tell a Meshagent OAuth return apart from unrelated query params. That marker is removed after a successful callback exchange.
80
+ When you omit `callbackUrl`, `ensureLogin(...)` uses the current page as the callback URL. After the OAuth redirect returns, it strips the auth query params from the current URL and reuses that same URL for the token exchange.
81
81
 
82
82
  ## Example: Ensure Login
83
83
 
@@ -224,9 +224,9 @@ Run `npm run build` to generate `dist/browser/ma-auth.global.js`.
224
224
  Serve that file from your app or copy it into your static assets, then include it with a classic script tag:
225
225
 
226
226
  ```html
227
- <script src="/assets/ma-auth.global.js"></script>
227
+ <script src="https://storage.googleapis.com/cdn.meshagent.com/latest/ma-auth.global.js"></script>
228
228
  <script>
229
- const auth = window.maAuth.MeshagentAuth.current;
229
+ const auth = window.meshagent.auth.MeshagentAuth.current;
230
230
  console.log(auth.isLoggedIn());
231
231
  </script>
232
232
  ```
@@ -240,23 +240,23 @@ TypeScript consumers using the global bundle can add:
240
240
  The browser-global API matches the module API, so the earlier examples translate directly. For example:
241
241
 
242
242
  ```html
243
- <script src="/assets/ma-auth.global.js"></script>
243
+ <script src="https://storage.googleapis.com/cdn.meshagent.com/latest/ma-auth.global.js"></script>
244
244
  <script>
245
245
  async function ensureMeshagentSession(provider) {
246
- await window.maAuth.ensureLogin({
246
+ await window.meshagent.auth.ensureLogin({
247
247
  serverUrl: "https://api.meshagent.com",
248
248
  callbackUrl: "http://localhost:3000/auth/callback",
249
249
  oauthClientId: "YOUR_OAUTH_CLIENT_ID",
250
250
  provider,
251
251
  });
252
252
 
253
- if (!window.maAuth.MeshagentAuth.current.isLoggedIn()) {
253
+ if (!window.meshagent.auth.MeshagentAuth.current.isLoggedIn()) {
254
254
  return;
255
255
  }
256
256
 
257
257
  console.log(
258
258
  "Logged in:",
259
- window.maAuth.MeshagentAuth.current.getSnapshot(),
259
+ window.meshagent.auth.MeshagentAuth.current.getSnapshot(),
260
260
  );
261
261
  }
262
262
  <\/script>