| 51 | // const surrogateType = 'SOME_INFO_TYPE_DEID'; |
| 52 | |
| 53 | async function deidentifyWithFpe() { |
| 54 | // Construct FPE config |
| 55 | const cryptoReplaceFfxFpeConfig = { |
| 56 | cryptoKey: { |
| 57 | kmsWrapped: { |
| 58 | wrappedKey: wrappedKey, |
| 59 | cryptoKeyName: keyName, |
| 60 | }, |
| 61 | }, |
| 62 | commonAlphabet: alphabet, |
| 63 | }; |
| 64 | if (surrogateType) { |
| 65 | cryptoReplaceFfxFpeConfig.surrogateInfoType = { |
| 66 | name: surrogateType, |
| 67 | }; |
| 68 | } |
| 69 | |
| 70 | // Construct deidentification request |
| 71 | const item = {value: string}; |
| 72 | const request = { |
| 73 | parent: `projects/${projectId}/locations/global`, |
| 74 | deidentifyConfig: { |
| 75 | infoTypeTransformations: { |
| 76 | transformations: [ |
| 77 | { |
| 78 | primitiveTransformation: { |
| 79 | cryptoReplaceFfxFpeConfig: cryptoReplaceFfxFpeConfig, |
| 80 | }, |
| 81 | }, |
| 82 | ], |
| 83 | }, |
| 84 | }, |
| 85 | item: item, |
| 86 | }; |
| 87 | |
| 88 | // Run deidentification request |
| 89 | const [response] = await dlp.deidentifyContent(request); |
| 90 | const deidentifiedItem = response.item; |
| 91 | console.log(deidentifiedItem.value); |
| 92 | } |
| 93 | deidentifyWithFpe(); |
| 94 | // [END dlp_deidentify_fpe] |
| 95 | } |