const encryptDecryptTransform = S.transformOrFail(
S.Struct({
iv: S.String,
content: S.String,
}),
S.String.pipe(S.Redacted),
{
strict: true,
decode: (input) =>
E.gen(function* () {
const { stringDecrypt } = yield* StringEncryptionService
const appKey = yield* appKeyConfig
return yield* stringDecrypt({
encryptedData: input,
secretKey: appKey,
})
}).pipe(E.provide(StringEncryptionService.live)),
encode: (input) =>
E.gen(function* () {
const { stringEncrypt } = yield* StringEncryptionService
const appKey = yield* appKeyConfig
return yield* stringEncrypt({
string: input,
secretKey: appKey,
})
}).pipe(E.provide(StringEncryptionService.live)),
},
)
const encryptDecryptTransform = S.transformOrFail(
S.Struct({
iv: S.String,
content: S.String,
}),
S.String.pipe(S.Redacted),
{
strict: true,
decode: (input) =>
E.gen(function* () {
const { stringDecrypt } = yield* StringEncryptionService
const appKey = yield* appKeyConfig
return yield* stringDecrypt({
encryptedData: input,
secretKey: appKey,
})
}).pipe(E.provide(StringEncryptionService.live)),
encode: (input) =>
E.gen(function* () {
const { stringEncrypt } = yield* StringEncryptionService
const appKey = yield* appKeyConfig
return yield* stringEncrypt({
string: input,
secretKey: appKey,
})
}).pipe(E.provide(StringEncryptionService.live)),
},
)