@straion/cli 0.0.1 → 0.0.2
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 +7 -0
- package/dist/cli.d.ts +4 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +5 -3
- package/dist/cli.js.map +1 -1
- package/dist/commands/default.d.ts +2 -1
- package/dist/commands/default.d.ts.map +1 -1
- package/dist/commands/default.js +15 -3
- package/dist/commands/default.js.map +1 -1
- package/dist/commands/find-requirements.d.ts.map +1 -1
- package/dist/commands/find-requirements.integration.test.d.ts +5 -0
- package/dist/commands/find-requirements.integration.test.d.ts.map +1 -0
- package/dist/commands/find-requirements.integration.test.js +131 -0
- package/dist/commands/find-requirements.integration.test.js.map +1 -0
- package/dist/commands/find-requirements.js +36 -5
- package/dist/commands/find-requirements.js.map +1 -1
- package/dist/commands/login.d.ts.map +1 -1
- package/dist/commands/login.integration.test.d.ts +13 -0
- package/dist/commands/login.integration.test.d.ts.map +1 -0
- package/dist/commands/login.integration.test.js +188 -0
- package/dist/commands/login.integration.test.js.map +1 -0
- package/dist/commands/login.js +13 -4
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/logout.d.ts.map +1 -1
- package/dist/commands/logout.js +19 -9
- package/dist/commands/logout.js.map +1 -1
- package/dist/commands/session-start.d.ts.map +1 -1
- package/dist/commands/session-start.js +8 -2
- package/dist/commands/session-start.js.map +1 -1
- package/dist/components/button.d.ts +2 -2
- package/dist/components/button.d.ts.map +1 -1
- package/dist/components/button.js +3 -3
- package/dist/components/button.js.map +1 -1
- package/dist/components/hero.d.ts +2 -1
- package/dist/components/hero.d.ts.map +1 -1
- package/dist/components/hero.js +76 -10
- package/dist/components/hero.js.map +1 -1
- package/dist/components/link.d.ts +2 -2
- package/dist/components/link.d.ts.map +1 -1
- package/dist/components/link.js +3 -3
- package/dist/components/link.js.map +1 -1
- package/dist/components/login/login-error.d.ts +6 -0
- package/dist/components/login/login-error.d.ts.map +1 -0
- package/dist/components/login/login-error.js +16 -0
- package/dist/components/login/login-error.js.map +1 -0
- package/dist/components/login/login-flow.d.ts +8 -2
- package/dist/components/login/login-flow.d.ts.map +1 -1
- package/dist/components/login/login-flow.js +123 -82
- package/dist/components/login/login-flow.js.map +1 -1
- package/dist/components/login/login-flow.test.js +69 -7
- package/dist/components/login/login-flow.test.js.map +1 -1
- package/dist/components/login/types.d.ts +2 -0
- package/dist/components/login/types.d.ts.map +1 -0
- package/dist/components/login/types.js +2 -0
- package/dist/components/login/types.js.map +1 -0
- package/dist/components/org-selector.d.ts +2 -1
- package/dist/components/org-selector.d.ts.map +1 -1
- package/dist/components/org-selector.js +7 -2
- package/dist/components/org-selector.js.map +1 -1
- package/dist/components/pat-input.d.ts +2 -1
- package/dist/components/pat-input.d.ts.map +1 -1
- package/dist/components/pat-input.js +9 -3
- package/dist/components/pat-input.js.map +1 -1
- package/dist/components/pat-input.test.js +8 -8
- package/dist/components/pat-input.test.js.map +1 -1
- package/dist/components/spinner.d.ts +2 -1
- package/dist/components/spinner.d.ts.map +1 -1
- package/dist/components/spinner.js +2 -3
- package/dist/components/spinner.js.map +1 -1
- package/dist/components/tabs.d.ts +3 -3
- package/dist/components/tabs.d.ts.map +1 -1
- package/dist/components/tabs.js +26 -21
- package/dist/components/tabs.js.map +1 -1
- package/dist/lib/ink-render.d.ts +1 -1
- package/dist/lib/ink-render.js +1 -1
- package/dist/lib/middleware.d.ts +9 -4
- package/dist/lib/middleware.d.ts.map +1 -1
- package/dist/lib/middleware.js +23 -7
- package/dist/lib/middleware.js.map +1 -1
- package/dist/lib/output.d.ts +16 -0
- package/dist/lib/output.d.ts.map +1 -0
- package/dist/lib/output.js +14 -0
- package/dist/lib/output.js.map +1 -0
- package/dist/test/integration-helpers.d.ts +101 -0
- package/dist/test/integration-helpers.d.ts.map +1 -0
- package/dist/test/integration-helpers.js +187 -0
- package/dist/test/integration-helpers.js.map +1 -0
- package/package.json +3 -1
- package/dist/auth/cookie-jar.d.ts +0 -24
- package/dist/auth/cookie-jar.d.ts.map +0 -1
- package/dist/auth/cookie-jar.js +0 -45
- package/dist/auth/cookie-jar.js.map +0 -1
- package/dist/components/login/login.provider.d.ts +0 -2
- package/dist/components/login/login.provider.d.ts.map +0 -1
- package/dist/components/login/login.provider.js +0 -2
- package/dist/components/login/login.provider.js.map +0 -1
- package/dist/components/login/login.store.d.ts +0 -2
- package/dist/components/login/login.store.d.ts.map +0 -1
- package/dist/components/login/login.store.js +0 -2
- package/dist/components/login/login.store.js.map +0 -1
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared helpers for CLI integration tests.
|
|
3
|
+
*
|
|
4
|
+
* These utilities help spawn the CLI as a child process and set up
|
|
5
|
+
* mock servers for testing in non-TTY environments.
|
|
6
|
+
*/
|
|
7
|
+
import { spawn } from 'node:child_process';
|
|
8
|
+
import fs from 'node:fs';
|
|
9
|
+
import os from 'node:os';
|
|
10
|
+
import path from 'node:path';
|
|
11
|
+
import { fileURLToPath } from 'node:url';
|
|
12
|
+
import { createServer } from '@mswjs/http-middleware';
|
|
13
|
+
import { graphql, HttpResponse } from 'msw';
|
|
14
|
+
// Get paths relative to this file
|
|
15
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
16
|
+
const CLI_PATH = path.resolve(__dirname, '../cli.ts');
|
|
17
|
+
const KEYTAR_LOADER_PATH = path.resolve(__dirname, 'keytar-loader.mts');
|
|
18
|
+
// TSX_PATH is set via env var in project.json
|
|
19
|
+
function getTsxPath() {
|
|
20
|
+
if (!process.env.TSX_PATH) {
|
|
21
|
+
throw new Error('TSX_PATH env var is required. Run tests via: pnpm nx test cli');
|
|
22
|
+
}
|
|
23
|
+
return path.resolve(process.cwd(), process.env.TSX_PATH);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Mock user data for authentication.
|
|
27
|
+
*/
|
|
28
|
+
export const mockUser = {
|
|
29
|
+
id: 'user-123',
|
|
30
|
+
name: 'Test User',
|
|
31
|
+
firstName: 'Test',
|
|
32
|
+
defaultOrganization: {
|
|
33
|
+
id: 'org-456',
|
|
34
|
+
name: 'Test Organization',
|
|
35
|
+
subdomain: 'test-org',
|
|
36
|
+
},
|
|
37
|
+
organizations: {
|
|
38
|
+
nodes: [
|
|
39
|
+
{
|
|
40
|
+
id: 'org-456',
|
|
41
|
+
name: 'Test Organization',
|
|
42
|
+
subdomain: 'test-org',
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Mock organization data.
|
|
49
|
+
*/
|
|
50
|
+
export const mockOrg = {
|
|
51
|
+
id: 'org-456',
|
|
52
|
+
name: 'Test Organization',
|
|
53
|
+
subdomain: 'test-org',
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Creates the standard "Me" query handler for authentication.
|
|
57
|
+
*/
|
|
58
|
+
export function createMeHandler(validToken = 'valid-test-token') {
|
|
59
|
+
return graphql.query('Me', ({ request }) => {
|
|
60
|
+
const authHeader = request.headers.get('Authorization');
|
|
61
|
+
if (authHeader === `Bearer ${validToken}`) {
|
|
62
|
+
return HttpResponse.json({
|
|
63
|
+
data: {
|
|
64
|
+
me: mockUser,
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
return HttpResponse.json({
|
|
69
|
+
errors: [{ message: 'Unauthorized' }],
|
|
70
|
+
}, { status: 401 });
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Test context that manages mock server and temp directories.
|
|
75
|
+
*/
|
|
76
|
+
export class IntegrationTestContext {
|
|
77
|
+
mockServer = null;
|
|
78
|
+
tempConfigDir = null;
|
|
79
|
+
mockServerUrl = '';
|
|
80
|
+
/**
|
|
81
|
+
* Sets up the mock server with the given handlers.
|
|
82
|
+
*/
|
|
83
|
+
async setupServer(handlers) {
|
|
84
|
+
const app = createServer(...handlers);
|
|
85
|
+
this.mockServer = app.listen(0);
|
|
86
|
+
const address = this.mockServer.address();
|
|
87
|
+
this.mockServerUrl = `http://localhost:${address.port}`;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Creates a minimal temp config directory (no credentials).
|
|
91
|
+
*/
|
|
92
|
+
setupConfigDir() {
|
|
93
|
+
this.tempConfigDir = fs.mkdtempSync(path.join(os.tmpdir(), 'straion-test-'));
|
|
94
|
+
const straionHomeDir = path.join(this.tempConfigDir, '.straion');
|
|
95
|
+
fs.mkdirSync(straionHomeDir, { recursive: true });
|
|
96
|
+
return this.tempConfigDir;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Writes org config to the config directory.
|
|
100
|
+
* Call after setupConfigDir() when tests need a pre-configured org.
|
|
101
|
+
*/
|
|
102
|
+
writeOrgConfig(org = mockOrg) {
|
|
103
|
+
const configPath = path.join(this.getStraionHome(), 'config.json');
|
|
104
|
+
fs.writeFileSync(configPath, JSON.stringify({ version: 1, globalOrg: org }));
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Gets the straion home path.
|
|
108
|
+
*/
|
|
109
|
+
getStraionHome() {
|
|
110
|
+
if (!this.tempConfigDir) {
|
|
111
|
+
throw new Error('Config dir not set up. Call setupConfigDir() first.');
|
|
112
|
+
}
|
|
113
|
+
return path.join(this.tempConfigDir, '.straion');
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Runs the CLI with the given arguments.
|
|
117
|
+
*/
|
|
118
|
+
runCLI(args, options = {}) {
|
|
119
|
+
return new Promise((resolve, reject) => {
|
|
120
|
+
const { env = {}, timeout = 10000 } = options;
|
|
121
|
+
if (!this.tempConfigDir) {
|
|
122
|
+
throw new Error('Config dir not set up. Call setupConfigDir() first.');
|
|
123
|
+
}
|
|
124
|
+
const child = spawn(getTsxPath(), ['--import', KEYTAR_LOADER_PATH, CLI_PATH, ...args], {
|
|
125
|
+
env: {
|
|
126
|
+
...process.env,
|
|
127
|
+
...env,
|
|
128
|
+
// Override HOME so os.homedir() returns our temp dir
|
|
129
|
+
HOME: this.tempConfigDir,
|
|
130
|
+
STRAION_API_BASEURL: this.mockServerUrl,
|
|
131
|
+
FORCE_COLOR: '0',
|
|
132
|
+
NO_COLOR: '1',
|
|
133
|
+
},
|
|
134
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
135
|
+
timeout,
|
|
136
|
+
});
|
|
137
|
+
let stdout = '';
|
|
138
|
+
let stderr = '';
|
|
139
|
+
child.stdout?.on('data', (data) => {
|
|
140
|
+
stdout += data.toString();
|
|
141
|
+
});
|
|
142
|
+
child.stderr?.on('data', (data) => {
|
|
143
|
+
stderr += data.toString();
|
|
144
|
+
});
|
|
145
|
+
child.on('close', (code) => {
|
|
146
|
+
resolve({ stdout, stderr, exitCode: code });
|
|
147
|
+
});
|
|
148
|
+
child.on('error', (err) => {
|
|
149
|
+
reject(err);
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Cleans up temp directories only (call in afterEach).
|
|
155
|
+
*/
|
|
156
|
+
cleanupConfigDir() {
|
|
157
|
+
if (this.tempConfigDir) {
|
|
158
|
+
fs.rmSync(this.tempConfigDir, { recursive: true, force: true });
|
|
159
|
+
this.tempConfigDir = null;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Cleans up everything including the mock server (call in afterAll).
|
|
164
|
+
*/
|
|
165
|
+
cleanup() {
|
|
166
|
+
this.mockServer?.close();
|
|
167
|
+
this.mockServer = null;
|
|
168
|
+
this.cleanupConfigDir();
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Parses JSON output from CLI, handling potential non-JSON content.
|
|
173
|
+
* Supports both arrays and objects.
|
|
174
|
+
*/
|
|
175
|
+
export function parseJSONOutput(output) {
|
|
176
|
+
// Match JSON array or object
|
|
177
|
+
const jsonMatch = output.match(/\[[\s\S]*\]|\{[\s\S]*\}/);
|
|
178
|
+
if (!jsonMatch)
|
|
179
|
+
return null;
|
|
180
|
+
try {
|
|
181
|
+
return JSON.parse(jsonMatch[0]);
|
|
182
|
+
}
|
|
183
|
+
catch {
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
//# sourceMappingURL=integration-helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"integration-helpers.js","sourceRoot":"","sources":["../../src/test/integration-helpers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,KAAK,EAAqB,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,MAAM,SAAS,CAAC;AAGzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,YAAY,EAAuB,MAAM,KAAK,CAAC;AAEjE,kCAAkC;AAClC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAC/D,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;AACtD,MAAM,kBAAkB,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;AAExE,8CAA8C;AAC9C,SAAS,UAAU;IACjB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,+DAA+D,CAAC,CAAC;IACnF,CAAC;IACD,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,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
|
22
22
|
"zustand": "^4.5.5"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
+
"@mswjs/http-middleware": "^0.10.3",
|
|
25
26
|
"@types/node": "^22",
|
|
26
27
|
"@types/react": "^19.0.0",
|
|
27
28
|
"eslint": "^9",
|
|
28
29
|
"eslint-config-prettier": "^10",
|
|
29
30
|
"ink-testing-library": "^4.0.0",
|
|
31
|
+
"msw": "2.7.0",
|
|
30
32
|
"typescript": "^5.4.5",
|
|
31
33
|
"vitest": "^3.0.7"
|
|
32
34
|
},
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Secure cookie storage for HTTP-only refresh token cookies
|
|
3
|
-
* Stores the raw Set-Cookie header value in the system keychain
|
|
4
|
-
*/
|
|
5
|
-
export declare const REFRESH_TOKEN_COOKIE = "___refresh_token";
|
|
6
|
-
export declare class CookieJar {
|
|
7
|
-
/**
|
|
8
|
-
* Store the refresh token cookie (the full Set-Cookie header value)
|
|
9
|
-
*/
|
|
10
|
-
setRefreshTokenCookie(setCookieHeader: string): Promise<void>;
|
|
11
|
-
/**
|
|
12
|
-
* Retrieve the stored refresh token cookie
|
|
13
|
-
*/
|
|
14
|
-
getRefreshTokenCookie(): Promise<string | null>;
|
|
15
|
-
/**
|
|
16
|
-
* Clear the stored refresh token cookie
|
|
17
|
-
*/
|
|
18
|
-
clearRefreshTokenCookie(): Promise<boolean>;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Factory function to create the appropriate cookie jar
|
|
22
|
-
*/
|
|
23
|
-
export declare function createCookieJar(): Promise<CookieJar>;
|
|
24
|
-
//# sourceMappingURL=cookie-jar.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cookie-jar.d.ts","sourceRoot":"","sources":["../../src/auth/cookie-jar.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,eAAO,MAAM,oBAAoB,qBAAqB,CAAC;AAGvD,qBAAa,SAAS;IACpB;;OAEG;IACG,qBAAqB,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAInE;;OAEG;IACG,qBAAqB,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAIrD;;OAEG;IACG,uBAAuB,IAAI,OAAO,CAAC,OAAO,CAAC;CAGlD;AAED;;GAEG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,SAAS,CAAC,CAW1D"}
|
package/dist/auth/cookie-jar.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Secure cookie storage for HTTP-only refresh token cookies
|
|
3
|
-
* Stores the raw Set-Cookie header value in the system keychain
|
|
4
|
-
*/
|
|
5
|
-
import * as keytar from 'keytar';
|
|
6
|
-
import { StraionCLIConfig } from './config.js';
|
|
7
|
-
/** TODO FFR: use shared config between gateway and cli */
|
|
8
|
-
const AUTH_TOKEN_COOKIE = '___auth_token';
|
|
9
|
-
export const REFRESH_TOKEN_COOKIE = '___refresh_token';
|
|
10
|
-
const ORGANIZATION_COOKIE = '___organization_id';
|
|
11
|
-
export class CookieJar {
|
|
12
|
-
/**
|
|
13
|
-
* Store the refresh token cookie (the full Set-Cookie header value)
|
|
14
|
-
*/
|
|
15
|
-
async setRefreshTokenCookie(setCookieHeader) {
|
|
16
|
-
await keytar.setPassword(StraionCLIConfig.serviceName, REFRESH_TOKEN_COOKIE, setCookieHeader);
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Retrieve the stored refresh token cookie
|
|
20
|
-
*/
|
|
21
|
-
async getRefreshTokenCookie() {
|
|
22
|
-
return keytar.getPassword(StraionCLIConfig.serviceName, REFRESH_TOKEN_COOKIE);
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Clear the stored refresh token cookie
|
|
26
|
-
*/
|
|
27
|
-
async clearRefreshTokenCookie() {
|
|
28
|
-
return keytar.deletePassword(StraionCLIConfig.serviceName, REFRESH_TOKEN_COOKIE);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Factory function to create the appropriate cookie jar
|
|
33
|
-
*/
|
|
34
|
-
export async function createCookieJar() {
|
|
35
|
-
try {
|
|
36
|
-
// Test if keytar works
|
|
37
|
-
await keytar.getPassword(StraionCLIConfig.serviceName, '__cookie_test__');
|
|
38
|
-
return new CookieJar();
|
|
39
|
-
}
|
|
40
|
-
catch {
|
|
41
|
-
console.error('System keychain unavailable. The straion cli requires a keychain to securely store authentication tokens.');
|
|
42
|
-
throw new Error('System keychain unavailable');
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
//# sourceMappingURL=cookie-jar.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cookie-jar.js","sourceRoot":"","sources":["../../src/auth/cookie-jar.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAEjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,0DAA0D;AAC1D,MAAM,iBAAiB,GAAG,eAAe,CAAC;AAC1C,MAAM,CAAC,MAAM,oBAAoB,GAAG,kBAAkB,CAAC;AACvD,MAAM,mBAAmB,GAAG,oBAAoB,CAAC;AAEjD,MAAM,OAAO,SAAS;IACpB;;OAEG;IACH,KAAK,CAAC,qBAAqB,CAAC,eAAuB;QACjD,MAAM,MAAM,CAAC,WAAW,CAAC,gBAAgB,CAAC,WAAW,EAAE,oBAAoB,EAAE,eAAe,CAAC,CAAC;IAChG,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,qBAAqB;QACzB,OAAO,MAAM,CAAC,WAAW,CAAC,gBAAgB,CAAC,WAAW,EAAE,oBAAoB,CAAC,CAAC;IAChF,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,uBAAuB;QAC3B,OAAO,MAAM,CAAC,cAAc,CAAC,gBAAgB,CAAC,WAAW,EAAE,oBAAoB,CAAC,CAAC;IACnF,CAAC;CACF;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe;IACnC,IAAI,CAAC;QACH,uBAAuB;QACvB,MAAM,MAAM,CAAC,WAAW,CAAC,gBAAgB,CAAC,WAAW,EAAE,iBAAiB,CAAC,CAAC;QAC1E,OAAO,IAAI,SAAS,EAAE,CAAC;IACzB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,CAAC,KAAK,CACX,2GAA2G,CAC5G,CAAC;QACF,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;IACjD,CAAC;AACH,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"login.provider.d.ts","sourceRoot":"","sources":["../../../src/components/login/login.provider.tsx"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"login.provider.js","sourceRoot":"","sources":["../../../src/components/login/login.provider.tsx"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"login.store.d.ts","sourceRoot":"","sources":["../../../src/components/login/login.store.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"login.store.js","sourceRoot":"","sources":["../../../src/components/login/login.store.ts"],"names":[],"mappings":""}
|