@verii/endpoints-organizations-registrar 1.0.0-pre.1752076816

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 (259) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +1 -0
  3. package/README.md +3 -0
  4. package/package.json +86 -0
  5. package/src/config/abi.json +1 -0
  6. package/src/config/config.js +261 -0
  7. package/src/controllers/consents/autohooks.js +6 -0
  8. package/src/controllers/consents/controller.js +106 -0
  9. package/src/controllers/consents/schemas/consent-response.schema.js +45 -0
  10. package/src/controllers/did-web-host/controller.js +64 -0
  11. package/src/controllers/groups/autohooks.js +10 -0
  12. package/src/controllers/groups/controller.js +172 -0
  13. package/src/controllers/groups/schemas/group.schema.json +22 -0
  14. package/src/controllers/groups/schemas/index.js +7 -0
  15. package/src/controllers/groups/schemas/modify-group.schema.json +25 -0
  16. package/src/controllers/image_upload/controller.js +48 -0
  17. package/src/controllers/invitations/controller.js +79 -0
  18. package/src/controllers/organizations/_did/autohooks.js +16 -0
  19. package/src/controllers/organizations/_did/controller.js +617 -0
  20. package/src/controllers/organizations/_did/invitations/_invitationId/autohooks.js +16 -0
  21. package/src/controllers/organizations/_did/invitations/_invitationId/controller.js +217 -0
  22. package/src/controllers/organizations/_did/invitations/controller.js +197 -0
  23. package/src/controllers/organizations/_did/keys/controller.js +141 -0
  24. package/src/controllers/organizations/_did/services/controller.js +195 -0
  25. package/src/controllers/organizations/_did/signatories/controller.js +63 -0
  26. package/src/controllers/organizations/autohooks.js +65 -0
  27. package/src/controllers/organizations/controller.js +322 -0
  28. package/src/controllers/organizations/full/controller.js +285 -0
  29. package/src/controllers/organizations/plugins.js +21 -0
  30. package/src/controllers/organizations/schemas/add-key-body.schema.json +35 -0
  31. package/src/controllers/organizations/schemas/create-did-service.schema.json +70 -0
  32. package/src/controllers/organizations/schemas/did-key.schema.json +178 -0
  33. package/src/controllers/organizations/schemas/full-organization.schema.json +35 -0
  34. package/src/controllers/organizations/schemas/index.js +33 -0
  35. package/src/controllers/organizations/schemas/invitationCodeProperty.schema.json +3 -0
  36. package/src/controllers/organizations/schemas/organization-ids.schema.json +34 -0
  37. package/src/controllers/organizations/schemas/organization-kyb-profile-creation.schema.json +26 -0
  38. package/src/controllers/organizations/schemas/organization-profile-creation.schema.json +20 -0
  39. package/src/controllers/organizations/schemas/organization-profile-update.schema.json +19 -0
  40. package/src/controllers/organizations/schemas/organization-profile-verifiable-credential.schema.json +25 -0
  41. package/src/controllers/organizations/schemas/organization-registry-service-response.schema.json +26 -0
  42. package/src/controllers/organizations/schemas/organization-service.schema.json +34 -0
  43. package/src/controllers/organizations/schemas/organization-verified-profile.schema.json +123 -0
  44. package/src/controllers/organizations/schemas/organization.search-profile.query-params.schema.json +50 -0
  45. package/src/controllers/organizations/schemas/organization.search.query-params.schema.json +42 -0
  46. package/src/controllers/reference/controller.js +103 -0
  47. package/src/controllers/resolve-did/controller.js +45 -0
  48. package/src/controllers/resolve-did/resolve-did.js +30 -0
  49. package/src/controllers/resolve-did/schemas/did-doc.schema.json +155 -0
  50. package/src/controllers/resolve-did/schemas/did-proof.schema.json +44 -0
  51. package/src/controllers/resolve-did/schemas/index.js +26 -0
  52. package/src/controllers/resolve-did/schemas/public-key.schema.json +173 -0
  53. package/src/controllers/resolve-kid/controller.js +76 -0
  54. package/src/controllers/resolve-kid/public-key-formats.js +8 -0
  55. package/src/controllers/service-types/controller.js +81 -0
  56. package/src/controllers/setup_image_upload/controller.js +99 -0
  57. package/src/controllers/signatories/controller.js +43 -0
  58. package/src/controllers/users/autohooks.js +10 -0
  59. package/src/controllers/users/controller.js +221 -0
  60. package/src/controllers/users/schemas/base-user.schema.json +55 -0
  61. package/src/controllers/users/schemas/index.js +4 -0
  62. package/src/controllers/users/schemas/modify-user.schema.js +17 -0
  63. package/src/controllers/users/schemas/user.schema.js +20 -0
  64. package/src/entities/groups/domain/constants.js +21 -0
  65. package/src/entities/groups/domain/index.js +19 -0
  66. package/src/entities/groups/factories/groups-factory.js +48 -0
  67. package/src/entities/groups/factories/index.js +17 -0
  68. package/src/entities/groups/index.js +19 -0
  69. package/src/entities/groups/repo.js +122 -0
  70. package/src/entities/images/domain/constant.js +11 -0
  71. package/src/entities/images/domain/index.js +3 -0
  72. package/src/entities/images/extension/activate.extension.js +35 -0
  73. package/src/entities/images/extension/deactivate.extension.js +27 -0
  74. package/src/entities/images/extension/find-by-url.extension.js +24 -0
  75. package/src/entities/images/extension/index.js +5 -0
  76. package/src/entities/images/factories/images-factory.js +43 -0
  77. package/src/entities/images/factories/index.js +17 -0
  78. package/src/entities/images/index.js +5 -0
  79. package/src/entities/images/repo.js +43 -0
  80. package/src/entities/images/schema/image-metadata.schema.js +58 -0
  81. package/src/entities/images/schema/index.js +3 -0
  82. package/src/entities/index.js +31 -0
  83. package/src/entities/invitations/domains/build-invitation-url.js +14 -0
  84. package/src/entities/invitations/domains/get-given-family-name-from-name.js +20 -0
  85. package/src/entities/invitations/domains/index.js +7 -0
  86. package/src/entities/invitations/domains/init-invitation-emails.js +17 -0
  87. package/src/entities/invitations/domains/is-invitation-expired.js +5 -0
  88. package/src/entities/invitations/domains/validate-invitee-email.js +18 -0
  89. package/src/entities/invitations/factories/index.js +17 -0
  90. package/src/entities/invitations/factories/invitations-factory.js +51 -0
  91. package/src/entities/invitations/index.js +6 -0
  92. package/src/entities/invitations/orchestrators/accept-invitation.js +24 -0
  93. package/src/entities/invitations/orchestrators/index.js +4 -0
  94. package/src/entities/invitations/orchestrators/send-email-invitee.js +36 -0
  95. package/src/entities/invitations/repo.js +37 -0
  96. package/src/entities/invitations/schemas/add-invitation-body.js +122 -0
  97. package/src/entities/invitations/schemas/get-invitation-response-body.js +20 -0
  98. package/src/entities/invitations/schemas/index.js +5 -0
  99. package/src/entities/invitations/schemas/invitation-response-item-body.js +61 -0
  100. package/src/entities/kms/factories/index.js +17 -0
  101. package/src/entities/kms/factories/kms-factory.js +31 -0
  102. package/src/entities/monitors/index.js +17 -0
  103. package/src/entities/monitors/orchestrators/index.js +17 -0
  104. package/src/entities/monitors/orchestrators/monitors.js +230 -0
  105. package/src/entities/oauth/domain/constants.js +23 -0
  106. package/src/entities/oauth/domain/index.js +5 -0
  107. package/src/entities/oauth/domain/roles.js +92 -0
  108. package/src/entities/oauth/domain/scopes.js +35 -0
  109. package/src/entities/oauth/index.js +4 -0
  110. package/src/entities/oauth/orchestrators/auth0-provisioner.js +293 -0
  111. package/src/entities/oauth/orchestrators/index.js +3 -0
  112. package/src/entities/organization-keys/domains/build-organization-key.js +50 -0
  113. package/src/entities/organization-keys/domains/constants.js +30 -0
  114. package/src/entities/organization-keys/domains/extract-verification-method-from-byo-did-document.js +38 -0
  115. package/src/entities/organization-keys/domains/find-key-by-purpose.js +6 -0
  116. package/src/entities/organization-keys/domains/index.js +10 -0
  117. package/src/entities/organization-keys/domains/jwk-to-hex-key-transformer.js +13 -0
  118. package/src/entities/organization-keys/domains/map-key-response.js +29 -0
  119. package/src/entities/organization-keys/domains/validate-non-custodial-key.js +11 -0
  120. package/src/entities/organization-keys/domains/validate-organization-key.js +42 -0
  121. package/src/entities/organization-keys/factories/index.js +17 -0
  122. package/src/entities/organization-keys/factories/organization-keys-factory.js +55 -0
  123. package/src/entities/organization-keys/index.js +5 -0
  124. package/src/entities/organization-keys/orchestrators/add-key-to-did-doc.js +19 -0
  125. package/src/entities/organization-keys/orchestrators/add-key.js +155 -0
  126. package/src/entities/organization-keys/orchestrators/add-operator-keys.js +46 -0
  127. package/src/entities/organization-keys/orchestrators/delete-key.js +93 -0
  128. package/src/entities/organization-keys/orchestrators/get-key.js +39 -0
  129. package/src/entities/organization-keys/orchestrators/index.js +24 -0
  130. package/src/entities/organization-keys/orchestrators/resolve-verification-method-byo-did.js +28 -0
  131. package/src/entities/organization-keys/repos/repo.js +48 -0
  132. package/src/entities/organization-services/adapters/index.js +21 -0
  133. package/src/entities/organization-services/adapters/init-provision-auth0-client-grants.js +44 -0
  134. package/src/entities/organization-services/adapters/init-provision-auth0-clients.js +56 -0
  135. package/src/entities/organization-services/adapters/update-blockchain-permissions-from-permitted-services.js +118 -0
  136. package/src/entities/organization-services/domains/activate-services.js +12 -0
  137. package/src/entities/organization-services/domains/build-organizations-services.js +38 -0
  138. package/src/entities/organization-services/domains/build-public-services.js +19 -0
  139. package/src/entities/organization-services/domains/constants.js +32 -0
  140. package/src/entities/organization-services/domains/extract-cao-service-refs.js +10 -0
  141. package/src/entities/organization-services/domains/extract-service-endpoint-did.js +10 -0
  142. package/src/entities/organization-services/domains/get-service-consent-type.js +16 -0
  143. package/src/entities/organization-services/domains/get-service-types-from-categories.js +18 -0
  144. package/src/entities/organization-services/domains/index.js +17 -0
  145. package/src/entities/organization-services/domains/is-new-node-operator-service.js +25 -0
  146. package/src/entities/organization-services/domains/is-service-category.js +31 -0
  147. package/src/entities/organization-services/domains/normalize-service-endpoint.js +6 -0
  148. package/src/entities/organization-services/domains/select-activated-services.js +8 -0
  149. package/src/entities/organization-services/domains/transform-profile-service.js +88 -0
  150. package/src/entities/organization-services/domains/validate-cao-service-refs.js +25 -0
  151. package/src/entities/organization-services/domains/validate-service-credential-type.js +47 -0
  152. package/src/entities/organization-services/domains/validate-service-endpoint.js +35 -0
  153. package/src/entities/organization-services/domains/validate-service-fields-by-service-type.js +37 -0
  154. package/src/entities/organization-services/domains/validate-service-id-uniqueness.js +19 -0
  155. package/src/entities/organization-services/domains/validate-service-key-purposes.js +56 -0
  156. package/src/entities/organization-services/domains/validate-service-type.js +12 -0
  157. package/src/entities/organization-services/domains/validate-service.js +80 -0
  158. package/src/entities/organization-services/domains/validate-services-for-delete.js +32 -0
  159. package/src/entities/organization-services/index.js +5 -0
  160. package/src/entities/organization-services/orchestrators/add-service.js +106 -0
  161. package/src/entities/organization-services/orchestrators/delete-service.js +142 -0
  162. package/src/entities/organization-services/orchestrators/get-service.js +36 -0
  163. package/src/entities/organization-services/orchestrators/index.js +8 -0
  164. package/src/entities/organization-services/orchestrators/init-add-service-to-organization.js +141 -0
  165. package/src/entities/organization-services/orchestrators/load-cao-service-refs.js +56 -0
  166. package/src/entities/organization-services/orchestrators/update-service.js +103 -0
  167. package/src/entities/organizations/adapters/index.js +6 -0
  168. package/src/entities/organizations/adapters/init-organization-registrar-emails.js +215 -0
  169. package/src/entities/organizations/adapters/init-send-activation-emails-to-caos.js +89 -0
  170. package/src/entities/organizations/adapters/send-email-invitation-accepted-to-inviter.js +70 -0
  171. package/src/entities/organizations/adapters/send-email-notifications.js +212 -0
  172. package/src/entities/organizations/domains/build-custodied-did-web.js +12 -0
  173. package/src/entities/organizations/domains/build-full-organization-response.js +40 -0
  174. package/src/entities/organizations/domains/build-organization-modifications-on-service-change.js +82 -0
  175. package/src/entities/organizations/domains/build-profile-vc-url.js +8 -0
  176. package/src/entities/organizations/domains/build-profile-verifiable-credential.js +36 -0
  177. package/src/entities/organizations/domains/build-public-profile.js +9 -0
  178. package/src/entities/organizations/domains/constants.js +54 -0
  179. package/src/entities/organizations/domains/index.js +17 -0
  180. package/src/entities/organizations/domains/organization-vc-checks.js +49 -0
  181. package/src/entities/organizations/domains/parse-profile-to-csv.js +41 -0
  182. package/src/entities/organizations/domains/prepare-profile-vc.js +28 -0
  183. package/src/entities/organizations/domains/profile-name-normalization.js +5 -0
  184. package/src/entities/organizations/domains/validate-byo-did-keys.js +28 -0
  185. package/src/entities/organizations/domains/validate-profile-name.js +48 -0
  186. package/src/entities/organizations/domains/validate-profile-website.js +17 -0
  187. package/src/entities/organizations/domains/validate-update-profile.js +11 -0
  188. package/src/entities/organizations/factories/index.js +17 -0
  189. package/src/entities/organizations/factories/organizations-factory.js +180 -0
  190. package/src/entities/organizations/index.js +6 -0
  191. package/src/entities/organizations/orchestrators/add-primary-permissions.js +28 -0
  192. package/src/entities/organizations/orchestrators/build-custodied-organization.js +92 -0
  193. package/src/entities/organizations/orchestrators/build-non-custodied-organization.js +83 -0
  194. package/src/entities/organizations/orchestrators/index.js +6 -0
  195. package/src/entities/organizations/orchestrators/init-create-organization.js +221 -0
  196. package/src/entities/organizations/orchestrators/init-provision-group.js +48 -0
  197. package/src/entities/organizations/orchestrators/verify-profile-website-unique.js +15 -0
  198. package/src/entities/organizations/repos/find-caos-extension.js +49 -0
  199. package/src/entities/organizations/repos/index.js +17 -0
  200. package/src/entities/organizations/repos/repo.js +156 -0
  201. package/src/entities/organizations/repos/search-by-aggregation-extension.js +128 -0
  202. package/src/entities/organizations/repos/transform-did-filter.js +13 -0
  203. package/src/entities/organizations/repos/transform-organization-filter.js +106 -0
  204. package/src/entities/registrar-consents/constants.js +10 -0
  205. package/src/entities/registrar-consents/factories/index.js +17 -0
  206. package/src/entities/registrar-consents/factories/registrar-consents-factory.js +38 -0
  207. package/src/entities/registrar-consents/index.js +3 -0
  208. package/src/entities/registrar-consents/repos/registrar-consent-repo-extension.js +55 -0
  209. package/src/entities/registrar-consents/repos/repo.js +31 -0
  210. package/src/entities/signatories/domain/constants.js +12 -0
  211. package/src/entities/signatories/domain/index.js +4 -0
  212. package/src/entities/signatories/domain/organization-emails.js +29 -0
  213. package/src/entities/signatories/factories/index.js +17 -0
  214. package/src/entities/signatories/factories/signatory-status-factory.js +53 -0
  215. package/src/entities/signatories/index.js +5 -0
  216. package/src/entities/signatories/orchestrators/approve-reminder.js +24 -0
  217. package/src/entities/signatories/orchestrators/index.js +6 -0
  218. package/src/entities/signatories/orchestrators/reject-reminder.js +17 -0
  219. package/src/entities/signatories/orchestrators/send-reminders.js +102 -0
  220. package/src/entities/signatories/orchestrators/validate-auth-code.js +56 -0
  221. package/src/entities/signatories/repos/index.js +3 -0
  222. package/src/entities/signatories/repos/repo.js +35 -0
  223. package/src/entities/signatories/repos/signatory-status-state-repo-extension.js +124 -0
  224. package/src/entities/users/domains/constants.js +40 -0
  225. package/src/entities/users/domains/index.js +4 -0
  226. package/src/entities/users/domains/user-registrar-emails.js +52 -0
  227. package/src/entities/users/index.js +4 -0
  228. package/src/entities/users/orchestrators/create-auth0-user.js +60 -0
  229. package/src/entities/users/orchestrators/get-or-create-auth0-user.js +63 -0
  230. package/src/entities/users/orchestrators/index.js +22 -0
  231. package/src/entities/users/orchestrators/user-management.js +157 -0
  232. package/src/fetchers/index.js +19 -0
  233. package/src/fetchers/monitoring/index.js +9 -0
  234. package/src/fetchers/monitoring/monitor-add-to-page-fetcher.js +18 -0
  235. package/src/fetchers/monitoring/monitor-create-fetcher.js +23 -0
  236. package/src/fetchers/monitoring/monitor-delete-fetcher.js +6 -0
  237. package/src/fetchers/monitoring/monitor-get-all-fetcher.js +6 -0
  238. package/src/fetchers/monitoring/section-create-fetcher.js +16 -0
  239. package/src/fetchers/monitoring/section-get-all-fetcher.js +6 -0
  240. package/src/fetchers/monitoring/service-version-fetcher.js +6 -0
  241. package/src/helpers/init-permissions-contract.js +48 -0
  242. package/src/index.js +23 -0
  243. package/src/init-server.js +91 -0
  244. package/src/organizations-registrar-endpoints.js +68 -0
  245. package/src/plugins/authorization.js +233 -0
  246. package/src/plugins/index.js +4 -0
  247. package/src/plugins/pubsub-plugin.js +82 -0
  248. package/src/subscribers/notify-caos.js +63 -0
  249. package/src/subscribers/notify-inviters.js +42 -0
  250. package/src/subscribers/notify-monitoring.js +40 -0
  251. package/src/subscribers/notify-signatory.js +51 -0
  252. package/src/subscribers/notify-support-and-groups.js +95 -0
  253. package/src/templates/invitee-invitation-email-body.hbs +13 -0
  254. package/src/templates/invitee-invitation-email-subject.hbs +1 -0
  255. package/src/templates/signatory-approval-email-body.hbs +92 -0
  256. package/src/templates/support-organization-created-body.hbs +17 -0
  257. package/src/templates/support-organization-created-subject.hbs +1 -0
  258. package/src/templates/support-signatory-max-reminders-reached-email-body.hbs +6 -0
  259. package/src/templates/support-signatory-max-reminders-reached-email-subject.hbs +1 -0
@@ -0,0 +1,155 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "did-doc",
4
+ "title": "did-doc",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "properties": {
8
+ "@context": {
9
+ "title": "@context",
10
+ "description": "https://w3c.github.io/did-core-registries/#context",
11
+ "oneOf": [
12
+ {
13
+ "type": "string",
14
+ "const": "https://www.w3.org/ns/did/v1"
15
+ },
16
+ {
17
+ "type": "array",
18
+ "additionalItems": {
19
+ "anyOf": [
20
+ {
21
+ "type": "string"
22
+ },
23
+ {
24
+ "type": "object"
25
+ }
26
+ ]
27
+ },
28
+ "prefixItems": [
29
+ {
30
+ "type": "string",
31
+ "const": "https://www.w3.org/ns/did/v1"
32
+ }
33
+ ]
34
+ },
35
+ {
36
+ "type": "object"
37
+ }
38
+ ]
39
+ },
40
+ "id": {
41
+ "title": "DID",
42
+ "description": "https://w3c.github.io/did-core-registries/#id",
43
+ "type": "string",
44
+ "pattern": "^did:[a-z0-9]+:[A-Za-z0-9._:?=&%;-]+$",
45
+ "example": [
46
+ "did:key:z6MksQ35B5bwZDQq4QKuhQW2Sv6dcqwg4PqcSFf67pdgrtjB"
47
+ ]
48
+ },
49
+ "controller": {
50
+ "title": "DID Controller",
51
+ "description": "https://w3c.github.io/did-core-registries/#controller",
52
+ "example": [
53
+ "did:key:z6MksQ35B5bwZDQq4QKuhQW2Sv6dcqwg4PqcSFf67pdgrtjB"
54
+ ],
55
+ "oneOf": [
56
+ {
57
+ "type": "string",
58
+ "pattern": "^did:[a-z0-9]+:[A-Za-z0-9._:?=&%;-]+$"
59
+ },
60
+ {
61
+ "type": "array",
62
+ "items": {
63
+ "type": "string",
64
+ "pattern": "^did:[a-z0-9]+:[A-Za-z0-9._:?=&%;-]+$"
65
+ }
66
+ }
67
+ ]
68
+ },
69
+ "publicKey": {
70
+ "title": "Public Key",
71
+ "deprecated": true,
72
+ "description": "https://w3c.github.io/did-core-registries/#publicKey",
73
+ "type": "array",
74
+ "items": {
75
+ "$ref": "public-key#"
76
+ }
77
+ },
78
+ "verificationMethod": {
79
+ "title": "Verification Methods of the did doc",
80
+ "description": "https://w3c.github.io/did-spec-registries/#verificationmethod",
81
+ "type": "array",
82
+ "items": {
83
+ "$ref": "public-key#"
84
+ }
85
+ },
86
+ "authentication": {
87
+ "title": "Authentication",
88
+ "description": "https://w3c.github.io/did-core-registries/#authentication",
89
+ "type": "array",
90
+ "items": {
91
+ "oneOf": [
92
+ {
93
+ "type": "string"
94
+ },
95
+ {
96
+ "$ref": "public-key#"
97
+ }
98
+ ]
99
+ }
100
+ },
101
+ "assertionMethod": {
102
+ "title": "Assertion Method",
103
+ "description": "https://w3c.github.io/did-core-registries/#assertionMethod",
104
+ "type": "array",
105
+ "items": {
106
+ "oneOf": [
107
+ {
108
+ "type": "string"
109
+ },
110
+ {
111
+ "$ref": "public-key#"
112
+ }
113
+ ]
114
+ }
115
+ },
116
+ "alsoKnownAs": {
117
+ "title": "Also Known As",
118
+ "description": "https://www.w3.org/TR/did-core/#also-known-as",
119
+ "type": "array",
120
+ "items": {
121
+ "type": "string",
122
+ "format": "uri"
123
+ }
124
+ },
125
+ "service": {
126
+ "title": "Service",
127
+ "description": "https://w3c.github.io/did-core-registries/#service",
128
+ "type": "array",
129
+ "items": {
130
+ "$ref": "did-service#"
131
+ }
132
+ },
133
+ "created": {
134
+ "title": "Created",
135
+ "description": "https://w3c.github.io/did-core-registries/#created",
136
+ "type": "string",
137
+ "format": "date-time"
138
+ },
139
+ "updated": {
140
+ "title": "Updated",
141
+ "description": "https://w3c.github.io/did-core-registries/#updated",
142
+ "type": "string",
143
+ "format": "date-time"
144
+ },
145
+ "proof": {
146
+ "title": "Proof",
147
+ "description": "https://w3c.github.io/did-core-registries/#proof",
148
+ "type": "string",
149
+ "$ref": "did-proof#"
150
+ }
151
+ },
152
+ "required": [
153
+ "id"
154
+ ]
155
+ }
@@ -0,0 +1,44 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "did-proof",
4
+ "title": "did-proof",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "properties": {
8
+ "created": {
9
+ "title": "Created",
10
+ "description": "https://w3c.github.io/did-core-registries/#created",
11
+ "type": "string",
12
+ "format": "date-time"
13
+ },
14
+ "jws": {
15
+ "title": "JWS",
16
+ "description": "https://w3c.github.io/did-core-registries/#jws",
17
+ "type": "string"
18
+ },
19
+ "proofPurpose": {
20
+ "title": "Proof Purpose",
21
+ "description": "https://w3c.github.io/did-core-registries/#proof-purpose",
22
+ "type": "string",
23
+ "enum": ["assertionMethod", "authentication"]
24
+ },
25
+ "type": {
26
+ "title": "Type of Proof supplied",
27
+ "description": "https://w3c.github.io/did-core-registries/#type",
28
+ "type": "string",
29
+ "enum": ["EcdsaSecp256k1Signature2019", "Ed25519Signature2020"]
30
+ },
31
+ "verificationMethod": {
32
+ "title": "Verification Method",
33
+ "description": "https://w3c.github.io/did-core-registries/#verification-method",
34
+ "oneOf": [
35
+ {
36
+ "type": "string"
37
+ },
38
+ {
39
+ "$ref": "public-key#"
40
+ }
41
+ ]
42
+ }
43
+ }
44
+ }
@@ -0,0 +1,26 @@
1
+ /*
2
+ * Copyright 2024 Velocity Team
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ *
16
+ */
17
+
18
+ const didDocSchema = require('./did-doc.schema.json');
19
+ const didProofSchema = require('./did-proof.schema.json');
20
+ const publicKeySchema = require('./public-key.schema.json');
21
+
22
+ module.exports = {
23
+ didDocSchema,
24
+ publicKeySchema,
25
+ didProofSchema,
26
+ };
@@ -0,0 +1,173 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "public-key",
4
+ "title": "public-key",
5
+ "description": "A public key is a verification method. Public keys are used for digital signatures, encryption and other cryptographic operations, which in turn are the basis for purposes such as authentication.",
6
+ "oneOf": [
7
+ {
8
+ "type": "object",
9
+ "additionalProperties": true,
10
+ "properties": {
11
+ "id": {
12
+ "title": "Public Key ID",
13
+ "type": "string",
14
+ "example": [
15
+ "did:example:123#primary"
16
+ ]
17
+ },
18
+ "type": {
19
+ "title": "Public Key Type",
20
+ "type": "string",
21
+ "enum": [
22
+ "JsonWebKey2020",
23
+ "EcdsaSecp256k1VerificationKey2019",
24
+ "X25519KeyAgreementKey2019",
25
+ "Ed25519VerificationKey2018"
26
+ ],
27
+ "example": [
28
+ "JsonWebKey2020"
29
+ ]
30
+ },
31
+ "controller": {
32
+ "title": "Controller",
33
+ "description": "https://w3c.github.io/did-core-registries/#controller",
34
+ "type": "string",
35
+ "example": [
36
+ "did:example:123"
37
+ ]
38
+ },
39
+ "publicKeyJwk": {
40
+ "title": "Public Key JWK",
41
+ "description": "https://w3c.github.io/did-spec-registries/#publickeyjwk",
42
+ "type": "object",
43
+ "properties": {
44
+ "crv": {
45
+ "type": "string"
46
+ },
47
+ "kid": {
48
+ "type": "string"
49
+ },
50
+ "kty": {
51
+ "type": "string"
52
+ },
53
+ "x": {
54
+ "type": "string"
55
+ },
56
+ "y": {
57
+ "type": "string"
58
+ }
59
+ },
60
+ "example": [
61
+ {
62
+ "crv": "secp256k1",
63
+ "kid": "JUvpllMEYUZ2joO59UNui_XYDqxVqiFLLAJ8klWuPBw",
64
+ "kty": "EC",
65
+ "x": "dWCvM4fTdeM0KmloF57zxtBPXTOythHPMm1HCLrdd3A",
66
+ "y": "36uMVGM7hnw-N6GnjFcihWE3SkrhMLzzLCdPMXPEXlA"
67
+ }
68
+ ]
69
+ }
70
+ },
71
+ "required": [
72
+ "id",
73
+ "type",
74
+ "controller",
75
+ "publicKeyJwk"
76
+ ]
77
+ },
78
+ {
79
+ "type": "object",
80
+ "additionalProperties": true,
81
+ "properties": {
82
+ "id": {
83
+ "title": "Public Key ID",
84
+ "type": "string",
85
+ "example": [
86
+ "did:example:123#primary"
87
+ ]
88
+ },
89
+ "type": {
90
+ "title": "Public Key Type",
91
+ "type": "string",
92
+ "enum": [
93
+ "EcdsaSecp256k1VerificationKey2019",
94
+ "X25519KeyAgreementKey2019",
95
+ "Ed25519VerificationKey2018"
96
+ ],
97
+ "example": [
98
+ "EcdsaSecp256k1VerificationKey2019"
99
+ ]
100
+ },
101
+ "controller": {
102
+ "title": "Controller",
103
+ "description": "https://w3c.github.io/did-core-registries/#controller",
104
+ "type": "string",
105
+ "example": [
106
+ "did:example:123"
107
+ ]
108
+ },
109
+ "publicKeyMultibase": {
110
+ "title": "Public Key in multibase format",
111
+ "description": "https://w3c.github.io/did-spec-registries/#multibase",
112
+ "type": "string",
113
+ "example": [
114
+ "CaSHXEvLKS6SfN9aBfkVGBpp15jSnaHazqHgLHp8KZ3Y"
115
+ ]
116
+ }
117
+ },
118
+ "required": [
119
+ "id",
120
+ "type",
121
+ "controller",
122
+ "publicKeyMultibase"
123
+ ]
124
+ },
125
+ {
126
+ "type": "object",
127
+ "additionalProperties": true,
128
+ "properties": {
129
+ "id": {
130
+ "title": "Public Key ID",
131
+ "type": "string",
132
+ "example": [
133
+ "did:example:123#primary"
134
+ ]
135
+ },
136
+ "type": {
137
+ "title": "Public Key Type",
138
+ "type": "string",
139
+ "enum": [
140
+ "EcdsaSecp256k1VerificationKey2019",
141
+ "X25519KeyAgreementKey2019",
142
+ "Ed25519VerificationKey2018"
143
+ ],
144
+ "example": [
145
+ "EcdsaSecp256k1VerificationKey2019"
146
+ ]
147
+ },
148
+ "controller": {
149
+ "title": "Controller",
150
+ "description": "https://w3c.github.io/did-core-registries/#controller",
151
+ "type": "string",
152
+ "example": [
153
+ "did:example:123"
154
+ ]
155
+ },
156
+ "publicKeyBase58": {
157
+ "title": "Public Key Base58",
158
+ "description": "https://w3c.github.io/did-spec-registries/#publickeybase58",
159
+ "type": "string",
160
+ "example": [
161
+ "CaSHXEvLKS6SfN9aBfkVGBpp15jSnaHazqHgLHp8KZ3Y"
162
+ ]
163
+ }
164
+ },
165
+ "required": [
166
+ "id",
167
+ "type",
168
+ "controller",
169
+ "publicKeyBase58"
170
+ ]
171
+ }
172
+ ]
173
+ }
@@ -0,0 +1,76 @@
1
+ const { flow, split, first } = require('lodash/fp');
2
+ const { default: bs58 } = require('bs58');
3
+ const newError = require('http-errors');
4
+
5
+ const { extractVerificationKey } = require('@verii/did-doc');
6
+ const { publicKeyHexToPem } = require('@verii/crypto');
7
+ const { jwkFromSecp256k1Key } = require('@verii/jwt');
8
+ const { resolveDid } = require('../resolve-did/resolve-did');
9
+ const publicKeyFormats = require('./public-key-formats');
10
+
11
+ const resolversController = async (fastify) => {
12
+ const publicKeyEncoders = {
13
+ [publicKeyFormats.PEM]: (publicKey) => publicKeyHexToPem(publicKey),
14
+ [publicKeyFormats.BASE58]: (publicKey) =>
15
+ bs58.encode(Buffer.from(publicKey, 'hex')),
16
+ [publicKeyFormats.HEX]: (publicKey) => publicKey,
17
+ [publicKeyFormats.JWK]: (publicKey) =>
18
+ JSON.stringify(jwkFromSecp256k1Key(publicKey, false)),
19
+ };
20
+
21
+ fastify.get(
22
+ '/:kid',
23
+ {
24
+ schema: fastify.autoSchema({
25
+ tags: ['registrar_organizations'],
26
+ params: {
27
+ type: 'object',
28
+ properties: {
29
+ kid: {
30
+ type: 'string',
31
+ },
32
+ },
33
+ },
34
+ querystring: {
35
+ type: 'object',
36
+ properties: {
37
+ format: {
38
+ type: 'string',
39
+ enum: [
40
+ publicKeyFormats.PEM,
41
+ publicKeyFormats.BASE58,
42
+ publicKeyFormats.HEX,
43
+ publicKeyFormats.JWK,
44
+ ],
45
+ default: publicKeyFormats.PEM,
46
+ },
47
+ },
48
+ },
49
+ response: {
50
+ 200: { type: 'string' },
51
+ 404: { type: 'string' },
52
+ },
53
+ }),
54
+ },
55
+ async (req) => {
56
+ const {
57
+ params: { kid },
58
+ query: { format },
59
+ } = req;
60
+ const did = flow(split('#'), first)(kid);
61
+ const didDoc = await resolveDid(did, req);
62
+
63
+ const publicKey = extractVerificationKey(didDoc, kid);
64
+ if (!publicKey) {
65
+ throw newError.NotFound(`Public key was not found in document ${did}`, {
66
+ kid,
67
+ didDoc,
68
+ });
69
+ }
70
+
71
+ return publicKeyEncoders[format](publicKey);
72
+ }
73
+ );
74
+ };
75
+
76
+ module.exports = resolversController;
@@ -0,0 +1,8 @@
1
+ const PublicKeyFormats = Object.freeze({
2
+ PEM: 'pem',
3
+ BASE58: 'base58',
4
+ HEX: 'hex',
5
+ JWK: 'jwk',
6
+ });
7
+
8
+ module.exports = PublicKeyFormats;
@@ -0,0 +1,81 @@
1
+ const {
2
+ ServiceTypes,
3
+ ServiceTypeToCategoryMap,
4
+ } = require('@verii/organizations-registry');
5
+ const { map, includes } = require('lodash/fp');
6
+
7
+ const CredentialGroupToServiceTypeMap = {
8
+ [ServiceTypes.IdentityIssuerType]: undefined,
9
+ [ServiceTypes.InspectionType]: undefined,
10
+ [ServiceTypes.NotaryIssuerType]: 'Contact',
11
+ [ServiceTypes.HolderAppProviderType]: undefined,
12
+ [ServiceTypes.NodeOperatorType]: undefined,
13
+ [ServiceTypes.CredentialAgentOperatorType]: undefined,
14
+ [ServiceTypes.CareerIssuerType]: 'Career',
15
+ [ServiceTypes.IdDocumentIssuerType]: 'IdDocument',
16
+ [ServiceTypes.NotaryIdDocumentIssuerType]: 'IdDocument',
17
+ [ServiceTypes.ContactIssuerType]: 'Contact',
18
+ [ServiceTypes.NotaryContactIssuerType]: 'Contact',
19
+ };
20
+
21
+ const isNotary = (serviceType) =>
22
+ includes(serviceType, [
23
+ ServiceTypes.NotaryContactIssuerType,
24
+ ServiceTypes.NotaryIdDocumentIssuerType,
25
+ ServiceTypes.NotaryIssuerType,
26
+ ]);
27
+
28
+ const serviceTypesController = async (fastify) => {
29
+ fastify.get(
30
+ '/',
31
+ {
32
+ schema: fastify.autoSchema({
33
+ response: {
34
+ 200: {
35
+ type: 'object',
36
+ properties: {
37
+ serviceTypes: {
38
+ type: 'array',
39
+ items: {
40
+ type: 'object',
41
+ properties: {
42
+ serviceType: {
43
+ type: 'string',
44
+ },
45
+ serviceCategory: {
46
+ type: 'string',
47
+ },
48
+ notary: {
49
+ type: 'boolean',
50
+ },
51
+ credentialGroup: {
52
+ type: 'string',
53
+ enum: ['Career', 'IdDocument', 'Contact'],
54
+ },
55
+ },
56
+ required: ['serviceType', 'serviceCategory'],
57
+ },
58
+ },
59
+ },
60
+ },
61
+ },
62
+ }),
63
+ },
64
+ async () => {
65
+ const serviceTypes = map(
66
+ (serviceType) => ({
67
+ serviceType,
68
+ serviceCategory: ServiceTypeToCategoryMap[serviceType],
69
+ notary: isNotary(serviceType),
70
+ credentialGroup: CredentialGroupToServiceTypeMap[serviceType],
71
+ }),
72
+ ServiceTypes
73
+ );
74
+ return {
75
+ serviceTypes,
76
+ };
77
+ }
78
+ );
79
+ };
80
+
81
+ module.exports = serviceTypesController;
@@ -0,0 +1,99 @@
1
+ const { initS3Client } = require('@verii/aws-clients');
2
+ const { values, isEmpty } = require('lodash/fp');
3
+ const newError = require('http-errors');
4
+ const { ExtensionTypes, getMimeType } = require('@verii/image-processing');
5
+ const { nanoid } = require('nanoid');
6
+ const {
7
+ RegistrarScopes,
8
+ ImageState,
9
+ imageMetadataSchema,
10
+ } = require('../../entities');
11
+
12
+ const controller = async (fastify) => {
13
+ const { mediaS3Bucket, mediaPutAccessKey, mediaPutAccessKeyId } =
14
+ fastify.config;
15
+
16
+ const s3Client = initS3Client({
17
+ ...fastify.config,
18
+ s3Bucket: mediaS3Bucket,
19
+ secretAccessKey: mediaPutAccessKey,
20
+ accessKeyId: mediaPutAccessKeyId,
21
+ });
22
+
23
+ fastify.post(
24
+ '/',
25
+ {
26
+ onRequest: fastify.verifyAccessToken([
27
+ RegistrarScopes.AdminOrganizations,
28
+ RegistrarScopes.WriteOrganizations,
29
+ ]),
30
+ schema: fastify.autoSchema({
31
+ security: [
32
+ {
33
+ RegistrarOAuth2: [
34
+ RegistrarScopes.WriteOrganizations,
35
+ RegistrarScopes.AdminOrganizations,
36
+ ],
37
+ },
38
+ ],
39
+ body: {
40
+ type: 'object',
41
+ properties: {
42
+ extension: {
43
+ type: 'string',
44
+ enum: values(ExtensionTypes),
45
+ },
46
+ },
47
+ required: ['extension'],
48
+ },
49
+ response: {
50
+ 200: imageMetadataSchema,
51
+ },
52
+ }),
53
+ },
54
+ async (req) => {
55
+ const {
56
+ user,
57
+ body,
58
+ repos,
59
+ config: { mediaUrl },
60
+ } = req;
61
+
62
+ if (isEmpty(user?.sub)) {
63
+ throw newError(401, 'User not found', {
64
+ errorCode: 'user_not_found',
65
+ });
66
+ }
67
+
68
+ const mime = getMimeType(body.extension);
69
+ const key = generateLogoName({
70
+ format: body.extension,
71
+ height: 400,
72
+ width: 400,
73
+ });
74
+ const url = await s3Client.getSignedUrl({
75
+ key: `temporary/${key}`,
76
+ contentType: mime,
77
+ });
78
+ const publicUrl = `${mediaUrl}/${key}`;
79
+ const imageMetadata = await repos.images.insert({
80
+ key,
81
+ url: publicUrl,
82
+ uploadUrl: url,
83
+ userId: user.sub,
84
+ uploadSucceeded: false,
85
+ state: ImageState.PENDING_UPLOAD,
86
+ });
87
+ return {
88
+ imageMetadata,
89
+ };
90
+ }
91
+ );
92
+ };
93
+
94
+ const generateLogoName = ({ format, height, width }) => {
95
+ const newImageFormat = format === 'svg' ? 'png' : format;
96
+ return `${height}x${width}-${nanoid()}.${newImageFormat}`;
97
+ };
98
+
99
+ module.exports = controller;