@transcend-io/cli 8.38.0 → 8.38.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/README.md +24 -8
  2. package/dist/{api-keys-DKB-2PVX.cjs → api-keys-DMPYZTne.cjs} +2 -2
  3. package/dist/{api-keys-DKB-2PVX.cjs.map → api-keys-DMPYZTne.cjs.map} +1 -1
  4. package/dist/{app-BUVlVXyg.cjs → app-bPlpZQj_.cjs} +18 -18
  5. package/dist/{app-BUVlVXyg.cjs.map → app-bPlpZQj_.cjs.map} +1 -1
  6. package/dist/bin/bash-complete.cjs +1 -1
  7. package/dist/bin/cli.cjs +1 -1
  8. package/dist/bin/deprecated-command.cjs +1 -1
  9. package/dist/{code-scanning-BAPEq8Xx.cjs → code-scanning-D6YstOWo.cjs} +2 -2
  10. package/dist/{code-scanning-BAPEq8Xx.cjs.map → code-scanning-D6YstOWo.cjs.map} +1 -1
  11. package/dist/{command-DM9vqmJO.cjs → command-C39HGpGR.cjs} +2 -2
  12. package/dist/{command-DM9vqmJO.cjs.map → command-C39HGpGR.cjs.map} +1 -1
  13. package/dist/{consent-manager-C6jfR89E.cjs → consent-manager-C3UVAKd_.cjs} +2 -2
  14. package/dist/{consent-manager-C6jfR89E.cjs.map → consent-manager-C3UVAKd_.cjs.map} +1 -1
  15. package/dist/{constants-BvCUdOlO.cjs → constants-gJm1eQH0.cjs} +2 -2
  16. package/dist/{constants-BvCUdOlO.cjs.map → constants-gJm1eQH0.cjs.map} +1 -1
  17. package/dist/{cron-BO5TvkmX.cjs → cron-NLlyCiml.cjs} +2 -2
  18. package/dist/{cron-BO5TvkmX.cjs.map → cron-NLlyCiml.cjs.map} +1 -1
  19. package/dist/{data-inventory-Bc9DbWkU.cjs → data-inventory-a9Nz9lUO.cjs} +4 -4
  20. package/dist/{data-inventory-Bc9DbWkU.cjs.map → data-inventory-a9Nz9lUO.cjs.map} +1 -1
  21. package/dist/{dataFlowsToDataSilos-CRqkUmje.cjs → dataFlowsToDataSilos-BJh0hzJI.cjs} +2 -2
  22. package/dist/{dataFlowsToDataSilos-CRqkUmje.cjs.map → dataFlowsToDataSilos-BJh0hzJI.cjs.map} +1 -1
  23. package/dist/{impl-DeGnhjhF.cjs → impl--RUTvJko.cjs} +2 -2
  24. package/dist/{impl-DeGnhjhF.cjs.map → impl--RUTvJko.cjs.map} +1 -1
  25. package/dist/{impl-CwX4DDy7.cjs → impl-6vrF2_M3.cjs} +2 -2
  26. package/dist/{impl-CwX4DDy7.cjs.map → impl-6vrF2_M3.cjs.map} +1 -1
  27. package/dist/{impl-B73GDL8C.cjs → impl-BAZ34gSp.cjs} +2 -2
  28. package/dist/{impl-B73GDL8C.cjs.map → impl-BAZ34gSp.cjs.map} +1 -1
  29. package/dist/{impl-DnAz_55s.cjs → impl-BAs-7neS.cjs} +2 -2
  30. package/dist/{impl-DnAz_55s.cjs.map → impl-BAs-7neS.cjs.map} +1 -1
  31. package/dist/{impl-D5YmaznJ.cjs → impl-BF44h4oH.cjs} +2 -2
  32. package/dist/{impl-D5YmaznJ.cjs.map → impl-BF44h4oH.cjs.map} +1 -1
  33. package/dist/{impl-BgTpF43h.cjs → impl-BKXkRTVx.cjs} +2 -2
  34. package/dist/{impl-BgTpF43h.cjs.map → impl-BKXkRTVx.cjs.map} +1 -1
  35. package/dist/{impl-Cd8q5X4H.cjs → impl-BN8N7BHo.cjs} +2 -2
  36. package/dist/{impl-Cd8q5X4H.cjs.map → impl-BN8N7BHo.cjs.map} +1 -1
  37. package/dist/{impl-CniCF9_X.cjs → impl-BO1fP5DL.cjs} +2 -2
  38. package/dist/{impl-CniCF9_X.cjs.map → impl-BO1fP5DL.cjs.map} +1 -1
  39. package/dist/impl-BRAiiMt3.cjs +2 -0
  40. package/dist/impl-BRAiiMt3.cjs.map +1 -0
  41. package/dist/{impl-CrUSLLov.cjs → impl-BRNha4nQ.cjs} +2 -2
  42. package/dist/{impl-CrUSLLov.cjs.map → impl-BRNha4nQ.cjs.map} +1 -1
  43. package/dist/{impl-C7tMMwk6.cjs → impl-Ba1d91O1.cjs} +2 -2
  44. package/dist/{impl-C7tMMwk6.cjs.map → impl-Ba1d91O1.cjs.map} +1 -1
  45. package/dist/{impl-CEUSknYB.cjs → impl-Bgp_TuxN.cjs} +2 -2
  46. package/dist/{impl-CEUSknYB.cjs.map → impl-Bgp_TuxN.cjs.map} +1 -1
  47. package/dist/{impl-OpdHSaSE.cjs → impl-BreaZGaV.cjs} +2 -2
  48. package/dist/{impl-OpdHSaSE.cjs.map → impl-BreaZGaV.cjs.map} +1 -1
  49. package/dist/{impl-CpJSuHLj.cjs → impl-BzAwMfNS.cjs} +2 -2
  50. package/dist/{impl-CpJSuHLj.cjs.map → impl-BzAwMfNS.cjs.map} +1 -1
  51. package/dist/{impl-CS2vnMmW.cjs → impl-C0eKnbO8.cjs} +2 -2
  52. package/dist/{impl-CS2vnMmW.cjs.map → impl-C0eKnbO8.cjs.map} +1 -1
  53. package/dist/{impl-B-N9AGP8.cjs → impl-C2kTLgRr.cjs} +2 -2
  54. package/dist/{impl-B-N9AGP8.cjs.map → impl-C2kTLgRr.cjs.map} +1 -1
  55. package/dist/{impl-C3SuSalX.cjs → impl-CA7X_TDD.cjs} +2 -2
  56. package/dist/{impl-C3SuSalX.cjs.map → impl-CA7X_TDD.cjs.map} +1 -1
  57. package/dist/{impl-CdxiD7Yy.cjs → impl-CC0T0jNd.cjs} +2 -2
  58. package/dist/{impl-CdxiD7Yy.cjs.map → impl-CC0T0jNd.cjs.map} +1 -1
  59. package/dist/{impl-GcBLFRSN.cjs → impl-CJT35FpG.cjs} +2 -2
  60. package/dist/{impl-GcBLFRSN.cjs.map → impl-CJT35FpG.cjs.map} +1 -1
  61. package/dist/{impl-B2rIghgi.cjs → impl-CTXPMoXc.cjs} +3 -3
  62. package/dist/{impl-B2rIghgi.cjs.map → impl-CTXPMoXc.cjs.map} +1 -1
  63. package/dist/{impl-VkDcqzOv.cjs → impl-CUScCLAS.cjs} +2 -2
  64. package/dist/{impl-VkDcqzOv.cjs.map → impl-CUScCLAS.cjs.map} +1 -1
  65. package/dist/{impl-CO2YHWDs.cjs → impl-CYmPZogW.cjs} +2 -2
  66. package/dist/{impl-CO2YHWDs.cjs.map → impl-CYmPZogW.cjs.map} +1 -1
  67. package/dist/{impl-BJAX3aRj.cjs → impl-Ccd0FaOU.cjs} +2 -2
  68. package/dist/{impl-BJAX3aRj.cjs.map → impl-Ccd0FaOU.cjs.map} +1 -1
  69. package/dist/{impl-CBxlf2zy.cjs → impl-CmKWcYiV.cjs} +2 -2
  70. package/dist/{impl-CBxlf2zy.cjs.map → impl-CmKWcYiV.cjs.map} +1 -1
  71. package/dist/{impl-eo3bGO0E.cjs → impl-CqshC7my.cjs} +2 -2
  72. package/dist/{impl-eo3bGO0E.cjs.map → impl-CqshC7my.cjs.map} +1 -1
  73. package/dist/{impl-UF7LI32t.cjs → impl-Cypfgm4t.cjs} +2 -2
  74. package/dist/{impl-UF7LI32t.cjs.map → impl-Cypfgm4t.cjs.map} +1 -1
  75. package/dist/{impl-BCKGKwcc.cjs → impl-D2SWeIGe.cjs} +2 -2
  76. package/dist/{impl-BCKGKwcc.cjs.map → impl-D2SWeIGe.cjs.map} +1 -1
  77. package/dist/{impl-ByMM0BtF.cjs → impl-DLwIQVA6.cjs} +2 -2
  78. package/dist/{impl-ByMM0BtF.cjs.map → impl-DLwIQVA6.cjs.map} +1 -1
  79. package/dist/{impl-DIQtkPMh.cjs → impl-DMm4lt-A.cjs} +2 -2
  80. package/dist/{impl-DIQtkPMh.cjs.map → impl-DMm4lt-A.cjs.map} +1 -1
  81. package/dist/{impl-DN-bpfF3.cjs → impl-DRsuGuRx.cjs} +2 -2
  82. package/dist/{impl-DN-bpfF3.cjs.map → impl-DRsuGuRx.cjs.map} +1 -1
  83. package/dist/{impl-C_Ap9B9z.cjs → impl-DSrvfkVp.cjs} +2 -2
  84. package/dist/{impl-C_Ap9B9z.cjs.map → impl-DSrvfkVp.cjs.map} +1 -1
  85. package/dist/{impl-B-JHBYrZ.cjs → impl-DZMWJNLE.cjs} +2 -2
  86. package/dist/{impl-B-JHBYrZ.cjs.map → impl-DZMWJNLE.cjs.map} +1 -1
  87. package/dist/{impl-DSnwLiWc.cjs → impl-DbqAvW7X.cjs} +2 -2
  88. package/dist/{impl-DSnwLiWc.cjs.map → impl-DbqAvW7X.cjs.map} +1 -1
  89. package/dist/{impl-DyNE7_Z9.cjs → impl-Dl78xJu6.cjs} +2 -2
  90. package/dist/{impl-DyNE7_Z9.cjs.map → impl-Dl78xJu6.cjs.map} +1 -1
  91. package/dist/{impl-DmV67HHX.cjs → impl-Dvpc-Qa5.cjs} +2 -2
  92. package/dist/{impl-DmV67HHX.cjs.map → impl-Dvpc-Qa5.cjs.map} +1 -1
  93. package/dist/{impl-Bm3SCfN0.cjs → impl-DySeNL1m.cjs} +2 -2
  94. package/dist/{impl-Bm3SCfN0.cjs.map → impl-DySeNL1m.cjs.map} +1 -1
  95. package/dist/{impl-C3h9aEfs.cjs → impl-Fj-Esff-.cjs} +2 -2
  96. package/dist/{impl-C3h9aEfs.cjs.map → impl-Fj-Esff-.cjs.map} +1 -1
  97. package/dist/{impl-BwRZ2Uh4.cjs → impl-W6tVmm8N.cjs} +2 -2
  98. package/dist/{impl-BwRZ2Uh4.cjs.map → impl-W6tVmm8N.cjs.map} +1 -1
  99. package/dist/{impl-DxCRgxen.cjs → impl-WphnR0cX.cjs} +2 -2
  100. package/dist/{impl-DxCRgxen.cjs.map → impl-WphnR0cX.cjs.map} +1 -1
  101. package/dist/{impl-CPVqTQlt.cjs → impl-YNAicr-z.cjs} +2 -2
  102. package/dist/{impl-CPVqTQlt.cjs.map → impl-YNAicr-z.cjs.map} +1 -1
  103. package/dist/{impl-CvNge9fm.cjs → impl-jEpWgC2N.cjs} +2 -2
  104. package/dist/{impl-CvNge9fm.cjs.map → impl-jEpWgC2N.cjs.map} +1 -1
  105. package/dist/{impl-NaNBTYBy.cjs → impl-x2P-_Pk2.cjs} +3 -3
  106. package/dist/{impl-NaNBTYBy.cjs.map → impl-x2P-_Pk2.cjs.map} +1 -1
  107. package/dist/index.cjs +3 -3
  108. package/dist/index.d.cts +135 -7
  109. package/dist/manual-enrichment-DTVJo7hP.cjs +2 -0
  110. package/dist/{manual-enrichment-D_kDV9gc.cjs.map → manual-enrichment-DTVJo7hP.cjs.map} +1 -1
  111. package/dist/{pooling-D9eTOOjE.cjs → pooling-C-TYBnHI.cjs} +2 -2
  112. package/dist/{pooling-D9eTOOjE.cjs.map → pooling-C-TYBnHI.cjs.map} +1 -1
  113. package/dist/{preference-management-CE64qiAB.cjs → preference-management-Ch77Yxod.cjs} +6 -6
  114. package/dist/{preference-management-CE64qiAB.cjs.map → preference-management-Ch77Yxod.cjs.map} +1 -1
  115. package/dist/{syncConfigurationToTranscend-BipGaTT0.cjs → syncConfigurationToTranscend-s-cjtUI3.cjs} +133 -127
  116. package/dist/syncConfigurationToTranscend-s-cjtUI3.cjs.map +1 -0
  117. package/dist/{uploadConsents-C7SPWTIr.cjs → uploadConsents-CDkk_sWY.cjs} +2 -2
  118. package/dist/{uploadConsents-C7SPWTIr.cjs.map → uploadConsents-CDkk_sWY.cjs.map} +1 -1
  119. package/package.json +1 -1
  120. package/dist/impl-C0Uwz7KR.cjs +0 -2
  121. package/dist/impl-C0Uwz7KR.cjs.map +0 -1
  122. package/dist/manual-enrichment-D_kDV9gc.cjs +0 -2
  123. package/dist/syncConfigurationToTranscend-BipGaTT0.cjs.map +0 -1
@@ -1,2 +1,2 @@
1
- const e=require(`./chunk-Bmb41Sf3.cjs`),t=require(`./constants-BvCUdOlO.cjs`),n=require(`./syncConfigurationToTranscend-BipGaTT0.cjs`),r=require(`./logger-DQwEYtSS.cjs`);let i=require(`@transcend-io/type-utils`),a=require(`colors`);a=e.t(a);let o=require(`io-ts`);o=e.t(o);let s=require(`cli-progress`);s=e.t(s);let c=require(`crypto`);c=e.t(c);let l=require(`jsonwebtoken`);l=e.t(l);function u(e,t,n){let r=Buffer.from(n,`base64`),i=Buffer.from(t,`base64`),a=Buffer.from(`A65959A6`,`hex`),o=c.createCipheriv(`id-aes256-wrap-pad`,i,a),s={encryptedIdentifier:Buffer.concat([o.update(e),o.final()]).toString(`base64`)};return l.sign(s,r,{algorithm:`HS384`})}const d=/^[0-9][Y|N]([Y|N])[Y|N]$/,f=o.record(o.string,o.union([o.boolean,o.literal(`Auto`)]));async function p({base64EncryptionKey:e,base64SigningKey:o,preferences:c,partition:l,concurrency:p=100,transcendUrl:m=t.o}){let h=n.$r(m),g=c.filter(e=>e.usp&&!d.test(e.usp));if(g.length>0)throw Error(`Received invalid usp strings: ${JSON.stringify(g,null,2)}`);let _=c.map((e,t)=>[e,t]).filter(([e])=>{if(!e.purposes)return!1;try{return(0,i.decodeCodec)(f,e.purposes),!1}catch{return!0}});if(_.length>0)throw Error(`Received invalid purpose maps: ${JSON.stringify(_,null,2)}`);let v=c.filter(e=>!e.usp&&!e.purposes);if(v.length>0)throw Error(`Received invalid inputs, expected either purposes or usp to be defined: ${JSON.stringify(v,null,2)}`);r.t.info(a.default.magenta(`Uploading ${c.length} user preferences to partition ${l}`));let y=new Date().getTime(),b=new s.default.SingleBar({},s.default.Presets.shades_classic),x=0;b.start(c.length,0),await n.Ts(c,async({userId:t,confirmed:n=`true`,updated:s,prompted:c,purposes:p,...m})=>{let g=u(t,e,o),[,_]=m.usp&&d.exec(m.usp)||[],v={token:g,partition:l,consent:{confirmed:n===`true`,purposes:p?(0,i.decodeCodec)(f,p):m.usp?{SaleOfInfo:_===`Y`}:{},...s?{updated:s===`true`}:{},...c?{prompted:c===`true`}:{},...m}};try{await h.post(`sync`,{json:v}).json()}catch(e){try{let t=JSON.parse(e?.response?.body||`{}`);t.error&&r.t.error(a.default.red(`Error: ${t.error}`))}catch{}throw Error(`Received an error from server: ${e?.response?.body||e?.message}`)}x+=1,b.update(x)},{concurrency:p}),b.stop();let S=new Date().getTime()-y;r.t.info(a.default.green(`Successfully uploaded ${c.length} user preferences to partition ${l} in "${S/1e3}" seconds!`))}Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return f}});
2
- //# sourceMappingURL=uploadConsents-C7SPWTIr.cjs.map
1
+ const e=require(`./chunk-Bmb41Sf3.cjs`),t=require(`./constants-gJm1eQH0.cjs`),n=require(`./syncConfigurationToTranscend-s-cjtUI3.cjs`),r=require(`./logger-DQwEYtSS.cjs`);let i=require(`@transcend-io/type-utils`),a=require(`colors`);a=e.t(a);let o=require(`io-ts`);o=e.t(o);let s=require(`cli-progress`);s=e.t(s);let c=require(`crypto`);c=e.t(c);let l=require(`jsonwebtoken`);l=e.t(l);function u(e,t,n){let r=Buffer.from(n,`base64`),i=Buffer.from(t,`base64`),a=Buffer.from(`A65959A6`,`hex`),o=c.createCipheriv(`id-aes256-wrap-pad`,i,a),s={encryptedIdentifier:Buffer.concat([o.update(e),o.final()]).toString(`base64`)};return l.sign(s,r,{algorithm:`HS384`})}const d=/^[0-9][Y|N]([Y|N])[Y|N]$/,f=o.record(o.string,o.union([o.boolean,o.literal(`Auto`)]));async function p({base64EncryptionKey:e,base64SigningKey:o,preferences:c,partition:l,concurrency:p=100,transcendUrl:m=t.o}){let h=n.ri(m),g=c.filter(e=>e.usp&&!d.test(e.usp));if(g.length>0)throw Error(`Received invalid usp strings: ${JSON.stringify(g,null,2)}`);let _=c.map((e,t)=>[e,t]).filter(([e])=>{if(!e.purposes)return!1;try{return(0,i.decodeCodec)(f,e.purposes),!1}catch{return!0}});if(_.length>0)throw Error(`Received invalid purpose maps: ${JSON.stringify(_,null,2)}`);let v=c.filter(e=>!e.usp&&!e.purposes);if(v.length>0)throw Error(`Received invalid inputs, expected either purposes or usp to be defined: ${JSON.stringify(v,null,2)}`);r.t.info(a.default.magenta(`Uploading ${c.length} user preferences to partition ${l}`));let y=new Date().getTime(),b=new s.default.SingleBar({},s.default.Presets.shades_classic),x=0;b.start(c.length,0),await n.As(c,async({userId:t,confirmed:n=`true`,updated:s,prompted:c,purposes:p,...m})=>{let g=u(t,e,o),[,_]=m.usp&&d.exec(m.usp)||[],v={token:g,partition:l,consent:{confirmed:n===`true`,purposes:p?(0,i.decodeCodec)(f,p):m.usp?{SaleOfInfo:_===`Y`}:{},...s?{updated:s===`true`}:{},...c?{prompted:c===`true`}:{},...m}};try{await h.post(`sync`,{json:v}).json()}catch(e){try{let t=JSON.parse(e?.response?.body||`{}`);t.error&&r.t.error(a.default.red(`Error: ${t.error}`))}catch{}throw Error(`Received an error from server: ${e?.response?.body||e?.message}`)}x+=1,b.update(x)},{concurrency:p}),b.stop();let S=new Date().getTime()-y;r.t.info(a.default.green(`Successfully uploaded ${c.length} user preferences to partition ${l} in "${S/1e3}" seconds!`))}Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return f}});
2
+ //# sourceMappingURL=uploadConsents-CDkk_sWY.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"uploadConsents-C7SPWTIr.cjs","names":["jwt","t","DEFAULT_TRANSCEND_CONSENT_API","createTranscendConsentGotInstance","cliProgress","map"],"sources":["../src/lib/consent-manager/createConsentToken.ts","../src/lib/consent-manager/uploadConsents.ts"],"sourcesContent":["import * as crypto from 'crypto';\nimport * as jwt from 'jsonwebtoken';\n\n/**\n * Function to create a consent manager token\n *\n * @see https://docs.transcend.io/docs/consent/reference/managed-consent-database\n * @param userId - User ID\n * @param base64EncryptionKey - Encryption key\n * @param base64SigningKey - Signing key\n * @returns Token\n */\nexport function createConsentToken(\n userId: string,\n base64EncryptionKey: string,\n base64SigningKey: string,\n): string {\n // Read on for where to find these keys\n const signingKey = Buffer.from(base64SigningKey, 'base64');\n const encryptionKey = Buffer.from(base64EncryptionKey, 'base64');\n\n // NIST's AES-KWP implementation { aes 48 } - see https://tools.ietf.org/html/rfc5649\n const encryptionAlgorithm = 'id-aes256-wrap-pad';\n // Initial Value for AES-KWP integrity check - see https://tools.ietf.org/html/rfc5649#section-3\n const iv = Buffer.from('A65959A6', 'hex');\n // Set up encryption algorithm\n const cipher = crypto.createCipheriv(encryptionAlgorithm, encryptionKey, iv);\n\n // Encrypt the userId and base64-encode the result\n const encryptedIdentifier = Buffer.concat([\n cipher.update(userId),\n cipher.final(),\n ]).toString('base64');\n\n // Create the JWT content - jwt.sign will add a 'iat' (issued at) field to the payload\n // If you wanted to add something manually, consider\n // const issued: Date = new Date();\n // const isoDate = issued.toISOString();\n const jwtPayload = {\n encryptedIdentifier,\n };\n\n // Create a JSON web token and HMAC it with SHA-384\n const consentToken = jwt.sign(jwtPayload, signingKey, {\n algorithm: 'HS384',\n });\n\n return consentToken;\n}\n","import { createTranscendConsentGotInstance } from '../graphql';\nimport colors from 'colors';\nimport * as t from 'io-ts';\nimport { DEFAULT_TRANSCEND_CONSENT_API } from '../../constants';\nimport { map } from '../bluebird';\nimport { createConsentToken } from './createConsentToken';\nimport { logger } from '../../logger';\nimport cliProgress from 'cli-progress';\nimport { decodeCodec } from '@transcend-io/type-utils';\nimport type { ConsentPreferenceUpload } from './types';\nimport { ConsentPreferencesBody } from '@transcend-io/airgap.js-types';\n\nexport const USP_STRING_REGEX = /^[0-9][Y|N]([Y|N])[Y|N]$/;\n\nexport const PurposeMap = t.record(\n t.string,\n t.union([t.boolean, t.literal('Auto')]),\n);\n\n/**\n * Upload a set of consent preferences\n *\n * @param options - Options\n */\nexport async function uploadConsents({\n base64EncryptionKey,\n base64SigningKey,\n preferences,\n partition,\n concurrency = 100,\n transcendUrl = DEFAULT_TRANSCEND_CONSENT_API,\n}: {\n /** base64 encryption key */\n base64EncryptionKey: string;\n /** base64 signing key */\n base64SigningKey: string;\n /** Partition key */\n partition: string;\n /** Sombra API key authentication */\n preferences: ConsentPreferenceUpload[];\n /** API URL for Transcend backend */\n transcendUrl?: string;\n /** Concurrency limit for approving */\n concurrency?: number;\n}): Promise<void> {\n // Create connection to API\n const transcendConsentApi = createTranscendConsentGotInstance(transcendUrl);\n\n // Ensure usp strings are valid\n const invalidUspStrings = preferences.filter(\n (pref) => pref.usp && !USP_STRING_REGEX.test(pref.usp),\n );\n if (invalidUspStrings.length > 0) {\n throw new Error(\n `Received invalid usp strings: ${JSON.stringify(\n invalidUspStrings,\n null,\n 2,\n )}`,\n );\n }\n\n // Ensure purpose maps are valid\n const invalidPurposeMaps = preferences\n .map((pref, ind) => [pref, ind] as [ConsentPreferenceUpload, number])\n .filter(([pref]) => {\n if (!pref.purposes) {\n return false;\n }\n try {\n decodeCodec(PurposeMap, pref.purposes);\n return false;\n } catch {\n return true;\n }\n });\n if (invalidPurposeMaps.length > 0) {\n throw new Error(\n `Received invalid purpose maps: ${JSON.stringify(\n invalidPurposeMaps,\n null,\n 2,\n )}`,\n );\n }\n\n // Ensure usp or preferences are provided\n const invalidInputs = preferences.filter(\n (pref) => !pref.usp && !pref.purposes,\n );\n if (invalidInputs.length > 0) {\n throw new Error(\n `Received invalid inputs, expected either purposes or usp to be defined: ${JSON.stringify(\n invalidInputs,\n null,\n 2,\n )}`,\n );\n }\n\n logger.info(\n colors.magenta(\n `Uploading ${preferences.length} user preferences to partition ${partition}`,\n ),\n );\n\n // Time duration\n const t0 = new Date().getTime();\n // create a new progress bar instance and use shades_classic theme\n const progressBar = new cliProgress.SingleBar(\n {},\n cliProgress.Presets.shades_classic,\n );\n\n // Build a GraphQL client\n let total = 0;\n progressBar.start(preferences.length, 0);\n await map(\n preferences,\n async ({\n userId,\n confirmed = 'true',\n updated,\n prompted,\n purposes,\n ...consent\n }) => {\n const token = createConsentToken(\n userId,\n base64EncryptionKey,\n base64SigningKey,\n );\n\n // parse usp string\n const [, saleStatus] = consent.usp\n ? USP_STRING_REGEX.exec(consent.usp) || []\n : [];\n\n const input = {\n token,\n partition,\n consent: {\n confirmed: confirmed === 'true',\n purposes: purposes\n ? decodeCodec(PurposeMap, purposes)\n : consent.usp\n ? { SaleOfInfo: saleStatus === 'Y' }\n : {},\n ...(updated ? { updated: updated === 'true' } : {}),\n ...(prompted ? { prompted: prompted === 'true' } : {}),\n ...consent,\n },\n } as ConsentPreferencesBody;\n\n // Make the request\n try {\n await transcendConsentApi\n .post('sync', {\n json: input,\n })\n .json();\n } catch (err) {\n try {\n const parsed = JSON.parse(err?.response?.body || '{}');\n if (parsed.error) {\n logger.error(colors.red(`Error: ${parsed.error}`));\n }\n } catch (e) {\n // continue\n }\n throw new Error(\n `Received an error from server: ${\n err?.response?.body || err?.message\n }`,\n );\n }\n\n total += 1;\n progressBar.update(total);\n },\n { concurrency },\n );\n\n progressBar.stop();\n const t1 = new Date().getTime();\n const totalTime = t1 - t0;\n\n logger.info(\n colors.green(\n `Successfully uploaded ${\n preferences.length\n } user preferences to partition ${partition} in \"${\n totalTime / 1000\n }\" seconds!`,\n ),\n );\n}\n"],"mappings":"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"}
1
+ {"version":3,"file":"uploadConsents-CDkk_sWY.cjs","names":["jwt","t","DEFAULT_TRANSCEND_CONSENT_API","createTranscendConsentGotInstance","cliProgress","map"],"sources":["../src/lib/consent-manager/createConsentToken.ts","../src/lib/consent-manager/uploadConsents.ts"],"sourcesContent":["import * as crypto from 'crypto';\nimport * as jwt from 'jsonwebtoken';\n\n/**\n * Function to create a consent manager token\n *\n * @see https://docs.transcend.io/docs/consent/reference/managed-consent-database\n * @param userId - User ID\n * @param base64EncryptionKey - Encryption key\n * @param base64SigningKey - Signing key\n * @returns Token\n */\nexport function createConsentToken(\n userId: string,\n base64EncryptionKey: string,\n base64SigningKey: string,\n): string {\n // Read on for where to find these keys\n const signingKey = Buffer.from(base64SigningKey, 'base64');\n const encryptionKey = Buffer.from(base64EncryptionKey, 'base64');\n\n // NIST's AES-KWP implementation { aes 48 } - see https://tools.ietf.org/html/rfc5649\n const encryptionAlgorithm = 'id-aes256-wrap-pad';\n // Initial Value for AES-KWP integrity check - see https://tools.ietf.org/html/rfc5649#section-3\n const iv = Buffer.from('A65959A6', 'hex');\n // Set up encryption algorithm\n const cipher = crypto.createCipheriv(encryptionAlgorithm, encryptionKey, iv);\n\n // Encrypt the userId and base64-encode the result\n const encryptedIdentifier = Buffer.concat([\n cipher.update(userId),\n cipher.final(),\n ]).toString('base64');\n\n // Create the JWT content - jwt.sign will add a 'iat' (issued at) field to the payload\n // If you wanted to add something manually, consider\n // const issued: Date = new Date();\n // const isoDate = issued.toISOString();\n const jwtPayload = {\n encryptedIdentifier,\n };\n\n // Create a JSON web token and HMAC it with SHA-384\n const consentToken = jwt.sign(jwtPayload, signingKey, {\n algorithm: 'HS384',\n });\n\n return consentToken;\n}\n","import { createTranscendConsentGotInstance } from '../graphql';\nimport colors from 'colors';\nimport * as t from 'io-ts';\nimport { DEFAULT_TRANSCEND_CONSENT_API } from '../../constants';\nimport { map } from '../bluebird';\nimport { createConsentToken } from './createConsentToken';\nimport { logger } from '../../logger';\nimport cliProgress from 'cli-progress';\nimport { decodeCodec } from '@transcend-io/type-utils';\nimport type { ConsentPreferenceUpload } from './types';\nimport { ConsentPreferencesBody } from '@transcend-io/airgap.js-types';\n\nexport const USP_STRING_REGEX = /^[0-9][Y|N]([Y|N])[Y|N]$/;\n\nexport const PurposeMap = t.record(\n t.string,\n t.union([t.boolean, t.literal('Auto')]),\n);\n\n/**\n * Upload a set of consent preferences\n *\n * @param options - Options\n */\nexport async function uploadConsents({\n base64EncryptionKey,\n base64SigningKey,\n preferences,\n partition,\n concurrency = 100,\n transcendUrl = DEFAULT_TRANSCEND_CONSENT_API,\n}: {\n /** base64 encryption key */\n base64EncryptionKey: string;\n /** base64 signing key */\n base64SigningKey: string;\n /** Partition key */\n partition: string;\n /** Sombra API key authentication */\n preferences: ConsentPreferenceUpload[];\n /** API URL for Transcend backend */\n transcendUrl?: string;\n /** Concurrency limit for approving */\n concurrency?: number;\n}): Promise<void> {\n // Create connection to API\n const transcendConsentApi = createTranscendConsentGotInstance(transcendUrl);\n\n // Ensure usp strings are valid\n const invalidUspStrings = preferences.filter(\n (pref) => pref.usp && !USP_STRING_REGEX.test(pref.usp),\n );\n if (invalidUspStrings.length > 0) {\n throw new Error(\n `Received invalid usp strings: ${JSON.stringify(\n invalidUspStrings,\n null,\n 2,\n )}`,\n );\n }\n\n // Ensure purpose maps are valid\n const invalidPurposeMaps = preferences\n .map((pref, ind) => [pref, ind] as [ConsentPreferenceUpload, number])\n .filter(([pref]) => {\n if (!pref.purposes) {\n return false;\n }\n try {\n decodeCodec(PurposeMap, pref.purposes);\n return false;\n } catch {\n return true;\n }\n });\n if (invalidPurposeMaps.length > 0) {\n throw new Error(\n `Received invalid purpose maps: ${JSON.stringify(\n invalidPurposeMaps,\n null,\n 2,\n )}`,\n );\n }\n\n // Ensure usp or preferences are provided\n const invalidInputs = preferences.filter(\n (pref) => !pref.usp && !pref.purposes,\n );\n if (invalidInputs.length > 0) {\n throw new Error(\n `Received invalid inputs, expected either purposes or usp to be defined: ${JSON.stringify(\n invalidInputs,\n null,\n 2,\n )}`,\n );\n }\n\n logger.info(\n colors.magenta(\n `Uploading ${preferences.length} user preferences to partition ${partition}`,\n ),\n );\n\n // Time duration\n const t0 = new Date().getTime();\n // create a new progress bar instance and use shades_classic theme\n const progressBar = new cliProgress.SingleBar(\n {},\n cliProgress.Presets.shades_classic,\n );\n\n // Build a GraphQL client\n let total = 0;\n progressBar.start(preferences.length, 0);\n await map(\n preferences,\n async ({\n userId,\n confirmed = 'true',\n updated,\n prompted,\n purposes,\n ...consent\n }) => {\n const token = createConsentToken(\n userId,\n base64EncryptionKey,\n base64SigningKey,\n );\n\n // parse usp string\n const [, saleStatus] = consent.usp\n ? USP_STRING_REGEX.exec(consent.usp) || []\n : [];\n\n const input = {\n token,\n partition,\n consent: {\n confirmed: confirmed === 'true',\n purposes: purposes\n ? decodeCodec(PurposeMap, purposes)\n : consent.usp\n ? { SaleOfInfo: saleStatus === 'Y' }\n : {},\n ...(updated ? { updated: updated === 'true' } : {}),\n ...(prompted ? { prompted: prompted === 'true' } : {}),\n ...consent,\n },\n } as ConsentPreferencesBody;\n\n // Make the request\n try {\n await transcendConsentApi\n .post('sync', {\n json: input,\n })\n .json();\n } catch (err) {\n try {\n const parsed = JSON.parse(err?.response?.body || '{}');\n if (parsed.error) {\n logger.error(colors.red(`Error: ${parsed.error}`));\n }\n } catch (e) {\n // continue\n }\n throw new Error(\n `Received an error from server: ${\n err?.response?.body || err?.message\n }`,\n );\n }\n\n total += 1;\n progressBar.update(total);\n },\n { concurrency },\n );\n\n progressBar.stop();\n const t1 = new Date().getTime();\n const totalTime = t1 - t0;\n\n logger.info(\n colors.green(\n `Successfully uploaded ${\n preferences.length\n } user preferences to partition ${partition} in \"${\n totalTime / 1000\n }\" seconds!`,\n ),\n );\n}\n"],"mappings":"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"}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "author": "Transcend Inc.",
3
3
  "name": "@transcend-io/cli",
4
4
  "description": "A command line interface for programmatic operations across Transcend.",
5
- "version": "8.38.0",
5
+ "version": "8.38.2",
6
6
  "homepage": "https://github.com/transcend-io/cli",
7
7
  "repository": {
8
8
  "type": "git",
@@ -1,2 +0,0 @@
1
- const e=require(`./chunk-Bmb41Sf3.cjs`);require(`./constants-BvCUdOlO.cjs`);const t=require(`./syncConfigurationToTranscend-BipGaTT0.cjs`);require(`./enums-BZulhPFa.cjs`);const n=require(`./logger-DQwEYtSS.cjs`);require(`./buildAIIntegrationType-BwuCYR-o.cjs`);const r=require(`./done-input-validation-DGckEJ5a.cjs`);let i=require(`colors`);i=e.t(i);async function a({auth:e,transcendUrl:a,file:o,pageLimit:s,actions:c,sombraAuth:l,skipRequestIdentifiers:u,statuses:d,createdAtBefore:f,createdAtAfter:p,updatedAtBefore:m,updatedAtAfter:h,showTests:g}){r.t(this.process.exit);let{requestsFormattedForCsv:_}=await t.I({transcendUrl:a,pageLimit:s,actions:c,skipRequestIdentifiers:u,statuses:d,auth:e,sombraAuth:l,createdAtBefore:f,createdAtAfter:p,updatedAtBefore:m,updatedAtAfter:h,isTest:g});await t.d(o,_,t.Ds(_.map(e=>Object.keys(e)).flat())),n.t.info(i.default.green(`Successfully wrote ${_.length} requests to file "${o}"`))}exports._export=a;
2
- //# sourceMappingURL=impl-C0Uwz7KR.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"impl-C0Uwz7KR.cjs","names":["pullPrivacyRequests","writeLargeCsv","uniq"],"sources":["../src/commands/request/export/impl.ts"],"sourcesContent":["import type { LocalContext } from '../../../context';\nimport colors from 'colors';\n\nimport { logger } from '../../../logger';\nimport { uniq } from 'lodash-es';\nimport { pullPrivacyRequests } from '../../../lib/requests';\nimport { writeLargeCsv } from '../../../lib/helpers';\nimport type { RequestAction, RequestStatus } from '@transcend-io/privacy-types';\nimport { doneInputValidation } from '../../../lib/cli/done-input-validation';\n\nexport interface ExportCommandFlags {\n auth: string;\n sombraAuth?: string;\n actions?: RequestAction[];\n statuses?: RequestStatus[];\n transcendUrl: string;\n file: string;\n concurrency: number;\n createdAtBefore?: Date;\n createdAtAfter?: Date;\n updatedAtBefore?: Date;\n updatedAtAfter?: Date;\n showTests?: boolean;\n skipRequestIdentifiers?: boolean;\n pageLimit: number;\n}\n\n// `export` is a reserved keyword, so we need to prefix it with an underscore\n// eslint-disable-next-line no-underscore-dangle\nexport async function _export(\n this: LocalContext,\n {\n auth,\n transcendUrl,\n file,\n pageLimit,\n actions,\n sombraAuth,\n skipRequestIdentifiers,\n statuses,\n createdAtBefore,\n createdAtAfter,\n updatedAtBefore,\n updatedAtAfter,\n showTests,\n }: ExportCommandFlags,\n): Promise<void> {\n doneInputValidation(this.process.exit);\n\n const { requestsFormattedForCsv } = await pullPrivacyRequests({\n transcendUrl,\n pageLimit,\n actions,\n skipRequestIdentifiers,\n statuses,\n auth,\n sombraAuth,\n createdAtBefore,\n createdAtAfter,\n updatedAtBefore,\n updatedAtAfter,\n isTest: showTests,\n });\n\n // Write to CSV\n const headers = uniq(\n requestsFormattedForCsv.map((d) => Object.keys(d)).flat(),\n );\n await writeLargeCsv(file, requestsFormattedForCsv, headers);\n logger.info(\n colors.green(\n `Successfully wrote ${requestsFormattedForCsv.length} requests to file \"${file}\"`,\n ),\n );\n}\n"],"mappings":"8VA6BA,eAAsB,EAEpB,CACE,OACA,eACA,OACA,YACA,UACA,aACA,yBACA,WACA,kBACA,iBACA,kBACA,iBACA,aAEa,CACf,EAAA,EAAoB,KAAK,QAAQ,KAAK,CAEtC,GAAM,CAAE,2BAA4B,MAAMA,EAAAA,EAAoB,CAC5D,eACA,YACA,UACA,yBACA,WACA,OACA,aACA,kBACA,iBACA,kBACA,iBACA,OAAQ,EACT,CAAC,CAMF,MAAMC,EAAAA,EAAc,EAAM,EAHVC,EAAAA,GACd,EAAwB,IAAK,GAAM,OAAO,KAAK,EAAE,CAAC,CAAC,MAAM,CAC1D,CAC0D,CAC3D,EAAA,EAAO,KACL,EAAA,QAAO,MACL,sBAAsB,EAAwB,OAAO,qBAAqB,EAAK,GAChF,CACF"}
@@ -1,2 +0,0 @@
1
- const e=require(`./chunk-Bmb41Sf3.cjs`),t=require(`./constants-BvCUdOlO.cjs`),n=require(`./syncConfigurationToTranscend-BipGaTT0.cjs`),r=require(`./logger-DQwEYtSS.cjs`);let i=require(`@transcend-io/privacy-types`),a=require(`colors`);a=e.t(a);let o=require(`io-ts`);o=e.t(o);async function s({file:e,auth:o,sombraAuth:s,requestActions:c=[],concurrency:l=100,transcendUrl:u=t.a}){let d=n.ti(u,o),f=await n.ei(u,o,s);r.t.info(a.default.magenta(`Pulling manual enrichment requests, filtered for actions: ${c.join(`,`)}`));let p=await n.fr(d,{actions:c,statuses:[i.RequestStatus.Enriching]}),m=[];await n.Ts(p,async e=>{let t=await n.gr(d,{requestId:e.id});if(t.filter(({status:e})=>e===`ACTION_REQUIRED`)){let r=await n.mr(d,f,{requestId:e.id});m.push({...e,requestIdentifiers:r,requestEnrichers:t})}},{concurrency:l});let h=m.map(({attributeValues:e,requestIdentifiers:t,requestEnrichers:r,...i})=>({...i,...Object.entries(n.As(t,`name`)).reduce((e,[t,n])=>Object.assign(e,{[t]:n.map(({value:e})=>e).join(`,`)}),{}),...Object.entries(n.As(e,`attributeKey.name`)).reduce((e,[t,n])=>Object.assign(e,{[t]:n.map(({name:e})=>e).join(`,`)}),{})}));return await n.l(e,h,n.Ds(h.map(e=>Object.keys(e)).flat())),r.t.info(a.default.green(`Successfully wrote ${m.length} requests to file "${e}"`)),m}const c=`https://app.transcend.io/privacy-requests/incoming-requests/`,l=o.record(o.string,o.string);async function u(e,{id:t,...i},o,s){if(!t){let e=`Request ID must be provided to enricher request.${s?` Found error in row: ${s}`:``}`;throw r.t.error(a.default.red(e)),Error(e)}let l=t.toLowerCase(),u=Object.entries(i).reduce((e,[t,r])=>n.Ds(n.li(r)).length===0?e:Object.assign(e,{[t]:n.Ds(n.li(r)).map(e=>({value:t===`email`?e.toLowerCase():e}))}),{});try{return await e.post(`v1/enrich-identifiers`,{headers:{"x-transcend-request-id":l,"x-transcend-enricher-id":o},json:{enrichedIdentifiers:u}}).json(),r.t.error(a.default.green(`Successfully enriched request: ${c}${l}`)),!0}catch(e){if(typeof e.response.body==`string`&&e.response.body.includes(`Cannot update a resolved RequestEnricher`))return r.t.warn(a.default.magenta(`Skipped enrichment for request: ${c}${l}, request is no longer in the enriching phase.`)),!1;throw r.t.error(a.default.red(`Failed to enricher identifiers for request with id: ${c}${l} - ${e.message} - ${e.response.body}`)),e}}async function d({file:e,auth:i,sombraAuth:o,enricherId:s,markSilent:c,concurrency:d=100,transcendUrl:f=t.a}){let p=await n.ei(f,i,o),m=n.ti(f,i);r.t.info(a.default.magenta(`Reading "${e}" from disk`));let h=n.oi(e,l);r.t.info(a.default.magenta(`Enriching "${h.length}" privacy requests.`));let g=0,_=0,v=0;if(await n.Ts(h,async(e,t)=>{try{c&&(await n.i(m,n.Ao,{input:{id:e.id,isSilent:!0}}),r.t.info(a.default.magenta(`Mark request as silent mode - ${e.id}`))),await u(p,e,s,t)?g+=1:_+=1}catch{v+=1}},{concurrency:d}),r.t.info(a.default.green(`Successfully notified Transcend! \n Success count: ${g}.`)),_>0&&r.t.info(a.default.magenta(`Skipped count: ${_}.`)),v>0)throw r.t.info(a.default.red(`Error Count: ${v}.`)),Error(`Failed to enrich: ${v} requests.`);return h.length}Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return d}});
2
- //# sourceMappingURL=manual-enrichment-D_kDV9gc.cjs.map