Skip to content

Commit e9e6173

Browse files
author
Caleb Jacob
authored
Merge pull request #164 from NearSocial/release-2.5.4
Release 2.5.4
2 parents b1e7886 + 9ccd064 commit e9e6173

File tree

6 files changed

+47
-7
lines changed

6 files changed

+47
-7
lines changed

CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
11
# Changelog
22

3+
## 2.5.4
4+
5+
- Added optional `commitModalBypass` feature config. When the `<CommitButton />` component is used inside of a widget with a matching `src` prop, the `CommitModal` will be bypassed and `onCommit()` will be called instantly when the button is clicked. If for some reason the requested transaction is invalid, the `CommitModal` will still appear to show an error message to the user. View example below to see configuration options.
6+
- Added optional `enableWidgetSrcWithCodeOverride` boolean feature flag. This is helpful to enable when developing in a local environment when using a `redirectMap` in combination with the new `commitModalBypass` feature. With this enabled, any widget that is overridden via `redirectMap` can still reference its `src` prop to respect your `commitModalBypass` config.
7+
8+
```js
9+
initNear({
10+
features: {
11+
commitModalBypass: {
12+
authorIds: ["mob.near", "root.near"], // Bypass for all widgets published by these accounts
13+
sources: [
14+
"cool.near/widget/CoolComponent",
15+
"awesome.near/widget/AwesomeComponent",
16+
], // Bypass for specific components
17+
},
18+
enableWidgetSrcWithCodeOverride: isLocalEnvironment,
19+
},
20+
});
21+
```
22+
- Add string type check to the `href` property on the `a` tag. Reported by BrunoModificato from OtterSec.
23+
324
## 2.5.3
425

526
- FIX: Remove `cachedPropery` from `elliptic.utils`. Reported by BrunoModificato from OtterSec.

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "near-social-vm",
3-
"version": "2.5.3",
3+
"version": "2.5.4",
44
"description": "Near Social VM",
55
"main": "dist/index.js",
66
"files": [

src/lib/components/Commit.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,26 @@ export const CommitModal = (props) => {
162162
}
163163
}
164164

165-
const show =
165+
const bypassConfig = {
166+
authorIds: near?.features?.commitModalBypass?.authorIds ?? [],
167+
sources: near?.features?.commitModalBypass?.sources ?? [],
168+
};
169+
const [widgetSrcAccountId] = (widgetSrc ?? "").split("/");
170+
const matchesModalBypassConfig =
171+
(!!widgetSrcAccountId &&
172+
bypassConfig.authorIds.indexOf(widgetSrcAccountId) > -1) ||
173+
(!!widgetSrc && bypassConfig.sources.indexOf(widgetSrc.split("@")[0]) > -1);
174+
const shouldBypassModal = !cantCommit && matchesModalBypassConfig;
175+
176+
const isReadyToCommit =
166177
!!commit && showIntent && !asyncCommitStarted && writePermission !== null;
178+
const show = isReadyToCommit && !shouldBypassModal;
179+
180+
useEffect(() => {
181+
if (isReadyToCommit && shouldBypassModal && !commitInProgress) {
182+
onCommit();
183+
}
184+
}, [isReadyToCommit, shouldBypassModal, commitInProgress]);
167185

168186
return (
169187
<Modal size="xl" centered scrollable show={show} onHide={onCancel}>

src/lib/components/Widget.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export const Widget = React.forwardRef((props, forwardedRef) => {
102102
setSrc(src);
103103
} else if (srcOrCode?.code) {
104104
setCode(srcOrCode.code);
105-
setSrc(null);
105+
setSrc(near?.features?.enableWidgetSrcWithCodeOverride ? propsSrc : null);
106106
}
107107
}, [near, srcOrCode, nonce]);
108108

src/lib/vm/vm.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -611,9 +611,10 @@ class VmStack {
611611
} else if (basicElement === "a") {
612612
Object.entries(attributes).forEach(([name, value]) => {
613613
if (name.toLowerCase() === "href") {
614-
attributes[name] = isValidAttribute("a", "href", value)
615-
? value
616-
: "about:blank";
614+
attributes[name] =
615+
isString(value) && isValidAttribute("a", "href", value)
616+
? value
617+
: "about:blank";
617618
}
618619
});
619620
} else if (element === "Widget") {

0 commit comments

Comments
 (0)