@mattrglobal/verifier-sdk-web 1.1.1-unstable.170 → 1.1.1-unstable.172
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/lib/verifier-js-no-deps.cjs.js +30 -6
- package/dist/lib/verifier-js-no-deps.cjs.js.map +1 -1
- package/dist/lib/verifier-js.cjs.js +55 -6
- package/dist/lib/verifier-js.cjs.js.map +1 -1
- package/dist/typings/verifier/types/verifier-web-sdk.d.ts +5 -5
- package/dist/verifier-js.development.js +54 -6
- package/dist/verifier-js.development.js.map +1 -1
- package/dist/verifier-js.production.esm.js +1 -1
- package/dist/verifier-js.production.esm.js.map +1 -1
- package/dist/verifier-js.production.js +1 -1
- package/dist/verifier-js.production.js.map +1 -1
- package/package.json +2 -2
|
@@ -705,6 +705,31 @@ function nonEmpty(message2) {
|
|
|
705
705
|
};
|
|
706
706
|
}
|
|
707
707
|
|
|
708
|
+
function url(message2) {
|
|
709
|
+
return {
|
|
710
|
+
kind: "validation",
|
|
711
|
+
type: "url",
|
|
712
|
+
reference: url,
|
|
713
|
+
async: false,
|
|
714
|
+
expects: null,
|
|
715
|
+
requirement: function requirement(input) {
|
|
716
|
+
try {
|
|
717
|
+
new URL(input);
|
|
718
|
+
return true;
|
|
719
|
+
} catch (_unused) {
|
|
720
|
+
return false;
|
|
721
|
+
}
|
|
722
|
+
},
|
|
723
|
+
message: message2,
|
|
724
|
+
"~run": function run(dataset, config2) {
|
|
725
|
+
if (dataset.typed && !this.requirement(dataset.value)) {
|
|
726
|
+
_addIssue(this, "URL", dataset, config2);
|
|
727
|
+
}
|
|
728
|
+
return dataset;
|
|
729
|
+
}
|
|
730
|
+
};
|
|
731
|
+
}
|
|
732
|
+
|
|
708
733
|
function getFallback(schema, dataset, config2) {
|
|
709
734
|
return typeof schema.fallback === "function" ? schema.fallback(dataset, config2) : schema.fallback;
|
|
710
735
|
}
|
|
@@ -1573,7 +1598,7 @@ var MessageEventDataType;
|
|
|
1573
1598
|
const OpenId4vpConfigSameDeviceOptionsValidator = object({
|
|
1574
1599
|
walletProviderId: optional(string()),
|
|
1575
1600
|
mode: literal(exports.Mode.SameDevice),
|
|
1576
|
-
redirectUri: string()
|
|
1601
|
+
redirectUri: pipe(string(), nonEmpty("Must not be empty"), url())
|
|
1577
1602
|
});
|
|
1578
1603
|
|
|
1579
1604
|
const OpenId4vpConfigCrossDeviceOptionsValidator = object({
|
|
@@ -1583,7 +1608,7 @@ const OpenId4vpConfigCrossDeviceOptionsValidator = object({
|
|
|
1583
1608
|
|
|
1584
1609
|
const OpenId4vpConfigAutoDetectOptionsValidator = object({
|
|
1585
1610
|
walletProviderId: optional(string()),
|
|
1586
|
-
redirectUri: string(),
|
|
1611
|
+
redirectUri: pipe(string(), nonEmpty("Must not be empty"), url()),
|
|
1587
1612
|
mode: optional(picklist([ exports.Mode.CrossDevice, exports.Mode.SameDevice ]))
|
|
1588
1613
|
});
|
|
1589
1614
|
|
|
@@ -1628,7 +1653,7 @@ var AbortSessionErrorMessage;
|
|
|
1628
1653
|
})(AbortSessionErrorMessage || (AbortSessionErrorMessage = {}));
|
|
1629
1654
|
|
|
1630
1655
|
const InitializeOptionsValidator = object({
|
|
1631
|
-
apiBaseUrl: pipe(string(), nonEmpty("Must not be empty")),
|
|
1656
|
+
apiBaseUrl: pipe(string(), nonEmpty("Must not be empty"), url()),
|
|
1632
1657
|
applicationId: pipe(string(), nonEmpty("Must not be empty"))
|
|
1633
1658
|
});
|
|
1634
1659
|
|
|
@@ -1653,10 +1678,29 @@ const safeFetch = async (input, init) => {
|
|
|
1653
1678
|
const response = await fetch(input, Object.assign(Object.assign({}, init), {
|
|
1654
1679
|
headers: headers
|
|
1655
1680
|
}));
|
|
1681
|
+
const defaultHttpErrorMessage = `HTTP error, status = ${response.status}`;
|
|
1682
|
+
if (response.status >= 400 && response.status < 500) {
|
|
1683
|
+
try {
|
|
1684
|
+
const errorBody = await response.json();
|
|
1685
|
+
if (typeof (errorBody === null || errorBody === void 0 ? void 0 : errorBody.message) === "string") {
|
|
1686
|
+
return err({
|
|
1687
|
+
type: SafeFetchErrorType.HttpError,
|
|
1688
|
+
message: errorBody.message,
|
|
1689
|
+
status: response.status
|
|
1690
|
+
});
|
|
1691
|
+
}
|
|
1692
|
+
} catch (_a) {
|
|
1693
|
+
return err({
|
|
1694
|
+
type: SafeFetchErrorType.HttpError,
|
|
1695
|
+
message: defaultHttpErrorMessage,
|
|
1696
|
+
status: response.status
|
|
1697
|
+
});
|
|
1698
|
+
}
|
|
1699
|
+
}
|
|
1656
1700
|
if (response.status > 299 || response.status < 200) {
|
|
1657
1701
|
return err({
|
|
1658
1702
|
type: SafeFetchErrorType.HttpError,
|
|
1659
|
-
message:
|
|
1703
|
+
message: defaultHttpErrorMessage,
|
|
1660
1704
|
status: response.status
|
|
1661
1705
|
});
|
|
1662
1706
|
}
|
|
@@ -1680,7 +1724,12 @@ var InitializeErrorMessage;
|
|
|
1680
1724
|
|
|
1681
1725
|
const initialize = options => {
|
|
1682
1726
|
assertType(InitializeOptionsValidator, "Invalid initialize options")(options);
|
|
1683
|
-
|
|
1727
|
+
const {apiBaseUrl: apiBaseUrl} = options;
|
|
1728
|
+
const trimmedApiBaseUrl = apiBaseUrl.trim();
|
|
1729
|
+
initializeOptions = {
|
|
1730
|
+
apiBaseUrl: trimmedApiBaseUrl,
|
|
1731
|
+
applicationId: options.applicationId
|
|
1732
|
+
};
|
|
1684
1733
|
};
|
|
1685
1734
|
|
|
1686
1735
|
const getInitializeOptions = () => initializeOptions;
|
|
@@ -2335,7 +2384,7 @@ const deriveOpenId4vpRedirectUri = openid4vpConfiguration => {
|
|
|
2335
2384
|
detectedMode = isMobileDetect(navigator.userAgent) ? exports.Mode.SameDevice : exports.Mode.CrossDevice;
|
|
2336
2385
|
}
|
|
2337
2386
|
if (detectedMode === exports.Mode.SameDevice && !isType(OpenId4vpConfigCrossDeviceOptionsValidator)(openid4vpConfiguration) && openid4vpConfiguration.redirectUri) {
|
|
2338
|
-
return openid4vpConfiguration.redirectUri;
|
|
2387
|
+
return openid4vpConfiguration.redirectUri.trim();
|
|
2339
2388
|
}
|
|
2340
2389
|
return undefined;
|
|
2341
2390
|
};
|