@yourself_id/siwys-react-js 0.5.1-SAPP-159.2 → 0.5.1-SAPP-159.4

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.
package/dist/index.mjs CHANGED
@@ -7,6 +7,35 @@ function _array_like_to_array(arr, len) {
7
7
  function _array_with_holes(arr) {
8
8
  if (Array.isArray(arr)) return arr;
9
9
  }
10
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
11
+ try {
12
+ var info = gen[key](arg);
13
+ var value = info.value;
14
+ } catch (error) {
15
+ reject(error);
16
+ return;
17
+ }
18
+ if (info.done) {
19
+ resolve(value);
20
+ } else {
21
+ Promise.resolve(value).then(_next, _throw);
22
+ }
23
+ }
24
+ function _async_to_generator(fn) {
25
+ return function() {
26
+ var self = this, args = arguments;
27
+ return new Promise(function(resolve, reject) {
28
+ var gen = fn.apply(self, args);
29
+ function _next(value) {
30
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
31
+ }
32
+ function _throw(err) {
33
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
34
+ }
35
+ _next(undefined);
36
+ });
37
+ };
38
+ }
10
39
  function _define_property(obj, key, value) {
11
40
  if (key in obj) {
12
41
  Object.defineProperty(obj, key, {
@@ -152,6 +181,101 @@ function _unsupported_iterable_to_array(o, minLen) {
152
181
  if (n === "Map" || n === "Set") return Array.from(n);
153
182
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
154
183
  }
184
+ function _ts_generator(thisArg, body) {
185
+ var f, y, t, g, _ = {
186
+ label: 0,
187
+ sent: function() {
188
+ if (t[0] & 1) throw t[1];
189
+ return t[1];
190
+ },
191
+ trys: [],
192
+ ops: []
193
+ };
194
+ return g = {
195
+ next: verb(0),
196
+ "throw": verb(1),
197
+ "return": verb(2)
198
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
199
+ return this;
200
+ }), g;
201
+ function verb(n) {
202
+ return function(v) {
203
+ return step([
204
+ n,
205
+ v
206
+ ]);
207
+ };
208
+ }
209
+ function step(op) {
210
+ if (f) throw new TypeError("Generator is already executing.");
211
+ while(_)try {
212
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
213
+ if (y = 0, t) op = [
214
+ op[0] & 2,
215
+ t.value
216
+ ];
217
+ switch(op[0]){
218
+ case 0:
219
+ case 1:
220
+ t = op;
221
+ break;
222
+ case 4:
223
+ _.label++;
224
+ return {
225
+ value: op[1],
226
+ done: false
227
+ };
228
+ case 5:
229
+ _.label++;
230
+ y = op[1];
231
+ op = [
232
+ 0
233
+ ];
234
+ continue;
235
+ case 7:
236
+ op = _.ops.pop();
237
+ _.trys.pop();
238
+ continue;
239
+ default:
240
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
241
+ _ = 0;
242
+ continue;
243
+ }
244
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
245
+ _.label = op[1];
246
+ break;
247
+ }
248
+ if (op[0] === 6 && _.label < t[1]) {
249
+ _.label = t[1];
250
+ t = op;
251
+ break;
252
+ }
253
+ if (t && _.label < t[2]) {
254
+ _.label = t[2];
255
+ _.ops.push(op);
256
+ break;
257
+ }
258
+ if (t[2]) _.ops.pop();
259
+ _.trys.pop();
260
+ continue;
261
+ }
262
+ op = body.call(thisArg, _);
263
+ } catch (e) {
264
+ op = [
265
+ 6,
266
+ e
267
+ ];
268
+ y = 0;
269
+ } finally{
270
+ f = t = 0;
271
+ }
272
+ if (op[0] & 5) throw op[1];
273
+ return {
274
+ value: op[0] ? op[1] : void 0,
275
+ done: true
276
+ };
277
+ }
278
+ }
155
279
  function _templateObject() {
156
280
  var data = _tagged_template_literal([
157
281
  "\n display: flex;\n justify-content: center;\n align-items: center;\n height: 3rem;\n width: fit-content;\n border-radius: 60px;\n border: none;\n padding: 12px 40px 12px 40px;\n white-space: nowrap;\n\n ",
@@ -779,7 +903,7 @@ var SiwysButton = function(_param) {
779
903
  }, props));
780
904
  };
781
905
  // src/components/signin/SignInWithYourSelf.tsx
782
- import React17 from "react";
906
+ import React17, { useState as useState2, useEffect } from "react";
783
907
  import styled4 from "styled-components";
784
908
  // src/components/signin/QrCode.tsx
785
909
  import React16 from "react";
@@ -813,7 +937,7 @@ var QRContainer = styled4.div(_templateObject8());
813
937
  var Title = styled4.h4(_templateObject9());
814
938
  var InstructionsContainer = styled4.div(_templateObject10());
815
939
  var InstructionsTitle = styled4.h4(_templateObject11());
816
- var InstructionstSubtitle = styled4.p(_templateObject12());
940
+ var InstructionsSubtitle = styled4.p(_templateObject12());
817
941
  var InstructionsDescription = styled4.ul(_templateObject13());
818
942
  var InstructionsDescriptionItem = styled4.li(_templateObject14());
819
943
  var DownloadTitleContainer = styled4.div(_templateObject15());
@@ -822,7 +946,53 @@ var DownloadContainerFlex = styled4.div(_templateObject17());
822
946
  var DownloadAppTitle = styled4.p(_templateObject18());
823
947
  var AppIconsContainer = styled4.div(_templateObject19());
824
948
  var SignInWithYourSelf = function(param) {
825
- var challengeUrl = param.challengeUrl, onSiwysPress = param.onSiwysPress, _param_isCYS = param.isCYS, isCYS = _param_isCYS === void 0 ? false : _param_isCYS;
949
+ var challengeUrlParam = param.challengeUrl, onSiwysPress = param.onSiwysPress, _param_isCYS = param.isCYS, isCYS = _param_isCYS === void 0 ? false : _param_isCYS, _param_createChallengeUrl = param.createChallengeUrl, createChallengeUrl = _param_createChallengeUrl === void 0 ? void 0 : _param_createChallengeUrl, _param_pollForAuthUrl = param.pollForAuthUrl, pollForAuthUrl = _param_pollForAuthUrl === void 0 ? void 0 : _param_pollForAuthUrl, successComponent = param.successComponent;
950
+ var _useState2 = _sliced_to_array(useState2(challengeUrlParam), 2), challengeUrl = _useState2[0], setChallengeUrl = _useState2[1];
951
+ var _useState21 = _sliced_to_array(useState2(""), 2), challengeDid = _useState21[0], setChallengeDid = _useState21[1];
952
+ var _useState22 = _sliced_to_array(useState2(false), 2), isAuthenticated = _useState22[0], setIsAuthenticated = _useState22[1];
953
+ useEffect(function() {
954
+ if (createChallengeUrl) {
955
+ fetch(createChallengeUrl, {
956
+ method: "POST"
957
+ }).then(function(resp) {
958
+ return resp.json();
959
+ }).then(function(json) {
960
+ setChallengeDid(json.challenge);
961
+ setChallengeUrl(json.challengeUrl);
962
+ });
963
+ }
964
+ }, [
965
+ createChallengeUrl
966
+ ]);
967
+ useEffect(function() {
968
+ if (!pollForAuthUrl || !challengeDid || isAuthenticated) return;
969
+ var interval = setInterval(/*#__PURE__*/ _async_to_generator(function() {
970
+ return _ts_generator(this, function(_state) {
971
+ fetch(pollForAuthUrl + "?challenge=".concat(challengeDid)).then(function(resp) {
972
+ if (resp.status === 200) {
973
+ return resp.json();
974
+ }
975
+ return {
976
+ match: false
977
+ };
978
+ }).then(function(json) {
979
+ if (json.match) {
980
+ setIsAuthenticated(json.match);
981
+ }
982
+ }).catch(function() {});
983
+ return [
984
+ 2
985
+ ];
986
+ });
987
+ }), 5e3);
988
+ return function() {
989
+ clearInterval(interval);
990
+ };
991
+ }, [
992
+ challengeDid,
993
+ isAuthenticated,
994
+ pollForAuthUrl
995
+ ]);
826
996
  var redirectToPlayStore = function() {
827
997
  var playStoreURL = "https://play.google.com/store/apps/details?id=id.selfid";
828
998
  window.open(playStoreURL, "_blank");
@@ -831,6 +1001,9 @@ var SignInWithYourSelf = function(param) {
831
1001
  var appStoreURL = "https://apps.apple.com/us/app/self-id/id1663745416";
832
1002
  window.open(appStoreURL, "_blank");
833
1003
  };
1004
+ if (isAuthenticated) {
1005
+ return /* @__PURE__ */ React17.createElement(Wrapper, null, successComponent);
1006
+ }
834
1007
  return /* @__PURE__ */ React17.createElement(Wrapper, null, /* @__PURE__ */ React17.createElement(SignInContainer, null, /* @__PURE__ */ React17.createElement(CircleLogoWhite_default, {
835
1008
  width: "48",
836
1009
  height: "48"
@@ -849,7 +1022,7 @@ var SignInWithYourSelf = function(param) {
849
1022
  colorTheme: "light",
850
1023
  onClick: onSiwysPress,
851
1024
  glow: true
852
- })), /* @__PURE__ */ React17.createElement(InstructionsContainer, null, /* @__PURE__ */ React17.createElement(InstructionsTitle, null, isCYS ? "Connect your SELF\u2122 Guide:" : "Sign in with your SELF\u2122 Guide:"), /* @__PURE__ */ React17.createElement("div", null, /* @__PURE__ */ React17.createElement(InstructionstSubtitle, null, isCYS ? "If you have the SELF\xAE\xA0mobile app:" : "If you are signing in on a device that has the SELF\xAE app installed:"), /* @__PURE__ */ React17.createElement(InstructionsDescription, null, /* @__PURE__ */ React17.createElement(InstructionsDescriptionItem, null, isCYS ? "Use scanning feature in the SELF\xAE app to scan the QR code." : 'Tap the "Sign in with your SELF\u2122" button.'), /* @__PURE__ */ React17.createElement(InstructionsDescriptionItem, null, "Approve the connection request within the SELF\xAE app."))), /* @__PURE__ */ React17.createElement("div", null, /* @__PURE__ */ React17.createElement(InstructionstSubtitle, null, isCYS ? "If you do not have the SELF\xAE mobile app:" : "If you are not signing in on a device that has the SELF\xAE app installed:"), /* @__PURE__ */ React17.createElement(InstructionsDescription, null, /* @__PURE__ */ React17.createElement(InstructionsDescriptionItem, null, isCYS ? "Download and open the SELF\xAE ID app from the App Store." : "Open the SELF\xAE app on the device with the app installed."), /* @__PURE__ */ React17.createElement(InstructionsDescriptionItem, null, "Use the scanning feature in the SELF\xAE app to scan the QR code."), /* @__PURE__ */ React17.createElement(InstructionsDescriptionItem, null, "Approve the connection request within the SELF\xAE app."))), /* @__PURE__ */ React17.createElement("div", null, /* @__PURE__ */ React17.createElement(DownloadTitleContainer, null, /* @__PURE__ */ React17.createElement(InstructionsTitle, null, "Don\u2019t have the"), /* @__PURE__ */ React17.createElement(SelfTextLogoWhite_default, {
1025
+ })), /* @__PURE__ */ React17.createElement(InstructionsContainer, null, /* @__PURE__ */ React17.createElement(InstructionsTitle, null, isCYS ? "Connect your SELF\u2122 Guide:" : "Sign in with your SELF\u2122 Guide:"), /* @__PURE__ */ React17.createElement("div", null, /* @__PURE__ */ React17.createElement(InstructionsSubtitle, null, isCYS ? "If you have the SELF\xAE\xA0mobile app:" : "If you are signing in on a device that has the SELF\xAE app installed:"), /* @__PURE__ */ React17.createElement(InstructionsDescription, null, /* @__PURE__ */ React17.createElement(InstructionsDescriptionItem, null, isCYS ? "Use scanning feature in the SELF\xAE app to scan the QR code." : 'Tap the "Sign in with your SELF\u2122" button.'), /* @__PURE__ */ React17.createElement(InstructionsDescriptionItem, null, "Approve the connection request within the SELF\xAE app."))), /* @__PURE__ */ React17.createElement("div", null, /* @__PURE__ */ React17.createElement(InstructionsSubtitle, null, isCYS ? "If you do not have the SELF\xAE mobile app:" : "If you are not signing in on a device that has the SELF\xAE app installed:"), /* @__PURE__ */ React17.createElement(InstructionsDescription, null, /* @__PURE__ */ React17.createElement(InstructionsDescriptionItem, null, isCYS ? "Download and open the SELF\xAE ID app from the App Store." : "Open the SELF\xAE app on the device with the app installed."), /* @__PURE__ */ React17.createElement(InstructionsDescriptionItem, null, "Use the scanning feature in the SELF\xAE app to scan the QR code."), /* @__PURE__ */ React17.createElement(InstructionsDescriptionItem, null, "Approve the connection request within the SELF\xAE app."))), /* @__PURE__ */ React17.createElement("div", null, /* @__PURE__ */ React17.createElement(DownloadTitleContainer, null, /* @__PURE__ */ React17.createElement(InstructionsTitle, null, "Don\u2019t have the"), /* @__PURE__ */ React17.createElement(SelfTextLogoWhite_default, {
853
1026
  width: "58",
854
1027
  height: "12"
855
1028
  }), /* @__PURE__ */ React17.createElement(InstructionsTitle, null, " app?")), /* @__PURE__ */ React17.createElement(DownloadContainer, null, /* @__PURE__ */ React17.createElement(DownloadContainerFlex, null, /* @__PURE__ */ React17.createElement(DownloadAppTitle, null, "Available to download now:"), /* @__PURE__ */ React17.createElement(AppIconsContainer, null, /* @__PURE__ */ React17.createElement(IconDark_default, {