Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hdfc-common-utility
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Roshan Suvarnkar
hdfc-common-utility
Commits
a8a12a4d
Commit
a8a12a4d
authored
1 month ago
by
roshan
Browse files
Options
Downloads
Patches
Plain Diff
where encryption logic added, redis ip changed to niveus ip
parent
ea16507a
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/utils/prisma.utils.ts
+46
-7
46 additions, 7 deletions
src/utils/prisma.utils.ts
src/utils/redis.utils.ts
+1
-1
1 addition, 1 deletion
src/utils/redis.utils.ts
with
47 additions
and
8 deletions
src/utils/prisma.utils.ts
+
46
−
7
View file @
a8a12a4d
...
...
@@ -91,20 +91,59 @@ function encryptFields(model: string, data: any): any {
}
function
encryptWhere
(
model
:
string
,
where
:
any
):
any
{
if
(
!
where
||
typeof
where
!==
'
object
'
)
return
where
;
const
fields
=
getEncryptedFields
()[
model
];
if
(
!
fields
||
!
where
)
return
where
;
const
encryptedWhere
:
any
=
{}
;
for
(
const
field
of
fields
)
{
if
(
where
[
field
])
{
where
[
field
]
=
encryptToBytes
(
where
[
field
]);
for
(
const
key
of
Object
.
keys
(
where
))
{
const
value
=
where
[
key
];
if
(
Array
.
isArray
(
value
))
{
// Handles AND / OR / NOT as arrays
encryptedWhere
[
key
]
=
value
.
map
(
v
=>
encryptWhere
(
model
,
v
));
}
else
if
(
typeof
value
===
'
object
'
&&
value
!==
null
)
{
if
(
fields
?.
includes
(
key
))
{
// Handle field-level operators like `equals`, `contains`, etc.
encryptedWhere
[
key
]
=
encryptFieldOperators
(
value
);
}
else
if
([
'
some
'
,
'
every
'
,
'
none
'
].
some
(
op
=>
Object
.
keys
(
value
).
includes
(
op
)))
{
// Handle relation filters for lists
encryptedWhere
[
key
]
=
{};
for
(
const
relOp
of
[
'
some
'
,
'
every
'
,
'
none
'
])
{
if
(
value
[
relOp
])
{
encryptedWhere
[
key
][
relOp
]
=
encryptWhere
(
key
,
value
[
relOp
]);
}
}
}
else
{
// Assume it's a nested relation
encryptedWhere
[
key
]
=
encryptWhere
(
key
,
value
);
}
}
else
{
// Primitive field value
if
(
fields
?.
includes
(
key
))
{
encryptedWhere
[
key
]
=
encryptToBytes
(
value
);
}
else
{
encryptedWhere
[
key
]
=
value
;
}
}
}
return
where
;
return
encryptedWhere
;
}
function
encryptFieldOperators
(
value
:
any
):
any
{
if
(
!
value
||
typeof
value
!==
'
object
'
)
return
encryptToBytes
(
value
);
const
encrypted
:
any
=
{};
for
(
const
op
in
value
)
{
encrypted
[
op
]
=
encryptToBytes
(
value
[
op
]);
}
return
encrypted
;
}
function
decryptFields
(
model
:
string
,
record
:
any
):
any
{
const
fields
=
getEncryptedFields
()[
model
];
if
(
!
record
||
typeof
record
!==
'
object
'
)
return
record
;
const
fields
=
getEncryptedFields
()[
model
];
// Decrypt current model's fields
if
(
fields
)
{
...
...
This diff is collapsed.
Click to expand it.
src/utils/redis.utils.ts
+
1
−
1
View file @
a8a12a4d
...
...
@@ -4,7 +4,7 @@ import { Logger } from './logger.util';
export
class
RedisWrapper
{
private
static
eventsRegistered
=
false
;
private
redisURL
:
string
=
process
.
env
.
REDIS_URL
||
"
redis://
localhost
:6379
"
;
private
redisURL
:
string
=
process
.
env
.
REDIS_URL
||
"
redis://
10.8.0.2
:6379
"
;
private
client
:
Redis
=
new
Redis
(
this
.
redisURL
);
private
subscriber
:
Redis
=
new
Redis
(
this
.
redisURL
);
private
logger
=
new
Logger
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment