diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2023-09-08 14:05:03 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-09-08 14:05:03 +0900 |
| commit | ff9a65e8faa46a101d3ed3dc8915dd1f269ef556 (patch) | |
| tree | a6b1ae734e61da58b4205cd08a505ce392b317a9 /packages/backend/src/models/entities | |
| parent | Update CHANGELOG.md (diff) | |
| download | misskey-ff9a65e8faa46a101d3ed3dc8915dd1f269ef556.tar.gz misskey-ff9a65e8faa46a101d3ed3dc8915dd1f269ef556.tar.bz2 misskey-ff9a65e8faa46a101d3ed3dc8915dd1f269ef556.zip | |
feat: passkey support (#11804)
https://github.com/MisskeyIO/misskey/pull/149
Diffstat (limited to 'packages/backend/src/models/entities')
| -rw-r--r-- | packages/backend/src/models/entities/AttestationChallenge.ts | 51 | ||||
| -rw-r--r-- | packages/backend/src/models/entities/UserSecurityKey.ts | 37 |
2 files changed, 30 insertions, 58 deletions
diff --git a/packages/backend/src/models/entities/AttestationChallenge.ts b/packages/backend/src/models/entities/AttestationChallenge.ts deleted file mode 100644 index dace378eff..0000000000 --- a/packages/backend/src/models/entities/AttestationChallenge.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SPDX-FileCopyrightText: syuilo and other misskey contributors - * SPDX-License-Identifier: AGPL-3.0-only - */ - -import { PrimaryColumn, Entity, JoinColumn, Column, ManyToOne, Index } from 'typeorm'; -import { id } from '../id.js'; -import { MiUser } from './User.js'; - -@Entity('attestation_challenge') -export class MiAttestationChallenge { - @PrimaryColumn(id()) - public id: string; - - @Index() - @PrimaryColumn(id()) - public userId: MiUser['id']; - - @ManyToOne(type => MiUser, { - onDelete: 'CASCADE', - }) - @JoinColumn() - public user: MiUser | null; - - @Index() - @Column('varchar', { - length: 64, - comment: 'Hex-encoded sha256 hash of the challenge.', - }) - public challenge: string; - - @Column('timestamp with time zone', { - comment: 'The date challenge was created for expiry purposes.', - }) - public createdAt: Date; - - @Column('boolean', { - comment: - 'Indicates that the challenge is only for registration purposes if true to prevent the challenge for being used as authentication.', - default: false, - }) - public registrationChallenge: boolean; - - constructor(data: Partial<MiAttestationChallenge>) { - if (data == null) return; - - for (const [k, v] of Object.entries(data)) { - (this as any)[k] = v; - } - } -} diff --git a/packages/backend/src/models/entities/UserSecurityKey.ts b/packages/backend/src/models/entities/UserSecurityKey.ts index ce1c270d46..96dd27d083 100644 --- a/packages/backend/src/models/entities/UserSecurityKey.ts +++ b/packages/backend/src/models/entities/UserSecurityKey.ts @@ -24,24 +24,47 @@ export class MiUserSecurityKey { @JoinColumn() public user: MiUser | null; + @Column('varchar', { + comment: 'User-defined name for this key', + length: 30, + }) + public name: string; + @Index() @Column('varchar', { - comment: - 'Variable-length public key used to verify attestations (hex-encoded).', + comment: 'The public key of the UserSecurityKey, hex-encoded.', }) public publicKey: string; + @Column('bigint', { + comment: 'The number of times the UserSecurityKey was validated.', + default: 0, + }) + public counter: number; + @Column('timestamp with time zone', { - comment: - 'The date of the last time the UserSecurityKey was successfully validated.', + comment: 'Timestamp of the last time the UserSecurityKey was used.', + default: () => 'now()', }) public lastUsed: Date; @Column('varchar', { - comment: 'User-defined name for this key', - length: 30, + comment: 'The type of Backup Eligibility in authenticator data', + length: 32, nullable: true, }) - public name: string; + public credentialDeviceType: string | null; + + @Column('boolean', { + comment: 'Whether or not the credential has been backed up', + nullable: true, + }) + public credentialBackedUp: boolean | null; + + @Column('varchar', { + comment: 'The type of the credential returned by the browser', + length: 32, array: true, nullable: true, + }) + public transports: string[] | null; constructor(data: Partial<MiUserSecurityKey>) { if (data == null) return; |