@aphexcms/auth 0.1.0

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.
@@ -0,0 +1,532 @@
1
+ import { and, eq } from 'drizzle-orm';
2
+ import { AuthError, createUserProfileWithBootstrap } from '@aphexcms/cms-core/server';
3
+ import { resolveBootstrapPolicy } from './bootstrap-policy.js';
4
+ import { cmsLogger, BUILTIN_ROLE_SEED, coarseApiKeyCapabilities } from '@aphexcms/cms-core';
5
+ /**
6
+ * Capabilities that make a key a *writing* key. Used to decide whether the
7
+ * coarse `write` scope survives the clamp against the owner's actual role.
8
+ */
9
+ const WRITE_CAPABILITIES = [
10
+ 'document.create',
11
+ 'document.update',
12
+ 'document.delete',
13
+ 'document.publish',
14
+ 'document.unpublish',
15
+ 'asset.upload',
16
+ 'asset.delete'
17
+ ];
18
+ function isApiKeyPermission(value) {
19
+ return value === 'read' || value === 'write';
20
+ }
21
+ /**
22
+ * Capabilities a role actually confers in a given organization.
23
+ *
24
+ * Mirrors `RolesService.resolveFromDb`, including its built-in seed fallback:
25
+ * without it, an organization whose built-in role rows were never seeded would
26
+ * resolve to an empty set and silently strip every capability from otherwise
27
+ * valid API keys.
28
+ */
29
+ async function resolveGrantableCapabilities(db, organizationId, roleName) {
30
+ const row = await db.findRoleByName(organizationId, roleName);
31
+ if (row)
32
+ return row.capabilities;
33
+ // Widened rather than asserted: `roleName` is a plain string from the
34
+ // membership row, so an index into the union-keyed record needs no cast.
35
+ const seed = BUILTIN_ROLE_SEED;
36
+ const builtin = seed[roleName];
37
+ if (builtin)
38
+ return builtin.capabilities;
39
+ cmsLogger.warn('[AuthService]', `Unknown role "${roleName}" in org=${organizationId} — API key granted no capabilities`);
40
+ return [];
41
+ }
42
+ /** How many times to retry evicting a revoked key before declaring revocation incomplete. */
43
+ const CACHE_EVICTION_ATTEMPTS = 3;
44
+ /** Base backoff between eviction attempts; multiplied by the attempt number. */
45
+ const CACHE_EVICTION_BACKOFF_MS = 50;
46
+ /**
47
+ * Revocation removed the database row but could not clear the cache, so the key may still
48
+ * authenticate until its entry expires — and a key created without `expiresAt` has no TTL
49
+ * at all, which is to say never.
50
+ *
51
+ * This is thrown rather than logged because the alternative is reporting success for a
52
+ * revocation that didn't take. An operator revoking a leaked key needs to know immediately
53
+ * that it is still live; discovering it from a log line later is not the same thing. The
54
+ * failure is not recoverable in-process (the row is already gone, and re-creating it would
55
+ * be worse), so the correct response is to surface it and let a human flush the cache.
56
+ */
57
+ export class ApiKeyRevocationError extends Error {
58
+ keyId;
59
+ cause;
60
+ code = 'API_KEY_REVOCATION_INCOMPLETE';
61
+ constructor(keyId, cause) {
62
+ super(`API key ${keyId} was deleted from the database but could not be evicted from the ` +
63
+ `cache. It may continue to authenticate until the cache entry expires — flush the ` +
64
+ `auth cache to complete revocation.`);
65
+ this.keyId = keyId;
66
+ this.cause = cause;
67
+ this.name = 'ApiKeyRevocationError';
68
+ }
69
+ }
70
+ export function createAuthService(deps) {
71
+ const { auth, drizzleDb, cache } = deps;
72
+ const bootstrapPolicy = resolveBootstrapPolicy(deps.bootstrap);
73
+ const { user, apikey } = deps.schema;
74
+ /**
75
+ * Remove a revoked key from the api-key plugin's secondary storage.
76
+ *
77
+ * The three key formats are the plugin's own (`api-key:<hashedKey>`,
78
+ * `api-key:by-id:<id>`, `api-key:by-ref:<referenceId>`) — a deliberate but
79
+ * narrow coupling, and the reason this is worth a comment: if a future version
80
+ * renames them, revocation silently stops taking effect rather than failing
81
+ * loudly. The `apikey.key` column stores the already-hashed key, which is what
82
+ * the lookup is keyed on, so nothing here needs the plaintext secret.
83
+ */
84
+ async function evictApiKeyFromCache(row) {
85
+ if (!cache)
86
+ return;
87
+ // Retried before giving up: the common failure is a momentary blip talking to
88
+ // Redis, and re-running the deletes is free — `delete` on an absent key is a
89
+ // no-op, so a partial success on the first pass costs nothing on the second.
90
+ let lastError;
91
+ for (let attempt = 1; attempt <= CACHE_EVICTION_ATTEMPTS; attempt++) {
92
+ try {
93
+ await Promise.all([
94
+ cache.delete(`api-key:${row.key}`),
95
+ cache.delete(`api-key:by-id:${row.id}`),
96
+ ...(row.referenceId ? [cache.delete(`api-key:by-ref:${row.referenceId}`)] : [])
97
+ ]);
98
+ return;
99
+ }
100
+ catch (error) {
101
+ lastError = error;
102
+ if (attempt < CACHE_EVICTION_ATTEMPTS) {
103
+ await new Promise((resolve) => setTimeout(resolve, attempt * CACHE_EVICTION_BACKOFF_MS));
104
+ }
105
+ }
106
+ }
107
+ // Loud, because the key is now live in cache with no database row behind
108
+ // it — the one state an operator needs to know about.
109
+ cmsLogger.error('[AuthService]', `API key ${row.id} was deleted but could not be evicted from cache — it may still authenticate:`, lastError);
110
+ throw new ApiKeyRevocationError(row.id, lastError);
111
+ }
112
+ return {
113
+ async getSession(request, db) {
114
+ try {
115
+ cmsLogger.debug('[AuthService]', 'getSession called');
116
+ // 1. Get the base user session from the auth provider
117
+ const session = await auth.api.getSession({ headers: request.headers });
118
+ if (!session) {
119
+ cmsLogger.debug('[AuthService]', 'No active session found from auth provider');
120
+ return null;
121
+ }
122
+ cmsLogger.debug('[AuthService]', `Found session for user ${session.user.id}`);
123
+ // 2. Get the corresponding CMS user profile from our database
124
+ cmsLogger.debug('[AuthService]', `Checking for user profile for ${session.user.id}`);
125
+ let userProfile = await db.findUserProfileById(session.user.id);
126
+ // 3. If no profile exists, create one (lazy sync)
127
+ if (!userProfile) {
128
+ cmsLogger.info('[AuthService]', `User profile not found for ${session.user.id}. Creating one now (lazy sync).`);
129
+ // Bootstrap promotion lives in cms-core so it happens identically no
130
+ // matter who authenticated the user — this package is just one provider.
131
+ userProfile = await createUserProfileWithBootstrap({
132
+ db,
133
+ user: {
134
+ id: session.user.id,
135
+ email: session.user.email,
136
+ emailVerified: session.user.emailVerified === true
137
+ },
138
+ request,
139
+ bootstrap: bootstrapPolicy
140
+ });
141
+ }
142
+ // 4. Combine the two into the final CMSUser object
143
+ const cmsUser = {
144
+ id: session.user.id,
145
+ email: session.user.email,
146
+ name: session.user.name ?? undefined,
147
+ image: session.user.image ?? undefined,
148
+ role: userProfile.role,
149
+ preferences: userProfile.preferences
150
+ };
151
+ cmsLogger.debug('[AuthService]', `Successfully assembled CMSUser for ${session.user.id}`);
152
+ // 5. Get the user's active organization from their session
153
+ cmsLogger.debug('[AuthService]', `Fetching active organization for ${session.user.id}`);
154
+ const userSession = await db.findUserSession(session.user.id);
155
+ // If no session exists, get the user's first organization as the default
156
+ if (!userSession) {
157
+ cmsLogger.debug('[AuthService]', `No user session found. Fetching user's organizations.`);
158
+ const userOrgs = await db.findUserOrganizations(session.user.id);
159
+ if (userOrgs.length === 0) {
160
+ // If this is a super_admin with no orgs, create a default organization
161
+ if (cmsUser.role === 'super_admin') {
162
+ cmsLogger.info('[AuthService]', `Super admin ${session.user.id} has no organizations. Creating default organization.`);
163
+ const defaultOrg = await db.createOrganization({
164
+ name: 'Default Organization',
165
+ slug: 'default',
166
+ createdBy: session.user.id
167
+ });
168
+ // Seed built-in roles before assigning membership — member
169
+ // rows reference roles by name, so they must exist first.
170
+ await db.seedBuiltinRoles(defaultOrg.id);
171
+ // Add super admin as owner
172
+ await db.addMember({
173
+ organizationId: defaultOrg.id,
174
+ userId: session.user.id,
175
+ role: 'owner'
176
+ });
177
+ // Set as active organization
178
+ await db.updateUserSession(session.user.id, defaultOrg.id);
179
+ cmsLogger.info('[AuthService]', `Created default organization ${defaultOrg.id} for super admin.`);
180
+ return {
181
+ type: 'session',
182
+ user: cmsUser,
183
+ session: {
184
+ id: session.session.id,
185
+ expiresAt: session.session.expiresAt
186
+ },
187
+ organizationId: defaultOrg.id,
188
+ organizationRole: 'owner'
189
+ };
190
+ }
191
+ // User has no organizations — return partial session without org context
192
+ // Routes like /invitations can use this to identify the user
193
+ cmsLogger.debug('[AuthService]', `User ${session.user.id} has no organizations. Returning partial session.`);
194
+ return {
195
+ type: 'partial_session',
196
+ user: cmsUser,
197
+ session: {
198
+ id: session.session.id,
199
+ expiresAt: session.session.expiresAt
200
+ }
201
+ };
202
+ }
203
+ // Set the first organization as active
204
+ const firstOrg = userOrgs[0];
205
+ await db.updateUserSession(session.user.id, firstOrg.organization.id);
206
+ cmsLogger.debug('[AuthService]', `Set first organization ${firstOrg.organization.id} as active.`);
207
+ return {
208
+ type: 'session',
209
+ user: cmsUser,
210
+ session: {
211
+ id: session.session.id,
212
+ expiresAt: session.session.expiresAt
213
+ },
214
+ organizationId: firstOrg.organization.id,
215
+ organizationRole: firstOrg.member.role
216
+ };
217
+ }
218
+ // 6. Get the user's membership in the active organization
219
+ cmsLogger.debug('[AuthService]', `Getting membership for org ${userSession.activeOrganizationId}`);
220
+ const membership = await db.findUserMembership(session.user.id, userSession.activeOrganizationId);
221
+ if (!membership) {
222
+ cmsLogger.error('[AuthService]', `User ${session.user.id} is not a member of org ${userSession.activeOrganizationId}`);
223
+ throw new AuthError('kicked_from_org', 'User is not a member of the active organization');
224
+ }
225
+ // 7. Return the complete SessionAuth object with organization context
226
+ return {
227
+ type: 'session',
228
+ user: cmsUser,
229
+ session: {
230
+ id: session.session.id,
231
+ expiresAt: session.session.expiresAt
232
+ },
233
+ organizationId: userSession.activeOrganizationId,
234
+ organizationRole: membership.role
235
+ };
236
+ }
237
+ catch (error) {
238
+ // Re-throw AuthError to preserve error codes
239
+ if (error instanceof AuthError) {
240
+ throw error;
241
+ }
242
+ cmsLogger.error('[AuthService]', 'Error in getSession:', error);
243
+ return null;
244
+ }
245
+ },
246
+ async requireSession(request, db) {
247
+ const session = await this.getSession(request, db);
248
+ if (!session) {
249
+ throw new AuthError('no_session', 'Unauthorized: Session required');
250
+ }
251
+ // User is authenticated but has no organization — redirect to invitations
252
+ if (session.type === 'partial_session') {
253
+ throw new AuthError('pending_invitations', 'User has pending invitations to review');
254
+ }
255
+ return session;
256
+ },
257
+ async validateApiKey(request, db) {
258
+ try {
259
+ const apiKeyHeader = request.headers.get('x-api-key');
260
+ if (!apiKeyHeader)
261
+ return null;
262
+ const result = await auth.api.verifyApiKey({ body: { key: apiKeyHeader } });
263
+ if (!result.valid || !result.key)
264
+ return null;
265
+ // Key metadata is CLIENT-WRITABLE. better-auth mounts its own
266
+ // `POST /api-key/create`, and `enableMetadata` lets any signed-in user
267
+ // put whatever they like in it — so nothing read here is authority, only
268
+ // a claim about which organization the key was meant for. Treating it as
269
+ // authority let any user mint a key for another tenant with arbitrary
270
+ // capabilities.
271
+ const metadata = result.key.metadata || {};
272
+ const claimedOrganizationId = metadata.organizationId;
273
+ if (!claimedOrganizationId) {
274
+ cmsLogger.error('[AuthService]', `API key ${result.key.id} missing organizationId in metadata`);
275
+ return null;
276
+ }
277
+ // The key acts as its owner. Re-check membership on every request rather
278
+ // than trusting the claim: this is also what revokes a key's access the
279
+ // moment its owner is removed from the organization.
280
+ // `referenceId` is the owning entity — userId here, since the plugin is
281
+ // left on its default `references` setting (see createApiKey below).
282
+ const ownerId = result.key.referenceId;
283
+ const membership = ownerId
284
+ ? await db.findUserMembership(ownerId, claimedOrganizationId)
285
+ : null;
286
+ if (!membership) {
287
+ cmsLogger.warn('[AuthService]', `API key ${result.key.id} rejected — owner is not a member of ${claimedOrganizationId}`);
288
+ return null;
289
+ }
290
+ // A key can never grant more than its owner holds in that organization.
291
+ // Instance admins are intentionally *not* special-cased: a long-lived
292
+ // bearer token shouldn't silently carry break-glass powers.
293
+ const grantable = new Set(await resolveGrantableCapabilities(db, claimedOrganizationId, membership.role));
294
+ // Same clamp for the coarse read/write scopes.
295
+ const requestedPermissions = Array.isArray(metadata.permissions)
296
+ ? metadata.permissions
297
+ : ['read'];
298
+ const canWrite = WRITE_CAPABILITIES.some((capability) => grantable.has(capability));
299
+ const permissions = requestedPermissions
300
+ .filter(isApiKeyPermission)
301
+ .filter((permission) => permission !== 'write' || canWrite);
302
+ // Always resolved to a concrete list here, never left undefined for a
303
+ // consumer to expand later. A key with no allowlist means "whatever the
304
+ // coarse scopes imply", and that expansion has to be clamped the same
305
+ // way an explicit list is: `canWrite` above only asks whether the owner
306
+ // can write *at all*, so an editor whose role lacks `document.delete`
307
+ // would otherwise pick it up from the `write` scope. Intersecting here
308
+ // makes `grantable` the ceiling for both paths.
309
+ const requested = Array.isArray(metadata.capabilities)
310
+ ? metadata.capabilities
311
+ : coarseApiKeyCapabilities(permissions);
312
+ const capabilities = requested
313
+ .filter((capability) => typeof capability === 'string')
314
+ .filter((capability) => grantable.has(capability));
315
+ return {
316
+ type: 'api_key',
317
+ keyId: result.key.id,
318
+ name: result.key.name || 'Unnamed Key',
319
+ permissions,
320
+ capabilities,
321
+ organizationId: claimedOrganizationId,
322
+ lastUsedAt: result.key.lastRequest || undefined
323
+ };
324
+ }
325
+ catch (error) {
326
+ cmsLogger.error('[AuthService]', 'validateApiKey error:', error);
327
+ return null;
328
+ }
329
+ },
330
+ async requireApiKey(request, db, permission) {
331
+ const apiKeyAuth = await this.validateApiKey(request, db);
332
+ if (!apiKeyAuth) {
333
+ throw new Error('Unauthorized: Valid API key required');
334
+ }
335
+ if (permission && !apiKeyAuth.permissions.includes(permission)) {
336
+ throw new Error(`Forbidden: API key missing ${permission} permission`);
337
+ }
338
+ return apiKeyAuth;
339
+ },
340
+ async listApiKeys(_db, userId) {
341
+ // Query the apikey table directly using drizzleDb (not the adapter)
342
+ const userApiKeys = await drizzleDb.query.apikey.findMany({
343
+ where: eq(apikey.referenceId, userId),
344
+ columns: {
345
+ id: true,
346
+ name: true,
347
+ metadata: true,
348
+ expiresAt: true,
349
+ lastRequest: true,
350
+ createdAt: true
351
+ },
352
+ orderBy: (table, ops) => [
353
+ ops.desc(table.createdAt)
354
+ ]
355
+ });
356
+ return userApiKeys.map((key) => {
357
+ const metadata = typeof key.metadata === 'string' ? JSON.parse(key.metadata) : key.metadata || {};
358
+ return {
359
+ ...key,
360
+ permissions: metadata.permissions || [],
361
+ capabilities: Array.isArray(metadata.capabilities) ? metadata.capabilities : undefined,
362
+ organizationId: metadata.organizationId
363
+ };
364
+ });
365
+ },
366
+ async createApiKey(userId, organizationId, data) {
367
+ const expiresIn = data.expiresInDays ? data.expiresInDays * 24 * 60 * 60 : undefined;
368
+ const result = await auth.api.createApiKey({
369
+ body: {
370
+ userId: userId,
371
+ name: data.name,
372
+ expiresIn,
373
+ metadata: {
374
+ // Keep both fields for forward/backward compatibility:
375
+ // older validators read `permissions`, newer ones prefer
376
+ // `capabilities` when the caller supplied them.
377
+ permissions: data.permissions ?? ['read'],
378
+ capabilities: data.capabilities,
379
+ organizationId: organizationId
380
+ }
381
+ }
382
+ });
383
+ if (!result || !result.id) {
384
+ throw new Error('Failed to create API key');
385
+ }
386
+ return {
387
+ id: result.id,
388
+ name: result.name,
389
+ key: result.key,
390
+ permissions: data.permissions ?? ['read'],
391
+ capabilities: data.capabilities,
392
+ organizationId: organizationId,
393
+ expiresAt: result.expiresAt,
394
+ createdAt: result.createdAt
395
+ };
396
+ },
397
+ async deleteApiKey(userId, keyId) {
398
+ // Scoped by owner in the WHERE clause, not checked beforehand: a key id
399
+ // belonging to somebody else matches nothing and reports false, so one
400
+ // account can't delete another's key by guessing an id.
401
+ //
402
+ // `referenceId` is the owner column — better-auth's api-key plugin does not
403
+ // call it `userId`.
404
+ const deleted = await drizzleDb
405
+ .delete(apikey)
406
+ .where(and(eq(apikey.id, keyId), eq(apikey.referenceId, userId)))
407
+ .returning({ id: apikey.id, key: apikey.key, referenceId: apikey.referenceId });
408
+ if (!deleted.length) {
409
+ cmsLogger.warn('[AuthService]', `No API key ${keyId} owned by ${userId} — nothing deleted`);
410
+ return false;
411
+ }
412
+ // Dropping the row is not revocation on its own. The api-key plugin runs
413
+ // in `secondary-storage` mode with `fallbackToDatabase`, and its lookup
414
+ // returns a cache hit *without* consulting the database — so a deleted key
415
+ // keeps authenticating for as long as its cache entry lives. Entries are
416
+ // written with a TTL derived from `expiresAt`, and a key created without
417
+ // an expiry (the default) gets no TTL at all, so "until it expires" meant
418
+ // "forever" for exactly the keys most worth revoking.
419
+ //
420
+ // Deliberately not caught: if eviction fails this throws `ApiKeyRevocationError`
421
+ // and the caller reports a failure. The row really is gone by now, so the throw
422
+ // isn't "nothing happened" — it's "revocation is incomplete", which is precisely
423
+ // what the operator has to act on. Swallowing it here would return `true` for a
424
+ // key that still authenticates.
425
+ await evictApiKeyFromCache(deleted[0]);
426
+ cmsLogger.info('[AuthService]', `Deleted API key ${keyId}`);
427
+ return true;
428
+ },
429
+ async getUserById(userId) {
430
+ try {
431
+ const userRecord = await drizzleDb.query.user.findFirst({
432
+ where: eq(user.id, userId),
433
+ columns: {
434
+ id: true,
435
+ name: true,
436
+ email: true,
437
+ image: true
438
+ }
439
+ });
440
+ if (!userRecord) {
441
+ return null;
442
+ }
443
+ return {
444
+ id: userRecord.id,
445
+ name: userRecord.name ?? undefined,
446
+ email: userRecord.email,
447
+ image: userRecord.image ?? undefined
448
+ };
449
+ }
450
+ catch (error) {
451
+ cmsLogger.error('[AuthService]', 'Error fetching user by ID:', error);
452
+ return null;
453
+ }
454
+ },
455
+ async getUserByEmail(email) {
456
+ try {
457
+ const userRecord = await drizzleDb.query.user.findFirst({
458
+ where: eq(user.email, email.toLowerCase()),
459
+ columns: {
460
+ id: true,
461
+ name: true,
462
+ email: true,
463
+ image: true
464
+ }
465
+ });
466
+ if (!userRecord) {
467
+ return null;
468
+ }
469
+ return {
470
+ id: userRecord.id,
471
+ name: userRecord.name ?? undefined,
472
+ email: userRecord.email,
473
+ image: userRecord.image ?? undefined
474
+ };
475
+ }
476
+ catch (error) {
477
+ cmsLogger.error('[AuthService]', 'Error fetching user by email:', error);
478
+ return null;
479
+ }
480
+ },
481
+ async changeUserName(userId, name) {
482
+ await drizzleDb
483
+ .update(user)
484
+ .set({
485
+ name,
486
+ updatedAt: new Date()
487
+ })
488
+ .where(eq(user.id, userId));
489
+ },
490
+ async changeUserImage(userId, image) {
491
+ await drizzleDb
492
+ .update(user)
493
+ .set({
494
+ image,
495
+ updatedAt: new Date()
496
+ })
497
+ .where(eq(user.id, userId));
498
+ },
499
+ async requestPasswordReset(email, redirectTo) {
500
+ try {
501
+ await auth.api.requestPasswordReset({
502
+ body: {
503
+ email,
504
+ redirectTo
505
+ }
506
+ });
507
+ // TODO: Send password reset email via email adapter - for true agnosticism
508
+ // The email adapter can be accessed from event.locals.aphexCMS.emailAdapter
509
+ // For now, Better Auth handles the email sending internally
510
+ }
511
+ catch (error) {
512
+ cmsLogger.error('[AuthService]', 'Error requesting password reset:', error);
513
+ throw error;
514
+ }
515
+ },
516
+ async resetPassword(token, newPassword) {
517
+ try {
518
+ await auth.api.resetPassword({
519
+ body: {
520
+ newPassword,
521
+ token
522
+ }
523
+ });
524
+ }
525
+ catch (error) {
526
+ cmsLogger.error('[AuthService]', 'Error resetting password:', error);
527
+ throw error;
528
+ }
529
+ }
530
+ };
531
+ }
532
+ //# sourceMappingURL=service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAStC,OAAO,EACN,SAAS,EACT,8BAA8B,EAG9B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAE5F;;;GAGG;AACH,MAAM,kBAAkB,GAAG;IAC1B,iBAAiB;IACjB,iBAAiB;IACjB,iBAAiB;IACjB,kBAAkB;IAClB,oBAAoB;IACpB,cAAc;IACd,cAAc;CACL,CAAC;AAIX,SAAS,kBAAkB,CAAC,KAAc;IACzC,OAAO,KAAK,KAAK,MAAM,IAAI,KAAK,KAAK,OAAO,CAAC;AAC9C,CAAC;AAED;;;;;;;GAOG;AACH,KAAK,UAAU,4BAA4B,CAC1C,EAAmB,EACnB,cAAsB,EACtB,QAAgB;IAEhB,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC,cAAc,CAAC,cAAc,EAAE,QAAQ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