@yourself_id/siwys-react-js 0.15.0 → 0.16.1-make-on-siwys-press-optional.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.
package/dist/index.d.mts CHANGED
@@ -14,10 +14,11 @@ declare const SiwysButton: React.FC<ButtonProps>;
14
14
 
15
15
  type ThemeProp = "light" | "dark";
16
16
  interface SignInProps {
17
- challengeUrl: string;
18
- onSiwysPress: () => void;
17
+ challengeDID: string;
18
+ challengeBaseUrl?: string;
19
19
  isCYS?: boolean;
20
20
  createChallengeUrl?: string;
21
+ onSiwysPress?: () => void;
21
22
  pollForAuthUrl?: string;
22
23
  successComponent?: React.ReactNode;
23
24
  theme?: ThemeProp;
@@ -33,7 +34,8 @@ interface QRCodeProps {
33
34
  declare const QRCode: React.FC<QRCodeProps>;
34
35
 
35
36
  interface ConnectYourSelfProps {
36
- challengeUrl: string;
37
+ challengeDID: string;
38
+ challengeBaseUrl?: string;
37
39
  onConnectPress: () => void;
38
40
  }
39
41
  declare const ConnectYourSelf: React.FC<ConnectYourSelfProps>;
package/dist/index.d.ts CHANGED
@@ -14,10 +14,11 @@ declare const SiwysButton: React.FC<ButtonProps>;
14
14
 
15
15
  type ThemeProp = "light" | "dark";
16
16
  interface SignInProps {
17
- challengeUrl: string;
18
- onSiwysPress: () => void;
17
+ challengeDID: string;
18
+ challengeBaseUrl?: string;
19
19
  isCYS?: boolean;
20
20
  createChallengeUrl?: string;
21
+ onSiwysPress?: () => void;
21
22
  pollForAuthUrl?: string;
22
23
  successComponent?: React.ReactNode;
23
24
  theme?: ThemeProp;
@@ -33,7 +34,8 @@ interface QRCodeProps {
33
34
  declare const QRCode: React.FC<QRCodeProps>;
34
35
 
35
36
  interface ConnectYourSelfProps {
36
- challengeUrl: string;
37
+ challengeDID: string;
38
+ challengeBaseUrl?: string;
37
39
  onConnectPress: () => void;
38
40
  }
39
41
  declare const ConnectYourSelf: React.FC<ConnectYourSelfProps>;
package/dist/index.js CHANGED
@@ -1059,8 +1059,8 @@ var DownloadContainerFlex = import_styled_components4.default.div(_templateObjec
1059
1059
  var DownloadAppTitle = import_styled_components4.default.p(_templateObject19());
1060
1060
  var AppIconsContainer = import_styled_components4.default.div(_templateObject20());
1061
1061
  var SignInWithYourSelf = function(param) {
1062
- 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, _param_theme = param.theme, theme = _param_theme === void 0 ? "light" : _param_theme;
1063
- var _ref = _sliced_to_array((0, import_react4.useState)(challengeUrlParam), 2), challengeUrl = _ref[0], setChallengeUrl = _ref[1];
1062
+ var challengeDID = param.challengeDID, 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, _param_theme = param.theme, theme = _param_theme === void 0 ? "light" : _param_theme, _param_challengeBaseUrl = param.challengeBaseUrl, challengeBaseUrl = _param_challengeBaseUrl === void 0 ? "" : _param_challengeBaseUrl;
1063
+ var _ref = _sliced_to_array((0, import_react4.useState)(challengeBaseUrl ? "".concat(challengeBaseUrl, "/challenge?challenge=").concat(challengeDID || "") : "https://www.selfid.link/challenge?challenge=".concat(challengeDID || "")), 2), challengeUrl = _ref[0], setChallengeUrl = _ref[1];
1064
1064
  var _ref1 = _sliced_to_array((0, import_react4.useState)(""), 2), challengeDid = _ref1[0], setChallengeDid = _ref1[1];
1065
1065
  var _ref2 = _sliced_to_array((0, import_react4.useState)(false), 2), isAuthenticated = _ref2[0], setIsAuthenticated = _ref2[1];
1066
1066
  (0, import_react4.useEffect)(function() {
@@ -1114,6 +1114,16 @@ var SignInWithYourSelf = function(param) {
1114
1114
  var appStoreURL = "https://apps.apple.com/us/app/self-id/id1663745416";
1115
1115
  window.open(appStoreURL, "_blank");
1116
1116
  };
1117
+ var defaultSiwysClick = (0, import_react4.useCallback)(function() {
1118
+ if (onSiwysPress) {
1119
+ onSiwysPress();
1120
+ return;
1121
+ }
1122
+ window.open(challengeUrl, "_blank");
1123
+ }, [
1124
+ challengeUrl,
1125
+ onSiwysPress
1126
+ ]);
1117
1127
  if (isAuthenticated) {
1118
1128
  return /* @__PURE__ */ import_react4.default.createElement(Wrapper, null, successComponent);
1119
1129
  }
@@ -1139,11 +1149,11 @@ var SignInWithYourSelf = function(param) {
1139
1149
  level: "H"
1140
1150
  })), isCYS ? /* @__PURE__ */ import_react4.default.createElement(CysButton, {
1141
1151
  colorTheme: theme,
1142
- onClick: onSiwysPress,
1152
+ onClick: defaultSiwysClick,
1143
1153
  glow: true
1144
1154
  }) : /* @__PURE__ */ import_react4.default.createElement(SiwysButton, {
1145
1155
  colorTheme: theme,
1146
- onClick: onSiwysPress,
1156
+ onClick: defaultSiwysClick,
1147
1157
  glow: true
1148
1158
  })), /* @__PURE__ */ import_react4.default.createElement(InstructionsContainer, null, /* @__PURE__ */ import_react4.default.createElement(InstructionsTitle, {
1149
1159
  $theme: theme
@@ -1191,9 +1201,10 @@ var SignInWithYourSelf_default = SignInWithYourSelf;
1191
1201
  // src/components/connect/ConnectYourSelf.tsx
1192
1202
  var import_react5 = __toESM(require("react"));
1193
1203
  var ConnectYourSelf = function(param) {
1194
- var challengeUrl = param.challengeUrl, onConnectPress = param.onConnectPress;
1204
+ var challengeBaseUrl = param.challengeBaseUrl, challengeDID = param.challengeDID, onConnectPress = param.onConnectPress;
1195
1205
  return /* @__PURE__ */ import_react5.default.createElement(SignInWithYourSelf_default, {
1196
- challengeUrl: challengeUrl,
1206
+ challengeBaseUrl: challengeBaseUrl,
1207
+ challengeDID: challengeDID,
1197
1208
  onSiwysPress: onConnectPress,
1198
1209
  isCYS: true
1199
1210
  });