mirror of
https://github.com/standardnotes/server
synced 2026-10-20 21:03:36 -04:00
feat(wip): deterministic keypairs
This commit is contained in:
@@ -11,15 +11,6 @@ export class AddPkcFields1684172607219 implements MigrationInterface {
|
||||
}),
|
||||
)
|
||||
|
||||
await queryRunner.addColumn(
|
||||
'users',
|
||||
new TableColumn({
|
||||
name: 'encrypted_private_key',
|
||||
type: 'text',
|
||||
isNullable: true,
|
||||
}),
|
||||
)
|
||||
|
||||
await queryRunner.addColumn(
|
||||
'users',
|
||||
new TableColumn({
|
||||
@@ -28,21 +19,10 @@ export class AddPkcFields1684172607219 implements MigrationInterface {
|
||||
isNullable: true,
|
||||
}),
|
||||
)
|
||||
|
||||
await queryRunner.addColumn(
|
||||
'users',
|
||||
new TableColumn({
|
||||
name: 'encrypted_signing_private_key',
|
||||
type: 'text',
|
||||
isNullable: true,
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.dropColumn('users', 'public_key')
|
||||
await queryRunner.dropColumn('users', 'encrypted_private_key')
|
||||
await queryRunner.dropColumn('users', 'signing_public_key')
|
||||
await queryRunner.dropColumn('users', 'encrypted_signing_private_key')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,15 +64,11 @@ export class AuthController implements UserServerInterface {
|
||||
kpOrigination: params.origination,
|
||||
kpCreated: params.created,
|
||||
version: params.version,
|
||||
// TODO: awaiting publishing of new standardnotes/api package
|
||||
// @TODO: awaiting publishing of new standardnotes/api package
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
publicKey: (params as any).public_key,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
encryptedPrivateKey: (params as any).encrypted_private_key,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
signingPublicKey: (params as any).signing_key_public,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
encryptedSigningPrivateKey: (params as any).encrypted_signing_private_key,
|
||||
})
|
||||
|
||||
if (!registerResult.success) {
|
||||
|
||||
@@ -66,9 +66,7 @@ export class UsersController extends BaseHttpController {
|
||||
updatedWithUserAgent: <string>request.headers['user-agent'],
|
||||
apiVersion: request.body.api,
|
||||
publicKey: request.body.public_key,
|
||||
encryptedPrivateKey: request.body.encrypted_private_key,
|
||||
signingPublicKey: request.body.signing_public_key,
|
||||
encryptedSigningPrivateKey: request.body.encrypted_signing_private_key,
|
||||
})
|
||||
|
||||
if (updateResult.success) {
|
||||
@@ -171,9 +169,7 @@ export class UsersController extends BaseHttpController {
|
||||
uuid: result.user.uuid,
|
||||
email: result.user.email,
|
||||
public_key: result.user.publicKey,
|
||||
encrypted_private_key: result.user.encryptedPrivateKey,
|
||||
signing_public_key: result.user.signingPublicKey,
|
||||
encrypted_signing_private_key: result.user.encryptedSigningPrivateKey,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -237,9 +233,7 @@ export class UsersController extends BaseHttpController {
|
||||
updatedWithUserAgent: <string>request.headers['user-agent'],
|
||||
protocolVersion: request.body.version,
|
||||
publicKey: request.body.new_public_key,
|
||||
encryptedPrivateKey: request.body.new_encrypted_private_key,
|
||||
signingPublicKey: request.body.new_signing_public_key,
|
||||
encryptedSigningPrivateKey: request.body.new_encrypted_signing_private_key,
|
||||
})
|
||||
|
||||
if (!changeCredentialsResult.success) {
|
||||
|
||||
@@ -85,14 +85,6 @@ export class ChangeCredentials implements UseCaseInterface {
|
||||
)
|
||||
}
|
||||
|
||||
if (dto.encryptedPrivateKey) {
|
||||
dto.user.encryptedPrivateKey = dto.encryptedPrivateKey
|
||||
}
|
||||
|
||||
if (dto.encryptedSigningPrivateKey) {
|
||||
dto.user.encryptedSigningPrivateKey = dto.encryptedSigningPrivateKey
|
||||
}
|
||||
|
||||
dto.user.pwNonce = dto.pwNonce
|
||||
if (dto.protocolVersion) {
|
||||
dto.user.version = dto.protocolVersion
|
||||
|
||||
@@ -12,7 +12,5 @@ export type ChangeCredentialsDTO = {
|
||||
kpOrigination?: string
|
||||
kpCreated?: string
|
||||
publicKey?: string
|
||||
encryptedPrivateKey?: string
|
||||
signingPublicKey?: string
|
||||
encryptedSigningPrivateKey?: string
|
||||
}
|
||||
|
||||
@@ -72,9 +72,7 @@ export class Register implements UseCaseInterface {
|
||||
user.encryptedServerKey = await this.crypter.generateEncryptedUserServerKey()
|
||||
user.serverEncryptionVersion = User.DEFAULT_ENCRYPTION_VERSION
|
||||
user.publicKey = dto.publicKey ?? null
|
||||
user.encryptedPrivateKey = dto.encryptedPrivateKey ?? null
|
||||
user.signingPublicKey = dto.signingPublicKey ?? null
|
||||
user.encryptedSigningPrivateKey = dto.encryptedSigningPrivateKey ?? null
|
||||
|
||||
const defaultRole = await this.roleRepository.findOneByName(RoleName.NAMES.CoreUser)
|
||||
if (defaultRole) {
|
||||
|
||||
@@ -11,7 +11,5 @@ export type RegisterDTO = {
|
||||
kpCreated?: string
|
||||
version?: string
|
||||
publicKey?: string
|
||||
encryptedPrivateKey?: string
|
||||
signingPublicKey?: string
|
||||
encryptedSigningPrivateKey?: string
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ export class UpdateUser implements UseCaseInterface {
|
||||
) {}
|
||||
|
||||
async execute(dto: UpdateUserDTO): Promise<UpdateUserResponse> {
|
||||
if (dto.user.publicKey || dto.user.encryptedPrivateKey) {
|
||||
if (dto.user.publicKey) {
|
||||
return {
|
||||
success: false,
|
||||
errorMessage:
|
||||
@@ -26,9 +26,7 @@ export class UpdateUser implements UseCaseInterface {
|
||||
}
|
||||
|
||||
dto.user.publicKey = dto.publicKey
|
||||
dto.user.encryptedPrivateKey = dto.encryptedPrivateKey
|
||||
dto.user.signingPublicKey = dto.signingPublicKey
|
||||
dto.user.encryptedSigningPrivateKey = dto.encryptedSigningPrivateKey
|
||||
dto.user.updatedAt = this.timer.getUTCDate()
|
||||
|
||||
const updatedUser = await this.userRepository.save(dto.user)
|
||||
|
||||
@@ -5,7 +5,5 @@ export type UpdateUserDTO = {
|
||||
apiVersion: string
|
||||
updatedWithUserAgent: string
|
||||
publicKey: string
|
||||
encryptedPrivateKey: string
|
||||
signingPublicKey: string
|
||||
encryptedSigningPrivateKey: string
|
||||
}
|
||||
|
||||
@@ -50,14 +50,6 @@ export class User {
|
||||
})
|
||||
declare publicKey: string | null
|
||||
|
||||
@Column({
|
||||
name: 'encrypted_private_key',
|
||||
length: 255,
|
||||
type: 'varchar',
|
||||
nullable: true,
|
||||
})
|
||||
declare encryptedPrivateKey: string | null
|
||||
|
||||
@Column({
|
||||
name: 'signing_public_key',
|
||||
length: 255,
|
||||
@@ -66,14 +58,6 @@ export class User {
|
||||
})
|
||||
declare signingPublicKey: string | null
|
||||
|
||||
@Column({
|
||||
name: 'encrypted_signing_private_key',
|
||||
length: 255,
|
||||
type: 'varchar',
|
||||
nullable: true,
|
||||
})
|
||||
declare encryptedSigningPrivateKey: string | null
|
||||
|
||||
@Column({
|
||||
name: 'server_encryption_version',
|
||||
type: 'tinyint',
|
||||
|
||||
@@ -3,5 +3,5 @@ export type SimpleUserProjection = {
|
||||
email: string
|
||||
protocolVersion: string
|
||||
publicKey?: string
|
||||
encryptedPrivateKey?: string
|
||||
signingPublicKey?: string
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ export class UserProjector implements ProjectorInterface<User> {
|
||||
email: user.email,
|
||||
protocolVersion: user.version,
|
||||
publicKey: user.publicKey ?? undefined,
|
||||
encryptedPrivateKey: user.encryptedPrivateKey ?? undefined,
|
||||
signingPublicKey: user.signingPublicKey ?? undefined,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user