MCPcopy Create free account
hub / github.com/FlowiseAI/Flowise / decryptToken

Function decryptToken

packages/server/src/enterprise/utils/tempTokenUtils.ts:46–62  ·  view source on GitHub ↗
(stringToDecrypt: string)

Source from the content-addressed store, hash-verified

44
45// Decrypt token using the inverse of encryption crypto algorithm
46export const decryptToken = (stringToDecrypt: string): string | undefined => {
47 try {
48 const key = crypto.createHash('sha256').update(getTokenHashSecret()).digest()
49
50 let textParts = stringToDecrypt.split(':')
51 let iv = Buffer.from(textParts.shift() as string, 'hex')
52 let encryptedText = Buffer.from(textParts.join(':'), 'hex')
53 let decipher = crypto.createDecipheriv('aes-256-cbc', key, iv)
54 let decrypted = decipher.update(encryptedText)
55
56 const result = Buffer.concat([decrypted, decipher.final()])
57
58 return result.toString()
59 } catch (error) {
60 return undefined
61 }
62}
63
64// Extract userUUID from decrypted token string
65export const getUserUUIDFromToken = (token: string): string | undefined => {

Callers 2

jwtVerifyFunction · 0.90

Calls 2

getTokenHashSecretFunction · 0.90
updateMethod · 0.65

Tested by

no test coverage detected