fix(snjs): refreshing sessions (#2106)
* fix(snjs): refreshing sessions * fix(snjs): bring back all tests * fix(snjs): passing session tokens values * fix(api): remove redundant specs * fix(snjs): add projecting sessions to storage values * fix(snjs): deps tree * fix(snjs): bring back subscription tests * fix(snjs): remove only tag for migration tests * fix(snjs): session specs
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import { LegacySession, MapperInterface } from '@standardnotes/domain-core'
|
||||
|
||||
export class LegacySessionStorageMapper implements MapperInterface<LegacySession, Record<string, unknown>> {
|
||||
toDomain(projection: Record<string, unknown>): LegacySession {
|
||||
const { jwt } = projection
|
||||
|
||||
const legacySessionOrError = LegacySession.create(jwt as string)
|
||||
if (legacySessionOrError.isFailed()) {
|
||||
throw new Error(legacySessionOrError.getError())
|
||||
}
|
||||
|
||||
return legacySessionOrError.getValue()
|
||||
}
|
||||
|
||||
toProjection(domain: LegacySession): Record<string, unknown> {
|
||||
return {
|
||||
jwt: domain.accessToken,
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user