adapty 0.9.0 → 0.9.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.
@@ -14,7 +14,7 @@ export default class AuthLogin extends BaseCommand {
14
14
  await this.parse(AuthLogin);
15
15
  const session = await openSession(this.config);
16
16
  if (session.user !== undefined) {
17
- this.log(`Already authenticated as ${session.user.email}. Re-authenticating...`);
17
+ this.log(`Already authenticated as ${session.user.name}. Re-authenticating...`);
18
18
  }
19
19
  // No token yet: the same factory without one, which leaves only auth reachable
20
20
  const adapty = build({ ...session, token: undefined }, {
@@ -45,7 +45,7 @@ export default class AuthLogin extends BaseCommand {
45
45
  signal: this.signal,
46
46
  });
47
47
  await session.store.save({ token: issued.accessToken, user: issued.user });
48
- this.log(`\nAuthenticated as ${issued.user.email}`);
48
+ this.log(`\nAuthenticated as ${issued.user.name}`);
49
49
  this.log(`Session saved to ${session.store.path}`);
50
50
  }
51
51
  /** ADAPTY_APP_URL is the CLI's business: the sdk knows nothing about browsers or dashboards. */
@@ -13,6 +13,7 @@ export default class AuthStatus extends BaseCommand {
13
13
  authenticated: true,
14
14
  config_path: session.store.path,
15
15
  email: session.user?.email,
16
+ name: session.user?.name,
16
17
  source: session.source === 'env' ? 'env' : 'file',
17
18
  token_prefix: session.token.slice(0, 8),
18
19
  };
@@ -4,6 +4,9 @@ export const renderStatus = (status) => {
4
4
  return 'Not authenticated. Run `adapty auth login`.';
5
5
  }
6
6
  const lines = [];
7
+ if (status.name !== undefined) {
8
+ lines.push(`User: ${status.name}`);
9
+ }
7
10
  if (status.email !== undefined) {
8
11
  lines.push(`Email: ${status.email}`);
9
12
  }
@@ -10,6 +10,7 @@ export type Result = {
10
10
  authenticated: true;
11
11
  config_path: string;
12
12
  email: string | undefined;
13
+ name: string | undefined;
13
14
  source: 'env' | 'file';
14
15
  token_prefix: string;
15
16
  };
@@ -1,7 +1,7 @@
1
1
  export type AdaptyConfig = {
2
2
  access_token?: string;
3
3
  user?: {
4
- email: string;
4
+ email?: string;
5
5
  name: string;
6
6
  };
7
7
  };
@@ -3,7 +3,6 @@
3
3
  * gives itself. An input shape belongs to its operation, not here.
4
4
  */
5
5
  export type AuthUser = {
6
- email: string;
7
6
  name: string;
8
7
  };
9
8
  export type IssuedToken = {
@@ -1,5 +1,5 @@
1
1
  export type SessionUser = {
2
- email: string;
2
+ email?: string | undefined;
3
3
  name: string;
4
4
  };
5
5
  export type Session = {
@@ -3,7 +3,8 @@ import { join } from 'node:path';
3
3
  import { StorageError } from './errors.js';
4
4
  /**
5
5
  * The file and field names the published CLI already writes. A rename would log every existing
6
- * user out, so the on-disk contract stays `{ "access_token", "user": { "email", "name" } }`.
6
+ * user out, so the on-disk contract stays `{ "access_token", "user": { "email", "name" } }`, where
7
+ * only a file written before the server stopped sending the email still has one.
7
8
  */
8
9
  const FILE_NAME = 'config.json';
9
10
  /** A file under a directory the adapter picks: the sdk touches neither HOME nor process.env. */
@@ -60,10 +61,10 @@ const toSession = (parsed) => {
60
61
  };
61
62
  const toUser = (value) => {
62
63
  const record = asRecord(value);
63
- if (record === undefined || typeof record.email !== 'string' || typeof record.name !== 'string') {
64
+ if (record === undefined || typeof record.name !== 'string') {
64
65
  return undefined;
65
66
  }
66
- return { email: record.email, name: record.name };
67
+ return typeof record.email === 'string' ? { email: record.email, name: record.name } : { name: record.name };
67
68
  };
68
69
  const asRecord = (value) => (typeof value === 'object' && value !== null ? value : undefined);
69
70
  const isErrno = (error, code) => error instanceof Error && 'code' in error && error.code === code;