@0xpolygonid/js-sdk 1.0.0-beta.0

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 (469) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +40 -0
  3. package/dist/cjs/auth/auth.js +179 -0
  4. package/dist/cjs/auth/auth.js.map +1 -0
  5. package/dist/cjs/auth/index.js +18 -0
  6. package/dist/cjs/auth/index.js.map +1 -0
  7. package/dist/cjs/circuits/atomic-query-mtp-v2.js +181 -0
  8. package/dist/cjs/circuits/atomic-query-mtp-v2.js.map +1 -0
  9. package/dist/cjs/circuits/atomic-query-sig-v2.js +219 -0
  10. package/dist/cjs/circuits/atomic-query-sig-v2.js.map +1 -0
  11. package/dist/cjs/circuits/auth-v2.js +99 -0
  12. package/dist/cjs/circuits/auth-v2.js.map +1 -0
  13. package/dist/cjs/circuits/common.js +193 -0
  14. package/dist/cjs/circuits/common.js.map +1 -0
  15. package/dist/cjs/circuits/comparer.js +132 -0
  16. package/dist/cjs/circuits/comparer.js.map +1 -0
  17. package/dist/cjs/circuits/index.js +24 -0
  18. package/dist/cjs/circuits/index.js.map +1 -0
  19. package/dist/cjs/circuits/models.js +110 -0
  20. package/dist/cjs/circuits/models.js.map +1 -0
  21. package/dist/cjs/circuits/state-transition.js +94 -0
  22. package/dist/cjs/circuits/state-transition.js.map +1 -0
  23. package/dist/cjs/credentials/credential-wallet.js +264 -0
  24. package/dist/cjs/credentials/credential-wallet.js.map +1 -0
  25. package/dist/cjs/credentials/index.js +18 -0
  26. package/dist/cjs/credentials/index.js.map +1 -0
  27. package/dist/cjs/credentials/revocation.js +290 -0
  28. package/dist/cjs/credentials/revocation.js.map +1 -0
  29. package/dist/cjs/iden3comm/constants.js +45 -0
  30. package/dist/cjs/iden3comm/constants.js.map +1 -0
  31. package/dist/cjs/iden3comm/errors.js +15 -0
  32. package/dist/cjs/iden3comm/errors.js.map +1 -0
  33. package/dist/cjs/iden3comm/index.js +35 -0
  34. package/dist/cjs/iden3comm/index.js.map +1 -0
  35. package/dist/cjs/iden3comm/packageManager.js +78 -0
  36. package/dist/cjs/iden3comm/packageManager.js.map +1 -0
  37. package/dist/cjs/iden3comm/packers/index.js +19 -0
  38. package/dist/cjs/iden3comm/packers/index.js.map +1 -0
  39. package/dist/cjs/iden3comm/packers/plain.js +49 -0
  40. package/dist/cjs/iden3comm/packers/plain.js.map +1 -0
  41. package/dist/cjs/iden3comm/packers/zkp.js +155 -0
  42. package/dist/cjs/iden3comm/packers/zkp.js.map +1 -0
  43. package/dist/cjs/iden3comm/types/index.js +24 -0
  44. package/dist/cjs/iden3comm/types/index.js.map +1 -0
  45. package/dist/cjs/iden3comm/types/packageManager.js +3 -0
  46. package/dist/cjs/iden3comm/types/packageManager.js.map +1 -0
  47. package/dist/cjs/iden3comm/types/packer.js +3 -0
  48. package/dist/cjs/iden3comm/types/packer.js.map +1 -0
  49. package/dist/cjs/iden3comm/types/protocol/auth.js +3 -0
  50. package/dist/cjs/iden3comm/types/protocol/auth.js.map +1 -0
  51. package/dist/cjs/iden3comm/types/protocol/credentials.js +3 -0
  52. package/dist/cjs/iden3comm/types/protocol/credentials.js.map +1 -0
  53. package/dist/cjs/iden3comm/types/protocol/messages.js +3 -0
  54. package/dist/cjs/iden3comm/types/protocol/messages.js.map +1 -0
  55. package/dist/cjs/iden3comm/types/protocol/proof.js +3 -0
  56. package/dist/cjs/iden3comm/types/protocol/proof.js.map +1 -0
  57. package/dist/cjs/iden3comm/types/protocol/revocation.js +3 -0
  58. package/dist/cjs/iden3comm/types/protocol/revocation.js.map +1 -0
  59. package/dist/cjs/iden3comm/utils/bytes.js +20 -0
  60. package/dist/cjs/iden3comm/utils/bytes.js.map +1 -0
  61. package/dist/cjs/iden3comm/utils/envelope.js +99 -0
  62. package/dist/cjs/iden3comm/utils/envelope.js.map +1 -0
  63. package/dist/cjs/iden3comm/utils/index.js +6 -0
  64. package/dist/cjs/iden3comm/utils/index.js.map +1 -0
  65. package/dist/cjs/iden3comm/utils/message.js +43 -0
  66. package/dist/cjs/iden3comm/utils/message.js.map +1 -0
  67. package/dist/cjs/identity/common.js +40 -0
  68. package/dist/cjs/identity/common.js.map +1 -0
  69. package/dist/cjs/identity/identity-wallet.js +422 -0
  70. package/dist/cjs/identity/identity-wallet.js.map +1 -0
  71. package/dist/cjs/identity/index.js +19 -0
  72. package/dist/cjs/identity/index.js.map +1 -0
  73. package/dist/cjs/index.js +42 -0
  74. package/dist/cjs/index.js.map +1 -0
  75. package/dist/cjs/kms/bjj-provider.js +101 -0
  76. package/dist/cjs/kms/bjj-provider.js.map +1 -0
  77. package/dist/cjs/kms/index.js +20 -0
  78. package/dist/cjs/kms/index.js.map +1 -0
  79. package/dist/cjs/kms/kms.js +74 -0
  80. package/dist/cjs/kms/kms.js.map +1 -0
  81. package/dist/cjs/kms/provider-helpers.js +49 -0
  82. package/dist/cjs/kms/provider-helpers.js.map +1 -0
  83. package/dist/cjs/kms/store/abstract-key-store.js +15 -0
  84. package/dist/cjs/kms/store/abstract-key-store.js.map +1 -0
  85. package/dist/cjs/kms/store/index.js +21 -0
  86. package/dist/cjs/kms/store/index.js.map +1 -0
  87. package/dist/cjs/kms/store/local-storage-key-store.js +56 -0
  88. package/dist/cjs/kms/store/local-storage-key-store.js.map +1 -0
  89. package/dist/cjs/kms/store/memory-key-store.js +28 -0
  90. package/dist/cjs/kms/store/memory-key-store.js.map +1 -0
  91. package/dist/cjs/kms/store/types.js +15 -0
  92. package/dist/cjs/kms/store/types.js.map +1 -0
  93. package/dist/cjs/loaders/index.js +19 -0
  94. package/dist/cjs/loaders/index.js.map +1 -0
  95. package/dist/cjs/loaders/key.js +50 -0
  96. package/dist/cjs/loaders/key.js.map +1 -0
  97. package/dist/cjs/loaders/schema.js +110 -0
  98. package/dist/cjs/loaders/schema.js.map +1 -0
  99. package/dist/cjs/proof/common.js +64 -0
  100. package/dist/cjs/proof/common.js.map +1 -0
  101. package/dist/cjs/proof/index.js +20 -0
  102. package/dist/cjs/proof/index.js.map +1 -0
  103. package/dist/cjs/proof/proof-service.js +344 -0
  104. package/dist/cjs/proof/proof-service.js.map +1 -0
  105. package/dist/cjs/proof/prover.js +79 -0
  106. package/dist/cjs/proof/prover.js.map +1 -0
  107. package/dist/cjs/proof/witness_calculator.js +282 -0
  108. package/dist/cjs/proof/witness_calculator.js.map +1 -0
  109. package/dist/cjs/schema-processor/index.js +19 -0
  110. package/dist/cjs/schema-processor/index.js.map +1 -0
  111. package/dist/cjs/schema-processor/json/index.js +19 -0
  112. package/dist/cjs/schema-processor/json/index.js.map +1 -0
  113. package/dist/cjs/schema-processor/json/parser.js +136 -0
  114. package/dist/cjs/schema-processor/json/parser.js.map +1 -0
  115. package/dist/cjs/schema-processor/json/validator.js +42 -0
  116. package/dist/cjs/schema-processor/json/validator.js.map +1 -0
  117. package/dist/cjs/schema-processor/utils.js +98 -0
  118. package/dist/cjs/schema-processor/utils.js.map +1 -0
  119. package/dist/cjs/storage/blockchain/index.js +18 -0
  120. package/dist/cjs/storage/blockchain/index.js.map +1 -0
  121. package/dist/cjs/storage/blockchain/state-abi.json +922 -0
  122. package/dist/cjs/storage/blockchain/state.js +112 -0
  123. package/dist/cjs/storage/blockchain/state.js.map +1 -0
  124. package/dist/cjs/storage/entities/circuitData.js +3 -0
  125. package/dist/cjs/storage/entities/circuitData.js.map +1 -0
  126. package/dist/cjs/storage/entities/identity.js +3 -0
  127. package/dist/cjs/storage/entities/identity.js.map +1 -0
  128. package/dist/cjs/storage/entities/index.js +21 -0
  129. package/dist/cjs/storage/entities/index.js.map +1 -0
  130. package/dist/cjs/storage/entities/mt.js +19 -0
  131. package/dist/cjs/storage/entities/mt.js.map +1 -0
  132. package/dist/cjs/storage/entities/state.js +3 -0
  133. package/dist/cjs/storage/entities/state.js.map +1 -0
  134. package/dist/cjs/storage/errors.js +14 -0
  135. package/dist/cjs/storage/errors.js.map +1 -0
  136. package/dist/cjs/storage/filters/index.js +18 -0
  137. package/dist/cjs/storage/filters/index.js.map +1 -0
  138. package/dist/cjs/storage/filters/jsonQuery.js +141 -0
  139. package/dist/cjs/storage/filters/jsonQuery.js.map +1 -0
  140. package/dist/cjs/storage/index.js +24 -0
  141. package/dist/cjs/storage/index.js.map +1 -0
  142. package/dist/cjs/storage/interfaces/circuits.js +3 -0
  143. package/dist/cjs/storage/interfaces/circuits.js.map +1 -0
  144. package/dist/cjs/storage/interfaces/credentials.js +3 -0
  145. package/dist/cjs/storage/interfaces/credentials.js.map +1 -0
  146. package/dist/cjs/storage/interfaces/data-source.js +3 -0
  147. package/dist/cjs/storage/interfaces/data-source.js.map +1 -0
  148. package/dist/cjs/storage/interfaces/data-storage.js +3 -0
  149. package/dist/cjs/storage/interfaces/data-storage.js.map +1 -0
  150. package/dist/cjs/storage/interfaces/identity.js +3 -0
  151. package/dist/cjs/storage/interfaces/identity.js.map +1 -0
  152. package/dist/cjs/storage/interfaces/index.js +24 -0
  153. package/dist/cjs/storage/interfaces/index.js.map +1 -0
  154. package/dist/cjs/storage/interfaces/merkletree.js +3 -0
  155. package/dist/cjs/storage/interfaces/merkletree.js.map +1 -0
  156. package/dist/cjs/storage/interfaces/state.js +3 -0
  157. package/dist/cjs/storage/interfaces/state.js.map +1 -0
  158. package/dist/cjs/storage/local-storage/data-source.js +89 -0
  159. package/dist/cjs/storage/local-storage/data-source.js.map +1 -0
  160. package/dist/cjs/storage/local-storage/index.js +19 -0
  161. package/dist/cjs/storage/local-storage/index.js.map +1 -0
  162. package/dist/cjs/storage/local-storage/merkletree.js +148 -0
  163. package/dist/cjs/storage/local-storage/merkletree.js.map +1 -0
  164. package/dist/cjs/storage/memory/data-source.js +49 -0
  165. package/dist/cjs/storage/memory/data-source.js.map +1 -0
  166. package/dist/cjs/storage/memory/index.js +19 -0
  167. package/dist/cjs/storage/memory/index.js.map +1 -0
  168. package/dist/cjs/storage/memory/merkletree.js +94 -0
  169. package/dist/cjs/storage/memory/merkletree.js.map +1 -0
  170. package/dist/cjs/storage/shared/circuit-storage.js +46 -0
  171. package/dist/cjs/storage/shared/circuit-storage.js.map +1 -0
  172. package/dist/cjs/storage/shared/credential-storage.js +66 -0
  173. package/dist/cjs/storage/shared/credential-storage.js.map +1 -0
  174. package/dist/cjs/storage/shared/identity-storage.js +71 -0
  175. package/dist/cjs/storage/shared/identity-storage.js.map +1 -0
  176. package/dist/cjs/storage/shared/index.js +20 -0
  177. package/dist/cjs/storage/shared/index.js.map +1 -0
  178. package/dist/cjs/verifiable/constants.js +104 -0
  179. package/dist/cjs/verifiable/constants.js.map +1 -0
  180. package/dist/cjs/verifiable/credential.js +129 -0
  181. package/dist/cjs/verifiable/credential.js.map +1 -0
  182. package/dist/cjs/verifiable/index.js +21 -0
  183. package/dist/cjs/verifiable/index.js.map +1 -0
  184. package/dist/cjs/verifiable/proof.js +70 -0
  185. package/dist/cjs/verifiable/proof.js.map +1 -0
  186. package/dist/cjs/verifiable/schema.js +245 -0
  187. package/dist/cjs/verifiable/schema.js.map +1 -0
  188. package/dist/esm/auth/auth.js +152 -0
  189. package/dist/esm/auth/auth.js.map +1 -0
  190. package/dist/esm/auth/index.js +2 -0
  191. package/dist/esm/auth/index.js.map +1 -0
  192. package/dist/esm/circuits/atomic-query-mtp-v2.js +176 -0
  193. package/dist/esm/circuits/atomic-query-mtp-v2.js.map +1 -0
  194. package/dist/esm/circuits/atomic-query-sig-v2.js +214 -0
  195. package/dist/esm/circuits/atomic-query-sig-v2.js.map +1 -0
  196. package/dist/esm/circuits/auth-v2.js +94 -0
  197. package/dist/esm/circuits/auth-v2.js.map +1 -0
  198. package/dist/esm/circuits/common.js +186 -0
  199. package/dist/esm/circuits/common.js.map +1 -0
  200. package/dist/esm/circuits/comparer.js +126 -0
  201. package/dist/esm/circuits/comparer.js.map +1 -0
  202. package/dist/esm/circuits/index.js +8 -0
  203. package/dist/esm/circuits/index.js.map +1 -0
  204. package/dist/esm/circuits/models.js +104 -0
  205. package/dist/esm/circuits/models.js.map +1 -0
  206. package/dist/esm/circuits/state-transition.js +89 -0
  207. package/dist/esm/circuits/state-transition.js.map +1 -0
  208. package/dist/esm/credentials/credential-wallet.js +232 -0
  209. package/dist/esm/credentials/credential-wallet.js.map +1 -0
  210. package/dist/esm/credentials/index.js +2 -0
  211. package/dist/esm/credentials/index.js.map +1 -0
  212. package/dist/esm/credentials/revocation.js +281 -0
  213. package/dist/esm/credentials/revocation.js.map +1 -0
  214. package/dist/esm/iden3comm/constants.js +42 -0
  215. package/dist/esm/iden3comm/constants.js.map +1 -0
  216. package/dist/esm/iden3comm/errors.js +12 -0
  217. package/dist/esm/iden3comm/errors.js.map +1 -0
  218. package/dist/esm/iden3comm/index.js +6 -0
  219. package/dist/esm/iden3comm/index.js.map +1 -0
  220. package/dist/esm/iden3comm/packageManager.js +74 -0
  221. package/dist/esm/iden3comm/packageManager.js.map +1 -0
  222. package/dist/esm/iden3comm/packers/index.js +3 -0
  223. package/dist/esm/iden3comm/packers/index.js.map +1 -0
  224. package/dist/esm/iden3comm/packers/plain.js +45 -0
  225. package/dist/esm/iden3comm/packers/plain.js.map +1 -0
  226. package/dist/esm/iden3comm/packers/zkp.js +149 -0
  227. package/dist/esm/iden3comm/packers/zkp.js.map +1 -0
  228. package/dist/esm/iden3comm/types/index.js +8 -0
  229. package/dist/esm/iden3comm/types/index.js.map +1 -0
  230. package/dist/esm/iden3comm/types/packageManager.js +2 -0
  231. package/dist/esm/iden3comm/types/packageManager.js.map +1 -0
  232. package/dist/esm/iden3comm/types/packer.js +2 -0
  233. package/dist/esm/iden3comm/types/packer.js.map +1 -0
  234. package/dist/esm/iden3comm/types/protocol/auth.js +2 -0
  235. package/dist/esm/iden3comm/types/protocol/auth.js.map +1 -0
  236. package/dist/esm/iden3comm/types/protocol/credentials.js +2 -0
  237. package/dist/esm/iden3comm/types/protocol/credentials.js.map +1 -0
  238. package/dist/esm/iden3comm/types/protocol/messages.js +2 -0
  239. package/dist/esm/iden3comm/types/protocol/messages.js.map +1 -0
  240. package/dist/esm/iden3comm/types/protocol/proof.js +2 -0
  241. package/dist/esm/iden3comm/types/protocol/proof.js.map +1 -0
  242. package/dist/esm/iden3comm/types/protocol/revocation.js +2 -0
  243. package/dist/esm/iden3comm/types/protocol/revocation.js.map +1 -0
  244. package/dist/esm/iden3comm/utils/bytes.js +20 -0
  245. package/dist/esm/iden3comm/utils/bytes.js.map +1 -0
  246. package/dist/esm/iden3comm/utils/envelope.js +92 -0
  247. package/dist/esm/iden3comm/utils/envelope.js.map +1 -0
  248. package/dist/esm/iden3comm/utils/index.js +3 -0
  249. package/dist/esm/iden3comm/utils/index.js.map +1 -0
  250. package/dist/esm/iden3comm/utils/message.js +37 -0
  251. package/dist/esm/iden3comm/utils/message.js.map +1 -0
  252. package/dist/esm/identity/common.js +35 -0
  253. package/dist/esm/identity/common.js.map +1 -0
  254. package/dist/esm/identity/identity-wallet.js +395 -0
  255. package/dist/esm/identity/identity-wallet.js.map +1 -0
  256. package/dist/esm/identity/index.js +3 -0
  257. package/dist/esm/identity/index.js.map +1 -0
  258. package/dist/esm/index.js +13 -0
  259. package/dist/esm/index.js.map +1 -0
  260. package/dist/esm/kms/bjj-provider.js +74 -0
  261. package/dist/esm/kms/bjj-provider.js.map +1 -0
  262. package/dist/esm/kms/index.js +4 -0
  263. package/dist/esm/kms/index.js.map +1 -0
  264. package/dist/esm/kms/kms.js +70 -0
  265. package/dist/esm/kms/kms.js.map +1 -0
  266. package/dist/esm/kms/provider-helpers.js +44 -0
  267. package/dist/esm/kms/provider-helpers.js.map +1 -0
  268. package/dist/esm/kms/store/abstract-key-store.js +11 -0
  269. package/dist/esm/kms/store/abstract-key-store.js.map +1 -0
  270. package/dist/esm/kms/store/index.js +5 -0
  271. package/dist/esm/kms/store/index.js.map +1 -0
  272. package/dist/esm/kms/store/local-storage-key-store.js +52 -0
  273. package/dist/esm/kms/store/local-storage-key-store.js.map +1 -0
  274. package/dist/esm/kms/store/memory-key-store.js +24 -0
  275. package/dist/esm/kms/store/memory-key-store.js.map +1 -0
  276. package/dist/esm/kms/store/types.js +12 -0
  277. package/dist/esm/kms/store/types.js.map +1 -0
  278. package/dist/esm/loaders/index.js +3 -0
  279. package/dist/esm/loaders/index.js.map +1 -0
  280. package/dist/esm/loaders/key.js +23 -0
  281. package/dist/esm/loaders/key.js.map +1 -0
  282. package/dist/esm/loaders/schema.js +100 -0
  283. package/dist/esm/loaders/schema.js.map +1 -0
  284. package/dist/esm/proof/common.js +59 -0
  285. package/dist/esm/proof/common.js.map +1 -0
  286. package/dist/esm/proof/index.js +4 -0
  287. package/dist/esm/proof/index.js.map +1 -0
  288. package/dist/esm/proof/proof-service.js +339 -0
  289. package/dist/esm/proof/proof-service.js.map +1 -0
  290. package/dist/esm/proof/prover.js +52 -0
  291. package/dist/esm/proof/prover.js.map +1 -0
  292. package/dist/esm/proof/witness_calculator.js +278 -0
  293. package/dist/esm/proof/witness_calculator.js.map +1 -0
  294. package/dist/esm/schema-processor/index.js +3 -0
  295. package/dist/esm/schema-processor/index.js.map +1 -0
  296. package/dist/esm/schema-processor/json/index.js +3 -0
  297. package/dist/esm/schema-processor/json/index.js.map +1 -0
  298. package/dist/esm/schema-processor/json/parser.js +132 -0
  299. package/dist/esm/schema-processor/json/parser.js.map +1 -0
  300. package/dist/esm/schema-processor/json/validator.js +35 -0
  301. package/dist/esm/schema-processor/json/validator.js.map +1 -0
  302. package/dist/esm/schema-processor/utils.js +89 -0
  303. package/dist/esm/schema-processor/utils.js.map +1 -0
  304. package/dist/esm/storage/blockchain/index.js +2 -0
  305. package/dist/esm/storage/blockchain/index.js.map +1 -0
  306. package/dist/esm/storage/blockchain/state-abi.json +922 -0
  307. package/dist/esm/storage/blockchain/state.js +105 -0
  308. package/dist/esm/storage/blockchain/state.js.map +1 -0
  309. package/dist/esm/storage/entities/circuitData.js +2 -0
  310. package/dist/esm/storage/entities/circuitData.js.map +1 -0
  311. package/dist/esm/storage/entities/identity.js +2 -0
  312. package/dist/esm/storage/entities/identity.js.map +1 -0
  313. package/dist/esm/storage/entities/index.js +5 -0
  314. package/dist/esm/storage/entities/index.js.map +1 -0
  315. package/dist/esm/storage/entities/mt.js +16 -0
  316. package/dist/esm/storage/entities/mt.js.map +1 -0
  317. package/dist/esm/storage/entities/state.js +2 -0
  318. package/dist/esm/storage/entities/state.js.map +1 -0
  319. package/dist/esm/storage/errors.js +11 -0
  320. package/dist/esm/storage/errors.js.map +1 -0
  321. package/dist/esm/storage/filters/index.js +2 -0
  322. package/dist/esm/storage/filters/index.js.map +1 -0
  323. package/dist/esm/storage/filters/jsonQuery.js +134 -0
  324. package/dist/esm/storage/filters/jsonQuery.js.map +1 -0
  325. package/dist/esm/storage/index.js +8 -0
  326. package/dist/esm/storage/index.js.map +1 -0
  327. package/dist/esm/storage/interfaces/circuits.js +2 -0
  328. package/dist/esm/storage/interfaces/circuits.js.map +1 -0
  329. package/dist/esm/storage/interfaces/credentials.js +2 -0
  330. package/dist/esm/storage/interfaces/credentials.js.map +1 -0
  331. package/dist/esm/storage/interfaces/data-source.js +2 -0
  332. package/dist/esm/storage/interfaces/data-source.js.map +1 -0
  333. package/dist/esm/storage/interfaces/data-storage.js +2 -0
  334. package/dist/esm/storage/interfaces/data-storage.js.map +1 -0
  335. package/dist/esm/storage/interfaces/identity.js +2 -0
  336. package/dist/esm/storage/interfaces/identity.js.map +1 -0
  337. package/dist/esm/storage/interfaces/index.js +8 -0
  338. package/dist/esm/storage/interfaces/index.js.map +1 -0
  339. package/dist/esm/storage/interfaces/merkletree.js +2 -0
  340. package/dist/esm/storage/interfaces/merkletree.js.map +1 -0
  341. package/dist/esm/storage/interfaces/state.js +2 -0
  342. package/dist/esm/storage/interfaces/state.js.map +1 -0
  343. package/dist/esm/storage/local-storage/data-source.js +85 -0
  344. package/dist/esm/storage/local-storage/data-source.js.map +1 -0
  345. package/dist/esm/storage/local-storage/index.js +3 -0
  346. package/dist/esm/storage/local-storage/index.js.map +1 -0
  347. package/dist/esm/storage/local-storage/merkletree.js +121 -0
  348. package/dist/esm/storage/local-storage/merkletree.js.map +1 -0
  349. package/dist/esm/storage/memory/data-source.js +45 -0
  350. package/dist/esm/storage/memory/data-source.js.map +1 -0
  351. package/dist/esm/storage/memory/index.js +3 -0
  352. package/dist/esm/storage/memory/index.js.map +1 -0
  353. package/dist/esm/storage/memory/merkletree.js +67 -0
  354. package/dist/esm/storage/memory/merkletree.js.map +1 -0
  355. package/dist/esm/storage/shared/circuit-storage.js +42 -0
  356. package/dist/esm/storage/shared/circuit-storage.js.map +1 -0
  357. package/dist/esm/storage/shared/credential-storage.js +62 -0
  358. package/dist/esm/storage/shared/credential-storage.js.map +1 -0
  359. package/dist/esm/storage/shared/identity-storage.js +67 -0
  360. package/dist/esm/storage/shared/identity-storage.js.map +1 -0
  361. package/dist/esm/storage/shared/index.js +4 -0
  362. package/dist/esm/storage/shared/index.js.map +1 -0
  363. package/dist/esm/verifiable/constants.js +101 -0
  364. package/dist/esm/verifiable/constants.js.map +1 -0
  365. package/dist/esm/verifiable/credential.js +124 -0
  366. package/dist/esm/verifiable/credential.js.map +1 -0
  367. package/dist/esm/verifiable/index.js +5 -0
  368. package/dist/esm/verifiable/index.js.map +1 -0
  369. package/dist/esm/verifiable/proof.js +64 -0
  370. package/dist/esm/verifiable/proof.js.map +1 -0
  371. package/dist/esm/verifiable/schema.js +242 -0
  372. package/dist/esm/verifiable/schema.js.map +1 -0
  373. package/dist/esm_esbuild/index.js +128087 -0
  374. package/dist/esm_esbuild/index.js.map +7 -0
  375. package/dist/types/auth/auth.d.ts +131 -0
  376. package/dist/types/auth/index.d.ts +1 -0
  377. package/dist/types/circuits/atomic-query-mtp-v2.d.ts +64 -0
  378. package/dist/types/circuits/atomic-query-sig-v2.d.ts +65 -0
  379. package/dist/types/circuits/auth-v2.d.ts +46 -0
  380. package/dist/types/circuits/common.d.ts +124 -0
  381. package/dist/types/circuits/comparer.d.ts +87 -0
  382. package/dist/types/circuits/index.d.ts +7 -0
  383. package/dist/types/circuits/models.d.ts +181 -0
  384. package/dist/types/circuits/state-transition.d.ts +50 -0
  385. package/dist/types/credentials/credential-wallet.d.ts +248 -0
  386. package/dist/types/credentials/index.d.ts +1 -0
  387. package/dist/types/credentials/revocation.d.ts +97 -0
  388. package/dist/types/iden3comm/constants.d.ts +27 -0
  389. package/dist/types/iden3comm/errors.d.ts +8 -0
  390. package/dist/types/iden3comm/index.d.ts +5 -0
  391. package/dist/types/iden3comm/packageManager.d.ts +31 -0
  392. package/dist/types/iden3comm/packers/index.d.ts +2 -0
  393. package/dist/types/iden3comm/packers/plain.d.ts +34 -0
  394. package/dist/types/iden3comm/packers/zkp.d.ts +86 -0
  395. package/dist/types/iden3comm/types/index.d.ts +15 -0
  396. package/dist/types/iden3comm/types/packageManager.d.ts +80 -0
  397. package/dist/types/iden3comm/types/packer.d.ts +59 -0
  398. package/dist/types/iden3comm/types/protocol/auth.d.ts +49 -0
  399. package/dist/types/iden3comm/types/protocol/credentials.d.ts +74 -0
  400. package/dist/types/iden3comm/types/protocol/messages.d.ts +16 -0
  401. package/dist/types/iden3comm/types/protocol/proof.d.ts +31 -0
  402. package/dist/types/iden3comm/types/protocol/revocation.d.ts +28 -0
  403. package/dist/types/iden3comm/utils/bytes.d.ts +8 -0
  404. package/dist/types/iden3comm/utils/envelope.d.ts +31 -0
  405. package/dist/types/iden3comm/utils/index.d.ts +2 -0
  406. package/dist/types/iden3comm/utils/message.d.ts +19 -0
  407. package/dist/types/identity/common.d.ts +18 -0
  408. package/dist/types/identity/identity-wallet.d.ts +248 -0
  409. package/dist/types/identity/index.d.ts +2 -0
  410. package/dist/types/index.d.ts +12 -0
  411. package/dist/types/kms/bjj-provider.d.ts +47 -0
  412. package/dist/types/kms/index.d.ts +3 -0
  413. package/dist/types/kms/kms.d.ts +80 -0
  414. package/dist/types/kms/provider-helpers.d.ts +18 -0
  415. package/dist/types/kms/store/abstract-key-store.d.ts +31 -0
  416. package/dist/types/kms/store/index.d.ts +4 -0
  417. package/dist/types/kms/store/local-storage-key-store.d.ts +32 -0
  418. package/dist/types/kms/store/memory-key-store.d.ts +20 -0
  419. package/dist/types/kms/store/types.d.ts +21 -0
  420. package/dist/types/loaders/index.d.ts +2 -0
  421. package/dist/types/loaders/key.d.ts +29 -0
  422. package/dist/types/loaders/schema.d.ts +85 -0
  423. package/dist/types/proof/common.d.ts +17 -0
  424. package/dist/types/proof/index.d.ts +3 -0
  425. package/dist/types/proof/proof-service.d.ts +121 -0
  426. package/dist/types/proof/prover.d.ts +11 -0
  427. package/dist/types/proof/witness_calculator.d.ts +16 -0
  428. package/dist/types/schema-processor/index.d.ts +2 -0
  429. package/dist/types/schema-processor/json/index.d.ts +2 -0
  430. package/dist/types/schema-processor/json/parser.d.ts +103 -0
  431. package/dist/types/schema-processor/json/validator.d.ts +22 -0
  432. package/dist/types/schema-processor/utils.d.ts +49 -0
  433. package/dist/types/storage/blockchain/index.d.ts +1 -0
  434. package/dist/types/storage/blockchain/state.d.ts +52 -0
  435. package/dist/types/storage/entities/circuitData.d.ts +7 -0
  436. package/dist/types/storage/entities/identity.d.ts +15 -0
  437. package/dist/types/storage/entities/index.d.ts +4 -0
  438. package/dist/types/storage/entities/mt.d.ts +23 -0
  439. package/dist/types/storage/entities/state.d.ts +48 -0
  440. package/dist/types/storage/errors.d.ts +9 -0
  441. package/dist/types/storage/filters/index.d.ts +1 -0
  442. package/dist/types/storage/filters/jsonQuery.d.ts +82 -0
  443. package/dist/types/storage/index.d.ts +7 -0
  444. package/dist/types/storage/interfaces/circuits.d.ts +26 -0
  445. package/dist/types/storage/interfaces/credentials.d.ts +53 -0
  446. package/dist/types/storage/interfaces/data-source.d.ts +39 -0
  447. package/dist/types/storage/interfaces/data-storage.d.ts +17 -0
  448. package/dist/types/storage/interfaces/identity.d.ts +63 -0
  449. package/dist/types/storage/interfaces/index.d.ts +7 -0
  450. package/dist/types/storage/interfaces/merkletree.d.ts +44 -0
  451. package/dist/types/storage/interfaces/state.d.ts +41 -0
  452. package/dist/types/storage/local-storage/data-source.d.ts +47 -0
  453. package/dist/types/storage/local-storage/index.d.ts +2 -0
  454. package/dist/types/storage/local-storage/merkletree.d.ts +46 -0
  455. package/dist/types/storage/memory/data-source.d.ts +22 -0
  456. package/dist/types/storage/memory/index.d.ts +2 -0
  457. package/dist/types/storage/memory/merkletree.d.ts +49 -0
  458. package/dist/types/storage/shared/circuit-storage.d.ts +35 -0
  459. package/dist/types/storage/shared/credential-storage.d.ts +39 -0
  460. package/dist/types/storage/shared/identity-storage.d.ts +40 -0
  461. package/dist/types/storage/shared/index.d.ts +3 -0
  462. package/dist/types/verifiable/constants.d.ts +78 -0
  463. package/dist/types/verifiable/credential.d.ts +123 -0
  464. package/dist/types/verifiable/index.d.ts +4 -0
  465. package/dist/types/verifiable/proof.d.ts +123 -0
  466. package/dist/types/verifiable/schema.d.ts +2 -0
  467. package/dist/umd/index.js +462 -0
  468. package/dist/umd/index.js.map +7 -0
  469. package/package.json +95 -0
@@ -0,0 +1,181 @@
1
+ import { Signature } from '@iden3/js-crypto';
2
+ import { Claim, Claim as CoreClaim, Id } from '@iden3/js-iden3-core';
3
+ import { Hash, Proof } from '@iden3/js-merkletree';
4
+ /**
5
+ * TreeState is model for merkle tree roots
6
+ *
7
+ * @export
8
+ * @beta
9
+ * @interface TreeState
10
+ */
11
+ export interface TreeState {
12
+ state: Hash;
13
+ claimsRoot: Hash;
14
+ revocationRoot: Hash;
15
+ rootOfRoots: Hash;
16
+ }
17
+ /**
18
+ * claim non revocation status for circuit
19
+ * TreeState and Proof of inclusion / non-inclusion
20
+ *
21
+ * @export
22
+ * @beta
23
+ * @interface ClaimNonRevStatus
24
+ */
25
+ export interface ClaimNonRevStatus {
26
+ treeState: TreeState;
27
+ proof: Proof;
28
+ }
29
+ /**
30
+ * Query represents basic request to claim slot verification
31
+ *
32
+ * @export
33
+ * @beta
34
+ * @class Query
35
+ */
36
+ export declare class Query {
37
+ slotIndex: number;
38
+ values: bigint[];
39
+ operator: number;
40
+ valueProof?: ValueProof;
41
+ /**
42
+ * Validates Query instance
43
+ *
44
+ */
45
+ validate(): void;
46
+ }
47
+ /**
48
+ * CircuitID is alias for circuit identifier
49
+ *
50
+ * @export
51
+ * @enum {number}
52
+ */
53
+ export declare enum CircuitId {
54
+ AuthV2 = "authV2",
55
+ StateTransition = "stateTransition",
56
+ AtomicQueryMTPV2 = "credentialAtomicQueryMTPV2",
57
+ AtomicQuerySigV2 = "credentialAtomicQuerySigV2"
58
+ }
59
+ /**
60
+ * Claim structure for circuit inputs
61
+ *
62
+ * @export
63
+ * @beta
64
+ * @class CircuitClaim
65
+ */
66
+ export declare class CircuitClaim {
67
+ issuerId: Id;
68
+ claim: CoreClaim;
69
+ treeState: TreeState;
70
+ proof: Proof;
71
+ nonRevProof: ClaimNonRevStatus;
72
+ signatureProof: BJJSignatureProof;
73
+ }
74
+ /**
75
+ *
76
+ * Claim for circuit with non revocation proof and signature proof
77
+ * @export
78
+ * @beta
79
+ * @interface ClaimWithSigProof
80
+ */
81
+ export interface ClaimWithSigProof {
82
+ issuerID: Id;
83
+ claim: Claim;
84
+ nonRevProof: MTProof;
85
+ signatureProof: BJJSignatureProof;
86
+ }
87
+ /**
88
+ * Claim for circuit with non revocation proof and proof of merkle tree inclusion
89
+ *
90
+ * @export
91
+ * @beta
92
+ * @interface ClaimWithMTPProof
93
+ */
94
+ export interface ClaimWithMTPProof {
95
+ issuerID?: Id;
96
+ claim: Claim;
97
+ incProof: MTProof;
98
+ nonRevProof: MTProof;
99
+ }
100
+ /**
101
+ * prepared bjj signature for circuits with auth bjj claim data
102
+ *
103
+ * @export
104
+ * @beta
105
+ * @interface BJJSignatureProof
106
+ */
107
+ export interface BJJSignatureProof {
108
+ signature: Signature;
109
+ issuerAuthClaim?: Claim;
110
+ issuerAuthIncProof: MTProof;
111
+ issuerAuthNonRevProof: MTProof;
112
+ }
113
+ /**
114
+ * prepared mtp with a tree state
115
+ *
116
+ * @export
117
+ * @beta
118
+ * @interface MTProof
119
+ */
120
+ export interface MTProof {
121
+ proof: Proof;
122
+ treeState?: TreeState;
123
+ }
124
+ /**
125
+ * global identity state proof
126
+ *
127
+ * @export
128
+ * @beta
129
+ * @interface GISTProof
130
+ */
131
+ export interface GISTProof {
132
+ root: Hash;
133
+ proof: Proof;
134
+ }
135
+ /**
136
+ * List of errors of circuit inputs processing
137
+ *
138
+ * @export
139
+ * @enum {number}
140
+ */
141
+ export declare enum CircuitError {
142
+ EmptyAuthClaimProof = "empty auth claim mtp proof",
143
+ EmptyAuthClaimProofInTheNewState = "empty auth claim mtp proof in the new state",
144
+ EmptyAuthClaimNonRevProof = "empty auth claim non-revocation mtp proof",
145
+ EmptyChallengeSignature = "empty challenge signature",
146
+ EmptyClaimSignature = "empty claim signature",
147
+ EmptyClaimProof = "empty claim mtp proof",
148
+ EmptyClaimNonRevProof = "empty claim non-revocation mtp proof",
149
+ EmptyIssuerAuthClaimProof = "empty issuer auth claim mtp proof",
150
+ EmptyIssuerAuthClaimNonRevProof = "empty issuer auth claim non-revocation mtp proof",
151
+ EmptyJsonLDQueryProof = "empty JSON-LD query mtp proof",
152
+ EmptyJsonLDQueryValue = "empty JSON-LD query value",
153
+ EmptyJsonLDQueryPath = "empty JSON-LD query path",
154
+ EmptyQueryValue = "empty query value",
155
+ EmptyJsonLDQueryValues = "empty JSON-LD query values",
156
+ EmptyId = "empty Id",
157
+ EmptyChallenge = "empty challenge",
158
+ EmptyGlobalProof = "empty global identity mtp proof",
159
+ EmptyRequestID = "empty request ID"
160
+ }
161
+ /**
162
+ * ValueProof represents a Merkle Proof for a value stored as MT
163
+ *
164
+ * @export
165
+ * @beta
166
+ * @class ValueProof
167
+ */
168
+ export declare class ValueProof {
169
+ path: bigint;
170
+ value: bigint;
171
+ mtp: Proof;
172
+ /**
173
+ * Creates an instance of ValueProof.
174
+ */
175
+ constructor();
176
+ /**
177
+ * validates instance of ValueProof
178
+ *
179
+ */
180
+ validate(): void;
181
+ }
@@ -0,0 +1,50 @@
1
+ import { Signature } from '@iden3/js-crypto';
2
+ import { Id } from '@iden3/js-iden3-core';
3
+ import { Hash, Proof } from '@iden3/js-merkletree';
4
+ import { BaseConfig } from './common';
5
+ import { ClaimWithMTPProof, TreeState } from './models';
6
+ /**
7
+ * StateTransition circuit representation
8
+ * Inputs and public signals declaration, marshalling and parsing
9
+ *
10
+ * @export
11
+ * @beta
12
+ * @class StateTransitionInputs
13
+ * @extends {BaseConfig}
14
+ */
15
+ export declare class StateTransitionInputs extends BaseConfig {
16
+ id: Id;
17
+ oldTreeState: TreeState;
18
+ newTreeState: TreeState;
19
+ isOldStateGenesis: boolean;
20
+ authClaim: ClaimWithMTPProof;
21
+ authClaimNewStateIncProof: Proof;
22
+ signature: Signature;
23
+ /**
24
+ * CircuitInputMarshal returns Circom private inputs for stateTransition.circom
25
+ *
26
+ * @returns Uint8Array
27
+ */
28
+ inputsMarshal(): Uint8Array;
29
+ }
30
+ /**
31
+ * Public signals of StateTransition circuit
32
+ *
33
+ * @export
34
+ * @beta
35
+ * @class StateTransitionPubSignals
36
+ */
37
+ export declare class StateTransitionPubSignals {
38
+ userId: Id;
39
+ oldUserState: Hash;
40
+ newUserState: Hash;
41
+ isOldStateGenesis: boolean;
42
+ /**
43
+ *
44
+ *
45
+ * PubSignalsUnmarshal unmarshal stateTransition.circom public signal
46
+ * @param {Uint8Array} data
47
+ * @returns StateTransitionPubSignals
48
+ */
49
+ pubSignalsUnmarshal(data: Uint8Array): StateTransitionPubSignals;
50
+ }
@@ -0,0 +1,248 @@
1
+ import { DID } from '@iden3/js-iden3-core';
2
+ import { IDataStorage } from '../storage/interfaces';
3
+ import { W3CCredential, ProofQuery, SubjectPosition, MerklizedRootPosition, CredentialStatus, RHSCredentialStatus, RevocationStatus, IssuerData } from './../verifiable';
4
+ import { JSONSchema } from '../schema-processor';
5
+ /**
6
+ * Request to core library to create Core Claim from W3C Verifiable Credential
7
+ *
8
+ * @export
9
+ * @beta
10
+ * @interface CredentialRequest
11
+ */
12
+ export interface CredentialRequest {
13
+ /**
14
+ * JSON credential schema
15
+ */
16
+ credentialSchema: string;
17
+ /**
18
+ * Credential type
19
+ */
20
+ type: string;
21
+ /**
22
+ * Credential subject, usually contains claims and identifier
23
+ */
24
+ credentialSubject: {
25
+ [key: string]: string | object | number;
26
+ };
27
+ /**
28
+ * expiration time
29
+ */
30
+ expiration?: number;
31
+ /**
32
+ * claim version
33
+ */
34
+ version?: number;
35
+ /**
36
+ * revocation nonce
37
+ */
38
+ revNonce?: number;
39
+ /**
40
+ * subject position (index / value / none)
41
+ */
42
+ subjectPosition?: SubjectPosition;
43
+ /**
44
+ * merklizedRootPosition (index / value / none)
45
+ */
46
+ merklizedRootPosition?: MerklizedRootPosition;
47
+ }
48
+ /**
49
+ * Interface to work with credential wallets
50
+ *
51
+ * @export
52
+ * @beta
53
+ * @interface ICredentialWallet
54
+ */
55
+ export interface ICredentialWallet {
56
+ /**
57
+ * List of W3C Credential
58
+ *
59
+ * @returns `Promise<W3CCredential[]`
60
+ */
61
+ list(): Promise<W3CCredential[]>;
62
+ /**
63
+ * saves W3C credential (upsert)
64
+ * @param {W3CCredential} credential - credential to save
65
+ * @returns `Promise<void>`
66
+ *
67
+ */
68
+ save(credential: W3CCredential): Promise<void>;
69
+ /**
70
+ * saves the batch of W3C credentials (upsert)
71
+ * @param {W3CCredential[]} credentials - credentials to save
72
+ * @returns `Promise<void>`
73
+ */
74
+ saveAll(credentials: W3CCredential[]): Promise<void>;
75
+ /**
76
+ *
77
+ * removes W3C credentials from data storage
78
+ * @param {string} id
79
+ * @returns `Promise<void>`
80
+ */
81
+ remove(id: string): Promise<void>;
82
+ /**
83
+ * Find credential using iden3 query language
84
+ *
85
+ * @param {ProofQuery} query - protocol query to find credential
86
+ * @returns `Promise<W3CCredential[]>`
87
+ */
88
+ findByQuery(query: ProofQuery): Promise<W3CCredential[]>;
89
+ /**
90
+ * Finds the credential by its id
91
+ *
92
+ * @param {string} id - id of credential
93
+ * @returns `Promise<W3CCredential | undefined>`
94
+ */
95
+ findById(id: string): Promise<W3CCredential | undefined>;
96
+ /**
97
+ * Finds credentials by JSON-LD schema and type
98
+ *
99
+ * @param {string} context - the URL of JSON-LD schema where type is defined
100
+ * @returns `Promise<W3CCredential[]>`
101
+ */
102
+ findByContextType(context: string, type: string): Promise<W3CCredential[]>;
103
+ /**
104
+ * Filters given credentials with given credential subject
105
+ *
106
+ * @param {W3CCredential[]} credentials - credentials to filter
107
+ * @param {DID} subject - credential subject id
108
+ * @returns `Promise<W3CCredential[]>`
109
+ */
110
+ filterByCredentialSubject(credentials: W3CCredential[], subject: DID): Promise<W3CCredential[]>;
111
+ /**
112
+ * Finds Auth BJJ credential for given user
113
+ *
114
+ * @param {DID} did - the issuer of Auth BJJ credential
115
+ * @returns `Promise<W3CCredential>` W3CCredential with AuthBJJCredential type
116
+ */
117
+ getAuthBJJCredential(did: DID): Promise<W3CCredential>;
118
+ /**
119
+ * Fetches or Builds a revocation status for a given credential
120
+ * Supported types for credentialStatus field: SparseMerkleTreeProof, Iden3ReverseSparseMerkleTreeProof
121
+ *
122
+ * @param {W3CCredential} cred - credential for which lib should build revocation status
123
+ * @returns `Promise<RevocationStatus>`
124
+ */
125
+ getRevocationStatusFromCredential(cred: W3CCredential): Promise<RevocationStatus>;
126
+ /**
127
+ * Fetches Revocation status depended on type
128
+ *
129
+ * @param {(CredentialStatus | RHSCredentialStatus)} credStatus - credentialStatus field of the Verifiable Credential. Supported types for credentialStatus field: SparseMerkleTreeProof, Iden3ReverseSparseMerkleTreeProof
130
+ * @param {DID} issuerDID - credential issuer identity
131
+ * @param {IssuerData} issuerData - metadata of the issuer, usually contained in the BjjSignature / Iden3SparseMerkleTreeProof
132
+ * @returns `Promise<RevocationStatus>`
133
+ */
134
+ getRevocationStatus(credStatus: CredentialStatus | RHSCredentialStatus, issuerDID: DID, issuerData: IssuerData): Promise<RevocationStatus>;
135
+ /**
136
+ * Creates a W3C verifiable Credential object
137
+ *
138
+ * @param {string} hostUrl - URL that will be used as a prefix for credential identifier
139
+ * @param {DID} issuer - issuer identity
140
+ * @param {CredentialRequest} request - specification of claim creation parameters
141
+ * @param {JSONSchema} schema - JSON schema for W3C Verifiable Credential
142
+ * @param {string} [rhsUrl] - URL of reverse hash service, if it's not set - host url is used for 'SparseMerkleTreeProof' credential status type
143
+ * @returns W3CCredential
144
+ */
145
+ createCredential(hostUrl: string, issuer: DID, request: CredentialRequest, schema: JSONSchema, rhsUrl?: string): W3CCredential;
146
+ /**
147
+ * Finds non-revoked credential from a given list by resolving their credential status
148
+ *
149
+ * @param {W3CCredential[]} creds
150
+ * @returns `{Promise<{
151
+ * cred: W3CCredential;
152
+ * revStatus: RevocationStatus;
153
+ * }>` not revoked credential and it's revocation status
154
+ */
155
+ findNonRevokedCredential(creds: W3CCredential[]): Promise<{
156
+ cred: W3CCredential;
157
+ revStatus: RevocationStatus;
158
+ }>;
159
+ }
160
+ /**
161
+ *
162
+ * Wallet instance is a wrapper of CRUD logic for W3C credentials,
163
+ * also it allows to fetch revocation statuses.
164
+ *
165
+ * @export
166
+ * @beta
167
+ * @class CredentialWallet
168
+ * @implements implements ICredentialWallet interface
169
+ */
170
+ export declare class CredentialWallet implements ICredentialWallet {
171
+ private readonly _storage;
172
+ /**
173
+ * Creates an instance of CredentialWallet.
174
+ * @param {IDataStorage} _storage - - data storage to access credential / identity / Merkle tree data
175
+ */
176
+ constructor(_storage: IDataStorage);
177
+ /**
178
+ * {@inheritDoc ICredentialWallet.getAuthBJJCredential}
179
+ */
180
+ getAuthBJJCredential(did: DID): Promise<W3CCredential>;
181
+ /**
182
+ * {@inheritDoc ICredentialWallet.getRevocationStatusFromCredential}
183
+ */
184
+ getRevocationStatusFromCredential(cred: W3CCredential): Promise<RevocationStatus>;
185
+ /**
186
+ * {@inheritDoc ICredentialWallet.getRevocationStatus}
187
+ */
188
+ getRevocationStatus(credStatus: CredentialStatus | RHSCredentialStatus, issuerDID: DID, issuerData: IssuerData): Promise<RevocationStatus>;
189
+ /**
190
+ * {@inheritDoc ICredentialWallet.createCredential}
191
+ */
192
+ createCredential: (hostUrl: string, issuer: DID, request: CredentialRequest, schema: JSONSchema, rhsUrl?: string) => W3CCredential;
193
+ /**
194
+ * {@inheritDoc ICredentialWallet.findById}
195
+ */
196
+ findById(id: string): Promise<W3CCredential | undefined>;
197
+ /**
198
+ * {@inheritDoc ICredentialWallet.findByContextType}
199
+ */
200
+ findByContextType(context: string, type: string): Promise<W3CCredential[]>;
201
+ /**
202
+ * {@inheritDoc ICredentialWallet.save}
203
+ */
204
+ save(credential: W3CCredential): Promise<void>;
205
+ /**
206
+ * {@inheritDoc ICredentialWallet.saveAll}
207
+ */
208
+ saveAll(credentials: W3CCredential[]): Promise<void>;
209
+ /**
210
+ * {@inheritDoc ICredentialWallet.remove}
211
+ */
212
+ remove(id: string): Promise<void>;
213
+ /**
214
+ * {@inheritDoc ICredentialWallet.list}
215
+ */
216
+ list(): Promise<W3CCredential[]>;
217
+ /**
218
+ * {@inheritDoc ICredentialWallet.findByQuery}
219
+ */
220
+ findByQuery(query: ProofQuery): Promise<W3CCredential[]>;
221
+ /**
222
+ * {@inheritDoc ICredentialWallet.filterByCredentialSubject}
223
+ */
224
+ filterByCredentialSubject(credentials: W3CCredential[], subject: DID): Promise<W3CCredential[]>;
225
+ findNonRevokedCredential(creds: W3CCredential[]): Promise<{
226
+ cred: W3CCredential;
227
+ revStatus: RevocationStatus;
228
+ }>;
229
+ }
230
+ /**
231
+ * Checks if issuer did is created from given state is genesis
232
+ *
233
+ * @export
234
+ * @param {string} issuer - did (string)
235
+ * @param {string} state - hex state
236
+ * @returns boolean
237
+ */
238
+ export declare function isIssuerGenesis(issuer: string, state: string): boolean;
239
+ /**
240
+ * Checks if id is created from given state and type is genesis
241
+ *
242
+ * @export
243
+ * @param {bigint} id
244
+ * @param {bigint} state
245
+ * @param {Uint8Array} type
246
+ * @returns boolean - returns if id is genesis
247
+ */
248
+ export declare function isGenesisStateId(id: bigint, state: bigint, type: Uint8Array): boolean;
@@ -0,0 +1 @@
1
+ export * from './credential-wallet';
@@ -0,0 +1,97 @@
1
+ import { Hash, Merkletree } from '@iden3/js-merkletree';
2
+ import { IStateStorage } from '../storage/interfaces';
3
+ import { DID } from '@iden3/js-iden3-core';
4
+ import { CredentialStatus, RevocationStatus, RHSCredentialStatus } from '../verifiable';
5
+ /**
6
+ * Interface to unite contains three trees: claim, revocation and rootOfRoots
7
+ * Also contains the current state of identity
8
+ * @export
9
+ * @beta
10
+ * @interface TreesModel
11
+ */
12
+ export interface TreesModel {
13
+ claimsTree: Merkletree;
14
+ revocationTree: Merkletree;
15
+ rootsTree: Merkletree;
16
+ state: Hash;
17
+ }
18
+ declare enum NodeType {
19
+ Unknown = 0,
20
+ Middle = 1,
21
+ Leaf = 2,
22
+ State = 3
23
+ }
24
+ /**
25
+ * ProofNode is a partial Reverse Hash Service result
26
+ * it contains the current node hash and its children
27
+ *
28
+ * @export
29
+ * @beta
30
+ * @class ProofNode
31
+ */
32
+ export declare class ProofNode {
33
+ hash: Hash;
34
+ children: Hash[];
35
+ /**
36
+ *
37
+ * Creates an instance of ProofNode.
38
+ * @param {Hash} [hash=ZERO_HASH] - current node hash
39
+ * @param {Hash[]} [children=[]] - children of the node
40
+ */
41
+ constructor(hash?: Hash, children?: Hash[]);
42
+ /**
43
+ * Determination of Node type
44
+ * Can be: Leaf, Middle or State node
45
+ *
46
+ * @returns NodeType
47
+ */
48
+ nodeType(): NodeType;
49
+ /**
50
+ * JSON Representation of ProofNode with a hex values
51
+ *
52
+ * @returns {*} - ProofNode with hexes
53
+ */
54
+ toJSON(): {
55
+ hash: string;
56
+ children: string[];
57
+ };
58
+ /**
59
+ * Creates ProofNode Hashes from hex values
60
+ *
61
+ * @static
62
+ * @param {ProofNodeHex} hexNode
63
+ * @returns ProofNode
64
+ */
65
+ static fromHex(hexNode: ProofNodeHex): ProofNode;
66
+ }
67
+ interface ProofNodeHex {
68
+ hash: string;
69
+ children: string[];
70
+ }
71
+ /**
72
+ *
73
+ * Fetches and Builds a revocation status for a given credential
74
+ * Supported types for credentialStatus field: SparseMerkleTreeProof, Iden3ReverseSparseMerkleTreeProof
75
+ *
76
+ * @export
77
+ * @param {DID} issuer - issuer identity
78
+ * @param {(CredentialStatus | RHSCredentialStatus)} credStatus - credentialStatus field from the W3C verifiable credential
79
+ * @param {IStateStorage} stateStorage - storage to fetch current issuer status
80
+ * @returns Promise<RevocationStatus>
81
+ */
82
+ export declare function getStatusFromRHS(issuer: DID, credStatus: CredentialStatus | RHSCredentialStatus, stateStorage: IStateStorage): Promise<RevocationStatus>;
83
+ /**
84
+ * Pushes identity state information to a reverse hash service.
85
+ *
86
+ * A reverse hash service (RHS) is a centralized or decentralized service for storing publicly available data about identity.
87
+ * Such data are identity state and state of revocation tree and roots tree root tree.
88
+ *
89
+ * @export
90
+ * @param {Hash} state - current state of identity
91
+ * @param {TreesModel} trees - current trees of identity (claims, revocation, rootOfRoots )
92
+ * @param {string} rhsUrl - URL of service
93
+ * @param {number[]} [revokedNonces] - revoked nonces since last published info
94
+ * @returns void
95
+ */
96
+ export declare function pushHashesToRHS(state: Hash, trees: TreesModel, rhsUrl: string, revokedNonces?: number[]): Promise<void>;
97
+ export {};
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Constants for Iden3 protocol
3
+ */
4
+ export declare const PROTOCOL_MESSAGE_TYPE: Readonly<{
5
+ AUTHORIZATION_REQUEST_MESSAGE_TYPE: string;
6
+ AUTHORIZATION_RESPONSE_MESSAGE_TYPE: string;
7
+ CREDENTIAL_ISSUANCE_REQUEST_MESSAGE_TYPE: string;
8
+ CREDENTIAL_FETCH_REQUEST_MESSAGE_TYPE: string;
9
+ CREDENTIAL_OFFER_MESSAGE_TYPE: string;
10
+ CREDENTIAL_ISSUANCE_RESPONSE_MESSAGE_TYPE: string;
11
+ DEVICE_REGISTRATION_REQUEST_MESSAGE_TYPE: string;
12
+ MESSAGE_FETCH_REQUEST_MESSAGE_TYPE: string;
13
+ PROOF_GENERATION_REQUEST_MESSAGE_TYPE: string;
14
+ PROOF_GENERATION_RESPONSE_MESSAGE_TYPE: string;
15
+ REVOCATION_STATUS_REQUEST_MESSAGE_TYPE: string;
16
+ REVOCATION_STATUS_RESPONSE_MESSAGE_TYPE: string;
17
+ }>;
18
+ /**
19
+ * Media types for iden3 comm communication protocol
20
+ *
21
+ * @export
22
+ * @enum {number}
23
+ */
24
+ export declare enum MediaType {
25
+ ZKPMessage = "application/iden3-zkp-json",
26
+ PlainMessage = "application/iden3comm-plain-json"
27
+ }
@@ -0,0 +1,8 @@
1
+ export declare const ErrNotProtocolMessage = "the envelope is not a protocol message";
2
+ export declare const ErrNotEnvelopeStub = "the envelope doesn't contain field protected";
3
+ export declare const ErrNotHeaderStub = "the envelope doesn't contain field typ";
4
+ export declare const ErrUnknownCircuitID = "unknown circuit ID. can't verify msg sender";
5
+ export declare const ErrSenderNotUsedTokenCreation = "sender of message is not used for jwz token creation";
6
+ export declare const ErrPackedWithUnsupportedCircuit = "message was packed with unsupported circuit";
7
+ export declare const ErrProofIsInvalid = "message proof is invalid";
8
+ export declare const ErrStateVerificationFailed = "message state verification failed";
@@ -0,0 +1,5 @@
1
+ export * from './packageManager';
2
+ export * from './packers';
3
+ export * from './types';
4
+ import * as PROTOCOL_CONSTANTS from './constants';
5
+ export { PROTOCOL_CONSTANTS };
@@ -0,0 +1,31 @@
1
+ import { BasicMessage, IPackageManager, IPacker, PackerParams } from './types';
2
+ import { MediaType } from './constants';
3
+ /**
4
+ * Basic package manager for iden3 communication protocol
5
+ *
6
+ * @export
7
+ * @beta
8
+ * @class PackageManager
9
+ * @implements implements IPackageManager interface
10
+ */
11
+ export declare class PackageManager implements IPackageManager {
12
+ packers: Map<MediaType, IPacker>;
13
+ /**
14
+ * Creates an instance of PackageManager.
15
+ */
16
+ constructor();
17
+ /** {@inheritDoc IPackageManager.registerPackers} */
18
+ registerPackers(packers: Array<IPacker>): void;
19
+ /** {@inheritDoc IPackageManager.pack} */
20
+ pack(mediaType: MediaType, payload: Uint8Array, params: PackerParams): Promise<Uint8Array>;
21
+ /** {@inheritDoc IPackageManager.unpack} */
22
+ unpack(envelope: Uint8Array): Promise<{
23
+ unpackedMessage: BasicMessage;
24
+ unpackedMediaType: MediaType;
25
+ }>;
26
+ /** {@inheritDoc IPackageManager.unpackWithType} */
27
+ unpackWithType(mediaType: MediaType, envelope: Uint8Array): Promise<BasicMessage>;
28
+ private unpackWithSafeEnvelope;
29
+ /** {@inheritDoc IPackageManager.getMediaType} */
30
+ getMediaType(envelope: string): MediaType;
31
+ }
@@ -0,0 +1,2 @@
1
+ export * from './zkp';
2
+ export * from './plain';
@@ -0,0 +1,34 @@
1
+ import { PlainPackerParams } from './../types/packer';
2
+ import { BasicMessage, IPacker } from '../types';
3
+ import { MediaType } from '../constants';
4
+ /**
5
+ * Plain packer just serializes bytes to JSON and adds media type
6
+ *
7
+ * @export
8
+ * @beta
9
+ * @class PlainPacker
10
+ * @implements implements IPacker interface
11
+ */
12
+ export declare class PlainPacker implements IPacker {
13
+ /**
14
+ * Pack returns packed message to transport envelope
15
+ *
16
+ * @param {Uint8Array} payload - json message serialized
17
+ * @param {PlainPackerParams} _params - not used here
18
+ * @returns `Promise<Uint8Array>`
19
+ */
20
+ pack(payload: Uint8Array, _params: PlainPackerParams): Promise<Uint8Array>;
21
+ /**
22
+ * Unpack returns unpacked message from transport envelope
23
+ *
24
+ * @param {Uint8Array} envelope - packed envelope (serialized json with media type)
25
+ * @returns `Promise<BasicMessage>`
26
+ */
27
+ unpack(envelope: Uint8Array): Promise<BasicMessage>;
28
+ /**
29
+ * returns media type for plain message
30
+ *
31
+ * @returns MediaType
32
+ */
33
+ mediaType(): MediaType;
34
+ }