@twin.org/identity-service 0.0.3-next.34 → 0.0.3-next.36

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 (31) hide show
  1. package/dist/es/identityProfileRoutes.js +1 -2
  2. package/dist/es/identityProfileRoutes.js.map +1 -1
  3. package/dist/es/identityProfileService.js +3 -3
  4. package/dist/es/identityProfileService.js.map +1 -1
  5. package/dist/es/identityResolverRoutes.js +2 -3
  6. package/dist/es/identityResolverRoutes.js.map +1 -1
  7. package/dist/es/identityResolverService.js +2 -0
  8. package/dist/es/identityResolverService.js.map +1 -1
  9. package/dist/es/identityRoutes.js +5 -10
  10. package/dist/es/identityRoutes.js.map +1 -1
  11. package/dist/es/identityService.js +11 -8
  12. package/dist/es/identityService.js.map +1 -1
  13. package/dist/es/models/IIdentityResolverServiceConfig.js.map +1 -1
  14. package/dist/es/models/IIdentityServiceConfig.js.map +1 -1
  15. package/dist/es/restEntryPoints.js +3 -0
  16. package/dist/es/restEntryPoints.js.map +1 -1
  17. package/dist/types/identityProfileService.d.ts +3 -3
  18. package/dist/types/identityResolverRoutes.d.ts +1 -1
  19. package/dist/types/identityService.d.ts +9 -8
  20. package/dist/types/models/IIdentityResolverServiceConfig.d.ts +1 -1
  21. package/dist/types/models/IIdentityServiceConfig.d.ts +1 -1
  22. package/dist/types/restEntryPoints.d.ts +3 -0
  23. package/docs/changelog.md +33 -0
  24. package/docs/open-api/spec.json +161 -0
  25. package/docs/reference/classes/IdentityProfileService.md +3 -3
  26. package/docs/reference/classes/IdentityService.md +10 -8
  27. package/docs/reference/functions/generateRestRoutesIdentityResolver.md +1 -1
  28. package/docs/reference/interfaces/IIdentityResolverServiceConfig.md +1 -1
  29. package/docs/reference/interfaces/IIdentityServiceConfig.md +1 -1
  30. package/docs/reference/variables/restEntryPoints.md +2 -0
  31. package/package.json +2 -2
@@ -156,8 +156,7 @@ export function generateRestRoutesIdentityProfile(baseRouteName, componentName)
156
156
  {
157
157
  type: "INotFoundResponse"
158
158
  }
159
- ],
160
- skipAuth: true
159
+ ]
161
160
  };
162
161
  const identityProfileUpdateRoute = {
163
162
  operationId: "identityProfileUpdate",
@@ -1 +1 @@
1
- {"version":3,"file":"identityProfileRoutes.js","sourceRoot":"","sources":["../../src/identityProfileRoutes.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EACN,mBAAmB,EAQnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnF,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAclE,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAEvE;;GAEG;AACH,MAAM,aAAa,GAAG,uBAAuB,CAAC;AAE9C;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAW;IAC1C;QACC,IAAI,EAAE,kBAAkB;QACxB,WAAW,EAAE,uEAAuE;KACpF;CACD,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,iCAAiC,CAChD,aAAqB,EACrB,aAAqB;IAErB,MAAM,0BAA0B,GAC/B;QACC,WAAW,EAAE,uBAAuB;QACpC,OAAO,EAAE,4BAA4B;QACrC,GAAG,EAAE,mBAAmB,CAAC,CAAC,CAAC,CAAC,IAAI;QAChC,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,GAAG,aAAa,GAAG;QACzB,OAAO,EAAE,KAAK,EAAE,kBAAkB,EAAE,OAAO,EAAE,EAAE,CAC9C,qBAAqB,CAAC,kBAAkB,EAAE,aAAa,EAAE,OAAO,CAAC;QAClE,WAAW,EAAE;YACZ,IAAI,iCAAyC;YAC7C,QAAQ,EAAE;gBACT;oBACC,EAAE,EAAE,qCAAqC;oBACzC,OAAO,EAAE;wBACR,IAAI,EAAE;4BACL,aAAa,EAAE;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CAAC,aAAa,EAAE,CAAC;IACxD,eAAe,CAAC,KAAK,CAAC,UAAU,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;IAEtD,MAAM,SAAS,GAAG,gBAAgB,CAAC,GAAG,CAA4B,aAAa,CAAC,CAAC;IAEjF,MAAM,SAAS,CAAC,MAAM,CAAC,UAAU,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC;IAEvD,OAAO;QACN,UAAU,EAAE,cAAc,CAAC,SAAS;KACpC,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CACnC,kBAAuC,EACvC,aAAqB,EACrB,OAAoC;IAEpC,MAAM,SAAS,GAAG,gBAAgB,CAAC,GAAG,CAA4B,aAAa,CAAC,CAAC;IAEjF,MAAM,iBAAiB,GAAG,mBAAmB,CAAC,eAAe,CAAC,OAAO,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC;IAC7F,MAAM,aAAa,GAAG,iBAAiB,EAAE,GAAG,CAAC,IAAI,CAAC,EAAE;QACnD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC9B,OAAO;YACN,YAAY,EAAE,KAAK,CAAC,CAAC,CAAC;YACtB,aAAa,EAAE,KAAK,CAAC,CAAC,CAAC;SACvB,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO;QACN,IAAI,EAAE,MAAM,SAAS,CAAC,IAAI,CACzB,aAAa,EACb,mBAAmB,CAAC,eAAe,CAClC,OAAO,EAAE,KAAK,EAAE,mBAAmB,CACnC,EACD,OAAO,EAAE,KAAK,EAAE,MAAM,EACtB,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CACpC;KACD,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport {\n\tHttpParameterHelper,\n\ttype IConflictResponse,\n\ttype IHttpRequestContext,\n\ttype INoContentRequest,\n\ttype INoContentResponse,\n\ttype INotFoundResponse,\n\ttype IRestRoute,\n\ttype ITag\n} from \"@twin.org/api-models\";\nimport { ContextIdHelper, ContextIdKeys, ContextIdStore } from \"@twin.org/context\";\nimport { Coerce, ComponentFactory, Guards } from \"@twin.org/core\";\nimport type { IJsonLdDocument } from \"@twin.org/data-json-ld\";\nimport type {\n\tIIdentityProfileComponent,\n\tIIdentityProfileCreateRequest,\n\tIIdentityProfileGetPublicRequest,\n\tIIdentityProfileGetPublicResponse,\n\tIIdentityProfileGetRequest,\n\tIIdentityProfileGetResponse,\n\tIIdentityProfileListRequest,\n\tIIdentityProfileListResponse,\n\tIIdentityProfileUpdateRequest\n} from \"@twin.org/identity-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { HeaderTypes, HttpStatusCode, MimeTypes } from \"@twin.org/web\";\n\n/**\n * The source used when communicating about these routes.\n */\nconst ROUTES_SOURCE = \"identityProfileRoutes\";\n\n/**\n * The tag to associate with the routes.\n */\nexport const tagsIdentityProfile: ITag[] = [\n\t{\n\t\tname: \"Identity Profile\",\n\t\tdescription: \"Service to provide all features related to digital identity profiles.\"\n\t}\n];\n\n/**\n * The REST routes for identity.\n * @param baseRouteName Prefix to prepend to the paths.\n * @param componentName The name of the component to use in the routes stored in the ComponentFactory.\n * @returns The generated routes.\n */\nexport function generateRestRoutesIdentityProfile(\n\tbaseRouteName: string,\n\tcomponentName: string\n): IRestRoute[] {\n\tconst identityProfileCreateRoute: IRestRoute<IIdentityProfileCreateRequest, INoContentResponse> =\n\t\t{\n\t\t\toperationId: \"identityProfileCreate\",\n\t\t\tsummary: \"Create an identity profile\",\n\t\t\ttag: tagsIdentityProfile[0].name,\n\t\t\tmethod: \"POST\",\n\t\t\tpath: `${baseRouteName}/`,\n\t\t\thandler: async (httpRequestContext, request) =>\n\t\t\t\tidentityProfileCreate(httpRequestContext, componentName, request),\n\t\t\trequestType: {\n\t\t\t\ttype: nameof<IIdentityProfileCreateRequest>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"identityProfileCreateRequestExample\",\n\t\t\t\t\t\trequest: {\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\tpublicProfile: {\n\t\t\t\t\t\t\t\t\t\"@context\": \"https://schema.org\",\n\t\t\t\t\t\t\t\t\t\"@type\": \"Person\",\n\t\t\t\t\t\t\t\t\tjobTitle: \"Professor\",\n\t\t\t\t\t\t\t\t\tname: \"Jane Doe\"\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tprivateProfile: {\n\t\t\t\t\t\t\t\t\t\"@context\": \"https://schema.org\",\n\t\t\t\t\t\t\t\t\t\"@type\": \"Person\",\n\t\t\t\t\t\t\t\t\ttelephone: \"(425) 123-4567\",\n\t\t\t\t\t\t\t\t\turl: \"http://www.janedoe.com\"\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t},\n\t\t\tresponseType: [\n\t\t\t\t{\n\t\t\t\t\ttype: nameof<INoContentResponse>()\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\ttype: nameof<IConflictResponse>()\n\t\t\t\t}\n\t\t\t]\n\t\t};\n\n\tconst identityProfileGetRoute: IRestRoute<\n\t\tIIdentityProfileGetRequest,\n\t\tIIdentityProfileGetResponse\n\t> = {\n\t\toperationId: \"identityProfileGet\",\n\t\tsummary: \"Get the identity profile properties\",\n\t\ttag: tagsIdentityProfile[0].name,\n\t\tmethod: \"GET\",\n\t\tpath: `${baseRouteName}/`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tidentityGet(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IIdentityProfileGetRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"identityGetProfileRequestExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tquery: {\n\t\t\t\t\t\t\tpublicPropertyNames: \"name,jobTitle\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<IIdentityProfileGetResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"identityGetResponseExample\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\tidentity:\n\t\t\t\t\t\t\t\t\t\"did:iota:tst:0xc57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70\",\n\t\t\t\t\t\t\t\tpublicProfile: {\n\t\t\t\t\t\t\t\t\t\"@context\": \"https://schema.org\",\n\t\t\t\t\t\t\t\t\t\"@type\": \"Person\",\n\t\t\t\t\t\t\t\t\tjobTitle: \"Professor\",\n\t\t\t\t\t\t\t\t\tname: \"Jane Doe\"\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: nameof<INotFoundResponse>()\n\t\t\t}\n\t\t]\n\t};\n\n\tconst identityProfileGetPublicRoute: IRestRoute<\n\t\tIIdentityProfileGetPublicRequest,\n\t\tIIdentityProfileGetPublicResponse\n\t> = {\n\t\toperationId: \"identityProfileGetPublic\",\n\t\tsummary: \"Get the identity profile public properties\",\n\t\ttag: tagsIdentityProfile[0].name,\n\t\tmethod: \"GET\",\n\t\tpath: `${baseRouteName}/:identity/public`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tidentityGetPublic(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IIdentityProfileGetPublicRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"identityGetPublicProfileRequestExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tidentity:\n\t\t\t\t\t\t\t\t\"did:iota:tst:0xc57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\tquery: {\n\t\t\t\t\t\t\tpropertyNames: \"role,email,name\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<IIdentityProfileGetPublicResponse>(),\n\t\t\t\tmimeType: MimeTypes.JsonLd,\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"identityGetPublicResponseExample\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\t\t[HeaderTypes.ContentType]: MimeTypes.JsonLd\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\t\"@context\": \"https://schema.org\",\n\t\t\t\t\t\t\t\t\"@type\": \"Person\",\n\t\t\t\t\t\t\t\tjobTitle: \"Professor\",\n\t\t\t\t\t\t\t\tname: \"Jane Doe\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: nameof<INotFoundResponse>()\n\t\t\t}\n\t\t],\n\t\tskipAuth: true\n\t};\n\n\tconst identityProfileUpdateRoute: IRestRoute<IIdentityProfileUpdateRequest, INoContentResponse> =\n\t\t{\n\t\t\toperationId: \"identityProfileUpdate\",\n\t\t\tsummary: \"Update an identity profile properties\",\n\t\t\ttag: tagsIdentityProfile[0].name,\n\t\t\tmethod: \"PUT\",\n\t\t\tpath: `${baseRouteName}/`,\n\t\t\thandler: async (httpRequestContext, request) =>\n\t\t\t\tidentityProfileUpdate(httpRequestContext, componentName, request),\n\t\t\trequestType: {\n\t\t\t\ttype: nameof<IIdentityProfileUpdateRequest>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"identityProfileUpdateRequestExample\",\n\t\t\t\t\t\trequest: {\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\tpublicProfile: {\n\t\t\t\t\t\t\t\t\t\"@context\": \"https://schema.org\",\n\t\t\t\t\t\t\t\t\t\"@type\": \"Person\",\n\t\t\t\t\t\t\t\t\tjobTitle: \"Professor\",\n\t\t\t\t\t\t\t\t\tname: \"Jane Doe\"\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tprivateProfile: {\n\t\t\t\t\t\t\t\t\t\"@context\": \"https://schema.org\",\n\t\t\t\t\t\t\t\t\t\"@type\": \"Person\",\n\t\t\t\t\t\t\t\t\ttelephone: \"(425) 123-4567\",\n\t\t\t\t\t\t\t\t\turl: \"http://www.janedoe.com\"\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t},\n\t\t\tresponseType: [\n\t\t\t\t{\n\t\t\t\t\ttype: nameof<INoContentResponse>()\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\ttype: nameof<INotFoundResponse>()\n\t\t\t\t}\n\t\t\t]\n\t\t};\n\n\tconst identityProfileRemoveRoute: IRestRoute<INoContentRequest, INoContentResponse> = {\n\t\toperationId: \"identityProfileRemove\",\n\t\tsummary: \"Remove an identity profile\",\n\t\ttag: tagsIdentityProfile[0].name,\n\t\tmethod: \"DELETE\",\n\t\tpath: `${baseRouteName}/`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tidentityProfileRemove(httpRequestContext, componentName, request),\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<INoContentResponse>()\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: nameof<INotFoundResponse>()\n\t\t\t}\n\t\t]\n\t};\n\n\tconst identityProfileListRoute: IRestRoute<\n\t\tIIdentityProfileListRequest,\n\t\tIIdentityProfileListResponse\n\t> = {\n\t\toperationId: \"identitiesProfileList\",\n\t\tsummary: \"Get the list of profile data for identities\",\n\t\ttag: tagsIdentityProfile[0].name,\n\t\tmethod: \"GET\",\n\t\tpath: `${baseRouteName}/query/`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tidentitiesList(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IIdentityProfileListRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"identityProfileListRequestExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tquery: {}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tid: \"identityProfileListRequestFilteredExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tquery: {\n\t\t\t\t\t\t\tpublicFilters: \"jobTitle:Professor\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<IIdentityProfileListResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"identitiesProfileListResponseExample\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\titems: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tidentity:\n\t\t\t\t\t\t\t\t\t\t\t\"did:iota:tst:0xc57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70\",\n\t\t\t\t\t\t\t\t\t\tpublicProfile: {\n\t\t\t\t\t\t\t\t\t\t\t\"@context\": \"https://schema.org\",\n\t\t\t\t\t\t\t\t\t\t\t\"@type\": \"Person\",\n\t\t\t\t\t\t\t\t\t\t\tjobTitle: \"Professor\",\n\t\t\t\t\t\t\t\t\t\t\tname: \"Jane Doe\"\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\tcursor: \"1\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t]\n\t};\n\n\treturn [\n\t\tidentityProfileCreateRoute,\n\t\tidentityProfileGetRoute,\n\t\tidentityProfileGetPublicRoute,\n\t\tidentityProfileUpdateRoute,\n\t\tidentityProfileRemoveRoute,\n\t\tidentityProfileListRoute\n\t];\n}\n\n/**\n * Create an identity profile.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes stored in the ComponentFactory.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function identityProfileCreate(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IIdentityProfileCreateRequest\n): Promise<INoContentResponse> {\n\tGuards.object<IIdentityProfileCreateRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<IIdentityProfileCreateRequest[\"body\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.body),\n\t\trequest.body\n\t);\n\n\tconst contextIds = await ContextIdStore.getContextIds();\n\tContextIdHelper.guard(contextIds, ContextIdKeys.User);\n\n\tconst component = ComponentFactory.get<IIdentityProfileComponent>(componentName);\n\n\tawait component.create(\n\t\trequest.body.publicProfile,\n\t\trequest.body.privateProfile,\n\t\tcontextIds[ContextIdKeys.User]\n\t);\n\n\treturn {\n\t\tstatusCode: HttpStatusCode.noContent\n\t};\n}\n\n/**\n * Get the identity profile.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes stored in the ComponentFactory.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function identityGet(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IIdentityProfileGetRequest\n): Promise<IIdentityProfileGetResponse> {\n\tGuards.object<IIdentityProfileGetRequest>(ROUTES_SOURCE, nameof(request), request);\n\n\tconst contextIds = await ContextIdStore.getContextIds();\n\tContextIdHelper.guard(contextIds, ContextIdKeys.User);\n\n\tconst component = ComponentFactory.get<IIdentityProfileComponent>(componentName);\n\n\tconst result = await component.get(\n\t\tHttpParameterHelper.arrayFromString<keyof IJsonLdDocument>(request?.query?.publicPropertyNames),\n\t\tHttpParameterHelper.arrayFromString<keyof IJsonLdDocument>(\n\t\t\trequest?.query?.privatePropertyNames\n\t\t),\n\t\tcontextIds[ContextIdKeys.User]\n\t);\n\n\treturn {\n\t\tbody: result\n\t};\n}\n\n/**\n * Get the identity public profile.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes stored in the ComponentFactory.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function identityGetPublic(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IIdentityProfileGetPublicRequest\n): Promise<IIdentityProfileGetPublicResponse> {\n\tGuards.object<IIdentityProfileGetPublicRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.stringValue(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.pathParams?.identity),\n\t\trequest.pathParams?.identity\n\t);\n\n\tconst component = ComponentFactory.get<IIdentityProfileComponent>(componentName);\n\n\tconst result = await component.getPublic(\n\t\trequest?.pathParams.identity,\n\t\tHttpParameterHelper.arrayFromString<keyof IJsonLdDocument>(request?.query?.propertyNames)\n\t);\n\n\treturn {\n\t\theaders: {\n\t\t\t[HeaderTypes.ContentType]: MimeTypes.JsonLd\n\t\t},\n\t\tbody: result\n\t};\n}\n\n/**\n * Update an identity profile.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes stored in the ComponentFactory.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function identityProfileUpdate(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IIdentityProfileUpdateRequest\n): Promise<INoContentResponse> {\n\tGuards.object<IIdentityProfileUpdateRequest>(ROUTES_SOURCE, nameof(request), request);\n\n\tGuards.object<IIdentityProfileUpdateRequest[\"body\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.body),\n\t\trequest.body\n\t);\n\n\tconst contextIds = await ContextIdStore.getContextIds();\n\tContextIdHelper.guard(contextIds, ContextIdKeys.User);\n\n\tconst component = ComponentFactory.get<IIdentityProfileComponent>(componentName);\n\n\tawait component.update(\n\t\trequest.body.publicProfile,\n\t\trequest.body.privateProfile,\n\t\tcontextIds[ContextIdKeys.User]\n\t);\n\n\treturn {\n\t\tstatusCode: HttpStatusCode.noContent\n\t};\n}\n\n/**\n * Remove an identity profile.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes stored in the ComponentFactory.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function identityProfileRemove(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: INoContentRequest\n): Promise<INoContentResponse> {\n\tconst contextIds = await ContextIdStore.getContextIds();\n\tContextIdHelper.guard(contextIds, ContextIdKeys.User);\n\n\tconst component = ComponentFactory.get<IIdentityProfileComponent>(componentName);\n\n\tawait component.remove(contextIds[ContextIdKeys.User]);\n\n\treturn {\n\t\tstatusCode: HttpStatusCode.noContent\n\t};\n}\n\n/**\n * Get the list of organizations.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes stored in the ComponentFactory.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function identitiesList(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IIdentityProfileListRequest\n): Promise<IIdentityProfileListResponse> {\n\tconst component = ComponentFactory.get<IIdentityProfileComponent>(componentName);\n\n\tconst publicFilterPairs = HttpParameterHelper.arrayFromString(request?.query?.publicFilters);\n\tconst publicFilters = publicFilterPairs?.map(pair => {\n\t\tconst parts = pair.split(\":\");\n\t\treturn {\n\t\t\tpropertyName: parts[0],\n\t\t\tpropertyValue: parts[1]\n\t\t};\n\t});\n\n\treturn {\n\t\tbody: await component.list(\n\t\t\tpublicFilters,\n\t\t\tHttpParameterHelper.arrayFromString<keyof IJsonLdDocument>(\n\t\t\t\trequest?.query?.publicPropertyNames\n\t\t\t),\n\t\t\trequest?.query?.cursor,\n\t\t\tCoerce.integer(request.query?.limit)\n\t\t)\n\t};\n}\n"]}
1
+ {"version":3,"file":"identityProfileRoutes.js","sourceRoot":"","sources":["../../src/identityProfileRoutes.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EACN,mBAAmB,EAQnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnF,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAclE,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAEvE;;GAEG;AACH,MAAM,aAAa,GAAG,uBAAuB,CAAC;AAE9C;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAW;IAC1C;QACC,IAAI,EAAE,kBAAkB;QACxB,WAAW,EAAE,uEAAuE;KACpF;CACD,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,iCAAiC,CAChD,aAAqB,EACrB,aAAqB;IAErB,MAAM,0BAA0B,GAC/B;QACC,WAAW,EAAE,uBAAuB;QACpC,OAAO,EAAE,4BAA4B;QACrC,GAAG,EAAE,mBAAmB,CAAC,CAAC,CAAC,CAAC,IAAI;QAChC,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,GAAG,aAAa,GAAG;QACzB,OAAO,EAAE,KAAK,EAAE,kBAAkB,EAAE,OAAO,EAAE,EAAE,CAC9C,qBAAqB,CAAC,kBAAkB,EAAE,aAAa,EAAE,OAAO,CAAC;QAClE,WAAW,EAAE;YACZ,IAAI,iCAAyC;YAC7C,QAAQ,EAAE;gBACT;oBACC,EAAE,EAAE,qCAAqC;oBACzC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flictResponse,\n\ttype IHttpRequestContext,\n\ttype INoContentRequest,\n\ttype INoContentResponse,\n\ttype INotFoundResponse,\n\ttype IRestRoute,\n\ttype ITag\n} from \"@twin.org/api-models\";\nimport { ContextIdHelper, ContextIdKeys, ContextIdStore } from \"@twin.org/context\";\nimport { Coerce, ComponentFactory, Guards } from \"@twin.org/core\";\nimport type { IJsonLdDocument } from \"@twin.org/data-json-ld\";\nimport type {\n\tIIdentityProfileComponent,\n\tIIdentityProfileCreateRequest,\n\tIIdentityProfileGetPublicRequest,\n\tIIdentityProfileGetPublicResponse,\n\tIIdentityProfileGetRequest,\n\tIIdentityProfileGetResponse,\n\tIIdentityProfileListRequest,\n\tIIdentityProfileListResponse,\n\tIIdentityProfileUpdateRequest\n} from \"@twin.org/identity-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { HeaderTypes, HttpStatusCode, MimeTypes } from \"@twin.org/web\";\n\n/**\n * The source used when communicating about these routes.\n */\nconst ROUTES_SOURCE = \"identityProfileRoutes\";\n\n/**\n * The tag to associate with the routes.\n */\nexport const tagsIdentityProfile: ITag[] = [\n\t{\n\t\tname: \"Identity Profile\",\n\t\tdescription: \"Service to provide all features related to digital identity profiles.\"\n\t}\n];\n\n/**\n * The REST routes for identity.\n * @param baseRouteName Prefix to prepend to the paths.\n * @param componentName The name of the component to use in the routes stored in the ComponentFactory.\n * @returns The generated routes.\n */\nexport function generateRestRoutesIdentityProfile(\n\tbaseRouteName: string,\n\tcomponentName: string\n): IRestRoute[] {\n\tconst identityProfileCreateRoute: IRestRoute<IIdentityProfileCreateRequest, INoContentResponse> =\n\t\t{\n\t\t\toperationId: \"identityProfileCreate\",\n\t\t\tsummary: \"Create an identity profile\",\n\t\t\ttag: tagsIdentityProfile[0].name,\n\t\t\tmethod: \"POST\",\n\t\t\tpath: `${baseRouteName}/`,\n\t\t\thandler: async (httpRequestContext, request) =>\n\t\t\t\tidentityProfileCreate(httpRequestContext, componentName, request),\n\t\t\trequestType: {\n\t\t\t\ttype: nameof<IIdentityProfileCreateRequest>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"identityProfileCreateRequestExample\",\n\t\t\t\t\t\trequest: {\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\tpublicProfile: {\n\t\t\t\t\t\t\t\t\t\"@context\": \"https://schema.org\",\n\t\t\t\t\t\t\t\t\t\"@type\": \"Person\",\n\t\t\t\t\t\t\t\t\tjobTitle: \"Professor\",\n\t\t\t\t\t\t\t\t\tname: \"Jane Doe\"\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tprivateProfile: {\n\t\t\t\t\t\t\t\t\t\"@context\": \"https://schema.org\",\n\t\t\t\t\t\t\t\t\t\"@type\": \"Person\",\n\t\t\t\t\t\t\t\t\ttelephone: \"(425) 123-4567\",\n\t\t\t\t\t\t\t\t\turl: \"http://www.janedoe.com\"\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t},\n\t\t\tresponseType: [\n\t\t\t\t{\n\t\t\t\t\ttype: nameof<INoContentResponse>()\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\ttype: nameof<IConflictResponse>()\n\t\t\t\t}\n\t\t\t]\n\t\t};\n\n\tconst identityProfileGetRoute: IRestRoute<\n\t\tIIdentityProfileGetRequest,\n\t\tIIdentityProfileGetResponse\n\t> = {\n\t\toperationId: \"identityProfileGet\",\n\t\tsummary: \"Get the identity profile properties\",\n\t\ttag: tagsIdentityProfile[0].name,\n\t\tmethod: \"GET\",\n\t\tpath: `${baseRouteName}/`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tidentityGet(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IIdentityProfileGetRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"identityGetProfileRequestExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tquery: {\n\t\t\t\t\t\t\tpublicPropertyNames: \"name,jobTitle\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<IIdentityProfileGetResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"identityGetResponseExample\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\tidentity:\n\t\t\t\t\t\t\t\t\t\"did:iota:tst:0xc57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70\",\n\t\t\t\t\t\t\t\tpublicProfile: {\n\t\t\t\t\t\t\t\t\t\"@context\": \"https://schema.org\",\n\t\t\t\t\t\t\t\t\t\"@type\": \"Person\",\n\t\t\t\t\t\t\t\t\tjobTitle: \"Professor\",\n\t\t\t\t\t\t\t\t\tname: \"Jane Doe\"\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: nameof<INotFoundResponse>()\n\t\t\t}\n\t\t]\n\t};\n\n\tconst identityProfileGetPublicRoute: IRestRoute<\n\t\tIIdentityProfileGetPublicRequest,\n\t\tIIdentityProfileGetPublicResponse\n\t> = {\n\t\toperationId: \"identityProfileGetPublic\",\n\t\tsummary: \"Get the identity profile public properties\",\n\t\ttag: tagsIdentityProfile[0].name,\n\t\tmethod: \"GET\",\n\t\tpath: `${baseRouteName}/:identity/public`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tidentityGetPublic(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IIdentityProfileGetPublicRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"identityGetPublicProfileRequestExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tidentity:\n\t\t\t\t\t\t\t\t\"did:iota:tst:0xc57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\tquery: {\n\t\t\t\t\t\t\tpropertyNames: \"role,email,name\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<IIdentityProfileGetPublicResponse>(),\n\t\t\t\tmimeType: MimeTypes.JsonLd,\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"identityGetPublicResponseExample\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\t\t[HeaderTypes.ContentType]: MimeTypes.JsonLd\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\t\"@context\": \"https://schema.org\",\n\t\t\t\t\t\t\t\t\"@type\": \"Person\",\n\t\t\t\t\t\t\t\tjobTitle: \"Professor\",\n\t\t\t\t\t\t\t\tname: \"Jane Doe\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: nameof<INotFoundResponse>()\n\t\t\t}\n\t\t]\n\t};\n\n\tconst identityProfileUpdateRoute: IRestRoute<IIdentityProfileUpdateRequest, INoContentResponse> =\n\t\t{\n\t\t\toperationId: \"identityProfileUpdate\",\n\t\t\tsummary: \"Update an identity profile properties\",\n\t\t\ttag: tagsIdentityProfile[0].name,\n\t\t\tmethod: \"PUT\",\n\t\t\tpath: `${baseRouteName}/`,\n\t\t\thandler: async (httpRequestContext, request) =>\n\t\t\t\tidentityProfileUpdate(httpRequestContext, componentName, request),\n\t\t\trequestType: {\n\t\t\t\ttype: nameof<IIdentityProfileUpdateRequest>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"identityProfileUpdateRequestExample\",\n\t\t\t\t\t\trequest: {\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\tpublicProfile: {\n\t\t\t\t\t\t\t\t\t\"@context\": \"https://schema.org\",\n\t\t\t\t\t\t\t\t\t\"@type\": \"Person\",\n\t\t\t\t\t\t\t\t\tjobTitle: \"Professor\",\n\t\t\t\t\t\t\t\t\tname: \"Jane Doe\"\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tprivateProfile: {\n\t\t\t\t\t\t\t\t\t\"@context\": \"https://schema.org\",\n\t\t\t\t\t\t\t\t\t\"@type\": \"Person\",\n\t\t\t\t\t\t\t\t\ttelephone: \"(425) 123-4567\",\n\t\t\t\t\t\t\t\t\turl: \"http://www.janedoe.com\"\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t},\n\t\t\tresponseType: [\n\t\t\t\t{\n\t\t\t\t\ttype: nameof<INoContentResponse>()\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\ttype: nameof<INotFoundResponse>()\n\t\t\t\t}\n\t\t\t]\n\t\t};\n\n\tconst identityProfileRemoveRoute: IRestRoute<INoContentRequest, INoContentResponse> = {\n\t\toperationId: \"identityProfileRemove\",\n\t\tsummary: \"Remove an identity profile\",\n\t\ttag: tagsIdentityProfile[0].name,\n\t\tmethod: \"DELETE\",\n\t\tpath: `${baseRouteName}/`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tidentityProfileRemove(httpRequestContext, componentName, request),\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<INoContentResponse>()\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: nameof<INotFoundResponse>()\n\t\t\t}\n\t\t]\n\t};\n\n\tconst identityProfileListRoute: IRestRoute<\n\t\tIIdentityProfileListRequest,\n\t\tIIdentityProfileListResponse\n\t> = {\n\t\toperationId: \"identitiesProfileList\",\n\t\tsummary: \"Get the list of profile data for identities\",\n\t\ttag: tagsIdentityProfile[0].name,\n\t\tmethod: \"GET\",\n\t\tpath: `${baseRouteName}/query/`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tidentitiesList(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IIdentityProfileListRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"identityProfileListRequestExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tquery: {}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tid: \"identityProfileListRequestFilteredExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tquery: {\n\t\t\t\t\t\t\tpublicFilters: \"jobTitle:Professor\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<IIdentityProfileListResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"identitiesProfileListResponseExample\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\titems: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tidentity:\n\t\t\t\t\t\t\t\t\t\t\t\"did:iota:tst:0xc57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70\",\n\t\t\t\t\t\t\t\t\t\tpublicProfile: {\n\t\t\t\t\t\t\t\t\t\t\t\"@context\": \"https://schema.org\",\n\t\t\t\t\t\t\t\t\t\t\t\"@type\": \"Person\",\n\t\t\t\t\t\t\t\t\t\t\tjobTitle: \"Professor\",\n\t\t\t\t\t\t\t\t\t\t\tname: \"Jane Doe\"\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\tcursor: \"1\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t]\n\t};\n\n\treturn [\n\t\tidentityProfileCreateRoute,\n\t\tidentityProfileGetRoute,\n\t\tidentityProfileGetPublicRoute,\n\t\tidentityProfileUpdateRoute,\n\t\tidentityProfileRemoveRoute,\n\t\tidentityProfileListRoute\n\t];\n}\n\n/**\n * Create an identity profile.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes stored in the ComponentFactory.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function identityProfileCreate(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IIdentityProfileCreateRequest\n): Promise<INoContentResponse> {\n\tGuards.object<IIdentityProfileCreateRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<IIdentityProfileCreateRequest[\"body\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.body),\n\t\trequest.body\n\t);\n\n\tconst contextIds = await ContextIdStore.getContextIds();\n\tContextIdHelper.guard(contextIds, ContextIdKeys.User);\n\n\tconst component = ComponentFactory.get<IIdentityProfileComponent>(componentName);\n\n\tawait component.create(\n\t\trequest.body.publicProfile,\n\t\trequest.body.privateProfile,\n\t\tcontextIds[ContextIdKeys.User]\n\t);\n\n\treturn {\n\t\tstatusCode: HttpStatusCode.noContent\n\t};\n}\n\n/**\n * Get the identity profile.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes stored in the ComponentFactory.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function identityGet(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IIdentityProfileGetRequest\n): Promise<IIdentityProfileGetResponse> {\n\tGuards.object<IIdentityProfileGetRequest>(ROUTES_SOURCE, nameof(request), request);\n\n\tconst contextIds = await ContextIdStore.getContextIds();\n\tContextIdHelper.guard(contextIds, ContextIdKeys.User);\n\n\tconst component = ComponentFactory.get<IIdentityProfileComponent>(componentName);\n\n\tconst result = await component.get(\n\t\tHttpParameterHelper.arrayFromString<keyof IJsonLdDocument>(request?.query?.publicPropertyNames),\n\t\tHttpParameterHelper.arrayFromString<keyof IJsonLdDocument>(\n\t\t\trequest?.query?.privatePropertyNames\n\t\t),\n\t\tcontextIds[ContextIdKeys.User]\n\t);\n\n\treturn {\n\t\tbody: result\n\t};\n}\n\n/**\n * Get the identity public profile.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes stored in the ComponentFactory.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function identityGetPublic(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IIdentityProfileGetPublicRequest\n): Promise<IIdentityProfileGetPublicResponse> {\n\tGuards.object<IIdentityProfileGetPublicRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.stringValue(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.pathParams?.identity),\n\t\trequest.pathParams?.identity\n\t);\n\n\tconst component = ComponentFactory.get<IIdentityProfileComponent>(componentName);\n\n\tconst result = await component.getPublic(\n\t\trequest?.pathParams.identity,\n\t\tHttpParameterHelper.arrayFromString<keyof IJsonLdDocument>(request?.query?.propertyNames)\n\t);\n\n\treturn {\n\t\theaders: {\n\t\t\t[HeaderTypes.ContentType]: MimeTypes.JsonLd\n\t\t},\n\t\tbody: result\n\t};\n}\n\n/**\n * Update an identity profile.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes stored in the ComponentFactory.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function identityProfileUpdate(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IIdentityProfileUpdateRequest\n): Promise<INoContentResponse> {\n\tGuards.object<IIdentityProfileUpdateRequest>(ROUTES_SOURCE, nameof(request), request);\n\n\tGuards.object<IIdentityProfileUpdateRequest[\"body\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.body),\n\t\trequest.body\n\t);\n\n\tconst contextIds = await ContextIdStore.getContextIds();\n\tContextIdHelper.guard(contextIds, ContextIdKeys.User);\n\n\tconst component = ComponentFactory.get<IIdentityProfileComponent>(componentName);\n\n\tawait component.update(\n\t\trequest.body.publicProfile,\n\t\trequest.body.privateProfile,\n\t\tcontextIds[ContextIdKeys.User]\n\t);\n\n\treturn {\n\t\tstatusCode: HttpStatusCode.noContent\n\t};\n}\n\n/**\n * Remove an identity profile.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes stored in the ComponentFactory.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function identityProfileRemove(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: INoContentRequest\n): Promise<INoContentResponse> {\n\tconst contextIds = await ContextIdStore.getContextIds();\n\tContextIdHelper.guard(contextIds, ContextIdKeys.User);\n\n\tconst component = ComponentFactory.get<IIdentityProfileComponent>(componentName);\n\n\tawait component.remove(contextIds[ContextIdKeys.User]);\n\n\treturn {\n\t\tstatusCode: HttpStatusCode.noContent\n\t};\n}\n\n/**\n * Get the list of organizations.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes stored in the ComponentFactory.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function identitiesList(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IIdentityProfileListRequest\n): Promise<IIdentityProfileListResponse> {\n\tconst component = ComponentFactory.get<IIdentityProfileComponent>(componentName);\n\n\tconst publicFilterPairs = HttpParameterHelper.arrayFromString(request?.query?.publicFilters);\n\tconst publicFilters = publicFilterPairs?.map(pair => {\n\t\tconst parts = pair.split(\":\");\n\t\treturn {\n\t\t\tpropertyName: parts[0],\n\t\t\tpropertyValue: parts[1]\n\t\t};\n\t});\n\n\treturn {\n\t\tbody: await component.list(\n\t\t\tpublicFilters,\n\t\t\tHttpParameterHelper.arrayFromString<keyof IJsonLdDocument>(\n\t\t\t\trequest?.query?.publicPropertyNames\n\t\t\t),\n\t\t\trequest?.query?.cursor,\n\t\t\tCoerce.integer(request.query?.limit)\n\t\t)\n\t};\n}\n"]}
@@ -35,7 +35,7 @@ export class IdentityProfileService {
35
35
  * @param publicProfile The public profile data as JSON-LD.
36
36
  * @param privateProfile The private profile data as JSON-LD.
37
37
  * @param identity The identity to perform the profile operation on.
38
- * @returns Nothing.
38
+ * @returns A promise that resolves when the profile has been created.
39
39
  */
40
40
  async create(publicProfile, privateProfile, identity) {
41
41
  Guards.stringValue(IdentityProfileService.CLASS_NAME, "identity", identity);
@@ -103,7 +103,7 @@ export class IdentityProfileService {
103
103
  * @param publicProfile The public profile data as JSON-LD.
104
104
  * @param privateProfile The private profile data as JSON-LD.
105
105
  * @param identity The identity to perform the profile operation on.
106
- * @returns Nothing.
106
+ * @returns A promise that resolves when the profile has been updated.
107
107
  */
108
108
  async update(publicProfile, privateProfile, identity) {
109
109
  Guards.stringValue(IdentityProfileService.CLASS_NAME, "identity", identity);
@@ -124,7 +124,7 @@ export class IdentityProfileService {
124
124
  /**
125
125
  * Delete the profile for an identity.
126
126
  * @param identity The identity to perform the profile operation on.
127
- * @returns Nothing.
127
+ * @returns A promise that resolves when the profile has been removed.
128
128
  */
129
129
  async remove(identity) {
130
130
  Guards.stringValue(IdentityProfileService.CLASS_NAME, "identity", identity);
@@ -1 +1 @@
1
- {"version":3,"file":"identityProfileService.js","sourceRoot":"","sources":["../../src/identityProfileService.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpF,OAAO,EACN,+BAA+B,EAG/B,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,eAAe,EAAE,MAAM,sBA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,CAAC,CAAC;YAClF,CAAC;YACD,MAAM,IAAI,CAAC,yBAAyB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACvD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,IAAI,SAAS,CAAC,cAAc,CAAC,KAAK,EAAE,sBAAsB,CAAC,UAAU,CAAC,EAAE,CAAC;gBACxE,MAAM,KAAK,CAAC;YACb,CAAC;YACD,MAAM,IAAI,YAAY,CACrB,sBAAsB,CAAC,UAAU,EACjC,cAAc,EACd,EAAE,QAAQ,EAAE,EACZ,KAAK,CACL,CAAC;QACH,CAAC;IACF,CAAC;IAED;;;;;;;OAOG;IACI,KAAK,CAAC,IAAI,CAChB,aAGG,EACH,mBAAiC,EACjC,MAAe,EACf,KAAc;QAWd,IAAI,CAAC;YACJ,iEAAiE;YACjE,gDAAgD;YAChD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,yBAAyB,CAAC,IAAI,CACvD,aAAa,EACb,SAAS,EACT,mBAAmB,EACnB,SAAS,EACT,MAAM,EACN,KAAK,CACL,CAAC;YACF,OAAO,MAAM,CAAC;QACf,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,MAAM,IAAI,YAAY,CAAC,sBAAsB,CAAC,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;QAC3F,CAAC;IACF,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { BaseError, GeneralError, Guards, Is, NotFoundError } from \"@twin.org/core\";\nimport type { IJsonLdDocument } from \"@twin.org/data-json-ld\";\nimport {\n\tIdentityProfileConnectorFactory,\n\ttype IIdentityProfileComponent,\n\ttype IIdentityProfileConnector\n} from \"@twin.org/identity-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { IdentityService } from \"./identityService.js\";\nimport type { IIdentityProfileServiceConstructorOptions } from \"./models/IIdentityProfileServiceConstructorOptions.js\";\n\n/**\n * Class which implements the identity profile contract.\n */\nexport class IdentityProfileService<\n\tT extends IJsonLdDocument = IJsonLdDocument,\n\tU extends IJsonLdDocument = IJsonLdDocument\n> implements IIdentityProfileComponent<T, U> {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<IdentityProfileService>();\n\n\t/**\n\t * The identity profile connector.\n\t * @internal\n\t */\n\tprivate readonly _identityProfileConnector: IIdentityProfileConnector<T, U>;\n\n\t/**\n\t * Create a new instance of IdentityProfileService.\n\t * @param options The dependencies for the identity profile service.\n\t */\n\tconstructor(options?: IIdentityProfileServiceConstructorOptions) {\n\t\tthis._identityProfileConnector = IdentityProfileConnectorFactory.get<\n\t\t\tIIdentityProfileConnector<T, U>\n\t\t>(options?.profileEntityConnectorType ?? \"identity-profile\");\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn IdentityService.CLASS_NAME;\n\t}\n\n\t/**\n\t * Create the profile properties for an identity.\n\t * @param publicProfile The public profile data as JSON-LD.\n\t * @param privateProfile The private profile data as JSON-LD.\n\t * @param identity The identity to perform the profile operation on.\n\t * @returns Nothing.\n\t */\n\tpublic async create(publicProfile?: T, privateProfile?: U, identity?: string): Promise<void> {\n\t\tGuards.stringValue(IdentityProfileService.CLASS_NAME, nameof(identity), identity);\n\n\t\ttry {\n\t\t\tawait this._identityProfileConnector.create(identity, publicProfile, privateProfile);\n\t\t} catch (error) {\n\t\t\tif (BaseError.someErrorClass(error, IdentityProfileService.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityProfileService.CLASS_NAME,\n\t\t\t\t\"createFailed\",\n\t\t\t\t{ identity },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Get the profile properties for an identity.\n\t * @param publicPropertyNames The public properties to get for the profile, defaults to all.\n\t * @param privatePropertyNames The private properties to get for the profile, defaults to all.\n\t * @param identity The identity to perform the profile operation on.\n\t * @returns The items identity and the properties.\n\t */\n\tpublic async get(\n\t\tpublicPropertyNames?: (keyof T)[],\n\t\tprivatePropertyNames?: (keyof U)[],\n\t\tidentity?: string\n\t): Promise<{\n\t\tidentity: string;\n\t\tpublicProfile?: Partial<T>;\n\t\tprivateProfile?: Partial<U>;\n\t}> {\n\t\tGuards.stringValue(IdentityProfileService.CLASS_NAME, nameof(identity), identity);\n\n\t\ttry {\n\t\t\tconst result = await this._identityProfileConnector.get(\n\t\t\t\tidentity,\n\t\t\t\tpublicPropertyNames,\n\t\t\t\tprivatePropertyNames\n\t\t\t);\n\t\t\tif (Is.undefined(result)) {\n\t\t\t\tthrow new NotFoundError(IdentityProfileService.CLASS_NAME, \"notFound\", identity);\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tidentity,\n\t\t\t\tpublicProfile: result.publicProfile,\n\t\t\t\tprivateProfile: result.privateProfile\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tif (BaseError.someErrorClass(error, IdentityProfileService.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(IdentityProfileService.CLASS_NAME, \"getFailed\", undefined, error);\n\t\t}\n\t}\n\n\t/**\n\t * Get the public profile properties for an identity.\n\t * @param identity The identity to perform the profile operation on.\n\t * @param propertyNames The properties to get for the item, defaults to all.\n\t * @returns The items properties.\n\t */\n\tpublic async getPublic(identity: string, propertyNames?: (keyof T)[]): Promise<Partial<T>> {\n\t\tGuards.stringValue(IdentityProfileService.CLASS_NAME, nameof(identity), identity);\n\n\t\ttry {\n\t\t\tconst result = await this._identityProfileConnector.get(identity, propertyNames);\n\t\t\tif (Is.undefined(result)) {\n\t\t\t\tthrow new NotFoundError(IdentityProfileService.CLASS_NAME, \"notFound\", identity);\n\t\t\t}\n\t\t\treturn result.publicProfile;\n\t\t} catch (error) {\n\t\t\tif (BaseError.someErrorClass(error, IdentityProfileService.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityProfileService.CLASS_NAME,\n\t\t\t\t\"getPublicFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Update the profile properties of an identity.\n\t * @param publicProfile The public profile data as JSON-LD.\n\t * @param privateProfile The private profile data as JSON-LD.\n\t * @param identity The identity to perform the profile operation on.\n\t * @returns Nothing.\n\t */\n\tpublic async update(publicProfile?: T, privateProfile?: U, identity?: string): Promise<void> {\n\t\tGuards.stringValue(IdentityProfileService.CLASS_NAME, nameof(identity), identity);\n\n\t\ttry {\n\t\t\tconst result = await this._identityProfileConnector.get(identity);\n\t\t\tif (Is.undefined(result)) {\n\t\t\t\tthrow new NotFoundError(IdentityProfileService.CLASS_NAME, \"notFound\", identity);\n\t\t\t}\n\t\t\tawait this._identityProfileConnector.update(identity, publicProfile, privateProfile);\n\t\t} catch (error) {\n\t\t\tif (BaseError.someErrorClass(error, IdentityProfileService.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityProfileService.CLASS_NAME,\n\t\t\t\t\"updateFailed\",\n\t\t\t\t{ identity },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Delete the profile for an identity.\n\t * @param identity The identity to perform the profile operation on.\n\t * @returns Nothing.\n\t */\n\tpublic async remove(identity?: string): Promise<void> {\n\t\tGuards.stringValue(IdentityProfileService.CLASS_NAME, nameof(identity), identity);\n\n\t\ttry {\n\t\t\tconst result = await this._identityProfileConnector.get(identity);\n\t\t\tif (Is.undefined(result)) {\n\t\t\t\tthrow new NotFoundError(IdentityProfileService.CLASS_NAME, \"notFound\", identity);\n\t\t\t}\n\t\t\tawait this._identityProfileConnector.remove(identity);\n\t\t} catch (error) {\n\t\t\tif (BaseError.someErrorClass(error, IdentityProfileService.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityProfileService.CLASS_NAME,\n\t\t\t\t\"removeFailed\",\n\t\t\t\t{ identity },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Get a list of the requested types.\n\t * @param publicFilters The filters to apply to the identities public profiles.\n\t * @param publicPropertyNames The public properties to get for the profile, defaults to all.\n\t * @param cursor The cursor for paged requests.\n\t * @param limit The maximum number of items in a page.\n\t * @returns The list of items and cursor for paging.\n\t */\n\tpublic async list(\n\t\tpublicFilters?: {\n\t\t\tpropertyName: string;\n\t\t\tpropertyValue: unknown;\n\t\t}[],\n\t\tpublicPropertyNames?: (keyof T)[],\n\t\tcursor?: string,\n\t\tlimit?: number\n\t): Promise<{\n\t\t/**\n\t\t * The identities.\n\t\t */\n\t\titems: { identity: string; publicProfile?: Partial<T>; privateProfile?: Partial<U> }[];\n\t\t/**\n\t\t * An optional cursor, when defined can be used to call find to get more entities.\n\t\t */\n\t\tcursor?: string;\n\t}> {\n\t\ttry {\n\t\t\t// We don't want to return private profile for this type of query\n\t\t\t// as it would expose the values to the REST api\n\t\t\tconst result = await this._identityProfileConnector.list(\n\t\t\t\tpublicFilters,\n\t\t\t\tundefined,\n\t\t\t\tpublicPropertyNames,\n\t\t\t\tundefined,\n\t\t\t\tcursor,\n\t\t\t\tlimit\n\t\t\t);\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(IdentityProfileService.CLASS_NAME, \"listFailed\", undefined, error);\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"identityProfileService.js","sourceRoot":"","sources":["../../src/identityProfileService.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpF,OAAO,EACN,+BAA+B,EAG/B,MAAM,2BAA2B,CA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sBAAsB,CAAC,UAAU,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;YAClF,CAAC;YACD,MAAM,IAAI,CAAC,yBAAyB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACvD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,IAAI,SAAS,CAAC,cAAc,CAAC,KAAK,EAAE,sBAAsB,CAAC,UAAU,CAAC,EAAE,CAAC;gBACxE,MAAM,KAAK,CAAC;YACb,CAAC;YACD,MAAM,IAAI,YAAY,CACrB,sBAAsB,CAAC,UAAU,EACjC,cAAc,EACd,EAAE,QAAQ,EAAE,EACZ,KAAK,CACL,CAAC;QACH,CAAC;IACF,CAAC;IAED;;;;;;;OAOG;IACI,KAAK,CAAC,IAAI,CAChB,aAGG,EACH,mBAAiC,EACjC,MAAe,EACf,KAAc;QAWd,IAAI,CAAC;YACJ,iEAAiE;YACjE,gDAAgD;YAChD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,yBAAyB,CAAC,IAAI,CACvD,aAAa,EACb,SAAS,EACT,mBAAmB,EACnB,SAAS,EACT,MAAM,EACN,KAAK,CACL,CAAC;YACF,OAAO,MAAM,CAAC;QACf,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,MAAM,IAAI,YAAY,CAAC,sBAAsB,CAAC,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;QAC3F,CAAC;IACF,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { BaseError, GeneralError, Guards, Is, NotFoundError } from \"@twin.org/core\";\nimport type { IJsonLdDocument } from \"@twin.org/data-json-ld\";\nimport {\n\tIdentityProfileConnectorFactory,\n\ttype IIdentityProfileComponent,\n\ttype IIdentityProfileConnector\n} from \"@twin.org/identity-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { IdentityService } from \"./identityService.js\";\nimport type { IIdentityProfileServiceConstructorOptions } from \"./models/IIdentityProfileServiceConstructorOptions.js\";\n\n/**\n * Class which implements the identity profile contract.\n */\nexport class IdentityProfileService<\n\tT extends IJsonLdDocument = IJsonLdDocument,\n\tU extends IJsonLdDocument = IJsonLdDocument\n> implements IIdentityProfileComponent<T, U> {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<IdentityProfileService>();\n\n\t/**\n\t * The identity profile connector.\n\t * @internal\n\t */\n\tprivate readonly _identityProfileConnector: IIdentityProfileConnector<T, U>;\n\n\t/**\n\t * Create a new instance of IdentityProfileService.\n\t * @param options The dependencies for the identity profile service.\n\t */\n\tconstructor(options?: IIdentityProfileServiceConstructorOptions) {\n\t\tthis._identityProfileConnector = IdentityProfileConnectorFactory.get<\n\t\t\tIIdentityProfileConnector<T, U>\n\t\t>(options?.profileEntityConnectorType ?? \"identity-profile\");\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn IdentityService.CLASS_NAME;\n\t}\n\n\t/**\n\t * Create the profile properties for an identity.\n\t * @param publicProfile The public profile data as JSON-LD.\n\t * @param privateProfile The private profile data as JSON-LD.\n\t * @param identity The identity to perform the profile operation on.\n\t * @returns A promise that resolves when the profile has been created.\n\t */\n\tpublic async create(publicProfile?: T, privateProfile?: U, identity?: string): Promise<void> {\n\t\tGuards.stringValue(IdentityProfileService.CLASS_NAME, nameof(identity), identity);\n\n\t\ttry {\n\t\t\tawait this._identityProfileConnector.create(identity, publicProfile, privateProfile);\n\t\t} catch (error) {\n\t\t\tif (BaseError.someErrorClass(error, IdentityProfileService.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityProfileService.CLASS_NAME,\n\t\t\t\t\"createFailed\",\n\t\t\t\t{ identity },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Get the profile properties for an identity.\n\t * @param publicPropertyNames The public properties to get for the profile, defaults to all.\n\t * @param privatePropertyNames The private properties to get for the profile, defaults to all.\n\t * @param identity The identity to perform the profile operation on.\n\t * @returns The items identity and the properties.\n\t */\n\tpublic async get(\n\t\tpublicPropertyNames?: (keyof T)[],\n\t\tprivatePropertyNames?: (keyof U)[],\n\t\tidentity?: string\n\t): Promise<{\n\t\tidentity: string;\n\t\tpublicProfile?: Partial<T>;\n\t\tprivateProfile?: Partial<U>;\n\t}> {\n\t\tGuards.stringValue(IdentityProfileService.CLASS_NAME, nameof(identity), identity);\n\n\t\ttry {\n\t\t\tconst result = await this._identityProfileConnector.get(\n\t\t\t\tidentity,\n\t\t\t\tpublicPropertyNames,\n\t\t\t\tprivatePropertyNames\n\t\t\t);\n\t\t\tif (Is.undefined(result)) {\n\t\t\t\tthrow new NotFoundError(IdentityProfileService.CLASS_NAME, \"notFound\", identity);\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tidentity,\n\t\t\t\tpublicProfile: result.publicProfile,\n\t\t\t\tprivateProfile: result.privateProfile\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tif (BaseError.someErrorClass(error, IdentityProfileService.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(IdentityProfileService.CLASS_NAME, \"getFailed\", undefined, error);\n\t\t}\n\t}\n\n\t/**\n\t * Get the public profile properties for an identity.\n\t * @param identity The identity to perform the profile operation on.\n\t * @param propertyNames The properties to get for the item, defaults to all.\n\t * @returns The items properties.\n\t */\n\tpublic async getPublic(identity: string, propertyNames?: (keyof T)[]): Promise<Partial<T>> {\n\t\tGuards.stringValue(IdentityProfileService.CLASS_NAME, nameof(identity), identity);\n\n\t\ttry {\n\t\t\tconst result = await this._identityProfileConnector.get(identity, propertyNames);\n\t\t\tif (Is.undefined(result)) {\n\t\t\t\tthrow new NotFoundError(IdentityProfileService.CLASS_NAME, \"notFound\", identity);\n\t\t\t}\n\t\t\treturn result.publicProfile;\n\t\t} catch (error) {\n\t\t\tif (BaseError.someErrorClass(error, IdentityProfileService.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityProfileService.CLASS_NAME,\n\t\t\t\t\"getPublicFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Update the profile properties of an identity.\n\t * @param publicProfile The public profile data as JSON-LD.\n\t * @param privateProfile The private profile data as JSON-LD.\n\t * @param identity The identity to perform the profile operation on.\n\t * @returns A promise that resolves when the profile has been updated.\n\t */\n\tpublic async update(publicProfile?: T, privateProfile?: U, identity?: string): Promise<void> {\n\t\tGuards.stringValue(IdentityProfileService.CLASS_NAME, nameof(identity), identity);\n\n\t\ttry {\n\t\t\tconst result = await this._identityProfileConnector.get(identity);\n\t\t\tif (Is.undefined(result)) {\n\t\t\t\tthrow new NotFoundError(IdentityProfileService.CLASS_NAME, \"notFound\", identity);\n\t\t\t}\n\t\t\tawait this._identityProfileConnector.update(identity, publicProfile, privateProfile);\n\t\t} catch (error) {\n\t\t\tif (BaseError.someErrorClass(error, IdentityProfileService.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityProfileService.CLASS_NAME,\n\t\t\t\t\"updateFailed\",\n\t\t\t\t{ identity },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Delete the profile for an identity.\n\t * @param identity The identity to perform the profile operation on.\n\t * @returns A promise that resolves when the profile has been removed.\n\t */\n\tpublic async remove(identity?: string): Promise<void> {\n\t\tGuards.stringValue(IdentityProfileService.CLASS_NAME, nameof(identity), identity);\n\n\t\ttry {\n\t\t\tconst result = await this._identityProfileConnector.get(identity);\n\t\t\tif (Is.undefined(result)) {\n\t\t\t\tthrow new NotFoundError(IdentityProfileService.CLASS_NAME, \"notFound\", identity);\n\t\t\t}\n\t\t\tawait this._identityProfileConnector.remove(identity);\n\t\t} catch (error) {\n\t\t\tif (BaseError.someErrorClass(error, IdentityProfileService.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityProfileService.CLASS_NAME,\n\t\t\t\t\"removeFailed\",\n\t\t\t\t{ identity },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Get a list of the requested types.\n\t * @param publicFilters The filters to apply to the identities public profiles.\n\t * @param publicPropertyNames The public properties to get for the profile, defaults to all.\n\t * @param cursor The cursor for paged requests.\n\t * @param limit The maximum number of items in a page.\n\t * @returns The list of items and cursor for paging.\n\t */\n\tpublic async list(\n\t\tpublicFilters?: {\n\t\t\tpropertyName: string;\n\t\t\tpropertyValue: unknown;\n\t\t}[],\n\t\tpublicPropertyNames?: (keyof T)[],\n\t\tcursor?: string,\n\t\tlimit?: number\n\t): Promise<{\n\t\t/**\n\t\t * The identities.\n\t\t */\n\t\titems: { identity: string; publicProfile?: Partial<T>; privateProfile?: Partial<U> }[];\n\t\t/**\n\t\t * An optional cursor, when defined can be used to call find to get more entities.\n\t\t */\n\t\tcursor?: string;\n\t}> {\n\t\ttry {\n\t\t\t// We don't want to return private profile for this type of query\n\t\t\t// as it would expose the values to the REST api\n\t\t\tconst result = await this._identityProfileConnector.list(\n\t\t\t\tpublicFilters,\n\t\t\t\tundefined,\n\t\t\t\tpublicPropertyNames,\n\t\t\t\tundefined,\n\t\t\t\tcursor,\n\t\t\t\tlimit\n\t\t\t);\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(IdentityProfileService.CLASS_NAME, \"listFailed\", undefined, error);\n\t\t}\n\t}\n}\n"]}
@@ -14,7 +14,7 @@ export const tagsIdentityResolver = [
14
14
  }
15
15
  ];
16
16
  /**
17
- * The REST routes for identity.
17
+ * The REST routes for identity resolution.
18
18
  * @param baseRouteName Prefix to prepend to the paths.
19
19
  * @param componentName The name of the component to use in the routes stored in the ComponentFactory.
20
20
  * @returns The generated routes.
@@ -62,8 +62,7 @@ export function generateRestRoutesIdentityResolver(baseRouteName, componentName)
62
62
  }
63
63
  ]
64
64
  }
65
- ],
66
- skipAuth: true
65
+ ]
67
66
  };
68
67
  return [identityResolveRoute];
69
68
  }
@@ -1 +1 @@
1
- {"version":3,"file":"identityResolverRoutes.js","sourceRoot":"","sources":["../../src/identityResolverRoutes.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAO1D,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAE1D;;GAEG;AACH,MAAM,aAAa,GAAG,wBAAwB,CAAC;AAE/C;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAW;IAC3C;QACC,IAAI,EAAE,UAAU;QAChB,WAAW,EAAE,8DAA8D;KAC3E;CACD,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,kCAAkC,CACjD,aAAqB,EACrB,aAAqB;IAErB,MAAM,oBAAoB,GAAkE;QAC3F,WAAW,EAAE,iBAAiB;QAC9B,OAAO,EAAE,qBAAqB;QAC9B,GAAG,EAAE,oBAAoB,CAAC,CAAC,CAAC,CAAC,IAAI;QACjC,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,GAAG,aAAa,YAAY;QAClC,OAAO,EAAE,KAAK,EAAE,kBAAkB,EAAE,OAAO,EAAE,EAAE,CAC9C,eAAe,CAAC,kBAAkB,EAAE,aAAa,EAAE,OAAO,CAAC;QAC5D,WAAW,EAAE;YACZ,IAAI,2BAAmC;YACvC,QAAQ,EAAE;gBACT;oBACC,EAAE,EAAE,+BAA+B;oBACnC,OAAO,EAAE;wBACR,UAAU,EAAE;4BACX,QAAQ,EACP,iFAAiF;yBAClF;qBACD;iBACD;aACD;SACD;QACD,YAAY,EAAE;YACb;gBACC,IAAI,4BAAoC;gBACxC,QAAQ,EAAE;oBACT;wBACC,EAAE,EAAE,gCAAgC;wBACpC,QAAQ,EAAE;4BACT,IAAI,EAAE;gCACL,UAAU,EAAE,WAAW,CAAC,OAAO;gCAC/B,EAAE,EAAE,iFAAiF;gCACrF,OAAO,EAAE;oCACR;wCACC,EAAE,EAAE,4FAA4F;wCAChG,IAAI,EAAE,sBAAsB;wCAC5B,eAAe,EAAE,oDAAoD;qCACrE;iCACD;6BACD;yBACD;qBACD;iBACD;aACD;SACD;QACD,QAAQ,EAAE,IAAI;KACd,CAAC;IAEF,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAC/B,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACpC,kBAAuC,EACvC,aAAqB,EACrB,OAAgC;IAEhC,MAAM,CAAC,MAAM,CAA0B,aAAa,aAAmB,OAAO,CAAC,CAAC;IAChF,MAAM,CAAC,MAAM,CACZ,aAAa,wBAEb,OAAO,CAAC,UAAU,CAClB,CAAC;IACF,MAAM,CAAC,WAAW,CACjB,aAAa,iCAEb,OAAO,CAAC,UAAU,CAAC,QAAQ,CAC3B,CAAC;IAEF,MAAM,SAAS,GAAG,gBAAgB,CAAC,GAAG,CAA6B,aAAa,CAAC,CAAC;IAElF,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,eAAe,CAAC,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IAE5E,OAAO;QACN,IAAI,EAAE,MAAM;KACZ,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IHttpRequestContext, IRestRoute, ITag } from \"@twin.org/api-models\";\nimport { ComponentFactory, Guards } from \"@twin.org/core\";\nimport type {\n\tIIdentityResolverComponent,\n\tIIdentityResolveRequest,\n\tIIdentityResolveResponse\n} from \"@twin.org/identity-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { DidContexts } from \"@twin.org/standards-w3c-did\";\n\n/**\n * The source used when communicating about these routes.\n */\nconst ROUTES_SOURCE = \"identityResolverRoutes\";\n\n/**\n * The tag to associate with the routes.\n */\nexport const tagsIdentityResolver: ITag[] = [\n\t{\n\t\tname: \"Identity\",\n\t\tdescription: \"Service to provide all features related to digital identity.\"\n\t}\n];\n\n/**\n * The REST routes for identity.\n * @param baseRouteName Prefix to prepend to the paths.\n * @param componentName The name of the component to use in the routes stored in the ComponentFactory.\n * @returns The generated routes.\n */\nexport function generateRestRoutesIdentityResolver(\n\tbaseRouteName: string,\n\tcomponentName: string\n): IRestRoute[] {\n\tconst identityResolveRoute: IRestRoute<IIdentityResolveRequest, IIdentityResolveResponse> = {\n\t\toperationId: \"identityResolve\",\n\t\tsummary: \"Resolve an identity\",\n\t\ttag: tagsIdentityResolver[0].name,\n\t\tmethod: \"GET\",\n\t\tpath: `${baseRouteName}/:identity`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tidentityResolve(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IIdentityResolveRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"identityResolveRequestExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tidentity:\n\t\t\t\t\t\t\t\t\"did:iota:tst:0xe3088ba9aa8c28e1d139708a14e8c0fdff11ee8223baac4aa5bcf3321e4bfc6a\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<IIdentityResolveResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"identityResolveResponseExample\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\t\"@context\": DidContexts.Context,\n\t\t\t\t\t\t\t\tid: \"did:iota:tst:0xe3088ba9aa8c28e1d139708a14e8c0fdff11ee8223baac4aa5bcf3321e4bfc6a\",\n\t\t\t\t\t\t\t\tservice: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tid: \"did:iota:tst:0xe3088ba9aa8c28e1d139708a14e8c0fdff11ee8223baac4aa5bcf3321e4bfc6a#revocation\",\n\t\t\t\t\t\t\t\t\t\ttype: \"RevocationBitmap2022\",\n\t\t\t\t\t\t\t\t\t\tserviceEndpoint: \"data:application/octet-stream;base64,eJyzMmAAAwABr\"\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t],\n\t\tskipAuth: true\n\t};\n\n\treturn [identityResolveRoute];\n}\n\n/**\n * Resolve an identity.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes stored in the ComponentFactory.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function identityResolve(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IIdentityResolveRequest\n): Promise<IIdentityResolveResponse> {\n\tGuards.object<IIdentityResolveRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<IIdentityResolveRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.pathParams),\n\t\trequest.pathParams\n\t);\n\tGuards.stringValue(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.pathParams.identity),\n\t\trequest.pathParams.identity\n\t);\n\n\tconst component = ComponentFactory.get<IIdentityResolverComponent>(componentName);\n\n\tconst result = await component.identityResolve(request.pathParams.identity);\n\n\treturn {\n\t\tbody: result\n\t};\n}\n"]}
1
+ {"version":3,"file":"identityResolverRoutes.js","sourceRoot":"","sources":["../../src/identityResolverRoutes.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAO1D,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAE1D;;GAEG;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EACrB,OAAgC;IAEhC,MAAM,CAAC,MAAM,CAA0B,aAAa,aAAmB,OAAO,CAAC,CAAC;IAChF,MAAM,CAAC,MAAM,CACZ,aAAa,wBAEb,OAAO,CAAC,UAAU,CAClB,CAAC;IACF,MAAM,CAAC,WAAW,CACjB,aAAa,iCAEb,OAAO,CAAC,UAAU,CAAC,QAAQ,CAC3B,CAAC;IAEF,MAAM,SAAS,GAAG,gBAAgB,CAAC,GAAG,CAA6B,aAAa,CAAC,CAAC;IAElF,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,eAAe,CAAC,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IAE5E,OAAO;QACN,IAAI,EAAE,MAAM;KACZ,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IHttpRequestContext, IRestRoute, ITag } from \"@twin.org/api-models\";\nimport { ComponentFactory, Guards } from \"@twin.org/core\";\nimport type {\n\tIIdentityResolverComponent,\n\tIIdentityResolveRequest,\n\tIIdentityResolveResponse\n} from \"@twin.org/identity-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { DidContexts } from \"@twin.org/standards-w3c-did\";\n\n/**\n * The source used when communicating about these routes.\n */\nconst ROUTES_SOURCE = \"identityResolverRoutes\";\n\n/**\n * The tag to associate with the routes.\n */\nexport const tagsIdentityResolver: ITag[] = [\n\t{\n\t\tname: \"Identity\",\n\t\tdescription: \"Service to provide all features related to digital identity.\"\n\t}\n];\n\n/**\n * The REST routes for identity resolution.\n * @param baseRouteName Prefix to prepend to the paths.\n * @param componentName The name of the component to use in the routes stored in the ComponentFactory.\n * @returns The generated routes.\n */\nexport function generateRestRoutesIdentityResolver(\n\tbaseRouteName: string,\n\tcomponentName: string\n): IRestRoute[] {\n\tconst identityResolveRoute: IRestRoute<IIdentityResolveRequest, IIdentityResolveResponse> = {\n\t\toperationId: \"identityResolve\",\n\t\tsummary: \"Resolve an identity\",\n\t\ttag: tagsIdentityResolver[0].name,\n\t\tmethod: \"GET\",\n\t\tpath: `${baseRouteName}/:identity`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tidentityResolve(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IIdentityResolveRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"identityResolveRequestExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tidentity:\n\t\t\t\t\t\t\t\t\"did:iota:tst:0xe3088ba9aa8c28e1d139708a14e8c0fdff11ee8223baac4aa5bcf3321e4bfc6a\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<IIdentityResolveResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"identityResolveResponseExample\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\t\"@context\": DidContexts.Context,\n\t\t\t\t\t\t\t\tid: \"did:iota:tst:0xe3088ba9aa8c28e1d139708a14e8c0fdff11ee8223baac4aa5bcf3321e4bfc6a\",\n\t\t\t\t\t\t\t\tservice: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tid: \"did:iota:tst:0xe3088ba9aa8c28e1d139708a14e8c0fdff11ee8223baac4aa5bcf3321e4bfc6a#revocation\",\n\t\t\t\t\t\t\t\t\t\ttype: \"RevocationBitmap2022\",\n\t\t\t\t\t\t\t\t\t\tserviceEndpoint: \"data:application/octet-stream;base64,eJyzMmAAAwABr\"\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t]\n\t};\n\n\treturn [identityResolveRoute];\n}\n\n/**\n * Resolve an identity.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes stored in the ComponentFactory.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function identityResolve(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IIdentityResolveRequest\n): Promise<IIdentityResolveResponse> {\n\tGuards.object<IIdentityResolveRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<IIdentityResolveRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.pathParams),\n\t\trequest.pathParams\n\t);\n\tGuards.stringValue(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.pathParams.identity),\n\t\trequest.pathParams.identity\n\t);\n\n\tconst component = ComponentFactory.get<IIdentityResolverComponent>(componentName);\n\n\tconst result = await component.identityResolve(request.pathParams.identity);\n\n\treturn {\n\t\tbody: result\n\t};\n}\n"]}
@@ -62,6 +62,7 @@ export class IdentityResolverService {
62
62
  * Get the connector from the namespace.
63
63
  * @param namespace The namespace for the identity.
64
64
  * @returns The connector.
65
+ * @throws GeneralError if the connector is not found.
65
66
  * @internal
66
67
  */
67
68
  getConnectorByNamespace(namespace) {
@@ -82,6 +83,7 @@ export class IdentityResolverService {
82
83
  * Get the connector from the uri.
83
84
  * @param id The id of the identity in urn format.
84
85
  * @returns The connector.
86
+ * @throws GeneralError if the namespace does not match or the connector is not found.
85
87
  * @internal
86
88
  */
87
89
  getConnectorByUri(id) {
@@ -1 +1 @@
1
- {"version":3,"file":"identityResolverService.js","sourceRoot":"","sources":["../../src/identityResolverService.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,YAAY,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EACN,gCAAgC,EAGhC,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAGvD;;GA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;QAE5D,IAAI,SAAS,GACZ,gCAAgC,CAAC,WAAW,CAA6B,eAAe,CAAC,CAAC;QAE3F,IAAI,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC;YACzB,8DAA8D;YAC9D,SAAS,GAAG,gCAAgC,CAAC,WAAW,CACvD,IAAI,CAAC,8BAA8B,CACnC,CAAC;YACF,IAAI,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC;gBACzB,MAAM,IAAI,YAAY,CAAC,uBAAuB,CAAC,UAAU,EAAE,mBAAmB,EAAE;oBAC/E,SAAS,EAAE,eAAe;iBAC1B,CAAC,CAAC;YACJ,CAAC;QACF,CAAC;QAED,OAAO,SAAS,CAAC;IAClB,CAAC;IAED;;;;;OAKG;IACK,iBAAiB,CAAC,EAAU;QACnC,MAAM,KAAK,GAAG,GAAG,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;QAEtC,IAAI,KAAK,CAAC,mBAAmB,EAAE,KAAK,KAAK,EAAE,CAAC;YAC3C,MAAM,IAAI,YAAY,CAAC,uBAAuB,CAAC,UAAU,EAAE,mBAAmB,EAAE;gBAC/E,SAAS,EAAE,KAAK;gBAChB,EAAE;aACF,CAAC,CAAC;QACJ,CAAC;QAED,OAAO,IAAI,CAAC,uBAAuB,CAAC,KAAK,CAAC,eAAe,EAAE,CAAC,CAAC;IAC9D,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { GeneralError, Is, Urn } from \"@twin.org/core\";\nimport {\n\tIdentityResolverConnectorFactory,\n\ttype IIdentityResolverComponent,\n\ttype IIdentityResolverConnector\n} from \"@twin.org/identity-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport type { IDidDocument } from \"@twin.org/standards-w3c-did\";\nimport { IdentityService } from \"./identityService.js\";\nimport type { IIdentityResolverServiceConstructorOptions } from \"./models/IIdentityResolverServiceConstructorOptions.js\";\n\n/**\n * Class which implements the identity resolver contract.\n */\nexport class IdentityResolverService implements IIdentityResolverComponent {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<IdentityResolverService>();\n\n\t/**\n\t * The default namespace for the connector to use.\n\t * @internal\n\t */\n\tprivate readonly _defaultNamespace: string;\n\n\t/**\n\t * Fallback connector type to use if the namespace connector is not available.\n\t * @internal\n\t */\n\tprivate readonly _fallbackResolverConnectorType: string;\n\n\t/**\n\t * Create a new instance of IdentityResolverService.\n\t * @param options The options for the service.\n\t */\n\tconstructor(options?: IIdentityResolverServiceConstructorOptions) {\n\t\tconst names = IdentityResolverConnectorFactory.names();\n\t\tif (names.length === 0) {\n\t\t\tthrow new GeneralError(IdentityResolverService.CLASS_NAME, \"noConnectors\");\n\t\t}\n\n\t\tthis._defaultNamespace = options?.config?.defaultNamespace ?? names[0];\n\t\tthis._fallbackResolverConnectorType = options?.fallbackResolverConnectorType ?? \"universal\";\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn IdentityService.CLASS_NAME;\n\t}\n\n\t/**\n\t * Resolve an identity.\n\t * @param identity The id of the document to resolve.\n\t * @returns The resolved document.\n\t */\n\tpublic async identityResolve(identity: string): Promise<IDidDocument> {\n\t\tUrn.guard(IdentityResolverService.CLASS_NAME, nameof(identity), identity);\n\n\t\ttry {\n\t\t\tconst identityResolverConnector = this.getConnectorByUri(identity);\n\t\t\tconst document = await identityResolverConnector.resolveDocument(identity);\n\n\t\t\treturn document;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityResolverService.CLASS_NAME,\n\t\t\t\t\"identityResolveFailed\",\n\t\t\t\t{\n\t\t\t\t\tidentity\n\t\t\t\t},\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Get the connector from the namespace.\n\t * @param namespace The namespace for the identity.\n\t * @returns The connector.\n\t * @internal\n\t */\n\tprivate getConnectorByNamespace(namespace?: string): IIdentityResolverConnector {\n\t\tconst namespaceMethod = namespace ?? this._defaultNamespace;\n\n\t\tlet connector =\n\t\t\tIdentityResolverConnectorFactory.getIfExists<IIdentityResolverConnector>(namespaceMethod);\n\n\t\tif (Is.empty(connector)) {\n\t\t\t// Let's see if a fallback 'universal' connector is registered\n\t\t\tconnector = IdentityResolverConnectorFactory.getIfExists<IIdentityResolverConnector>(\n\t\t\t\tthis._fallbackResolverConnectorType\n\t\t\t);\n\t\t\tif (Is.empty(connector)) {\n\t\t\t\tthrow new GeneralError(IdentityResolverService.CLASS_NAME, \"connectorNotFound\", {\n\t\t\t\t\tnamespace: namespaceMethod\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\treturn connector;\n\t}\n\n\t/**\n\t * Get the connector from the uri.\n\t * @param id The id of the identity in urn format.\n\t * @returns The connector.\n\t * @internal\n\t */\n\tprivate getConnectorByUri(id: string): IIdentityResolverConnector {\n\t\tconst idUri = Urn.fromValidString(id);\n\n\t\tif (idUri.namespaceIdentifier() !== \"did\") {\n\t\t\tthrow new GeneralError(IdentityResolverService.CLASS_NAME, \"namespaceMismatch\", {\n\t\t\t\tnamespace: \"did\",\n\t\t\t\tid\n\t\t\t});\n\t\t}\n\n\t\treturn this.getConnectorByNamespace(idUri.namespaceMethod());\n\t}\n}\n"]}
1
+ {"version":3,"file":"identityResolverService.js","sourceRoot":"","sources":["../../src/identityResolverService.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,YAAY,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EACN,gCAAgC,EAGhC,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAGvD;;GAEG;AACH,MAAM,OAAO,uBAAuB;IACnC;;OAEG;IACI,MAAM,CAAU,UAAU,6BAA6C;IAE9E;;;OAGG;IACc,iBAAiB,CAAS;IAE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AAS,CAAC,EAAE,CAAC;YACzB,8DAA8D;YAC9D,SAAS,GAAG,gCAAgC,CAAC,WAAW,CACvD,IAAI,CAAC,8BAA8B,CACnC,CAAC;YACF,IAAI,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC;gBACzB,MAAM,IAAI,YAAY,CAAC,uBAAuB,CAAC,UAAU,EAAE,mBAAmB,EAAE;oBAC/E,SAAS,EAAE,eAAe;iBAC1B,CAAC,CAAC;YACJ,CAAC;QACF,CAAC;QAED,OAAO,SAAS,CAAC;IAClB,CAAC;IAED;;;;;;OAMG;IACK,iBAAiB,CAAC,EAAU;QACnC,MAAM,KAAK,GAAG,GAAG,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;QAEtC,IAAI,KAAK,CAAC,mBAAmB,EAAE,KAAK,KAAK,EAAE,CAAC;YAC3C,MAAM,IAAI,YAAY,CAAC,uBAAuB,CAAC,UAAU,EAAE,mBAAmB,EAAE;gBAC/E,SAAS,EAAE,KAAK;gBAChB,EAAE;aACF,CAAC,CAAC;QACJ,CAAC;QAED,OAAO,IAAI,CAAC,uBAAuB,CAAC,KAAK,CAAC,eAAe,EAAE,CAAC,CAAC;IAC9D,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { GeneralError, Is, Urn } from \"@twin.org/core\";\nimport {\n\tIdentityResolverConnectorFactory,\n\ttype IIdentityResolverComponent,\n\ttype IIdentityResolverConnector\n} from \"@twin.org/identity-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport type { IDidDocument } from \"@twin.org/standards-w3c-did\";\nimport { IdentityService } from \"./identityService.js\";\nimport type { IIdentityResolverServiceConstructorOptions } from \"./models/IIdentityResolverServiceConstructorOptions.js\";\n\n/**\n * Class which implements the identity resolver contract.\n */\nexport class IdentityResolverService implements IIdentityResolverComponent {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<IdentityResolverService>();\n\n\t/**\n\t * The default namespace for the connector to use.\n\t * @internal\n\t */\n\tprivate readonly _defaultNamespace: string;\n\n\t/**\n\t * Fallback connector type to use if the namespace connector is not available.\n\t * @internal\n\t */\n\tprivate readonly _fallbackResolverConnectorType: string;\n\n\t/**\n\t * Create a new instance of IdentityResolverService.\n\t * @param options The options for the service.\n\t */\n\tconstructor(options?: IIdentityResolverServiceConstructorOptions) {\n\t\tconst names = IdentityResolverConnectorFactory.names();\n\t\tif (names.length === 0) {\n\t\t\tthrow new GeneralError(IdentityResolverService.CLASS_NAME, \"noConnectors\");\n\t\t}\n\n\t\tthis._defaultNamespace = options?.config?.defaultNamespace ?? names[0];\n\t\tthis._fallbackResolverConnectorType = options?.fallbackResolverConnectorType ?? \"universal\";\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn IdentityService.CLASS_NAME;\n\t}\n\n\t/**\n\t * Resolve an identity.\n\t * @param identity The id of the document to resolve.\n\t * @returns The resolved document.\n\t */\n\tpublic async identityResolve(identity: string): Promise<IDidDocument> {\n\t\tUrn.guard(IdentityResolverService.CLASS_NAME, nameof(identity), identity);\n\n\t\ttry {\n\t\t\tconst identityResolverConnector = this.getConnectorByUri(identity);\n\t\t\tconst document = await identityResolverConnector.resolveDocument(identity);\n\n\t\t\treturn document;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityResolverService.CLASS_NAME,\n\t\t\t\t\"identityResolveFailed\",\n\t\t\t\t{\n\t\t\t\t\tidentity\n\t\t\t\t},\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Get the connector from the namespace.\n\t * @param namespace The namespace for the identity.\n\t * @returns The connector.\n\t * @throws GeneralError if the connector is not found.\n\t * @internal\n\t */\n\tprivate getConnectorByNamespace(namespace?: string): IIdentityResolverConnector {\n\t\tconst namespaceMethod = namespace ?? this._defaultNamespace;\n\n\t\tlet connector =\n\t\t\tIdentityResolverConnectorFactory.getIfExists<IIdentityResolverConnector>(namespaceMethod);\n\n\t\tif (Is.empty(connector)) {\n\t\t\t// Let's see if a fallback 'universal' connector is registered\n\t\t\tconnector = IdentityResolverConnectorFactory.getIfExists<IIdentityResolverConnector>(\n\t\t\t\tthis._fallbackResolverConnectorType\n\t\t\t);\n\t\t\tif (Is.empty(connector)) {\n\t\t\t\tthrow new GeneralError(IdentityResolverService.CLASS_NAME, \"connectorNotFound\", {\n\t\t\t\t\tnamespace: namespaceMethod\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\treturn connector;\n\t}\n\n\t/**\n\t * Get the connector from the uri.\n\t * @param id The id of the identity in urn format.\n\t * @returns The connector.\n\t * @throws GeneralError if the namespace does not match or the connector is not found.\n\t * @internal\n\t */\n\tprivate getConnectorByUri(id: string): IIdentityResolverConnector {\n\t\tconst idUri = Urn.fromValidString(id);\n\n\t\tif (idUri.namespaceIdentifier() !== \"did\") {\n\t\t\tthrow new GeneralError(IdentityResolverService.CLASS_NAME, \"namespaceMismatch\", {\n\t\t\t\tnamespace: \"did\",\n\t\t\t\tid\n\t\t\t});\n\t\t}\n\n\t\treturn this.getConnectorByNamespace(idUri.namespaceMethod());\n\t}\n}\n"]}
@@ -428,8 +428,7 @@ export function generateRestRoutesIdentity(baseRouteName, componentName) {
428
428
  }
429
429
  ]
430
430
  }
431
- ],
432
- skipAuth: true
431
+ ]
433
432
  };
434
433
  const identityVerifiableCredentialVerifyDocumentRoute = {
435
434
  operationId: "identityVerifiableCredentialVerifyDocument",
@@ -494,8 +493,7 @@ export function generateRestRoutesIdentity(baseRouteName, componentName) {
494
493
  }
495
494
  ]
496
495
  }
497
- ],
498
- skipAuth: true
496
+ ]
499
497
  };
500
498
  const identityVerifiableCredentialRevokeRoute = {
501
499
  operationId: "identityVerifiableCredentialRevoke",
@@ -656,8 +654,7 @@ export function generateRestRoutesIdentity(baseRouteName, componentName) {
656
654
  }
657
655
  ]
658
656
  }
659
- ],
660
- skipAuth: true
657
+ ]
661
658
  };
662
659
  const identityVerifiablePresentationVerifyDocumentRoute = {
663
660
  operationId: "identityVerifiablePresentationVerifyDocument",
@@ -720,8 +717,7 @@ export function generateRestRoutesIdentity(baseRouteName, componentName) {
720
717
  }
721
718
  ]
722
719
  }
723
- ],
724
- skipAuth: true
720
+ ]
725
721
  };
726
722
  const identityProofCreateRoute = {
727
723
  operationId: "identityProofCreate",
@@ -846,8 +842,7 @@ export function generateRestRoutesIdentity(baseRouteName, componentName) {
846
842
  }
847
843
  ]
848
844
  }
849
- ],
850
- skipAuth: true
845
+ ]
851
846
  };
852
847
  return [
853
848
  identityCreateRoute,