@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
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CreateFido2CredentialsTableMigration = void 0;
|
|
4
|
+
const dbal_1 = require("@riao/dbal");
|
|
5
|
+
const column_pack_1 = require("@riao/dbal/column-pack");
|
|
6
|
+
const dbal_2 = require("@riao/dbal");
|
|
7
|
+
class CreateFido2CredentialsTableMigration extends dbal_2.Migration {
|
|
8
|
+
async up() {
|
|
9
|
+
await this.ddl.createTable({
|
|
10
|
+
name: 'iam_fido2_credentials',
|
|
11
|
+
columns: [
|
|
12
|
+
// Base64URL encoded credential ID from WebAuthn (primary key)
|
|
13
|
+
{
|
|
14
|
+
name: 'id',
|
|
15
|
+
type: dbal_1.ColumnType.VARCHAR,
|
|
16
|
+
length: 1024,
|
|
17
|
+
primaryKey: true,
|
|
18
|
+
},
|
|
19
|
+
// Reference to the account who owns this credential
|
|
20
|
+
{
|
|
21
|
+
name: 'account_id',
|
|
22
|
+
type: dbal_1.ColumnType.UUID,
|
|
23
|
+
required: true,
|
|
24
|
+
fk: {
|
|
25
|
+
referencesTable: 'iam_accounts',
|
|
26
|
+
referencesColumn: 'id',
|
|
27
|
+
onDelete: 'CASCADE',
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
// CBOR-encoded public key from the authenticator
|
|
31
|
+
{
|
|
32
|
+
name: 'public_key',
|
|
33
|
+
type: dbal_1.ColumnType.TEXT,
|
|
34
|
+
required: true,
|
|
35
|
+
},
|
|
36
|
+
// Signature counter for replay attack prevention
|
|
37
|
+
{
|
|
38
|
+
name: 'counter',
|
|
39
|
+
type: dbal_1.ColumnType.BIGINT,
|
|
40
|
+
required: true,
|
|
41
|
+
},
|
|
42
|
+
// JSON array of supported authenticator transports
|
|
43
|
+
{
|
|
44
|
+
name: 'transports',
|
|
45
|
+
// TODO: Change to JSON when/if supported
|
|
46
|
+
type: dbal_1.ColumnType.TEXT,
|
|
47
|
+
required: false,
|
|
48
|
+
},
|
|
49
|
+
// User-friendly name for the authenticator device
|
|
50
|
+
{
|
|
51
|
+
name: 'device_name',
|
|
52
|
+
type: dbal_1.ColumnType.VARCHAR,
|
|
53
|
+
length: 255,
|
|
54
|
+
required: false,
|
|
55
|
+
},
|
|
56
|
+
column_pack_1.CreateTimestampColumn,
|
|
57
|
+
column_pack_1.UpdateTimestampColumn,
|
|
58
|
+
],
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
async down() {
|
|
62
|
+
await this.ddl.dropTable({
|
|
63
|
+
tables: ['iam_fido2_credentials'],
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.CreateFido2CredentialsTableMigration = CreateFido2CredentialsTableMigration;
|
|
68
|
+
//# sourceMappingURL=create-fido-credentials-table.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-fido-credentials-table.js","sourceRoot":"","sources":["../../../../../src/authentication/authentication-fido2/migrations/create-fido-credentials-table.ts"],"names":[],"mappings":";;;AAAA,qCAAwC;AACxC,wDAGgC;AAChC,qCAAuC;AAEvC,MAAa,oCAAqC,SAAQ,gBAAS;IACzD,KAAK,CAAC,EAAE;QAChB,MAAM,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC;YAC1B,IAAI,EAAE,uBAAuB;YAC7B,OAAO,EAAE;gBACR,8DAA8D;gBAC9D;oBACC,IAAI,EAAE,IAAI;oBACV,IAAI,EAAE,iBAAU,CAAC,OAAO;oBACxB,MAAM,EAAE,IAAI;oBACZ,UAAU,EAAE,IAAI;iBAChB;gBACD,oDAAoD;gBACpD;oBACC,IAAI,EAAE,YAAY;oBAClB,IAAI,EAAE,iBAAU,CAAC,IAAI;oBACrB,QAAQ,EAAE,IAAI;oBACd,EAAE,EAAE;wBACH,eAAe,EAAE,cAAc;wBAC/B,gBAAgB,EAAE,IAAI;wBACtB,QAAQ,EAAE,SAAS;qBACnB;iBACD;gBACD,iDAAiD;gBACjD;oBACC,IAAI,EAAE,YAAY;oBAClB,IAAI,EAAE,iBAAU,CAAC,IAAI;oBACrB,QAAQ,EAAE,IAAI;iBACd;gBACD,iDAAiD;gBACjD;oBACC,IAAI,EAAE,SAAS;oBACf,IAAI,EAAE,iBAAU,CAAC,MAAM;oBACvB,QAAQ,EAAE,IAAI;iBACd;gBACD,mDAAmD;gBACnD;oBACC,IAAI,EAAE,YAAY;oBAClB,yCAAyC;oBACzC,IAAI,EAAE,iBAAU,CAAC,IAAI;oBACrB,QAAQ,EAAE,KAAK;iBACf;gBACD,kDAAkD;gBAClD;oBACC,IAAI,EAAE,aAAa;oBACnB,IAAI,EAAE,iBAAU,CAAC,OAAO;oBACxB,MAAM,EAAE,GAAG;oBACX,QAAQ,EAAE,KAAK;iBACf;gBACD,mCAAqB;gBACrB,mCAAqB;aACrB;SACD,CAAC,CAAC;IACJ,CAAC;IAEQ,KAAK,CAAC,IAAI;QAClB,MAAM,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC;YACxB,MAAM,EAAE,CAAC,uBAAuB,CAAC;SACjC,CAAC,CAAC;IACJ,CAAC;CACD;AA5DD,oFA4DC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./create-fido-credentials-table"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./create-fido-challenges-table"), exports);
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/authentication/authentication-fido2/migrations/index.ts"],"names":[],"mappings":";;;AAAA,0EAAgD;AAChD,yEAA+C"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AuthenticationMagicTokenMigrations = void 0;
|
|
4
|
+
const auth_migrations_1 = require("../../auth/auth-migrations");
|
|
5
|
+
const _001_create_magic_token_table_1 = require("./migrations/001-create-magic-token-table");
|
|
6
|
+
class AuthenticationMagicTokenMigrations extends auth_migrations_1.AuthMigrations {
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8
|
+
getMigrations() {
|
|
9
|
+
return {
|
|
10
|
+
...super.getMigrations(),
|
|
11
|
+
'create-magic-token-table': _001_create_magic_token_table_1.CreateMagicTokenTable,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.AuthenticationMagicTokenMigrations = AuthenticationMagicTokenMigrations;
|
|
16
|
+
//# sourceMappingURL=authentication-magic-token-migrations.js.map
|
package/authentication/authentication-magic-token/authentication-magic-token-migrations.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authentication-magic-token-migrations.js","sourceRoot":"","sources":["../../../../src/authentication/authentication-magic-token/authentication-magic-token-migrations.ts"],"names":[],"mappings":";;;AACA,gEAA4D;AAC5D,6FAAkF;AAElF,MAAa,kCAAmC,SAAQ,gCAAc;IACrE,8DAA8D;IAC9C,aAAa;QAC5B,OAAO;YACN,GAAG,KAAK,CAAC,aAAa,EAAE;YACxB,0BAA0B,EAAE,qDAAqB;SACjD,CAAC;IACH,CAAC;CACD;AARD,gFAQC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { AuthenticationBase } from '../authentication-base';
|
|
2
|
+
import { Token, Jwt, JwtOptions } from '../../jwt';
|
|
3
|
+
import { MagicTokenPayload, MagicTokenRecord, TokenOptions } from './magic-token';
|
|
4
|
+
import { Account } from '../../../test/account';
|
|
5
|
+
import { QueryRepository } from '@riao/dbal';
|
|
6
|
+
import { AuthOptions } from '../../auth/auth';
|
|
7
|
+
export interface MagicTokenAuthenticationOptions<TAccount extends Account> extends AuthOptions<TAccount> {
|
|
8
|
+
jwtOptions: JwtOptions;
|
|
9
|
+
}
|
|
10
|
+
export declare class MagicTokenAuthentication<TAccount extends Account = Account> extends AuthenticationBase<TAccount> {
|
|
11
|
+
protected jwt: Jwt<MagicTokenPayload>;
|
|
12
|
+
protected magicTokenTable: string;
|
|
13
|
+
protected tokenColumn: string;
|
|
14
|
+
protected magicTokenRepo: QueryRepository<MagicTokenRecord>;
|
|
15
|
+
constructor(options: MagicTokenAuthenticationOptions<TAccount>);
|
|
16
|
+
createMagicToken(credentials: {
|
|
17
|
+
login: string;
|
|
18
|
+
}, options?: TokenOptions & {
|
|
19
|
+
type: string;
|
|
20
|
+
}): Promise<Token>;
|
|
21
|
+
authenticate(credentials: {
|
|
22
|
+
token: string;
|
|
23
|
+
type: string;
|
|
24
|
+
}): Promise<TAccount | null>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MagicTokenAuthentication = void 0;
|
|
4
|
+
const authentication_base_1 = require("../authentication-base");
|
|
5
|
+
const jwt_1 = require("../../jwt");
|
|
6
|
+
const magic_token_1 = require("./magic-token");
|
|
7
|
+
class MagicTokenAuthentication extends authentication_base_1.AuthenticationBase {
|
|
8
|
+
jwt;
|
|
9
|
+
magicTokenTable = 'iam_magic_tokens';
|
|
10
|
+
tokenColumn = 'token';
|
|
11
|
+
magicTokenRepo;
|
|
12
|
+
constructor(options) {
|
|
13
|
+
super(options);
|
|
14
|
+
this.jwt = new jwt_1.Jwt(options.jwtOptions);
|
|
15
|
+
}
|
|
16
|
+
async createMagicToken(credentials, options = {
|
|
17
|
+
...magic_token_1.defaultTokenOptions,
|
|
18
|
+
type: 'auth',
|
|
19
|
+
}) {
|
|
20
|
+
const account = await this.findActiveAccount({
|
|
21
|
+
where: {
|
|
22
|
+
[this.loginColumn]: credentials.login,
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
if (account === null) {
|
|
26
|
+
throw new Error('Account not found or not active.');
|
|
27
|
+
}
|
|
28
|
+
const accountId = account[this.accountIdColumn];
|
|
29
|
+
// Generate token
|
|
30
|
+
const token = await this.jwt.generateToken({
|
|
31
|
+
type: 'magic-token',
|
|
32
|
+
accountId: account[this.accountIdColumn],
|
|
33
|
+
}, {
|
|
34
|
+
expiresIn: options.expiresIn,
|
|
35
|
+
});
|
|
36
|
+
await this.magicTokenRepo.insertOne({
|
|
37
|
+
record: {
|
|
38
|
+
account_id: accountId,
|
|
39
|
+
token: token.token,
|
|
40
|
+
type: options.type,
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
return token;
|
|
44
|
+
}
|
|
45
|
+
async authenticate(credentials) {
|
|
46
|
+
// Verify magic token
|
|
47
|
+
const data = await this.jwt.decodeToken(credentials.token);
|
|
48
|
+
if (data.type !== 'magic-token') {
|
|
49
|
+
throw new Error('Wrong type of token provided for this operation.');
|
|
50
|
+
}
|
|
51
|
+
// Check account
|
|
52
|
+
const account = await this.findActiveAccount({
|
|
53
|
+
where: {
|
|
54
|
+
[this.accountIdColumn]: data.accountId,
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
// Check token exists
|
|
58
|
+
const tokenRecord = await this.magicTokenRepo.findOne({
|
|
59
|
+
where: {
|
|
60
|
+
account_id: data.accountId,
|
|
61
|
+
token: credentials.token,
|
|
62
|
+
type: credentials.type,
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
if (!tokenRecord) {
|
|
66
|
+
throw new Error('Token is invalid or expired.');
|
|
67
|
+
}
|
|
68
|
+
// Delete token
|
|
69
|
+
await this.magicTokenRepo.delete({
|
|
70
|
+
where: { id: tokenRecord.id },
|
|
71
|
+
});
|
|
72
|
+
return account;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.MagicTokenAuthentication = MagicTokenAuthentication;
|
|
76
|
+
//# sourceMappingURL=authentication-magic-token.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authentication-magic-token.js","sourceRoot":"","sources":["../../../../src/authentication/authentication-magic-token/authentication-magic-token.ts"],"names":[],"mappings":";;;AAAA,gEAA4D;AAC5D,mCAAmD;AACnD,+CAKuB;AAUvB,MAAa,wBAEX,SAAQ,wCAA4B;IAC3B,GAAG,CAAyB;IAC5B,eAAe,GAAG,kBAAkB,CAAC;IACrC,WAAW,GAAG,OAAO,CAAC;IACtB,cAAc,CAAoC;IAE5D,YAAmB,OAAkD;QACpE,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,GAAG,GAAG,IAAI,SAAG,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IACxC,CAAC;IAEM,KAAK,CAAC,gBAAgB,CAC5B,WAA8B,EAC9B,UAA2C;QAC1C,GAAG,iCAAmB;QACtB,IAAI,EAAE,MAAM;KACZ;QAED,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAC;YAC5C,KAAK,EAAO;gBACX,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,WAAW,CAAC,KAAK;aACrC;SACD,CAAC,CAAC;QAEH,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;QACrD,CAAC;QAED,MAAM,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QAEhD,iBAAiB;QACjB,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,aAAa,CACzC;YACC,IAAI,EAAE,aAAa;YACnB,SAAS,EAAE,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC;SACxC,EACD;YACC,SAAS,EAAE,OAAO,CAAC,SAAS;SAC5B,CACD,CAAC;QAEF,MAAM,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC;YACnC,MAAM,EAAE;gBACP,UAAU,EAAE,SAAS;gBACrB,KAAK,EAAE,KAAK,CAAC,KAAK;gBAClB,IAAI,EAAE,OAAO,CAAC,IAAI;aAClB;SACD,CAAC,CAAC;QAEH,OAAO,KAAK,CAAC;IACd,CAAC;IAEM,KAAK,CAAC,YAAY,CAAC,WAGzB;QACA,qBAAqB;QACrB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAE3D,IAAI,IAAI,CAAC,IAAI,KAAK,aAAa,EAAE,CAAC;YACjC,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;QACrE,CAAC;QAED,gBAAgB;QAChB,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAC;YAC5C,KAAK,EAAY;gBAChB,CAAC,IAAI,CAAC,eAAe,CAAC,EAAE,IAAI,CAAC,SAAS;aACtC;SACD,CAAC,CAAC;QAEH,qBAAqB;QACrB,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC;YACrD,KAAK,EAAE;gBACN,UAAU,EAAE,IAAI,CAAC,SAAS;gBAC1B,KAAK,EAAE,WAAW,CAAC,KAAK;gBACxB,IAAI,EAAE,WAAW,CAAC,IAAI;aACtB;SACD,CAAC,CAAC;QAEH,IAAI,CAAC,WAAW,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;QACjD,CAAC;QAED,eAAe;QACf,MAAM,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC;YAChC,KAAK,EAAE,EAAE,EAAE,EAAE,WAAW,CAAC,EAAE,EAAE;SAC7B,CAAC,CAAC;QAEH,OAAO,OAAO,CAAC;IAChB,CAAC;CACD;AA5FD,4DA4FC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MagicTokenAuthentication } from './authentication-magic-token';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MagicTokenAuthentication = void 0;
|
|
4
|
+
var authentication_magic_token_1 = require("./authentication-magic-token");
|
|
5
|
+
Object.defineProperty(exports, "MagicTokenAuthentication", { enumerable: true, get: function () { return authentication_magic_token_1.MagicTokenAuthentication; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/authentication/authentication-magic-token/index.ts"],"names":[],"mappings":";;;AAAA,2EAAwE;AAA/D,sIAAA,wBAAwB,OAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { DatabaseRecordId } from '@riao/dbal';
|
|
2
|
+
import ms from 'ms';
|
|
3
|
+
export interface TokenOptions {
|
|
4
|
+
expiresIn: ms.StringValue;
|
|
5
|
+
}
|
|
6
|
+
export declare const defaultTokenOptions: TokenOptions;
|
|
7
|
+
export interface MagicTokenPayload {
|
|
8
|
+
type: 'magic-token';
|
|
9
|
+
accountId: DatabaseRecordId;
|
|
10
|
+
}
|
|
11
|
+
export interface MagicTokenRecord {
|
|
12
|
+
id: DatabaseRecordId;
|
|
13
|
+
account_id: DatabaseRecordId;
|
|
14
|
+
created_at: Date;
|
|
15
|
+
type: string;
|
|
16
|
+
token: string;
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"magic-token.js","sourceRoot":"","sources":["../../../../src/authentication/authentication-magic-token/magic-token.ts"],"names":[],"mappings":";;;AAOa,QAAA,mBAAmB,GAAiB;IAChD,SAAS,EAAE,IAAI;CACf,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CreateMagicTokenTable = void 0;
|
|
4
|
+
const dbal_1 = require("@riao/dbal");
|
|
5
|
+
const column_pack_1 = require("@riao/dbal/column-pack");
|
|
6
|
+
const dbal_2 = require("@riao/dbal");
|
|
7
|
+
class CreateMagicTokenTable extends dbal_2.Migration {
|
|
8
|
+
async up() {
|
|
9
|
+
await this.ddl.createTable({
|
|
10
|
+
name: 'iam_magic_tokens',
|
|
11
|
+
columns: [
|
|
12
|
+
column_pack_1.UUIDKeyColumn,
|
|
13
|
+
column_pack_1.CreateTimestampColumn,
|
|
14
|
+
{
|
|
15
|
+
name: 'type',
|
|
16
|
+
type: dbal_1.ColumnType.VARCHAR,
|
|
17
|
+
length: 255,
|
|
18
|
+
required: true,
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: 'account_id',
|
|
22
|
+
type: dbal_1.ColumnType.UUID,
|
|
23
|
+
required: true,
|
|
24
|
+
fk: {
|
|
25
|
+
referencesTable: 'iam_accounts',
|
|
26
|
+
referencesColumn: 'id',
|
|
27
|
+
onDelete: 'CASCADE',
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: 'token',
|
|
32
|
+
type: dbal_1.ColumnType.VARCHAR,
|
|
33
|
+
length: 1024,
|
|
34
|
+
required: true,
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
async down() {
|
|
40
|
+
await this.ddl.dropTable({ tables: ['iam_magic_tokens'] });
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.CreateMagicTokenTable = CreateMagicTokenTable;
|
|
44
|
+
//# sourceMappingURL=001-create-magic-token-table.js.map
|
package/authentication/authentication-magic-token/migrations/001-create-magic-token-table.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"001-create-magic-token-table.js","sourceRoot":"","sources":["../../../../../src/authentication/authentication-magic-token/migrations/001-create-magic-token-table.ts"],"names":[],"mappings":";;;AAAA,qCAAwC;AACxC,wDAIgC;AAChC,qCAAuC;AAEvC,MAAa,qBAAsB,SAAQ,gBAAS;IAC1C,KAAK,CAAC,EAAE;QAChB,MAAM,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC;YAC1B,IAAI,EAAE,kBAAkB;YACxB,OAAO,EAAE;gBACR,2BAAa;gBACb,mCAAqB;gBACrB;oBACC,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,iBAAU,CAAC,OAAO;oBACxB,MAAM,EAAE,GAAG;oBACX,QAAQ,EAAE,IAAI;iBACd;gBACD;oBACC,IAAI,EAAE,YAAY;oBAClB,IAAI,EAAE,iBAAU,CAAC,IAAI;oBACrB,QAAQ,EAAE,IAAI;oBACd,EAAE,EAAE;wBACH,eAAe,EAAE,cAAc;wBAC/B,gBAAgB,EAAE,IAAI;wBACtB,QAAQ,EAAE,SAAS;qBACnB;iBACD;gBACD;oBACC,IAAI,EAAE,OAAO;oBACb,IAAI,EAAE,iBAAU,CAAC,OAAO;oBACxB,MAAM,EAAE,IAAI;oBACZ,QAAQ,EAAE,IAAI;iBACd;aACD;SACD,CAAC,CAAC;IACJ,CAAC;IAEQ,KAAK,CAAC,IAAI;QAClB,MAAM,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC;IAC5D,CAAC;CACD;AApCD,sDAoCC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AuthenticationPasswordMigrations = void 0;
|
|
4
|
+
const auth_migrations_1 = require("../../auth/auth-migrations");
|
|
5
|
+
const _001_add_password_column_1 = require("./migrations/001-add-password-column");
|
|
6
|
+
class AuthenticationPasswordMigrations extends auth_migrations_1.AuthMigrations {
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8
|
+
getMigrations() {
|
|
9
|
+
return {
|
|
10
|
+
...super.getMigrations(),
|
|
11
|
+
'add-password-column': _001_add_password_column_1.AddPasswordColumn,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.AuthenticationPasswordMigrations = AuthenticationPasswordMigrations;
|
|
16
|
+
//# sourceMappingURL=authentication-password-migrations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authentication-password-migrations.js","sourceRoot":"","sources":["../../../../src/authentication/authentication-password/authentication-password-migrations.ts"],"names":[],"mappings":";;;AACA,gEAA4D;AAC5D,mFAAyE;AAEzE,MAAa,gCAAiC,SAAQ,gCAAc;IACnE,8DAA8D;IACrD,aAAa;QACrB,OAAO;YACN,GAAG,KAAK,CAAC,aAAa,EAAE;YACxB,qBAAqB,EAAE,4CAAiB;SACxC,CAAC;IACH,CAAC;CACD;AARD,4EAQC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DatabaseRecordId } from '@riao/dbal';
|
|
2
|
+
import { AuthenticationBase } from '../authentication-base';
|
|
3
|
+
import { Account } from '../../../test/account';
|
|
4
|
+
export declare abstract class PasswordAuthentication<TAccount extends Account> extends AuthenticationBase<TAccount> {
|
|
5
|
+
protected passwordColumn: string;
|
|
6
|
+
createAccount(account: TAccount): Promise<DatabaseRecordId>;
|
|
7
|
+
authenticate(credentials: Partial<TAccount>): Promise<TAccount | null>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PasswordAuthentication = void 0;
|
|
4
|
+
const authentication_base_1 = require("../authentication-base");
|
|
5
|
+
class PasswordAuthentication extends authentication_base_1.AuthenticationBase {
|
|
6
|
+
passwordColumn = 'password';
|
|
7
|
+
async createAccount(account) {
|
|
8
|
+
const hash = await this.hash.make(account[this.passwordColumn]);
|
|
9
|
+
return await super.createAccount({
|
|
10
|
+
...account,
|
|
11
|
+
[this.passwordColumn]: hash,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
async authenticate(credentials) {
|
|
15
|
+
const account = await this.findActiveAccount({
|
|
16
|
+
where: {
|
|
17
|
+
[this.loginColumn]: credentials[this.loginColumn],
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
if (!account) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
const isValid = await this.hash.check(credentials[this.passwordColumn], account[this.passwordColumn]);
|
|
24
|
+
return isValid ? account : null;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.PasswordAuthentication = PasswordAuthentication;
|
|
28
|
+
//# sourceMappingURL=authentication-password.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authentication-password.js","sourceRoot":"","sources":["../../../../src/authentication/authentication-password/authentication-password.ts"],"names":[],"mappings":";;;AACA,gEAA4D;AAG5D,MAAsB,sBAEpB,SAAQ,wCAA4B;IAC3B,cAAc,GAAG,UAAU,CAAC;IAEtB,KAAK,CAAC,aAAa,CAClC,OAAiB;QAEjB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAChC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAW,CACtC,CAAC;QAEF,OAAO,MAAM,KAAK,CAAC,aAAa,CAAC;YAChC,GAAG,OAAO;YACV,CAAC,IAAI,CAAC,cAAc,CAAC,EAAE,IAAI;SAC3B,CAAC,CAAC;IACJ,CAAC;IAEM,KAAK,CAAC,YAAY,CACxB,WAA8B;QAE9B,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAC;YAC5C,KAAK,EAAY;gBAChB,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC;aACjD;SACD,CAAC,CAAC;QAEH,IAAI,CAAC,OAAO,EAAE,CAAC;YACd,OAAO,IAAI,CAAC;QACb,CAAC;QAED,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,CACpC,WAAW,CAAC,IAAI,CAAC,cAAc,CAAW,EAC1C,OAAO,CAAC,IAAI,CAAC,cAAc,CAAW,CACtC,CAAC;QAEF,OAAO,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;IACjC,CAAC;CACD;AAtCD,wDAsCC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PasswordAuthentication } from './authentication-password';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PasswordAuthentication = void 0;
|
|
4
|
+
var authentication_password_1 = require("./authentication-password");
|
|
5
|
+
Object.defineProperty(exports, "PasswordAuthentication", { enumerable: true, get: function () { return authentication_password_1.PasswordAuthentication; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/authentication/authentication-password/index.ts"],"names":[],"mappings":";;;AAAA,qEAAmE;AAA1D,iIAAA,sBAAsB,OAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AddPasswordColumn = void 0;
|
|
4
|
+
const column_pack_1 = require("@riao/dbal/column-pack");
|
|
5
|
+
const dbal_1 = require("@riao/dbal");
|
|
6
|
+
class AddPasswordColumn extends dbal_1.Migration {
|
|
7
|
+
async up() {
|
|
8
|
+
await this.ddl.addColumns({
|
|
9
|
+
table: 'iam_accounts',
|
|
10
|
+
columns: [{ ...column_pack_1.PasswordColumn, name: 'password' }],
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
async down() {
|
|
14
|
+
await this.ddl.dropColumn({
|
|
15
|
+
table: 'iam_accounts',
|
|
16
|
+
column: 'password',
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.AddPasswordColumn = AddPasswordColumn;
|
|
21
|
+
//# sourceMappingURL=001-add-password-column.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"001-add-password-column.js","sourceRoot":"","sources":["../../../../../src/authentication/authentication-password/migrations/001-add-password-column.ts"],"names":[],"mappings":";;;AAAA,wDAAwD;AACxD,qCAAuC;AAEvC,MAAa,iBAAkB,SAAQ,gBAAS;IACtC,KAAK,CAAC,EAAE;QAChB,MAAM,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC;YACzB,KAAK,EAAE,cAAc;YACrB,OAAO,EAAE,CAAC,EAAE,GAAG,4BAAc,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;SAClD,CAAC,CAAC;IACJ,CAAC;IAEQ,KAAK,CAAC,IAAI;QAClB,MAAM,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC;YACzB,KAAK,EAAE,cAAc;YACrB,MAAM,EAAE,UAAU;SAClB,CAAC,CAAC;IACJ,CAAC;CACD;AAdD,8CAcC"}
|
package/encrypt.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
/// <reference types="node" />
|
|
4
|
+
import * as crypto from 'crypto';
|
|
5
|
+
export declare function encrypt(publicKey: string | crypto.KeyObject, data: string | Buffer): Buffer;
|
|
6
|
+
export declare function decrypt(privateKey: string | crypto.KeyObject, encryptedData: string | Buffer): Buffer;
|
package/encrypt.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.decrypt = exports.encrypt = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const crypto = tslib_1.__importStar(require("crypto"));
|
|
6
|
+
function encrypt(publicKey, data) {
|
|
7
|
+
data = Buffer.isBuffer(data) ? data : Buffer.from(data);
|
|
8
|
+
return crypto.publicEncrypt(publicKey, data);
|
|
9
|
+
}
|
|
10
|
+
exports.encrypt = encrypt;
|
|
11
|
+
function decrypt(privateKey, encryptedData) {
|
|
12
|
+
encryptedData = Buffer.isBuffer(encryptedData)
|
|
13
|
+
? encryptedData
|
|
14
|
+
: Buffer.from(encryptedData);
|
|
15
|
+
return crypto.privateDecrypt(privateKey, encryptedData);
|
|
16
|
+
}
|
|
17
|
+
exports.decrypt = decrypt;
|
|
18
|
+
//# sourceMappingURL=encrypt.js.map
|
package/encrypt.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encrypt.js","sourceRoot":"","sources":["../../src/encrypt.ts"],"names":[],"mappings":";;;;AAAA,uDAAiC;AAEjC,SAAgB,OAAO,CACtB,SAAoC,EACpC,IAAqB;IAErB,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACxD,OAAO,MAAM,CAAC,aAAa,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;AAC9C,CAAC;AAND,0BAMC;AAED,SAAgB,OAAO,CACtB,UAAqC,EACrC,aAA8B;IAE9B,aAAa,GAAG,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC;QAC7C,CAAC,CAAC,aAAa;QACf,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAE9B,OAAO,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;AACzD,CAAC;AATD,0BASC"}
|
package/hash.d.ts
ADDED
package/hash.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Hash = void 0;
|
|
4
|
+
const bcrypt_1 = require("bcrypt");
|
|
5
|
+
class Hash {
|
|
6
|
+
rounds = 12;
|
|
7
|
+
async make(input, rounds) {
|
|
8
|
+
return await (0, bcrypt_1.hash)(input, rounds || this.rounds);
|
|
9
|
+
}
|
|
10
|
+
async check(input, hashed) {
|
|
11
|
+
return await (0, bcrypt_1.compare)(input, hashed);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.Hash = Hash;
|
|
15
|
+
//# sourceMappingURL=hash.js.map
|
package/hash.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hash.js","sourceRoot":"","sources":["../../src/hash.ts"],"names":[],"mappings":";;;AAAA,mCAAuC;AAEvC,MAAa,IAAI;IACT,MAAM,GAAW,EAAE,CAAC;IAEpB,KAAK,CAAC,IAAI,CAAC,KAAa,EAAE,MAAe;QAC/C,OAAO,MAAM,IAAA,aAAI,EAAC,KAAK,EAAE,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC;IACjD,CAAC;IAEM,KAAK,CAAC,KAAK,CAAC,KAAa,EAAE,MAAc;QAC/C,OAAO,MAAM,IAAA,gBAAO,EAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACrC,CAAC;CACD;AAVD,oBAUC"}
|
package/index.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
export * from './jwt';
|
|
1
|
+
export declare const a = true;
|
package/index.js
CHANGED
|
@@ -1,19 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./iam"), exports);
|
|
18
|
-
__exportStar(require("./jwt"), exports);
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.a = void 0;
|
|
4
|
+
exports.a = true;
|
|
19
5
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAa,QAAA,CAAC,GAAG,IAAI,CAAC"}
|
package/jwt.d.ts
CHANGED
|
@@ -1,28 +1,26 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import * as jwt from 'jsonwebtoken';
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
export type
|
|
8
|
-
export type
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
export declare class Jwt<TPayload extends JwtPayload = JwtPayload> {
|
|
17
|
-
protected publicKey: KeyObject;
|
|
18
|
-
protected privateKey: KeyObject;
|
|
19
|
-
protected expiresIn?:
|
|
20
|
-
protected notBefore?:
|
|
21
|
-
protected algorithm?: SecretAlgorithm | KeyPairAlgorithm;
|
|
22
|
-
constructor(options: JwtOptions);
|
|
23
|
-
protected tokenOptions(): jwt.SignOptions;
|
|
24
|
-
generateToken(data: TPayload, options?: jwt.SignOptions): Promise<Token>;
|
|
25
|
-
decodeToken(token: string): Promise<TPayload>;
|
|
26
|
-
|
|
27
|
-
verifyRefreshToken(token: string): Promise<TPayload>;
|
|
28
|
-
}
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import * as jwt from 'jsonwebtoken';
|
|
3
|
+
import ms from 'ms';
|
|
4
|
+
import { Secret, SecretAlgorithm } from './secret';
|
|
5
|
+
import { KeyPair, KeyPairAlgorithm } from './keypair';
|
|
6
|
+
import { KeyObject } from 'crypto';
|
|
7
|
+
export type JwtPayload = Record<string, any>;
|
|
8
|
+
export type JwtSigningOptions = Secret | KeyPair;
|
|
9
|
+
export type JwtOptions = JwtSigningOptions & {
|
|
10
|
+
expiresIn?: ms.StringValue;
|
|
11
|
+
notBefore?: ms.StringValue;
|
|
12
|
+
};
|
|
13
|
+
export interface Token {
|
|
14
|
+
token: string;
|
|
15
|
+
}
|
|
16
|
+
export declare class Jwt<TPayload extends JwtPayload = JwtPayload> {
|
|
17
|
+
protected publicKey: KeyObject;
|
|
18
|
+
protected privateKey: KeyObject;
|
|
19
|
+
protected expiresIn?: ms.StringValue;
|
|
20
|
+
protected notBefore?: ms.StringValue;
|
|
21
|
+
protected algorithm?: SecretAlgorithm | KeyPairAlgorithm;
|
|
22
|
+
constructor(options: JwtOptions);
|
|
23
|
+
protected tokenOptions(): jwt.SignOptions;
|
|
24
|
+
generateToken(data: TPayload, options?: jwt.SignOptions): Promise<Token>;
|
|
25
|
+
decodeToken(token: string): Promise<TPayload>;
|
|
26
|
+
}
|