@yourself_id/siwys-react-js 0.5.1-SAPP-159.3 → 0.5.1-SAPP-159.6

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.d.mts CHANGED
@@ -16,6 +16,9 @@ interface SignInProps {
16
16
  challengeUrl: string;
17
17
  onSiwysPress: () => void;
18
18
  isCYS?: boolean;
19
+ createChallengeUrl?: string;
20
+ pollForAuthUrl?: string;
21
+ successComponent?: React.ReactNode;
19
22
  }
20
23
  declare const SignInWithYourSelf: React.FC<SignInProps>;
21
24
 
package/dist/index.d.ts CHANGED
@@ -16,6 +16,9 @@ interface SignInProps {
16
16
  challengeUrl: string;
17
17
  onSiwysPress: () => void;
18
18
  isCYS?: boolean;
19
+ createChallengeUrl?: string;
20
+ pollForAuthUrl?: string;
21
+ successComponent?: React.ReactNode;
19
22
  }
20
23
  declare const SignInWithYourSelf: React.FC<SignInProps>;
21
24
 
package/dist/index.js 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, {
@@ -156,6 +185,101 @@ function _unsupported_iterable_to_array(o, minLen) {
156
185
  if (n === "Map" || n === "Set") return Array.from(n);
157
186
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
158
187
  }
188
+ function _ts_generator(thisArg, body) {
189
+ var f, y, t, g, _ = {
190
+ label: 0,
191
+ sent: function() {
192
+ if (t[0] & 1) throw t[1];
193
+ return t[1];
194
+ },
195
+ trys: [],
196
+ ops: []
197
+ };
198
+ return g = {
199
+ next: verb(0),
200
+ "throw": verb(1),
201
+ "return": verb(2)
202
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
203
+ return this;
204
+ }), g;
205
+ function verb(n) {
206
+ return function(v) {
207
+ return step([
208
+ n,
209
+ v
210
+ ]);
211
+ };
212
+ }
213
+ function step(op) {
214
+ if (f) throw new TypeError("Generator is already executing.");
215
+ while(_)try {
216
+ 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;
217
+ if (y = 0, t) op = [
218
+ op[0] & 2,
219
+ t.value
220
+ ];
221
+ switch(op[0]){
222
+ case 0:
223
+ case 1:
224
+ t = op;
225
+ break;
226
+ case 4:
227
+ _.label++;
228
+ return {
229
+ value: op[1],
230
+ done: false
231
+ };
232
+ case 5:
233
+ _.label++;
234
+ y = op[1];
235
+ op = [
236
+ 0
237
+ ];
238
+ continue;
239
+ case 7:
240
+ op = _.ops.pop();
241
+ _.trys.pop();
242
+ continue;
243
+ default:
244
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
245
+ _ = 0;
246
+ continue;
247
+ }
248
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
249
+ _.label = op[1];
250
+ break;
251
+ }
252
+ if (op[0] === 6 && _.label < t[1]) {
253
+ _.label = t[1];
254
+ t = op;
255
+ break;
256
+ }
257
+ if (t && _.label < t[2]) {
258
+ _.label = t[2];
259
+ _.ops.push(op);
260
+ break;
261
+ }
262
+ if (t[2]) _.ops.pop();
263
+ _.trys.pop();
264
+ continue;
265
+ }
266
+ op = body.call(thisArg, _);
267
+ } catch (e) {
268
+ op = [
269
+ 6,
270
+ e
271
+ ];
272
+ y = 0;
273
+ } finally{
274
+ f = t = 0;
275
+ }
276
+ if (op[0] & 5) throw op[1];
277
+ return {
278
+ value: op[0] ? op[1] : void 0,
279
+ done: true
280
+ };
281
+ }
282
+ }
159
283
  function _templateObject() {
160
284
  var data = _tagged_template_literal([
161
285
  "\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 ",
@@ -207,7 +331,7 @@ function _templateObject4() {
207
331
  }
208
332
  function _templateObject5() {
209
333
  var data = _tagged_template_literal([
210
- "\n position: relative;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n gap: 20%;\n padding-bottom: 40px;\n z-index: 10;\n\n @media (min-width: 1024px) {\n flex-direction: row;\n gap: 196px;\n padding-bottom: 0px;\n }\n"
334
+ "\n position: relative;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n gap: 20%;\n padding-bottom: 40px;\n z-index: 10;\n margin-right: 16px;\n margin-left: 16px;\n @media (min-width: 1024px) {\n flex-direction: row;\n gap: 196px;\n padding-bottom: 0px;\n margin-right: 0px;\n margin-left: 0px;\n }\n"
211
335
  ]);
212
336
  _templateObject5 = function _templateObject() {
213
337
  return data;
@@ -252,7 +376,7 @@ function _templateObject9() {
252
376
  }
253
377
  function _templateObject10() {
254
378
  var data = _tagged_template_literal([
255
- "\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n gap: 24px;\n margin-right: 24px;\n margin-left: 24px;\n @media (min-width: 1024px) {\n margin-right: 0px;\n margin-left: 0px;\n }\n"
379
+ "\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n gap: 24px;\n"
256
380
  ]);
257
381
  _templateObject10 = function _templateObject() {
258
382
  return data;
@@ -306,7 +430,7 @@ function _templateObject15() {
306
430
  }
307
431
  function _templateObject16() {
308
432
  var data = _tagged_template_literal([
309
- "\n display: flex;\n flex-direction: row;\n background: #121114;\n border: 1px solid #3d414c;\n border-radius: 8px;\n padding: 20px;\n gap: 20px;\n width: 100%;\n box-sizing: border-box;\n @media (min-width: 1024px) {\n flex-direction: column;\n padding-left: 53px;\n padding-right: 53px;\n max-width: 446px;\n }\n }\n"
433
+ "\n display: flex;\n flex-direction: column;\n width: 100%;\n @media (min-width: 1024px) {\n width: auto;\n }\n"
310
434
  ]);
311
435
  _templateObject16 = function _templateObject() {
312
436
  return data;
@@ -315,7 +439,7 @@ function _templateObject16() {
315
439
  }
316
440
  function _templateObject17() {
317
441
  var data = _tagged_template_literal([
318
- "\n display: flex;\n flex-direction: column;\n justify-content: space-between;\n width: 100%;\n gap: 16px;\n @media (min-width: 1024px) {\n flex-direction: row;\n align-items: center;\n }\n"
442
+ "\n display: flex;\n flex-direction: column;\n background: #121114;\n border: 1px solid #3d414c;\n border-radius: 8px;\n padding: 20px;\n gap: 20px;\n width: 100%;\n box-sizing: border-box;\n @media (min-width: 1024px) {\n padding-left: 53px;\n padding-right: 53px;\n max-width: 446px;\n }\n }\n"
319
443
  ]);
320
444
  _templateObject17 = function _templateObject() {
321
445
  return data;
@@ -324,7 +448,7 @@ function _templateObject17() {
324
448
  }
325
449
  function _templateObject18() {
326
450
  var data = _tagged_template_literal([
327
- '\n font-family: "Inter", sans-serif;\n font-weight: 500;\n margin-top: 0px;\n margin-bottom: 0px;\n font-size: 15px;\n line-height: 126%;\n letter-spacing: 0.025em;\n max-width: 128px;\n color: #c4ccd4;\n'
451
+ "\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n width: 100%;\n gap: 8px;\n @media (min-width: 1024px) {\n gap: 16px;\n align-items: center;\n }\n"
328
452
  ]);
329
453
  _templateObject18 = function _templateObject() {
330
454
  return data;
@@ -333,13 +457,22 @@ function _templateObject18() {
333
457
  }
334
458
  function _templateObject19() {
335
459
  var data = _tagged_template_literal([
336
- "\n display: flex;\n flex-direction: column;\n gap: 16px;\n @media (min-width: 1024px) {\n flex-direction: row;\n }\n"
460
+ '\n font-family: "Inter", sans-serif;\n font-weight: 500;\n margin-top: 0px;\n margin-bottom: 0px;\n font-size: 15px;\n line-height: 126%;\n letter-spacing: 0.025em;\n max-width: 128px;\n color: #c4ccd4;\n'
337
461
  ]);
338
462
  _templateObject19 = function _templateObject() {
339
463
  return data;
340
464
  };
341
465
  return data;
342
466
  }
467
+ function _templateObject20() {
468
+ var data = _tagged_template_literal([
469
+ "\n display: flex;\n flex-direction: row;\n gap: 8px;\n @media (min-width: 1024px) {\n gap: 16px;\n }\n"
470
+ ]);
471
+ _templateObject20 = function _templateObject() {
472
+ return data;
473
+ };
474
+ return data;
475
+ }
343
476
  var __create = Object.create;
344
477
  var __defProp = Object.defineProperty;
345
478
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -899,12 +1032,59 @@ var InstructionsSubtitle = import_styled_components4.default.p(_templateObject12
899
1032
  var InstructionsDescription = import_styled_components4.default.ul(_templateObject13());
900
1033
  var InstructionsDescriptionItem = import_styled_components4.default.li(_templateObject14());
901
1034
  var DownloadTitleContainer = import_styled_components4.default.div(_templateObject15());
902
- var DownloadContainer = import_styled_components4.default.div(_templateObject16());
903
- var DownloadContainerFlex = import_styled_components4.default.div(_templateObject17());
904
- var DownloadAppTitle = import_styled_components4.default.p(_templateObject18());
905
- var AppIconsContainer = import_styled_components4.default.div(_templateObject19());
1035
+ var ParentDownloadContainer = import_styled_components4.default.div(_templateObject16());
1036
+ var DownloadContainer = import_styled_components4.default.div(_templateObject17());
1037
+ var DownloadContainerFlex = import_styled_components4.default.div(_templateObject18());
1038
+ var DownloadAppTitle = import_styled_components4.default.p(_templateObject19());
1039
+ var AppIconsContainer = import_styled_components4.default.div(_templateObject20());
906
1040
  var SignInWithYourSelf = function(param) {
907
- var challengeUrl = param.challengeUrl, onSiwysPress = param.onSiwysPress, _param_isCYS = param.isCYS, isCYS = _param_isCYS === void 0 ? false : _param_isCYS;
1041
+ 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;
1042
+ var _ref = _sliced_to_array((0, import_react4.useState)(challengeUrlParam), 2), challengeUrl = _ref[0], setChallengeUrl = _ref[1];
1043
+ var _ref1 = _sliced_to_array((0, import_react4.useState)(""), 2), challengeDid = _ref1[0], setChallengeDid = _ref1[1];
1044
+ var _ref2 = _sliced_to_array((0, import_react4.useState)(false), 2), isAuthenticated = _ref2[0], setIsAuthenticated = _ref2[1];
1045
+ (0, import_react4.useEffect)(function() {
1046
+ if (createChallengeUrl) {
1047
+ fetch(createChallengeUrl, {
1048
+ method: "POST"
1049
+ }).then(function(resp) {
1050
+ return resp.json();
1051
+ }).then(function(json) {
1052
+ setChallengeDid(json.challenge);
1053
+ setChallengeUrl(json.challengeUrl);
1054
+ });
1055
+ }
1056
+ }, [
1057
+ createChallengeUrl
1058
+ ]);
1059
+ (0, import_react4.useEffect)(function() {
1060
+ if (!pollForAuthUrl || !challengeDid || isAuthenticated) return;
1061
+ var interval = setInterval(/*#__PURE__*/ _async_to_generator(function() {
1062
+ return _ts_generator(this, function(_state) {
1063
+ fetch(pollForAuthUrl + "?challenge=".concat(challengeDid)).then(function(resp) {
1064
+ if (resp.status === 200) {
1065
+ return resp.json();
1066
+ }
1067
+ return {
1068
+ match: false
1069
+ };
1070
+ }).then(function(json) {
1071
+ if (json.match) {
1072
+ setIsAuthenticated(json.match);
1073
+ }
1074
+ }).catch(function() {});
1075
+ return [
1076
+ 2
1077
+ ];
1078
+ });
1079
+ }), 5e3);
1080
+ return function() {
1081
+ clearInterval(interval);
1082
+ };
1083
+ }, [
1084
+ challengeDid,
1085
+ isAuthenticated,
1086
+ pollForAuthUrl
1087
+ ]);
908
1088
  var redirectToPlayStore = function() {
909
1089
  var playStoreURL = "https://play.google.com/store/apps/details?id=id.selfid";
910
1090
  window.open(playStoreURL, "_blank");
@@ -913,6 +1093,9 @@ var SignInWithYourSelf = function(param) {
913
1093
  var appStoreURL = "https://apps.apple.com/us/app/self-id/id1663745416";
914
1094
  window.open(appStoreURL, "_blank");
915
1095
  };
1096
+ if (isAuthenticated) {
1097
+ return /* @__PURE__ */ import_react4.default.createElement(Wrapper, null, successComponent);
1098
+ }
916
1099
  return /* @__PURE__ */ import_react4.default.createElement(Wrapper, null, /* @__PURE__ */ import_react4.default.createElement(SignInContainer, null, /* @__PURE__ */ import_react4.default.createElement(CircleLogoWhite_default, {
917
1100
  width: "48",
918
1101
  height: "48"
@@ -931,7 +1114,7 @@ var SignInWithYourSelf = function(param) {
931
1114
  colorTheme: "light",
932
1115
  onClick: onSiwysPress,
933
1116
  glow: true
934
- })), /* @__PURE__ */ import_react4.default.createElement(InstructionsContainer, null, /* @__PURE__ */ import_react4.default.createElement(InstructionsTitle, null, isCYS ? "Connect your SELF\u2122 Guide:" : "Sign in with your SELF\u2122 Guide:"), /* @__PURE__ */ import_react4.default.createElement("div", null, /* @__PURE__ */ import_react4.default.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__ */ import_react4.default.createElement(InstructionsDescription, null, /* @__PURE__ */ import_react4.default.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__ */ import_react4.default.createElement(InstructionsDescriptionItem, null, "Approve the connection request within the SELF\xAE app."))), /* @__PURE__ */ import_react4.default.createElement("div", null, /* @__PURE__ */ import_react4.default.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__ */ import_react4.default.createElement(InstructionsDescription, null, /* @__PURE__ */ import_react4.default.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__ */ import_react4.default.createElement(InstructionsDescriptionItem, null, "Use the scanning feature in the SELF\xAE app to scan the QR code."), /* @__PURE__ */ import_react4.default.createElement(InstructionsDescriptionItem, null, "Approve the connection request within the SELF\xAE app."))), /* @__PURE__ */ import_react4.default.createElement("div", null, /* @__PURE__ */ import_react4.default.createElement(DownloadTitleContainer, null, /* @__PURE__ */ import_react4.default.createElement(InstructionsTitle, null, "Don\u2019t have the"), /* @__PURE__ */ import_react4.default.createElement(SelfTextLogoWhite_default, {
1117
+ })), /* @__PURE__ */ import_react4.default.createElement(InstructionsContainer, null, /* @__PURE__ */ import_react4.default.createElement(InstructionsTitle, null, isCYS ? "Connect your SELF\u2122 Guide:" : "Sign in with your SELF\u2122 Guide:"), /* @__PURE__ */ import_react4.default.createElement("div", null, /* @__PURE__ */ import_react4.default.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__ */ import_react4.default.createElement(InstructionsDescription, null, /* @__PURE__ */ import_react4.default.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__ */ import_react4.default.createElement(InstructionsDescriptionItem, null, "Approve the connection request within the SELF\xAE app."))), /* @__PURE__ */ import_react4.default.createElement("div", null, /* @__PURE__ */ import_react4.default.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__ */ import_react4.default.createElement(InstructionsDescription, null, /* @__PURE__ */ import_react4.default.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__ */ import_react4.default.createElement(InstructionsDescriptionItem, null, "Use the scanning feature in the SELF\xAE app to scan the QR code."), /* @__PURE__ */ import_react4.default.createElement(InstructionsDescriptionItem, null, "Approve the connection request within the SELF\xAE app."))), /* @__PURE__ */ import_react4.default.createElement(ParentDownloadContainer, null, /* @__PURE__ */ import_react4.default.createElement(DownloadTitleContainer, null, /* @__PURE__ */ import_react4.default.createElement(InstructionsTitle, null, "Don\u2019t have the"), /* @__PURE__ */ import_react4.default.createElement(SelfTextLogoWhite_default, {
935
1118
  width: "58",
936
1119
  height: "12"
937
1120
  }), /* @__PURE__ */ import_react4.default.createElement(InstructionsTitle, null, " app?")), /* @__PURE__ */ import_react4.default.createElement(DownloadContainer, null, /* @__PURE__ */ import_react4.default.createElement(DownloadContainerFlex, null, /* @__PURE__ */ import_react4.default.createElement(DownloadAppTitle, null, "Available to download now:"), /* @__PURE__ */ import_react4.default.createElement(AppIconsContainer, null, /* @__PURE__ */ import_react4.default.createElement(IconDark_default, {