diff --git a/src/migration/1662882569739-tokentypes.ts b/src/migration/1662882569739-tokentypes.ts new file mode 100644 index 0000000..405a606 --- /dev/null +++ b/src/migration/1662882569739-tokentypes.ts @@ -0,0 +1,27 @@ +import { MigrationInterface, QueryRunner } from 'typeorm'; + +export class tokentypes1662882569739 implements MigrationInterface { + name = 'tokentypes1662882569739'; + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `ALTER TABLE \`user_token\` ADD \`nonce\` text NULL`, + ); + await queryRunner.query( + `ALTER TABLE \`o_auth2_token\` ADD \`nonce\` text NULL`, + ); + await queryRunner.query( + `ALTER TABLE \`user_token\` CHANGE \`type\` \`type\` enum ('generic', 'activation', 'deactivation', 'password', 'login', 'gdpr', 'totp', 'public_key', 'recovery') NOT NULL`, + ); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `ALTER TABLE \`user_token\` CHANGE \`type\` \`type\` enum ('generic', 'activation', 'deactivation', 'password', 'login', 'gdpr', 'totp', 'recovery') NOT NULL`, + ); + await queryRunner.query(`ALTER TABLE \`user_token\` DROP COLUMN \`nonce\``); + await queryRunner.query( + `ALTER TABLE \`o_auth2_token\` DROP COLUMN \`nonce\``, + ); + } +} diff --git a/src/modules/objects/oauth2-token/oauth2-token.entity.ts b/src/modules/objects/oauth2-token/oauth2-token.entity.ts index 6fe355b..b9830ea 100644 --- a/src/modules/objects/oauth2-token/oauth2-token.entity.ts +++ b/src/modules/objects/oauth2-token/oauth2-token.entity.ts @@ -26,6 +26,9 @@ export class OAuth2Token { @Column({ nullable: false, type: 'text' }) token: string; + @Column({ nullable: true, type: 'text' }) + nonce: string; + @Column({ type: 'text', nullable: true }) scope: string; diff --git a/src/modules/objects/user-token/user-token.entity.ts b/src/modules/objects/user-token/user-token.entity.ts index ce7e6fc..25f0ee8 100644 --- a/src/modules/objects/user-token/user-token.entity.ts +++ b/src/modules/objects/user-token/user-token.entity.ts @@ -15,6 +15,7 @@ export enum UserTokenType { LOGIN = 'login', GDPR = 'gdpr', TOTP = 'totp', + PUBLIC_KEY = 'public_key', RECOVERY = 'recovery', } @@ -26,6 +27,9 @@ export class UserToken { @Column({ nullable: false, type: 'text' }) token: string; + @Column({ nullable: true, type: 'text' }) + nonce: string; + @Column({ type: 'enum', enum: UserTokenType, nullable: false }) type: UserTokenType;