@@ -15,29 +15,45 @@ internal TokenHelper(string endpoint, string authKey, string secretKey)
15
15
_uid2ClientHelper = new Uid2ClientHelper ( endpoint , authKey , secretKey ) ;
16
16
}
17
17
18
+ internal static DecryptionResponse TokenDetailsToDecryptionResponse ( TokenDetails tokenDetails )
19
+ {
20
+ string uid = tokenDetails . idString ; //todo, some errors should blank this out
21
+ int siteKeySiteId = 0 ; //todo
22
+
23
+ return new DecryptionResponse ( tokenDetails . decryptionStatus , uid , tokenDetails . established , tokenDetails . siteId , siteKeySiteId , tokenDetails . identityType , tokenDetails . tokenVersion ,
24
+ tokenDetails . privacyBits ? . IsClientSideGenerated , tokenDetails . expiry ) ;
25
+ }
26
+
18
27
internal DecryptionResponse Decrypt ( string token , DateTime now , string domainOrAppNameFromBidRequest , ClientType clientType )
28
+ {
29
+ var tokenDetails = DecryptTokenDetails ( token , now , domainOrAppNameFromBidRequest , clientType ) ;
30
+ return TokenDetailsToDecryptionResponse ( tokenDetails ) ;
31
+ }
32
+
33
+ internal TokenDetails DecryptTokenDetails ( string token , DateTime now , string domainOrAppNameFromBidRequest , ClientType clientType )
19
34
{
20
35
var container = Volatile . Read ( ref _container ) ;
21
36
if ( container == null )
22
37
{
23
- return DecryptionResponse . MakeError ( DecryptionStatus . NotInitialized ) ;
38
+ return new TokenDetails ( DecryptionStatus . NotInitialized ) ;
24
39
}
25
40
26
41
if ( ! container . IsValid ( now ) )
27
42
{
28
- return DecryptionResponse . MakeError ( DecryptionStatus . KeysNotSynced ) ;
43
+ return new TokenDetails ( DecryptionStatus . KeysNotSynced ) ;
29
44
}
30
45
31
46
try
32
47
{
33
- return UID2Encryption . Decrypt ( token , container , now , domainOrAppNameFromBidRequest , container . IdentityScope , clientType ) ;
48
+ return UID2Encryption . DecryptTokenDetails ( token , container , now , domainOrAppNameFromBidRequest , container . IdentityScope , clientType ) ;
34
49
}
35
50
catch ( Exception )
36
51
{
37
- return DecryptionResponse . MakeError ( DecryptionStatus . InvalidPayload ) ;
52
+ return new TokenDetails ( DecryptionStatus . InvalidPayload ) ;
38
53
}
39
54
}
40
55
56
+
41
57
internal EncryptionDataResponse Encrypt ( string rawUid , DateTime now )
42
58
{
43
59
var container = Volatile . Read ( ref _container ) ;
0 commit comments