forked from JavaScriptSolidServer/JavaScriptSolidServer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinteractions.js
More file actions
693 lines (596 loc) · 24.1 KB
/
Copy pathinteractions.js
File metadata and controls
693 lines (596 loc) · 24.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
/**
* Interaction handlers for login, consent, and registration flows
* Handles the user-facing parts of the authentication flow
*/
import { authenticate, findById, findByWebId, createAccount, updateLastLogin, setPasskeyPromptDismissed } from './accounts.js';
import { loginPage, consentPage, errorPage, registerPage, passkeyPromptPage } from './views.js';
import * as storage from '../storage/filesystem.js';
import { createPodStructure } from '../handlers/container.js';
import { validateInvite } from './invites.js';
import { verifyNostrAuth } from '../auth/nostr.js';
// Security: Maximum body size for IdP form submissions (1MB)
const MAX_BODY_SIZE = 1024 * 1024;
/**
* Handle GET /idp/interaction/:uid
* Shows login or consent page based on interaction state
*/
export async function handleInteractionGet(request, reply, provider) {
const { uid } = request.params;
try {
const interaction = await provider.Interaction.find(uid);
if (!interaction) {
return reply.code(404).type('text/html').send(errorPage('Interaction not found', 'This login session has expired. Please try again.'));
}
const { prompt, params, session } = interaction;
// If we need login
if (prompt.name === 'login') {
return reply.type('text/html').send(loginPage(uid, params.client_id, interaction.lastError));
}
// If we need consent
if (prompt.name === 'consent') {
const client = await provider.Client.find(params.client_id);
const account = session?.accountId ? await findById(session.accountId) : null;
return reply.type('text/html').send(consentPage(uid, client, params, account));
}
// Unknown prompt
return reply.code(400).type('text/html').send(errorPage('Unknown prompt', `Unexpected prompt: ${prompt.name}`));
} catch (err) {
request.log.error(err, 'Interaction error');
return reply.code(500).type('text/html').send(errorPage('Server Error', err.message));
}
}
/**
* Handle POST /idp/interaction/:uid/login
* Processes login form submission
*/
export async function handleLogin(request, reply, provider) {
const { uid } = request.params;
// Parse body - handle multiple formats (Buffer, string, object)
let parsedBody = request.body || {};
const contentType = request.headers['content-type'] || '';
if (Buffer.isBuffer(parsedBody)) {
// Security: check body size
if (parsedBody.length > MAX_BODY_SIZE) {
return reply.code(413).type('text/html').send(errorPage('Request Too Large', 'Request body exceeds maximum size.'));
}
const bodyStr = parsedBody.toString();
if (contentType.includes('application/json')) {
try {
parsedBody = JSON.parse(bodyStr);
} catch (e) {
parsedBody = {};
}
} else {
// Assume form-urlencoded
const params = new URLSearchParams(bodyStr);
parsedBody = Object.fromEntries(params.entries());
}
} else if (typeof parsedBody === 'string') {
// Security: check body size
if (parsedBody.length > MAX_BODY_SIZE) {
return reply.code(413).type('text/html').send(errorPage('Request Too Large', 'Request body exceeds maximum size.'));
}
// Body might be a string for form-urlencoded
if (contentType.includes('application/json')) {
try {
parsedBody = JSON.parse(parsedBody);
} catch (e) {
parsedBody = {};
}
} else {
const params = new URLSearchParams(parsedBody);
parsedBody = Object.fromEntries(params.entries());
}
}
// If it's already an object, use as-is
// Support username, email, or legacy 'email' field for backwards compatibility
const identifier = parsedBody.username || parsedBody.email;
const password = parsedBody.password;
request.log.info({ identifier, hasPassword: !!password, bodyType: typeof request.body, keys: Object.keys(parsedBody) }, 'Login attempt');
try {
const interaction = await provider.Interaction.find(uid);
if (!interaction) {
return reply.code(404).type('text/html').send(errorPage('Session expired', 'Please try logging in again.'));
}
// Validate input
if (!identifier || !password) {
interaction.lastError = 'Username and password are required';
await interaction.save(interaction.exp - Math.floor(Date.now() / 1000));
return reply.redirect(`/idp/interaction/${uid}`);
}
// Authenticate
const account = await authenticate(identifier, password);
if (!account) {
interaction.lastError = 'Invalid username or password';
await interaction.save(interaction.exp - Math.floor(Date.now() / 1000));
return reply.redirect(`/idp/interaction/${uid}`);
}
// Login successful
request.log.info({ accountId: account.id, uid }, 'Login successful');
// Detect if this is a browser (wants HTML/redirect) or programmatic client (wants JSON)
const acceptHeader = request.headers.accept || '';
const wantsBrowserRedirect = acceptHeader.includes('text/html') && !acceptHeader.includes('application/json');
// Check if user should see passkey prompt (browser only, no passkeys, not dismissed)
const fullAccount = await findById(account.id);
const shouldPromptPasskey = wantsBrowserRedirect &&
!fullAccount.passkeys?.length &&
!fullAccount.passkeyPromptDismissed;
if (shouldPromptPasskey) {
// Show passkey registration prompt before completing login
// Store the pending login in the interaction
interaction.result = {
passkeyPromptPending: true,
login: { accountId: account.id, remember: true }
};
await interaction.save(interaction.exp - Math.floor(Date.now() / 1000));
return reply.type('text/html').send(passkeyPromptPage(uid, account.id));
}
// Complete the interaction
const result = {
login: {
accountId: account.id,
remember: true,
},
};
// Save the login result to the interaction
interaction.result = result;
await interaction.save(interaction.exp - Math.floor(Date.now() / 1000));
// For browsers (mashlib, etc): do a proper HTTP redirect
if (wantsBrowserRedirect) {
reply.hijack();
return provider.interactionFinished(request.raw, reply.raw, result, { mergeWithLastSubmission: false });
}
// For CTH and programmatic clients: return JSON with location
// CTH expects a 200 response with "location" in body (CSS v3+ style)
try {
reply.hijack();
// Create a mock response that captures the redirect and returns JSON
let capturedLocation = null;
let headersSent = false;
const mockRes = {
statusCode: 200,
headersSent: false,
setHeader: (name, value) => {
if (name.toLowerCase() === 'location') {
capturedLocation = value;
}
return mockRes;
},
getHeader: (name) => {
if (name.toLowerCase() === 'location') return capturedLocation;
return undefined;
},
removeHeader: () => mockRes,
writeHead: (status, headers) => {
if (headers) {
if (typeof headers === 'object' && !Array.isArray(headers)) {
for (const [key, value] of Object.entries(headers)) {
if (key.toLowerCase() === 'location') {
capturedLocation = value;
}
}
}
}
return mockRes;
},
write: () => mockRes,
end: (body) => {
if (!headersSent) {
headersSent = true;
const location = capturedLocation || `/idp/auth/${uid}`;
reply.raw.writeHead(200, {
'Content-Type': 'application/json',
'Location': location,
});
reply.raw.end(JSON.stringify({ location }));
}
},
finished: false,
on: () => mockRes,
once: () => mockRes,
emit: () => mockRes,
};
await provider.interactionFinished(request.raw, mockRes, result, { mergeWithLastSubmission: false });
return;
} catch (err) {
request.log.warn({ err: err.message, errName: err.name, uid }, 'interactionFinished failed, using fallback');
// Fallback: return the redirect URL for manual following
const redirectTo = `/idp/auth/${uid}`;
return reply
.code(200)
.header('Location', redirectTo)
.type('application/json')
.send({ location: redirectTo });
}
} catch (err) {
request.log.error(err, 'Login error');
return reply.code(500).type('text/html').send(errorPage('Login failed', err.message));
}
}
/**
* Handle POST /idp/interaction/:uid/confirm
* Processes consent confirmation
*/
export async function handleConsent(request, reply, provider) {
const { uid } = request.params;
try {
const interaction = await provider.Interaction.find(uid);
if (!interaction) {
return reply.code(404).type('text/html').send(errorPage('Session expired', 'Please try again.'));
}
const { prompt, params, session } = interaction;
if (prompt.name !== 'consent') {
return reply.code(400).type('text/html').send(errorPage('Invalid state', 'Not in consent stage.'));
}
// Grant consent
const grant = new provider.Grant({
accountId: session.accountId,
clientId: params.client_id,
});
// Grant requested scopes
if (params.scope) {
grant.addOIDCScope(params.scope);
}
// Grant resource-specific scopes if present
if (params.resource) {
const resources = Array.isArray(params.resource) ? params.resource : [params.resource];
for (const resource of resources) {
grant.addResourceScope(resource, params.scope);
}
}
const grantId = await grant.save();
const result = {
consent: {
grantId,
},
};
// Mark reply as sent since interactionFinished will handle the response
reply.hijack();
// Use interactionFinished which handles the redirect directly
return provider.interactionFinished(
request.raw,
reply.raw,
result,
{ mergeWithLastSubmission: true }
);
} catch (err) {
request.log.error(err, 'Consent error');
return reply.code(500).type('text/html').send(errorPage('Consent failed', err.message));
}
}
/**
* Handle POST /idp/interaction/:uid/abort
* User cancelled the flow
*/
export async function handleAbort(request, reply, provider) {
const { uid } = request.params;
try {
const result = {
error: 'access_denied',
error_description: 'User cancelled the authorization request',
};
// oidc-provider is configured with /idp routes, so redirectTo will have correct path
const redirectTo = await provider.interactionResult(
request.raw,
reply.raw,
result,
{ mergeWithLastSubmission: false }
);
return reply.redirect(redirectTo);
} catch (err) {
request.log.error(err, 'Abort error');
return reply.code(500).type('text/html').send(errorPage('Error', err.message));
}
}
/**
* Handle GET /idp/register
* Shows registration page
*/
export async function handleRegisterGet(request, reply, issuer, inviteOnly = false) {
const uid = request.query.uid || null;
const ctx = previewContext(request, issuer);
return reply.type('text/html').send(registerPage(uid, null, null, inviteOnly, ctx));
}
// Live-preview context for the register page: lets the client-side script
// build the WebID + storage URL the user is about to claim, before submit.
function previewContext(request, issuer) {
const baseUri = (issuer || `${request.protocol}://${request.hostname}`).replace(/\/$/, '');
return {
baseUri,
subdomainsEnabled: !!request.subdomainsEnabled,
baseDomain: request.baseDomain || null,
};
}
/**
* Handle POST /idp/register
* Creates account and pod
*/
export async function handleRegisterPost(request, reply, issuer, inviteOnly = false) {
const uid = request.query.uid || null;
const ctx = previewContext(request, issuer);
// Parse body
let parsedBody = request.body || {};
const contentType = request.headers['content-type'] || '';
if (Buffer.isBuffer(parsedBody)) {
// Security: check body size
if (parsedBody.length > MAX_BODY_SIZE) {
return reply.code(413).type('text/html').send(registerPage(null, 'Request body exceeds maximum size.', null, inviteOnly, ctx));
}
const bodyStr = parsedBody.toString();
if (contentType.includes('application/json')) {
try {
parsedBody = JSON.parse(bodyStr);
} catch (e) {
parsedBody = {};
}
} else {
const params = new URLSearchParams(bodyStr);
parsedBody = Object.fromEntries(params.entries());
}
} else if (typeof parsedBody === 'string') {
// Security: check body size
if (parsedBody.length > MAX_BODY_SIZE) {
return reply.code(413).type('text/html').send(registerPage(null, 'Request body exceeds maximum size.', null, inviteOnly, ctx));
}
const params = new URLSearchParams(parsedBody);
parsedBody = Object.fromEntries(params.entries());
}
const { username, password, confirmPassword, invite } = parsedBody;
// Validate invite code if invite-only mode is enabled
if (inviteOnly) {
const inviteResult = await validateInvite(invite);
if (!inviteResult.valid) {
return reply.code(403).type('text/html').send(registerPage(uid, inviteResult.error, null, inviteOnly, ctx));
}
}
// Validate input
if (!username || !password) {
return reply.type('text/html').send(registerPage(uid, 'Username and password are required', null, inviteOnly, ctx));
}
// Validate username format. Must start and end alphanumeric; the middle
// can contain dot, dash, underscore — covers `alice-smith`, `alice.smith`,
// `alice_work`, and so on. No leading/trailing separators (avoids the
// `.hidden` / trailing-dot footguns), no `..` (path traversal hygiene
// even though storage already guards against it).
//
// In subdomain mode the username becomes a single-level subdomain — DNS
// hostnames don't allow `.` or `_`, and `server.js` already refuses to
// route multi-level subdomains as pods. So we restrict to alphanumeric +
// hyphen there to keep the username and the pod actually addressable.
const subdomainMode = !!(request.subdomainsEnabled && request.baseDomain);
const usernameRegex = subdomainMode
? /^[a-z0-9]([a-z0-9-]{1,30}[a-z0-9])?$/
: /^[a-z0-9]([a-z0-9._-]{1,30}[a-z0-9])?$/;
if (!usernameRegex.test(username)) {
const msg = subdomainMode
? 'Username must be lowercase letters, numbers, or - (subdomain mode disallows . and _)'
: 'Username must be lowercase letters, numbers, or . _ - (start and end alphanumeric)';
return reply.type('text/html').send(registerPage(uid, msg, null, inviteOnly, ctx));
}
if (username.includes('..')) {
return reply.type('text/html').send(registerPage(uid, 'Username cannot contain ".."', null, inviteOnly, ctx));
}
if (username.length < 3) {
return reply.type('text/html').send(registerPage(uid, 'Username must be at least 3 characters', null, inviteOnly, ctx));
}
// Password strength validation
if (password.length < 8) {
return reply.type('text/html').send(registerPage(uid, 'Password must be at least 8 characters', null, inviteOnly, ctx));
}
if (password !== confirmPassword) {
return reply.type('text/html').send(registerPage(uid, 'Passwords do not match', null, inviteOnly, ctx));
}
try {
// Build URLs. WebID is the JSON-LD profile with an #me fragment.
const subdomainsEnabled = request.subdomainsEnabled;
const baseDomain = request.baseDomain;
const baseUrl = issuer.endsWith('/') ? issuer.slice(0, -1) : issuer;
let podUri, webId;
if (subdomainsEnabled && baseDomain) {
// Subdomain mode: alice.example.com/profile/card.jsonld#me
podUri = `${request.protocol}://${username}.${baseDomain}/`;
webId = `${podUri}profile/card.jsonld#me`;
} else {
// Path mode: example.com/alice/profile/card.jsonld#me
podUri = `${baseUrl}/${username}/`;
webId = `${podUri}profile/card.jsonld#me`;
}
// Check if pod already exists
const podPath = `${username}/`;
const podExists = await storage.exists(podPath);
if (podExists) {
return reply.type('text/html').send(registerPage(uid, 'Username is already taken', null, inviteOnly, ctx));
}
// Create pod structure
await createPodStructure(username, webId, podUri, issuer);
// Create account
await createAccount({
username,
password,
webId,
podName: username,
});
request.log.info({ username, webId }, 'Account and pod created');
// Redirect to login
if (uid) {
return reply.redirect(`/idp/interaction/${uid}`);
} else {
return reply.type('text/html').send(registerPage(null, null, `Account created! You can now sign in as "${username}".`, inviteOnly, ctx));
}
} catch (err) {
request.log.error(err, 'Registration error');
return reply.type('text/html').send(registerPage(uid, err.message, null, inviteOnly, ctx));
}
}
/**
* Handle GET /idp/interaction/:uid/passkey-complete
* Completes OIDC interaction after passkey login or registration
*/
export async function handlePasskeyComplete(request, reply, provider) {
const { uid } = request.params;
const { accountId } = request.query;
if (!accountId) {
return reply.code(400).type('text/html').send(errorPage('Missing account', 'Account ID is required.'));
}
try {
const interaction = await provider.Interaction.find(uid);
if (!interaction) {
return reply.code(404).type('text/html').send(errorPage('Session expired', 'Please try logging in again.'));
}
// If this is a post-login passkey registration flow, validate accountId matches
// the already-authenticated user to prevent account takeover
if (interaction.result?.passkeyPromptPending && interaction.result?.login?.accountId) {
if (interaction.result.login.accountId !== accountId) {
request.log.warn({ expected: interaction.result.login.accountId, provided: accountId }, 'AccountId mismatch in passkey complete');
return reply.code(403).type('text/html').send(errorPage('Access denied', 'Account mismatch.'));
}
}
const account = await findById(accountId);
if (!account) {
return reply.code(404).type('text/html').send(errorPage('Account not found', 'The account could not be found.'));
}
// Update last login
await updateLastLogin(accountId);
// Complete the OIDC interaction
const result = {
login: {
accountId: account.id,
remember: true,
},
};
request.log.info({ accountId: account.id, uid }, 'Passkey login completed');
reply.hijack();
return provider.interactionFinished(request.raw, reply.raw, result, { mergeWithLastSubmission: false });
} catch (err) {
request.log.error(err, 'Passkey complete error');
return reply.code(500).type('text/html').send(errorPage('Error', err.message));
}
}
/**
* Handle GET /idp/interaction/:uid/passkey-skip
* User skipped passkey registration, complete login
*/
export async function handlePasskeySkip(request, reply, provider) {
const { uid } = request.params;
try {
const interaction = await provider.Interaction.find(uid);
if (!interaction) {
return reply.code(404).type('text/html').send(errorPage('Session expired', 'Please try logging in again.'));
}
// Validate the interaction is in the passkey prompt state
if (!interaction.result?.passkeyPromptPending) {
return reply.code(400).type('text/html').send(errorPage('Invalid state', 'Not in passkey prompt flow.'));
}
// Get the pending login result
const result = interaction.result;
if (!result?.login?.accountId) {
return reply.code(400).type('text/html').send(errorPage('Invalid state', 'No pending login found.'));
}
// Mark passkey prompt as dismissed so we don't nag again
await setPasskeyPromptDismissed(result.login.accountId, true);
request.log.info({ accountId: result.login.accountId, uid }, 'Passkey prompt skipped');
// Complete the OIDC interaction
reply.hijack();
return provider.interactionFinished(request.raw, reply.raw, result, { mergeWithLastSubmission: false });
} catch (err) {
request.log.error(err, 'Passkey skip error');
return reply.code(500).type('text/html').send(errorPage('Error', err.message));
}
}
/**
* Handle POST /idp/interaction/:uid/schnorr-login
* Authenticates user via Schnorr signature (NIP-98)
*/
export async function handleSchnorrLogin(request, reply, provider) {
const { uid } = request.params;
try {
const interaction = await provider.Interaction.find(uid);
if (!interaction) {
return reply.code(404).type('application/json').send({
success: false,
error: 'Session expired. Please try again.'
});
}
// Verify the Schnorr signature
const authResult = await verifyNostrAuth(request);
if (authResult.error) {
request.log.warn({ error: authResult.error }, 'Schnorr auth failed');
return reply.code(401).type('application/json').send({
success: false,
error: authResult.error
});
}
// authResult.webId is either a resolved WebID or did:nostr:pubkey
const identity = authResult.webId;
request.log.info({ identity, uid }, 'Schnorr auth verified');
// Try to find an existing account linked to this identity
let account = await findByWebId(identity);
if (!account) {
// No account linked to this did:nostr
// For now, return error - user needs to link their did:nostr to an account
// Future: could auto-create account or prompt for linking
return reply.code(403).type('application/json').send({
success: false,
error: 'No account linked to this identity. Please register or link your Schnorr key to an existing account.'
});
}
// Update last login
await updateLastLogin(account.id);
// Complete the OIDC interaction
const result = {
login: {
accountId: account.id,
remember: true,
},
};
// Save the login result
interaction.result = result;
await interaction.save(interaction.exp - Math.floor(Date.now() / 1000));
request.log.info({ accountId: account.id, identity, uid }, 'Schnorr login successful');
// Return success with redirect URL
// The client will follow this redirect
const redirectUrl = `/idp/interaction/${uid}/schnorr-complete?accountId=${encodeURIComponent(account.id)}`;
return reply.type('application/json').send({
success: true,
redirectUrl
});
} catch (err) {
request.log.error(err, 'Schnorr login error');
return reply.code(500).type('application/json').send({
success: false,
error: err.message
});
}
}
/**
* Handle GET /idp/interaction/:uid/schnorr-complete
* Completes OIDC interaction after Schnorr login
*/
export async function handleSchnorrComplete(request, reply, provider) {
const { uid } = request.params;
const { accountId } = request.query;
if (!accountId) {
return reply.code(400).type('text/html').send(errorPage('Missing account', 'Account ID is required.'));
}
try {
const interaction = await provider.Interaction.find(uid);
if (!interaction) {
return reply.code(404).type('text/html').send(errorPage('Session expired', 'Please try logging in again.'));
}
// Validate accountId matches the interaction result
if (interaction.result?.login?.accountId !== accountId) {
request.log.warn({ expected: interaction.result?.login?.accountId, provided: accountId }, 'AccountId mismatch in schnorr complete');
return reply.code(403).type('text/html').send(errorPage('Access denied', 'Account mismatch.'));
}
const account = await findById(accountId);
if (!account) {
return reply.code(404).type('text/html').send(errorPage('Account not found', 'The account could not be found.'));
}
request.log.info({ accountId: account.id, uid }, 'Schnorr login completed');
reply.hijack();
return provider.interactionFinished(request.raw, reply.raw, interaction.result, { mergeWithLastSubmission: false });
} catch (err) {
request.log.error(err, 'Schnorr complete error');
return reply.code(500).type('text/html').send(errorPage('Error', err.message));
}
}