@almyty/auth 1.5.2 → 1.5.3

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
@@ -9,8 +9,9 @@ directory) and shared by `@almyty/agents`, `@almyty/chat`,
9
9
  ## Quick start
10
10
 
11
11
  ```bash
12
- $ npx @almyty/auth login
13
- $ npx @almyty/auth whoami
12
+ $ npm i -g @almyty/cli
13
+ $ almyty login
14
+ $ almyty whoami
14
15
  ```
15
16
 
16
17
  ## Commands
@@ -46,7 +47,7 @@ alongside it. An expired token exits `3`, so `whoami` is a usable
46
47
  precondition in a script:
47
48
 
48
49
  ```bash
49
- npx @almyty/auth whoami --verify > /dev/null || npx @almyty/auth login
50
+ almyty whoami --verify > /dev/null || almyty login
50
51
  ```
51
52
 
52
53
  `whoami` never prints the token — only a first-8/last-4 preview, enough
@@ -34,6 +34,7 @@
34
34
  export interface BrowserLoginResult {
35
35
  token: string;
36
36
  frontendUrl: string;
37
+ organizationId?: string;
37
38
  }
38
39
  export interface BrowserLoginOptions {
39
40
  /**
@@ -236,6 +236,7 @@ export function browserLogin(options = {}) {
236
236
  var params = new URLSearchParams(hash);
237
237
  var token = params.get('token');
238
238
  var state = params.get('state');
239
+ var organizationId = params.get('organizationId');
239
240
  if (!token || !state) {
240
241
  document.getElementById('t').textContent = 'Login failed';
241
242
  document.getElementById('t').className = 'err';
@@ -248,7 +249,7 @@ export function browserLogin(options = {}) {
248
249
  fetch('/cb-complete', {
249
250
  method: 'POST',
250
251
  headers: { 'Content-Type': 'application/json' },
251
- body: JSON.stringify({ token: token, state: state }),
252
+ body: JSON.stringify({ token: token, state: state, organizationId: organizationId }),
252
253
  }).then(function (r) {
253
254
  if (!r.ok) return r.text().then(function (t) { throw new Error(t || ('HTTP ' + r.status)); });
254
255
  window.location.href = '/success';
@@ -288,7 +289,7 @@ export function browserLogin(options = {}) {
288
289
  }
289
290
  res.writeHead(200, { 'Content-Type': 'application/json' });
290
291
  res.end(JSON.stringify({ ok: true }));
291
- settleResolve({ token: body.token, frontendUrl });
292
+ settleResolve({ token: body.token, frontendUrl, ...(typeof body.organizationId === 'string' ? { organizationId: body.organizationId } : {}) });
292
293
  return;
293
294
  }
294
295
  catch (err) {
@@ -331,7 +332,7 @@ export function browserLogin(options = {}) {
331
332
  'Access-Control-Allow-Origin': frontendUrl,
332
333
  });
333
334
  res.end(JSON.stringify({ ok: true }));
334
- settleResolve({ token: body.token, frontendUrl });
335
+ settleResolve({ token: body.token, frontendUrl, ...(typeof body.organizationId === 'string' ? { organizationId: body.organizationId } : {}) });
335
336
  return;
336
337
  }
337
338
  catch (err) {
@@ -12,6 +12,7 @@ export interface StoredCredentials {
12
12
  email?: string;
13
13
  expiresAt?: string;
14
14
  frontendUrl?: string;
15
+ organizationId?: string;
15
16
  }
16
17
  export declare function loadCredentials(): StoredCredentials | null;
17
18
  export declare function saveCredentials(creds: StoredCredentials): void;
@@ -43,6 +44,7 @@ export declare function expiryState(creds: StoredCredentials, now?: Date): {
43
44
  export declare function credentialSummary(creds: StoredCredentials): {
44
45
  url: string;
45
46
  frontendUrl?: string;
47
+ organizationId?: string;
46
48
  email?: string;
47
49
  tokenPreview: string;
48
50
  };
@@ -105,6 +105,7 @@ export function credentialSummary(creds) {
105
105
  : `${'*'.repeat(Math.max(0, token.length))}`;
106
106
  return {
107
107
  url: creds.url,
108
+ ...(creds.organizationId ? { organizationId: creds.organizationId } : {}),
108
109
  ...(creds.frontendUrl ? { frontendUrl: creds.frontendUrl } : {}),
109
110
  ...(creds.email ? { email: creds.email } : {}),
110
111
  tokenPreview: preview,
package/dist/index.js CHANGED
@@ -106,6 +106,7 @@ async function cmdLogin(args) {
106
106
  url: apiUrl,
107
107
  token: result.token,
108
108
  frontendUrl: result.frontendUrl,
109
+ organizationId: result.organizationId,
109
110
  });
110
111
  // Only once the login succeeded. Persisting the URLs first meant a
111
112
  // cancelled `login --api <typo>` left the typo behind for every
@@ -198,6 +199,8 @@ async function cmdWhoami(args) {
198
199
  if (verified?.email || summary.email) {
199
200
  console.log(`Email: ${verified?.email ?? summary.email}`);
200
201
  }
202
+ if (summary.organizationId)
203
+ console.log(`Runner org: ${summary.organizationId}`);
201
204
  console.log(`Token: ${summary.tokenPreview}`);
202
205
  console.log(`Expiry: ${expiry.message}`);
203
206
  if (verified?.organizations?.length) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@almyty/auth",
3
- "version": "1.5.2",
3
+ "version": "1.5.3",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },