@riao/iam 2.0.0 → 3.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.
Files changed (89) hide show
  1. package/README.md +67 -1
  2. package/auth/auth-migrations.d.ts +5 -3
  3. package/auth/auth-migrations.js +8 -5
  4. package/auth/auth-migrations.js.map +1 -1
  5. package/auth/auth.d.ts +6 -8
  6. package/auth/auth.js +5 -8
  7. package/auth/auth.js.map +1 -1
  8. package/auth/index.d.ts +1 -0
  9. package/auth/migrations/{001-create-accounts-table.d.ts → 001-create-principals-table.d.ts} +1 -1
  10. package/auth/migrations/001-create-principals-table.js +39 -0
  11. package/auth/migrations/001-create-principals-table.js.map +1 -0
  12. package/auth/principal.d.ts +8 -0
  13. package/auth/principal.js +3 -0
  14. package/auth/principal.js.map +1 -0
  15. package/authentication/authentication.d.ts +9 -0
  16. package/authentication/authentication.js +41 -0
  17. package/authentication/authentication.js.map +1 -0
  18. package/authentication/index.d.ts +1 -0
  19. package/authentication/index.js +6 -0
  20. package/authentication/index.js.map +1 -0
  21. package/crypto.d.ts +16 -0
  22. package/crypto.js +35 -0
  23. package/crypto.js.map +1 -0
  24. package/index.d.ts +4 -1
  25. package/index.js +11 -2
  26. package/index.js.map +1 -1
  27. package/jwt.d.ts +1 -1
  28. package/jwt.js +3 -9
  29. package/jwt.js.map +1 -1
  30. package/keypair.d.ts +5 -5
  31. package/keypair.js +21 -23
  32. package/keypair.js.map +1 -1
  33. package/package.json +9 -29
  34. package/auth/migrations/001-create-accounts-table.js +0 -27
  35. package/auth/migrations/001-create-accounts-table.js.map +0 -1
  36. package/authentication/authentication-base/authentication-base.d.ts +0 -10
  37. package/authentication/authentication-base/authentication-base.js +0 -33
  38. package/authentication/authentication-base/authentication-base.js.map +0 -1
  39. package/authentication/authentication-base/index.d.ts +0 -1
  40. package/authentication/authentication-base/index.js +0 -6
  41. package/authentication/authentication-base/index.js.map +0 -1
  42. package/authentication/authentication-fido2/authentication-fido2-migrations.d.ts +0 -5
  43. package/authentication/authentication-fido2/authentication-fido2-migrations.js +0 -17
  44. package/authentication/authentication-fido2/authentication-fido2-migrations.js.map +0 -1
  45. package/authentication/authentication-fido2/authentication-fido2.d.ts +0 -58
  46. package/authentication/authentication-fido2/authentication-fido2.js +0 -260
  47. package/authentication/authentication-fido2/authentication-fido2.js.map +0 -1
  48. package/authentication/authentication-fido2/index.d.ts +0 -1
  49. package/authentication/authentication-fido2/index.js +0 -6
  50. package/authentication/authentication-fido2/index.js.map +0 -1
  51. package/authentication/authentication-fido2/migrations/create-fido-challenges-table.d.ts +0 -5
  52. package/authentication/authentication-fido2/migrations/create-fido-challenges-table.js +0 -61
  53. package/authentication/authentication-fido2/migrations/create-fido-challenges-table.js.map +0 -1
  54. package/authentication/authentication-fido2/migrations/create-fido-credentials-table.d.ts +0 -5
  55. package/authentication/authentication-fido2/migrations/create-fido-credentials-table.js +0 -68
  56. package/authentication/authentication-fido2/migrations/create-fido-credentials-table.js.map +0 -1
  57. package/authentication/authentication-fido2/migrations/index.d.ts +0 -2
  58. package/authentication/authentication-fido2/migrations/index.js +0 -6
  59. package/authentication/authentication-fido2/migrations/index.js.map +0 -1
  60. package/authentication/authentication-magic-token/authentication-magic-token-migrations.d.ts +0 -5
  61. package/authentication/authentication-magic-token/authentication-magic-token-migrations.js +0 -16
  62. package/authentication/authentication-magic-token/authentication-magic-token-migrations.js.map +0 -1
  63. package/authentication/authentication-magic-token/authentication-magic-token.d.ts +0 -25
  64. package/authentication/authentication-magic-token/authentication-magic-token.js +0 -76
  65. package/authentication/authentication-magic-token/authentication-magic-token.js.map +0 -1
  66. package/authentication/authentication-magic-token/index.d.ts +0 -1
  67. package/authentication/authentication-magic-token/index.js +0 -6
  68. package/authentication/authentication-magic-token/index.js.map +0 -1
  69. package/authentication/authentication-magic-token/magic-token.d.ts +0 -17
  70. package/authentication/authentication-magic-token/magic-token.js +0 -7
  71. package/authentication/authentication-magic-token/magic-token.js.map +0 -1
  72. package/authentication/authentication-magic-token/migrations/001-create-magic-token-table.d.ts +0 -5
  73. package/authentication/authentication-magic-token/migrations/001-create-magic-token-table.js +0 -44
  74. package/authentication/authentication-magic-token/migrations/001-create-magic-token-table.js.map +0 -1
  75. package/authentication/authentication-password/authentication-password-migrations.d.ts +0 -5
  76. package/authentication/authentication-password/authentication-password-migrations.js +0 -16
  77. package/authentication/authentication-password/authentication-password-migrations.js.map +0 -1
  78. package/authentication/authentication-password/authentication-password.d.ts +0 -8
  79. package/authentication/authentication-password/authentication-password.js +0 -28
  80. package/authentication/authentication-password/authentication-password.js.map +0 -1
  81. package/authentication/authentication-password/index.d.ts +0 -1
  82. package/authentication/authentication-password/index.js +0 -6
  83. package/authentication/authentication-password/index.js.map +0 -1
  84. package/authentication/authentication-password/migrations/001-add-password-column.d.ts +0 -5
  85. package/authentication/authentication-password/migrations/001-add-password-column.js +0 -21
  86. package/authentication/authentication-password/migrations/001-add-password-column.js.map +0 -1
  87. package/encrypt.d.ts +0 -6
  88. package/encrypt.js +0 -18
  89. package/encrypt.js.map +0 -1
package/README.md CHANGED
@@ -1,4 +1,70 @@
1
- # riao-iam - Readme
1
+ # @riao/iam - Readme
2
+
3
+ ## Installation
4
+
5
+ `npm i @riao/iam`
6
+
7
+ ## Encryption & Key Pairs
8
+
9
+ To use encryption and signing features, you need to generate a key pair. The `KeyPairGenerator` class supports generating RSA and Elliptic Curve key pairs.
10
+
11
+ ### Quick Start with Encryptor/Decryptor (Recommended)
12
+
13
+ The `Encryptor` and `Decryptor` classes provide a simple, object-oriented interface for managing encryption and decryption:
14
+
15
+ ```typescript
16
+ import { Encryptor, Decryptor, KeyPairGenerator } from '@riao/iam';
17
+
18
+ // Generate a key pair
19
+ const generator = new KeyPairGenerator({ algorithm: 'RS256' });
20
+ const keypair = generator.generate();
21
+
22
+ // Create Encryptor and Decryptor instances
23
+ const encryptor = new Encryptor(keypair.publicKey);
24
+ const decryptor = new Decryptor(keypair.privateKey);
25
+
26
+ // Encrypt and decrypt
27
+ const encrypted = encryptor.encrypt('Secret message');
28
+ const decrypted = decryptor.decrypt(encrypted);
29
+ console.log(decrypted.toString()); // 'Secret message'
30
+ ```
31
+
32
+ ## JSON Web Tokens (JWT)
33
+
34
+ The `Jwt` class provides a secure way to generate and verify JSON Web Tokens for authentication and authorization. It supports both symmetric signing (using a shared secret) and asymmetric signing (using public/private key pairs).
35
+
36
+ ### Quick Start
37
+
38
+ ```typescript
39
+ import { Jwt } from '@riao/iam';
40
+
41
+ // Create a JWT manager with a shared secret
42
+ const jwtManager = new Jwt({
43
+ secret: 'your-secret-key',
44
+ algorithm: 'HS512',
45
+ expiresIn: '1h',
46
+ });
47
+
48
+ // Generate a token
49
+ const { token } = await jwtManager.generateToken({
50
+ userId: 'user-123',
51
+ role: 'admin',
52
+ });
53
+
54
+ // Verify and decode a token
55
+ const payload = await jwtManager.decodeToken(token);
56
+ console.log(payload.userId); // 'user-123'
57
+ ```
58
+
59
+ For detailed usage, algorithms, security best practices, and advanced patterns, see the [JWT Guide](docs/jwt-guide.md).
60
+
61
+ ### Documentation
62
+
63
+ - [Encryptor & Decryptor Guide](docs/encryptor-decryptor-guide.md) - **Recommended** - Object-oriented encryption/decryption interface
64
+ - [KeyPair Usage Guide](docs/keypair-guide.md) - Learn how to use the KeyPairGenerator for cryptographic operations
65
+ - [Encryption & Decryption Guide](docs/crypto-guide.md) - Lower-level `encrypt` and `decrypt` functions (for advanced use cases)
66
+ - [Hash Guide](docs/hash-guide.md) - Password hashing and verification with bcrypt
67
+ - [JWT Guide](docs/jwt-guide.md) - Generate and verify JSON Web Tokens for authentication and authorization
2
68
 
3
69
  ## Contributing & Development
4
70
 
@@ -1,4 +1,6 @@
1
- import { Migration } from '@riao/dbal';
2
- export declare class AuthMigrations {
3
- getMigrations(): Record<string, typeof Migration<any>>;
1
+ import { Migration, MigrationPackage } from '@riao/dbal';
2
+ export declare class AuthMigrations extends MigrationPackage {
3
+ name: string;
4
+ package: string;
5
+ getMigrations(): Promise<Record<string, typeof Migration<any>>>;
4
6
  }
@@ -1,11 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AuthMigrations = void 0;
4
- const _001_create_accounts_table_1 = require("./migrations/001-create-accounts-table");
5
- class AuthMigrations {
6
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
7
- getMigrations() {
8
- return { 'create-accounts-table': _001_create_accounts_table_1.CreateAccountsTableMigration };
4
+ const dbal_1 = require("@riao/dbal");
5
+ // eslint-disable-next-line max-len
6
+ const _001_create_principals_table_1 = require("./migrations/001-create-principals-table");
7
+ class AuthMigrations extends dbal_1.MigrationPackage {
8
+ name = '@riao/iam';
9
+ package = '@riao/iam';
10
+ async getMigrations() {
11
+ return { 'create-principals-table': _001_create_principals_table_1.CreatePrincipalsTableMigration };
9
12
  }
10
13
  }
11
14
  exports.AuthMigrations = AuthMigrations;
@@ -1 +1 @@
1
- {"version":3,"file":"auth-migrations.js","sourceRoot":"","sources":["../../../src/auth/auth-migrations.ts"],"names":[],"mappings":";;;AACA,uFAAsF;AAEtF,MAAa,cAAc;IAC1B,8DAA8D;IACvD,aAAa;QACnB,OAAO,EAAE,uBAAuB,EAAE,yDAA4B,EAAE,CAAC;IAClE,CAAC;CACD;AALD,wCAKC"}
1
+ {"version":3,"file":"auth-migrations.js","sourceRoot":"","sources":["../../../src/auth/auth-migrations.ts"],"names":[],"mappings":";;;AAAA,qCAAyD;AACzD,mCAAmC;AACnC,2FAA0F;AAE1F,MAAa,cAAe,SAAQ,uBAAgB;IAC1C,IAAI,GAAG,WAAW,CAAC;IACnB,OAAO,GAAG,WAAW,CAAC;IAExB,KAAK,CAAC,aAAa;QAIzB,OAAO,EAAE,yBAAyB,EAAE,6DAA8B,EAAE,CAAC;IACtE,CAAC;CACD;AAVD,wCAUC"}
package/auth/auth.d.ts CHANGED
@@ -1,11 +1,9 @@
1
- import { DatabaseRecord, QueryRepository } from '@riao/dbal';
2
- export interface AuthOptions<TAccount extends DatabaseRecord> {
3
- repo: QueryRepository<TAccount>;
1
+ import { Database, DatabaseRecord, QueryRepository } from '@riao/dbal';
2
+ export interface AuthOptions {
3
+ db: Database;
4
4
  }
5
- export declare abstract class Auth<TAccount extends DatabaseRecord> {
6
- protected accountRepo: QueryRepository<TAccount>;
7
- protected accountTable: string;
8
- protected accountIdColumn: string;
5
+ export declare abstract class Auth<TPrincipal extends DatabaseRecord> {
6
+ principalRepo: QueryRepository<TPrincipal>;
9
7
  protected loginColumn: string;
10
- constructor(options: AuthOptions<TAccount>);
8
+ constructor(options: AuthOptions);
11
9
  }
package/auth/auth.js CHANGED
@@ -2,16 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Auth = void 0;
4
4
  class Auth {
5
- accountRepo;
6
- accountTable = 'iam_accounts';
7
- accountIdColumn = 'id';
5
+ principalRepo;
8
6
  loginColumn = 'login';
9
7
  constructor(options) {
10
- this.accountRepo = options.repo;
11
- this.accountTable =
12
- this.accountRepo.getTableName() || this.accountTable;
13
- this.accountIdColumn =
14
- this.accountRepo.getIdentifier() || this.accountIdColumn;
8
+ this.principalRepo = options.db.getQueryRepository({
9
+ table: 'iam_principals',
10
+ identifiedBy: 'id',
11
+ });
15
12
  }
16
13
  }
17
14
  exports.Auth = Auth;
package/auth/auth.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/auth/auth.ts"],"names":[],"mappings":";;;AAKA,MAAsB,IAAI;IACf,WAAW,CAA4B;IACvC,YAAY,GAAG,cAAc,CAAC;IAC9B,eAAe,GAAG,IAAI,CAAC;IACvB,WAAW,GAAG,OAAO,CAAC;IAEhC,YAAmB,OAA8B;QAChD,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;QAChC,IAAI,CAAC,YAAY;YAChB,IAAI,CAAC,WAAW,CAAC,YAAY,EAAE,IAAI,IAAI,CAAC,YAAY,CAAC;QACtD,IAAI,CAAC,eAAe;YACnB,IAAI,CAAC,WAAW,CAAC,aAAa,EAAE,IAAI,IAAI,CAAC,eAAe,CAAC;IAC3D,CAAC;CACD;AAbD,oBAaC"}
1
+ {"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/auth/auth.ts"],"names":[],"mappings":";;;AAMA,MAAsB,IAAI;IAClB,aAAa,CAA8B;IACxC,WAAW,GAAG,OAAO,CAAC;IAEhC,YAAmB,OAAoB;QACtC,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,EAAE,CAAC,kBAAkB,CAAa;YAC9D,KAAK,EAAE,gBAAgB;YACvB,YAAY,EAAE,IAAI;SAClB,CAAC,CAAC;IACJ,CAAC;CACD;AAVD,oBAUC"}
package/auth/index.d.ts CHANGED
@@ -1 +1,2 @@
1
1
  export { Auth } from './auth';
2
+ export { Principal } from './principal';
@@ -1,5 +1,5 @@
1
1
  import { Migration } from '@riao/dbal';
2
- export declare class CreateAccountsTableMigration extends Migration {
2
+ export declare class CreatePrincipalsTableMigration extends Migration {
3
3
  up(): Promise<void>;
4
4
  down(): Promise<void>;
5
5
  }
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CreatePrincipalsTableMigration = void 0;
4
+ const column_pack_1 = require("@riao/dbal/column-pack");
5
+ const dbal_1 = require("@riao/dbal");
6
+ class CreatePrincipalsTableMigration extends dbal_1.Migration {
7
+ async up() {
8
+ await this.ddl.createTable({
9
+ name: 'iam_principals',
10
+ columns: [
11
+ column_pack_1.UUIDKeyColumn,
12
+ {
13
+ name: 'type',
14
+ type: dbal_1.ColumnType.VARCHAR,
15
+ length: 20,
16
+ required: true,
17
+ },
18
+ {
19
+ ...column_pack_1.UsernameColumn,
20
+ name: 'login',
21
+ required: true,
22
+ },
23
+ { ...column_pack_1.NameColumn, required: true },
24
+ column_pack_1.CreateTimestampColumn,
25
+ {
26
+ name: 'deactivate_timestamp',
27
+ type: dbal_1.ColumnType.TIMESTAMP,
28
+ },
29
+ ],
30
+ });
31
+ }
32
+ async down() {
33
+ await this.ddl.dropTable({
34
+ tables: ['iam_principals'],
35
+ });
36
+ }
37
+ }
38
+ exports.CreatePrincipalsTableMigration = CreatePrincipalsTableMigration;
39
+ //# sourceMappingURL=001-create-principals-table.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"001-create-principals-table.js","sourceRoot":"","sources":["../../../../src/auth/migrations/001-create-principals-table.ts"],"names":[],"mappings":";;;AAAA,wDAKgC;AAChC,qCAAmD;AAEnD,MAAa,8BAA+B,SAAQ,gBAAS;IACnD,KAAK,CAAC,EAAE;QAChB,MAAM,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC;YAC1B,IAAI,EAAE,gBAAgB;YACtB,OAAO,EAAE;gBACR,2BAAa;gBACb;oBACC,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,iBAAU,CAAC,OAAO;oBACxB,MAAM,EAAE,EAAE;oBACV,QAAQ,EAAE,IAAI;iBACd;gBACD;oBACC,GAAG,4BAAc;oBACjB,IAAI,EAAE,OAAO;oBACb,QAAQ,EAAE,IAAI;iBACd;gBACD,EAAE,GAAG,wBAAU,EAAE,QAAQ,EAAE,IAAI,EAAE;gBACjC,mCAAqB;gBACrB;oBACC,IAAI,EAAE,sBAAsB;oBAC5B,IAAI,EAAE,iBAAU,CAAC,SAAS;iBAC1B;aACD;SACD,CAAC,CAAC;IACJ,CAAC;IAEQ,KAAK,CAAC,IAAI;QAClB,MAAM,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC;YACxB,MAAM,EAAE,CAAC,gBAAgB,CAAC;SAC1B,CAAC,CAAC;IACJ,CAAC;CACD;AAhCD,wEAgCC"}
@@ -0,0 +1,8 @@
1
+ export interface Principal {
2
+ id: string;
3
+ type: 'user' | 'service' | 'system' | 'bot';
4
+ login: string;
5
+ name: string;
6
+ create_timestamp: Date;
7
+ deactivate_timestamp?: Date;
8
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=principal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"principal.js","sourceRoot":"","sources":["../../../src/auth/principal.ts"],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
1
+ import { DatabaseRecordId, Expression, SelectQuery } from '@riao/dbal';
2
+ import { Auth, Principal } from '../auth';
3
+ export declare abstract class Authentication<TPrincipal extends Principal> extends Auth<TPrincipal> {
4
+ createPrincipal(principal: Omit<TPrincipal, 'id' | 'create_timestamp'>): Promise<DatabaseRecordId>;
5
+ abstract authenticate(credentials: any): Promise<TPrincipal | null>;
6
+ findActivePrincipal(query: SelectQuery<TPrincipal>): Promise<TPrincipal | null>;
7
+ deactivatePrincipal(principalId: DatabaseRecordId): Promise<void>;
8
+ protected isActiveQuery(): undefined | Expression<TPrincipal>;
9
+ }
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Authentication = void 0;
4
+ const dbal_1 = require("@riao/dbal");
5
+ const auth_1 = require("../auth");
6
+ class Authentication extends auth_1.Auth {
7
+ async createPrincipal(principal) {
8
+ const inserted = await this.principalRepo.insertOne({
9
+ record: principal,
10
+ });
11
+ return inserted.id;
12
+ }
13
+ async findActivePrincipal(query) {
14
+ const isActiveQuery = this.isActiveQuery();
15
+ if (query.where && isActiveQuery !== undefined) {
16
+ query.where = [isActiveQuery, dbal_1.and, query.where];
17
+ }
18
+ else if (isActiveQuery !== undefined) {
19
+ query.where = isActiveQuery;
20
+ }
21
+ const principal = await this.principalRepo.findOne({
22
+ ...query,
23
+ });
24
+ return principal;
25
+ }
26
+ async deactivatePrincipal(principalId) {
27
+ return this.principalRepo.update({
28
+ set: {
29
+ deactivate_timestamp: new Date(),
30
+ },
31
+ where: { id: principalId },
32
+ });
33
+ }
34
+ isActiveQuery() {
35
+ return {
36
+ deactivate_timestamp: null,
37
+ };
38
+ }
39
+ }
40
+ exports.Authentication = Authentication;
41
+ //# sourceMappingURL=authentication.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authentication.js","sourceRoot":"","sources":["../../../src/authentication/authentication.ts"],"names":[],"mappings":";;;AAAA,qCAA4E;AAC5E,kCAA0C;AAG1C,MAAsB,cAEpB,SAAQ,WAAgB;IAClB,KAAK,CAAC,eAAe,CAC3B,SAAsD;QAEtD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC;YACnD,MAAM,EAAE,SAAuB;SAC/B,CAAC,CAAC;QAEH,OAAO,QAAQ,CAAC,EAAsB,CAAC;IACxC,CAAC;IAKM,KAAK,CAAC,mBAAmB,CAC/B,KAA8B;QAE9B,MAAM,aAAa,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;QAE3C,IAAI,KAAK,CAAC,KAAK,IAAI,aAAa,KAAK,SAAS,EAAE,CAAC;YAChD,KAAK,CAAC,KAAK,GAAG,CAAC,aAAa,EAAE,UAAG,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;QACjD,CAAC;aACI,IAAI,aAAa,KAAK,SAAS,EAAE,CAAC;YACtC,KAAK,CAAC,KAAK,GAAG,aAAa,CAAC;QAC7B,CAAC;QAED,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC;YAClD,GAAG,KAAK;SACR,CAAC,CAAC;QAEH,OAAO,SAAS,CAAC;IAClB,CAAC;IAEM,KAAK,CAAC,mBAAmB,CAC/B,WAA6B;QAE7B,OAAO,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC;YAChC,GAAG,EAAE;gBACJ,oBAAoB,EAAE,IAAI,IAAI,EAAE;aACT;YACxB,KAAK,EAAE,EAAE,EAAE,EAAE,WAAW,EAAkC;SAC1D,CAAC,CAAC;IACJ,CAAC;IAES,aAAa;QACtB,OAAO;YACN,oBAAoB,EAAE,IAAI;SACM,CAAC;IACnC,CAAC;CACD;AAnDD,wCAmDC"}
@@ -0,0 +1 @@
1
+ export { Authentication } from './authentication';
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Authentication = void 0;
4
+ var authentication_1 = require("./authentication");
5
+ Object.defineProperty(exports, "Authentication", { enumerable: true, get: function () { return authentication_1.Authentication; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/authentication/index.ts"],"names":[],"mappings":";;;AAAA,mDAAkD;AAAzC,gHAAA,cAAc,OAAA"}
package/crypto.d.ts ADDED
@@ -0,0 +1,16 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ /// <reference types="node" />
4
+ import * as crypto from 'crypto';
5
+ export declare function encrypt(publicKey: crypto.KeyObject, data: string | Buffer): Buffer;
6
+ export declare function decrypt(privateKey: crypto.KeyObject, encryptedData: Buffer): Buffer;
7
+ export declare class Encryptor {
8
+ private publicKey;
9
+ constructor(publicKey: crypto.KeyObject);
10
+ encrypt(data: string | Buffer): Buffer;
11
+ }
12
+ export declare class Decryptor {
13
+ private privateKey;
14
+ constructor(privateKey: crypto.KeyObject);
15
+ decrypt(encryptedData: Buffer): Buffer;
16
+ }
package/crypto.js ADDED
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Decryptor = exports.Encryptor = 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
+ return crypto.privateDecrypt(privateKey, encryptedData);
13
+ }
14
+ exports.decrypt = decrypt;
15
+ class Encryptor {
16
+ publicKey;
17
+ constructor(publicKey) {
18
+ this.publicKey = publicKey;
19
+ }
20
+ encrypt(data) {
21
+ return encrypt(this.publicKey, data);
22
+ }
23
+ }
24
+ exports.Encryptor = Encryptor;
25
+ class Decryptor {
26
+ privateKey;
27
+ constructor(privateKey) {
28
+ this.privateKey = privateKey;
29
+ }
30
+ decrypt(encryptedData) {
31
+ return decrypt(this.privateKey, encryptedData);
32
+ }
33
+ }
34
+ exports.Decryptor = Decryptor;
35
+ //# sourceMappingURL=crypto.js.map
package/crypto.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crypto.js","sourceRoot":"","sources":["../../src/crypto.ts"],"names":[],"mappings":";;;;AAAA,uDAAiC;AAEjC,SAAgB,OAAO,CACtB,SAA2B,EAC3B,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,UAA4B,EAC5B,aAAqB;IAErB,OAAO,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;AACzD,CAAC;AALD,0BAKC;AAED,MAAa,SAAS;IACb,SAAS,CAAmB;IAEpC,YAAY,SAA2B;QACtC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC5B,CAAC;IAED,OAAO,CAAC,IAAqB;QAC5B,OAAO,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IACtC,CAAC;CACD;AAVD,8BAUC;AAED,MAAa,SAAS;IACb,UAAU,CAAmB;IAErC,YAAY,UAA4B;QACvC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC9B,CAAC;IAED,OAAO,CAAC,aAAqB;QAC5B,OAAO,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;IAChD,CAAC;CACD;AAVD,8BAUC"}
package/index.d.ts CHANGED
@@ -1 +1,4 @@
1
- export declare const a = true;
1
+ export { encrypt, decrypt, Encryptor, Decryptor } from './crypto';
2
+ export { KeyPairGenerator } from './keypair';
3
+ export * from './auth';
4
+ export * from './authentication';
package/index.js CHANGED
@@ -1,5 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.a = void 0;
4
- exports.a = true;
3
+ exports.KeyPairGenerator = exports.Decryptor = exports.Encryptor = exports.decrypt = exports.encrypt = void 0;
4
+ const tslib_1 = require("tslib");
5
+ var crypto_1 = require("./crypto");
6
+ Object.defineProperty(exports, "encrypt", { enumerable: true, get: function () { return crypto_1.encrypt; } });
7
+ Object.defineProperty(exports, "decrypt", { enumerable: true, get: function () { return crypto_1.decrypt; } });
8
+ Object.defineProperty(exports, "Encryptor", { enumerable: true, get: function () { return crypto_1.Encryptor; } });
9
+ Object.defineProperty(exports, "Decryptor", { enumerable: true, get: function () { return crypto_1.Decryptor; } });
10
+ var keypair_1 = require("./keypair");
11
+ Object.defineProperty(exports, "KeyPairGenerator", { enumerable: true, get: function () { return keypair_1.KeyPairGenerator; } });
12
+ tslib_1.__exportStar(require("./auth"), exports);
13
+ tslib_1.__exportStar(require("./authentication"), exports);
5
14
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAa,QAAA,CAAC,GAAG,IAAI,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;AAAA,mCAAkE;AAAzD,iGAAA,OAAO,OAAA;AAAE,iGAAA,OAAO,OAAA;AAAE,mGAAA,SAAS,OAAA;AAAE,mGAAA,SAAS,OAAA;AAC/C,qCAA6C;AAApC,2GAAA,gBAAgB,OAAA;AAEzB,iDAAuB;AACvB,2DAAiC"}
package/jwt.d.ts CHANGED
@@ -4,7 +4,7 @@ import ms from 'ms';
4
4
  import { Secret, SecretAlgorithm } from './secret';
5
5
  import { KeyPair, KeyPairAlgorithm } from './keypair';
6
6
  import { KeyObject } from 'crypto';
7
- export type JwtPayload = Record<string, any>;
7
+ export type JwtPayload = Record<string, unknown>;
8
8
  export type JwtSigningOptions = Secret | KeyPair;
9
9
  export type JwtOptions = JwtSigningOptions & {
10
10
  expiresIn?: ms.StringValue;
package/jwt.js CHANGED
@@ -13,19 +13,13 @@ class Jwt {
13
13
  constructor(options) {
14
14
  this.expiresIn = options.expiresIn ?? this.expiresIn;
15
15
  this.notBefore = options.notBefore ?? this.notBefore;
16
- this.algorithm = options.algorithm ?? this.algorithm;
16
+ this.algorithm = options.algorithm;
17
17
  if ('secret' in options && options.secret) {
18
18
  this.privateKey = this.publicKey = (0, crypto_1.createSecretKey)(Buffer.from(options.secret));
19
19
  }
20
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;
21
+ this.publicKey = options.publicKey;
22
+ this.privateKey = options.privateKey;
29
23
  }
30
24
  }
31
25
  tokenOptions() {
package/jwt.js.map CHANGED
@@ -1 +1 @@
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,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S,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;AAvDD,kBAuDC"}
package/keypair.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  /// <reference types="node" />
2
2
  import * as crypto from 'crypto';
3
- export type KeyPairAlgorithm = 'RS256' | 'RS384' | 'RS512' | 'ES256' | 'ES384' | 'ES512';
3
+ export type KeyPairAlgorithm = 'RS256' | 'RS384' | 'RS512' | 'HS256' | 'ES256' | 'ES384' | 'ES512';
4
4
  export interface KeyPair {
5
- publicKey: string | crypto.KeyObject;
6
- privateKey: string | crypto.KeyObject;
5
+ publicKey: crypto.KeyObject;
6
+ privateKey: crypto.KeyObject;
7
7
  algorithm: KeyPairAlgorithm;
8
8
  }
9
9
  export declare class KeyPairGenerator {
@@ -15,10 +15,10 @@ export declare class KeyPairGenerator {
15
15
  load(options: {
16
16
  publicKeyPath: string;
17
17
  privateKeyPath: string;
18
- }): KeyPair;
18
+ }): Promise<KeyPair>;
19
19
  save(options: {
20
20
  keys: KeyPair;
21
21
  publicKeyPath: string;
22
22
  privateKeyPath: string;
23
- }): void;
23
+ }): Promise<void>;
24
24
  }
package/keypair.js CHANGED
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.KeyPairGenerator = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const crypto = tslib_1.__importStar(require("crypto"));
6
- const fs_1 = require("fs");
6
+ const promises_1 = require("fs/promises");
7
7
  class KeyPairGenerator {
8
8
  algorithm;
9
9
  constructor(options) {
@@ -12,10 +12,18 @@ class KeyPairGenerator {
12
12
  generate() {
13
13
  let type = null;
14
14
  let modulusLength, namedCurve;
15
- if (this.algorithm.startsWith('RS')) {
15
+ if (this.algorithm === 'RS256') {
16
16
  type = 'rsa';
17
17
  modulusLength = 2048;
18
18
  }
19
+ else if (this.algorithm === 'RS384') {
20
+ type = 'rsa';
21
+ modulusLength = 3072;
22
+ }
23
+ else if (this.algorithm === 'RS512') {
24
+ type = 'rsa';
25
+ modulusLength = 4096;
26
+ }
19
27
  else if (this.algorithm === 'ES256') {
20
28
  type = 'ec';
21
29
  namedCurve = 'prime256v1';
@@ -31,17 +39,11 @@ class KeyPairGenerator {
31
39
  if (type === null) {
32
40
  throw new Error('Keypair type could not be inferred');
33
41
  }
34
- const { publicKey, privateKey } = crypto.generateKeyPairSync(type, {
42
+ const { publicKey, privateKey } = crypto.generateKeyPairSync(
43
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
44
+ type, {
35
45
  modulusLength,
36
46
  namedCurve,
37
- publicKeyEncoding: {
38
- type: 'spki',
39
- format: 'pem',
40
- },
41
- privateKeyEncoding: {
42
- type: 'pkcs8',
43
- format: 'pem',
44
- },
45
47
  });
46
48
  return {
47
49
  algorithm: this.algorithm,
@@ -49,24 +51,20 @@ class KeyPairGenerator {
49
51
  privateKey,
50
52
  };
51
53
  }
52
- load(options) {
53
- const publicKey = (0, fs_1.readFileSync)(options.publicKeyPath).toString();
54
- const privateKey = (0, fs_1.readFileSync)(options.privateKeyPath).toString();
54
+ async load(options) {
55
+ const publicKey = (await (0, promises_1.readFile)(options.publicKeyPath)).toString();
56
+ const privateKey = (await (0, promises_1.readFile)(options.privateKeyPath)).toString();
55
57
  return {
56
58
  algorithm: this.algorithm,
57
59
  publicKey: crypto.createPublicKey(publicKey),
58
60
  privateKey: crypto.createPrivateKey(privateKey),
59
61
  };
60
62
  }
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);
63
+ async save(options) {
64
+ const publicKey = options.keys.publicKey;
65
+ const privateKey = options.keys.privateKey;
66
+ await (0, promises_1.writeFile)(options.publicKeyPath, publicKey.export({ format: 'pem', type: 'spki' }));
67
+ await (0, promises_1.writeFile)(options.privateKeyPath, privateKey.export({ format: 'pem', type: 'pkcs8' }));
70
68
  }
71
69
  }
72
70
  exports.KeyPairGenerator = KeyPairGenerator;
package/keypair.js.map CHANGED
@@ -1 +1 @@
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,UAA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E,MAAM,CAAC,eAAe,CAAC,SAAS,CAAC;YAC5C,UAAU,EAAE,MAAM,CAAC,gBAAgB,CAAC,UAAU,CAAC;SAC/C,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,OAIjB;QACA,MAAM,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC;QACzC,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC;QAE3C,MAAM,IAAA,oBAAS,EACd,OAAO,CAAC,aAAa,EACrB,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CACjD,CAAC;QACF,MAAM,IAAA,oBAAS,EACd,OAAO,CAAC,cAAc,EACtB,UAAU,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CACnD,CAAC;IACH,CAAC;CACD;AAvFD,4CAuFC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@riao/iam",
3
- "version": "2.0.0",
4
- "description": "riao-iam",
3
+ "version": "3.0.0",
4
+ "description": "Identity Access Management for Riao",
5
5
  "typescript-template": {
6
6
  "base": "1.0.1",
7
7
  "jasmine": "1.0.0",
@@ -9,42 +9,22 @@
9
9
  },
10
10
  "scripts": {},
11
11
  "dependencies": {
12
- "@riao/dbal": "^3.7.1",
13
- "@riao/postgres": "^3.5.0",
14
- "@simplewebauthn/server": "^13.2.2",
12
+ "@riao/dbal": "^3.8.0",
15
13
  "bcrypt": "^6.0.0",
16
- "jsonwebtoken": "^9.0.2",
14
+ "jsonwebtoken": "^9.0.3",
17
15
  "ms": "^2.1.3"
18
16
  },
19
17
  "repository": {
20
18
  "type": "git",
21
- "url": "git+https://github.com/riao-project/riao-iam.git"
19
+ "url": "git+https://github.com/riao-iam/riao-iam.git"
22
20
  },
23
- "author": "riao-project",
21
+ "author": "riao-iam",
24
22
  "license": "MIT",
25
23
  "bugs": {
26
- "url": "https://github.com/riao-project/riao-iam/issues"
24
+ "url": "https://github.com/riao-iam/riao-iam/issues"
27
25
  },
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
- ],
26
+ "homepage": "https://github.com/riao-iam/riao-iam#readme",
27
+ "keywords": [],
48
28
  "main": "index.js",
49
29
  "types": "index.d.ts"
50
30
  }