@opentdf/sdk 0.1.0-beta.1701

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 (566) hide show
  1. package/README.md +52 -0
  2. package/dist/cjs/package.json +3 -0
  3. package/dist/cjs/src/access.js +155 -0
  4. package/dist/cjs/src/auth/Eas.js +60 -0
  5. package/dist/cjs/src/auth/auth.js +79 -0
  6. package/dist/cjs/src/auth/oidc-clientcredentials-provider.js +26 -0
  7. package/dist/cjs/src/auth/oidc-externaljwt-provider.js +33 -0
  8. package/dist/cjs/src/auth/oidc-refreshtoken-provider.js +34 -0
  9. package/dist/cjs/src/auth/oidc.js +222 -0
  10. package/dist/cjs/src/auth/providers.js +143 -0
  11. package/dist/cjs/src/encodings/base64.js +154 -0
  12. package/dist/cjs/src/encodings/hex.js +70 -0
  13. package/dist/cjs/src/encodings/index.js +29 -0
  14. package/dist/cjs/src/errors.js +138 -0
  15. package/dist/cjs/src/index.js +344 -0
  16. package/dist/cjs/src/nanotdf/Client.js +296 -0
  17. package/dist/cjs/src/nanotdf/NanoTDF.js +94 -0
  18. package/dist/cjs/src/nanotdf/browser-entry.js +19 -0
  19. package/dist/cjs/src/nanotdf/constants.js +5 -0
  20. package/dist/cjs/src/nanotdf/decrypt.js +17 -0
  21. package/dist/cjs/src/nanotdf/encrypt-dataset.js +38 -0
  22. package/dist/cjs/src/nanotdf/encrypt.js +132 -0
  23. package/dist/cjs/src/nanotdf/enum/CipherEnum.js +13 -0
  24. package/dist/cjs/src/nanotdf/enum/CurveNameEnum.js +15 -0
  25. package/dist/cjs/src/nanotdf/enum/EncodingEnum.js +8 -0
  26. package/dist/cjs/src/nanotdf/enum/PolicyTypeEnum.js +11 -0
  27. package/dist/cjs/src/nanotdf/enum/ProtocolEnum.js +10 -0
  28. package/dist/cjs/src/nanotdf/enum/ResourceLocatorIdentifierEnum.js +11 -0
  29. package/dist/cjs/src/nanotdf/helpers/calculateByCurve.js +29 -0
  30. package/dist/cjs/src/nanotdf/helpers/getHkdfSalt.js +11 -0
  31. package/dist/cjs/src/nanotdf/index.js +25 -0
  32. package/dist/cjs/src/nanotdf/interfaces/PolicyInterface.js +3 -0
  33. package/dist/cjs/src/nanotdf/models/Ciphers.js +61 -0
  34. package/dist/cjs/src/nanotdf/models/DefaultParams.js +27 -0
  35. package/dist/cjs/src/nanotdf/models/EcCurves.js +39 -0
  36. package/dist/cjs/src/nanotdf/models/Header.js +255 -0
  37. package/dist/cjs/src/nanotdf/models/Payload.js +158 -0
  38. package/dist/cjs/src/nanotdf/models/Policy/AbstractPolicy.js +73 -0
  39. package/dist/cjs/src/nanotdf/models/Policy/EmbeddedPolicy.js +82 -0
  40. package/dist/cjs/src/nanotdf/models/Policy/PolicyFactory.js +38 -0
  41. package/dist/cjs/src/nanotdf/models/Policy/RemotePolicy.js +62 -0
  42. package/dist/cjs/src/nanotdf/models/ResourceLocator.js +211 -0
  43. package/dist/cjs/src/nanotdf/models/Signature.js +77 -0
  44. package/dist/cjs/src/nanotdf-crypto/ciphers.js +17 -0
  45. package/dist/cjs/src/nanotdf-crypto/decrypt.js +24 -0
  46. package/dist/cjs/src/nanotdf-crypto/digest.js +7 -0
  47. package/dist/cjs/src/nanotdf-crypto/ecdsaSignature.js +83 -0
  48. package/dist/cjs/src/nanotdf-crypto/encrypt.js +24 -0
  49. package/dist/cjs/src/nanotdf-crypto/enums.js +52 -0
  50. package/dist/cjs/src/nanotdf-crypto/exportCryptoKey.js +20 -0
  51. package/dist/cjs/src/nanotdf-crypto/generateKeyPair.js +13 -0
  52. package/dist/cjs/src/nanotdf-crypto/generateRandomNumber.js +12 -0
  53. package/dist/cjs/src/nanotdf-crypto/importRawKey.js +18 -0
  54. package/dist/cjs/src/nanotdf-crypto/index.js +52 -0
  55. package/dist/cjs/src/nanotdf-crypto/keyAgreement.js +91 -0
  56. package/dist/cjs/src/nanotdf-crypto/pemPublicToCrypto.js +225 -0
  57. package/dist/cjs/src/policy/api.js +58 -0
  58. package/dist/cjs/src/policy/attributes.js +3 -0
  59. package/dist/cjs/src/policy/granter.js +146 -0
  60. package/dist/cjs/src/tdf/AttributeObject.js +15 -0
  61. package/dist/cjs/src/tdf/AttributeObjectJwt.js +3 -0
  62. package/dist/cjs/src/tdf/Crypto.js +47 -0
  63. package/dist/cjs/src/tdf/EntityObject.js +3 -0
  64. package/dist/cjs/src/tdf/NanoTDF/NanoTDF.js +38 -0
  65. package/dist/cjs/src/tdf/Policy.js +50 -0
  66. package/dist/cjs/src/tdf/PolicyObject.js +3 -0
  67. package/dist/cjs/src/tdf/TypedArray.js +3 -0
  68. package/dist/cjs/src/tdf/index.js +35 -0
  69. package/dist/cjs/src/types/index.js +3 -0
  70. package/dist/cjs/src/utils.js +147 -0
  71. package/dist/cjs/src/version.js +12 -0
  72. package/dist/cjs/tdf3/index.js +57 -0
  73. package/dist/cjs/tdf3/src/assertions.js +118 -0
  74. package/dist/cjs/tdf3/src/binary.js +153 -0
  75. package/dist/cjs/tdf3/src/ciphers/aes-gcm-cipher.js +56 -0
  76. package/dist/cjs/tdf3/src/ciphers/algorithms.js +8 -0
  77. package/dist/cjs/tdf3/src/ciphers/index.js +8 -0
  78. package/dist/cjs/tdf3/src/ciphers/symmetric-cipher-base.js +22 -0
  79. package/dist/cjs/tdf3/src/client/DecoratedReadableStream.js +116 -0
  80. package/dist/cjs/tdf3/src/client/builders.js +561 -0
  81. package/dist/cjs/tdf3/src/client/index.js +460 -0
  82. package/dist/cjs/tdf3/src/client/validation.js +63 -0
  83. package/dist/cjs/tdf3/src/crypto/crypto-utils.js +116 -0
  84. package/dist/cjs/tdf3/src/crypto/declarations.js +8 -0
  85. package/dist/cjs/tdf3/src/crypto/index.js +315 -0
  86. package/dist/cjs/tdf3/src/index.js +34 -0
  87. package/dist/cjs/tdf3/src/models/attribute-set.js +122 -0
  88. package/dist/cjs/tdf3/src/models/encryption-information.js +90 -0
  89. package/dist/cjs/tdf3/src/models/index.js +25 -0
  90. package/dist/cjs/tdf3/src/models/key-access.js +103 -0
  91. package/dist/cjs/tdf3/src/models/manifest.js +3 -0
  92. package/dist/cjs/tdf3/src/models/payload.js +3 -0
  93. package/dist/cjs/tdf3/src/models/policy.js +24 -0
  94. package/dist/cjs/tdf3/src/models/upsert-response.js +3 -0
  95. package/dist/cjs/tdf3/src/tdf.js +907 -0
  96. package/dist/cjs/tdf3/src/templates/default.html.js +98 -0
  97. package/dist/cjs/tdf3/src/templates/escaper.js +15 -0
  98. package/dist/cjs/tdf3/src/templates/index.js +12 -0
  99. package/dist/cjs/tdf3/src/utils/buffer-crc32.js +48 -0
  100. package/dist/cjs/tdf3/src/utils/chunkers.js +106 -0
  101. package/dist/cjs/tdf3/src/utils/index.js +296 -0
  102. package/dist/cjs/tdf3/src/utils/keysplit.js +61 -0
  103. package/dist/cjs/tdf3/src/utils/zip-reader.js +253 -0
  104. package/dist/cjs/tdf3/src/utils/zip-writer.js +308 -0
  105. package/dist/cjs/tdf3/src/version.js +6 -0
  106. package/dist/types/src/access.d.ts +47 -0
  107. package/dist/types/src/access.d.ts.map +1 -0
  108. package/dist/types/src/auth/Eas.d.ts +34 -0
  109. package/dist/types/src/auth/Eas.d.ts.map +1 -0
  110. package/dist/types/src/auth/auth.d.ts +86 -0
  111. package/dist/types/src/auth/auth.d.ts.map +1 -0
  112. package/dist/types/src/auth/oidc-clientcredentials-provider.d.ts +9 -0
  113. package/dist/types/src/auth/oidc-clientcredentials-provider.d.ts.map +1 -0
  114. package/dist/types/src/auth/oidc-externaljwt-provider.d.ts +10 -0
  115. package/dist/types/src/auth/oidc-externaljwt-provider.d.ts.map +1 -0
  116. package/dist/types/src/auth/oidc-refreshtoken-provider.d.ts +10 -0
  117. package/dist/types/src/auth/oidc-refreshtoken-provider.d.ts.map +1 -0
  118. package/dist/types/src/auth/oidc.d.ts +104 -0
  119. package/dist/types/src/auth/oidc.d.ts.map +1 -0
  120. package/dist/types/src/auth/providers.d.ts +67 -0
  121. package/dist/types/src/auth/providers.d.ts.map +1 -0
  122. package/dist/types/src/encodings/base64.d.ts +18 -0
  123. package/dist/types/src/encodings/base64.d.ts.map +1 -0
  124. package/dist/types/src/encodings/hex.d.ts +5 -0
  125. package/dist/types/src/encodings/hex.d.ts.map +1 -0
  126. package/dist/types/src/encodings/index.d.ts +3 -0
  127. package/dist/types/src/encodings/index.d.ts.map +1 -0
  128. package/dist/types/src/errors.d.ts +72 -0
  129. package/dist/types/src/errors.d.ts.map +1 -0
  130. package/dist/types/src/index.d.ts +138 -0
  131. package/dist/types/src/index.d.ts.map +1 -0
  132. package/dist/types/src/nanotdf/Client.d.ts +95 -0
  133. package/dist/types/src/nanotdf/Client.d.ts.map +1 -0
  134. package/dist/types/src/nanotdf/NanoTDF.d.ts +25 -0
  135. package/dist/types/src/nanotdf/NanoTDF.d.ts.map +1 -0
  136. package/dist/types/src/nanotdf/browser-entry.d.ts +17 -0
  137. package/dist/types/src/nanotdf/browser-entry.d.ts.map +1 -0
  138. package/dist/types/src/nanotdf/constants.d.ts +2 -0
  139. package/dist/types/src/nanotdf/constants.d.ts.map +1 -0
  140. package/dist/types/src/nanotdf/decrypt.d.ts +9 -0
  141. package/dist/types/src/nanotdf/decrypt.d.ts.map +1 -0
  142. package/dist/types/src/nanotdf/encrypt-dataset.d.ts +12 -0
  143. package/dist/types/src/nanotdf/encrypt-dataset.d.ts.map +1 -0
  144. package/dist/types/src/nanotdf/encrypt.d.ts +14 -0
  145. package/dist/types/src/nanotdf/encrypt.d.ts.map +1 -0
  146. package/dist/types/src/nanotdf/enum/CipherEnum.d.ts +10 -0
  147. package/dist/types/src/nanotdf/enum/CipherEnum.d.ts.map +1 -0
  148. package/dist/types/src/nanotdf/enum/CurveNameEnum.d.ts +12 -0
  149. package/dist/types/src/nanotdf/enum/CurveNameEnum.d.ts.map +1 -0
  150. package/dist/types/src/nanotdf/enum/EncodingEnum.d.ts +5 -0
  151. package/dist/types/src/nanotdf/enum/EncodingEnum.d.ts.map +1 -0
  152. package/dist/types/src/nanotdf/enum/PolicyTypeEnum.d.ts +8 -0
  153. package/dist/types/src/nanotdf/enum/PolicyTypeEnum.d.ts.map +1 -0
  154. package/dist/types/src/nanotdf/enum/ProtocolEnum.d.ts +7 -0
  155. package/dist/types/src/nanotdf/enum/ProtocolEnum.d.ts.map +1 -0
  156. package/dist/types/src/nanotdf/enum/ResourceLocatorIdentifierEnum.d.ts +8 -0
  157. package/dist/types/src/nanotdf/enum/ResourceLocatorIdentifierEnum.d.ts.map +1 -0
  158. package/dist/types/src/nanotdf/helpers/calculateByCurve.d.ts +20 -0
  159. package/dist/types/src/nanotdf/helpers/calculateByCurve.d.ts.map +1 -0
  160. package/dist/types/src/nanotdf/helpers/getHkdfSalt.d.ts +9 -0
  161. package/dist/types/src/nanotdf/helpers/getHkdfSalt.d.ts.map +1 -0
  162. package/dist/types/src/nanotdf/index.d.ts +9 -0
  163. package/dist/types/src/nanotdf/index.d.ts.map +1 -0
  164. package/dist/types/src/nanotdf/interfaces/PolicyInterface.d.ts +17 -0
  165. package/dist/types/src/nanotdf/interfaces/PolicyInterface.d.ts.map +1 -0
  166. package/dist/types/src/nanotdf/models/Ciphers.d.ts +14 -0
  167. package/dist/types/src/nanotdf/models/Ciphers.d.ts.map +1 -0
  168. package/dist/types/src/nanotdf/models/DefaultParams.d.ts +21 -0
  169. package/dist/types/src/nanotdf/models/DefaultParams.d.ts.map +1 -0
  170. package/dist/types/src/nanotdf/models/EcCurves.d.ts +15 -0
  171. package/dist/types/src/nanotdf/models/EcCurves.d.ts.map +1 -0
  172. package/dist/types/src/nanotdf/models/Header.d.ts +73 -0
  173. package/dist/types/src/nanotdf/models/Header.d.ts.map +1 -0
  174. package/dist/types/src/nanotdf/models/Payload.d.ts +47 -0
  175. package/dist/types/src/nanotdf/models/Payload.d.ts.map +1 -0
  176. package/dist/types/src/nanotdf/models/Policy/AbstractPolicy.d.ts +52 -0
  177. package/dist/types/src/nanotdf/models/Policy/AbstractPolicy.d.ts.map +1 -0
  178. package/dist/types/src/nanotdf/models/Policy/EmbeddedPolicy.d.ts +35 -0
  179. package/dist/types/src/nanotdf/models/Policy/EmbeddedPolicy.d.ts.map +1 -0
  180. package/dist/types/src/nanotdf/models/Policy/PolicyFactory.d.ts +11 -0
  181. package/dist/types/src/nanotdf/models/Policy/PolicyFactory.d.ts.map +1 -0
  182. package/dist/types/src/nanotdf/models/Policy/RemotePolicy.d.ts +31 -0
  183. package/dist/types/src/nanotdf/models/Policy/RemotePolicy.d.ts.map +1 -0
  184. package/dist/types/src/nanotdf/models/ResourceLocator.d.ts +65 -0
  185. package/dist/types/src/nanotdf/models/ResourceLocator.d.ts.map +1 -0
  186. package/dist/types/src/nanotdf/models/Signature.d.ts +33 -0
  187. package/dist/types/src/nanotdf/models/Signature.d.ts.map +1 -0
  188. package/dist/types/src/nanotdf-crypto/ciphers.d.ts +8 -0
  189. package/dist/types/src/nanotdf-crypto/ciphers.d.ts.map +1 -0
  190. package/dist/types/src/nanotdf-crypto/decrypt.d.ts +14 -0
  191. package/dist/types/src/nanotdf-crypto/decrypt.d.ts.map +1 -0
  192. package/dist/types/src/nanotdf-crypto/digest.d.ts +3 -0
  193. package/dist/types/src/nanotdf-crypto/digest.d.ts.map +1 -0
  194. package/dist/types/src/nanotdf-crypto/ecdsaSignature.d.ts +35 -0
  195. package/dist/types/src/nanotdf-crypto/ecdsaSignature.d.ts.map +1 -0
  196. package/dist/types/src/nanotdf-crypto/encrypt.d.ts +14 -0
  197. package/dist/types/src/nanotdf-crypto/encrypt.d.ts.map +1 -0
  198. package/dist/types/src/nanotdf-crypto/enums.d.ts +42 -0
  199. package/dist/types/src/nanotdf-crypto/enums.d.ts.map +1 -0
  200. package/dist/types/src/nanotdf-crypto/exportCryptoKey.d.ts +7 -0
  201. package/dist/types/src/nanotdf-crypto/exportCryptoKey.d.ts.map +1 -0
  202. package/dist/types/src/nanotdf-crypto/generateKeyPair.d.ts +10 -0
  203. package/dist/types/src/nanotdf-crypto/generateKeyPair.d.ts.map +1 -0
  204. package/dist/types/src/nanotdf-crypto/generateRandomNumber.d.ts +5 -0
  205. package/dist/types/src/nanotdf-crypto/generateRandomNumber.d.ts.map +1 -0
  206. package/dist/types/src/nanotdf-crypto/importRawKey.d.ts +13 -0
  207. package/dist/types/src/nanotdf-crypto/importRawKey.d.ts.map +1 -0
  208. package/dist/types/src/nanotdf-crypto/index.d.ts +12 -0
  209. package/dist/types/src/nanotdf-crypto/index.d.ts.map +1 -0
  210. package/dist/types/src/nanotdf-crypto/keyAgreement.d.ts +28 -0
  211. package/dist/types/src/nanotdf-crypto/keyAgreement.d.ts.map +1 -0
  212. package/dist/types/src/nanotdf-crypto/pemPublicToCrypto.d.ts +28 -0
  213. package/dist/types/src/nanotdf-crypto/pemPublicToCrypto.d.ts.map +1 -0
  214. package/dist/types/src/policy/api.d.ts +4 -0
  215. package/dist/types/src/policy/api.d.ts.map +1 -0
  216. package/dist/types/src/policy/attributes.d.ts +95 -0
  217. package/dist/types/src/policy/attributes.d.ts.map +1 -0
  218. package/dist/types/src/policy/granter.d.ts +23 -0
  219. package/dist/types/src/policy/granter.d.ts.map +1 -0
  220. package/dist/types/src/tdf/AttributeObject.d.ts +13 -0
  221. package/dist/types/src/tdf/AttributeObject.d.ts.map +1 -0
  222. package/dist/types/src/tdf/AttributeObjectJwt.d.ts +4 -0
  223. package/dist/types/src/tdf/AttributeObjectJwt.d.ts.map +1 -0
  224. package/dist/types/src/tdf/Crypto.d.ts +37 -0
  225. package/dist/types/src/tdf/Crypto.d.ts.map +1 -0
  226. package/dist/types/src/tdf/EntityObject.d.ts +18 -0
  227. package/dist/types/src/tdf/EntityObject.d.ts.map +1 -0
  228. package/dist/types/src/tdf/NanoTDF/NanoTDF.d.ts +99 -0
  229. package/dist/types/src/tdf/NanoTDF/NanoTDF.d.ts.map +1 -0
  230. package/dist/types/src/tdf/Policy.d.ts +28 -0
  231. package/dist/types/src/tdf/Policy.d.ts.map +1 -0
  232. package/dist/types/src/tdf/PolicyObject.d.ts +11 -0
  233. package/dist/types/src/tdf/PolicyObject.d.ts.map +1 -0
  234. package/dist/types/src/tdf/TypedArray.d.ts +3 -0
  235. package/dist/types/src/tdf/TypedArray.d.ts.map +1 -0
  236. package/dist/types/src/tdf/index.d.ts +7 -0
  237. package/dist/types/src/tdf/index.d.ts.map +1 -0
  238. package/dist/types/src/types/index.d.ts +45 -0
  239. package/dist/types/src/types/index.d.ts.map +1 -0
  240. package/dist/types/src/utils.d.ts +45 -0
  241. package/dist/types/src/utils.d.ts.map +1 -0
  242. package/dist/types/src/version.d.ts +9 -0
  243. package/dist/types/src/version.d.ts.map +1 -0
  244. package/dist/types/tdf3/index.d.ts +16 -0
  245. package/dist/types/tdf3/index.d.ts.map +1 -0
  246. package/dist/types/tdf3/src/assertions.d.ts +63 -0
  247. package/dist/types/tdf3/src/assertions.d.ts.map +1 -0
  248. package/dist/types/tdf3/src/binary.d.ts +38 -0
  249. package/dist/types/tdf3/src/binary.d.ts.map +1 -0
  250. package/dist/types/tdf3/src/ciphers/aes-gcm-cipher.d.ts +18 -0
  251. package/dist/types/tdf3/src/ciphers/aes-gcm-cipher.d.ts.map +1 -0
  252. package/dist/types/tdf3/src/ciphers/algorithms.d.ts +4 -0
  253. package/dist/types/tdf3/src/ciphers/algorithms.d.ts.map +1 -0
  254. package/dist/types/tdf3/src/ciphers/index.d.ts +3 -0
  255. package/dist/types/tdf3/src/ciphers/index.d.ts.map +1 -0
  256. package/dist/types/tdf3/src/ciphers/symmetric-cipher-base.d.ts +14 -0
  257. package/dist/types/tdf3/src/ciphers/symmetric-cipher-base.d.ts.map +1 -0
  258. package/dist/types/tdf3/src/client/DecoratedReadableStream.d.ts +53 -0
  259. package/dist/types/tdf3/src/client/DecoratedReadableStream.d.ts.map +1 -0
  260. package/dist/types/tdf3/src/client/builders.d.ts +436 -0
  261. package/dist/types/tdf3/src/client/builders.d.ts.map +1 -0
  262. package/dist/types/tdf3/src/client/index.d.ts +139 -0
  263. package/dist/types/tdf3/src/client/index.d.ts.map +1 -0
  264. package/dist/types/tdf3/src/client/validation.d.ts +8 -0
  265. package/dist/types/tdf3/src/client/validation.d.ts.map +1 -0
  266. package/dist/types/tdf3/src/crypto/crypto-utils.d.ts +34 -0
  267. package/dist/types/tdf3/src/crypto/crypto-utils.d.ts.map +1 -0
  268. package/dist/types/tdf3/src/crypto/declarations.d.ts +60 -0
  269. package/dist/types/tdf3/src/crypto/declarations.d.ts.map +1 -0
  270. package/dist/types/tdf3/src/crypto/index.d.ts +103 -0
  271. package/dist/types/tdf3/src/crypto/index.d.ts.map +1 -0
  272. package/dist/types/tdf3/src/index.d.ts +5 -0
  273. package/dist/types/tdf3/src/index.d.ts.map +1 -0
  274. package/dist/types/tdf3/src/models/attribute-set.d.ts +65 -0
  275. package/dist/types/tdf3/src/models/attribute-set.d.ts.map +1 -0
  276. package/dist/types/tdf3/src/models/encryption-information.d.ts +49 -0
  277. package/dist/types/tdf3/src/models/encryption-information.d.ts.map +1 -0
  278. package/dist/types/tdf3/src/models/index.d.ts +9 -0
  279. package/dist/types/tdf3/src/models/index.d.ts.map +1 -0
  280. package/dist/types/tdf3/src/models/key-access.d.ts +42 -0
  281. package/dist/types/tdf3/src/models/key-access.d.ts.map +1 -0
  282. package/dist/types/tdf3/src/models/manifest.d.ts +9 -0
  283. package/dist/types/tdf3/src/models/manifest.d.ts.map +1 -0
  284. package/dist/types/tdf3/src/models/payload.d.ts +7 -0
  285. package/dist/types/tdf3/src/models/payload.d.ts.map +1 -0
  286. package/dist/types/tdf3/src/models/policy.d.ts +13 -0
  287. package/dist/types/tdf3/src/models/policy.d.ts.map +1 -0
  288. package/dist/types/tdf3/src/models/upsert-response.d.ts +16 -0
  289. package/dist/types/tdf3/src/models/upsert-response.d.ts.map +1 -0
  290. package/dist/types/tdf3/src/tdf.d.ts +152 -0
  291. package/dist/types/tdf3/src/tdf.d.ts.map +1 -0
  292. package/dist/types/tdf3/src/templates/default.html.d.ts +8 -0
  293. package/dist/types/tdf3/src/templates/default.html.d.ts.map +1 -0
  294. package/dist/types/tdf3/src/templates/escaper.d.ts +6 -0
  295. package/dist/types/tdf3/src/templates/escaper.d.ts.map +1 -0
  296. package/dist/types/tdf3/src/templates/index.d.ts +3 -0
  297. package/dist/types/tdf3/src/templates/index.d.ts.map +1 -0
  298. package/dist/types/tdf3/src/utils/buffer-crc32.d.ts +2 -0
  299. package/dist/types/tdf3/src/utils/buffer-crc32.d.ts.map +1 -0
  300. package/dist/types/tdf3/src/utils/chunkers.d.ts +29 -0
  301. package/dist/types/tdf3/src/utils/chunkers.d.ts.map +1 -0
  302. package/dist/types/tdf3/src/utils/index.d.ts +36 -0
  303. package/dist/types/tdf3/src/utils/index.d.ts.map +1 -0
  304. package/dist/types/tdf3/src/utils/keysplit.d.ts +19 -0
  305. package/dist/types/tdf3/src/utils/keysplit.d.ts.map +1 -0
  306. package/dist/types/tdf3/src/utils/zip-reader.d.ts +63 -0
  307. package/dist/types/tdf3/src/utils/zip-reader.d.ts.map +1 -0
  308. package/dist/types/tdf3/src/utils/zip-writer.d.ts +35 -0
  309. package/dist/types/tdf3/src/utils/zip-writer.d.ts.map +1 -0
  310. package/dist/types/tdf3/src/version.d.ts +3 -0
  311. package/dist/types/tdf3/src/version.d.ts.map +1 -0
  312. package/dist/web/package.json +3 -0
  313. package/dist/web/src/access.js +147 -0
  314. package/dist/web/src/auth/Eas.js +55 -0
  315. package/dist/web/src/auth/auth.js +71 -0
  316. package/dist/web/src/auth/oidc-clientcredentials-provider.js +22 -0
  317. package/dist/web/src/auth/oidc-externaljwt-provider.js +29 -0
  318. package/dist/web/src/auth/oidc-refreshtoken-provider.js +30 -0
  319. package/dist/web/src/auth/oidc.js +215 -0
  320. package/dist/web/src/auth/providers.js +119 -0
  321. package/dist/web/src/encodings/base64.js +147 -0
  322. package/dist/web/src/encodings/hex.js +63 -0
  323. package/dist/web/src/encodings/index.js +3 -0
  324. package/dist/web/src/errors.js +123 -0
  325. package/dist/web/src/index.js +313 -0
  326. package/dist/web/src/nanotdf/Client.js +268 -0
  327. package/dist/web/src/nanotdf/NanoTDF.js +89 -0
  328. package/dist/web/src/nanotdf/browser-entry.js +14 -0
  329. package/dist/web/src/nanotdf/constants.js +2 -0
  330. package/dist/web/src/nanotdf/decrypt.js +14 -0
  331. package/dist/web/src/nanotdf/encrypt-dataset.js +32 -0
  332. package/dist/web/src/nanotdf/encrypt.js +126 -0
  333. package/dist/web/src/nanotdf/enum/CipherEnum.js +11 -0
  334. package/dist/web/src/nanotdf/enum/CurveNameEnum.js +13 -0
  335. package/dist/web/src/nanotdf/enum/EncodingEnum.js +6 -0
  336. package/dist/web/src/nanotdf/enum/PolicyTypeEnum.js +9 -0
  337. package/dist/web/src/nanotdf/enum/ProtocolEnum.js +8 -0
  338. package/dist/web/src/nanotdf/enum/ResourceLocatorIdentifierEnum.js +9 -0
  339. package/dist/web/src/nanotdf/helpers/calculateByCurve.js +24 -0
  340. package/dist/web/src/nanotdf/helpers/getHkdfSalt.js +8 -0
  341. package/dist/web/src/nanotdf/index.js +11 -0
  342. package/dist/web/src/nanotdf/interfaces/PolicyInterface.js +2 -0
  343. package/dist/web/src/nanotdf/models/Ciphers.js +54 -0
  344. package/dist/web/src/nanotdf/models/DefaultParams.js +22 -0
  345. package/dist/web/src/nanotdf/models/EcCurves.js +32 -0
  346. package/dist/web/src/nanotdf/models/Header.js +250 -0
  347. package/dist/web/src/nanotdf/models/Payload.js +156 -0
  348. package/dist/web/src/nanotdf/models/Policy/AbstractPolicy.js +71 -0
  349. package/dist/web/src/nanotdf/models/Policy/EmbeddedPolicy.js +77 -0
  350. package/dist/web/src/nanotdf/models/Policy/PolicyFactory.js +33 -0
  351. package/dist/web/src/nanotdf/models/Policy/RemotePolicy.js +57 -0
  352. package/dist/web/src/nanotdf/models/ResourceLocator.js +206 -0
  353. package/dist/web/src/nanotdf/models/Signature.js +74 -0
  354. package/dist/web/src/nanotdf-crypto/ciphers.js +14 -0
  355. package/dist/web/src/nanotdf-crypto/decrypt.js +21 -0
  356. package/dist/web/src/nanotdf-crypto/digest.js +4 -0
  357. package/dist/web/src/nanotdf-crypto/ecdsaSignature.js +77 -0
  358. package/dist/web/src/nanotdf-crypto/encrypt.js +21 -0
  359. package/dist/web/src/nanotdf-crypto/enums.js +49 -0
  360. package/dist/web/src/nanotdf-crypto/exportCryptoKey.js +17 -0
  361. package/dist/web/src/nanotdf-crypto/generateKeyPair.js +10 -0
  362. package/dist/web/src/nanotdf-crypto/generateRandomNumber.js +9 -0
  363. package/dist/web/src/nanotdf-crypto/importRawKey.js +15 -0
  364. package/dist/web/src/nanotdf-crypto/index.js +12 -0
  365. package/dist/web/src/nanotdf-crypto/keyAgreement.js +87 -0
  366. package/dist/web/src/nanotdf-crypto/pemPublicToCrypto.js +197 -0
  367. package/dist/web/src/policy/api.js +54 -0
  368. package/dist/web/src/policy/attributes.js +2 -0
  369. package/dist/web/src/policy/granter.js +141 -0
  370. package/dist/web/src/tdf/AttributeObject.js +11 -0
  371. package/dist/web/src/tdf/AttributeObjectJwt.js +2 -0
  372. package/dist/web/src/tdf/Crypto.js +44 -0
  373. package/dist/web/src/tdf/EntityObject.js +2 -0
  374. package/dist/web/src/tdf/NanoTDF/NanoTDF.js +35 -0
  375. package/dist/web/src/tdf/Policy.js +48 -0
  376. package/dist/web/src/tdf/PolicyObject.js +2 -0
  377. package/dist/web/src/tdf/TypedArray.js +2 -0
  378. package/dist/web/src/tdf/index.js +4 -0
  379. package/dist/web/src/types/index.js +2 -0
  380. package/dist/web/src/utils.js +133 -0
  381. package/dist/web/src/version.js +9 -0
  382. package/dist/web/tdf3/index.js +13 -0
  383. package/dist/web/tdf3/src/assertions.js +111 -0
  384. package/dist/web/tdf3/src/binary.js +149 -0
  385. package/dist/web/tdf3/src/ciphers/aes-gcm-cipher.js +52 -0
  386. package/dist/web/tdf3/src/ciphers/algorithms.js +5 -0
  387. package/dist/web/tdf3/src/ciphers/index.js +3 -0
  388. package/dist/web/tdf3/src/ciphers/symmetric-cipher-base.js +18 -0
  389. package/dist/web/tdf3/src/client/DecoratedReadableStream.js +107 -0
  390. package/dist/web/tdf3/src/client/builders.js +557 -0
  391. package/dist/web/tdf3/src/client/index.js +423 -0
  392. package/dist/web/tdf3/src/client/validation.js +58 -0
  393. package/dist/web/tdf3/src/crypto/crypto-utils.js +107 -0
  394. package/dist/web/tdf3/src/crypto/declarations.js +5 -0
  395. package/dist/web/tdf3/src/crypto/index.js +296 -0
  396. package/dist/web/tdf3/src/index.js +5 -0
  397. package/dist/web/tdf3/src/models/attribute-set.js +118 -0
  398. package/dist/web/tdf3/src/models/encryption-information.js +86 -0
  399. package/dist/web/tdf3/src/models/index.js +9 -0
  400. package/dist/web/tdf3/src/models/key-access.js +74 -0
  401. package/dist/web/tdf3/src/models/manifest.js +2 -0
  402. package/dist/web/tdf3/src/models/payload.js +2 -0
  403. package/dist/web/tdf3/src/models/policy.js +20 -0
  404. package/dist/web/tdf3/src/models/upsert-response.js +2 -0
  405. package/dist/web/tdf3/src/tdf.js +866 -0
  406. package/dist/web/tdf3/src/templates/default.html.js +96 -0
  407. package/dist/web/tdf3/src/templates/escaper.js +10 -0
  408. package/dist/web/tdf3/src/templates/index.js +3 -0
  409. package/dist/web/tdf3/src/utils/buffer-crc32.js +44 -0
  410. package/dist/web/tdf3/src/utils/chunkers.js +96 -0
  411. package/dist/web/tdf3/src/utils/index.js +248 -0
  412. package/dist/web/tdf3/src/utils/keysplit.js +55 -0
  413. package/dist/web/tdf3/src/utils/zip-reader.js +247 -0
  414. package/dist/web/tdf3/src/utils/zip-writer.js +302 -0
  415. package/dist/web/tdf3/src/version.js +3 -0
  416. package/package.json +126 -0
  417. package/src/access.ts +198 -0
  418. package/src/auth/Eas.ts +79 -0
  419. package/src/auth/auth.ts +141 -0
  420. package/src/auth/oidc-clientcredentials-provider.ts +32 -0
  421. package/src/auth/oidc-externaljwt-provider.ts +41 -0
  422. package/src/auth/oidc-refreshtoken-provider.ts +41 -0
  423. package/src/auth/oidc.ts +307 -0
  424. package/src/auth/providers.ts +139 -0
  425. package/src/encodings/base64.ts +160 -0
  426. package/src/encodings/hex.ts +69 -0
  427. package/src/encodings/index.ts +2 -0
  428. package/src/errors.ts +113 -0
  429. package/src/index.ts +441 -0
  430. package/src/nanotdf/Client.ts +349 -0
  431. package/src/nanotdf/NanoTDF.ts +121 -0
  432. package/src/nanotdf/browser-entry.ts +20 -0
  433. package/src/nanotdf/constants.ts +1 -0
  434. package/src/nanotdf/decrypt.ts +19 -0
  435. package/src/nanotdf/encrypt-dataset.ts +52 -0
  436. package/src/nanotdf/encrypt.ts +197 -0
  437. package/src/nanotdf/enum/CipherEnum.ts +10 -0
  438. package/src/nanotdf/enum/CurveNameEnum.ts +12 -0
  439. package/src/nanotdf/enum/EncodingEnum.ts +5 -0
  440. package/src/nanotdf/enum/PolicyTypeEnum.ts +8 -0
  441. package/src/nanotdf/enum/ProtocolEnum.ts +7 -0
  442. package/src/nanotdf/enum/ResourceLocatorIdentifierEnum.ts +8 -0
  443. package/src/nanotdf/helpers/calculateByCurve.ts +26 -0
  444. package/src/nanotdf/helpers/getHkdfSalt.ts +15 -0
  445. package/src/nanotdf/index.ts +10 -0
  446. package/src/nanotdf/interfaces/PolicyInterface.ts +27 -0
  447. package/src/nanotdf/models/Ciphers.ts +67 -0
  448. package/src/nanotdf/models/DefaultParams.ts +24 -0
  449. package/src/nanotdf/models/EcCurves.ts +40 -0
  450. package/src/nanotdf/models/Header.ts +322 -0
  451. package/src/nanotdf/models/Payload.ts +196 -0
  452. package/src/nanotdf/models/Policy/AbstractPolicy.ts +90 -0
  453. package/src/nanotdf/models/Policy/EmbeddedPolicy.ts +101 -0
  454. package/src/nanotdf/models/Policy/PolicyFactory.ts +48 -0
  455. package/src/nanotdf/models/Policy/RemotePolicy.ts +74 -0
  456. package/src/nanotdf/models/ResourceLocator.ts +212 -0
  457. package/src/nanotdf/models/Signature.ts +85 -0
  458. package/src/nanotdf-crypto/ciphers.ts +13 -0
  459. package/src/nanotdf-crypto/decrypt.ts +30 -0
  460. package/src/nanotdf-crypto/digest.ts +8 -0
  461. package/src/nanotdf-crypto/ecdsaSignature.ts +109 -0
  462. package/src/nanotdf-crypto/encrypt.ts +30 -0
  463. package/src/nanotdf-crypto/enums.ts +47 -0
  464. package/src/nanotdf-crypto/exportCryptoKey.ts +17 -0
  465. package/src/nanotdf-crypto/generateKeyPair.ts +19 -0
  466. package/src/nanotdf-crypto/generateRandomNumber.ts +8 -0
  467. package/src/nanotdf-crypto/importRawKey.ts +19 -0
  468. package/src/nanotdf-crypto/index.ts +11 -0
  469. package/src/nanotdf-crypto/keyAgreement.ts +139 -0
  470. package/src/nanotdf-crypto/pemPublicToCrypto.ts +232 -0
  471. package/src/package-lock.json +6 -0
  472. package/src/package.json +3 -0
  473. package/src/platform/authorization/authorization_connect.d.ts +44 -0
  474. package/src/platform/authorization/authorization_connect.js +44 -0
  475. package/src/platform/authorization/authorization_pb.d.ts +707 -0
  476. package/src/platform/authorization/authorization_pb.js +372 -0
  477. package/src/platform/common/common_pb.d.ts +129 -0
  478. package/src/platform/common/common_pb.js +58 -0
  479. package/src/platform/entityresolution/entity_resolution_connect.d.ts +35 -0
  480. package/src/platform/entityresolution/entity_resolution_connect.js +35 -0
  481. package/src/platform/entityresolution/entity_resolution_pb.d.ts +242 -0
  482. package/src/platform/entityresolution/entity_resolution_pb.js +139 -0
  483. package/src/platform/kas/kas_connect.d.ts +59 -0
  484. package/src/platform/kas/kas_connect.js +59 -0
  485. package/src/platform/kas/kas_pb.d.ts +200 -0
  486. package/src/platform/kas/kas_pb.js +84 -0
  487. package/src/platform/policy/attributes/attributes_connect.d.ts +168 -0
  488. package/src/platform/policy/attributes/attributes_connect.js +168 -0
  489. package/src/platform/policy/attributes/attributes_pb.d.ts +929 -0
  490. package/src/platform/policy/attributes/attributes_pb.js +363 -0
  491. package/src/platform/policy/kasregistry/key_access_server_registry_connect.d.ts +62 -0
  492. package/src/platform/policy/kasregistry/key_access_server_registry_connect.js +62 -0
  493. package/src/platform/policy/kasregistry/key_access_server_registry_pb.d.ts +283 -0
  494. package/src/platform/policy/kasregistry/key_access_server_registry_pb.js +113 -0
  495. package/src/platform/policy/namespaces/namespaces_connect.d.ts +62 -0
  496. package/src/platform/policy/namespaces/namespaces_connect.js +62 -0
  497. package/src/platform/policy/namespaces/namespaces_pb.d.ts +270 -0
  498. package/src/platform/policy/namespaces/namespaces_pb.js +110 -0
  499. package/src/platform/policy/objects_pb.d.ts +725 -0
  500. package/src/platform/policy/objects_pb.js +288 -0
  501. package/src/platform/policy/resourcemapping/resource_mapping_connect.d.ts +259 -0
  502. package/src/platform/policy/resourcemapping/resource_mapping_connect.js +259 -0
  503. package/src/platform/policy/resourcemapping/resource_mapping_pb.d.ts +314 -0
  504. package/src/platform/policy/resourcemapping/resource_mapping_pb.js +142 -0
  505. package/src/platform/policy/selectors_pb.d.ts +269 -0
  506. package/src/platform/policy/selectors_pb.js +110 -0
  507. package/src/platform/policy/subjectmapping/subject_mapping_connect.d.ts +118 -0
  508. package/src/platform/policy/subjectmapping/subject_mapping_connect.js +118 -0
  509. package/src/platform/policy/subjectmapping/subject_mapping_pb.d.ts +672 -0
  510. package/src/platform/policy/subjectmapping/subject_mapping_pb.js +260 -0
  511. package/src/platform/wellknownconfiguration/wellknown_configuration_connect.d.ts +26 -0
  512. package/src/platform/wellknownconfiguration/wellknown_configuration_connect.js +26 -0
  513. package/src/platform/wellknownconfiguration/wellknown_configuration_pb.d.ts +75 -0
  514. package/src/platform/wellknownconfiguration/wellknown_configuration_pb.js +35 -0
  515. package/src/policy/api.ts +61 -0
  516. package/src/policy/attributes.ts +117 -0
  517. package/src/policy/granter.ts +181 -0
  518. package/src/tdf/AttributeObject.ts +27 -0
  519. package/src/tdf/AttributeObjectJwt.ts +3 -0
  520. package/src/tdf/Crypto.ts +42 -0
  521. package/src/tdf/EntityObject.ts +18 -0
  522. package/src/tdf/NanoTDF/NanoTDF.ts +120 -0
  523. package/src/tdf/Policy.ts +51 -0
  524. package/src/tdf/PolicyObject.ts +12 -0
  525. package/src/tdf/TypedArray.ts +12 -0
  526. package/src/tdf/index.ts +6 -0
  527. package/src/types/index.ts +55 -0
  528. package/src/utils.ts +149 -0
  529. package/src/version.ts +9 -0
  530. package/tdf3/index.ts +91 -0
  531. package/tdf3/package-lock.json +6 -0
  532. package/tdf3/package.json +3 -0
  533. package/tdf3/src/assertions.ts +191 -0
  534. package/tdf3/src/binary.ts +195 -0
  535. package/tdf3/src/ciphers/aes-gcm-cipher.ts +76 -0
  536. package/tdf3/src/ciphers/algorithms.ts +9 -0
  537. package/tdf3/src/ciphers/index.ts +2 -0
  538. package/tdf3/src/ciphers/symmetric-cipher-base.ts +38 -0
  539. package/tdf3/src/client/DecoratedReadableStream.ts +148 -0
  540. package/tdf3/src/client/builders.ts +701 -0
  541. package/tdf3/src/client/index.ts +637 -0
  542. package/tdf3/src/client/validation.ts +79 -0
  543. package/tdf3/src/crypto/crypto-utils.ts +119 -0
  544. package/tdf3/src/crypto/declarations.ts +89 -0
  545. package/tdf3/src/crypto/index.ts +394 -0
  546. package/tdf3/src/index.ts +4 -0
  547. package/tdf3/src/models/attribute-set.ts +142 -0
  548. package/tdf3/src/models/encryption-information.ts +172 -0
  549. package/tdf3/src/models/index.ts +8 -0
  550. package/tdf3/src/models/key-access.ts +128 -0
  551. package/tdf3/src/models/manifest.ts +9 -0
  552. package/tdf3/src/models/payload.ts +6 -0
  553. package/tdf3/src/models/policy.ts +35 -0
  554. package/tdf3/src/models/upsert-response.ts +17 -0
  555. package/tdf3/src/tdf.ts +1351 -0
  556. package/tdf3/src/templates/default.html.ts +105 -0
  557. package/tdf3/src/templates/escaper.ts +10 -0
  558. package/tdf3/src/templates/index.ts +2 -0
  559. package/tdf3/src/utils/buffer-crc32.ts +46 -0
  560. package/tdf3/src/utils/chunkers.ts +118 -0
  561. package/tdf3/src/utils/index.ts +309 -0
  562. package/tdf3/src/utils/keysplit.ts +63 -0
  563. package/tdf3/src/utils/zip-reader.ts +341 -0
  564. package/tdf3/src/utils/zip-writer.ts +375 -0
  565. package/tdf3/src/version.ts +2 -0
  566. package/tdf3/types.d.ts +14 -0
package/package.json ADDED
@@ -0,0 +1,126 @@
1
+ {
2
+ "name": "@opentdf/sdk",
3
+ "version": "0.1.0-beta.1701",
4
+ "description": "OpenTDF for the Web",
5
+ "homepage": "https://github.com/opentdf/web-sdk",
6
+ "bugs": {
7
+ "url": "https://github.com/opentdf/web-sdk/issues"
8
+ },
9
+ "files": [
10
+ "dist/*/src/**",
11
+ "dist/*/tdf3/**",
12
+ "dist/*/*.json",
13
+ "src/**",
14
+ "tdf3/**",
15
+ "README.md"
16
+ ],
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/opentdf/web-sdk.git",
20
+ "directory": "lib"
21
+ },
22
+ "license": "BSD-3-Clause-Clear",
23
+ "author": "Virtru",
24
+ "types": "./dist/types/tdf3/index.d.ts",
25
+ "main": "./dist/cjs/tdf3/index.js",
26
+ "exports": {
27
+ ".": {
28
+ "types": "./dist/types/tdf3/index.d.ts",
29
+ "require": "./dist/cjs/tdf3/index.js",
30
+ "import": "./dist/web/tdf3/index.js"
31
+ },
32
+ "./assertions": {
33
+ "default": {
34
+ "types": "./dist/types/tdf3/src/assertions.d.ts",
35
+ "require": "./dist/cjs/tdf3/src/assertions.js",
36
+ "import": "./dist/web/tdf3/src/assertions.js"
37
+ }
38
+ },
39
+ "./encodings": {
40
+ "default": {
41
+ "types": "./dist/types/src/encodings/index.d.ts",
42
+ "require": "./dist/cjs/src/encodings/index.js",
43
+ "import": "./dist/web/src/encodings/index.js"
44
+ }
45
+ },
46
+ "./nano": {
47
+ "types": "./dist/types/src/index.d.ts",
48
+ "require": "./dist/cjs/src/index.js",
49
+ "import": "./dist/web/src/index.js"
50
+ }
51
+ },
52
+ "scripts": {
53
+ "build": "npm run clean && tsc && tsc --project tsconfig.commonjs.json && ../scripts/add-module-types.sh",
54
+ "build:watch": "tsc --watch",
55
+ "clean": "rm -rf {build,coverage,dist,tests/mocha/dist}",
56
+ "coverage:merge": "for x in mocha wtr; do cp coverage/$x/coverage-final.json coverage/$x.json; done; nyc report --reporter text --reporter lcov -t coverage --lines 75 --statements 75 --branches 70 --functions 65 --check-coverage >coverage/coverage.txt",
57
+ "doc": "typedoc --out dist/docs src/index.ts",
58
+ "format": "prettier --write \"{src,tdf3,tests}/**/*.ts\"",
59
+ "license-check": "license-checker-rseidelsohn --production --onlyAllow 'Apache-2.0; BSD; CC-BY-4.0; ISC; MIT'",
60
+ "lint": "eslint ./src/**/*.ts ./tdf3/**/*.ts ./tests/**/*.ts",
61
+ "prepack": "npm run build",
62
+ "test": "npm run build && npm run test:with-server",
63
+ "test:with-server": "node dist/web/tests/server.js & trap \"node dist/web/tests/stopServer.js\" EXIT; npm run test:mocha && npm run test:wtr && npm run test:browser && npm run coverage:merge",
64
+ "test:browser": "npx webpack --config webpack.test.config.cjs && npx karma start karma.conf.cjs",
65
+ "test:mocha": "c8 --exclude=\"dist/web/tests/**/*\" --report-dir=./coverage/mocha mocha 'dist/web/tests/mocha/**/*.spec.js' --file dist/web/tests/mocha/setup.js && npx c8 report --reporter=json --report-dir=./coverage/mocha",
66
+ "test:wtr": "web-test-runner",
67
+ "watch": "(trap 'kill 0' SIGINT; npm run build && (npm run build:watch & npm run test -- --watch))"
68
+ },
69
+ "dependencies": {
70
+ "axios": "^1.6.1",
71
+ "axios-retry": "^3.9.0",
72
+ "base64-js": "^1.5.1",
73
+ "browser-fs-access": "^0.34.1",
74
+ "buffer-crc32": "^0.2.13",
75
+ "dpop": "^1.2.0",
76
+ "eventemitter3": "^5.0.1",
77
+ "jose": "^4.14.4",
78
+ "json-canonicalize": "^1.0.6",
79
+ "streamsaver": "^2.0.6",
80
+ "uuid": "~9.0.0"
81
+ },
82
+ "devDependencies": {
83
+ "@esm-bundle/chai": "~4.3.4-fix.0",
84
+ "@types/buffer-crc32": "^0.2.4",
85
+ "@types/chai": "~4.3.5",
86
+ "@types/jest": "^29.5.3",
87
+ "@types/jsdom": "^21.1.7",
88
+ "@types/jsonwebtoken": "~9.0.2",
89
+ "@types/mocha": "~10.0.1",
90
+ "@types/node": "^20.4.5",
91
+ "@types/send": "^0.17.1",
92
+ "@types/sinon": "~10.0.15",
93
+ "@types/streamsaver": "^2.0.1",
94
+ "@types/uuid": "~9.0.2",
95
+ "@types/wicg-file-system-access": "^2020.9.6",
96
+ "@typescript-eslint/eslint-plugin": "^6.2.1",
97
+ "@typescript-eslint/parser": "^6.2.1",
98
+ "@web/dev-server-esbuild": "^1.0.3",
99
+ "@web/dev-server-rollup": "^0.6.4",
100
+ "@web/test-runner": "^0.19.0",
101
+ "@web/test-runner-commands": "^0.9.0",
102
+ "audit-ci": "^6.6.1",
103
+ "c8": "^8.0.1",
104
+ "chai": "^4.3.7",
105
+ "colors": "^1.4.0",
106
+ "eslint": "^8.46.0",
107
+ "eslint-config-prettier": "^8.9.0",
108
+ "glob": "^10.3.3",
109
+ "jsdom": "^25.0.1",
110
+ "karma": "^6.4.4",
111
+ "karma-chrome-launcher": "^3.2.0",
112
+ "karma-mocha": "^2.0.1",
113
+ "license-checker-rseidelsohn": "^4.2.6",
114
+ "mocha": "^10.8.2",
115
+ "nyc": "^17.1.0",
116
+ "prettier": "^3.3.3",
117
+ "process": "^0.11.10",
118
+ "rollup": "^4.25.0",
119
+ "sinon": "~15.2.0",
120
+ "tsconfig-paths": "^4.2.0",
121
+ "typedoc": "^0.24.8",
122
+ "typescript": "5.1.6",
123
+ "webpack": "^5.96.1",
124
+ "webpack-cli": "^5.1.4"
125
+ }
126
+ }
package/src/access.ts ADDED
@@ -0,0 +1,198 @@
1
+ import { type AuthProvider } from './auth/auth.js';
2
+ import {
3
+ InvalidFileError,
4
+ NetworkError,
5
+ PermissionDeniedError,
6
+ ServiceError,
7
+ UnauthenticatedError,
8
+ } from './errors.js';
9
+ import { pemToCryptoPublicKey, validateSecureUrl } from './utils.js';
10
+
11
+ export class RewrapRequest {
12
+ signedRequestToken = '';
13
+ }
14
+
15
+ export class RewrapResponse {
16
+ entityWrappedKey = '';
17
+ sessionPublicKey = '';
18
+ }
19
+
20
+ /**
21
+ * Get a rewrapped access key to the document, if possible
22
+ * @param url Key access server rewrap endpoint
23
+ * @param requestBody a signed request with an encrypted document key
24
+ * @param authProvider Authorization middleware
25
+ * @param clientVersion
26
+ */
27
+ export async function fetchWrappedKey(
28
+ url: string,
29
+ requestBody: RewrapRequest,
30
+ authProvider: AuthProvider,
31
+ clientVersion: string
32
+ ): Promise<RewrapResponse> {
33
+ const req = await authProvider.withCreds({
34
+ url,
35
+ method: 'POST',
36
+ headers: {
37
+ 'Content-Type': 'application/json',
38
+ 'virtru-ntdf-version': clientVersion,
39
+ },
40
+ body: JSON.stringify(requestBody),
41
+ });
42
+
43
+ try {
44
+ const response = await fetch(req.url, {
45
+ method: req.method,
46
+ mode: 'cors', // no-cors, *cors, same-origin
47
+ cache: 'no-cache', // *default, no-cache, reload, force-cache, only-if-cached
48
+ credentials: 'same-origin', // include, *same-origin, omit
49
+ headers: req.headers,
50
+ redirect: 'follow', // manual, *follow, error
51
+ referrerPolicy: 'no-referrer', // no-referrer, *no-referrer-when-downgrade, origin, origin-when-cross-origin, same-origin, strict-origin, strict-origin-when-cross-origin, unsafe-url
52
+ body: req.body as BodyInit,
53
+ });
54
+
55
+ if (!response.ok) {
56
+ switch (response.status) {
57
+ case 400:
58
+ throw new InvalidFileError(
59
+ `400 for [${req.url}]: rewrap failure [${await response.text()}]`
60
+ );
61
+ case 401:
62
+ throw new UnauthenticatedError(`401 for [${req.url}]`);
63
+ case 403:
64
+ throw new PermissionDeniedError(`403 for [${req.url}]`);
65
+ default:
66
+ throw new NetworkError(
67
+ `${req.method} ${req.url} => ${response.status} ${response.statusText}`
68
+ );
69
+ }
70
+ }
71
+
72
+ return response.json();
73
+ } catch (e) {
74
+ throw new NetworkError(`unable to fetch wrapped key from [${url}]: ${e}`);
75
+ }
76
+ }
77
+
78
+ export type KasPublicKeyAlgorithm = 'ec:secp256r1' | 'rsa:2048';
79
+
80
+ /**
81
+ * Information about one of a KAS's published public keys.
82
+ * A KAS may publish multiple keys with a given algorithm type.
83
+ */
84
+ export type KasPublicKeyInfo = {
85
+ /** The locator to the given KAS associated with this key */
86
+ url: string;
87
+
88
+ /** The encryption algorithm the key is to be used with. */
89
+ algorithm: KasPublicKeyAlgorithm;
90
+
91
+ /** If present, an identifier which is tied to this specific key. */
92
+ kid?: string;
93
+
94
+ /** The key value, encoded within a PEM envelope */
95
+ publicKey: string;
96
+
97
+ /** A subtle crypto version of the key.
98
+ * This can be used for wrapping key data for key access objects (with RSA)
99
+ * or to derive key data (with EC keys). */
100
+ key: Promise<CryptoKey>;
101
+ };
102
+
103
+ async function noteInvalidPublicKey(url: string, r: Promise<CryptoKey>): Promise<CryptoKey> {
104
+ try {
105
+ return await r;
106
+ } catch (e) {
107
+ if (e instanceof TypeError) {
108
+ throw new ServiceError(`invalid public key from [${url}]`, e);
109
+ }
110
+ throw e;
111
+ }
112
+ }
113
+
114
+ /**
115
+ * If we have KAS url but not public key we can fetch it from KAS, fetching
116
+ * the value from `${kas}/kas_public_key`.
117
+ */
118
+ export async function fetchECKasPubKey(kasEndpoint: string): Promise<KasPublicKeyInfo> {
119
+ validateSecureUrl(kasEndpoint);
120
+ const pkUrlV2 = `${kasEndpoint}/v2/kas_public_key?algorithm=ec:secp256r1&v=2`;
121
+ const kasPubKeyResponseV2 = await fetch(pkUrlV2);
122
+ if (!kasPubKeyResponseV2.ok) {
123
+ switch (kasPubKeyResponseV2.status) {
124
+ case 404:
125
+ // v2 not implemented, perhaps a legacy server
126
+ break;
127
+ case 401:
128
+ throw new UnauthenticatedError(`401 for [${pkUrlV2}]`);
129
+ case 403:
130
+ throw new PermissionDeniedError(`403 for [${pkUrlV2}]`);
131
+ default:
132
+ throw new NetworkError(
133
+ `${pkUrlV2} => ${kasPubKeyResponseV2.status} ${kasPubKeyResponseV2.statusText}`
134
+ );
135
+ }
136
+ // most likely a server that does not implement v2 endpoint, so no key identifier
137
+ const pkUrlV1 = `${kasEndpoint}/kas_public_key?algorithm=ec:secp256r1`;
138
+ const r2 = await fetch(pkUrlV1);
139
+ if (!r2.ok) {
140
+ switch (r2.status) {
141
+ case 401:
142
+ throw new UnauthenticatedError(`401 for [${pkUrlV2}]`);
143
+ case 403:
144
+ throw new PermissionDeniedError(`403 for [${pkUrlV2}]`);
145
+ default:
146
+ throw new NetworkError(
147
+ `unable to load KAS public key from [${pkUrlV1}]. Received [${r2.status}:${r2.statusText}]`
148
+ );
149
+ }
150
+ }
151
+ const pem = await r2.json();
152
+ return {
153
+ key: noteInvalidPublicKey(pkUrlV1, pemToCryptoPublicKey(pem)),
154
+ publicKey: pem,
155
+ url: kasEndpoint,
156
+ algorithm: 'ec:secp256r1',
157
+ };
158
+ }
159
+ const jsonContent = await kasPubKeyResponseV2.json();
160
+ const { publicKey, kid }: KasPublicKeyInfo = jsonContent;
161
+ if (!publicKey) {
162
+ throw new NetworkError(
163
+ `invalid response from public key endpoint [${JSON.stringify(jsonContent)}]`
164
+ );
165
+ }
166
+ return {
167
+ key: noteInvalidPublicKey(pkUrlV2, pemToCryptoPublicKey(publicKey)),
168
+ publicKey,
169
+ url: kasEndpoint,
170
+ algorithm: 'ec:secp256r1',
171
+ ...(kid && { kid }),
172
+ };
173
+ }
174
+
175
+ const origin = (u: string): string => {
176
+ try {
177
+ return new URL(u).origin;
178
+ } catch (e) {
179
+ console.log(`invalid kas url: [${u}]`);
180
+ throw e;
181
+ }
182
+ };
183
+
184
+ export class OriginAllowList {
185
+ origins: string[];
186
+ allowAll: boolean;
187
+ constructor(urls: string[], allowAll?: boolean) {
188
+ this.origins = urls.map(origin);
189
+ urls.forEach(validateSecureUrl);
190
+ this.allowAll = !!allowAll;
191
+ }
192
+ allows(url: string): boolean {
193
+ if (this.allowAll) {
194
+ return true;
195
+ }
196
+ return this.origins.includes(origin(url));
197
+ }
198
+ }
@@ -0,0 +1,79 @@
1
+ import axios, { type AxiosResponse, type RawAxiosRequestConfig } from 'axios';
2
+
3
+ import { AppIdAuthProvider, HttpRequest } from './auth.js';
4
+
5
+ const { request } = axios;
6
+
7
+ // Required `any` below is to match type from axios library.
8
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
+ type RequestFunctor = <T = any, R = AxiosResponse<T>>(config: RawAxiosRequestConfig) => Promise<R>;
10
+
11
+ /**
12
+ * Client for EAS interaction, specifically fetching entity object.
13
+ */
14
+ class Eas {
15
+ authProvider: AppIdAuthProvider;
16
+
17
+ endpoint: string;
18
+
19
+ requestFunctor: RequestFunctor;
20
+
21
+ /**
22
+ * Create an object for accessing an Entity Attribute Service.
23
+ * @param {object} config - options to configure this EAS accessor
24
+ * @param {AuthProvider|function} config.authProvider - interceptor for `http-request.Request` object manipulation
25
+ * @param {string} config.endpoint - the URI to connect to
26
+ * @param {function} [config.requestFunctor=request] - http request async function object
27
+ */
28
+ constructor({
29
+ authProvider,
30
+ endpoint,
31
+ requestFunctor,
32
+ }: {
33
+ authProvider: AppIdAuthProvider;
34
+ endpoint: string;
35
+ requestFunctor?: RequestFunctor;
36
+ }) {
37
+ this.authProvider = authProvider;
38
+ this.endpoint = endpoint;
39
+ this.requestFunctor = requestFunctor || request;
40
+ }
41
+
42
+ /**
43
+ * Request an entity object for the current user.
44
+ * @param {object} config - options for the request
45
+ * @param {string} config.publicKey - String encoded public key from the keypair to be used with any subsequent requests refering to the returned EO
46
+ * @param {object} [config.etc] - additional parameters to be passed to the EAS entity-object endpoint
47
+ */
48
+ async fetchEntityObject({ publicKey, ...etc }: { publicKey: string }) {
49
+ // Create a skeleton http request for EAS.
50
+ const incredibleHttpReq: HttpRequest = {
51
+ url: this.endpoint,
52
+ method: 'POST',
53
+ headers: { 'Content-Type': 'application/json' },
54
+ body: { publicKey, ...etc },
55
+ };
56
+
57
+ // Delegate modifications to the auth provider.
58
+ // TODO: Handle various exception cases from interface docs.
59
+ const httpReq = await this.authProvider.withCreds(incredibleHttpReq);
60
+
61
+ // Execute the http request using axios.
62
+ const axiosParams: RawAxiosRequestConfig = {
63
+ method: httpReq.method,
64
+ headers: httpReq.headers,
65
+ url: httpReq.url,
66
+ params: undefined,
67
+ data: undefined,
68
+ };
69
+ // Allow the authProvider to change the method.
70
+ if (httpReq.method === 'POST' || httpReq.method === 'PATCH' || httpReq.method === 'PUT') {
71
+ axiosParams.data = httpReq.body;
72
+ } else {
73
+ axiosParams.params = httpReq.body;
74
+ }
75
+ return (await this.requestFunctor(axiosParams)).data;
76
+ }
77
+ }
78
+
79
+ export default Eas;
@@ -0,0 +1,141 @@
1
+ import { type JWTHeaderParameters, type JWTPayload, type KeyLike, SignJWT } from 'jose';
2
+
3
+ export type HttpMethod =
4
+ | 'GET'
5
+ | 'HEAD'
6
+ | 'POST'
7
+ | 'PUT'
8
+ | 'DELETE'
9
+ | 'CONNECT'
10
+ | 'OPTIONS'
11
+ | 'TRACE'
12
+ | 'PATCH';
13
+
14
+ /**
15
+ * Generic HTTP request interface used by AuthProvider implementers.
16
+ */
17
+ export class HttpRequest {
18
+ headers: Record<string, string>;
19
+
20
+ method: HttpMethod;
21
+
22
+ params?: object;
23
+
24
+ url: string;
25
+
26
+ body?: BodyInit | null | unknown;
27
+
28
+ constructor() {
29
+ this.headers = {};
30
+ this.params = {};
31
+ this.method = 'POST';
32
+ this.url = '';
33
+ }
34
+ }
35
+
36
+ /**
37
+ * Appends the given `newHeaders` to the headers listed in HttpRequest, overwriting
38
+ * any with the same name. NOTE: Case sensitive.
39
+ * @param httpReq the source request
40
+ * @param newHeaders header name/value pairs
41
+ * @returns an updated variant of the request
42
+ */
43
+ export function withHeaders(httpReq: HttpRequest, newHeaders: Record<string, string>): HttpRequest {
44
+ const headers = {
45
+ ...httpReq.headers,
46
+ ...newHeaders,
47
+ };
48
+ return { ...httpReq, headers };
49
+ }
50
+
51
+ function getTimestampInSeconds() {
52
+ return Math.floor(Date.now() / 1000);
53
+ }
54
+
55
+ /**
56
+ * Generate a JWT (or JWS-ed object)
57
+ * @param toSign the data to sign. Interpreted as JWTPayload but AFAIK this isn't required
58
+ * @param privateKey an RSA key
59
+ * @returns the signed object, with a JWS header. This may be a JWT.
60
+ */
61
+ export async function reqSignature(
62
+ toSign: unknown,
63
+ privateKey: KeyLike,
64
+ jwtProtectedHeader: JWTHeaderParameters = { alg: 'RS256' }
65
+ ) {
66
+ const now = getTimestampInSeconds();
67
+ const anHour = 3600;
68
+ return new SignJWT(toSign as JWTPayload)
69
+ .setProtectedHeader(jwtProtectedHeader)
70
+ .setIssuedAt(now - anHour)
71
+ .setExpirationTime(now + anHour)
72
+ .sign(privateKey);
73
+ }
74
+
75
+ /**
76
+ * A utility type for getting and updating a bearer token to associate with
77
+ * HTTP requests to the backend services, notably rewrap and upsert endpoints.
78
+ *
79
+ * In the TDF protocol, this bearer token will be a wrapper around a signed
80
+ * ephemeral key, to be included in
81
+ * [the claims object](https://github.com/opentdf/spec/blob/main/schema/ClaimsObject.md).
82
+ */
83
+ export type AuthProvider = {
84
+ /**
85
+ * This function should be called if the consumer of this auth provider
86
+ * changes the client keypair, or wishes to set the keypair after creating
87
+ * the object.
88
+ *
89
+ * Calling this function will (optionally) trigger a forcible token refresh
90
+ * using the cached refresh token, and update the auth server config with the
91
+ * current key.
92
+ *
93
+ * @param signingKey the client signing key pair. Will be bound
94
+ * to the OIDC token and require a DPoP header, when set.
95
+ */
96
+ updateClientPublicKey(signingKey?: CryptoKeyPair): Promise<void>;
97
+
98
+ /**
99
+ * Augment the provided http request with custom auth info to be used by backend services.
100
+ *
101
+ * @param httpReq - Required. An http request pre-populated with the data public key.
102
+ */
103
+ withCreds(httpReq: HttpRequest): Promise<HttpRequest>;
104
+ };
105
+
106
+ export function isAuthProvider(a?: unknown): a is AuthProvider {
107
+ if (!a || typeof a != 'object') {
108
+ return false;
109
+ }
110
+ return 'withCreds' in a;
111
+ }
112
+
113
+ /**
114
+ * An AuthProvider encapsulates all logic necessary to authenticate to a backend service, in the
115
+ * vein of <a href="https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Credentials.html">AWS.Credentials</a>.
116
+ * <br/><br/>
117
+ * The client will call into its configured AuthProvider to decorate remote TDF service calls with necessary
118
+ * authentication info. This approach allows the client to be agnostic to the auth scheme, allowing for
119
+ * methods like identify federation and custom service credentials to be used and changed at the developer's will.
120
+ * <br/><br/>
121
+ * This class is not intended to be used on its own. See the documented subclasses for public-facing implementations.
122
+ * <ul>
123
+ * <li><a href="EmailCodeAuthProvider.html">EmailCodeAuthProvider</li>
124
+ * <li><a href="GoogleAuthProvider.html">GoogleAuthProvider</li>
125
+ * <li><a href="O365AuthProvider.html">O365AuthProvider</li>
126
+ * <li><a href="OutlookAuthProvider.html">OutlookAuthProvider</li>
127
+ * <li><a href="VirtruCredentialsAuthProvider.html">VirtruCredentialsAuthProvider</li>
128
+ * </ul>
129
+ */
130
+ export abstract class AppIdAuthProvider {
131
+ /**
132
+ * Augment the provided http request with custom auth info to be used by backend services.
133
+ *
134
+ * @param httpReq - Required. An http request pre-populated with the data public key.
135
+ */
136
+ abstract withCreds(httpReq: HttpRequest): Promise<HttpRequest>;
137
+
138
+ abstract _getName(): string;
139
+ }
140
+
141
+ export default AppIdAuthProvider;
@@ -0,0 +1,32 @@
1
+ import { ConfigurationError } from '../errors.js';
2
+ import { AuthProvider, type HttpRequest } from './auth.js';
3
+ import { AccessToken, type ClientSecretCredentials } from './oidc.js';
4
+
5
+ export class OIDCClientCredentialsProvider implements AuthProvider {
6
+ oidcAuth: AccessToken;
7
+
8
+ constructor({
9
+ clientId,
10
+ clientSecret,
11
+ oidcOrigin,
12
+ }: Partial<ClientSecretCredentials> & Omit<ClientSecretCredentials, 'exchange'>) {
13
+ if (!clientId || !clientSecret) {
14
+ throw new ConfigurationError('clientId & clientSecret required for client credentials flow');
15
+ }
16
+
17
+ this.oidcAuth = new AccessToken({
18
+ exchange: 'client',
19
+ clientId,
20
+ clientSecret,
21
+ oidcOrigin,
22
+ });
23
+ }
24
+
25
+ async updateClientPublicKey(signingKey: CryptoKeyPair): Promise<void> {
26
+ await this.oidcAuth.refreshTokenClaimsWithClientPubkeyIfNeeded(signingKey);
27
+ }
28
+
29
+ async withCreds(httpReq: HttpRequest): Promise<HttpRequest> {
30
+ return this.oidcAuth.withCreds(httpReq);
31
+ }
32
+ }
@@ -0,0 +1,41 @@
1
+ import { ConfigurationError } from '../errors.js';
2
+ import { type AuthProvider, type HttpRequest } from './auth.js';
3
+ import { AccessToken, type ExternalJwtCredentials } from './oidc.js';
4
+
5
+ export class OIDCExternalJwtProvider implements AuthProvider {
6
+ oidcAuth: AccessToken;
7
+ externalJwt?: string;
8
+
9
+ constructor({
10
+ clientId,
11
+ externalJwt,
12
+ oidcOrigin,
13
+ }: Partial<ExternalJwtCredentials> & Omit<ExternalJwtCredentials, 'exchange'>) {
14
+ if (!clientId || !externalJwt) {
15
+ throw new ConfigurationError('external JWT exchange reequires client id and jwt');
16
+ }
17
+
18
+ this.oidcAuth = new AccessToken({
19
+ exchange: 'external',
20
+ clientId,
21
+ oidcOrigin,
22
+ externalJwt,
23
+ });
24
+
25
+ this.externalJwt = externalJwt;
26
+ }
27
+
28
+ async updateClientPublicKey(signingKey: CryptoKeyPair): Promise<void> {
29
+ this.oidcAuth.refreshTokenClaimsWithClientPubkeyIfNeeded(signingKey);
30
+ }
31
+
32
+ async withCreds(httpReq: HttpRequest): Promise<HttpRequest> {
33
+ //If we've been seeded with an externally-issued JWT, consume it
34
+ //and exchange it for a Virtru bearer token.
35
+ if (this.externalJwt) {
36
+ await this.oidcAuth.exchangeForRefreshToken();
37
+ delete this.externalJwt;
38
+ }
39
+ return this.oidcAuth.withCreds(httpReq);
40
+ }
41
+ }
@@ -0,0 +1,41 @@
1
+ import { ConfigurationError } from '../errors.js';
2
+ import { type AuthProvider, type HttpRequest } from './auth.js';
3
+ import { AccessToken, type RefreshTokenCredentials } from './oidc.js';
4
+
5
+ export class OIDCRefreshTokenProvider implements AuthProvider {
6
+ oidcAuth: AccessToken;
7
+ refreshToken?: string;
8
+
9
+ constructor({
10
+ clientId,
11
+ refreshToken,
12
+ oidcOrigin,
13
+ }: Partial<RefreshTokenCredentials> & Omit<RefreshTokenCredentials, 'exchange'>) {
14
+ if (!clientId || !refreshToken) {
15
+ throw new ConfigurationError('refresh token or client id missing');
16
+ }
17
+
18
+ this.oidcAuth = new AccessToken({
19
+ exchange: 'refresh',
20
+ clientId,
21
+ refreshToken: refreshToken,
22
+ oidcOrigin,
23
+ });
24
+ this.refreshToken = refreshToken;
25
+ }
26
+
27
+ async updateClientPublicKey(signingKey: CryptoKeyPair): Promise<void> {
28
+ await this.oidcAuth.refreshTokenClaimsWithClientPubkeyIfNeeded(signingKey);
29
+ }
30
+
31
+ async withCreds(httpReq: HttpRequest): Promise<HttpRequest> {
32
+ //If we've been seeded with an externally-issued refresh token, consume it
33
+ //and exchange it for a Virtru bearer token - if it's already been consumed,
34
+ //skip this step
35
+ if (this.refreshToken) {
36
+ await this.oidcAuth.exchangeForRefreshToken();
37
+ delete this.refreshToken;
38
+ }
39
+ return this.oidcAuth.withCreds(httpReq);
40
+ }
41
+ }