@yourself_id/siwys-react-js 0.5.1-SAPP-159.3 → 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.d.mts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +174 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +175 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
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 ",
|
|
@@ -904,7 +1028,53 @@ var DownloadContainerFlex = import_styled_components4.default.div(_templateObjec
|
|
|
904
1028
|
var DownloadAppTitle = import_styled_components4.default.p(_templateObject18());
|
|
905
1029
|
var AppIconsContainer = import_styled_components4.default.div(_templateObject19());
|
|
906
1030
|
var SignInWithYourSelf = function(param) {
|
|
907
|
-
var
|
|
1031
|
+
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;
|
|
1032
|
+
var _ref = _sliced_to_array((0, import_react4.useState)(challengeUrlParam), 2), challengeUrl = _ref[0], setChallengeUrl = _ref[1];
|
|
1033
|
+
var _ref1 = _sliced_to_array((0, import_react4.useState)(""), 2), challengeDid = _ref1[0], setChallengeDid = _ref1[1];
|
|
1034
|
+
var _ref2 = _sliced_to_array((0, import_react4.useState)(false), 2), isAuthenticated = _ref2[0], setIsAuthenticated = _ref2[1];
|
|
1035
|
+
(0, import_react4.useEffect)(function() {
|
|
1036
|
+
if (createChallengeUrl) {
|
|
1037
|
+
fetch(createChallengeUrl, {
|
|
1038
|
+
method: "POST"
|
|
1039
|
+
}).then(function(resp) {
|
|
1040
|
+
return resp.json();
|
|
1041
|
+
}).then(function(json) {
|
|
1042
|
+
setChallengeDid(json.challenge);
|
|
1043
|
+
setChallengeUrl(json.challengeUrl);
|
|
1044
|
+
});
|
|
1045
|
+
}
|
|
1046
|
+
}, [
|
|
1047
|
+
createChallengeUrl
|
|
1048
|
+
]);
|
|
1049
|
+
(0, import_react4.useEffect)(function() {
|
|
1050
|
+
if (!pollForAuthUrl || !challengeDid || isAuthenticated) return;
|
|
1051
|
+
var interval = setInterval(/*#__PURE__*/ _async_to_generator(function() {
|
|
1052
|
+
return _ts_generator(this, function(_state) {
|
|
1053
|
+
fetch(pollForAuthUrl + "?challenge=".concat(challengeDid)).then(function(resp) {
|
|
1054
|
+
if (resp.status === 200) {
|
|
1055
|
+
return resp.json();
|
|
1056
|
+
}
|
|
1057
|
+
return {
|
|
1058
|
+
match: false
|
|
1059
|
+
};
|
|
1060
|
+
}).then(function(json) {
|
|
1061
|
+
if (json.match) {
|
|
1062
|
+
setIsAuthenticated(json.match);
|
|
1063
|
+
}
|
|
1064
|
+
}).catch(function() {});
|
|
1065
|
+
return [
|
|
1066
|
+
2
|
|
1067
|
+
];
|
|
1068
|
+
});
|
|
1069
|
+
}), 5e3);
|
|
1070
|
+
return function() {
|
|
1071
|
+
clearInterval(interval);
|
|
1072
|
+
};
|
|
1073
|
+
}, [
|
|
1074
|
+
challengeDid,
|
|
1075
|
+
isAuthenticated,
|
|
1076
|
+
pollForAuthUrl
|
|
1077
|
+
]);
|
|
908
1078
|
var redirectToPlayStore = function() {
|
|
909
1079
|
var playStoreURL = "https://play.google.com/store/apps/details?id=id.selfid";
|
|
910
1080
|
window.open(playStoreURL, "_blank");
|
|
@@ -913,6 +1083,9 @@ var SignInWithYourSelf = function(param) {
|
|
|
913
1083
|
var appStoreURL = "https://apps.apple.com/us/app/self-id/id1663745416";
|
|
914
1084
|
window.open(appStoreURL, "_blank");
|
|
915
1085
|
};
|
|
1086
|
+
if (isAuthenticated) {
|
|
1087
|
+
return /* @__PURE__ */ import_react4.default.createElement(Wrapper, null, successComponent);
|
|
1088
|
+
}
|
|
916
1089
|
return /* @__PURE__ */ import_react4.default.createElement(Wrapper, null, /* @__PURE__ */ import_react4.default.createElement(SignInContainer, null, /* @__PURE__ */ import_react4.default.createElement(CircleLogoWhite_default, {
|
|
917
1090
|
width: "48",
|
|
918
1091
|
height: "48"
|