@enactprotocol/api 2.0.0 → 2.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/dist/auth.d.ts ADDED
@@ -0,0 +1,169 @@
1
+ /**
2
+ * Authentication functionality (v2)
3
+ * Handles OAuth-based authentication for the Enact registry
4
+ */
5
+ import type { EnactApiClient } from "./client";
6
+ import type { CurrentUser, OAuthLoginResponse, OAuthProvider, OAuthTokenResponse, RefreshTokenResponse } from "./types";
7
+ /**
8
+ * Authentication result
9
+ */
10
+ export interface AuthResult {
11
+ /** Whether authentication succeeded */
12
+ success: boolean;
13
+ /** Authentication token (if successful) */
14
+ token?: string | undefined;
15
+ /** Current user info (if successful) */
16
+ user?: AuthUser | undefined;
17
+ /** Error message (if failed) */
18
+ error?: string | undefined;
19
+ }
20
+ /**
21
+ * Authenticated user info
22
+ */
23
+ export interface AuthUser {
24
+ /** Username */
25
+ username: string;
26
+ /** Email address */
27
+ email: string;
28
+ /** Namespaces owned */
29
+ namespaces: string[];
30
+ }
31
+ /**
32
+ * Authentication status
33
+ */
34
+ export interface AuthStatus {
35
+ /** Whether currently authenticated */
36
+ authenticated: boolean;
37
+ /** Current user (if authenticated) */
38
+ user?: AuthUser | undefined;
39
+ /** Token expiration time (if available) */
40
+ expiresAt?: Date | undefined;
41
+ }
42
+ /**
43
+ * Initiate OAuth login (v2)
44
+ *
45
+ * @param client - API client instance
46
+ * @param provider - OAuth provider (github, google, microsoft)
47
+ * @param redirectUri - Callback URL (usually http://localhost:PORT/callback)
48
+ * @returns Authorization URL to redirect user to
49
+ *
50
+ * @example
51
+ * ```ts
52
+ * const result = await initiateLogin(client, "github", "http://localhost:9876/callback");
53
+ * console.log(`Visit: ${result.authUrl}`);
54
+ * ```
55
+ */
56
+ export declare function initiateLogin(client: EnactApiClient, provider: OAuthProvider, redirectUri: string): Promise<OAuthLoginResponse>;
57
+ /**
58
+ * Exchange OAuth code for tokens (v2)
59
+ *
60
+ * @param client - API client instance
61
+ * @param provider - OAuth provider used
62
+ * @param code - Authorization code from OAuth callback
63
+ * @returns Token response with access token, refresh token, and user info
64
+ *
65
+ * @example
66
+ * ```ts
67
+ * const tokens = await exchangeCodeForToken(client, "github", "auth_code_123");
68
+ * client.setAuthToken(tokens.access_token);
69
+ * console.log(`Logged in as ${tokens.user.username}`);
70
+ * ```
71
+ */
72
+ export declare function exchangeCodeForToken(client: EnactApiClient, provider: OAuthProvider, code: string): Promise<OAuthTokenResponse>;
73
+ /**
74
+ * Refresh an expired access token (v2)
75
+ *
76
+ * @param client - API client instance
77
+ * @param refreshToken - Refresh token obtained during login
78
+ * @returns New access token and expiration
79
+ *
80
+ * @example
81
+ * ```ts
82
+ * const newToken = await refreshAccessToken(client, storedRefreshToken);
83
+ * client.setAuthToken(newToken.access_token);
84
+ * ```
85
+ */
86
+ export declare function refreshAccessToken(client: EnactApiClient, refreshToken: string): Promise<RefreshTokenResponse>;
87
+ /**
88
+ * Authenticate with the Enact registry (v2 OAuth flow)
89
+ *
90
+ * This is a convenience wrapper that initiates an OAuth flow:
91
+ * 1. Opens a browser for authentication
92
+ * 2. User logs in via their provider (GitHub, Google, etc.)
93
+ * 3. Receives a token from the registry
94
+ *
95
+ * Note: The actual OAuth callback handling requires a local HTTP server,
96
+ * which should be implemented in the CLI package.
97
+ *
98
+ * @param client - API client instance
99
+ * @returns Authentication result
100
+ *
101
+ * @example
102
+ * ```ts
103
+ * const result = await authenticate(client);
104
+ * if (result.success) {
105
+ * client.setAuthToken(result.token);
106
+ * console.log(`Logged in as ${result.user.username}`);
107
+ * }
108
+ * ```
109
+ */
110
+ export declare function authenticate(_client: EnactApiClient): Promise<AuthResult>;
111
+ /**
112
+ * Log out by clearing the authentication token
113
+ *
114
+ * @param client - API client instance
115
+ */
116
+ export declare function logout(client: EnactApiClient): void;
117
+ /**
118
+ * Get current user info (v2)
119
+ *
120
+ * @param client - API client instance (must be authenticated)
121
+ * @returns Current user info
122
+ *
123
+ * @example
124
+ * ```ts
125
+ * const user = await getCurrentUser(client);
126
+ * console.log(`Logged in as ${user.username}`);
127
+ * ```
128
+ */
129
+ export declare function getCurrentUser(client: EnactApiClient): Promise<CurrentUser>;
130
+ /**
131
+ * Get current authentication status (v2)
132
+ *
133
+ * @param client - API client instance
134
+ * @returns Current auth status
135
+ *
136
+ * @example
137
+ * ```ts
138
+ * const status = await getAuthStatus(client);
139
+ * if (status.authenticated) {
140
+ * console.log(`Logged in as ${status.user.username}`);
141
+ * }
142
+ * ```
143
+ */
144
+ export declare function getAuthStatus(client: EnactApiClient): Promise<AuthStatus>;
145
+ /**
146
+ * Get user profile by username (v2)
147
+ *
148
+ * @param client - API client instance
149
+ * @param username - Username to look up
150
+ * @returns User profile info
151
+ */
152
+ export declare function getUserProfile(client: EnactApiClient, username: string): Promise<{
153
+ username: string;
154
+ displayName?: string | undefined;
155
+ avatarUrl?: string | undefined;
156
+ createdAt: Date;
157
+ toolsCount?: number | undefined;
158
+ }>;
159
+ /**
160
+ * Submit feedback for a tool
161
+ *
162
+ * @param client - API client instance (must be authenticated)
163
+ * @param name - Tool name
164
+ * @param rating - Rating (1-5)
165
+ * @param version - Version being rated
166
+ * @param comment - Optional comment
167
+ */
168
+ export declare function submitFeedback(client: EnactApiClient, name: string, rating: number, version: string, comment?: string): Promise<void>;
169
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,KAAK,EACV,WAAW,EAGX,kBAAkB,EAClB,aAAa,EACb,kBAAkB,EAElB,oBAAoB,EACrB,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,uCAAuC;IACvC,OAAO,EAAE,OAAO,CAAC;IACjB,2CAA2C;IAC3C,KAAK,CAAC,EAAE,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AsB,cAAc,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,WAAW,CAAC,CAGjF;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,aAAa,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,UAAU,CAAC,CAmB/E;AAED;;;;;;GAMG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,cAAc,EACtB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC;IACT,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,SAAS,EAAE,IAAI,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC,CAAC,CAgBD;AAED;;;;;;;;GAQG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,cAAc,EACtB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC,CAMf"}
package/dist/auth.js ADDED
@@ -0,0 +1,196 @@
1
+ /**
2
+ * Authentication functionality (v2)
3
+ * Handles OAuth-based authentication for the Enact registry
4
+ */
5
+ /**
6
+ * Initiate OAuth login (v2)
7
+ *
8
+ * @param client - API client instance
9
+ * @param provider - OAuth provider (github, google, microsoft)
10
+ * @param redirectUri - Callback URL (usually http://localhost:PORT/callback)
11
+ * @returns Authorization URL to redirect user to
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * const result = await initiateLogin(client, "github", "http://localhost:9876/callback");
16
+ * console.log(`Visit: ${result.authUrl}`);
17
+ * ```
18
+ */
19
+ export async function initiateLogin(client, provider, redirectUri) {
20
+ const response = await client.post("/auth/login", {
21
+ provider,
22
+ redirect_uri: redirectUri,
23
+ });
24
+ return response.data;
25
+ }
26
+ /**
27
+ * Exchange OAuth code for tokens (v2)
28
+ *
29
+ * @param client - API client instance
30
+ * @param provider - OAuth provider used
31
+ * @param code - Authorization code from OAuth callback
32
+ * @returns Token response with access token, refresh token, and user info
33
+ *
34
+ * @example
35
+ * ```ts
36
+ * const tokens = await exchangeCodeForToken(client, "github", "auth_code_123");
37
+ * client.setAuthToken(tokens.access_token);
38
+ * console.log(`Logged in as ${tokens.user.username}`);
39
+ * ```
40
+ */
41
+ export async function exchangeCodeForToken(client, provider, code) {
42
+ const response = await client.post("/auth/callback", {
43
+ provider,
44
+ code,
45
+ });
46
+ return response.data;
47
+ }
48
+ /**
49
+ * Refresh an expired access token (v2)
50
+ *
51
+ * @param client - API client instance
52
+ * @param refreshToken - Refresh token obtained during login
53
+ * @returns New access token and expiration
54
+ *
55
+ * @example
56
+ * ```ts
57
+ * const newToken = await refreshAccessToken(client, storedRefreshToken);
58
+ * client.setAuthToken(newToken.access_token);
59
+ * ```
60
+ */
61
+ export async function refreshAccessToken(client, refreshToken) {
62
+ const response = await client.post("/auth/refresh", {
63
+ refresh_token: refreshToken,
64
+ });
65
+ return response.data;
66
+ }
67
+ /**
68
+ * Authenticate with the Enact registry (v2 OAuth flow)
69
+ *
70
+ * This is a convenience wrapper that initiates an OAuth flow:
71
+ * 1. Opens a browser for authentication
72
+ * 2. User logs in via their provider (GitHub, Google, etc.)
73
+ * 3. Receives a token from the registry
74
+ *
75
+ * Note: The actual OAuth callback handling requires a local HTTP server,
76
+ * which should be implemented in the CLI package.
77
+ *
78
+ * @param client - API client instance
79
+ * @returns Authentication result
80
+ *
81
+ * @example
82
+ * ```ts
83
+ * const result = await authenticate(client);
84
+ * if (result.success) {
85
+ * client.setAuthToken(result.token);
86
+ * console.log(`Logged in as ${result.user.username}`);
87
+ * }
88
+ * ```
89
+ */
90
+ export async function authenticate(_client) {
91
+ // This is a placeholder for the full OAuth flow
92
+ // The actual implementation should be in the CLI package
93
+ // which can start a local server and open a browser
94
+ //
95
+ // Typical flow:
96
+ // 1. const loginResponse = await initiateLogin(client, "github", redirectUri);
97
+ // 2. Open browser to loginResponse.auth_url
98
+ // 3. Start local server on redirectUri to receive callback
99
+ // 4. Extract code from callback
100
+ // 5. const tokens = await exchangeCodeForToken(client, "github", code);
101
+ // 6. Return { success: true, token: tokens.access_token, user: {...} }
102
+ throw new Error("authenticate() must be implemented in the CLI package. " +
103
+ "Use initiateLogin() and exchangeCodeForToken() for OAuth flow.");
104
+ }
105
+ /**
106
+ * Log out by clearing the authentication token
107
+ *
108
+ * @param client - API client instance
109
+ */
110
+ export function logout(client) {
111
+ client.setAuthToken(undefined);
112
+ }
113
+ /**
114
+ * Get current user info (v2)
115
+ *
116
+ * @param client - API client instance (must be authenticated)
117
+ * @returns Current user info
118
+ *
119
+ * @example
120
+ * ```ts
121
+ * const user = await getCurrentUser(client);
122
+ * console.log(`Logged in as ${user.username}`);
123
+ * ```
124
+ */
125
+ export async function getCurrentUser(client) {
126
+ const response = await client.get("/auth/me");
127
+ return response.data;
128
+ }
129
+ /**
130
+ * Get current authentication status (v2)
131
+ *
132
+ * @param client - API client instance
133
+ * @returns Current auth status
134
+ *
135
+ * @example
136
+ * ```ts
137
+ * const status = await getAuthStatus(client);
138
+ * if (status.authenticated) {
139
+ * console.log(`Logged in as ${status.user.username}`);
140
+ * }
141
+ * ```
142
+ */
143
+ export async function getAuthStatus(client) {
144
+ if (!client.isAuthenticated()) {
145
+ return { authenticated: false };
146
+ }
147
+ try {
148
+ const user = await getCurrentUser(client);
149
+ return {
150
+ authenticated: true,
151
+ user: {
152
+ username: user.username,
153
+ email: user.email,
154
+ namespaces: user.namespaces,
155
+ },
156
+ };
157
+ }
158
+ catch {
159
+ // Token might be invalid/expired
160
+ return { authenticated: false };
161
+ }
162
+ }
163
+ /**
164
+ * Get user profile by username (v2)
165
+ *
166
+ * @param client - API client instance
167
+ * @param username - Username to look up
168
+ * @returns User profile info
169
+ */
170
+ export async function getUserProfile(client, username) {
171
+ const response = await client.get(`/users/${username}`);
172
+ return {
173
+ username: response.data.username,
174
+ displayName: response.data.display_name,
175
+ avatarUrl: response.data.avatar_url,
176
+ createdAt: new Date(response.data.created_at),
177
+ toolsCount: response.data.tools_count,
178
+ };
179
+ }
180
+ /**
181
+ * Submit feedback for a tool
182
+ *
183
+ * @param client - API client instance (must be authenticated)
184
+ * @param name - Tool name
185
+ * @param rating - Rating (1-5)
186
+ * @param version - Version being rated
187
+ * @param comment - Optional comment
188
+ */
189
+ export async function submitFeedback(client, name, rating, version, comment) {
190
+ await client.post(`/tools/${name}/feedback`, {
191
+ rating,
192
+ version,
193
+ comment,
194
+ });
195
+ }
196
+ //# sourceMappingURL=auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAoDH;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,MAAsB,EACtB,QAAuB,EACvB,WAAmB;IAEnB,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,IAAI,CAAqB,aAAa,EAAE;QACpE,QAAQ;QACR,YAAY,EAAE,WAAW;KACL,CAAC,CAAC;IAExB,OAAO,QAAQ,CAAC,IAAI,CAAC;AACvB,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,MAAsB,EACtB,QAAuB,EACvB,IAAY;IAEZ,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,IAAI,CAAqB,gBAAgB,EAAE;QACvE,QAAQ;QACR,IAAI;KACmB,CAAC,CAAC;IAE3B,OAAO,QAAQ,CAAC,IAAI,CAAC;AACvB,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,MAAsB,EACtB,YAAoB;IAEpB,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,IAAI,CAAuB,eAAe,EAAE;QACxE,aAAa,EAAE,YAAY;KACL,CAAC,CAAC;IAE1B,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AAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,MAAsB,EACtB,QAAgB;IAQhB,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,GAAG,CAM9B,UAAU,QAAQ,EAAE,CAAC,CAAC;IAEzB,OAAO;QACL,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,QAAQ;QAChC,WAAW,EAAE,QAAQ,CAAC,IAAI,CAAC,YAAY;QACvC,SAAS,EAAE,QAAQ,CAAC,IAAI,CAAC,UAAU;QACnC,SAAS,EAAE,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC;QAC7C,UAAU,EAAE,QAAQ,CAAC,IAAI,CAAC,WAAW;KACtC,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,MAAsB,EACtB,IAAY,EACZ,MAAc,EACd,OAAe,EACf,OAAgB;IAEhB,MAAM,MAAM,CAAC,IAAI,CAAC,UAAU,IAAI,WAAW,EAAE;QAC3C,MAAM;QACN,OAAO;QACP,OAAO;KACR,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,111 @@
1
+ /**
2
+ * Enact Registry API Client
3
+ * Core HTTP client for interacting with the Enact registry
4
+ */
5
+ import type { ApiError, RateLimitInfo } from "./types";
6
+ /**
7
+ * Default registry URL
8
+ */
9
+ export declare const DEFAULT_REGISTRY_URL = "https://siikwkfgsmouioodghho.supabase.co/functions/v1";
10
+ /**
11
+ * API client configuration options
12
+ */
13
+ export interface ApiClientOptions {
14
+ /** Registry base URL (default: https://siikwkfgsmouioodghho.supabase.co/functions/v1) */
15
+ baseUrl?: string | undefined;
16
+ /** Authentication token */
17
+ authToken?: string | undefined;
18
+ /** Request timeout in milliseconds (default: 30000) */
19
+ timeout?: number | undefined;
20
+ /** Number of retry attempts for failed requests (default: 3) */
21
+ retries?: number | undefined;
22
+ /** User agent string */
23
+ userAgent?: string | undefined;
24
+ }
25
+ /**
26
+ * API response wrapper
27
+ */
28
+ export interface ApiResponse<T> {
29
+ /** Response data */
30
+ data: T;
31
+ /** HTTP status code */
32
+ status: number;
33
+ /** Rate limit information */
34
+ rateLimit?: RateLimitInfo | undefined;
35
+ }
36
+ /**
37
+ * API request error
38
+ */
39
+ export declare class ApiRequestError extends Error {
40
+ /** HTTP status code */
41
+ readonly status: number;
42
+ /** API error code */
43
+ readonly code: string;
44
+ /** Original error response */
45
+ readonly response?: ApiError | undefined;
46
+ constructor(message: string, status: number, code: string, response?: ApiError);
47
+ }
48
+ /**
49
+ * Enact Registry API Client
50
+ */
51
+ export declare class EnactApiClient {
52
+ private readonly baseUrl;
53
+ private readonly timeout;
54
+ private readonly maxRetries;
55
+ private readonly userAgent;
56
+ private authToken;
57
+ constructor(options?: ApiClientOptions);
58
+ /**
59
+ * Set authentication token
60
+ */
61
+ setAuthToken(token: string | undefined): void;
62
+ /**
63
+ * Get current authentication token
64
+ */
65
+ getAuthToken(): string | undefined;
66
+ /**
67
+ * Get the base URL for the registry
68
+ */
69
+ getBaseUrl(): string;
70
+ /**
71
+ * Get the user agent string
72
+ */
73
+ getUserAgent(): string;
74
+ /**
75
+ * Check if client is authenticated
76
+ */
77
+ isAuthenticated(): boolean;
78
+ /**
79
+ * Build headers for a request
80
+ */
81
+ private buildHeaders;
82
+ /**
83
+ * Make an HTTP request with retry logic
84
+ */
85
+ private request;
86
+ /**
87
+ * GET request
88
+ */
89
+ get<T>(path: string): Promise<ApiResponse<T>>;
90
+ /**
91
+ * POST request
92
+ */
93
+ post<T>(path: string, body?: unknown): Promise<ApiResponse<T>>;
94
+ /**
95
+ * PUT request
96
+ */
97
+ put<T>(path: string, body?: unknown): Promise<ApiResponse<T>>;
98
+ /**
99
+ * DELETE request
100
+ */
101
+ delete<T>(path: string): Promise<ApiResponse<T>>;
102
+ /**
103
+ * Download a file (returns raw response for streaming)
104
+ */
105
+ download(path: string): Promise<Response>;
106
+ }
107
+ /**
108
+ * Create a new API client instance
109
+ */
110
+ export declare function createApiClient(options?: ApiClientOptions): EnactApiClient;
111
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAEvD;;GAEG;AACH,eAAO,MAAM,oBAAoB,0DAA0D,CAAC;AAE5F;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,yFAAyF;IACzF,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,2BAA2B;IAC3B,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,uDAAuD;IACvD,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,gEAAgE;IAChE,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,wBAAwB;IACxB,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,WAAW,CAAC,CAAC;IAC5B,oBAAoB;IACpB,IAAI,EAAE,CAAC,CAAC;IACR,uBAAuB;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,6BAA6B;IAC7B,SAAS,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;CACvC;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,KAAK;IACxC,uBAAuB;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,qBAAqB;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,8BAA8B;IAC9B,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;gBAE7B,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,QAAQ;CAO/E;A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