feat: replace private workspaces with private usernames (#1783)
This commit is contained in:
19
packages/encryption/src/Domain/Username/PrivateUsername.ts
Normal file
19
packages/encryption/src/Domain/Username/PrivateUsername.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { PureCryptoInterface } from '@standardnotes/sncrypto-common'
|
||||
|
||||
const PrivateUserNameV1 = 'StandardNotes-PrivateUsername-V1'
|
||||
|
||||
export async function ComputePrivateUsername(
|
||||
crypto: PureCryptoInterface,
|
||||
usernameInput: string,
|
||||
): Promise<string | undefined> {
|
||||
const result = await crypto.hmac256(
|
||||
await crypto.sha256(PrivateUserNameV1),
|
||||
await crypto.sha256(usernameInput.trim().toLowerCase()),
|
||||
)
|
||||
|
||||
if (result == undefined) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
import { PureCryptoInterface } from '@standardnotes/sncrypto-common'
|
||||
|
||||
export async function ComputePrivateWorkspaceIdentifier(
|
||||
crypto: PureCryptoInterface,
|
||||
userphrase: string,
|
||||
name: string,
|
||||
): Promise<string | undefined> {
|
||||
const identifier = await crypto.hmac256(
|
||||
await crypto.sha256(name.trim().toLowerCase()),
|
||||
await crypto.sha256(userphrase.trim().toLowerCase()),
|
||||
)
|
||||
|
||||
if (identifier == undefined) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
return identifier
|
||||
}
|
||||
@@ -34,4 +34,4 @@ export * from './Types/EncryptedParameters'
|
||||
export * from './Types/ItemAuthenticatedData'
|
||||
export * from './Types/LegacyAttachedData'
|
||||
export * from './Types/RootKeyEncryptedAuthenticatedData'
|
||||
export * from './Workspace/PrivateWorkspace'
|
||||
export * from './Username/PrivateUsername'
|
||||
|
||||
Reference in New Issue
Block a user