unwallet-client-sdk 0.2.0 → 0.3.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.
@@ -1 +1 @@
1
- {"version":3,"file":"unwallet.d.ts","sourceRoot":"","sources":["../src/unwallet.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAElE,qBAAa,QAAQ;IACnB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,cAAc,CAAiB;IAEvC,OAAO,CAAC,EAAE,CAAY;IACtB,OAAO,CAAC,YAAY,CAAS;IAE7B,OAAO,CAAC,OAAO,CAAwC;IACvD,OAAO,CAAC,MAAM,CAAwC;gBAE1C,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,cAAc,EAAE,EAAE,EAAE,SAAS;IAUzE,OAAO,CAAC,eAAe;WAKT,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IAiC9C,SAAS,CAAC,IAAI,EAAE;QACrB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,WAAW,EAAE,MAAM,CAAC;QACpB,KAAK,EAAE,MAAM,CAAC;KACf,GAAG,IAAI;IAgBD,IAAI,CAAC,IAAI,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IAahD,iBAAiB,CAAC,IAAI,EAAE;QAC7B,EAAE,EAAE,MAAM,CAAC;QACX,EAAE,EAAE,MAAM,CAAC;QACX,MAAM,EAAE,MAAM,CAAC;KAChB,GAAG,OAAO,CAAC,eAAe,CAAC;IAerB,kBAAkB,CAAC,IAAI,EAAE;QAC9B,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC;KACnB,GAAG,OAAO,CAAC,MAAM,CAAC;IAgBnB,OAAO,CAAC,eAAe;IAMvB,OAAO,CAAC,aAAa;IAIrB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ED
@@ -35,7 +35,7 @@ class UnWallet {
35
35
  ws.onmessage = (event) => {
36
36
  const msg = JSON.parse(event.data);
37
37
  if (msg.type === "connectionID") {
38
- unWallet.connectionID = msg.data.value;
38
+ unWallet.connectionID = msg.value;
39
39
  resolve(unWallet);
40
40
  return;
41
41
  }
@@ -105,17 +105,26 @@ class UnWallet {
105
105
  handleWSMessage(msg) {
106
106
  switch (msg.type) {
107
107
  case "signature":
108
+ this.resolve(msg.value);
109
+ break;
108
110
  case "metaTransaction":
111
+ this.resolve(msg.value);
112
+ break;
109
113
  case "presentation":
110
- if (msg.data.value === null) {
111
- this.reject("canceled");
112
- }
113
- else {
114
- this.resolve(msg.data.value);
115
- }
116
- this.initPromiseArgs();
114
+ this.resolve(msg.value);
117
115
  break;
116
+ case "error":
117
+ switch (msg.value) {
118
+ case "rejected":
119
+ this.reject("canceled");
120
+ break;
121
+ default:
122
+ throw new Error(msg.value);
123
+ }
124
+ default:
125
+ throw new Error(`unknown message type: ${msg.type}`);
118
126
  }
127
+ this.initPromiseArgs();
119
128
  }
120
129
  openWindow(url) {
121
130
  const width = screen.width / 2;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unwallet-client-sdk",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "unWallet client-side SDK",
5
5
  "license": "MIT",
6
6
  "author": "SIVIRA",
package/src/unwallet.ts CHANGED
@@ -47,7 +47,7 @@ export class UnWallet {
47
47
  ws.onmessage = (event) => {
48
48
  const msg = JSON.parse(event.data);
49
49
  if (msg.type === "connectionID") {
50
- unWallet.connectionID = msg.data.value;
50
+ unWallet.connectionID = msg.value;
51
51
  resolve(unWallet);
52
52
  return;
53
53
  }
@@ -143,16 +143,32 @@ export class UnWallet {
143
143
  private handleWSMessage(msg: any): void {
144
144
  switch (msg.type) {
145
145
  case "signature":
146
+ this.resolve!(msg.value);
147
+ break;
148
+
146
149
  case "metaTransaction":
150
+ this.resolve!(msg.value);
151
+ break;
152
+
147
153
  case "presentation":
148
- if (msg.data.value === null) {
149
- this.reject!("canceled");
150
- } else {
151
- this.resolve!(msg.data.value);
152
- }
153
- this.initPromiseArgs();
154
+ this.resolve!(msg.value);
154
155
  break;
156
+
157
+ case "error":
158
+ switch (msg.value) {
159
+ case "rejected":
160
+ this.reject!("canceled");
161
+ break;
162
+
163
+ default:
164
+ throw new Error(msg.value);
165
+ }
166
+
167
+ default:
168
+ throw new Error(`unknown message type: ${msg.type}`);
155
169
  }
170
+
171
+ this.initPromiseArgs();
156
172
  }
157
173
 
158
174
  private openWindow(url: URL): void {