@opentdf/sdk 0.8.0-beta.71 → 0.8.0-beta.75

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 (260) hide show
  1. package/README.md +5 -30
  2. package/dist/cjs/src/{nanotdf-crypto → crypto}/ciphers.js +1 -1
  3. package/dist/cjs/src/{nanotdf-crypto → crypto}/decrypt.js +1 -1
  4. package/dist/cjs/src/{nanotdf-crypto → crypto}/digest.js +1 -1
  5. package/dist/cjs/src/{nanotdf-crypto → crypto}/ecdsaSignature.js +2 -2
  6. package/dist/cjs/src/{nanotdf-crypto → crypto}/encrypt.js +1 -1
  7. package/dist/cjs/src/{nanotdf-crypto → crypto}/enums.js +1 -1
  8. package/dist/cjs/src/crypto/exportCryptoKey.js +20 -0
  9. package/dist/cjs/src/{nanotdf-crypto → crypto}/generateKeyPair.js +1 -1
  10. package/dist/cjs/src/{nanotdf-crypto → crypto}/generateRandomNumber.js +1 -1
  11. package/dist/cjs/src/{nanotdf-crypto → crypto}/index.js +1 -1
  12. package/dist/cjs/src/{nanotdf-crypto → crypto}/keyAgreement.js +1 -1
  13. package/dist/cjs/src/{nanotdf-crypto → crypto}/pemPublicToCrypto.js +1 -1
  14. package/dist/cjs/src/opentdf.js +9 -260
  15. package/dist/cjs/src/utils.js +2 -2
  16. package/dist/cjs/tdf3/index.js +7 -8
  17. package/dist/cjs/tdf3/src/models/key-access.js +4 -4
  18. package/dist/cjs/tdf3/src/tdf.js +4 -4
  19. package/dist/types/src/crypto/ciphers.d.ts.map +1 -0
  20. package/dist/types/src/crypto/decrypt.d.ts.map +1 -0
  21. package/dist/types/src/crypto/digest.d.ts.map +1 -0
  22. package/dist/types/src/crypto/ecdsaSignature.d.ts.map +1 -0
  23. package/dist/types/src/crypto/encrypt.d.ts.map +1 -0
  24. package/dist/types/src/crypto/enums.d.ts.map +1 -0
  25. package/dist/types/src/crypto/exportCryptoKey.d.ts.map +1 -0
  26. package/dist/types/src/crypto/generateKeyPair.d.ts.map +1 -0
  27. package/dist/types/src/crypto/generateRandomNumber.d.ts.map +1 -0
  28. package/dist/types/src/crypto/index.d.ts.map +1 -0
  29. package/dist/types/src/crypto/keyAgreement.d.ts.map +1 -0
  30. package/dist/types/src/crypto/pemPublicToCrypto.d.ts.map +1 -0
  31. package/dist/types/src/opentdf.d.ts +1 -65
  32. package/dist/types/src/opentdf.d.ts.map +1 -1
  33. package/dist/types/tdf3/index.d.ts +4 -3
  34. package/dist/types/tdf3/index.d.ts.map +1 -1
  35. package/dist/web/src/crypto/ciphers.js +14 -0
  36. package/dist/web/src/{nanotdf-crypto → crypto}/decrypt.js +1 -1
  37. package/dist/web/src/crypto/digest.js +4 -0
  38. package/dist/web/src/{nanotdf-crypto → crypto}/ecdsaSignature.js +2 -2
  39. package/dist/web/src/{nanotdf-crypto → crypto}/encrypt.js +1 -1
  40. package/dist/web/src/{nanotdf-crypto → crypto}/enums.js +1 -1
  41. package/dist/web/src/crypto/exportCryptoKey.js +17 -0
  42. package/dist/web/src/crypto/generateKeyPair.js +10 -0
  43. package/dist/web/src/crypto/generateRandomNumber.js +9 -0
  44. package/dist/web/src/crypto/index.js +11 -0
  45. package/dist/web/src/{nanotdf-crypto → crypto}/keyAgreement.js +1 -1
  46. package/dist/web/src/{nanotdf-crypto → crypto}/pemPublicToCrypto.js +1 -1
  47. package/dist/web/src/opentdf.js +8 -255
  48. package/dist/web/src/utils.js +2 -2
  49. package/dist/web/tdf3/index.js +4 -3
  50. package/dist/web/tdf3/src/models/key-access.js +4 -4
  51. package/dist/web/tdf3/src/tdf.js +4 -4
  52. package/package.json +1 -6
  53. package/src/{nanotdf-crypto → crypto}/ecdsaSignature.ts +1 -1
  54. package/src/opentdf.ts +6 -343
  55. package/src/utils.ts +1 -1
  56. package/tdf3/index.ts +2 -12
  57. package/tdf3/src/models/key-access.ts +3 -3
  58. package/tdf3/src/tdf.ts +3 -3
  59. package/dist/cjs/src/nanoclients.js +0 -292
  60. package/dist/cjs/src/nanoindex.js +0 -47
  61. package/dist/cjs/src/nanotdf/Client.js +0 -315
  62. package/dist/cjs/src/nanotdf/NanoTDF.js +0 -94
  63. package/dist/cjs/src/nanotdf/browser-entry.js +0 -19
  64. package/dist/cjs/src/nanotdf/constants.js +0 -5
  65. package/dist/cjs/src/nanotdf/decrypt.js +0 -17
  66. package/dist/cjs/src/nanotdf/encrypt-dataset.js +0 -38
  67. package/dist/cjs/src/nanotdf/encrypt.js +0 -132
  68. package/dist/cjs/src/nanotdf/enum/CipherEnum.js +0 -13
  69. package/dist/cjs/src/nanotdf/enum/CurveNameEnum.js +0 -15
  70. package/dist/cjs/src/nanotdf/enum/EncodingEnum.js +0 -8
  71. package/dist/cjs/src/nanotdf/enum/PolicyTypeEnum.js +0 -11
  72. package/dist/cjs/src/nanotdf/enum/ProtocolEnum.js +0 -10
  73. package/dist/cjs/src/nanotdf/enum/ResourceLocatorIdentifierEnum.js +0 -11
  74. package/dist/cjs/src/nanotdf/helpers/calculateByCurve.js +0 -28
  75. package/dist/cjs/src/nanotdf/helpers/getHkdfSalt.js +0 -11
  76. package/dist/cjs/src/nanotdf/index.js +0 -25
  77. package/dist/cjs/src/nanotdf/interfaces/PolicyInterface.js +0 -3
  78. package/dist/cjs/src/nanotdf/models/Ciphers.js +0 -61
  79. package/dist/cjs/src/nanotdf/models/DefaultParams.js +0 -27
  80. package/dist/cjs/src/nanotdf/models/EcCurves.js +0 -39
  81. package/dist/cjs/src/nanotdf/models/Header.js +0 -255
  82. package/dist/cjs/src/nanotdf/models/Payload.js +0 -158
  83. package/dist/cjs/src/nanotdf/models/Policy/AbstractPolicy.js +0 -73
  84. package/dist/cjs/src/nanotdf/models/Policy/EmbeddedPolicy.js +0 -82
  85. package/dist/cjs/src/nanotdf/models/Policy/PolicyFactory.js +0 -38
  86. package/dist/cjs/src/nanotdf/models/Policy/RemotePolicy.js +0 -62
  87. package/dist/cjs/src/nanotdf/models/ResourceLocator.js +0 -211
  88. package/dist/cjs/src/nanotdf/models/Signature.js +0 -77
  89. package/dist/cjs/src/nanotdf-crypto/exportCryptoKey.js +0 -20
  90. package/dist/cjs/src/tdf/NanoTDF/NanoTDF.js +0 -38
  91. package/dist/cjs/src/types/index.js +0 -3
  92. package/dist/types/src/nanoclients.d.ts +0 -106
  93. package/dist/types/src/nanoclients.d.ts.map +0 -1
  94. package/dist/types/src/nanoindex.d.ts +0 -5
  95. package/dist/types/src/nanoindex.d.ts.map +0 -1
  96. package/dist/types/src/nanotdf/Client.d.ts +0 -91
  97. package/dist/types/src/nanotdf/Client.d.ts.map +0 -1
  98. package/dist/types/src/nanotdf/NanoTDF.d.ts +0 -24
  99. package/dist/types/src/nanotdf/NanoTDF.d.ts.map +0 -1
  100. package/dist/types/src/nanotdf/browser-entry.d.ts +0 -17
  101. package/dist/types/src/nanotdf/browser-entry.d.ts.map +0 -1
  102. package/dist/types/src/nanotdf/constants.d.ts +0 -2
  103. package/dist/types/src/nanotdf/constants.d.ts.map +0 -1
  104. package/dist/types/src/nanotdf/decrypt.d.ts +0 -9
  105. package/dist/types/src/nanotdf/decrypt.d.ts.map +0 -1
  106. package/dist/types/src/nanotdf/encrypt-dataset.d.ts +0 -11
  107. package/dist/types/src/nanotdf/encrypt-dataset.d.ts.map +0 -1
  108. package/dist/types/src/nanotdf/encrypt.d.ts +0 -13
  109. package/dist/types/src/nanotdf/encrypt.d.ts.map +0 -1
  110. package/dist/types/src/nanotdf/enum/CipherEnum.d.ts +0 -10
  111. package/dist/types/src/nanotdf/enum/CipherEnum.d.ts.map +0 -1
  112. package/dist/types/src/nanotdf/enum/CurveNameEnum.d.ts +0 -12
  113. package/dist/types/src/nanotdf/enum/CurveNameEnum.d.ts.map +0 -1
  114. package/dist/types/src/nanotdf/enum/EncodingEnum.d.ts +0 -5
  115. package/dist/types/src/nanotdf/enum/EncodingEnum.d.ts.map +0 -1
  116. package/dist/types/src/nanotdf/enum/PolicyTypeEnum.d.ts +0 -8
  117. package/dist/types/src/nanotdf/enum/PolicyTypeEnum.d.ts.map +0 -1
  118. package/dist/types/src/nanotdf/enum/ProtocolEnum.d.ts +0 -7
  119. package/dist/types/src/nanotdf/enum/ProtocolEnum.d.ts.map +0 -1
  120. package/dist/types/src/nanotdf/enum/ResourceLocatorIdentifierEnum.d.ts +0 -8
  121. package/dist/types/src/nanotdf/enum/ResourceLocatorIdentifierEnum.d.ts.map +0 -1
  122. package/dist/types/src/nanotdf/helpers/calculateByCurve.d.ts +0 -20
  123. package/dist/types/src/nanotdf/helpers/calculateByCurve.d.ts.map +0 -1
  124. package/dist/types/src/nanotdf/helpers/getHkdfSalt.d.ts +0 -8
  125. package/dist/types/src/nanotdf/helpers/getHkdfSalt.d.ts.map +0 -1
  126. package/dist/types/src/nanotdf/index.d.ts +0 -9
  127. package/dist/types/src/nanotdf/index.d.ts.map +0 -1
  128. package/dist/types/src/nanotdf/interfaces/PolicyInterface.d.ts +0 -17
  129. package/dist/types/src/nanotdf/interfaces/PolicyInterface.d.ts.map +0 -1
  130. package/dist/types/src/nanotdf/models/Ciphers.d.ts +0 -14
  131. package/dist/types/src/nanotdf/models/Ciphers.d.ts.map +0 -1
  132. package/dist/types/src/nanotdf/models/DefaultParams.d.ts +0 -21
  133. package/dist/types/src/nanotdf/models/DefaultParams.d.ts.map +0 -1
  134. package/dist/types/src/nanotdf/models/EcCurves.d.ts +0 -15
  135. package/dist/types/src/nanotdf/models/EcCurves.d.ts.map +0 -1
  136. package/dist/types/src/nanotdf/models/Header.d.ts +0 -73
  137. package/dist/types/src/nanotdf/models/Header.d.ts.map +0 -1
  138. package/dist/types/src/nanotdf/models/Payload.d.ts +0 -47
  139. package/dist/types/src/nanotdf/models/Payload.d.ts.map +0 -1
  140. package/dist/types/src/nanotdf/models/Policy/AbstractPolicy.d.ts +0 -52
  141. package/dist/types/src/nanotdf/models/Policy/AbstractPolicy.d.ts.map +0 -1
  142. package/dist/types/src/nanotdf/models/Policy/EmbeddedPolicy.d.ts +0 -35
  143. package/dist/types/src/nanotdf/models/Policy/EmbeddedPolicy.d.ts.map +0 -1
  144. package/dist/types/src/nanotdf/models/Policy/PolicyFactory.d.ts +0 -11
  145. package/dist/types/src/nanotdf/models/Policy/PolicyFactory.d.ts.map +0 -1
  146. package/dist/types/src/nanotdf/models/Policy/RemotePolicy.d.ts +0 -31
  147. package/dist/types/src/nanotdf/models/Policy/RemotePolicy.d.ts.map +0 -1
  148. package/dist/types/src/nanotdf/models/ResourceLocator.d.ts +0 -65
  149. package/dist/types/src/nanotdf/models/ResourceLocator.d.ts.map +0 -1
  150. package/dist/types/src/nanotdf/models/Signature.d.ts +0 -33
  151. package/dist/types/src/nanotdf/models/Signature.d.ts.map +0 -1
  152. package/dist/types/src/nanotdf-crypto/ciphers.d.ts.map +0 -1
  153. package/dist/types/src/nanotdf-crypto/decrypt.d.ts.map +0 -1
  154. package/dist/types/src/nanotdf-crypto/digest.d.ts.map +0 -1
  155. package/dist/types/src/nanotdf-crypto/ecdsaSignature.d.ts.map +0 -1
  156. package/dist/types/src/nanotdf-crypto/encrypt.d.ts.map +0 -1
  157. package/dist/types/src/nanotdf-crypto/enums.d.ts.map +0 -1
  158. package/dist/types/src/nanotdf-crypto/exportCryptoKey.d.ts.map +0 -1
  159. package/dist/types/src/nanotdf-crypto/generateKeyPair.d.ts.map +0 -1
  160. package/dist/types/src/nanotdf-crypto/generateRandomNumber.d.ts.map +0 -1
  161. package/dist/types/src/nanotdf-crypto/index.d.ts.map +0 -1
  162. package/dist/types/src/nanotdf-crypto/keyAgreement.d.ts.map +0 -1
  163. package/dist/types/src/nanotdf-crypto/pemPublicToCrypto.d.ts.map +0 -1
  164. package/dist/types/src/tdf/NanoTDF/NanoTDF.d.ts +0 -99
  165. package/dist/types/src/tdf/NanoTDF/NanoTDF.d.ts.map +0 -1
  166. package/dist/types/src/types/index.d.ts +0 -45
  167. package/dist/types/src/types/index.d.ts.map +0 -1
  168. package/dist/web/src/nanoclients.js +0 -287
  169. package/dist/web/src/nanoindex.js +0 -5
  170. package/dist/web/src/nanotdf/Client.js +0 -310
  171. package/dist/web/src/nanotdf/NanoTDF.js +0 -89
  172. package/dist/web/src/nanotdf/browser-entry.js +0 -14
  173. package/dist/web/src/nanotdf/constants.js +0 -2
  174. package/dist/web/src/nanotdf/decrypt.js +0 -14
  175. package/dist/web/src/nanotdf/encrypt-dataset.js +0 -32
  176. package/dist/web/src/nanotdf/encrypt.js +0 -126
  177. package/dist/web/src/nanotdf/enum/CipherEnum.js +0 -11
  178. package/dist/web/src/nanotdf/enum/CurveNameEnum.js +0 -13
  179. package/dist/web/src/nanotdf/enum/EncodingEnum.js +0 -6
  180. package/dist/web/src/nanotdf/enum/PolicyTypeEnum.js +0 -9
  181. package/dist/web/src/nanotdf/enum/ProtocolEnum.js +0 -8
  182. package/dist/web/src/nanotdf/enum/ResourceLocatorIdentifierEnum.js +0 -9
  183. package/dist/web/src/nanotdf/helpers/calculateByCurve.js +0 -24
  184. package/dist/web/src/nanotdf/helpers/getHkdfSalt.js +0 -8
  185. package/dist/web/src/nanotdf/index.js +0 -11
  186. package/dist/web/src/nanotdf/interfaces/PolicyInterface.js +0 -2
  187. package/dist/web/src/nanotdf/models/Ciphers.js +0 -54
  188. package/dist/web/src/nanotdf/models/DefaultParams.js +0 -22
  189. package/dist/web/src/nanotdf/models/EcCurves.js +0 -32
  190. package/dist/web/src/nanotdf/models/Header.js +0 -250
  191. package/dist/web/src/nanotdf/models/Payload.js +0 -156
  192. package/dist/web/src/nanotdf/models/Policy/AbstractPolicy.js +0 -71
  193. package/dist/web/src/nanotdf/models/Policy/EmbeddedPolicy.js +0 -77
  194. package/dist/web/src/nanotdf/models/Policy/PolicyFactory.js +0 -33
  195. package/dist/web/src/nanotdf/models/Policy/RemotePolicy.js +0 -57
  196. package/dist/web/src/nanotdf/models/ResourceLocator.js +0 -206
  197. package/dist/web/src/nanotdf/models/Signature.js +0 -74
  198. package/dist/web/src/nanotdf-crypto/ciphers.js +0 -14
  199. package/dist/web/src/nanotdf-crypto/digest.js +0 -4
  200. package/dist/web/src/nanotdf-crypto/exportCryptoKey.js +0 -17
  201. package/dist/web/src/nanotdf-crypto/generateKeyPair.js +0 -10
  202. package/dist/web/src/nanotdf-crypto/generateRandomNumber.js +0 -9
  203. package/dist/web/src/nanotdf-crypto/index.js +0 -11
  204. package/dist/web/src/tdf/NanoTDF/NanoTDF.js +0 -35
  205. package/dist/web/src/types/index.js +0 -2
  206. package/src/nanoclients.ts +0 -406
  207. package/src/nanoindex.ts +0 -4
  208. package/src/nanotdf/Client.ts +0 -425
  209. package/src/nanotdf/NanoTDF.ts +0 -120
  210. package/src/nanotdf/browser-entry.ts +0 -20
  211. package/src/nanotdf/constants.ts +0 -1
  212. package/src/nanotdf/decrypt.ts +0 -19
  213. package/src/nanotdf/encrypt-dataset.ts +0 -51
  214. package/src/nanotdf/encrypt.ts +0 -196
  215. package/src/nanotdf/enum/CipherEnum.ts +0 -10
  216. package/src/nanotdf/enum/CurveNameEnum.ts +0 -12
  217. package/src/nanotdf/enum/EncodingEnum.ts +0 -5
  218. package/src/nanotdf/enum/PolicyTypeEnum.ts +0 -8
  219. package/src/nanotdf/enum/ProtocolEnum.ts +0 -7
  220. package/src/nanotdf/enum/ResourceLocatorIdentifierEnum.ts +0 -8
  221. package/src/nanotdf/helpers/calculateByCurve.ts +0 -26
  222. package/src/nanotdf/helpers/getHkdfSalt.ts +0 -13
  223. package/src/nanotdf/index.ts +0 -10
  224. package/src/nanotdf/interfaces/PolicyInterface.ts +0 -27
  225. package/src/nanotdf/models/Ciphers.ts +0 -67
  226. package/src/nanotdf/models/DefaultParams.ts +0 -24
  227. package/src/nanotdf/models/EcCurves.ts +0 -40
  228. package/src/nanotdf/models/Header.ts +0 -322
  229. package/src/nanotdf/models/Payload.ts +0 -196
  230. package/src/nanotdf/models/Policy/AbstractPolicy.ts +0 -90
  231. package/src/nanotdf/models/Policy/EmbeddedPolicy.ts +0 -101
  232. package/src/nanotdf/models/Policy/PolicyFactory.ts +0 -48
  233. package/src/nanotdf/models/Policy/RemotePolicy.ts +0 -74
  234. package/src/nanotdf/models/ResourceLocator.ts +0 -212
  235. package/src/nanotdf/models/Signature.ts +0 -85
  236. package/src/tdf/NanoTDF/NanoTDF.ts +0 -120
  237. package/src/types/index.ts +0 -55
  238. /package/dist/types/src/{nanotdf-crypto → crypto}/ciphers.d.ts +0 -0
  239. /package/dist/types/src/{nanotdf-crypto → crypto}/decrypt.d.ts +0 -0
  240. /package/dist/types/src/{nanotdf-crypto → crypto}/digest.d.ts +0 -0
  241. /package/dist/types/src/{nanotdf-crypto → crypto}/ecdsaSignature.d.ts +0 -0
  242. /package/dist/types/src/{nanotdf-crypto → crypto}/encrypt.d.ts +0 -0
  243. /package/dist/types/src/{nanotdf-crypto → crypto}/enums.d.ts +0 -0
  244. /package/dist/types/src/{nanotdf-crypto → crypto}/exportCryptoKey.d.ts +0 -0
  245. /package/dist/types/src/{nanotdf-crypto → crypto}/generateKeyPair.d.ts +0 -0
  246. /package/dist/types/src/{nanotdf-crypto → crypto}/generateRandomNumber.d.ts +0 -0
  247. /package/dist/types/src/{nanotdf-crypto → crypto}/index.d.ts +0 -0
  248. /package/dist/types/src/{nanotdf-crypto → crypto}/keyAgreement.d.ts +0 -0
  249. /package/dist/types/src/{nanotdf-crypto → crypto}/pemPublicToCrypto.d.ts +0 -0
  250. /package/src/{nanotdf-crypto → crypto}/ciphers.ts +0 -0
  251. /package/src/{nanotdf-crypto → crypto}/decrypt.ts +0 -0
  252. /package/src/{nanotdf-crypto → crypto}/digest.ts +0 -0
  253. /package/src/{nanotdf-crypto → crypto}/encrypt.ts +0 -0
  254. /package/src/{nanotdf-crypto → crypto}/enums.ts +0 -0
  255. /package/src/{nanotdf-crypto → crypto}/exportCryptoKey.ts +0 -0
  256. /package/src/{nanotdf-crypto → crypto}/generateKeyPair.ts +0 -0
  257. /package/src/{nanotdf-crypto → crypto}/generateRandomNumber.ts +0 -0
  258. /package/src/{nanotdf-crypto → crypto}/index.ts +0 -0
  259. /package/src/{nanotdf-crypto → crypto}/keyAgreement.ts +0 -0
  260. /package/src/{nanotdf-crypto → crypto}/pemPublicToCrypto.ts +0 -0
package/src/opentdf.ts CHANGED
@@ -1,11 +1,6 @@
1
1
  import { type AuthProvider } from './auth/providers.js';
2
2
  import { ConfigurationError, InvalidFileError } from './errors.js';
3
- import { type EncryptOptions as NanoEncryptOptions, NanoTDFDatasetClient } from './nanoclients.js';
4
3
  export { Client as TDF3Client } from '../tdf3/src/client/index.js';
5
- import NanoTDF from './nanotdf/NanoTDF.js';
6
- import decryptNanoTDF from './nanotdf/decrypt.js';
7
- import Client from './nanotdf/Client.js';
8
- import Header from './nanotdf/models/Header.js';
9
4
  import { Chunker, fromSource, sourceToStream, type Source } from './seekable.js';
10
5
  import { Client as TDF3Client } from '../tdf3/src/client/index.js';
11
6
  import {
@@ -34,7 +29,6 @@ import {
34
29
  type IntegrityAlgorithm,
35
30
  } from '../tdf3/src/tdf.js';
36
31
  import { base64 } from './encodings/index.js';
37
- import PolicyType from './nanotdf/enum/PolicyTypeEnum.js';
38
32
  import { Policy } from '../tdf3/src/models/policy.js';
39
33
 
40
34
  export {
@@ -85,29 +79,6 @@ export type CreateOptions = {
85
79
  source: Source;
86
80
  };
87
81
 
88
- /** Options for creating a NanoTDF. */
89
- export type CreateNanoTDFOptions = CreateOptions & {
90
- /** The type of binding to use for the NanoTDF. */
91
- bindingType?: 'ecdsa' | 'gmac';
92
-
93
- /** When creating a new collection, use ECDSA binding with this key id from the signers, instead of the DEK. */
94
- ecdsaBindingKeyID?: string;
95
-
96
- /**
97
- * When creating a new collection, use the key in the `signers` list with this id
98
- * to generate a signature for each element. When absent, the nanotdf is unsigned.
99
- */
100
- signingKeyID?: string;
101
- };
102
-
103
- /** Options for creating a NanoTDF collection. */
104
- export type CreateNanoTDFCollectionOptions = CreateNanoTDFOptions & {
105
- /** The platform URL. */
106
- platformUrl: string;
107
- /** The maximum number of key iterations to use for a single DEK. */
108
- maxKeyIterations?: number;
109
- };
110
-
111
82
  /** Metadata for a TDF object. */
112
83
  export type Metadata = object;
113
84
 
@@ -202,9 +173,6 @@ export type OpenTDFOptions = {
202
173
  * which is out of the scope of this library.
203
174
  */
204
175
  dpopKeys?: Promise<CryptoKeyPair>;
205
-
206
- /** Configuration options for the collection header cache. */
207
- rewrapCacheOptions?: RewrapCacheOptions;
208
176
  };
209
177
 
210
178
  /** A decorated readable stream. */
@@ -213,86 +181,8 @@ export type DecoratedStream = ReadableStream<Uint8Array> & {
213
181
  metadata?: Promise<unknown>;
214
182
  /** The TDF manifest. */
215
183
  manifest?: Promise<Manifest>;
216
- /** If the source is a NanoTDF, this will be set. */
217
- header?: Header;
218
- };
219
-
220
- /** Configuration options for the collection header cache. */
221
- export type RewrapCacheOptions = {
222
- /** If we should disable (bypass) the cache. */
223
- bypass?: boolean;
224
-
225
- /** Evict keys after this many milliseconds. */
226
- maxAge?: number;
227
-
228
- /** Check for expired keys once every this many milliseconds. */
229
- pollInterval?: number;
230
- };
231
-
232
- const defaultRewrapCacheOptions: Required<RewrapCacheOptions> = {
233
- bypass: false,
234
- maxAge: 300000,
235
- pollInterval: 500,
236
184
  };
237
185
 
238
- /**
239
- * Cache for headers of nanotdf collections, to quickly open multiple entries of the same collection.
240
- * It has a demon that removes all keys that have not been accessed in the last 5 minutes.
241
- * To cancel the demon, and clear the cache, call `close()`.
242
- * */
243
- export class RewrapCache {
244
- private cache?: Map<Uint8Array, { lastAccessTime: number; value: CryptoKey }>;
245
- private closer?: ReturnType<typeof setInterval>;
246
- constructor(opts?: RewrapCacheOptions) {
247
- const { bypass, maxAge, pollInterval } = { ...defaultRewrapCacheOptions, ...opts };
248
- if (bypass) {
249
- return;
250
- }
251
- this.cache = new Map();
252
- this.closer = setInterval(() => {
253
- const now = Date.now();
254
- const c = this.cache;
255
- if (!c) {
256
- return;
257
- }
258
- for (const [key, value] of c.entries()) {
259
- if (now - value.lastAccessTime > maxAge) {
260
- c.delete(key);
261
- }
262
- }
263
- }, pollInterval);
264
- }
265
-
266
- get(key: Uint8Array): CryptoKey | undefined {
267
- if (!this.cache) {
268
- return undefined;
269
- }
270
- const entry = this.cache.get(key);
271
- if (entry) {
272
- entry.lastAccessTime = Date.now();
273
- return entry.value;
274
- }
275
- return undefined;
276
- }
277
-
278
- /** Set a key in the cache. */
279
- set(key: Uint8Array, value: CryptoKey) {
280
- if (!this.cache) {
281
- return;
282
- }
283
- this.cache.set(key, { lastAccessTime: Date.now(), value });
284
- }
285
-
286
- /** Close the cache and release any resources. */
287
- close() {
288
- if (this.closer !== undefined) {
289
- clearInterval(this.closer);
290
- delete this.closer;
291
- delete this.cache;
292
- }
293
- }
294
- }
295
-
296
186
  /**
297
187
  * A TDF reader that can decrypt and inspect a TDF file.
298
188
  */
@@ -324,7 +214,6 @@ export type TDFReader = {
324
214
 
325
215
  /**
326
216
  * The main OpenTDF class that provides methods for creating and reading TDF files.
327
- * It supports both NanoTDF and ZTDF formats.
328
217
  * It can be used to create new TDF files and read existing ones.
329
218
  * This class is the entry point for using the OpenTDF SDK.
330
219
  * It requires an authentication provider to be passed in the constructor.
@@ -369,8 +258,6 @@ export class OpenTDF {
369
258
  defaultReadOptions: Omit<ReadOptions, 'source'>;
370
259
  /** The DPoP keys for this instance, if any. */
371
260
  readonly dpopKeys: Promise<CryptoKeyPair>;
372
- /** Cache for rewrapped keys */
373
- private readonly rewrapCache: RewrapCache;
374
261
  /** The TDF3 client for encrypting and decrypting ZTDF files. */
375
262
  readonly tdf3Client: TDF3Client;
376
263
 
@@ -381,7 +268,6 @@ export class OpenTDF {
381
268
  defaultReadOptions,
382
269
  disableDPoP,
383
270
  policyEndpoint,
384
- rewrapCacheOptions,
385
271
  platformUrl,
386
272
  }: OpenTDFOptions) {
387
273
  this.authProvider = authProvider;
@@ -396,7 +282,6 @@ export class OpenTDF {
396
282
  );
397
283
  }
398
284
  this.policyEndpoint = policyEndpoint || '';
399
- this.rewrapCache = new RewrapCache(rewrapCacheOptions);
400
285
  this.tdf3Client = new TDF3Client({
401
286
  authProvider,
402
287
  dpopKeys,
@@ -418,33 +303,6 @@ export class OpenTDF {
418
303
  );
419
304
  }
420
305
 
421
- /** Creates a new NanoTDF stream. */
422
- async createNanoTDF(opts: CreateNanoTDFOptions): Promise<DecoratedStream> {
423
- opts = {
424
- ...this.defaultCreateOptions,
425
- ...opts,
426
- };
427
- const collection = await this.createNanoTDFCollection({
428
- ...opts,
429
- platformUrl: this.platformUrl,
430
- });
431
- try {
432
- return await collection.encrypt(opts.source);
433
- } finally {
434
- await collection.close();
435
- }
436
- }
437
-
438
- /**
439
- * Creates a new collection object, which can be used to encrypt a series of data with the same policy.
440
- */
441
- async createNanoTDFCollection(
442
- opts: CreateNanoTDFCollectionOptions
443
- ): Promise<NanoTDFCollectionWriter> {
444
- opts = { ...this.defaultCreateOptions, ...opts };
445
- return new Collection(this.authProvider, opts);
446
- }
447
-
448
306
  /** Creates a new ZTDF stream. */
449
307
  async createZTDF(opts: CreateZTDFOptions): Promise<DecoratedStream> {
450
308
  opts = { ...this.defaultCreateOptions, ...opts };
@@ -473,7 +331,7 @@ export class OpenTDF {
473
331
  /** Opens a TDF file for inspection and decryption. */
474
332
  open(opts: ReadOptions): TDFReader {
475
333
  opts = { ...this.defaultReadOptions, ...opts };
476
- return new UnknownTypeReader(this, opts, this.rewrapCache);
334
+ return new ZTDFReaderWrapper(this, opts);
477
335
  }
478
336
 
479
337
  /** Decrypts a TDF file. */
@@ -484,18 +342,17 @@ export class OpenTDF {
484
342
 
485
343
  /** Closes the OpenTDF instance and releases any resources. */
486
344
  close() {
487
- this.rewrapCache.close();
345
+ // No-op for now, but kept for API compatibility
488
346
  }
489
347
  }
490
348
 
491
- /** A TDF reader that can automatically detect the TDF type. */
492
- class UnknownTypeReader {
349
+ /** A TDF reader wrapper that handles ZTDF files. */
350
+ class ZTDFReaderWrapper {
493
351
  delegate: Promise<TDFReader>;
494
352
  state: 'init' | 'resolving' | 'loaded' | 'decrypting' | 'closing' | 'done' | 'error' = 'init';
495
353
  constructor(
496
354
  readonly outer: OpenTDF,
497
- readonly opts: ReadOptions,
498
- private readonly rewrapCache: RewrapCache
355
+ readonly opts: ReadOptions
499
356
  ) {
500
357
  this.delegate = this.resolveType();
501
358
  }
@@ -514,9 +371,6 @@ class UnknownTypeReader {
514
371
  if (prefix[0] === 0x50 && prefix[1] === 0x4b) {
515
372
  this.state = 'loaded';
516
373
  return new ZTDFReader(this.outer.tdf3Client, this.opts, chunker);
517
- } else if (prefix[0] === 0x4c && prefix[1] === 0x31 && prefix[2] === 0x4c) {
518
- this.state = 'loaded';
519
- return new NanoTDFReader(this.outer, this.opts, chunker, this.rewrapCache);
520
374
  }
521
375
  this.state = 'done';
522
376
  throw new InvalidFileError(`unsupported format; prefix not recognized ${prefix}`);
@@ -563,117 +417,7 @@ class UnknownTypeReader {
563
417
  }
564
418
  }
565
419
 
566
- /** A TDF reader for NanoTDF files. */
567
- class NanoTDFReader {
568
- container: Promise<NanoTDF>;
569
- // Required obligation FQNs that must be fulfilled, provided via the decrypt flow.
570
- private requiredObligations?: RequiredObligations;
571
- constructor(
572
- readonly outer: OpenTDF,
573
- readonly opts: ReadOptions,
574
- readonly chunker: Chunker,
575
- private readonly rewrapCache: RewrapCache
576
- ) {
577
- if (
578
- !this.opts.ignoreAllowlist &&
579
- !this.opts.platformUrl &&
580
- !this.opts.allowedKASEndpoints?.length
581
- ) {
582
- throw new ConfigurationError('platformUrl is required when allowedKasEndpoints is empty');
583
- }
584
- // lazily load the container
585
- this.container = new Promise(async (resolve, reject) => {
586
- try {
587
- const ciphertext = await chunker();
588
- const nanotdf = NanoTDF.from(ciphertext);
589
- resolve(nanotdf);
590
- } catch (e) {
591
- reject(e);
592
- }
593
- });
594
- }
595
-
596
- /**
597
- * Decrypts the NanoTDF file and returns a decorated stream.
598
- * Sets required obligations on the reader when retrieved from KAS rewrap response.
599
- */
600
- async decrypt(): Promise<DecoratedStream> {
601
- const nanotdf = await this.container;
602
- const cachedDEK = this.rewrapCache.get(nanotdf.header.ephemeralPublicKey);
603
- if (cachedDEK) {
604
- const r: DecoratedStream = await streamify(decryptNanoTDF(cachedDEK, nanotdf));
605
- r.header = nanotdf.header;
606
- return r;
607
- }
608
- const platformUrl = this.opts.platformUrl || this.outer.platformUrl;
609
- const kasEndpoint =
610
- this.opts.allowedKASEndpoints?.[0] || platformUrl || 'https://disallow.all.invalid';
611
- const nc = new Client({
612
- allowedKases: this.opts.allowedKASEndpoints,
613
- fulfillableObligationFQNs: this.opts.fulfillableObligationFQNs,
614
- authProvider: this.outer.authProvider,
615
- ignoreAllowList: this.opts.ignoreAllowlist,
616
- dpopEnabled: this.outer.dpopEnabled,
617
- dpopKeys: this.outer.dpopKeys,
618
- kasEndpoint,
619
- platformUrl,
620
- });
621
- // TODO: The version number should be fetched from the API
622
- const version = '0.0.1';
623
- // Rewrap key on every request
624
- const { unwrappedKey: dek, requiredObligations } = await nc.rewrapKey(
625
- nanotdf.header.toBuffer(),
626
- nanotdf.header.getKasRewrapUrl(),
627
- nanotdf.header.magicNumberVersion,
628
- version
629
- );
630
- if (!dek) {
631
- // These should have thrown already.
632
- throw new Error('internal: key rewrap failure');
633
- }
634
- this.requiredObligations = { fqns: requiredObligations };
635
- this.rewrapCache.set(nanotdf.header.ephemeralPublicKey, dek);
636
- const r: DecoratedStream = await streamify(decryptNanoTDF(dek, nanotdf));
637
- // TODO figure out how to attach policy and metadata to the stream
638
- r.header = nanotdf.header;
639
- return r;
640
- }
641
-
642
- async close() {}
643
-
644
- /** Returns blank manifest. NanoTDF has no manifest. */
645
- async manifest(): Promise<Manifest> {
646
- return {} as Manifest;
647
- }
648
-
649
- /** Returns the attributes of the NanoTDF file. */
650
- async attributes(): Promise<string[]> {
651
- const nanotdf = await this.container;
652
- if (!nanotdf.header.policy?.content) {
653
- return [];
654
- }
655
- if (nanotdf.header.policy.type !== PolicyType.EmbeddedText) {
656
- throw new Error('unsupported policy type');
657
- }
658
- const policyString = new TextDecoder().decode(nanotdf.header.policy.content);
659
- const policy = JSON.parse(policyString) as Policy;
660
- return policy?.body?.dataAttributes.map((a) => a.attribute) || [];
661
- }
662
-
663
- /**
664
- * Returns obligations populated from the decrypt flow.
665
- * If a decrypt has not occurred, attempts one to retrieve obligations.
666
- */
667
- async obligations(): Promise<RequiredObligations> {
668
- if (this.requiredObligations) {
669
- return this.requiredObligations;
670
- }
671
- await this.decrypt();
672
- return this.requiredObligations ?? { fqns: [] };
673
- }
674
- }
675
-
676
- /** A reader for TDF files. */
420
+ /** A reader for ZTDF files. */
677
421
  class ZTDFReader {
678
422
  overview: Promise<InspectedTDFOverview>;
679
423
  // Required obligation FQNs that must be fulfilled, provided via the decrypt flow.
@@ -778,84 +522,3 @@ class ZTDFReader {
778
522
  return this.requiredObligations ?? { fqns: [] };
779
523
  }
780
524
  }
781
-
782
- async function streamify(ab: Promise<ArrayBuffer>): Promise<ReadableStream<Uint8Array>> {
783
- const stream = new ReadableStream<Uint8Array>({
784
- start(controller) {
785
- ab.then((arrayBuffer) => {
786
- controller.enqueue(new Uint8Array(arrayBuffer));
787
- controller.close();
788
- });
789
- },
790
- });
791
- return stream;
792
- }
793
-
794
- /** A writer for NanoTDF collections. */
795
- export type NanoTDFCollectionWriter = {
796
- /** The NanoTDF client used for encrypting data in this collection. */
797
- encrypt: (source: Source) => Promise<ReadableStream<Uint8Array>>;
798
- /** Closes the collection and releases any resources. */
799
- close: () => Promise<void>;
800
- };
801
-
802
- class Collection {
803
- /** The NanoTDF client used for encrypting data in this collection. */
804
- client?: NanoTDFDatasetClient;
805
- /** Options for encrypting data in this collection. */
806
- encryptOptions?: NanoEncryptOptions;
807
-
808
- constructor(authProvider: AuthProvider, opts: CreateNanoTDFCollectionOptions) {
809
- if (opts.signers || opts.signingKeyID) {
810
- throw new ConfigurationError('ntdf signing not implemented');
811
- }
812
- if (opts.autoconfigure) {
813
- throw new ConfigurationError('autoconfigure not implemented');
814
- }
815
- if (opts.ecdsaBindingKeyID) {
816
- throw new ConfigurationError('custom binding key not implemented');
817
- }
818
- switch (opts.bindingType) {
819
- case 'ecdsa':
820
- this.encryptOptions = { ecdsaBinding: true };
821
- break;
822
- case 'gmac':
823
- this.encryptOptions = { ecdsaBinding: false };
824
- break;
825
- }
826
-
827
- const kasEndpoint =
828
- opts.defaultKASEndpoint || opts.platformUrl || 'https://disallow.all.invalid';
829
-
830
- this.client = new NanoTDFDatasetClient({
831
- authProvider,
832
- kasEndpoint: kasEndpoint,
833
- maxKeyIterations: opts.maxKeyIterations,
834
- platformUrl: opts.platformUrl,
835
- });
836
- this.client.dataAttributes = opts.attributes || [];
837
- }
838
-
839
- /** Encrypts a source into a NanoTDF stream. */
840
- async encrypt(source: Source): Promise<DecoratedStream> {
841
- if (!this.client) {
842
- throw new ConfigurationError('Collection is closed');
843
- }
844
- const chunker = await fromSource(source);
845
- const cipherChunk = await this.client.encrypt(await chunker(), this.encryptOptions);
846
- const stream: DecoratedStream = new ReadableStream<Uint8Array>({
847
- start(controller) {
848
- controller.enqueue(new Uint8Array(cipherChunk));
849
- controller.close();
850
- },
851
- });
852
- // TODO: client's header object is private
853
- // stream.header = this.client.header;
854
- return stream;
855
- }
856
-
857
- /** Releases client resources. */
858
- async close() {
859
- delete this.client;
860
- }
861
- }
package/src/utils.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { exportSPKI, importX509 } from 'jose';
2
2
 
3
3
  import { base64 } from './encodings/index.js';
4
- import { pemCertToCrypto, pemPublicToCrypto } from './nanotdf-crypto/pemPublicToCrypto.js';
4
+ import { pemCertToCrypto, pemPublicToCrypto } from './crypto/pemPublicToCrypto.js';
5
5
  import { ConfigurationError } from './errors.js';
6
6
  import {
7
7
  RewrapResponse,
package/tdf3/index.ts CHANGED
@@ -27,13 +27,8 @@ import {
27
27
  } from './src/models/encryption-information.js';
28
28
  import { AuthProvider, type HttpMethod, HttpRequest, withHeaders } from '../src/auth/auth.js';
29
29
  import { AesGcmCipher } from './src/ciphers/aes-gcm-cipher.js';
30
- import {
31
- NanoTDFClient,
32
- NanoTDFDatasetClient,
33
- AuthProviders,
34
- version,
35
- clientType,
36
- } from '../src/nanoindex.js';
30
+ import * as AuthProviders from '../src/auth/providers.js';
31
+ import { version, clientType } from '../src/version.js';
37
32
  import { Algorithms, type AlgorithmName, type AlgorithmUrn } from './src/ciphers/algorithms.js';
38
33
  import { type Chunker } from '../src/seekable.js';
39
34
 
@@ -71,8 +66,6 @@ export {
71
66
  Errors,
72
67
  HttpRequest,
73
68
  KeyInfo,
74
- NanoTDFClient,
75
- NanoTDFDatasetClient,
76
69
  SplitKey,
77
70
  TDF3Client,
78
71
  clientType,
@@ -83,14 +76,11 @@ export {
83
76
 
84
77
  export * as WebCryptoService from './src/crypto/index.js';
85
78
  export {
86
- type CreateNanoTDFCollectionOptions,
87
- type CreateNanoTDFOptions,
88
79
  type CreateOptions,
89
80
  type CreateZTDFOptions,
90
81
  type DecoratedStream,
91
82
  type Keys,
92
83
  type OpenTDFOptions,
93
- type NanoTDFCollectionWriter,
94
84
  type ReadOptions,
95
85
  type TDFReader,
96
86
  OpenTDF,
@@ -1,7 +1,7 @@
1
1
  import { base64, hex } from '../../../src/encodings/index.js';
2
- import { generateRandomNumber } from '../../../src/nanotdf-crypto/generateRandomNumber.js';
3
- import { keyAgreement } from '../../../src/nanotdf-crypto/keyAgreement.js';
4
- import { pemPublicToCrypto } from '../../../src/nanotdf-crypto/pemPublicToCrypto.js';
2
+ import { generateRandomNumber } from '../../../src/crypto/generateRandomNumber.js';
3
+ import { keyAgreement } from '../../../src/crypto/keyAgreement.js';
4
+ import { pemPublicToCrypto } from '../../../src/crypto/pemPublicToCrypto.js';
5
5
  import { cryptoPublicToPem } from '../../../src/utils.js';
6
6
  import { Binary } from '../binary.js';
7
7
  import * as cryptoService from '../crypto/index.js';
package/tdf3/src/tdf.ts CHANGED
@@ -29,9 +29,9 @@ import {
29
29
  UnsafeUrlError,
30
30
  UnsupportedFeatureError as UnsupportedError,
31
31
  } from '../../src/errors.js';
32
- import { generateKeyPair } from '../../src/nanotdf-crypto/generateKeyPair.js';
33
- import { keyAgreement } from '../../src/nanotdf-crypto/keyAgreement.js';
34
- import { pemPublicToCrypto } from '../../src/nanotdf-crypto/pemPublicToCrypto.js';
32
+ import { generateKeyPair } from '../../src/crypto/generateKeyPair.js';
33
+ import { keyAgreement } from '../../src/crypto/keyAgreement.js';
34
+ import { pemPublicToCrypto } from '../../src/crypto/pemPublicToCrypto.js';
35
35
  import { type Chunker } from '../../src/seekable.js';
36
36
  import { tdfSpecVersion } from '../../src/version.js';
37
37
  import { AssertionConfig, AssertionKey, AssertionVerificationKeys } from './assertions.js';