@didcid/keymaster 0.3.10 → 0.4.1

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
 
@@ -146,6 +146,15 @@ class KeymasterClient {
146
146
  throwError(error);
147
147
  }
148
148
  }
149
+ async changePassphrase(newPassphrase) {
150
+ try {
151
+ const response = await axios.post(`${this.API}/wallet/passphrase`, { passphrase: newPassphrase });
152
+ return response.data.ok;
153
+ }
154
+ catch (error) {
155
+ throwError(error);
156
+ }
157
+ }
149
158
  async listRegistries() {
150
159
  try {
151
160
  const response = await axios.get(`${this.API}/registries`);
@@ -679,9 +688,9 @@ class KeymasterClient {
679
688
  throwError(error);
680
689
  }
681
690
  }
682
- async createPoll(poll, options) {
691
+ async createPoll(config, options) {
683
692
  try {
684
- const response = await axios.post(`${this.API}/polls`, { poll, options });
693
+ const response = await axios.post(`${this.API}/polls`, { poll: config, options });
685
694
  return response.data.did;
686
695
  }
687
696
  catch (error) {
@@ -697,6 +706,24 @@ class KeymasterClient {
697
706
  throwError(error);
698
707
  }
699
708
  }
709
+ async testPoll(id) {
710
+ try {
711
+ const response = await axios.get(`${this.API}/polls/${id}/test`);
712
+ return response.data.test;
713
+ }
714
+ catch (error) {
715
+ throwError(error);
716
+ }
717
+ }
718
+ async listPolls(owner) {
719
+ try {
720
+ const response = await axios.get(`${this.API}/polls`, { params: { owner } });
721
+ return response.data.polls;
722
+ }
723
+ catch (error) {
724
+ throwError(error);
725
+ }
726
+ }
700
727
  async viewPoll(pollId) {
701
728
  try {
702
729
  const response = await axios.get(`${this.API}/polls/${pollId}/view`);
@@ -715,6 +742,33 @@ class KeymasterClient {
715
742
  throwError(error);
716
743
  }
717
744
  }
745
+ async sendPoll(pollId) {
746
+ try {
747
+ const response = await axios.post(`${this.API}/polls/${pollId}/send`);
748
+ return response.data.did;
749
+ }
750
+ catch (error) {
751
+ throwError(error);
752
+ }
753
+ }
754
+ async sendBallot(ballotDid, pollId) {
755
+ try {
756
+ const response = await axios.post(`${this.API}/polls/ballot/send`, { ballot: ballotDid, poll: pollId });
757
+ return response.data.did;
758
+ }
759
+ catch (error) {
760
+ throwError(error);
761
+ }
762
+ }
763
+ async viewBallot(ballotDid) {
764
+ try {
765
+ const response = await axios.get(`${this.API}/polls/ballot/${ballotDid}`);
766
+ return response.data.ballot;
767
+ }
768
+ catch (error) {
769
+ throwError(error);
770
+ }
771
+ }
718
772
  async updatePoll(ballot) {
719
773
  try {
720
774
  const response = await axios.put(`${this.API}/polls/update`, { ballot });
@@ -742,6 +796,33 @@ class KeymasterClient {
742
796
  throwError(error);
743
797
  }
744
798
  }
799
+ async addPollVoter(pollId, memberId) {
800
+ try {
801
+ const response = await axios.post(`${this.API}/polls/${pollId}/voters`, { memberId });
802
+ return response.data.ok;
803
+ }
804
+ catch (error) {
805
+ throwError(error);
806
+ }
807
+ }
808
+ async removePollVoter(pollId, memberId) {
809
+ try {
810
+ const response = await axios.delete(`${this.API}/polls/${pollId}/voters/${memberId}`);
811
+ return response.data.ok;
812
+ }
813
+ catch (error) {
814
+ throwError(error);
815
+ }
816
+ }
817
+ async listPollVoters(pollId) {
818
+ try {
819
+ const response = await axios.get(`${this.API}/polls/${pollId}/voters`);
820
+ return response.data.voters;
821
+ }
822
+ catch (error) {
823
+ throwError(error);
824
+ }
825
+ }
745
826
  async createImage(data, options = {}) {
746
827
  try {
747
828
  const response = await axios.post(`${this.API}/images`, data, {