@arkstack/auth 0.12.19 → 0.12.21
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/index.d.ts +1 -0
- package/dist/index.js +9 -7
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -294,6 +294,7 @@ declare class Auth extends AuthContract {
|
|
|
294
294
|
*/
|
|
295
295
|
private verifyJWT;
|
|
296
296
|
private getSecret;
|
|
297
|
+
private setAuthenticated;
|
|
297
298
|
/**
|
|
298
299
|
* Update the last used timestamp and device information of a personal
|
|
299
300
|
* access token to keep the session active and reflect the latest device details.
|
package/dist/index.js
CHANGED
|
@@ -356,8 +356,7 @@ var Auth = class Auth extends AuthContract {
|
|
|
356
356
|
status: 422,
|
|
357
357
|
errors: { password: ["Invalid password"] }
|
|
358
358
|
});
|
|
359
|
-
|
|
360
|
-
this.#user = user;
|
|
359
|
+
this.setAuthenticated(user);
|
|
361
360
|
return user;
|
|
362
361
|
}
|
|
363
362
|
/**
|
|
@@ -406,8 +405,7 @@ var Auth = class Auth extends AuthContract {
|
|
|
406
405
|
req: Auth.req,
|
|
407
406
|
status: 401
|
|
408
407
|
});
|
|
409
|
-
|
|
410
|
-
this.#user = user;
|
|
408
|
+
this.setAuthenticated(user, token);
|
|
411
409
|
return user;
|
|
412
410
|
}
|
|
413
411
|
/**
|
|
@@ -422,6 +420,7 @@ var Auth = class Auth extends AuthContract {
|
|
|
422
420
|
else await token.delete();
|
|
423
421
|
else await (await getModel("PersonalAccessToken")).query().where({ userId: this.#user.id }).delete();
|
|
424
422
|
this.#user = null;
|
|
423
|
+
if (Auth.req?.auth === this) Auth.req.clearAuthentication();
|
|
425
424
|
}
|
|
426
425
|
/**
|
|
427
426
|
* Check if the user is authenticated
|
|
@@ -450,11 +449,11 @@ var Auth = class Auth extends AuthContract {
|
|
|
450
449
|
sub: user.id.toString(),
|
|
451
450
|
email: user.email
|
|
452
451
|
};
|
|
453
|
-
Auth.req?.setUser(user);
|
|
454
452
|
const token = await this.createJWT(payload);
|
|
455
453
|
const deviceInfo = SessionDevice.fromRequest(Auth.req);
|
|
456
454
|
const pat = await this.upsertDeviceToken(user, token, deviceInfo);
|
|
457
455
|
pat.setLoadedRelation("user", user);
|
|
456
|
+
this.setAuthenticated(user, token);
|
|
458
457
|
return pat;
|
|
459
458
|
}
|
|
460
459
|
/**
|
|
@@ -514,11 +513,10 @@ var Auth = class Auth extends AuthContract {
|
|
|
514
513
|
req: Auth.req,
|
|
515
514
|
status: 401
|
|
516
515
|
});
|
|
517
|
-
Auth.req?.setUser(user);
|
|
518
516
|
this.touchSession(pat).catch((error) => {
|
|
519
517
|
if (env("NODE_ENV") === "development") console.error("Failed to update session activity", error);
|
|
520
518
|
});
|
|
521
|
-
this
|
|
519
|
+
this.setAuthenticated(user, token);
|
|
522
520
|
return user;
|
|
523
521
|
}
|
|
524
522
|
/**
|
|
@@ -547,6 +545,10 @@ var Auth = class Auth extends AuthContract {
|
|
|
547
545
|
getSecret() {
|
|
548
546
|
return this.configuredSecret ?? env("JWT_SECRET", "default_secret");
|
|
549
547
|
}
|
|
548
|
+
setAuthenticated(user, token) {
|
|
549
|
+
this.#user = user;
|
|
550
|
+
Auth.req?.setAuthentication(this, user, token);
|
|
551
|
+
}
|
|
550
552
|
/**
|
|
551
553
|
* Update the last used timestamp and device information of a personal
|
|
552
554
|
* access token to keep the session active and reflect the latest device details.
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arkstack/auth",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.21",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Authentication module for Arkstack, providing core authentication and identity features.",
|
|
6
6
|
"homepage": "https://arkstack.toneflix.net/guide/auth",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "git+https://github.com/arkstack-
|
|
9
|
+
"url": "git+https://github.com/arkstack-hq/arkstack.git",
|
|
10
10
|
"directory": "packages/auth"
|
|
11
11
|
},
|
|
12
12
|
"keywords": [
|
|
@@ -38,12 +38,12 @@
|
|
|
38
38
|
"jose": "^6.2.3",
|
|
39
39
|
"otpauth": "^9.5.1",
|
|
40
40
|
"ua-parser-js": "^2.0.9",
|
|
41
|
-
"@arkstack/common": "^0.12.
|
|
42
|
-
"@arkstack/http": "^0.12.
|
|
41
|
+
"@arkstack/common": "^0.12.21",
|
|
42
|
+
"@arkstack/http": "^0.12.21"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"@h3ravel/support": "^0.15.11",
|
|
46
|
-
"@arkstack/database": "^0.12.
|
|
46
|
+
"@arkstack/database": "^0.12.21"
|
|
47
47
|
},
|
|
48
48
|
"scripts": {
|
|
49
49
|
"build": "tsdown --config-loader unrun",
|