1- import { FingerprintServerApiClient , Region , RequestError , TooManyRequestsError } from '@fingerprint/node-sdk'
1+ import {
2+ FingerprintServerApiClient ,
3+ Region ,
4+ RequestError ,
5+ TooManyRequestsError ,
6+ unsealEventsResponse ,
7+ DecryptionAlgorithm ,
8+ } from '@fingerprint/node-sdk'
29import { config } from 'dotenv'
310import assert from 'node:assert'
411config ( )
@@ -128,6 +135,34 @@ async function validateOldestOrder(client, start, end) {
128135 }
129136}
130137
138+ async function validateSealedResult ( ) {
139+ const sealedData = process . env . BASE64_SEALED_RESULT
140+ const decryptionKey = process . env . BASE64_KEY
141+
142+ if ( ! sealedData || ! decryptionKey ) {
143+ // In CI the fixture must be present; locally we skip so contributors don't need it.
144+ if ( process . env . CI ) {
145+ throw new Error ( 'BASE64_SEALED_RESULT and BASE64_KEY must be set in CI for sealed results validation' )
146+ }
147+ console . log ( 'BASE64_SEALED_RESULT or BASE64_KEY not set, skipping sealed results validation' )
148+ return
149+ }
150+
151+ console . log ( 'Validating sealed result...' )
152+ const unsealed = await unsealEventsResponse ( Buffer . from ( sealedData , 'base64' ) , [
153+ {
154+ key : Buffer . from ( decryptionKey , 'base64' ) ,
155+ algorithm : DecryptionAlgorithm . Aes256Gcm ,
156+ } ,
157+ ] )
158+
159+ if ( ! unsealed ?. identification ?. visitor_id ) {
160+ throw new Error ( 'Unsealed result missing identification.visitor_id' )
161+ }
162+
163+ console . log ( 'Sealed result validation works!' )
164+ }
165+
131166async function main ( ) {
132167 try {
133168 const client = createClient ( )
@@ -141,6 +176,8 @@ async function main() {
141176
142177 await validateOldestOrder ( client , start , end )
143178
179+ await validateSealedResult ( )
180+
144181 if ( ruleset_id ) {
145182 await validateRulesetEvaluationForBlock ( client , start , end )
146183 await validateRulesetEvaluationForAllow ( client , start , end )
0 commit comments