@didcid/keymaster 0.3.10 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,7 +13,6 @@ var db_typeGuards = require('./db/typeGuards.cjs');
13
13
  require('image-size');
14
14
  require('file-type');
15
15
  require('crypto');
16
- require('./encryption.cjs');
17
16
  require('buffer');
18
17
  require('axios');
19
18
 
@@ -679,9 +679,9 @@ class KeymasterClient {
679
679
  throwError(error);
680
680
  }
681
681
  }
682
- async createPoll(poll, options) {
682
+ async createPoll(config, options) {
683
683
  try {
684
- const response = await axios.post(`${this.API}/polls`, { poll, options });
684
+ const response = await axios.post(`${this.API}/polls`, { poll: config, options });
685
685
  return response.data.did;
686
686
  }
687
687
  catch (error) {
@@ -697,6 +697,24 @@ class KeymasterClient {
697
697
  throwError(error);
698
698
  }
699
699
  }
700
+ async testPoll(id) {
701
+ try {
702
+ const response = await axios.get(`${this.API}/polls/${id}/test`);
703
+ return response.data.test;
704
+ }
705
+ catch (error) {
706
+ throwError(error);
707
+ }
708
+ }
709
+ async listPolls(owner) {
710
+ try {
711
+ const response = await axios.get(`${this.API}/polls`, { params: { owner } });
712
+ return response.data.polls;
713
+ }
714
+ catch (error) {
715
+ throwError(error);
716
+ }
717
+ }
700
718
  async viewPoll(pollId) {
701
719
  try {
702
720
  const response = await axios.get(`${this.API}/polls/${pollId}/view`);
@@ -715,6 +733,33 @@ class KeymasterClient {
715
733
  throwError(error);
716
734
  }
717
735
  }
736
+ async sendPoll(pollId) {
737
+ try {
738
+ const response = await axios.post(`${this.API}/polls/${pollId}/send`);
739
+ return response.data.did;
740
+ }
741
+ catch (error) {
742
+ throwError(error);
743
+ }
744
+ }
745
+ async sendBallot(ballotDid, pollId) {
746
+ try {
747
+ const response = await axios.post(`${this.API}/polls/ballot/send`, { ballot: ballotDid, poll: pollId });
748
+ return response.data.did;
749
+ }
750
+ catch (error) {
751
+ throwError(error);
752
+ }
753
+ }
754
+ async viewBallot(ballotDid) {
755
+ try {
756
+ const response = await axios.get(`${this.API}/polls/ballot/${ballotDid}`);
757
+ return response.data.ballot;
758
+ }
759
+ catch (error) {
760
+ throwError(error);
761
+ }
762
+ }
718
763
  async updatePoll(ballot) {
719
764
  try {
720
765
  const response = await axios.put(`${this.API}/polls/update`, { ballot });
@@ -742,6 +787,33 @@ class KeymasterClient {
742
787
  throwError(error);
743
788
  }
744
789
  }
790
+ async addPollVoter(pollId, memberId) {
791
+ try {
792
+ const response = await axios.post(`${this.API}/polls/${pollId}/voters`, { memberId });
793
+ return response.data.ok;
794
+ }
795
+ catch (error) {
796
+ throwError(error);
797
+ }
798
+ }
799
+ async removePollVoter(pollId, memberId) {
800
+ try {
801
+ const response = await axios.delete(`${this.API}/polls/${pollId}/voters/${memberId}`);
802
+ return response.data.ok;
803
+ }
804
+ catch (error) {
805
+ throwError(error);
806
+ }
807
+ }
808
+ async listPollVoters(pollId) {
809
+ try {
810
+ const response = await axios.get(`${this.API}/polls/${pollId}/voters`);
811
+ return response.data.voters;
812
+ }
813
+ catch (error) {
814
+ throwError(error);
815
+ }
816
+ }
745
817
  async createImage(data, options = {}) {
746
818
  try {
747
819
  const response = await axios.post(`${this.API}/images`, data, {