@riao/iam 1.0.0 → 2.0.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.
- package/auth/auth-migrations.d.ts +4 -0
- package/auth/auth-migrations.js +12 -0
- package/auth/auth-migrations.js.map +1 -0
- package/auth/auth.d.ts +11 -0
- package/auth/auth.js +18 -0
- package/auth/auth.js.map +1 -0
- package/auth/index.d.ts +1 -0
- package/auth/index.js +6 -0
- package/auth/index.js.map +1 -0
- package/auth/migrations/001-create-accounts-table.d.ts +5 -0
- package/auth/migrations/001-create-accounts-table.js +27 -0
- package/auth/migrations/001-create-accounts-table.js.map +1 -0
- package/authentication/authentication-base/authentication-base.d.ts +10 -0
- package/authentication/authentication-base/authentication-base.js +33 -0
- package/authentication/authentication-base/authentication-base.js.map +1 -0
- package/authentication/authentication-base/index.d.ts +1 -0
- package/authentication/authentication-base/index.js +6 -0
- package/authentication/authentication-base/index.js.map +1 -0
- package/authentication/authentication-fido2/authentication-fido2-migrations.d.ts +5 -0
- package/authentication/authentication-fido2/authentication-fido2-migrations.js +17 -0
- package/authentication/authentication-fido2/authentication-fido2-migrations.js.map +1 -0
- package/authentication/authentication-fido2/authentication-fido2.d.ts +58 -0
- package/authentication/authentication-fido2/authentication-fido2.js +260 -0
- package/authentication/authentication-fido2/authentication-fido2.js.map +1 -0
- package/authentication/authentication-fido2/index.d.ts +1 -0
- package/authentication/authentication-fido2/index.js +6 -0
- package/authentication/authentication-fido2/index.js.map +1 -0
- package/authentication/authentication-fido2/migrations/create-fido-challenges-table.d.ts +5 -0
- package/authentication/authentication-fido2/migrations/create-fido-challenges-table.js +61 -0
- package/authentication/authentication-fido2/migrations/create-fido-challenges-table.js.map +1 -0
- package/authentication/authentication-fido2/migrations/create-fido-credentials-table.d.ts +5 -0
- package/authentication/authentication-fido2/migrations/create-fido-credentials-table.js +68 -0
- package/authentication/authentication-fido2/migrations/create-fido-credentials-table.js.map +1 -0
- package/authentication/authentication-fido2/migrations/index.d.ts +2 -0
- package/authentication/authentication-fido2/migrations/index.js +6 -0
- package/authentication/authentication-fido2/migrations/index.js.map +1 -0
- package/authentication/authentication-magic-token/authentication-magic-token-migrations.d.ts +5 -0
- package/authentication/authentication-magic-token/authentication-magic-token-migrations.js +16 -0
- package/authentication/authentication-magic-token/authentication-magic-token-migrations.js.map +1 -0
- package/authentication/authentication-magic-token/authentication-magic-token.d.ts +25 -0
- package/authentication/authentication-magic-token/authentication-magic-token.js +76 -0
- package/authentication/authentication-magic-token/authentication-magic-token.js.map +1 -0
- package/authentication/authentication-magic-token/index.d.ts +1 -0
- package/authentication/authentication-magic-token/index.js +6 -0
- package/authentication/authentication-magic-token/index.js.map +1 -0
- package/authentication/authentication-magic-token/magic-token.d.ts +17 -0
- package/authentication/authentication-magic-token/magic-token.js +7 -0
- package/authentication/authentication-magic-token/magic-token.js.map +1 -0
- package/authentication/authentication-magic-token/migrations/001-create-magic-token-table.d.ts +5 -0
- package/authentication/authentication-magic-token/migrations/001-create-magic-token-table.js +44 -0
- package/authentication/authentication-magic-token/migrations/001-create-magic-token-table.js.map +1 -0
- package/authentication/authentication-password/authentication-password-migrations.d.ts +5 -0
- package/authentication/authentication-password/authentication-password-migrations.js +16 -0
- package/authentication/authentication-password/authentication-password-migrations.js.map +1 -0
- package/authentication/authentication-password/authentication-password.d.ts +8 -0
- package/authentication/authentication-password/authentication-password.js +28 -0
- package/authentication/authentication-password/authentication-password.js.map +1 -0
- package/authentication/authentication-password/index.d.ts +1 -0
- package/authentication/authentication-password/index.js +6 -0
- package/authentication/authentication-password/index.js.map +1 -0
- package/authentication/authentication-password/migrations/001-add-password-column.d.ts +5 -0
- package/authentication/authentication-password/migrations/001-add-password-column.js +21 -0
- package/authentication/authentication-password/migrations/001-add-password-column.js.map +1 -0
- package/encrypt.d.ts +6 -0
- package/encrypt.js +18 -0
- package/encrypt.js.map +1 -0
- package/hash.d.ts +5 -0
- package/hash.js +15 -0
- package/hash.js.map +1 -0
- package/index.d.ts +1 -2
- package/index.js +4 -18
- package/index.js.map +1 -1
- package/jwt.d.ts +26 -28
- package/jwt.js +54 -83
- package/jwt.js.map +1 -1
- package/keypair.d.ts +24 -24
- package/keypair.js +72 -70
- package/keypair.js.map +1 -1
- package/package.json +31 -10
- package/secret.d.ts +5 -5
- package/secret.js +2 -2
- package/auth.d.ts +0 -11
- package/auth.js +0 -16
- package/auth.js.map +0 -1
- package/authentication-base.d.ts +0 -12
- package/authentication-base.js +0 -48
- package/authentication-base.js.map +0 -1
- package/authentication-password.d.ts +0 -11
- package/authentication-password.js +0 -43
- package/authentication-password.js.map +0 -1
- package/authentication-passwordless.d.ts +0 -24
- package/authentication-passwordless.js +0 -55
- package/authentication-passwordless.js.map +0 -1
- package/authorization-abac.d.ts +0 -8
- package/authorization-abac.js +0 -33
- package/authorization-abac.js.map +0 -1
- package/authorization-base.d.ts +0 -17
- package/authorization-base.js +0 -30
- package/authorization-base.js.map +0 -1
- package/authorization-hmm.d.ts +0 -0
- package/authorization-hmm.js +0 -173
- package/authorization-hmm.js.map +0 -1
- package/authorization-rbac.d.ts +0 -14
- package/authorization-rbac.js +0 -61
- package/authorization-rbac.js.map +0 -1
- package/errors/authentication-error.d.ts +0 -3
- package/errors/authentication-error.js +0 -8
- package/errors/authentication-error.js.map +0 -1
- package/errors/authorization-error.d.ts +0 -3
- package/errors/authorization-error.js +0 -8
- package/errors/authorization-error.js.map +0 -1
- package/errors/error.d.ts +0 -2
- package/errors/error.js +0 -7
- package/errors/error.js.map +0 -1
- package/iam.d.ts +0 -40
- package/iam.js +0 -73
- package/iam.js.map +0 -1
- package/migrations/1725221752756-create-users-table.d.ts +0 -7
- package/migrations/1725221752756-create-users-table.js +0 -36
- package/migrations/1725221752756-create-users-table.js.map +0 -1
- package/migrations/1725221859886-create-roles-table.d.ts +0 -7
- package/migrations/1725221859886-create-roles-table.js +0 -36
- package/migrations/1725221859886-create-roles-table.js.map +0 -1
- package/migrations/1725221896876-create-permissions-table.d.ts +0 -7
- package/migrations/1725221896876-create-permissions-table.js +0 -41
- package/migrations/1725221896876-create-permissions-table.js.map +0 -1
- package/migrations/1725221935064-create-role-permissions-table.d.ts +0 -7
- package/migrations/1725221935064-create-role-permissions-table.js +0 -56
- package/migrations/1725221935064-create-role-permissions-table.js.map +0 -1
- package/migrations/1725221951873-create-user-roles-table.d.ts +0 -7
- package/migrations/1725221951873-create-user-roles-table.js +0 -56
- package/migrations/1725221951873-create-user-roles-table.js.map +0 -1
- package/migrations/index.d.ts +0 -5
- package/migrations/index.js +0 -22
- package/migrations/index.js.map +0 -1
- package/token.d.ts +0 -13
- package/token.js +0 -3
- package/token.js.map +0 -1
package/jwt.js
CHANGED
|
@@ -1,84 +1,55 @@
|
|
|
1
|
-
"use strict";
|
|
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
|
-
const result = yield jwt.verify(token, this.publicKey);
|
|
56
|
-
delete result.iat;
|
|
57
|
-
delete result.nbf;
|
|
58
|
-
delete result.exp;
|
|
59
|
-
return result;
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
verifyAccessToken(token) {
|
|
63
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
64
|
-
const data = yield this.decodeToken(token);
|
|
65
|
-
if (data.type !== 'access') {
|
|
66
|
-
throw new error_1.IamError('Expected access token, received ' + data.type);
|
|
67
|
-
}
|
|
68
|
-
delete data.type;
|
|
69
|
-
return data;
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
verifyRefreshToken(token) {
|
|
73
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
-
const data = yield this.decodeToken(token);
|
|
75
|
-
if (data.type !== 'refresh') {
|
|
76
|
-
throw new error_1.IamError('Expected refresh token, received ' + data.type);
|
|
77
|
-
}
|
|
78
|
-
delete data.type;
|
|
79
|
-
return data;
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
exports.Jwt = Jwt;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Jwt = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const jwt = tslib_1.__importStar(require("jsonwebtoken"));
|
|
6
|
+
const crypto_1 = require("crypto");
|
|
7
|
+
class Jwt {
|
|
8
|
+
publicKey;
|
|
9
|
+
privateKey;
|
|
10
|
+
expiresIn;
|
|
11
|
+
notBefore;
|
|
12
|
+
algorithm;
|
|
13
|
+
constructor(options) {
|
|
14
|
+
this.expiresIn = options.expiresIn ?? this.expiresIn;
|
|
15
|
+
this.notBefore = options.notBefore ?? this.notBefore;
|
|
16
|
+
this.algorithm = options.algorithm ?? this.algorithm;
|
|
17
|
+
if ('secret' in options && options.secret) {
|
|
18
|
+
this.privateKey = this.publicKey = (0, crypto_1.createSecretKey)(Buffer.from(options.secret));
|
|
19
|
+
}
|
|
20
|
+
else if ('privateKey' in options && options.privateKey) {
|
|
21
|
+
this.publicKey =
|
|
22
|
+
typeof options.publicKey === 'string'
|
|
23
|
+
? (0, crypto_1.createPublicKey)(options.publicKey)
|
|
24
|
+
: options.publicKey;
|
|
25
|
+
this.privateKey =
|
|
26
|
+
typeof options.privateKey === 'string'
|
|
27
|
+
? (0, crypto_1.createPrivateKey)(options.privateKey)
|
|
28
|
+
: options.privateKey;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
tokenOptions() {
|
|
32
|
+
return {
|
|
33
|
+
expiresIn: this.expiresIn ?? '15m',
|
|
34
|
+
notBefore: this.notBefore ?? 1,
|
|
35
|
+
algorithm: this.algorithm,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
async generateToken(data, options = {}) {
|
|
39
|
+
options = {
|
|
40
|
+
...this.tokenOptions(),
|
|
41
|
+
...options,
|
|
42
|
+
};
|
|
43
|
+
const token = await jwt.sign(data, this.privateKey, options);
|
|
44
|
+
return { token };
|
|
45
|
+
}
|
|
46
|
+
async decodeToken(token) {
|
|
47
|
+
const result = await jwt.verify(token, this.publicKey);
|
|
48
|
+
delete result['iat'];
|
|
49
|
+
delete result['nbf'];
|
|
50
|
+
delete result['exp'];
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.Jwt = Jwt;
|
|
84
55
|
//# sourceMappingURL=jwt.js.map
|
package/jwt.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jwt.js","sourceRoot":"","sources":["../../src/jwt.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"jwt.js","sourceRoot":"","sources":["../../src/jwt.ts"],"names":[],"mappings":";;;;AAAA,0DAAoC;AAKpC,mCAKgB;AAehB,MAAa,GAAG;IACL,SAAS,CAAY;IACrB,UAAU,CAAY;IAEtB,SAAS,CAAkB;IAC3B,SAAS,CAAkB;IAC3B,SAAS,CAAsC;IAEzD,YAAmB,OAAmB;QACrC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,IAAI,CAAC,SAAS,CAAC;QACrD,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,IAAI,CAAC,SAAS,CAAC;QACrD,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,IAAI,CAAC,SAAS,CAAC;QAErD,IAAI,QAAQ,IAAI,OAAO,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;YAC3C,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,SAAS,GAAG,IAAA,wBAAe,EACjD,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAC3B,CAAC;QACH,CAAC;aACI,IAAI,YAAY,IAAI,OAAO,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;YACxD,IAAI,CAAC,SAAS;gBACb,OAAO,OAAO,CAAC,SAAS,KAAK,QAAQ;oBACpC,CAAC,CAAC,IAAA,wBAAe,EAAC,OAAO,CAAC,SAAS,CAAC;oBACpC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC;YAEtB,IAAI,CAAC,UAAU;gBACd,OAAO,OAAO,CAAC,UAAU,KAAK,QAAQ;oBACrC,CAAC,CAAC,IAAA,yBAAgB,EAAC,OAAO,CAAC,UAAU,CAAC;oBACtC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC;QACxB,CAAC;IACF,CAAC;IAES,YAAY;QACrB,OAAO;YACN,SAAS,EAAE,IAAI,CAAC,SAAS,IAAI,KAAK;YAClC,SAAS,EAAE,IAAI,CAAC,SAAS,IAAI,CAAC;YAC9B,SAAS,EAAE,IAAI,CAAC,SAAS;SACzB,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,aAAa,CACzB,IAAc,EACd,UAA2B,EAAE;QAE7B,OAAO,GAAG;YACT,GAAG,IAAI,CAAC,YAAY,EAAE;YACtB,GAAG,OAAO;SACV,CAAC;QAEF,MAAM,KAAK,GAAG,MAAM,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QAE7D,OAAO,EAAE,KAAK,EAAE,CAAC;IAClB,CAAC;IAEM,KAAK,CAAC,WAAW,CAAC,KAAa;QACrC,MAAM,MAAM,GAAa,MAAM,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;QAEjE,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;QACrB,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;QACrB,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;QAErB,OAAO,MAAM,CAAC;IACf,CAAC;CACD;AA9DD,kBA8DC"}
|
package/keypair.d.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import * as crypto from 'crypto';
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export declare class KeyPairGenerator {
|
|
10
|
-
algorithm: KeyPairAlgorithm;
|
|
11
|
-
constructor(options: {
|
|
12
|
-
algorithm: KeyPairAlgorithm;
|
|
13
|
-
});
|
|
14
|
-
generate(): KeyPair;
|
|
15
|
-
load(options: {
|
|
16
|
-
publicKeyPath: string;
|
|
17
|
-
privateKeyPath: string;
|
|
18
|
-
}): KeyPair;
|
|
19
|
-
save(options: {
|
|
20
|
-
keys: KeyPair;
|
|
21
|
-
publicKeyPath: string;
|
|
22
|
-
privateKeyPath: string;
|
|
23
|
-
}): void;
|
|
24
|
-
}
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import * as crypto from 'crypto';
|
|
3
|
+
export type KeyPairAlgorithm = 'RS256' | 'RS384' | 'RS512' | 'ES256' | 'ES384' | 'ES512';
|
|
4
|
+
export interface KeyPair {
|
|
5
|
+
publicKey: string | crypto.KeyObject;
|
|
6
|
+
privateKey: string | crypto.KeyObject;
|
|
7
|
+
algorithm: KeyPairAlgorithm;
|
|
8
|
+
}
|
|
9
|
+
export declare class KeyPairGenerator {
|
|
10
|
+
algorithm: KeyPairAlgorithm;
|
|
11
|
+
constructor(options: {
|
|
12
|
+
algorithm: KeyPairAlgorithm;
|
|
13
|
+
});
|
|
14
|
+
generate(): KeyPair;
|
|
15
|
+
load(options: {
|
|
16
|
+
publicKeyPath: string;
|
|
17
|
+
privateKeyPath: string;
|
|
18
|
+
}): KeyPair;
|
|
19
|
+
save(options: {
|
|
20
|
+
keys: KeyPair;
|
|
21
|
+
publicKeyPath: string;
|
|
22
|
+
privateKeyPath: string;
|
|
23
|
+
}): void;
|
|
24
|
+
}
|
package/keypair.js
CHANGED
|
@@ -1,71 +1,73 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.KeyPairGenerator = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
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
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.KeyPairGenerator = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const crypto = tslib_1.__importStar(require("crypto"));
|
|
6
|
+
const fs_1 = require("fs");
|
|
7
|
+
class KeyPairGenerator {
|
|
8
|
+
algorithm;
|
|
9
|
+
constructor(options) {
|
|
10
|
+
this.algorithm = options.algorithm;
|
|
11
|
+
}
|
|
12
|
+
generate() {
|
|
13
|
+
let type = null;
|
|
14
|
+
let modulusLength, namedCurve;
|
|
15
|
+
if (this.algorithm.startsWith('RS')) {
|
|
16
|
+
type = 'rsa';
|
|
17
|
+
modulusLength = 2048;
|
|
18
|
+
}
|
|
19
|
+
else if (this.algorithm === 'ES256') {
|
|
20
|
+
type = 'ec';
|
|
21
|
+
namedCurve = 'prime256v1';
|
|
22
|
+
}
|
|
23
|
+
else if (this.algorithm === 'ES384') {
|
|
24
|
+
type = 'ec';
|
|
25
|
+
namedCurve = 'secp384r1';
|
|
26
|
+
}
|
|
27
|
+
else if (this.algorithm === 'ES512') {
|
|
28
|
+
type = 'ec';
|
|
29
|
+
namedCurve = 'secp521r1';
|
|
30
|
+
}
|
|
31
|
+
if (type === null) {
|
|
32
|
+
throw new Error('Keypair type could not be inferred');
|
|
33
|
+
}
|
|
34
|
+
const { publicKey, privateKey } = crypto.generateKeyPairSync(type, {
|
|
35
|
+
modulusLength,
|
|
36
|
+
namedCurve,
|
|
37
|
+
publicKeyEncoding: {
|
|
38
|
+
type: 'spki',
|
|
39
|
+
format: 'pem',
|
|
40
|
+
},
|
|
41
|
+
privateKeyEncoding: {
|
|
42
|
+
type: 'pkcs8',
|
|
43
|
+
format: 'pem',
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
return {
|
|
47
|
+
algorithm: this.algorithm,
|
|
48
|
+
publicKey,
|
|
49
|
+
privateKey,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
load(options) {
|
|
53
|
+
const publicKey = (0, fs_1.readFileSync)(options.publicKeyPath).toString();
|
|
54
|
+
const privateKey = (0, fs_1.readFileSync)(options.privateKeyPath).toString();
|
|
55
|
+
return {
|
|
56
|
+
algorithm: this.algorithm,
|
|
57
|
+
publicKey: crypto.createPublicKey(publicKey),
|
|
58
|
+
privateKey: crypto.createPrivateKey(privateKey),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
save(options) {
|
|
62
|
+
const publicKey = options.keys.publicKey instanceof crypto.KeyObject
|
|
63
|
+
? options.keys.publicKey.export().toString()
|
|
64
|
+
: options.keys.publicKey;
|
|
65
|
+
const privateKey = options.keys.privateKey instanceof crypto.KeyObject
|
|
66
|
+
? options.keys.privateKey.export().toString()
|
|
67
|
+
: options.keys.privateKey;
|
|
68
|
+
(0, fs_1.writeFileSync)(options.publicKeyPath, publicKey);
|
|
69
|
+
(0, fs_1.writeFileSync)(options.privateKeyPath, privateKey);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
exports.KeyPairGenerator = KeyPairGenerator;
|
|
71
73
|
//# sourceMappingURL=keypair.js.map
|
package/keypair.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keypair.js","sourceRoot":"","sources":["../../src/keypair.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"keypair.js","sourceRoot":"","sources":["../../src/keypair.ts"],"names":[],"mappings":";;;;AAAA,uDAAiC;AACjC,2BAAiD;AAgBjD,MAAa,gBAAgB;IACrB,SAAS,CAAmB;IAEnC,YAAmB,OAAwC;QAC1D,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;IACpC,CAAC;IAEM,QAAQ;QACd,IAAI,IAAI,GAAwB,IAAI,CAAC;QACrC,IAAI,aAAa,EAAE,UAAU,CAAC;QAE9B,IAAI,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YACrC,IAAI,GAAG,KAAK,CAAC;YACb,aAAa,GAAG,IAAI,CAAC;QACtB,CAAC;aACI,IAAI,IAAI,CAAC,SAAS,KAAK,OAAO,EAAE,CAAC;YACrC,IAAI,GAAG,IAAI,CAAC;YACZ,UAAU,GAAG,YAAY,CAAC;QAC3B,CAAC;aACI,IAAI,IAAI,CAAC,SAAS,KAAK,OAAO,EAAE,CAAC;YACrC,IAAI,GAAG,IAAI,CAAC;YACZ,UAAU,GAAG,WAAW,CAAC;QAC1B,CAAC;aACI,IAAI,IAAI,CAAC,SAAS,KAAK,OAAO,EAAE,CAAC;YACrC,IAAI,GAAG,IAAI,CAAC;YACZ,UAAU,GAAG,WAAW,CAAC;QAC1B,CAAC;QAED,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;QACvD,CAAC;QAED,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC,mBAAmB,CACtD,IAAI,EACT;YACC,aAAa;YACb,UAAU;YACV,iBAAiB,EAAE;gBAClB,IAAI,EAAE,MAAM;gBACZ,MAAM,EAAE,KAAK;aACb;YACD,kBAAkB,EAAE;gBACnB,IAAI,EAAE,OAAO;gBACb,MAAM,EAAE,KAAK;aACb;SACD,CACD,CAAC;QAEF,OAAO;YACN,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,SAAS;YACT,UAAU;SACV,CAAC;IACH,CAAC;IAEM,IAAI,CAAC,OAGX;QACA,MAAM,SAAS,GAAG,IAAA,iBAAY,EAAC,OAAO,CAAC,aAAa,CAAC,CAAC,QAAQ,EAAE,CAAC;QACjE,MAAM,UAAU,GAAG,IAAA,iBAAY,EAAC,OAAO,CAAC,cAAc,CAAC,CAAC,QAAQ,EAAE,CAAC;QAEnE,OAAO;YACN,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,SAAS,EAAE,MAAM,CAAC,eAAe,CAAC,SAAS,CAAC;YAC5C,UAAU,EAAE,MAAM,CAAC,gBAAgB,CAAC,UAAU,CAAC;SAC/C,CAAC;IACH,CAAC;IAEM,IAAI,CAAC,OAIX;QACA,MAAM,SAAS,GACd,OAAO,CAAC,IAAI,CAAC,SAAS,YAAY,MAAM,CAAC,SAAS;YACjD,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;YAC5C,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC;QAE3B,MAAM,UAAU,GACf,OAAO,CAAC,IAAI,CAAC,UAAU,YAAY,MAAM,CAAC,SAAS;YAClD,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;YAC7C,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC;QAE5B,IAAA,kBAAa,EAAC,OAAO,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;QAChD,IAAA,kBAAa,EAAC,OAAO,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC;IACnD,CAAC;CACD;AAvFD,4CAuFC"}
|
package/package.json
CHANGED
|
@@ -1,29 +1,50 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riao/iam",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "riao-iam",
|
|
5
5
|
"typescript-template": {
|
|
6
|
-
"base": "1.0.
|
|
6
|
+
"base": "1.0.1",
|
|
7
7
|
"jasmine": "1.0.0",
|
|
8
8
|
"library": "1.0.0"
|
|
9
9
|
},
|
|
10
10
|
"scripts": {},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@riao/dbal": "^3.
|
|
13
|
-
"
|
|
14
|
-
"
|
|
12
|
+
"@riao/dbal": "^3.7.1",
|
|
13
|
+
"@riao/postgres": "^3.5.0",
|
|
14
|
+
"@simplewebauthn/server": "^13.2.2",
|
|
15
|
+
"bcrypt": "^6.0.0",
|
|
16
|
+
"jsonwebtoken": "^9.0.2",
|
|
17
|
+
"ms": "^2.1.3"
|
|
15
18
|
},
|
|
16
19
|
"repository": {
|
|
17
20
|
"type": "git",
|
|
18
|
-
"url": "git+https://github.com/riao-
|
|
21
|
+
"url": "git+https://github.com/riao-project/riao-iam.git"
|
|
19
22
|
},
|
|
20
|
-
"author": "riao-
|
|
23
|
+
"author": "riao-project",
|
|
21
24
|
"license": "MIT",
|
|
22
25
|
"bugs": {
|
|
23
|
-
"url": "https://github.com/riao-
|
|
26
|
+
"url": "https://github.com/riao-project/riao-iam/issues"
|
|
24
27
|
},
|
|
25
|
-
"homepage": "https://github.com/riao-
|
|
26
|
-
"keywords": [
|
|
28
|
+
"homepage": "https://github.com/riao-project/riao-iam#readme",
|
|
29
|
+
"keywords": [
|
|
30
|
+
"iam",
|
|
31
|
+
"authentication",
|
|
32
|
+
"authorization",
|
|
33
|
+
"riao",
|
|
34
|
+
"riao-project",
|
|
35
|
+
"typescript",
|
|
36
|
+
"password",
|
|
37
|
+
"magic-link",
|
|
38
|
+
"webauthn",
|
|
39
|
+
"oauth2",
|
|
40
|
+
"fido2",
|
|
41
|
+
"jwt",
|
|
42
|
+
"openid-connect",
|
|
43
|
+
"acl",
|
|
44
|
+
"rbac",
|
|
45
|
+
"abac",
|
|
46
|
+
"rebac"
|
|
47
|
+
],
|
|
27
48
|
"main": "index.js",
|
|
28
49
|
"types": "index.d.ts"
|
|
29
50
|
}
|
package/secret.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export type SecretAlgorithm = 'HS256' | 'HS384' | 'HS512';
|
|
2
|
-
export interface Secret {
|
|
3
|
-
secret: string;
|
|
4
|
-
algorithm: SecretAlgorithm;
|
|
5
|
-
}
|
|
1
|
+
export type SecretAlgorithm = 'HS256' | 'HS384' | 'HS512';
|
|
2
|
+
export interface Secret {
|
|
3
|
+
secret: string;
|
|
4
|
+
algorithm: SecretAlgorithm;
|
|
5
|
+
}
|
package/secret.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
//# sourceMappingURL=secret.js.map
|
package/auth.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Database, DatabaseRecord, QueryRepository } from '@riao/dbal';
|
|
2
|
-
export interface AuthOptions {
|
|
3
|
-
db: Database;
|
|
4
|
-
userTable?: string;
|
|
5
|
-
}
|
|
6
|
-
export declare abstract class AuthBase<TUser extends DatabaseRecord = DatabaseRecord> {
|
|
7
|
-
protected db: Database;
|
|
8
|
-
protected userRepo: QueryRepository<TUser>;
|
|
9
|
-
protected userTable: string;
|
|
10
|
-
constructor(options: AuthOptions);
|
|
11
|
-
}
|
package/auth.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AuthBase = void 0;
|
|
4
|
-
class AuthBase {
|
|
5
|
-
constructor(options) {
|
|
6
|
-
var _a, _b;
|
|
7
|
-
this.userTable = 'users';
|
|
8
|
-
this.db = (_a = options.db) !== null && _a !== void 0 ? _a : this.db;
|
|
9
|
-
this.userTable = (_b = options.userTable) !== null && _b !== void 0 ? _b : this.userTable;
|
|
10
|
-
this.userRepo = this.db.getQueryRepository({
|
|
11
|
-
table: this.userTable,
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
exports.AuthBase = AuthBase;
|
|
16
|
-
//# sourceMappingURL=auth.js.map
|
package/auth.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/auth.ts"],"names":[],"mappings":";;;AAOA,MAAsB,QAAQ;IAK7B,YAAmB,OAAoB;;QAF7B,cAAS,GAAG,OAAO,CAAC;QAG7B,IAAI,CAAC,EAAE,GAAG,MAAA,OAAO,CAAC,EAAE,mCAAI,IAAI,CAAC,EAAE,CAAC;QAChC,IAAI,CAAC,SAAS,GAAG,MAAA,OAAO,CAAC,SAAS,mCAAI,IAAI,CAAC,SAAS,CAAC;QAErD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,EAAE,CAAC,kBAAkB,CAAC;YAC1C,KAAK,EAAE,IAAI,CAAC,SAAS;SACrB,CAAC,CAAC;IACJ,CAAC;CACD;AAbD,4BAaC"}
|
package/authentication-base.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { DatabaseRecord, Expression, SelectQuery } from '@riao/dbal';
|
|
2
|
-
import { AuthBase, AuthOptions } from './auth';
|
|
3
|
-
export interface AuthenticationOptions extends AuthOptions {
|
|
4
|
-
loginColumn: string;
|
|
5
|
-
}
|
|
6
|
-
export declare abstract class AuthenticationBase<TUser extends DatabaseRecord = DatabaseRecord> extends AuthBase<TUser> {
|
|
7
|
-
protected loginColumn: string;
|
|
8
|
-
constructor(options: AuthenticationOptions);
|
|
9
|
-
findActiveUser(query: SelectQuery<TUser>): Promise<TUser>;
|
|
10
|
-
login(credentials: any): Promise<TUser>;
|
|
11
|
-
protected userIsActive(): Expression<TUser>;
|
|
12
|
-
}
|
package/authentication-base.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.AuthenticationBase = void 0;
|
|
13
|
-
const dbal_1 = require("@riao/dbal");
|
|
14
|
-
const authentication_error_1 = require("./errors/authentication-error");
|
|
15
|
-
const auth_1 = require("./auth");
|
|
16
|
-
class AuthenticationBase extends auth_1.AuthBase {
|
|
17
|
-
constructor(options) {
|
|
18
|
-
var _a;
|
|
19
|
-
super(options);
|
|
20
|
-
this.loginColumn = (_a = options.loginColumn) !== null && _a !== void 0 ? _a : this.loginColumn;
|
|
21
|
-
}
|
|
22
|
-
findActiveUser(query) {
|
|
23
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
-
const userWhere = this.userIsActive();
|
|
25
|
-
if (query.where && userWhere !== undefined) {
|
|
26
|
-
query.where = [userWhere, dbal_1.and, query.where];
|
|
27
|
-
}
|
|
28
|
-
else if (userWhere !== undefined) {
|
|
29
|
-
query.where = userWhere;
|
|
30
|
-
}
|
|
31
|
-
const user = yield this.userRepo.findOne(Object.assign({ columns: ['id'] }, query));
|
|
32
|
-
if (!user) {
|
|
33
|
-
throw new authentication_error_1.AuthenticationError('Could not find active user');
|
|
34
|
-
}
|
|
35
|
-
return user;
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
login(credentials) {
|
|
39
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
-
throw new Error('No login implementation');
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
userIsActive() {
|
|
44
|
-
return undefined;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
exports.AuthenticationBase = AuthenticationBase;
|
|
48
|
-
//# sourceMappingURL=authentication-base.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"authentication-base.js","sourceRoot":"","sources":["../../src/authentication-base.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAOoB;AACpB,wEAAoE;AACpE,iCAA+C;AAM/C,MAAsB,kBAEpB,SAAQ,eAAe;IAGxB,YAAmB,OAA8B;;QAChD,KAAK,CAAC,OAAO,CAAC,CAAC;QAEf,IAAI,CAAC,WAAW,GAAG,MAAA,OAAO,CAAC,WAAW,mCAAI,IAAI,CAAC,WAAW,CAAC;IAC5D,CAAC;IAEY,cAAc,CAAC,KAAyB;;YACpD,MAAM,SAAS,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;YAEtC,IAAI,KAAK,CAAC,KAAK,IAAI,SAAS,KAAK,SAAS,EAAE;gBAC3C,KAAK,CAAC,KAAK,GAAG,CAAC,SAAS,EAAE,UAAG,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;aAC5C;iBACI,IAAI,SAAS,KAAK,SAAS,EAAE;gBACjC,KAAK,CAAC,KAAK,GAAG,SAAS,CAAC;aACxB;YAED,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,OAAO,iBACvC,OAAO,EAAE,CAAC,IAAI,CAAC,IACZ,KAAK,EACP,CAAC;YAEH,IAAI,CAAC,IAAI,EAAE;gBACV,MAAM,IAAI,0CAAmB,CAAC,4BAA4B,CAAC,CAAC;aAC5D;YAED,OAAO,IAAI,CAAC;QACb,CAAC;KAAA;IAEY,KAAK,CAAC,WAAW;;YAC7B,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;QAC5C,CAAC;KAAA;IAES,YAAY;QACrB,OAAO,SAAS,CAAC;IAClB,CAAC;CACD;AAxCD,gDAwCC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { DatabaseRecord } from '@riao/dbal';
|
|
2
|
-
import { AuthenticationBase } from './authentication-base';
|
|
3
|
-
export interface PasswordLogin {
|
|
4
|
-
login: string;
|
|
5
|
-
password: string;
|
|
6
|
-
}
|
|
7
|
-
export declare class AuthenticationPassword<TUser extends DatabaseRecord = DatabaseRecord> extends AuthenticationBase<TUser> {
|
|
8
|
-
login(credentials: PasswordLogin): Promise<TUser>;
|
|
9
|
-
hashPassword(password: string): Promise<string>;
|
|
10
|
-
verifyPassword(hash: string, password: string): Promise<boolean>;
|
|
11
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.AuthenticationPassword = void 0;
|
|
13
|
-
const authentication_base_1 = require("./authentication-base");
|
|
14
|
-
const argon2 = require("argon2");
|
|
15
|
-
const authentication_error_1 = require("./errors/authentication-error");
|
|
16
|
-
class AuthenticationPassword extends authentication_base_1.AuthenticationBase {
|
|
17
|
-
login(credentials) {
|
|
18
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
-
const user = yield this.findActiveUser({
|
|
20
|
-
columns: ['id', 'password'],
|
|
21
|
-
where: { [this.loginColumn]: credentials.login },
|
|
22
|
-
});
|
|
23
|
-
if (yield this.verifyPassword(user.password, credentials.password)) {
|
|
24
|
-
return user;
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
throw new authentication_error_1.AuthenticationError('Wrong password');
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
hashPassword(password) {
|
|
32
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
-
return yield argon2.hash(password);
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
verifyPassword(hash, password) {
|
|
37
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
-
return yield argon2.verify(hash, password);
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
exports.AuthenticationPassword = AuthenticationPassword;
|
|
43
|
-
//# sourceMappingURL=authentication-password.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"authentication-password.js","sourceRoot":"","sources":["../../src/authentication-password.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,+DAA2D;AAE3D,iCAAiC;AACjC,wEAAoE;AAOpE,MAAa,sBAEX,SAAQ,wCAAyB;IACrB,KAAK,CAAC,WAA0B;;YAC5C,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC;gBACtC,OAAO,EAAE,CAAC,IAAI,EAAE,UAAU,CAAC;gBAC3B,KAAK,EAAO,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,WAAW,CAAC,KAAK,EAAE;aACrD,CAAC,CAAC;YAEH,IAAI,MAAM,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,EAAE,WAAW,CAAC,QAAQ,CAAC,EAAE;gBACnE,OAAO,IAAI,CAAC;aACZ;iBACI;gBACJ,MAAM,IAAI,0CAAmB,CAAC,gBAAgB,CAAC,CAAC;aAChD;QACF,CAAC;KAAA;IAEY,YAAY,CAAC,QAAgB;;YACzC,OAAO,MAAM,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACpC,CAAC;KAAA;IAEY,cAAc,CAC1B,IAAY,EACZ,QAAgB;;YAEhB,OAAO,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAC5C,CAAC;KAAA;CACD;AA3BD,wDA2BC"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { DatabaseRecord, DatabaseRecordId } from '@riao/dbal';
|
|
2
|
-
import { AuthenticationBase, AuthenticationOptions } from './authentication-base';
|
|
3
|
-
import { Token, Jwt, JwtOptions } from './jwt';
|
|
4
|
-
export interface MagicLinkPayload {
|
|
5
|
-
type: 'magic-link';
|
|
6
|
-
userId: DatabaseRecordId;
|
|
7
|
-
}
|
|
8
|
-
export interface PasswordlessAuthenticationOptions extends AuthenticationOptions {
|
|
9
|
-
jwt: JwtOptions;
|
|
10
|
-
}
|
|
11
|
-
export interface TokenOptions {
|
|
12
|
-
expiresIn: string;
|
|
13
|
-
}
|
|
14
|
-
export declare const defaultTokenOptions: TokenOptions;
|
|
15
|
-
export declare class AuthenticationPasswordless<TUser extends DatabaseRecord = DatabaseRecord> extends AuthenticationBase<TUser> {
|
|
16
|
-
protected jwt: Jwt<MagicLinkPayload>;
|
|
17
|
-
constructor(options: PasswordlessAuthenticationOptions);
|
|
18
|
-
getMagicToken(credentials: {
|
|
19
|
-
login: string;
|
|
20
|
-
}, options?: TokenOptions): Promise<Token>;
|
|
21
|
-
login(credentials: {
|
|
22
|
-
token: string;
|
|
23
|
-
}): Promise<TUser>;
|
|
24
|
-
}
|