From 9a9cb694a375e2e499d87724162cc9d1340b7697 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Ribo=CC=81?= Date: Sat, 15 Jun 2024 00:11:32 +0200 Subject: [PATCH] fix: deprecate schemas package --- packages/schemas/.gitignore | 10 - packages/schemas/CHANGELOG.md | 27 --- packages/schemas/LICENSE | 201 ----------------- packages/schemas/README.md | 2 - .../schemas/coverage/coverage-summary.json | 25 --- packages/schemas/package.json | 49 ----- packages/schemas/rollup/rollup.mjs | 5 - packages/schemas/src/index.ts | 90 -------- .../schemas/src/schemas/credential/index.ts | 4 - .../schemas/src/schemas/credential/orm.ts | 29 --- .../schemas/src/schemas/credential/schema.ts | 51 ----- .../schemas/src/schemas/credential/static.ts | 24 --- .../schemas/src/schemas/credential/types.ts | 40 ---- .../credentialRequestMetadata/index.ts | 4 - .../schemas/credentialRequestMetadata/orm.ts | 9 - .../credentialRequestMetadata/schema.ts | 31 --- .../credentialRequestMetadata/static.ts | 33 --- .../credentialRequestMetadata/types.ts | 45 ---- packages/schemas/src/schemas/did/index.ts | 3 - packages/schemas/src/schemas/did/schema.ts | 35 --- packages/schemas/src/schemas/did/static.ts | 204 ------------------ packages/schemas/src/schemas/did/types.ts | 46 ---- packages/schemas/src/schemas/didpair/index.ts | 3 - .../schemas/src/schemas/didpair/schema.ts | 24 --- .../schemas/src/schemas/didpair/static.ts | 81 ------- packages/schemas/src/schemas/didpair/types.ts | 25 --- .../schemas/src/schemas/linksecret/index.ts | 4 - .../schemas/src/schemas/linksecret/orm.ts | 10 - .../schemas/src/schemas/linksecret/schema.ts | 19 -- .../schemas/src/schemas/linksecret/static.ts | 31 --- .../schemas/src/schemas/linksecret/types.ts | 41 ---- .../schemas/src/schemas/mediator/index.ts | 4 - packages/schemas/src/schemas/mediator/orm.ts | 15 -- .../schemas/src/schemas/mediator/schema.ts | 30 --- .../schemas/src/schemas/mediator/static.ts | 24 --- .../schemas/src/schemas/mediator/types.ts | 32 --- packages/schemas/src/schemas/message/index.ts | 4 - packages/schemas/src/schemas/message/orm.ts | 10 - .../schemas/src/schemas/message/schema.ts | 88 -------- .../schemas/src/schemas/message/static.ts | 192 ----------------- packages/schemas/src/schemas/message/types.ts | 81 ------- .../schemas/src/schemas/privatekey/index.ts | 4 - .../schemas/src/schemas/privatekey/orm.ts | 94 -------- .../schemas/src/schemas/privatekey/schema.ts | 41 ---- .../schemas/src/schemas/privatekey/static.ts | 68 ------ .../schemas/src/schemas/privatekey/types.ts | 49 ----- packages/schemas/src/types.ts | 58 ----- packages/schemas/tsconfig.json | 10 - packages/schemas/vitest.config.ts | 28 --- 49 files changed, 2037 deletions(-) delete mode 100644 packages/schemas/.gitignore delete mode 100644 packages/schemas/CHANGELOG.md delete mode 100644 packages/schemas/LICENSE delete mode 100644 packages/schemas/README.md delete mode 100644 packages/schemas/coverage/coverage-summary.json delete mode 100644 packages/schemas/package.json delete mode 100644 packages/schemas/rollup/rollup.mjs delete mode 100644 packages/schemas/src/index.ts delete mode 100644 packages/schemas/src/schemas/credential/index.ts delete mode 100644 packages/schemas/src/schemas/credential/orm.ts delete mode 100644 packages/schemas/src/schemas/credential/schema.ts delete mode 100644 packages/schemas/src/schemas/credential/static.ts delete mode 100644 packages/schemas/src/schemas/credential/types.ts delete mode 100644 packages/schemas/src/schemas/credentialRequestMetadata/index.ts delete mode 100644 packages/schemas/src/schemas/credentialRequestMetadata/orm.ts delete mode 100644 packages/schemas/src/schemas/credentialRequestMetadata/schema.ts delete mode 100644 packages/schemas/src/schemas/credentialRequestMetadata/static.ts delete mode 100644 packages/schemas/src/schemas/credentialRequestMetadata/types.ts delete mode 100644 packages/schemas/src/schemas/did/index.ts delete mode 100644 packages/schemas/src/schemas/did/schema.ts delete mode 100644 packages/schemas/src/schemas/did/static.ts delete mode 100644 packages/schemas/src/schemas/did/types.ts delete mode 100644 packages/schemas/src/schemas/didpair/index.ts delete mode 100644 packages/schemas/src/schemas/didpair/schema.ts delete mode 100644 packages/schemas/src/schemas/didpair/static.ts delete mode 100644 packages/schemas/src/schemas/didpair/types.ts delete mode 100644 packages/schemas/src/schemas/linksecret/index.ts delete mode 100644 packages/schemas/src/schemas/linksecret/orm.ts delete mode 100644 packages/schemas/src/schemas/linksecret/schema.ts delete mode 100644 packages/schemas/src/schemas/linksecret/static.ts delete mode 100644 packages/schemas/src/schemas/linksecret/types.ts delete mode 100644 packages/schemas/src/schemas/mediator/index.ts delete mode 100644 packages/schemas/src/schemas/mediator/orm.ts delete mode 100644 packages/schemas/src/schemas/mediator/schema.ts delete mode 100644 packages/schemas/src/schemas/mediator/static.ts delete mode 100644 packages/schemas/src/schemas/mediator/types.ts delete mode 100644 packages/schemas/src/schemas/message/index.ts delete mode 100644 packages/schemas/src/schemas/message/orm.ts delete mode 100644 packages/schemas/src/schemas/message/schema.ts delete mode 100644 packages/schemas/src/schemas/message/static.ts delete mode 100644 packages/schemas/src/schemas/message/types.ts delete mode 100644 packages/schemas/src/schemas/privatekey/index.ts delete mode 100644 packages/schemas/src/schemas/privatekey/orm.ts delete mode 100644 packages/schemas/src/schemas/privatekey/schema.ts delete mode 100644 packages/schemas/src/schemas/privatekey/static.ts delete mode 100644 packages/schemas/src/schemas/privatekey/types.ts delete mode 100644 packages/schemas/src/types.ts delete mode 100644 packages/schemas/tsconfig.json delete mode 100644 packages/schemas/vitest.config.ts diff --git a/packages/schemas/.gitignore b/packages/schemas/.gitignore deleted file mode 100644 index 37d9a7e8..00000000 --- a/packages/schemas/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -node_modules -junit.xml -lcov.info -build -.npmrc - -coverage/**/*.html -coverage/**/*.css -coverage/**/*.js -coverage/**/*.png \ No newline at end of file diff --git a/packages/schemas/CHANGELOG.md b/packages/schemas/CHANGELOG.md deleted file mode 100644 index a462cd7d..00000000 --- a/packages/schemas/CHANGELOG.md +++ /dev/null @@ -1,27 +0,0 @@ -## @pluto-encrypted/schemas [1.3.5](https://github.com/atala-community-projects/pluto-encrypted/compare/@pluto-encrypted/schemas@1.3.4...@pluto-encrypted/schemas@1.3.5) (2024-02-10) - - -### Bug Fixes - -* workaround to not store dids twice ([aa3b069](https://github.com/atala-community-projects/pluto-encrypted/commit/aa3b0696aa5c438750d9add0e04f599d9260fcc6)) - -## @pluto-encrypted/schemas [1.3.4](https://github.com/atala-community-projects/pluto-encrypted/compare/@pluto-encrypted/schemas@1.3.3...@pluto-encrypted/schemas@1.3.4) (2024-02-10) - - -### Bug Fixes - -* database and schemas fix for last key index for prism did keys. ([b88fa6e](https://github.com/atala-community-projects/pluto-encrypted/commit/b88fa6ed71a6f44da48129bf5bd7a5222b8d000f)) - -## @pluto-encrypted/schemas [1.3.3](https://github.com/atala-community-projects/pluto-encrypted/compare/@pluto-encrypted/schemas@1.3.2...@pluto-encrypted/schemas@1.3.3) (2024-02-10) - - -### Bug Fixes - -* workaround to fix last keypath issue in SDKs. ([f4d1f94](https://github.com/atala-community-projects/pluto-encrypted/commit/f4d1f9430cfd0ed6e90c1c79783f4c91c6101752)) - -## @pluto-encrypted/schemas [1.3.2](https://github.com/atala-community-projects/pluto-encrypted/compare/@pluto-encrypted/schemas@1.3.1...@pluto-encrypted/schemas@1.3.2) (2024-02-08) - - -### Bug Fixes - -* Upgrade SDK to latest version which contains a fix to deserialize the JWT Credential from JTI String. ([e9aa761](https://github.com/atala-community-projects/pluto-encrypted/commit/e9aa7610f263fbe7aecf9786e42a1840c2b9a18d)) diff --git a/packages/schemas/LICENSE b/packages/schemas/LICENSE deleted file mode 100644 index 216af719..00000000 --- a/packages/schemas/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright © 2021-2023 Input Output Global - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/packages/schemas/README.md b/packages/schemas/README.md deleted file mode 100644 index c8439483..00000000 --- a/packages/schemas/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# Pluto-encrypted -Pluto Encrypted default models and schemas. \ No newline at end of file diff --git a/packages/schemas/coverage/coverage-summary.json b/packages/schemas/coverage/coverage-summary.json deleted file mode 100644 index 425132b6..00000000 --- a/packages/schemas/coverage/coverage-summary.json +++ /dev/null @@ -1,25 +0,0 @@ -{"total": {"lines":{"total":176,"covered":0,"skipped":0,"pct":0},"statements":{"total":187,"covered":0,"skipped":0,"pct":0},"functions":{"total":61,"covered":0,"skipped":0,"pct":0},"branches":{"total":60,"covered":0,"skipped":0,"pct":0},"branchesTrue":{"total":0,"covered":0,"skipped":0,"pct":100}} -,"/Users/ribo/Projects/personal/pluto-encrypted/packages/schemas/src/index.ts": {"lines":{"total":1,"covered":0,"skipped":0,"pct":0},"functions":{"total":1,"covered":0,"skipped":0,"pct":0},"statements":{"total":1,"covered":0,"skipped":0,"pct":0},"branches":{"total":1,"covered":0,"skipped":0,"pct":0}} -,"/Users/ribo/Projects/personal/pluto-encrypted/packages/schemas/src/schemas/credential/orm.ts": {"lines":{"total":10,"covered":0,"skipped":0,"pct":0},"functions":{"total":1,"covered":0,"skipped":0,"pct":0},"statements":{"total":10,"covered":0,"skipped":0,"pct":0},"branches":{"total":4,"covered":0,"skipped":0,"pct":0}} -,"/Users/ribo/Projects/personal/pluto-encrypted/packages/schemas/src/schemas/credential/schema.ts": {"lines":{"total":1,"covered":0,"skipped":0,"pct":0},"functions":{"total":0,"covered":0,"skipped":0,"pct":100},"statements":{"total":1,"covered":0,"skipped":0,"pct":0},"branches":{"total":0,"covered":0,"skipped":0,"pct":100}} -,"/Users/ribo/Projects/personal/pluto-encrypted/packages/schemas/src/schemas/credential/static.ts": {"lines":{"total":9,"covered":0,"skipped":0,"pct":0},"functions":{"total":3,"covered":0,"skipped":0,"pct":0},"statements":{"total":10,"covered":0,"skipped":0,"pct":0},"branches":{"total":5,"covered":0,"skipped":0,"pct":0}} -,"/Users/ribo/Projects/personal/pluto-encrypted/packages/schemas/src/schemas/credentialRequestMetadata/orm.ts": {"lines":{"total":2,"covered":0,"skipped":0,"pct":0},"functions":{"total":1,"covered":0,"skipped":0,"pct":0},"statements":{"total":2,"covered":0,"skipped":0,"pct":0},"branches":{"total":0,"covered":0,"skipped":0,"pct":100}} -,"/Users/ribo/Projects/personal/pluto-encrypted/packages/schemas/src/schemas/credentialRequestMetadata/schema.ts": {"lines":{"total":1,"covered":0,"skipped":0,"pct":0},"functions":{"total":0,"covered":0,"skipped":0,"pct":100},"statements":{"total":1,"covered":0,"skipped":0,"pct":0},"branches":{"total":0,"covered":0,"skipped":0,"pct":100}} -,"/Users/ribo/Projects/personal/pluto-encrypted/packages/schemas/src/schemas/credentialRequestMetadata/static.ts": {"lines":{"total":6,"covered":0,"skipped":0,"pct":0},"functions":{"total":2,"covered":0,"skipped":0,"pct":0},"statements":{"total":6,"covered":0,"skipped":0,"pct":0},"branches":{"total":2,"covered":0,"skipped":0,"pct":0}} -,"/Users/ribo/Projects/personal/pluto-encrypted/packages/schemas/src/schemas/did/schema.ts": {"lines":{"total":1,"covered":0,"skipped":0,"pct":0},"functions":{"total":0,"covered":0,"skipped":0,"pct":100},"statements":{"total":1,"covered":0,"skipped":0,"pct":0},"branches":{"total":0,"covered":0,"skipped":0,"pct":100}} -,"/Users/ribo/Projects/personal/pluto-encrypted/packages/schemas/src/schemas/did/static.ts": {"lines":{"total":48,"covered":0,"skipped":0,"pct":0},"functions":{"total":11,"covered":0,"skipped":0,"pct":0},"statements":{"total":49,"covered":0,"skipped":0,"pct":0},"branches":{"total":14,"covered":0,"skipped":0,"pct":0}} -,"/Users/ribo/Projects/personal/pluto-encrypted/packages/schemas/src/schemas/didpair/schema.ts": {"lines":{"total":1,"covered":0,"skipped":0,"pct":0},"functions":{"total":0,"covered":0,"skipped":0,"pct":100},"statements":{"total":1,"covered":0,"skipped":0,"pct":0},"branches":{"total":0,"covered":0,"skipped":0,"pct":100}} -,"/Users/ribo/Projects/personal/pluto-encrypted/packages/schemas/src/schemas/didpair/static.ts": {"lines":{"total":9,"covered":0,"skipped":0,"pct":0},"functions":{"total":5,"covered":0,"skipped":0,"pct":0},"statements":{"total":9,"covered":0,"skipped":0,"pct":0},"branches":{"total":4,"covered":0,"skipped":0,"pct":0}} -,"/Users/ribo/Projects/personal/pluto-encrypted/packages/schemas/src/schemas/linksecret/orm.ts": {"lines":{"total":2,"covered":0,"skipped":0,"pct":0},"functions":{"total":1,"covered":0,"skipped":0,"pct":0},"statements":{"total":2,"covered":0,"skipped":0,"pct":0},"branches":{"total":0,"covered":0,"skipped":0,"pct":100}} -,"/Users/ribo/Projects/personal/pluto-encrypted/packages/schemas/src/schemas/linksecret/schema.ts": {"lines":{"total":1,"covered":0,"skipped":0,"pct":0},"functions":{"total":0,"covered":0,"skipped":0,"pct":100},"statements":{"total":1,"covered":0,"skipped":0,"pct":0},"branches":{"total":0,"covered":0,"skipped":0,"pct":100}} -,"/Users/ribo/Projects/personal/pluto-encrypted/packages/schemas/src/schemas/linksecret/static.ts": {"lines":{"total":7,"covered":0,"skipped":0,"pct":0},"functions":{"total":2,"covered":0,"skipped":0,"pct":0},"statements":{"total":7,"covered":0,"skipped":0,"pct":0},"branches":{"total":4,"covered":0,"skipped":0,"pct":0}} -,"/Users/ribo/Projects/personal/pluto-encrypted/packages/schemas/src/schemas/mediator/orm.ts": {"lines":{"total":3,"covered":0,"skipped":0,"pct":0},"functions":{"total":1,"covered":0,"skipped":0,"pct":0},"statements":{"total":3,"covered":0,"skipped":0,"pct":0},"branches":{"total":0,"covered":0,"skipped":0,"pct":100}} -,"/Users/ribo/Projects/personal/pluto-encrypted/packages/schemas/src/schemas/mediator/schema.ts": {"lines":{"total":1,"covered":0,"skipped":0,"pct":0},"functions":{"total":0,"covered":0,"skipped":0,"pct":100},"statements":{"total":1,"covered":0,"skipped":0,"pct":0},"branches":{"total":0,"covered":0,"skipped":0,"pct":100}} -,"/Users/ribo/Projects/personal/pluto-encrypted/packages/schemas/src/schemas/mediator/static.ts": {"lines":{"total":4,"covered":0,"skipped":0,"pct":0},"functions":{"total":3,"covered":0,"skipped":0,"pct":0},"statements":{"total":5,"covered":0,"skipped":0,"pct":0},"branches":{"total":0,"covered":0,"skipped":0,"pct":100}} -,"/Users/ribo/Projects/personal/pluto-encrypted/packages/schemas/src/schemas/message/orm.ts": {"lines":{"total":2,"covered":0,"skipped":0,"pct":0},"functions":{"total":1,"covered":0,"skipped":0,"pct":0},"statements":{"total":2,"covered":0,"skipped":0,"pct":0},"branches":{"total":0,"covered":0,"skipped":0,"pct":100}} -,"/Users/ribo/Projects/personal/pluto-encrypted/packages/schemas/src/schemas/message/schema.ts": {"lines":{"total":1,"covered":0,"skipped":0,"pct":0},"functions":{"total":0,"covered":0,"skipped":0,"pct":100},"statements":{"total":1,"covered":0,"skipped":0,"pct":0},"branches":{"total":0,"covered":0,"skipped":0,"pct":100}} -,"/Users/ribo/Projects/personal/pluto-encrypted/packages/schemas/src/schemas/message/static.ts": {"lines":{"total":30,"covered":0,"skipped":0,"pct":0},"functions":{"total":19,"covered":0,"skipped":0,"pct":0},"statements":{"total":38,"covered":0,"skipped":0,"pct":0},"branches":{"total":6,"covered":0,"skipped":0,"pct":0}} -,"/Users/ribo/Projects/personal/pluto-encrypted/packages/schemas/src/schemas/privatekey/orm.ts": {"lines":{"total":27,"covered":0,"skipped":0,"pct":0},"functions":{"total":5,"covered":0,"skipped":0,"pct":0},"statements":{"total":27,"covered":0,"skipped":0,"pct":0},"branches":{"total":18,"covered":0,"skipped":0,"pct":0}} -,"/Users/ribo/Projects/personal/pluto-encrypted/packages/schemas/src/schemas/privatekey/schema.ts": {"lines":{"total":1,"covered":0,"skipped":0,"pct":0},"functions":{"total":0,"covered":0,"skipped":0,"pct":100},"statements":{"total":1,"covered":0,"skipped":0,"pct":0},"branches":{"total":0,"covered":0,"skipped":0,"pct":100}} -,"/Users/ribo/Projects/personal/pluto-encrypted/packages/schemas/src/schemas/privatekey/static.ts": {"lines":{"total":8,"covered":0,"skipped":0,"pct":0},"functions":{"total":5,"covered":0,"skipped":0,"pct":0},"statements":{"total":8,"covered":0,"skipped":0,"pct":0},"branches":{"total":2,"covered":0,"skipped":0,"pct":0}} -} diff --git a/packages/schemas/package.json b/packages/schemas/package.json deleted file mode 100644 index d98b5bcf..00000000 --- a/packages/schemas/package.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "name": "@pluto-encrypted/schemas", - "version": "1.3.5", - "description": "Provides the default schemas used in @pluto-encrypted/database", - "main": "./build/cjs/index.cjs", - "module": "./build/esm/index.mjs", - "types": "./build/index.d.ts", - "exports": { - ".": { - "import": "./build/esm/index.mjs", - "require": "./build/cjs/index.cjs" - } - }, - "homepage": "https://atala-community-projects.github.io/pluto-encrypted", - "publishConfig": { - "access": "public" - }, - "scripts": { - "prepublishOnly": "npm run build", - "clean-packages": "rm -rf node_modules && rm -rf build", - "build": "rm -rf build && npx rollup -c rollup/rollup.mjs" - }, - "repository": { - "type": "git", - "url": "https://github.com/atala-community-projects/pluto-encrypted.git" - }, - "author": "elribonazo@gmail.com", - "license": "Apache-2.0", - "peerDependencies": { - "@atala/prism-wallet-sdk": "^4.0.2" - }, - "devDependencies": { - "@pluto-encrypted/encryption": "1.11.0", - "@pluto-encrypted/shared": "1.11.3", - "@vitest/coverage-v8": "^1.0.4" - }, - "dependencies": { - "@atala/prism-wallet-sdk": "^4.0.2", - "@pluto-encrypted/encryption": "1.11.0", - "@pluto-encrypted/shared": "1.11.3", - "rxdb": "^14.17.0", - "rxjs": "7.8.1", - "uuid": "^9.0.1" - }, - "files": [ - "build/*" - ], - "gitHead": "6aa4ce8bbb9938fc4c4e790efffa5b902631362c" -} diff --git a/packages/schemas/rollup/rollup.mjs b/packages/schemas/rollup/rollup.mjs deleted file mode 100644 index 1278dac6..00000000 --- a/packages/schemas/rollup/rollup.mjs +++ /dev/null @@ -1,5 +0,0 @@ -import nodePolyfills from "rollup-plugin-polyfill-node"; - -import CreateConfig from "../../../rollup/index.mjs"; - -export default CreateConfig(undefined, []); diff --git a/packages/schemas/src/index.ts b/packages/schemas/src/index.ts deleted file mode 100644 index 61f53fdb..00000000 --- a/packages/schemas/src/index.ts +++ /dev/null @@ -1,90 +0,0 @@ -/** - * @packageDocumentation - * @module database - */ -import { RxCollection, RxCollectionCreator } from 'rxdb' -import { CredentialSchema, CredentialMethods, CredentialStaticMethods, CredentialCollection } from './schemas/credential' -import { CredentialRequestMetadataSchema, CredentialRequestMetadataMethods, CredentialRequestMetadataStaticMethods, CredentialRequestMetadataCollection } from './schemas/credentialRequestMetadata' -import { DIDCollection, DIDSchema, DIDStaticMethods } from './schemas/did' -import { DIDPairCollection, DIDPairSchema, DIDPairStaticMethods } from './schemas/didpair' -import { LinkSecretSchema, LinkSecretMethods, LinkSecretStaticMethods, LinkSecretColletion } from './schemas/linksecret' -import { MediatorSchema, MediatorMethods, MediatorStaticMethods, MediatorCollection } from './schemas/mediator' -import { MessageSchema, MessageMethods, MessageStaticMethods, MessageColletion } from './schemas/message' -import { PrivateKeySchema, PrivateKeyMethods, PrivateKeyStaticMethods, PrivateKeyColletion } from './schemas/privatekey' -import { PlutoCollectionsCreator } from './types' -import { DatabaseBase } from '@pluto-encrypted/shared' -import { UnionToIntersection } from '@pluto-encrypted/shared' -import { ExtractStaticMethods } from '@pluto-encrypted/shared' - -type Collections = { - messages: MessageColletion; - dids: DIDCollection; - didpairs: DIDPairCollection; - mediators: MediatorCollection; - privatekeys: PrivateKeyColletion; - credentials: CredentialCollection; - credentialrequestmetadatas: CredentialRequestMetadataCollection; - linksecrets: LinkSecretColletion; -} & { - [name: string]: RxCollection -} - -export type PlutoDBontext = DatabaseBase & ExtractStaticMethods> - -export function getDefaultCollections(extendedCollections: { [name: string]: RxCollectionCreator } = {}): { [name: string]: RxCollectionCreator } & PlutoCollectionsCreator { - return { - messages: { - schema: MessageSchema, - methods: MessageMethods, - statics: MessageStaticMethods - }, - dids: { - schema: DIDSchema, - statics: DIDStaticMethods - }, - didpairs: { - schema: DIDPairSchema, - statics: DIDPairStaticMethods - }, - mediators: { - schema: MediatorSchema, - methods: MediatorMethods, - statics: MediatorStaticMethods - }, - privatekeys: { - schema: PrivateKeySchema, - methods: PrivateKeyMethods, - statics: PrivateKeyStaticMethods - }, - credentials: { - schema: CredentialSchema, - methods: CredentialMethods, - statics: CredentialStaticMethods - }, - credentialrequestmetadatas: { - schema: CredentialRequestMetadataSchema, - methods: CredentialRequestMetadataMethods, - statics: CredentialRequestMetadataStaticMethods - }, - linksecrets: { - schema: LinkSecretSchema, - methods: LinkSecretMethods, - statics: LinkSecretStaticMethods - }, - ...extendedCollections, - } -} - -export * from './schemas/credential' -export * from './schemas/credentialRequestMetadata' -export * from './schemas/did' -export * from './schemas/didpair' -export * from './schemas/linksecret' -export * from './schemas/mediator' -export * from './schemas/message' -export * from './schemas/privatekey' -export * from './types' - -export type { Domain as WALLET_SDK_DOMAIN } from '@atala/prism-wallet-sdk' \ No newline at end of file diff --git a/packages/schemas/src/schemas/credential/index.ts b/packages/schemas/src/schemas/credential/index.ts deleted file mode 100644 index c6864c03..00000000 --- a/packages/schemas/src/schemas/credential/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './orm'; -export * from './schema'; -export * from './static'; -export * from './types'; \ No newline at end of file diff --git a/packages/schemas/src/schemas/credential/orm.ts b/packages/schemas/src/schemas/credential/orm.ts deleted file mode 100644 index 386cd826..00000000 --- a/packages/schemas/src/schemas/credential/orm.ts +++ /dev/null @@ -1,29 +0,0 @@ - -import SDK from '@atala/prism-wallet-sdk' -import { CredentialMethodTypes, CredentialSchemaType } from './types'; - -export const CredentialMethods: CredentialMethodTypes = { - toDomainCredential: function toDomainCredential(this: CredentialSchemaType) { - if (this.recoveryId === SDK.JWTVerifiableCredentialRecoveryId) { - const jwtString = Buffer.from(this.credentialData).toString() - const jwtObj = JSON.parse(jwtString) - const fromJWT = SDK.JWTCredential.fromJWT(jwtObj, jwtObj.jti) - return fromJWT - } else if (this.recoveryId === SDK.AnonCredsRecoveryId) { - const credentialData = Buffer.from(this.credentialData).toString() - const credentialJson = JSON.parse(credentialData) - return new SDK.AnonCredsCredential({ - schema_id: credentialJson[SDK.AnonCredsCredentialProperties.schemaId], - cred_def_id: credentialJson[SDK.AnonCredsCredentialProperties.credentialDefinitionId], - values: credentialJson[SDK.AnonCredsCredentialProperties.values], - signature: credentialJson[SDK.AnonCredsCredentialProperties.signature], - signature_correctness_proof: - credentialJson[ - SDK.AnonCredsCredentialProperties.signatureCorrectnessProof - ] - }) - } else { - throw new Error('Unsupported key type from db storage') - } - } -} \ No newline at end of file diff --git a/packages/schemas/src/schemas/credential/schema.ts b/packages/schemas/src/schemas/credential/schema.ts deleted file mode 100644 index 6e38cc41..00000000 --- a/packages/schemas/src/schemas/credential/schema.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { Schema } from "../../types"; -import { CredentialSchemaType } from "./types"; - - - -export const CredentialSchema: Schema = { - version: 0, - primaryKey: 'id', - type: 'object', - properties: { - id: { - type: 'string', - maxLength: 60 - }, - recoveryId: { - type: 'string' - }, - credentialData: { - type: 'string' - }, - issuer: { - type: 'string' - }, - subject: { - type: 'string' - }, - credentialCreated: { - type: 'string' - }, - credentialUpdated: { - type: 'string' - }, - credentialSchema: { - type: 'string' - }, - validUntil: { - type: 'string' - }, - revoked: { - type: 'boolean' - }, - availableClaims: { - type: 'array', - items: { - type: 'string' - } - } - }, - encrypted: ['credentialData'], - required: ['id', 'recoveryId', 'credentialData'] -} \ No newline at end of file diff --git a/packages/schemas/src/schemas/credential/static.ts b/packages/schemas/src/schemas/credential/static.ts deleted file mode 100644 index 379cf76d..00000000 --- a/packages/schemas/src/schemas/credential/static.ts +++ /dev/null @@ -1,24 +0,0 @@ -import SDK from '@atala/prism-wallet-sdk' -import { v4 as uuidv4 } from 'uuid' - -import { CredentialStaticMethodTypes } from './types' - -export const CredentialStaticMethods: CredentialStaticMethodTypes = { - async getAllCredentials(): Promise { - const credentials = await this.db.collections.credentials.find().exec() - return credentials.map( - (verifiableCredential) => verifiableCredential.toDomainCredential() - ) - }, - async storeCredential(credential: SDK.Domain.Credential): Promise { - if (!credential.isStorable || !credential.isStorable()) { - throw new Error('Credential is not storable') - } - const storable = credential.toStorable() - /* istanbul ignore else -- @preserve */ - if (!storable.id) storable.id = uuidv4() - - await this.db.collections.credentials.insert(storable) - } - -} \ No newline at end of file diff --git a/packages/schemas/src/schemas/credential/types.ts b/packages/schemas/src/schemas/credential/types.ts deleted file mode 100644 index ebf20ce3..00000000 --- a/packages/schemas/src/schemas/credential/types.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { KeyFunctionMap, RxCollection, RxDocument } from "rxdb" -import SDK from '@atala/prism-wallet-sdk' -import { StaticRxCollectionContext } from "../../types" -import { PlutoDBontext } from "../.." - -export interface CredentialSubjectType { - type: string - name: string - value: string -} - -export interface CredentialSchemaType { - id: string - recoveryId: string - credentialData: string - issuer?: string - subject?: string - credentialCreated?: string - credentialUpdated?: string - credentialSchema?: string - validUntil?: string - revoked?: boolean - availableClaims?: string[] -} - -export type CredentialDocument = RxDocument -export interface CredentialMethodTypes extends KeyFunctionMap { - toDomainCredential: (this: CredentialSchemaType) => SDK.Domain.Credential -} - -export interface CredentialStaticMethodTypes extends KeyFunctionMap { - getAllCredentials(this: PlutoDBontext): Promise - storeCredential(this: PlutoDBontext, credential: SDK.Domain.Credential): Promise -} - -export type CredentialCollection = RxCollection< - CredentialSchemaType, - CredentialMethodTypes, - CredentialStaticMethodTypes -> diff --git a/packages/schemas/src/schemas/credentialRequestMetadata/index.ts b/packages/schemas/src/schemas/credentialRequestMetadata/index.ts deleted file mode 100644 index c6864c03..00000000 --- a/packages/schemas/src/schemas/credentialRequestMetadata/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './orm'; -export * from './schema'; -export * from './static'; -export * from './types'; \ No newline at end of file diff --git a/packages/schemas/src/schemas/credentialRequestMetadata/orm.ts b/packages/schemas/src/schemas/credentialRequestMetadata/orm.ts deleted file mode 100644 index f5a8c21d..00000000 --- a/packages/schemas/src/schemas/credentialRequestMetadata/orm.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { CredentialRequestMetadataMethodTypes, CredentialRequestMetadataSchemaType } from "./types" - -export const CredentialRequestMetadataMethods: CredentialRequestMetadataMethodTypes = { - toDomainCredentialRequestMetadata: function toDomainCredentialRequestMetadata( - this: CredentialRequestMetadataSchemaType - ) { - return this - } -} \ No newline at end of file diff --git a/packages/schemas/src/schemas/credentialRequestMetadata/schema.ts b/packages/schemas/src/schemas/credentialRequestMetadata/schema.ts deleted file mode 100644 index a42cea58..00000000 --- a/packages/schemas/src/schemas/credentialRequestMetadata/schema.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { Schema } from "../../types"; -import { CredentialRequestMetadataSchemaType } from "./types"; - -export const CredentialRequestMetadataSchema: Schema = -{ - version: 0, - primaryKey: 'id', - type: 'object', - properties: { - id: { - type: 'string', - maxLength: 60 - }, - link_secret_blinding_data: { - type: 'object', - properties: { - v_prime: { - type: 'string' - } - } - }, - link_secret_name: { - type: 'string' - }, - nonce: { - type: 'string' - } - }, - encrypted: ['link_secret_blinding_data', 'nonce'], - required: ['id', 'link_secret_blinding_data', 'link_secret_name', 'nonce'] -} \ No newline at end of file diff --git a/packages/schemas/src/schemas/credentialRequestMetadata/static.ts b/packages/schemas/src/schemas/credentialRequestMetadata/static.ts deleted file mode 100644 index 905cebec..00000000 --- a/packages/schemas/src/schemas/credentialRequestMetadata/static.ts +++ /dev/null @@ -1,33 +0,0 @@ -import SDK from '@atala/prism-wallet-sdk' -import { v4 as uuidv4 } from 'uuid' -import { CredentialRequestMetadataStaticMethodTypes } from './types' - -export const CredentialRequestMetadataStaticMethods: CredentialRequestMetadataStaticMethodTypes = -{ - async storeCredentialMetadata( - metadata: SDK.Domain.Anoncreds.CredentialRequestMeta, - linkSecret: string - ): Promise { - await this.db.collections.credentialrequestmetadatas.insert({ - ...metadata, - id: uuidv4(), - link_secret_name: linkSecret - }) - }, - async fetchCredentialMetadata( - linkSecretName: string - ): Promise { - const credentialRequestMetadata = await this.db.collections.credentialrequestmetadatas.findOne({ - selector: { - link_secret_name: { - $eq: linkSecretName - } - } - }).exec() - - if (credentialRequestMetadata) { - return credentialRequestMetadata.toDomainCredentialRequestMetadata() - } - return null - } -} diff --git a/packages/schemas/src/schemas/credentialRequestMetadata/types.ts b/packages/schemas/src/schemas/credentialRequestMetadata/types.ts deleted file mode 100644 index 94223df1..00000000 --- a/packages/schemas/src/schemas/credentialRequestMetadata/types.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { KeyFunctionMap, RxCollection, RxDocument } from "rxdb" -import SDK from '@atala/prism-wallet-sdk' -import { StaticRxCollectionContext } from "../../types" -import { PlutoDBontext } from "../.." - - - - -export type CredentialRequestMetadataCollection = RxCollection< - CredentialRequestMetadataSchemaType, - CredentialRequestMetadataMethodTypes, - CredentialRequestMetadataStaticMethodTypes -> - - - -export interface CredentialRequestMetadataSchemaType { - id: string - link_secret_blinding_data: { - v_prime: string - } - link_secret_name: string - nonce: string -} - -export type CredentialRequestMetadataDocument = - RxDocument - -export interface CredentialRequestMetadataMethodTypes extends KeyFunctionMap { - toDomainCredentialRequestMetadata: ( - this: CredentialRequestMetadataSchemaType - ) => SDK.Domain.Anoncreds.CredentialRequestMeta -} - -export interface CredentialRequestMetadataStaticMethodTypes extends KeyFunctionMap { - fetchCredentialMetadata( - this: PlutoDBontext, - linkSecretName: string - ): Promise - storeCredentialMetadata( - this: PlutoDBontext, - metadata: SDK.Domain.Anoncreds.CredentialRequestMeta, - linkSecret: string - ): Promise -} \ No newline at end of file diff --git a/packages/schemas/src/schemas/did/index.ts b/packages/schemas/src/schemas/did/index.ts deleted file mode 100644 index 70bef2c2..00000000 --- a/packages/schemas/src/schemas/did/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './schema'; -export * from './static'; -export * from './types'; \ No newline at end of file diff --git a/packages/schemas/src/schemas/did/schema.ts b/packages/schemas/src/schemas/did/schema.ts deleted file mode 100644 index 3d47dbf8..00000000 --- a/packages/schemas/src/schemas/did/schema.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { Schema } from "../../types"; -import { DIDSchemaType } from "./types"; - - - - -export const DIDSchema: Schema = { - version: 0, - primaryKey: 'did', - type: 'object', - properties: { - method: { - type: 'string', - maxLength: 60 - }, - methodId: { - type: 'string', - maxLength: 60 - }, - schema: { - type: 'string', - maxLength: 60 - }, - alias: { - type: 'string', - maxLength: 60 - }, - did: { - type: 'string', - maxLength: 60 - } - }, - encrypted: [], - required: ['method', 'methodId', 'did', 'schema'] -} \ No newline at end of file diff --git a/packages/schemas/src/schemas/did/static.ts b/packages/schemas/src/schemas/did/static.ts deleted file mode 100644 index 14229abf..00000000 --- a/packages/schemas/src/schemas/did/static.ts +++ /dev/null @@ -1,204 +0,0 @@ -import SDK from '@atala/prism-wallet-sdk' -import { v4 as uuidv4 } from 'uuid' - -import { KeySpec } from '../privatekey' -import { DIDStaticMethodTypes } from './types' - - - -export const DIDStaticMethods: DIDStaticMethodTypes = { - async storePrismDID(did: SDK.Domain.DID, keyPathIndex: number, privateKey: SDK.Domain.PrivateKey, _privateKeyMetaId?: string | null | undefined, alias?: string | undefined): Promise { - const found = await this.db.collections.dids.findOne({ - selector: { - did: { - $eq: did.toString(), - } - } - }).exec(); - if (!found) { - await this.db.collections.dids.insert({ - did: did.toString(), - method: did.method, - methodId: did.methodId, - schema: did.schema, - alias - }) - await this.storePrivateKeys( - privateKey, - did, - keyPathIndex, - ) - } - }, - async getAllPrismDIDs(): Promise { - const dids = await this.db.collections.dids.find({ - selector: { - method: { - $eq: 'prism' - } - } - }).exec() - - const prismDIDInfo: SDK.Domain.PrismDIDInfo[] = [] - - for (const did of dids) { - const didPrivateKeys = await this.getDIDPrivateKeysByDID!( - SDK.Domain.DID.fromString(did.did) - ) - - for (const privateKey of didPrivateKeys) { - const indexProp = privateKey.getProperty(SDK.Domain.KeyProperties.index)! - - prismDIDInfo.push( - new SDK.Domain.PrismDIDInfo( - SDK.Domain.DID.fromString(did.did), - parseInt(indexProp), - did.alias - ) - ) - } - } - - return prismDIDInfo - }, - async getDIDInfoByDID(did: SDK.Domain.DID): Promise { - const didDB = await this.db.collections.dids.findOne({ - selector: { - did: did.toString() - } - }).exec() - - if (didDB) { - const privateKeys = await this.getDIDPrivateKeysByDID!( - SDK.Domain.DID.fromString(didDB.did) - ) - /* istanbul ignore if */ - if (privateKeys.length === 0) { - throw new Error( - 'Imposible to recover PrismDIDInfo without its privateKey data.' - ) - } - const indexProp = privateKeys - .at(0)! - .getProperty(SDK.Domain.KeyProperties.index) - const index = indexProp ? parseInt(indexProp) : undefined - return new SDK.Domain.PrismDIDInfo( - SDK.Domain.DID.fromString(didDB.did), - index, - didDB.alias - ) - } - - return null - }, - async getDIDInfoByAlias(alias: string): Promise { - const dids = await this.db.collections.dids.find({ - selector: { - alias: { - $eq: alias - } - } - }).exec() - const prismDIDInfo: SDK.Domain.PrismDIDInfo[] = [] - for (const did of dids) { - const didPrivateKeys = await this.getDIDPrivateKeysByDID!( - SDK.Domain.DID.fromString(did.did) - ) - for (const privateKey of didPrivateKeys) { - const indexProp = privateKey.getProperty(SDK.Domain.KeyProperties.index)! - prismDIDInfo.push( - new SDK.Domain.PrismDIDInfo( - SDK.Domain.DID.fromString(did.did), - parseInt(indexProp), - did.alias - ) - ) - } - } - return prismDIDInfo - }, - async getPrismDIDKeyPathIndex(did: SDK.Domain.DID): Promise { - const [key] = await this.getDIDPrivateKeysByDID!(did) - if (!key) { - return 0 - } - return key.index + 1 - }, - - async getPrismLastKeyPathIndex(): Promise { - const results = await this.getAllPrismDIDs!() - if (!results || results.length === 0) { - return 0 - } - const maxim = Math.max(...results.map((result) => result.keyPathIndex)) - return maxim + 1 - }, - async getAllPeerDIDs(): Promise { - const peerDIDs: SDK.PeerDID[] = [] - const dids = await this.db.collections.dids.find({ - selector: { - method: { - $eq: 'peer' - } - } - }).exec() - for (const did of dids) { - const peerDID = SDK.Domain.DID.fromString(did.did) - const keys = await this.getDIDPrivateKeysByDID!(peerDID) - peerDIDs.push( - new SDK.PeerDID( - peerDID, - keys.map((key) => ({ - keyCurve: { - curve: key.curve as any - }, - value: key.raw - })) - ) - ) - } - return peerDIDs - }, - /** - * Stores a peerdid with its privateKeys - * @param did - * @param privateKeys - */ - async storePeerDID( - did: SDK.Domain.DID, - privateKeys: SDK.Domain.PrivateKey[] - ): Promise { - await this.db.collections.dids.insert({ - did: did.toString(), - method: did.method, - methodId: did.methodId, - schema: did.schema - }) - for (const prv of privateKeys) { - await this.db.collections.privatekeys.insert({ - id: uuidv4(), - did: did.toString(), - type: prv.type, - keySpecification: Array.from(prv.keySpecification).reduce( - (all, [key, value]) => [ - ...all, - { - type: 'string', - name: key, - value: `${value}` - } - ], - [ - { - type: 'string', - name: 'raw', - value: Buffer.from(prv.raw).toString('hex') - } - ] - ) - }) - } - }, - - -} \ No newline at end of file diff --git a/packages/schemas/src/schemas/did/types.ts b/packages/schemas/src/schemas/did/types.ts deleted file mode 100644 index ed73edf7..00000000 --- a/packages/schemas/src/schemas/did/types.ts +++ /dev/null @@ -1,46 +0,0 @@ -import SDK from '@atala/prism-wallet-sdk' -import { RxDocument, KeyFunctionMap, RxCollection } from "rxdb" - -import { StaticRxCollectionContext } from "../../types" -import { PlutoDBontext } from '../..' - - -export interface DIDSchemaType { - schema: string - method: string - methodId: string - alias?: string - did: string -} - -export type DIDDocument = RxDocument - -export interface DIDStaticMethodTypes extends KeyFunctionMap { - getPrismLastKeyPathIndex(this: PlutoDBontext,): Promise - getPrismDIDKeyPathIndex(this: PlutoDBontext, did: SDK.Domain.DID): Promise - storePeerDID( - this: PlutoDBontext, - did: SDK.Domain.DID, - privateKeys: SDK.Domain.PrivateKey[] - ): Promise - getAllPeerDIDs(this: PlutoDBontext): Promise - getAllPrismDIDs(this: PlutoDBontext): Promise - getDIDInfoByDID(this: PlutoDBontext, did: SDK.Domain.DID): Promise - getDIDInfoByAlias(this: PlutoDBontext, alias: string): Promise - storePrismDID( - this: PlutoDBontext, - did: SDK.Domain.DID, - keyPathIndex: number, - privateKey: SDK.Domain.PrivateKey, - _privateKeyMetaId?: string | null, - alias?: string | undefined - ): Promise -} - - - -export type DIDCollection = RxCollection< - DIDSchemaType, - any, - DIDStaticMethodTypes -> \ No newline at end of file diff --git a/packages/schemas/src/schemas/didpair/index.ts b/packages/schemas/src/schemas/didpair/index.ts deleted file mode 100644 index 70bef2c2..00000000 --- a/packages/schemas/src/schemas/didpair/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './schema'; -export * from './static'; -export * from './types'; \ No newline at end of file diff --git a/packages/schemas/src/schemas/didpair/schema.ts b/packages/schemas/src/schemas/didpair/schema.ts deleted file mode 100644 index 1db82356..00000000 --- a/packages/schemas/src/schemas/didpair/schema.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { Schema } from "../../types"; -import { DIDPairSchemaType } from "./types"; - - - -export const DIDPairSchema: Schema = { - version: 0, - primaryKey: 'name', - type: 'object', - properties: { - hostDID: { - type: 'string' - }, - name: { - type: 'string', - maxLength: 60 - }, - receiverDID: { - type: 'string' - } - }, - encrypted: [], - required: ['name', 'hostDID', 'receiverDID'] -} \ No newline at end of file diff --git a/packages/schemas/src/schemas/didpair/static.ts b/packages/schemas/src/schemas/didpair/static.ts deleted file mode 100644 index 6e5fa88d..00000000 --- a/packages/schemas/src/schemas/didpair/static.ts +++ /dev/null @@ -1,81 +0,0 @@ -import SDK from '@atala/prism-wallet-sdk' - - -import { DIDPairStaticMethodTypes } from './types' - -export const DIDPairStaticMethods: DIDPairStaticMethodTypes = { - - /** - * Stores a didpair - * @param host - * @param receiver - * @param name - */ - async storeDIDPair( - host: SDK.Domain.DID, - receiver: SDK.Domain.DID, - name: string - ): Promise { - await this.db.collections.didpairs.insert({ - hostDID: host.toString(), - receiverDID: receiver.toString(), - name - }) - }, - /** - * Gets all the stores didPairs - * @returns [Domain.DIDPair[]](https://input-output-hk.github.io/atala-prism-wallet-sdk-ts/classes/Domain.DIDPair.html) - */ - async getAllDidPairs(): Promise { - const results = await this.db.collections.didpairs.find().exec() - return results.map( - ({ hostDID, receiverDID, name }) => - new SDK.Domain.DIDPair(SDK.Domain.DID.fromString(hostDID), SDK.Domain.DID.fromString(receiverDID), name) - ) - }, - async getPairByName(name: string): Promise { - const didPair = await this.db.collections.didpairs.findOne({ - selector: { - $and: [ - { - name - } - ] - } - }).exec() - - return didPair - ? new SDK.Domain.DIDPair( - SDK.Domain.DID.fromString(didPair.hostDID), - SDK.Domain.DID.fromString(didPair.receiverDID), - didPair.name - ) - : null - }, - /** - * Get a did pair (connection) by one of its dids - * @param did - * @returns [Domain.DIDPair](https://input-output-hk.github.io/atala-prism-wallet-sdk-ts/classes/Domain.DIDPair.html) - */ - async getPairByDID(did: SDK.Domain.DID): Promise { - const didPair = await this.db.collections.didpairs.findOne({ - selector: { - $or: [ - { - hostDID: did.toString() - }, - { - receiverDID: did.toString() - } - ] - } - }).exec() - return didPair - ? new SDK.Domain.DIDPair( - SDK.Domain.DID.fromString(didPair.hostDID), - SDK.Domain.DID.fromString(didPair.receiverDID), - didPair.name - ) - : null - } -} \ No newline at end of file diff --git a/packages/schemas/src/schemas/didpair/types.ts b/packages/schemas/src/schemas/didpair/types.ts deleted file mode 100644 index 164a31ce..00000000 --- a/packages/schemas/src/schemas/didpair/types.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { RxDocument, KeyFunctionMap, RxCollection } from "rxdb" -import SDK from '@atala/prism-wallet-sdk' -import { PlutoDBontext } from "../.." - -export interface DIDPairSchemaType { - hostDID: string - receiverDID: string - name: string -} - - -export type DIDPairDocument = RxDocument - -export interface DIDPairStaticMethodTypes extends KeyFunctionMap { - storeDIDPair( - this: PlutoDBontext, - host: SDK.Domain.DID, - receiver: SDK.Domain.DID, - name: string - ): Promise - getAllDidPairs(this: PlutoDBontext): Promise - getPairByName(this: PlutoDBontext, name: string): Promise - getPairByDID(this: PlutoDBontext, did: SDK.Domain.DID): Promise -} -export type DIDPairCollection = RxCollection diff --git a/packages/schemas/src/schemas/linksecret/index.ts b/packages/schemas/src/schemas/linksecret/index.ts deleted file mode 100644 index c6864c03..00000000 --- a/packages/schemas/src/schemas/linksecret/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './orm'; -export * from './schema'; -export * from './static'; -export * from './types'; \ No newline at end of file diff --git a/packages/schemas/src/schemas/linksecret/orm.ts b/packages/schemas/src/schemas/linksecret/orm.ts deleted file mode 100644 index 5a483192..00000000 --- a/packages/schemas/src/schemas/linksecret/orm.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { LinkSecretDocument, LinkSecretMethodTypes } from "./types" - - - - -export const LinkSecretMethods: LinkSecretMethodTypes = { - toDomainLinkSecret: function toDomainLinkSecret(this: LinkSecretDocument) { - return this.secret - } -} \ No newline at end of file diff --git a/packages/schemas/src/schemas/linksecret/schema.ts b/packages/schemas/src/schemas/linksecret/schema.ts deleted file mode 100644 index 5b640616..00000000 --- a/packages/schemas/src/schemas/linksecret/schema.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { Schema } from "../../types"; -import { LinkSecretSchemaType } from "./types"; - -export const LinkSecretSchema: Schema = { - version: 0, - primaryKey: 'name', - type: 'object', - properties: { - name: { - type: 'string', - maxLength: 60 - }, - secret: { - type: 'string' - } - }, - encrypted: ['secret'], - required: ['name', 'secret'] -} diff --git a/packages/schemas/src/schemas/linksecret/static.ts b/packages/schemas/src/schemas/linksecret/static.ts deleted file mode 100644 index e921960a..00000000 --- a/packages/schemas/src/schemas/linksecret/static.ts +++ /dev/null @@ -1,31 +0,0 @@ - -import { LinkSecretStaticMethodTypes } from "./types" - -export const LinkSecretStaticMethods: LinkSecretStaticMethodTypes = { - async storeLinkSecret( - linkSecret: string, - linkSecretName: string - ): Promise { - await this.db.collections.linksecrets.insert({ - name: linkSecretName, - secret: linkSecret - }) - }, - async getLinkSecret( - linkSecretName?: string | undefined - ): Promise { - const query = linkSecretName - ? { - selector: { - name: { - $eq: linkSecretName - } - } - } : {} - const linkSecret = await this.db.collections.linksecrets.findOne(query).exec() - if (linkSecret) { - return linkSecret.toDomainLinkSecret() - } - return null - } -} diff --git a/packages/schemas/src/schemas/linksecret/types.ts b/packages/schemas/src/schemas/linksecret/types.ts deleted file mode 100644 index e8ac183a..00000000 --- a/packages/schemas/src/schemas/linksecret/types.ts +++ /dev/null @@ -1,41 +0,0 @@ -import SDK from '@atala/prism-wallet-sdk' -import { RxDocument, KeyFunctionMap, RxCollection } from 'rxdb' -import { PlutoDBontext } from '../..' - - - - - -export interface LinkSecretSchemaType { - readonly name: string - readonly secret: string -} - - - -export type LinkSecretDocument = RxDocument< - LinkSecretSchemaType, - LinkSecretMethodTypes -> - -export interface LinkSecretMethodTypes extends KeyFunctionMap { - toDomainLinkSecret: (this: LinkSecretDocument) => SDK.Domain.Anoncreds.LinkSecret -} - -export interface LinkSecretStaticMethodTypes extends KeyFunctionMap { - storeLinkSecret( - this: PlutoDBontext, - linkSecret: string, - linkSecretName: string - ): Promise - getLinkSecret( - this: PlutoDBontext, - linkSecretName?: string | undefined - ): Promise -} - -export type LinkSecretColletion = RxCollection< - LinkSecretSchemaType, - LinkSecretMethodTypes, - LinkSecretStaticMethodTypes -> \ No newline at end of file diff --git a/packages/schemas/src/schemas/mediator/index.ts b/packages/schemas/src/schemas/mediator/index.ts deleted file mode 100644 index c6864c03..00000000 --- a/packages/schemas/src/schemas/mediator/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './orm'; -export * from './schema'; -export * from './static'; -export * from './types'; \ No newline at end of file diff --git a/packages/schemas/src/schemas/mediator/orm.ts b/packages/schemas/src/schemas/mediator/orm.ts deleted file mode 100644 index e7f4249b..00000000 --- a/packages/schemas/src/schemas/mediator/orm.ts +++ /dev/null @@ -1,15 +0,0 @@ - -import SDK from '@atala/prism-wallet-sdk' -import { MediatorMethodTypes, MediatorSchemaType } from './types' -import { RxDocument } from 'rxdb' - -export const MediatorMethods: MediatorMethodTypes = { - toDomainMediator: function toDomainMediator(this: RxDocument) { - const mediator = this.toJSON() - return { - hostDID: SDK.Domain.DID.fromString(mediator.hostDID), - routingDID: SDK.Domain.DID.fromString(mediator.routingDID), - mediatorDID: SDK.Domain.DID.fromString(mediator.mediatorDID) - } - } -} \ No newline at end of file diff --git a/packages/schemas/src/schemas/mediator/schema.ts b/packages/schemas/src/schemas/mediator/schema.ts deleted file mode 100644 index 5b097552..00000000 --- a/packages/schemas/src/schemas/mediator/schema.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { Schema } from "../../types"; -import { MediatorSchemaType } from "./types"; - - - - -export const MediatorSchema: Schema = { - version: 0, - primaryKey: 'id', - type: 'object', - properties: { - id: { - type: 'string', - maxLength: 60 - }, - mediatorDID: { - type: 'string' - }, - hostDID: { - type: 'string' - }, - routingDID: { - type: 'string' - } - }, - encrypted: [], - required: ['id', 'mediatorDID'] -} - - diff --git a/packages/schemas/src/schemas/mediator/static.ts b/packages/schemas/src/schemas/mediator/static.ts deleted file mode 100644 index 664f0b4d..00000000 --- a/packages/schemas/src/schemas/mediator/static.ts +++ /dev/null @@ -1,24 +0,0 @@ -import SDK from '@atala/prism-wallet-sdk' -import { v4 as uuidv4 } from 'uuid' - -import { MediatorStaticMethodTypes } from "./types" - -export const MediatorStaticMethods: MediatorStaticMethodTypes = { - async storeMediator( - mediator: SDK.Domain.DID, - host: SDK.Domain.DID, - routing: SDK.Domain.DID - ): Promise { - await this.db.collections.mediators.insert({ - id: uuidv4(), - mediatorDID: mediator.toString(), - hostDID: host.toString(), - routingDID: routing.toString() - }) - } - , - async getAllMediators(): Promise { - const mediators = await this.db.collections.mediators.find().exec() - return mediators.map((mediator) => mediator.toDomainMediator()) - } -} \ No newline at end of file diff --git a/packages/schemas/src/schemas/mediator/types.ts b/packages/schemas/src/schemas/mediator/types.ts deleted file mode 100644 index 84b7b5fe..00000000 --- a/packages/schemas/src/schemas/mediator/types.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { KeyFunctionMap, RxCollection, RxDocument } from "rxdb" -import SDK from '@atala/prism-wallet-sdk' -import { PlutoDBontext } from "../.." - -export interface MediatorSchemaType { - id: string - mediatorDID: string - hostDID: string - routingDID: string -} - - - -export type MediatorDocument = RxDocument -export interface MediatorMethodTypes extends KeyFunctionMap { - toDomainMediator: (this: RxDocument) => SDK.Domain.Mediator -} - -export interface MediatorStaticMethodTypes extends KeyFunctionMap { - getAllMediators(this: PlutoDBontext): Promise - storeMediator( - this: PlutoDBontext, - mediator: SDK.Domain.DID, - host: SDK.Domain.DID, - routing: SDK.Domain.DID - ): Promise -} -export type MediatorCollection = RxCollection< - MediatorSchemaType, - MediatorMethodTypes, - MediatorStaticMethodTypes -> \ No newline at end of file diff --git a/packages/schemas/src/schemas/message/index.ts b/packages/schemas/src/schemas/message/index.ts deleted file mode 100644 index c6864c03..00000000 --- a/packages/schemas/src/schemas/message/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './orm'; -export * from './schema'; -export * from './static'; -export * from './types'; \ No newline at end of file diff --git a/packages/schemas/src/schemas/message/orm.ts b/packages/schemas/src/schemas/message/orm.ts deleted file mode 100644 index ef992454..00000000 --- a/packages/schemas/src/schemas/message/orm.ts +++ /dev/null @@ -1,10 +0,0 @@ - -import SDK from '@atala/prism-wallet-sdk' -import { MessageDocument, MessageMethodTypes } from './types' - - -export const MessageMethods: MessageMethodTypes = { - toDomainMessage: function toDomainMessage(this: MessageDocument) { - return SDK.Domain.Message.fromJson(JSON.stringify(this)) - } -} \ No newline at end of file diff --git a/packages/schemas/src/schemas/message/schema.ts b/packages/schemas/src/schemas/message/schema.ts deleted file mode 100644 index 5826525f..00000000 --- a/packages/schemas/src/schemas/message/schema.ts +++ /dev/null @@ -1,88 +0,0 @@ -import { Schema } from "../../types"; -import { MessageSchemaType } from "./types"; - -export const MessageSchema: Schema = { - version: 0, - primaryKey: 'id', - type: 'object', - properties: { - id: { - type: 'string', - maxLength: 60 - }, - body: { - type: 'string' - }, - piuri: { - type: 'string' - }, - attachments: { - type: 'array', - items: { - type: 'object', - properties: { - id: { - type: 'id', - maxLength: 60 - }, - description: { - type: 'string' - }, - byteCount: { - type: 'number' - }, - lastModTime: { - type: 'string' - }, - format: { - type: 'string' - }, - filename: { - type: 'array', - items: { - type: 'string' - } - }, - mediaType: { - type: 'string' - }, - data: { - type: 'object' - } - } - } - }, - extraHeaders: { - type: 'array' - }, - createdTime: { - type: 'string' - }, - expiresTimePlus: { - type: 'string' - }, - ack: { - type: 'array' - }, - direction: { - type: 'number' - }, - from: { - type: 'string' - }, - to: { - type: 'string' - }, - thid: { - type: 'string' - }, - fromPrior: { - type: 'string' - }, - pthid: { - type: 'string' - } - }, - encrypted: ['thid', 'attachments', 'body'], - required: ['id'] -} \ No newline at end of file diff --git a/packages/schemas/src/schemas/message/static.ts b/packages/schemas/src/schemas/message/static.ts deleted file mode 100644 index 38dbfcd4..00000000 --- a/packages/schemas/src/schemas/message/static.ts +++ /dev/null @@ -1,192 +0,0 @@ - -import SDK from '@atala/prism-wallet-sdk' -import { MessageSchemaType, MessageStaticMethodTypes } from './types' -import { MangoQuerySelector } from 'rxdb' - - -export const MessageStaticMethods: MessageStaticMethodTypes = { - async getAllMessagesByDID(did: SDK.Domain.DID): Promise { - const messages = await this.db.collections.messages.find({ - selector: { - $or: [ - { - to: did.toString() - }, - { - from: did.toString() - } - ] - } - }).exec() - - return messages.map((message) => message.toDomainMessage()) - }, - async getAllMessagesSent(): Promise { - const messages = await this.db.collections.messages.find({ - selector: { - $or: [ - { - direction: SDK.Domain.MessageDirection.SENT - } - ] - } - }).exec() - - return messages.map((message) => message.toDomainMessage()) - }, - async getAllMessagesReceived(): Promise { - const messages = await this.db.collections.messages.find({ - selector: { - $or: [ - { - direction: SDK.Domain.MessageDirection.RECEIVED - } - ] - } - }).exec() - - return messages.map((message) => message.toDomainMessage()) - }, - async getAllMessagesSentTo(did: SDK.Domain.DID): Promise { - const messages = await this.db.collections.messages.find({ - selector: { - $and: [ - { - to: did.toString() - }, - { - direction: SDK.Domain.MessageDirection.SENT - } - ] - } - }).exec() - return messages.map((message) => message.toDomainMessage()) - }, - async getAllMessagesReceivedFrom(did: SDK.Domain.DID): Promise { - const messages = await this.db.collections.messages.find({ - selector: { - $and: [ - { - from: did.toString() - }, - { - direction: SDK.Domain.MessageDirection.RECEIVED - } - ] - } - }).exec() - return messages.map((message) => message.toDomainMessage()) - }, - async getAllMessagesOfType( - type: string, - relatedWithDID?: SDK.Domain.DID | undefined - ): Promise { - const query: Array> = [ - { - piuri: type - } - ] - if (relatedWithDID) { - query.push({ - $or: [ - { - from: relatedWithDID.toString() - }, - { - to: relatedWithDID.toString() - } - ] - }) - } - const messages = await this.db.collections.messages.find({ - selector: { - $and: query - } - }).exec() - - return messages.map((message) => message.toDomainMessage()) - }, - async getAllMessagesByFromToDID( - from: SDK.Domain.DID, - to: SDK.Domain.DID - ): Promise { - const messages = await this.db.collections.messages.find({ - selector: { - $or: [ - { - from: from.toString() - }, - { - to: to.toString() - } - ] - } - }).exec() - - return messages.map((message) => message.toDomainMessage()) - } - , - /** - * Get all the stored messages - * @returns [Message[]](https://input-output-hk.github.io/atala-prism-wallet-sdk-ts/classes/Domain.Message.html) - */ - async getAllMessages(): Promise { - const messages = await this.db.collections.messages.find().exec() - return messages.map((message) => message.toDomainMessage()) - }, - /** - * Stores multiple messages in 1 call - * @param [Message[]](https://input-output-hk.github.io/atala-prism-wallet-sdk-ts/classes/Domain.Message.html) - * @returns void - */ - async storeMessages(messages: SDK.Domain.Message[]): Promise { - for (const message of messages) { - await this.storeMessage(message) - } - }, - /** - * Stores a message - * @param [Message](https://input-output-hk.github.io/atala-prism-wallet-sdk-ts/classes/Domain.Message.html) - * @returns void - */ - async storeMessage(message: SDK.Domain.Message): Promise { - const existing = await this.db.collections.messages.findOne({ - selector: { - id: { - $eq: message.id - } - } - }).exec() - if (existing) { - await existing.patch({ - ...message, - to: message.to?.toString(), - from: message.from?.toString() - }) - } else { - await this.db.collections.messages.insert({ - ...message, - to: message.to?.toString(), - from: message.from?.toString() - }) - } - }, - /** - * Get a Message by its id - * @param id - * @returns [Message](https://input-output-hk.github.io/atala-prism-wallet-sdk-ts/classes/Domain.Message.html) - */ - async getMessage(id: string): Promise { - const message = await this.db.collections.messages.findOne({ - selector: { - id: { - $eq: id - } - } - }).exec() - if (message) { - return message.toDomainMessage() - } - return null - } -} \ No newline at end of file diff --git a/packages/schemas/src/schemas/message/types.ts b/packages/schemas/src/schemas/message/types.ts deleted file mode 100644 index 904c8062..00000000 --- a/packages/schemas/src/schemas/message/types.ts +++ /dev/null @@ -1,81 +0,0 @@ -import SDK from '@atala/prism-wallet-sdk' -import { RxDocument, KeyFunctionMap, RxCollection } from 'rxdb' -import { PlutoDBontext } from '../..' - - -export interface MessageSchemaType { - readonly body: string - readonly id: string - readonly piuri: string - readonly from?: string | undefined - readonly to?: string | undefined - readonly attachments: SDK.Domain.AttachmentDescriptor[] - readonly thid?: string - readonly extraHeaders: string[] - readonly createdTime: string - readonly expiresTimePlus: string - readonly ack: string[] - readonly direction: SDK.Domain.MessageDirection - readonly fromPrior?: string | undefined - readonly pthid?: string | undefined -} - -export type MessageDocument = RxDocument - -export interface MessageMethodTypes extends KeyFunctionMap { - toDomainMessage: ( - this: MessageDocument - ) => SDK.Domain.Message -} - -export interface MessageStaticMethodTypes extends KeyFunctionMap { - getMessage( - this: PlutoDBontext, - id: string - ): Promise - storeMessage( - this: PlutoDBontext, - message: SDK.Domain.Message - ): Promise - storeMessages( - this: PlutoDBontext, - messages: SDK.Domain.Message[] - ): Promise - getAllMessages( - this: PlutoDBontext, - ): Promise - getAllMessagesByFromToDID( - this: PlutoDBontext, - from: SDK.Domain.DID, - to: SDK.Domain.DID - ): Promise - getAllMessagesOfType( - this: PlutoDBontext, - type: string, - relatedWithDID?: SDK.Domain.DID | undefined - ): Promise - getAllMessagesReceivedFrom( - this: PlutoDBontext, - did: SDK.Domain.DID - ): Promise - getAllMessagesSentTo( - this: PlutoDBontext, - did: SDK.Domain.DID - ): Promise - getAllMessagesReceived( - this: PlutoDBontext, - ): Promise - getAllMessagesSent( - this: PlutoDBontext, - ): Promise - getAllMessagesByDID( - this: PlutoDBontext, - did: SDK.Domain.DID - ): Promise -} - -export type MessageColletion = RxCollection< - MessageSchemaType, - MessageMethodTypes, - MessageStaticMethodTypes -> \ No newline at end of file diff --git a/packages/schemas/src/schemas/privatekey/index.ts b/packages/schemas/src/schemas/privatekey/index.ts deleted file mode 100644 index c6864c03..00000000 --- a/packages/schemas/src/schemas/privatekey/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './orm'; -export * from './schema'; -export * from './static'; -export * from './types'; \ No newline at end of file diff --git a/packages/schemas/src/schemas/privatekey/orm.ts b/packages/schemas/src/schemas/privatekey/orm.ts deleted file mode 100644 index 776ee86d..00000000 --- a/packages/schemas/src/schemas/privatekey/orm.ts +++ /dev/null @@ -1,94 +0,0 @@ -import SDK from '@atala/prism-wallet-sdk' -import { PrivateKeyDocument, PrivateKeyMethodTypes } from './types'; - -export const PrivateKeyMethods: PrivateKeyMethodTypes = { - toDomainPrivateKey: function toDomainPrivateKey(this: PrivateKeyDocument) { - const { type, keySpecification } = this - const curve = keySpecification.find( - (item) => item.name === SDK.KeyProperties.curve - ) - const raw = keySpecification.find( - (item) => item.name === SDK.KeyProperties.rawKey - ) - if (!(type in SDK.Domain.KeyTypes)) { - throw new Error(`Invalid KeyType ${type || 'undefined'}`) - } - if (!curve) { - throw new Error('Undefined key curve') - } - - if ( - curve.value !== SDK.Domain.Curve.SECP256K1 && - curve.value !== SDK.Domain.Curve.ED25519 && - curve.value !== SDK.Domain.Curve.X25519 - ) { - throw new Error(`Invalid key curve ${curve.value}`) - } - - if (!raw) { - throw new Error('Undefined key raw') - } - - /* istanbul ignore else -- @preserve */ - if (curve.value === SDK.Domain.Curve.SECP256K1) { - const index = keySpecification.find( - (item) => item.name === SDK.KeyProperties.index - ) - const seed = keySpecification.find( - (item) => item.name === SDK.KeyProperties.seed - ) - - const privateKey = new SDK.Secp256k1PrivateKey( - Buffer.from(raw.value, 'hex') - ) - - privateKey.keySpecification.set(SDK.Domain.KeyProperties.rawKey, raw.value) - - privateKey.keySpecification.set( - SDK.Domain.KeyProperties.curve, - SDK.Domain.Curve.SECP256K1 - ) - - if (index) { - privateKey.keySpecification.set( - SDK.Domain.KeyProperties.index, - index.value - ) - } - - if (seed) { - privateKey.keySpecification.set( - SDK.Domain.KeyProperties.seed, - seed.value - ) - } - - return privateKey - } else if (curve.value === SDK.Domain.Curve.ED25519) { - const privateKey = new SDK.Ed25519PrivateKey(Buffer.from(raw.value, 'hex')) - - privateKey.keySpecification.set(SDK.Domain.KeyProperties.rawKey, raw.value) - - privateKey.keySpecification.set( - SDK.Domain.KeyProperties.curve, - SDK.Domain.Curve.ED25519 - ) - - return privateKey - } else if (curve.value === SDK.Domain.Curve.X25519) { - const privateKey = new SDK.X25519PrivateKey(Buffer.from(raw.value, 'hex')) - - privateKey.keySpecification.set(SDK.Domain.KeyProperties.rawKey, raw.value) - - privateKey.keySpecification.set( - SDK.Domain.KeyProperties.curve, - SDK.Domain.Curve.X25519 - ) - - return privateKey - } else { - /* istanbul ignore next -- @preserve */ - throw new Error(`Invalid key ${curve.value} ${type}`) - } - } -} \ No newline at end of file diff --git a/packages/schemas/src/schemas/privatekey/schema.ts b/packages/schemas/src/schemas/privatekey/schema.ts deleted file mode 100644 index a0352c2e..00000000 --- a/packages/schemas/src/schemas/privatekey/schema.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { Schema } from "../../types"; -import { KeySchemaType } from "./types"; - - - -export const PrivateKeySchema: Schema = { - version: 0, - primaryKey: 'id', - type: 'object', - properties: { - id: { - type: 'string', - maxLength: 60 - }, - did: { - type: 'string' - }, - type: { - type: 'string' - }, - keySpecification: { - type: 'array', - items: { - type: 'object', - properties: { - name: { - type: 'string' - }, - type: { - type: 'string' - }, - value: { - type: 'string' - } - } - } - } - }, - encrypted: ['keySpecification', 'type'], - required: ['keySpecification', 'did', 'type', 'id'] -} \ No newline at end of file diff --git a/packages/schemas/src/schemas/privatekey/static.ts b/packages/schemas/src/schemas/privatekey/static.ts deleted file mode 100644 index 9f8287fe..00000000 --- a/packages/schemas/src/schemas/privatekey/static.ts +++ /dev/null @@ -1,68 +0,0 @@ -import SDK from '@atala/prism-wallet-sdk' -import { v4 as uuidv4 } from 'uuid' -import { KeySpec, PrivateKeyStaticMethodTypes } from './types' - -export const PrivateKeyStaticMethods: PrivateKeyStaticMethodTypes = { - /** - * Stores privateKeys references to an existing DID - * @param privateKey - * @param did - * @param keyPathIndex - * @param _metaId - */ - async storePrivateKeys( - privateKey: SDK.Domain.PrivateKey, - did: SDK.Domain.DID, - keyPathIndex: number - ): Promise { - await this.db.collections.privatekeys.insert({ - id: uuidv4(), - did: did.toString(), - type: privateKey.type, - keySpecification: Array.from(privateKey.keySpecification).reduce( - (all, [key, value]) => [ - ...all, - { - type: 'string', - name: key, - value: `${value}` - } - ], - [ - { - type: 'string', - name: 'raw', - value: Buffer.from(privateKey.raw).toString('hex') - }, - { - type: 'number', - name: 'index', - value: `${keyPathIndex}` - } - ] - ) - }) - }, - async getDIDPrivateKeysByDID(did: SDK.Domain.DID): Promise { - const privateKeys = await this.db.collections.privatekeys.find({ - selector: { - did: { - $eq: did.toString() - } - } - }).exec() - return privateKeys.map((privateKey) => { - return privateKey.toDomainPrivateKey() - }) - }, - async getDIDPrivateKeyByID(id: string): Promise { - const privateKey = await this.db.collections.privatekeys.findOne({ - selector: { - id: { - $eq: id - } - } - }).exec() - return privateKey ? privateKey.toDomainPrivateKey() : null - } -} \ No newline at end of file diff --git a/packages/schemas/src/schemas/privatekey/types.ts b/packages/schemas/src/schemas/privatekey/types.ts deleted file mode 100644 index bff2c89b..00000000 --- a/packages/schemas/src/schemas/privatekey/types.ts +++ /dev/null @@ -1,49 +0,0 @@ -import SDK from '@atala/prism-wallet-sdk' -import { KeyFunctionMap, RxCollection, RxDocument } from 'rxdb' -import { StaticRxCollectionContext } from '../../types' -import { DatabaseBase } from '@pluto-encrypted/shared' -import { PlutoDBontext } from '../..' - -export interface KeySpec { - name: string - type: string - value: string -} - -export interface KeySchemaType { - id: string - type: string - did: string - keySpecification: KeySpec[] -} - -export interface PrivateKeyMethodTypes extends KeyFunctionMap { - toDomainPrivateKey: (this: PrivateKeyDocument) => SDK.Domain.PrivateKey -} - -export interface PrivateKeyStaticMethodTypes extends KeyFunctionMap { - storePrivateKeys( - this: PlutoDBontext, - privateKey: SDK.Domain.PrivateKey, - did: SDK.Domain.DID, - keyPathIndex: number - ): Promise - getDIDPrivateKeysByDID( - this: PlutoDBontext, - did: SDK.Domain.DID - ): Promise - getDIDPrivateKeyByID( - this: PlutoDBontext, - id: string - ): Promise -} - -export type PrivateKeyColletion = RxCollection< - KeySchemaType, - PrivateKeyMethodTypes, - PrivateKeyStaticMethodTypes -> -export type PrivateKeyDocument = RxDocument< - KeySchemaType, - PrivateKeyMethodTypes -> \ No newline at end of file diff --git a/packages/schemas/src/types.ts b/packages/schemas/src/types.ts deleted file mode 100644 index 62ae74c8..00000000 --- a/packages/schemas/src/types.ts +++ /dev/null @@ -1,58 +0,0 @@ -import SDK from '@atala/prism-wallet-sdk' - -import { - CollectionsOfDatabase, - RxCollection, - RxCollectionCreator, - RxDatabase, - RxDatabaseCreator, - RxDumpDatabase, - RxJsonSchema, - RxStorage -} from "rxdb" - -import { CredentialCollection } from "./schemas/credential" -import { DIDPairCollection } from "./schemas/didpair" - -import { MediatorCollection } from "./schemas/mediator" -import { LinkSecretColletion } from "./schemas/linksecret" -import { DIDCollection } from "./schemas/did" -import { CredentialRequestMetadataCollection } from "./schemas/credentialRequestMetadata" - - -import { MessageColletion } from "./schemas/message" -import { PrivateKeyColletion } from "./schemas/privatekey" -import { DatabaseBase } from '@pluto-encrypted/shared' - -export type ValuesOf = T[keyof T] -export type Schema = RxJsonSchema & { - encrypted: Array -} - -export type PlutoCollections = { - messages: MessageColletion; - dids: DIDCollection; - didpairs: DIDPairCollection; - mediators: MediatorCollection; - privatekeys: PrivateKeyColletion; - credentials: CredentialCollection; - credentialrequestmetadatas: CredentialRequestMetadataCollection; - linksecrets: LinkSecretColletion; -} & { [name: string]: RxCollection } - -export interface PlutoCollectionsCreator { - messages: RxCollectionCreator - dids: RxCollectionCreator - didpairs: RxCollectionCreator - mediators: RxCollectionCreator - privatekeys: RxCollectionCreator - credentials: RxCollectionCreator - credentialrequestmetadatas: RxCollectionCreator - linksecrets: RxCollectionCreator -} - -export type PlutoInstance< - Collections = CollectionsOfDatabase, -> = DatabaseBase -export type DBOptions = RxDatabaseCreator; -export type StaticRxCollectionContext = PlutoInstance diff --git a/packages/schemas/tsconfig.json b/packages/schemas/tsconfig.json deleted file mode 100644 index 41c8ed49..00000000 --- a/packages/schemas/tsconfig.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "compilerOptions": { - "rootDir": "./src", - "declarationDir": "./build", - }, - "include": [ - "src" - ] -} diff --git a/packages/schemas/vitest.config.ts b/packages/schemas/vitest.config.ts deleted file mode 100644 index 16c4c803..00000000 --- a/packages/schemas/vitest.config.ts +++ /dev/null @@ -1,28 +0,0 @@ -/// -import { defineConfig } from 'vite' - -const isCI = process.env.CI === "true"; - -export default defineConfig({ - build: { - minify: 'terser', - terserOptions: { format: { comments: 'all' } }, - }, - test: { - reporters: ['verbose'], // or 'verbose' - coverage: { - provider: 'istanbul', - reporter: isCI ? ['json-summary'] : ['json-summary', "html"], - thresholds: { - branches: 95, - functions: 95, - lines: 95, - statements: 95 - }, - include: [ - 'src/**/*', - ], - }, - - } -})