instant-cli 1.0.56 → 1.0.57

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.
Files changed (78) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/__tests__/auth.test.ts +128 -0
  3. package/__tests__/config.test.ts +47 -0
  4. package/dist/auth/index.d.ts +4 -0
  5. package/dist/auth/index.d.ts.map +1 -0
  6. package/dist/auth/index.js +103 -0
  7. package/dist/auth/index.js.map +1 -0
  8. package/dist/commands/auth/client/add.d.ts +1 -1
  9. package/dist/commands/auth/client/delete.d.ts +1 -1
  10. package/dist/commands/auth/client/list.d.ts +1 -1
  11. package/dist/commands/auth/client/update.d.ts +1 -1
  12. package/dist/commands/auth/email/pull.d.ts +2 -2
  13. package/dist/commands/auth/email/push.d.ts +1 -1
  14. package/dist/commands/auth/email/reset.d.ts +1 -1
  15. package/dist/commands/auth/email/status.d.ts +2 -2
  16. package/dist/commands/auth/email/verify.d.ts +1 -1
  17. package/dist/commands/auth/origin/add.d.ts +1 -1
  18. package/dist/commands/auth/origin/delete.d.ts +1 -1
  19. package/dist/commands/auth/origin/list.d.ts +1 -1
  20. package/dist/commands/info.d.ts +1 -1
  21. package/dist/commands/init.d.ts +1 -1
  22. package/dist/commands/login.d.ts +1 -1
  23. package/dist/commands/login.d.ts.map +1 -1
  24. package/dist/commands/login.js +2 -2
  25. package/dist/commands/login.js.map +1 -1
  26. package/dist/commands/logout.d.ts +1 -2
  27. package/dist/commands/logout.d.ts.map +1 -1
  28. package/dist/commands/logout.js +9 -16
  29. package/dist/commands/logout.js.map +1 -1
  30. package/dist/commands/pull.d.ts +1 -1
  31. package/dist/commands/push.d.ts +1 -1
  32. package/dist/commands/query.d.ts +1 -1
  33. package/dist/context/authToken.d.ts +2 -3
  34. package/dist/context/authToken.d.ts.map +1 -1
  35. package/dist/context/authToken.js +4 -17
  36. package/dist/context/authToken.js.map +1 -1
  37. package/dist/context/currentApp.d.ts +1 -1
  38. package/dist/layer.d.ts +2 -2
  39. package/dist/layer.d.ts.map +1 -1
  40. package/dist/lib/config.d.ts +5 -0
  41. package/dist/lib/config.d.ts.map +1 -0
  42. package/dist/lib/config.js +37 -0
  43. package/dist/lib/config.js.map +1 -0
  44. package/dist/lib/createApp.d.ts +1 -1
  45. package/dist/lib/email.d.ts +1 -1
  46. package/dist/lib/handleEnv.d.ts +1 -1
  47. package/dist/lib/http.d.ts +3 -6
  48. package/dist/lib/http.d.ts.map +1 -1
  49. package/dist/lib/http.js +3 -36
  50. package/dist/lib/http.js.map +1 -1
  51. package/dist/lib/login.d.ts +3 -4
  52. package/dist/lib/login.d.ts.map +1 -1
  53. package/dist/lib/login.js +5 -6
  54. package/dist/lib/login.js.map +1 -1
  55. package/dist/lib/oauth.d.ts +9 -9
  56. package/dist/lib/pullPerms.d.ts +1 -1
  57. package/dist/lib/pullSchema.d.ts +1 -1
  58. package/dist/lib/pushPerms.d.ts +1 -1
  59. package/dist/lib/pushSchema.d.ts +1 -1
  60. package/dist/old.d.ts +1 -1
  61. package/dist/old.d.ts.map +1 -1
  62. package/dist/old.js +6 -7
  63. package/dist/old.js.map +1 -1
  64. package/dist/util/getAppName.d.ts +1 -1
  65. package/package.json +10 -4
  66. package/src/auth/index.ts +125 -0
  67. package/src/commands/login.ts +2 -2
  68. package/src/commands/logout.ts +17 -18
  69. package/src/context/authToken.ts +6 -21
  70. package/src/lib/config.ts +68 -0
  71. package/src/lib/http.ts +4 -68
  72. package/src/lib/login.ts +5 -11
  73. package/src/old.js +6 -10
  74. package/dist/util/getAuthPaths.d.ts +0 -5
  75. package/dist/util/getAuthPaths.d.ts.map +0 -1
  76. package/dist/util/getAuthPaths.js +0 -10
  77. package/dist/util/getAuthPaths.js.map +0 -1
  78. package/src/util/getAuthPaths.ts +0 -12
@@ -1,4 +1,4 @@
1
1
 
2
- > instant-cli@1.0.56 build /home/runner/work/instant/instant/client/packages/cli
2
+ > instant-cli@1.0.57 build /home/runner/work/instant/instant/client/packages/cli
3
3
  > rm -rf dist; tsc -p tsconfig.build.json
4
4
 
@@ -0,0 +1,128 @@
1
+ import {
2
+ mkdir,
3
+ mkdtemp,
4
+ readFile,
5
+ rm,
6
+ unlink,
7
+ writeFile,
8
+ } from 'node:fs/promises';
9
+ import { tmpdir } from 'node:os';
10
+ import { join } from 'node:path';
11
+ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
12
+
13
+ const paths = vi.hoisted(() => ({ root: '' }));
14
+
15
+ vi.mock('env-paths', () => ({
16
+ default: (name: string) => ({ config: `${paths.root}/${name}` }),
17
+ }));
18
+
19
+ import {
20
+ readAuthToken,
21
+ removeAuthToken,
22
+ writeAuthToken,
23
+ } from '../src/auth/index.ts';
24
+
25
+ beforeEach(async () => {
26
+ paths.root = await mkdtemp(join(tmpdir(), 'instant-cli-auth-'));
27
+ });
28
+
29
+ afterEach(async () => {
30
+ await rm(paths.root, { recursive: true, force: true });
31
+ });
32
+
33
+ const writeLegacyAuthToken = async (
34
+ configName: 'instantdb-prod' | 'instantdb-dev',
35
+ authToken: string,
36
+ ) => {
37
+ const configDir = join(paths.root, configName);
38
+ await mkdir(configDir, { recursive: true });
39
+ await writeFile(join(configDir, 'a'), authToken);
40
+ };
41
+
42
+ describe('backend-scoped auth tokens', () => {
43
+ it('treats equivalent backend URLs as the same credential scope', async () => {
44
+ await writeAuthToken(
45
+ 'https://EXAMPLE.com:443/backend/?ignored=true',
46
+ 'auth-token',
47
+ );
48
+
49
+ expect(await readAuthToken('https://example.com/backend')).toBe(
50
+ 'auth-token',
51
+ );
52
+ });
53
+
54
+ it('rejects non-HTTP URLs', async () => {
55
+ await expect(readAuthToken('ftp://example.com')).rejects.toThrow(
56
+ 'Instant API URI must use http:// or https://',
57
+ );
58
+ });
59
+
60
+ it('stores and removes credentials independently by backend', async () => {
61
+ const cloudApiURI = 'https://api.instantdb.com';
62
+ const selfHostedApiURI = 'https://instant.example.com';
63
+
64
+ await writeAuthToken(cloudApiURI, 'cloud-token');
65
+ await writeAuthToken(selfHostedApiURI, 'self-hosted-token');
66
+
67
+ expect(await readAuthToken(cloudApiURI)).toBe('cloud-token');
68
+ expect(await readAuthToken(selfHostedApiURI)).toBe('self-hosted-token');
69
+
70
+ expect(await removeAuthToken(selfHostedApiURI)).toBe(true);
71
+ expect(await readAuthToken(selfHostedApiURI)).toBeNull();
72
+ expect(await readAuthToken(cloudApiURI)).toBe('cloud-token');
73
+ });
74
+
75
+ it('does not read or overwrite a legacy Cloud token for a custom backend', async () => {
76
+ await writeLegacyAuthToken('instantdb-prod', 'cloud-token');
77
+
78
+ const selfHostedApiURI = 'https://instant.example.com';
79
+ expect(await readAuthToken(selfHostedApiURI)).toBeNull();
80
+
81
+ await writeAuthToken(selfHostedApiURI, 'self-hosted-token');
82
+ expect(
83
+ await readFile(join(paths.root, 'instantdb-prod', 'a'), 'utf8'),
84
+ ).toBe('cloud-token');
85
+ });
86
+
87
+ it('copies the legacy Cloud token into scoped storage', async () => {
88
+ const apiURI = 'https://api.instantdb.com';
89
+ const legacyPath = join(paths.root, 'instantdb-prod', 'a');
90
+ await writeLegacyAuthToken('instantdb-prod', 'cloud-token');
91
+
92
+ expect(await readAuthToken(apiURI)).toBe('cloud-token');
93
+ await unlink(legacyPath);
94
+ expect(await readAuthToken(apiURI)).toBe('cloud-token');
95
+ });
96
+
97
+ it('copies the legacy localhost token into scoped storage', async () => {
98
+ const apiURI = 'http://localhost:8888';
99
+ const legacyPath = join(paths.root, 'instantdb-dev', 'a');
100
+ await writeLegacyAuthToken('instantdb-dev', 'local-token');
101
+
102
+ expect(await readAuthToken(apiURI)).toBe('local-token');
103
+ await unlink(legacyPath);
104
+ expect(await readAuthToken(apiURI)).toBe('local-token');
105
+ });
106
+
107
+ it('keeps legacy clients logged in for known backends', async () => {
108
+ await writeAuthToken('https://api.instantdb.com', 'cloud-token');
109
+ await writeAuthToken('http://localhost:8888', 'local-token');
110
+
111
+ expect(
112
+ await readFile(join(paths.root, 'instantdb-prod', 'a'), 'utf8'),
113
+ ).toBe('cloud-token');
114
+ expect(await readFile(join(paths.root, 'instantdb-dev', 'a'), 'utf8')).toBe(
115
+ 'local-token',
116
+ );
117
+ });
118
+
119
+ it('logs out legacy and scoped credentials for the current backend', async () => {
120
+ const apiURI = 'https://api.instantdb.com';
121
+ await writeLegacyAuthToken('instantdb-prod', 'legacy-token');
122
+ await writeAuthToken(apiURI, 'scoped-token');
123
+
124
+ expect(await removeAuthToken(apiURI)).toBe(true);
125
+ expect(await readAuthToken(apiURI)).toBeNull();
126
+ expect(await removeAuthToken(apiURI)).toBe(false);
127
+ });
128
+ });
@@ -0,0 +1,47 @@
1
+ import { Effect } from 'effect';
2
+ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
3
+
4
+ const mocks = vi.hoisted(() => ({
5
+ readInstantConfigFile: vi.fn(),
6
+ }));
7
+
8
+ vi.mock('../src/util/instantConfig.ts', () => ({
9
+ readInstantConfigFile: mocks.readInstantConfigFile,
10
+ }));
11
+
12
+ import { getDashUrl } from '../src/lib/config.ts';
13
+
14
+ beforeEach(() => {
15
+ vi.stubEnv('INSTANT_CLI_API_URI', undefined);
16
+ vi.stubEnv('INSTANT_CLI_DASH_URI', undefined);
17
+ vi.stubEnv('INSTANT_CLI_DEV', undefined);
18
+ mocks.readInstantConfigFile.mockResolvedValue({});
19
+ });
20
+
21
+ afterEach(() => {
22
+ vi.unstubAllEnvs();
23
+ vi.clearAllMocks();
24
+ });
25
+
26
+ describe('dashboard URL configuration', () => {
27
+ it('reads dashURI from instant.config.ts', async () => {
28
+ mocks.readInstantConfigFile.mockResolvedValue({
29
+ dashURI: 'https://dash.instant.example',
30
+ });
31
+
32
+ await expect(Effect.runPromise(getDashUrl)).resolves.toBe(
33
+ 'https://dash.instant.example',
34
+ );
35
+ });
36
+
37
+ it('prefers INSTANT_CLI_DASH_URI over instant.config.ts', async () => {
38
+ vi.stubEnv('INSTANT_CLI_DASH_URI', 'https://dash.env.example');
39
+ mocks.readInstantConfigFile.mockResolvedValue({
40
+ dashURI: 'https://dash.config.example',
41
+ });
42
+
43
+ await expect(Effect.runPromise(getDashUrl)).resolves.toBe(
44
+ 'https://dash.env.example',
45
+ );
46
+ });
47
+ });
@@ -0,0 +1,4 @@
1
+ export declare function readAuthToken(apiURI: string): Promise<string | null>;
2
+ export declare function writeAuthToken(apiURI: string, authToken: string): Promise<void>;
3
+ export declare function removeAuthToken(apiURI: string): Promise<boolean>;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AA0DA,wBAAsB,aAAa,CAAC,MAAM,EAAE,MAAM,0BAqBjD;AAED,wBAAsB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,iBAQrE;AAOD,wBAAsB,eAAe,CAAC,MAAM,EAAE,MAAM,oBAQnD"}
@@ -0,0 +1,103 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { mkdir, readFile, unlink, writeFile } from 'node:fs/promises';
3
+ import { dirname, join } from 'node:path';
4
+ import envPaths from 'env-paths';
5
+ const CLOUD_API_URI = 'https://api.instantdb.com';
6
+ const LOCAL_API_URI = 'http://localhost:8888';
7
+ function normalizeApiURI(apiURI) {
8
+ const url = new URL(apiURI);
9
+ if (url.protocol !== 'http:' && url.protocol !== 'https:') {
10
+ throw new Error('Instant API URI must use http:// or https://');
11
+ }
12
+ url.search = '';
13
+ url.hash = '';
14
+ url.pathname = url.pathname.replace(/\/+$/, '');
15
+ return url.toString().replace(/\/$/, '');
16
+ }
17
+ function getAuthConfigFilePath(apiURI) {
18
+ const normalizedApiURI = normalizeApiURI(apiURI);
19
+ const backendKey = createHash('sha256')
20
+ .update(normalizedApiURI)
21
+ .digest('hex');
22
+ const { config: configDir } = envPaths('instantdb-prod');
23
+ return join(configDir, 'auth', backendKey);
24
+ }
25
+ function getLegacyAuthConfigFilePath(apiURI) {
26
+ const normalizedApiURI = normalizeApiURI(apiURI);
27
+ const legacyConfigName = normalizedApiURI === CLOUD_API_URI
28
+ ? 'instantdb-prod'
29
+ : normalizedApiURI === LOCAL_API_URI
30
+ ? 'instantdb-dev'
31
+ : null;
32
+ if (!legacyConfigName) {
33
+ return null;
34
+ }
35
+ return join(envPaths(legacyConfigName).config, 'a');
36
+ }
37
+ async function readFileOrNull(filePath) {
38
+ try {
39
+ return (await readFile(filePath, 'utf8')).trim();
40
+ }
41
+ catch (error) {
42
+ if (isFileNotFoundError(error)) {
43
+ return null;
44
+ }
45
+ throw error;
46
+ }
47
+ }
48
+ export async function readAuthToken(apiURI) {
49
+ const authConfigFilePath = getAuthConfigFilePath(apiURI);
50
+ const authToken = await readFileOrNull(authConfigFilePath);
51
+ if (authToken) {
52
+ return authToken;
53
+ }
54
+ const legacyPath = getLegacyAuthConfigFilePath(apiURI);
55
+ if (!legacyPath) {
56
+ return null;
57
+ }
58
+ const legacyAuthToken = await readFileOrNull(legacyPath);
59
+ if (!legacyAuthToken) {
60
+ return null;
61
+ }
62
+ await writeAuthTokenFile(authConfigFilePath, legacyAuthToken).catch(() => undefined);
63
+ return legacyAuthToken;
64
+ }
65
+ export async function writeAuthToken(apiURI, authToken) {
66
+ const authConfigFilePath = getAuthConfigFilePath(apiURI);
67
+ await writeAuthTokenFile(authConfigFilePath, authToken);
68
+ const legacyPath = getLegacyAuthConfigFilePath(apiURI);
69
+ if (legacyPath) {
70
+ await writeAuthTokenFile(legacyPath, authToken).catch(() => undefined);
71
+ }
72
+ }
73
+ async function writeAuthTokenFile(filePath, authToken) {
74
+ await mkdir(dirname(filePath), { recursive: true });
75
+ await writeFile(filePath, authToken, { encoding: 'utf8', mode: 0o600 });
76
+ }
77
+ export async function removeAuthToken(apiURI) {
78
+ const authConfigFilePath = getAuthConfigFilePath(apiURI);
79
+ const legacyPath = getLegacyAuthConfigFilePath(apiURI);
80
+ const paths = legacyPath
81
+ ? [authConfigFilePath, legacyPath]
82
+ : [authConfigFilePath];
83
+ const removed = await Promise.all(paths.map(removeFileIfExists));
84
+ return removed.some(Boolean);
85
+ }
86
+ async function removeFileIfExists(filePath) {
87
+ try {
88
+ await unlink(filePath);
89
+ return true;
90
+ }
91
+ catch (error) {
92
+ if (isFileNotFoundError(error)) {
93
+ return false;
94
+ }
95
+ throw error;
96
+ }
97
+ }
98
+ function isFileNotFoundError(error) {
99
+ return (error instanceof Error &&
100
+ 'code' in error &&
101
+ error.code === 'ENOENT');
102
+ }
103
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,QAAQ,MAAM,WAAW,CAAC;AAEjC,MAAM,aAAa,GAAG,2BAA2B,CAAC;AAClD,MAAM,aAAa,GAAG,uBAAuB,CAAC;AAE9C,SAAS,eAAe,CAAC,MAAc;IACrC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC;IAC5B,IAAI,GAAG,CAAC,QAAQ,KAAK,OAAO,IAAI,GAAG,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAC1D,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;IAClE,CAAC;IAED,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC;IAChB,GAAG,CAAC,IAAI,GAAG,EAAE,CAAC;IACd,GAAG,CAAC,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAEhD,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,C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AAU,eAAe,CAAC,MAAc;IAClD,MAAM,kBAAkB,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAC;IACzD,MAAM,UAAU,GAAG,2BAA2B,CAAC,MAAM,CAAC,CAAC;IACvD,MAAM,KAAK,GAAG,UAAU;QACtB,CAAC,CAAC,CAAC,kBAAkB,EAAE,UAAU,CAAC;QAClC,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC;IACzB,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC,CAAC;IACjE,OAAO,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AAC/B,CAAC;AAED,KAAK,UAAU,kBAAkB,CAAC,QAAgB;IAChD,IAAI,CAAC;QACH,MAAM,MAAM,CAAC,QAAQ,CAAC,CAAC;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,mBAAmB,CAAC,KAAK,CAAC,EAAE,CAAC;YAC/B,OAAO,KAAK,CAAC;QACf,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAED,SAAS,mBAAmB,CAAC,KAAc;IACzC,OAAO,CACL,KAAK,YAAY,KAAK;QACtB,MAAM,IAAI,KAAK;QACd,KAA+B,CAAC,IAAI,KAAK,QAAQ,CACnD,CAAC;AACJ,CAAC","sourcesContent":["import { createHash } from 'node:crypto';\nimport { mkdir, readFile, unlink, writeFile } from 'node:fs/promises';\nimport { dirname, join } from 'node:path';\nimport envPaths from 'env-paths';\n\nconst CLOUD_API_URI = 'https://api.instantdb.com';\nconst LOCAL_API_URI = 'http://localhost:8888';\n\nfunction normalizeApiURI(apiURI: string) {\n const url = new URL(apiURI);\n if (url.protocol !== 'http:' && url.protocol !== 'https:') {\n throw new Error('Instant API URI must use http:// or https://');\n }\n\n url.search = '';\n url.hash = '';\n url.pathname = url.pathname.replace(/\\/+$/, '');\n\n return url.toString().replace(/\\/$/, '');\n}\n\nfunction getAuthConfigFilePath(apiURI: string) {\n const normalizedApiURI = normalizeApiURI(apiURI);\n const backendKey = createHash('sha256')\n .update(normalizedApiURI)\n .digest('hex');\n const { config: configDir } = envPaths('instantdb-prod');\n\n return join(configDir, 'auth', backendKey);\n}\n\nfunction getLegacyAuthConfigFilePath(apiURI: string) {\n const normalizedApiURI = normalizeApiURI(apiURI);\n const legacyConfigName =\n normalizedApiURI === CLOUD_API_URI\n ? 'instantdb-prod'\n : normalizedApiURI === LOCAL_API_URI\n ? 'instantdb-dev'\n : null;\n\n if (!legacyConfigName) {\n return null;\n }\n\n return join(envPaths(legacyConfigName).config, 'a');\n}\n\nasync function readFileOrNull(filePath: string) {\n try {\n return (await readFile(filePath, 'utf8')).trim();\n } catch (error) {\n if (isFileNotFoundError(error)) {\n return null;\n }\n throw error;\n }\n}\n\nexport async function readAuthToken(apiURI: string) {\n const authConfigFilePath = getAuthConfigFilePath(apiURI);\n const authToken = await readFileOrNull(authConfigFilePath);\n if (authToken) {\n return authToken;\n }\n\n const legacyPath = getLegacyAuthConfigFilePath(apiURI);\n if (!legacyPath) {\n return null;\n }\n\n const legacyAuthToken = await readFileOrNull(legacyPath);\n if (!legacyAuthToken) {\n return null;\n }\n\n await writeAuthTokenFile(authConfigFilePath, legacyAuthToken).catch(\n () => undefined,\n );\n return legacyAuthToken;\n}\n\nexport async function writeAuthToken(apiURI: string, authToken: string) {\n const authConfigFilePath = getAuthConfigFilePath(apiURI);\n await writeAuthTokenFile(authConfigFilePath, authToken);\n\n const legacyPath = getLegacyAuthConfigFilePath(apiURI);\n if (legacyPath) {\n await writeAuthTokenFile(legacyPath, authToken).catch(() => undefined);\n }\n}\n\nasync function writeAuthTokenFile(filePath: string, authToken: string) {\n await mkdir(dirname(filePath), { recursive: true });\n await writeFile(filePath, authToken, { encoding: 'utf8', mode: 0o600 });\n}\n\nexport async function removeAuthToken(apiURI: string) {\n const authConfigFilePath = getAuthConfigFilePath(apiURI);\n const legacyPath = getLegacyAuthConfigFilePath(apiURI);\n const paths = legacyPath\n ? [authConfigFilePath, legacyPath]\n : [authConfigFilePath];\n const removed = await Promise.all(paths.map(removeFileIfExists));\n return removed.some(Boolean);\n}\n\nasync function removeFileIfExists(filePath: string) {\n try {\n await unlink(filePath);\n return true;\n } catch (error) {\n if (isFileNotFoundError(error)) {\n return false;\n }\n throw error;\n }\n}\n\nfunction isFileNotFoundError(error: unknown): error is NodeJS.ErrnoException {\n return (\n error instanceof Error &&\n 'code' in error &&\n (error as NodeJS.ErrnoException).code === 'ENOENT'\n );\n}\n"]}
@@ -5,5 +5,5 @@ export declare const authClientAddCmd: (opts: {
5
5
  type?: string | undefined;
6
6
  name?: string | undefined;
7
7
  app?: string | undefined;
8
- } & Record<string, unknown>) => Effect.Effect<void | undefined, import("../../../lib/ui.ts").UIError | import("../../../lib/http.ts").InstantHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("effect/ParseResult").ParseError | import("@effect/platform/HttpClientError").ResponseError, GlobalOpts | import("@effect/platform/FileSystem").FileSystem | import("../../../lib/http.ts").InstantHttpAuthed | import("../../../context/currentApp.ts").CurrentApp>;
8
+ } & Record<string, unknown>) => Effect.Effect<void | undefined, import("../../../lib/ui.ts").UIError | import("effect/ParseResult").ParseError | import("../../../lib/http.ts").InstantHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("@effect/platform/HttpClientError").ResponseError, GlobalOpts | import("../../../lib/http.ts").InstantHttpAuthed | import("@effect/platform/FileSystem").FileSystem | import("../../../context/currentApp.ts").CurrentApp>;
9
9
  //# sourceMappingURL=add.d.ts.map
@@ -7,5 +7,5 @@ export declare const authClientDeleteCmd: (opts: {
7
7
  id?: string | undefined;
8
8
  name?: string | undefined;
9
9
  app?: string | undefined;
10
- }) => Effect.Effect<undefined, BadArgsError | import("../../../lib/ui.ts").UIError | import("../../../lib/http.ts").InstantHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("effect/ParseResult").ParseError | import("@effect/platform/HttpClientError").ResponseError, GlobalOpts | InstantHttpAuthed | CurrentApp>;
10
+ }) => Effect.Effect<undefined, BadArgsError | import("../../../lib/ui.ts").UIError | import("effect/ParseResult").ParseError | import("../../../lib/http.ts").InstantHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("@effect/platform/HttpClientError").ResponseError, GlobalOpts | InstantHttpAuthed | CurrentApp>;
11
11
  //# sourceMappingURL=delete.d.ts.map
@@ -2,5 +2,5 @@ import { Effect } from 'effect';
2
2
  export declare const authClientListCmd: (_opts: {
3
3
  app?: string | undefined;
4
4
  json?: true | undefined;
5
- }) => Effect.Effect<void, import("../../../lib/http.ts").InstantHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("effect/ParseResult").ParseError | import("@effect/platform/HttpClientError").ResponseError, import("../../../lib/http.ts").InstantHttpAuthed | import("../../../context/currentApp.ts").CurrentApp>;
5
+ }) => Effect.Effect<void, import("effect/ParseResult").ParseError | import("../../../lib/http.ts").InstantHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("@effect/platform/HttpClientError").ResponseError, import("../../../lib/http.ts").InstantHttpAuthed | import("../../../context/currentApp.ts").CurrentApp>;
6
6
  //# sourceMappingURL=list.d.ts.map
@@ -4,5 +4,5 @@ export declare const authClientUpdateCmd: (opts: {
4
4
  id?: string | undefined;
5
5
  name?: string | undefined;
6
6
  app?: string | undefined;
7
- } & Record<string, unknown>) => Effect.Effect<void | undefined, import("../../../lib/http.ts").InstantHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("effect/ParseResult").ParseError | import("@effect/platform/HttpClientError").ResponseError, GlobalOpts | import("@effect/platform/FileSystem").FileSystem | import("../../../lib/http.ts").InstantHttpAuthed | import("../../../context/currentApp.ts").CurrentApp>;
7
+ } & Record<string, unknown>) => Effect.Effect<void | undefined, import("effect/ParseResult").ParseError | import("../../../lib/http.ts").InstantHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("@effect/platform/HttpClientError").ResponseError, GlobalOpts | import("../../../lib/http.ts").InstantHttpAuthed | import("@effect/platform/FileSystem").FileSystem | import("../../../context/currentApp.ts").CurrentApp>;
8
8
  //# sourceMappingURL=update.d.ts.map
@@ -7,7 +7,7 @@ import type { EmailConfig } from '../../../lib/email.ts';
7
7
  export declare const authEmailPullCmd: (opts: {
8
8
  app?: string | undefined;
9
9
  file?: string | undefined;
10
- }) => Effect.Effect<void, BadArgsError | import("effect/Cause").UnknownException | import("../../../lib/http.ts").InstantHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("effect/ParseResult").ParseError | import("@effect/platform/HttpClientError").ResponseError | import("@effect/platform/Error").PlatformError, import("../../../context/globalOpts.ts").GlobalOpts | ProjectInfo | InstantHttp | import("@effect/platform/FileSystem").FileSystem | import("../../../lib/http.ts").InstantHttpAuthed | Path.Path | import("../../../context/currentApp.ts").CurrentApp>;
10
+ }) => Effect.Effect<void, BadArgsError | import("effect/Cause").UnknownException | import("effect/ParseResult").ParseError | import("../../../lib/http.ts").InstantHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("@effect/platform/HttpClientError").ResponseError | import("@effect/platform/Error").PlatformError, import("../../../context/globalOpts.ts").GlobalOpts | ProjectInfo | InstantHttp | import("../../../lib/http.ts").InstantHttpAuthed | import("@effect/platform/FileSystem").FileSystem | Path.Path | import("../../../context/currentApp.ts").CurrentApp>;
11
11
  export type EmailConfig = (typeof EmailConfig.Type)['authEmail'];
12
12
  type WriteEmailTemplateOpts = {
13
13
  emailPath?: string;
@@ -19,6 +19,6 @@ export declare const getDefaultEmailTemplate: Effect.Effect<{
19
19
  senderName: string;
20
20
  senderEmail: string | undefined;
21
21
  body: string;
22
- }, import("../../../lib/http.ts").InstantHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("effect/ParseResult").ParseError | import("@effect/platform/HttpClientError").ResponseError, InstantHttp | import("../../../lib/http.ts").InstantHttpAuthed | import("../../../context/currentApp.ts").CurrentApp>;
22
+ }, import("effect/ParseResult").ParseError | import("../../../lib/http.ts").InstantHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("@effect/platform/HttpClientError").ResponseError, InstantHttp | import("../../../lib/http.ts").InstantHttpAuthed | import("../../../context/currentApp.ts").CurrentApp>;
23
23
  export {};
24
24
  //# sourceMappingURL=pull.d.ts.map
@@ -4,5 +4,5 @@ import { InstantHttpAuthed } from '../../../lib/http.ts';
4
4
  export declare const authEmailPushCmd: (opts: {
5
5
  app?: string | undefined;
6
6
  file?: string | undefined;
7
- }) => Effect.Effect<void, import("../../../errors.ts").BadArgsError | import("../../../lib/http.ts").InstantHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("effect/ParseResult").ParseError | import("@effect/platform/HttpClientError").ResponseError | import("@effect/platform/HttpBody").HttpBodyError | import("../../../lib/email.ts").NoEmailFileFound, import("../../../lib/http.ts").InstantHttp | InstantHttpAuthed | CurrentApp>;
7
+ }) => Effect.Effect<void, import("../../../errors.ts").BadArgsError | import("effect/ParseResult").ParseError | import("../../../lib/http.ts").InstantHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("@effect/platform/HttpClientError").ResponseError | import("@effect/platform/HttpBody").HttpBodyError | import("../../../lib/email.ts").NoEmailFileFound, import("../../../lib/http.ts").InstantHttp | InstantHttpAuthed | CurrentApp>;
8
8
  //# sourceMappingURL=push.d.ts.map
@@ -1,5 +1,5 @@
1
1
  import { Effect } from 'effect';
2
2
  import { CurrentApp } from '../../../context/currentApp.ts';
3
3
  import { InstantHttpAuthed } from '../../../lib/http.ts';
4
- export declare const authEmailResetCmd: () => Effect.Effect<void, import("../../../errors.ts").BadArgsError | import("effect/Cause").UnknownException | import("../../../lib/http.ts").InstantHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("effect/ParseResult").ParseError | import("@effect/platform/HttpClientError").ResponseError | import("@effect/platform/Error").PlatformError, import("../../../context/globalOpts.ts").GlobalOpts | import("../../../context/projectInfo.ts").ProjectInfo | import("../../../lib/http.ts").InstantHttp | import("@effect/platform/FileSystem").FileSystem | InstantHttpAuthed | import("@effect/platform/Path").Path | CurrentApp>;
4
+ export declare const authEmailResetCmd: () => Effect.Effect<void, import("../../../errors.ts").BadArgsError | import("effect/Cause").UnknownException | import("effect/ParseResult").ParseError | import("../../../lib/http.ts").InstantHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("@effect/platform/HttpClientError").ResponseError | import("@effect/platform/Error").PlatformError, import("../../../context/globalOpts.ts").GlobalOpts | import("../../../context/projectInfo.ts").ProjectInfo | import("../../../lib/http.ts").InstantHttp | InstantHttpAuthed | import("@effect/platform/FileSystem").FileSystem | import("@effect/platform/Path").Path | CurrentApp>;
5
5
  //# sourceMappingURL=reset.d.ts.map
@@ -49,9 +49,9 @@ export declare const getEmailTemplateStatus: Effect.Effect<{
49
49
  readonly verification_verified: boolean | null | undefined;
50
50
  readonly verification_id: string | null | undefined;
51
51
  readonly email_type: string;
52
- } | null | undefined, import("../../../lib/http.ts").InstantHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("effect/ParseResult").ParseError | import("@effect/platform/HttpClientError").ResponseError, InstantHttpAuthed | CurrentApp>;
52
+ } | null | undefined, import("effect/ParseResult").ParseError | import("../../../lib/http.ts").InstantHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("@effect/platform/HttpClientError").ResponseError, InstantHttpAuthed | CurrentApp>;
53
53
  export declare const emailStatusCmd: (opts: {
54
54
  app?: string | undefined;
55
55
  json?: true | undefined;
56
- }) => Effect.Effect<void, import("../../../lib/http.ts").InstantHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("effect/ParseResult").ParseError | import("@effect/platform/HttpClientError").ResponseError, InstantHttpAuthed | CurrentApp>;
56
+ }) => Effect.Effect<void, import("effect/ParseResult").ParseError | import("../../../lib/http.ts").InstantHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("@effect/platform/HttpClientError").ResponseError, InstantHttpAuthed | CurrentApp>;
57
57
  //# sourceMappingURL=status.d.ts.map
@@ -1,5 +1,5 @@
1
1
  import { Effect } from 'effect';
2
2
  export declare const verifyCmd: (code: string, _opts: {
3
3
  app?: string | undefined;
4
- }) => Effect.Effect<void, import("../../../lib/http.ts").InstantHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("effect/ParseResult").ParseError | import("@effect/platform/HttpClientError").ResponseError, import("../../../lib/http.ts").InstantHttpAuthed | import("../../../context/currentApp.ts").CurrentApp>;
4
+ }) => Effect.Effect<void, import("effect/ParseResult").ParseError | import("../../../lib/http.ts").InstantHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("@effect/platform/HttpClientError").ResponseError, import("../../../lib/http.ts").InstantHttpAuthed | import("../../../context/currentApp.ts").CurrentApp>;
5
5
  //# sourceMappingURL=verify.d.ts.map
@@ -8,5 +8,5 @@ export declare const authOriginAddCmd: (opts: {
8
8
  site?: string | undefined;
9
9
  scheme?: string | undefined;
10
10
  app?: string | undefined;
11
- } & Record<string, unknown>) => Effect.Effect<void | undefined, import("../../../lib/ui.ts").UIError | import("../../../lib/http.ts").InstantHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("effect/ParseResult").ParseError | import("@effect/platform/HttpClientError").ResponseError, GlobalOpts | import("../../../lib/http.ts").InstantHttpAuthed | import("../../../context/currentApp.ts").CurrentApp>;
11
+ } & Record<string, unknown>) => Effect.Effect<void | undefined, import("../../../lib/ui.ts").UIError | import("effect/ParseResult").ParseError | import("../../../lib/http.ts").InstantHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("@effect/platform/HttpClientError").ResponseError, GlobalOpts | import("../../../lib/http.ts").InstantHttpAuthed | import("../../../context/currentApp.ts").CurrentApp>;
12
12
  //# sourceMappingURL=add.d.ts.map
@@ -4,5 +4,5 @@ import { GlobalOpts } from '../../../context/globalOpts.ts';
4
4
  export declare const authOriginDeleteCmd: (opts: {
5
5
  id?: string | undefined;
6
6
  app?: string | undefined;
7
- }) => Effect.Effect<undefined, BadArgsError | import("../../../lib/ui.ts").UIError | import("../../../lib/http.ts").InstantHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("effect/ParseResult").ParseError | import("@effect/platform/HttpClientError").ResponseError, GlobalOpts | import("../../../lib/http.ts").InstantHttpAuthed | import("../../../context/currentApp.ts").CurrentApp>;
7
+ }) => Effect.Effect<undefined, BadArgsError | import("../../../lib/ui.ts").UIError | import("effect/ParseResult").ParseError | import("../../../lib/http.ts").InstantHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("@effect/platform/HttpClientError").ResponseError, GlobalOpts | import("../../../lib/http.ts").InstantHttpAuthed | import("../../../context/currentApp.ts").CurrentApp>;
8
8
  //# sourceMappingURL=delete.d.ts.map
@@ -5,5 +5,5 @@ export declare const originDisplay: (origin: Schema.Schema.Type<typeof Authorize
5
5
  export declare const authOriginListCmd: (_opts: {
6
6
  app?: string | undefined;
7
7
  json?: true | undefined;
8
- }) => Effect.Effect<void, import("../../../lib/http.ts").InstantHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("effect/ParseResult").ParseError | import("@effect/platform/HttpClientError").ResponseError, import("../../../lib/http.ts").InstantHttpAuthed | import("../../../context/currentApp.ts").CurrentApp>;
8
+ }) => Effect.Effect<void, import("effect/ParseResult").ParseError | import("../../../lib/http.ts").InstantHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("@effect/platform/HttpClientError").ResponseError, import("../../../lib/http.ts").InstantHttpAuthed | import("../../../context/currentApp.ts").CurrentApp>;
9
9
  //# sourceMappingURL=list.d.ts.map
@@ -5,5 +5,5 @@ export declare const DashAppResponse: Schema.Struct<{
5
5
  title: typeof Schema.String;
6
6
  }>;
7
7
  }>;
8
- export declare const infoCommand: () => Effect.Effect<void, Error | import("@effect/platform/HttpClientError").RequestError | import("effect/ParseResult").ParseError | import("@effect/platform/HttpClientError").ResponseError | import("effect/ConfigError").ConfigError, never>;
8
+ export declare const infoCommand: () => Effect.Effect<void, Error | import("effect/ConfigError").ConfigError | import("effect/ParseResult").ParseError | import("@effect/platform/HttpClientError").RequestError | import("@effect/platform/HttpClientError").ResponseError, never>;
9
9
  //# sourceMappingURL=info.d.ts.map
@@ -1,5 +1,5 @@
1
1
  import { Effect } from 'effect';
2
2
  import { initDef } from '../index.ts';
3
3
  import type { OptsFromCommand } from '../index.ts';
4
- export declare const initCommand: (_options: OptsFromCommand<typeof initDef>) => Effect.Effect<void, import("../errors.ts").BadArgsError | import("effect/Cause").UnknownException | import("../lib/http.ts").InstantHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("effect/ParseResult").ParseError | import("@effect/platform/HttpClientError").ResponseError | import("@effect/platform/Error").PlatformError | import("effect/ConfigError").ConfigError | import("@effect/platform/HttpBody").HttpBodyError | import("../lib/pushSchema.ts").ReadSchemaFileError | import("../lib/pushSchema.ts").SchemaDiffError | import("../lib/pushSchema.ts").GetSchemaError | import("../lib/pushSchema.ts").SchemaValidationError | import("../lib/pushSchema.ts").WaitForJobsError | import("../lib/pushSchema.ts").CancelSchemaError | import("../util/mergeSchema.ts").MergeSchemaError | import("../lib/pushPerms.ts").NoPermsFileError, import("../context/globalOpts.ts").GlobalOpts | import("../context/projectInfo.ts").ProjectInfo | import("@effect/platform/FileSystem").FileSystem | import("../context/authToken.ts").AuthToken | import("../lib/http.ts").InstantHttpAuthed | import("@effect/platform/Path").Path | import("../context/currentApp.ts").CurrentApp>;
4
+ export declare const initCommand: (_options: OptsFromCommand<typeof initDef>) => Effect.Effect<void, import("../errors.ts").BadArgsError | import("effect/Cause").UnknownException | import("effect/ConfigError").ConfigError | import("effect/ParseResult").ParseError | import("../lib/http.ts").InstantHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("@effect/platform/HttpClientError").ResponseError | import("@effect/platform/Error").PlatformError | import("@effect/platform/HttpBody").HttpBodyError | import("../lib/pushSchema.ts").ReadSchemaFileError | import("../lib/pushSchema.ts").SchemaDiffError | import("../lib/pushSchema.ts").GetSchemaError | import("../lib/pushSchema.ts").SchemaValidationError | import("../lib/pushSchema.ts").WaitForJobsError | import("../lib/pushSchema.ts").CancelSchemaError | import("../util/mergeSchema.ts").MergeSchemaError | import("../lib/pushPerms.ts").NoPermsFileError, import("../context/globalOpts.ts").GlobalOpts | import("../context/projectInfo.ts").ProjectInfo | import("../context/authToken.ts").AuthToken | import("../lib/http.ts").InstantHttpAuthed | import("@effect/platform/FileSystem").FileSystem | import("@effect/platform/Path").Path | import("../context/currentApp.ts").CurrentApp>;
5
5
  //# sourceMappingURL=init.d.ts.map
@@ -5,5 +5,5 @@ export declare const loginCommand: (opts: {
5
5
  }) => Effect.Effect<{
6
6
  authToken: string;
7
7
  source: "file";
8
- }, import("../errors.ts").BadArgsError | import("effect/Cause").UnknownException | import("../lib/http.ts").InstantHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("effect/ParseResult").ParseError | import("@effect/platform/HttpClientError").ResponseError | import("@effect/platform/Error").PlatformError | import("effect/ConfigError").ConfigError, import("../context/globalOpts.ts").GlobalOpts | import("../lib/http.ts").InstantHttp | import("@effect/platform/FileSystem").FileSystem>;
8
+ }, import("../errors.ts").BadArgsError | import("effect/Cause").UnknownException | import("effect/ConfigError").ConfigError | import("effect/ParseResult").ParseError | import("../lib/http.ts").InstantHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("@effect/platform/HttpClientError").ResponseError, import("../context/globalOpts.ts").GlobalOpts | import("../lib/http.ts").InstantHttp>;
9
9
  //# sourceMappingURL=login.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAgBhC,eAAO,MAAM,YAAY;;;;;;2iBA4CvB,CAAC"}
1
+ {"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAgBhC,eAAO,MAAM,YAAY;;;;;;ucA4CvB,CAAC"}
@@ -2,7 +2,7 @@ import chalk from 'chalk';
2
2
  import { Effect } from 'effect';
3
3
  import openInBrowser from 'open';
4
4
  import { loginDef } from "../index.js";
5
- import { getDashUrl } from "../lib/http.js";
5
+ import { getDashUrl } from "../lib/config.js";
6
6
  import { getLoginTicketAndSecret, saveConfigAuthToken, waitForAuthToken, } from "../lib/login.js";
7
7
  import { promptOk } from "../lib/ui.js";
8
8
  import { isHeadlessEnvironment } from "../util/isHeadlessEnvironment.js";
@@ -19,7 +19,7 @@ export const loginCommand = Effect.fn(function* (opts) {
19
19
  }
20
20
  else {
21
21
  const ok = yield* promptOk({
22
- promptText: 'This will open instantdb.com in your browser, OK to proceed?',
22
+ promptText: 'This will open your Instant dashboard in your browser, OK to proceed?',
23
23
  }, true);
24
24
  if (!ok) {
25
25
  process.exit(0);
@@ -1 +1 @@
1
- {"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,aAAa,MAAM,MAAM,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,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C,IAAI,CAC1D,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC,CAC7D,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;IAEnD,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAC/C,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;IAChC,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;QACf,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CACf,KAAK,CAAC,GAAG,CAAC,yCAAyC,EAAE,KAAK,CAAC,CAC5D,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,KAAK,CAAC,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC;QAClC,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,6BAA6B,KAAK,GAAG,CAAC,CAAC,CAAC;IACxE,CAAC;IACD,OAAO;QACL,SAAS,EAAE,KAAK;QAChB,MAAM,EAAE,MAAe;KACxB,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import chalk from 'chalk';\nimport { Effect } from 'effect';\nimport openInBrowser from 'open';\nimport { loginDef } from '../index.ts';\nimport type { OptsFromCommand } from '../index.ts';\nimport { getDashUrl } from '../lib/http.ts';\nimport {\n getLoginTicketAndSecret,\n saveConfigAuthToken,\n waitForAuthToken,\n} from '../lib/login.ts';\nimport { promptOk } from '../lib/ui.ts';\nimport { isHeadlessEnvironment } from '../util/isHeadlessEnvironment.ts';\n\nconst loginUrlMessage = (url: string) =>\n `Open this URL in a browser to log in:\\n ${url}\\n`;\n\nexport const loginCommand = Effect.fn(function* (\n opts: OptsFromCommand<typeof loginDef>,\n) {\n yield* Effect.log(\"Let's log you in!\");\n\n const loginInfo = yield* getLoginTicketAndSecret;\n const { secret, ticket } = loginInfo;\n const dashOrigin = yield* getDashUrl;\n const loginUrl = `${dashOrigin}/dash?ticket=${ticket}`;\n yield* Effect.log();\n if (isHeadlessEnvironment(opts)) {\n yield* Effect.log(loginUrlMessage(loginUrl));\n } else {\n const ok = yield* promptOk(\n {\n promptText:\n 'This will open instantdb.com in your browser, OK to proceed?',\n },\n true,\n );\n if (!ok) {\n process.exit(0);\n }\n yield* Effect.tryPromise(() => openInBrowser(loginUrl)).pipe(\n Effect.catchAll(() => Effect.log(loginUrlMessage(loginUrl))),\n );\n }\n\n yield* Effect.log('Waiting for authentication...');\n\n const result = yield* waitForAuthToken(secret);\n const { token, email } = result;\n if (opts.print) {\n yield* Effect.log(\n chalk.red('[Do not share] Your Instant auth token:', token),\n );\n } else {\n yield* saveConfigAuthToken(token);\n yield* Effect.log(chalk.green(`Successfully logged in as ${email}!`));\n }\n return {\n authToken: token,\n source: 'file' as const,\n };\n});\n"]}
1
+ {"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,aAAa,MAAM,MAAM,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EACL,uBAAuB,EACvB,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAEzE,MAAM,eAAe,GAAG,CAAC,GAAW,EAAE,EAAE,CACtC,2CAA2C,GAAG,IAAI,CAAC;AAErD,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,EAAE,CAAC,QAAQ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AAC;QACf,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CACf,KAAK,CAAC,GAAG,CAAC,yCAAyC,EAAE,KAAK,CAAC,CAC5D,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,KAAK,CAAC,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC;QAClC,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,6BAA6B,KAAK,GAAG,CAAC,CAAC,CAAC;IACxE,CAAC;IACD,OAAO;QACL,SAAS,EAAE,KAAK;QAChB,MAAM,EAAE,MAAe;KACxB,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import chalk from 'chalk';\nimport { Effect } from 'effect';\nimport openInBrowser from 'open';\nimport { loginDef } from '../index.ts';\nimport type { OptsFromCommand } from '../index.ts';\nimport { getDashUrl } from '../lib/config.ts';\nimport {\n getLoginTicketAndSecret,\n saveConfigAuthToken,\n waitForAuthToken,\n} from '../lib/login.ts';\nimport { promptOk } from '../lib/ui.ts';\nimport { isHeadlessEnvironment } from '../util/isHeadlessEnvironment.ts';\n\nconst loginUrlMessage = (url: string) =>\n `Open this URL in a browser to log in:\\n ${url}\\n`;\n\nexport const loginCommand = Effect.fn(function* (\n opts: OptsFromCommand<typeof loginDef>,\n) {\n yield* Effect.log(\"Let's log you in!\");\n\n const loginInfo = yield* getLoginTicketAndSecret;\n const { secret, ticket } = loginInfo;\n const dashOrigin = yield* getDashUrl;\n const loginUrl = `${dashOrigin}/dash?ticket=${ticket}`;\n yield* Effect.log();\n if (isHeadlessEnvironment(opts)) {\n yield* Effect.log(loginUrlMessage(loginUrl));\n } else {\n const ok = yield* promptOk(\n {\n promptText:\n 'This will open your Instant dashboard in your browser, OK to proceed?',\n },\n true,\n );\n if (!ok) {\n process.exit(0);\n }\n yield* Effect.tryPromise(() => openInBrowser(loginUrl)).pipe(\n Effect.catchAll(() => Effect.log(loginUrlMessage(loginUrl))),\n );\n }\n\n yield* Effect.log('Waiting for authentication...');\n\n const result = yield* waitForAuthToken(secret);\n const { token, email } = result;\n if (opts.print) {\n yield* Effect.log(\n chalk.red('[Do not share] Your Instant auth token:', token),\n );\n } else {\n yield* saveConfigAuthToken(token);\n yield* Effect.log(chalk.green(`Successfully logged in as ${email}!`));\n }\n return {\n authToken: token,\n source: 'file' as const,\n };\n});\n"]}
@@ -1,4 +1,3 @@
1
1
  import { Effect } from 'effect';
2
- import { FileSystem } from '@effect/platform';
3
- export declare const logoutCommand: () => Effect.Effect<void, never, FileSystem.FileSystem>;
2
+ export declare const logoutCommand: () => Effect.Effect<void, import("../errors.ts").BadArgsError | import("effect/Cause").UnknownException | import("effect/ConfigError").ConfigError, never>;
4
3
  //# sourceMappingURL=logout.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../src/commands/logout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAI9C,eAAO,MAAM,aAAa,yDAgBxB,CAAC"}
1
+ {"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../src/commands/logout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAKhC,eAAO,MAAM,aAAa,4JAgBxB,CAAC"}
@@ -1,21 +1,14 @@
1
1
  import { Effect } from 'effect';
2
- import { getAuthPaths } from "../util/getAuthPaths.js";
3
- import { FileSystem } from '@effect/platform';
4
2
  import chalk from 'chalk';
5
- import { SystemError } from '@effect/platform/Error';
3
+ import { removeAuthToken } from "../auth/index.js";
4
+ import { getBaseUrl } from "../lib/config.js";
6
5
  export const logoutCommand = Effect.fn(function* () {
7
- const { authConfigFilePath } = getAuthPaths();
8
- const fs = yield* FileSystem.FileSystem;
9
- yield* Effect.matchEffect(fs.remove(authConfigFilePath), {
10
- onFailure: (e) => Effect.gen(function* () {
11
- if (e instanceof SystemError && e.reason === 'NotFound') {
12
- yield* Effect.log(chalk.green('You were already logged out!'));
13
- }
14
- else {
15
- yield* Effect.logError(chalk.red('Failed to logout: ' + e.message));
16
- }
17
- }),
18
- onSuccess: () => Effect.log(chalk.green('Successfully logged out from Instant!')),
19
- });
6
+ const apiURI = yield* getBaseUrl;
7
+ yield* Effect.tryPromise(() => removeAuthToken(apiURI)).pipe(Effect.matchEffect({
8
+ onFailure: (error) => Effect.logError(chalk.red(`Failed to logout: ${error.message}`)),
9
+ onSuccess: (removed) => Effect.log(chalk.green(removed
10
+ ? 'Successfully logged out from Instant!'
11
+ : 'You were already logged out!')),
12
+ }));
20
13
  });
21
14
  //# sourceMappingURL=logout.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"logout.js","sourceRoot":"","sources":["../../src/commands/logout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC;IAC9C,MAAM,EAAE,kBAAkB,EAAE,GAAG,YAAY,EAAE,CAAC;IAC9C,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC;IAExC,KAAK,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,MAAM,CAAC,kBAAkB,CAAC,EAAE;QACvD,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE,CACf,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;YAClB,IAAI,CAAC,YAAY,WAAW,IAAI,CAAC,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;gBACxD,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC,CAAC;YACjE,CAAC;iBAAM,CAAC;gBACN,KAAK,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,oBAAoB,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;YACtE,CAAC;QACH,CAAC,CAAC;QACJ,SAAS,EAAE,GAAG,EAAE,CACd,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,uCAAuC,CAAC,CAAC;KACnE,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { Effect } from 'effect';\nimport { getAuthPaths } from '../util/getAuthPaths.ts';\nimport { FileSystem } from '@effect/platform';\nimport chalk from 'chalk';\nimport { SystemError } from '@effect/platform/Error';\n\nexport const logoutCommand = Effect.fn(function* () {\n const { authConfigFilePath } = getAuthPaths();\n const fs = yield* FileSystem.FileSystem;\n\n yield* Effect.matchEffect(fs.remove(authConfigFilePath), {\n onFailure: (e) =>\n Effect.gen(function* () {\n if (e instanceof SystemError && e.reason === 'NotFound') {\n yield* Effect.log(chalk.green('You were already logged out!'));\n } else {\n yield* Effect.logError(chalk.red('Failed to logout: ' + e.message));\n }\n }),\n onSuccess: () =>\n Effect.log(chalk.green('Successfully logged out from Instant!')),\n });\n});\n"]}
1
+ {"version":3,"file":"logout.js","sourceRoot":"","sources":["../../src/commands/logout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC;IAC9C,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,UAAU,CAAC;IACjC,KAAK,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAC1D,MAAM,CAAC,WAAW,CAAC;QACjB,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE,CACnB,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,qBAAqB,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAClE,SAAS,EAAE,CAAC,OAAO,EAAE,EAAE,CACrB,MAAM,CAAC,GAAG,CACR,KAAK,CAAC,KAAK,CACT,OAAO;YACL,CAAC,CAAC,uCAAuC;YACzC,CAAC,CAAC,8BAA8B,CACnC,CACF;KACJ,CAAC,CACH,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import { Effect } from 'effect';\nimport chalk from 'chalk';\nimport { removeAuthToken } from '../auth/index.ts';\nimport { getBaseUrl } from '../lib/config.ts';\n\nexport const logoutCommand = Effect.fn(function* () {\n const apiURI = yield* getBaseUrl;\n yield* Effect.tryPromise(() => removeAuthToken(apiURI)).pipe(\n Effect.matchEffect({\n onFailure: (error) =>\n Effect.logError(chalk.red(`Failed to logout: ${error.message}`)),\n onSuccess: (removed) =>\n Effect.log(\n chalk.green(\n removed\n ? 'Successfully logged out from Instant!'\n : 'You were already logged out!',\n ),\n ),\n }),\n );\n});\n"]}
@@ -1,5 +1,5 @@
1
1
  import { Effect } from 'effect';
2
2
  import type { OptsFromCommand, pullDef } from '../index.ts';
3
3
  export type SchemaPermsOrBoth = 'schema' | 'perms' | 'all';
4
- export declare const pullCommand: (arg: SchemaPermsOrBoth, opts: OptsFromCommand<typeof pullDef>) => Effect.Effect<void, import("effect/Cause").UnknownException | import("../lib/http.ts").InstantHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("effect/ParseResult").ParseError | import("@effect/platform/HttpClientError").ResponseError | import("@effect/platform/Error").PlatformError | import("../lib/pushSchema.ts").ReadSchemaFileError | import("../util/mergeSchema.ts").MergeSchemaError, import("../context/globalOpts.ts").GlobalOpts | import("../context/projectInfo.ts").ProjectInfo | import("@effect/platform/FileSystem").FileSystem | import("../lib/http.ts").InstantHttpAuthed | import("@effect/platform/Path").Path | import("../context/currentApp.ts").CurrentApp>;
4
+ export declare const pullCommand: (arg: SchemaPermsOrBoth, opts: OptsFromCommand<typeof pullDef>) => Effect.Effect<void, import("effect/Cause").UnknownException | import("effect/ParseResult").ParseError | import("../lib/http.ts").InstantHttpError | import("effect/Cause").TimeoutException | import("@effect/platform/HttpClientError").RequestError | import("@effect/platform/HttpClientError").ResponseError | import("@effect/platform/Error").PlatformError | import("../lib/pushSchema.ts").ReadSchemaFileError | import("../util/mergeSchema.ts").MergeSchemaError, import("../context/globalOpts.ts").GlobalOpts | import("../context/projectInfo.ts").ProjectInfo | import("../lib/http.ts").InstantHttpAuthed | import("@effect/platform/FileSystem").FileSystem | import("@effect/platform/Path").Path | import("../context/currentApp.ts").CurrentApp>;
5
5
  //# sourceMappingURL=pull.d.ts.map