@arkstack/auth 0.12.11 → 0.12.12
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 +13 -14
- package/dist/index.js +6 -6
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/// <reference path="./app.d.ts" />
|
|
2
2
|
import { Exception } from "@arkstack/common";
|
|
3
|
-
import { Request, RequestSource, Response, ResponseSource, Session
|
|
4
|
-
import * as _$otpauth from "otpauth";
|
|
3
|
+
import { Request, RequestSource, Response, ResponseSource, Session } from "@arkstack/http";
|
|
5
4
|
import { Model } from "@arkstack/database";
|
|
6
5
|
|
|
7
6
|
//#region src/Contracts/PersonalAccessToken.d.ts
|
|
@@ -17,15 +16,15 @@ declare abstract class PersonalAccessToken extends Model {
|
|
|
17
16
|
deviceInfo: Record<string, unknown> | null;
|
|
18
17
|
}
|
|
19
18
|
//#endregion
|
|
20
|
-
//#region src/
|
|
19
|
+
//#region src/AuthSession.d.ts
|
|
21
20
|
/**
|
|
22
21
|
* Represents an authenticated user session.
|
|
23
22
|
*
|
|
24
23
|
* @author 3m1n3nc3
|
|
25
24
|
*/
|
|
26
|
-
declare class
|
|
25
|
+
declare class AuthSession extends Session {
|
|
27
26
|
private auth;
|
|
28
|
-
constructor(auth: AuthContract, current?: Session
|
|
27
|
+
constructor(auth: AuthContract, current?: Session | undefined);
|
|
29
28
|
/**
|
|
30
29
|
* Destroy the current session
|
|
31
30
|
*
|
|
@@ -140,7 +139,7 @@ declare abstract class AuthContract {
|
|
|
140
139
|
*
|
|
141
140
|
* @returns
|
|
142
141
|
*/
|
|
143
|
-
abstract session():
|
|
142
|
+
abstract session(): AuthSession;
|
|
144
143
|
/**
|
|
145
144
|
* Create a personal access token for a user
|
|
146
145
|
*
|
|
@@ -265,7 +264,7 @@ declare class Auth extends AuthContract {
|
|
|
265
264
|
*
|
|
266
265
|
* @returns
|
|
267
266
|
*/
|
|
268
|
-
session():
|
|
267
|
+
session(): AuthSession;
|
|
269
268
|
/**
|
|
270
269
|
* Create a personal access token for a user
|
|
271
270
|
*
|
|
@@ -475,7 +474,7 @@ declare class TwoFactor {
|
|
|
475
474
|
* @param secret
|
|
476
475
|
* @returns
|
|
477
476
|
*/
|
|
478
|
-
static getTotp(user: User, secret: string):
|
|
477
|
+
static getTotp(user: User, secret: string): any;
|
|
479
478
|
/**
|
|
480
479
|
* Generate a new shared secret for authenticator-based 2FA.
|
|
481
480
|
*
|
|
@@ -507,7 +506,7 @@ declare class TwoFactor {
|
|
|
507
506
|
* @param userId The ID of the user.
|
|
508
507
|
* @returns The stored secret, or null if not found.
|
|
509
508
|
*/
|
|
510
|
-
static getSecret(userId: User['id']): Promise<
|
|
509
|
+
static getSecret(userId: User['id']): Promise<any>;
|
|
511
510
|
/**
|
|
512
511
|
* Store the setup secret for a user.
|
|
513
512
|
*
|
|
@@ -522,7 +521,7 @@ declare class TwoFactor {
|
|
|
522
521
|
* @param userId The ID of the user.
|
|
523
522
|
* @returns The timestamp when 2FA was enabled, or null if not enabled.
|
|
524
523
|
*/
|
|
525
|
-
static getEnabledAt(userId: User['id']): Promise<
|
|
524
|
+
static getEnabledAt(userId: User['id']): Promise<any>;
|
|
526
525
|
/**
|
|
527
526
|
* Persist the timestamp marking 2FA as enabled.
|
|
528
527
|
*
|
|
@@ -548,14 +547,14 @@ declare class TwoFactor {
|
|
|
548
547
|
* @param codes An array of recovery codes to hash.
|
|
549
548
|
* @returns An array of hashed recovery codes.
|
|
550
549
|
*/
|
|
551
|
-
static hashBackupCodes(codes: string[]): Promise<
|
|
550
|
+
static hashBackupCodes(codes: string[]): Promise<any>;
|
|
552
551
|
/**
|
|
553
552
|
* Read stored recovery-code hashes for a user.
|
|
554
553
|
*
|
|
555
554
|
* @param userId The ID of the user.
|
|
556
555
|
* @returns An array of recovery-code hashes.
|
|
557
556
|
*/
|
|
558
|
-
static readRecoveryCodeHashes(userId: User['id']): Promise<
|
|
557
|
+
static readRecoveryCodeHashes(userId: User['id']): Promise<any>;
|
|
559
558
|
/**
|
|
560
559
|
* Persist recovery-code hashes on the user's dedicated 2FA record.
|
|
561
560
|
*
|
|
@@ -595,7 +594,7 @@ declare class TwoFactor {
|
|
|
595
594
|
* @param purpose
|
|
596
595
|
* @returns
|
|
597
596
|
*/
|
|
598
|
-
static verifySmsCode(userId: User['id'], code: string, purpose: SmsCodePurpose): Promise<
|
|
597
|
+
static verifySmsCode(userId: User['id'], code: string, purpose: SmsCodePurpose): Promise<any>;
|
|
599
598
|
}
|
|
600
599
|
//#endregion
|
|
601
600
|
//#region src/Contracts/UserTwoFactor.d.ts
|
|
@@ -631,4 +630,4 @@ declare class AuthenticationException extends Exception {
|
|
|
631
630
|
errors(): Record<string, any> | undefined;
|
|
632
631
|
}
|
|
633
632
|
//#endregion
|
|
634
|
-
export { Auth, AuthContract, AuthenticationException, DeviceAgentPayload, IssuedSmsCode, PersonalAccessToken,
|
|
633
|
+
export { Auth, AuthContract, AuthSession, AuthenticationException, DeviceAgentPayload, IssuedSmsCode, PersonalAccessToken, SessionDevice, SessionDeviceInfo, SmsCodePurpose, TwoFactor, TwoFactorMethod, TwoFactorSetup, TwoFactorStatus, User, UserTwoFactor, auth };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Encryption, Exception, Hash, env, getModel } from "@arkstack/common";
|
|
2
2
|
import { SignJWT, jwtVerify } from "jose";
|
|
3
|
-
import { Request, Response, Session
|
|
3
|
+
import { Request, Response, Session } from "@arkstack/http";
|
|
4
4
|
import { UAParser } from "ua-parser-js";
|
|
5
5
|
import { Secret } from "otpauth";
|
|
6
6
|
import { randomBytes } from "node:crypto";
|
|
@@ -38,16 +38,16 @@ var AuthenticationException = class extends Exception {
|
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
40
|
//#endregion
|
|
41
|
-
//#region src/
|
|
41
|
+
//#region src/AuthSession.ts
|
|
42
42
|
/**
|
|
43
43
|
* Represents an authenticated user session.
|
|
44
44
|
*
|
|
45
45
|
* @author 3m1n3nc3
|
|
46
46
|
*/
|
|
47
|
-
var
|
|
47
|
+
var AuthSession = class extends Session {
|
|
48
48
|
auth;
|
|
49
49
|
constructor(auth, current = globalThis.session?.()) {
|
|
50
|
-
super(current instanceof Session
|
|
50
|
+
super(current instanceof Session ? current : void 0);
|
|
51
51
|
this.auth = auth;
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
@@ -437,7 +437,7 @@ var Auth = class Auth extends AuthContract {
|
|
|
437
437
|
* @returns
|
|
438
438
|
*/
|
|
439
439
|
session() {
|
|
440
|
-
return new
|
|
440
|
+
return new AuthSession(this);
|
|
441
441
|
}
|
|
442
442
|
/**
|
|
443
443
|
* Create a personal access token for a user
|
|
@@ -854,4 +854,4 @@ var UserTwoFactor = class extends Model {
|
|
|
854
854
|
casts = { recoveryCodeHashes: "json" };
|
|
855
855
|
};
|
|
856
856
|
//#endregion
|
|
857
|
-
export { Auth, AuthContract, AuthenticationException, PersonalAccessToken,
|
|
857
|
+
export { Auth, AuthContract, AuthSession, AuthenticationException, PersonalAccessToken, SessionDevice, TwoFactor, User, UserTwoFactor, auth };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arkstack/auth",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.12",
|
|
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",
|
|
@@ -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.12",
|
|
42
|
+
"@arkstack/http": "^0.12.12"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"@h3ravel/support": "^0.15.11",
|
|
46
|
-
"@arkstack/database": "^0.12.
|
|
46
|
+
"@arkstack/database": "^0.12.12"
|
|
47
47
|
},
|
|
48
48
|
"scripts": {
|
|
49
49
|
"build": "tsdown --config-loader unrun",
|