Skip to content

Commit

Permalink
Merge pull request #164 from NearSocial/release-2.5.4
Browse files Browse the repository at this point in the history
Release 2.5.4
  • Loading branch information
calebjacob authored Jan 4, 2024
2 parents b1e7886 + 9ccd064 commit e9e6173
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 7 deletions.
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
# Changelog

## 2.5.4

- 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.
- 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.

```js
initNear({
features: {
commitModalBypass: {
authorIds: ["mob.near", "root.near"], // Bypass for all widgets published by these accounts
sources: [
"cool.near/widget/CoolComponent",
"awesome.near/widget/AwesomeComponent",
], // Bypass for specific components
},
enableWidgetSrcWithCodeOverride: isLocalEnvironment,
},
});
```
- Add string type check to the `href` property on the `a` tag. Reported by BrunoModificato from OtterSec.

## 2.5.3

- FIX: Remove `cachedPropery` from `elliptic.utils`. Reported by BrunoModificato from OtterSec.
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "near-social-vm",
"version": "2.5.3",
"version": "2.5.4",
"description": "Near Social VM",
"main": "dist/index.js",
"files": [
Expand Down
20 changes: 19 additions & 1 deletion src/lib/components/Commit.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,26 @@ export const CommitModal = (props) => {
}
}

const show =
const bypassConfig = {
authorIds: near?.features?.commitModalBypass?.authorIds ?? [],
sources: near?.features?.commitModalBypass?.sources ?? [],
};
const [widgetSrcAccountId] = (widgetSrc ?? "").split("/");
const matchesModalBypassConfig =
(!!widgetSrcAccountId &&
bypassConfig.authorIds.indexOf(widgetSrcAccountId) > -1) ||
(!!widgetSrc && bypassConfig.sources.indexOf(widgetSrc.split("@")[0]) > -1);
const shouldBypassModal = !cantCommit && matchesModalBypassConfig;

const isReadyToCommit =
!!commit && showIntent && !asyncCommitStarted && writePermission !== null;
const show = isReadyToCommit && !shouldBypassModal;

useEffect(() => {
if (isReadyToCommit && shouldBypassModal && !commitInProgress) {
onCommit();
}
}, [isReadyToCommit, shouldBypassModal, commitInProgress]);

return (
<Modal size="xl" centered scrollable show={show} onHide={onCancel}>
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/Widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export const Widget = React.forwardRef((props, forwardedRef) => {
setSrc(src);
} else if (srcOrCode?.code) {
setCode(srcOrCode.code);
setSrc(null);
setSrc(near?.features?.enableWidgetSrcWithCodeOverride ? propsSrc : null);
}
}, [near, srcOrCode, nonce]);

Expand Down
7 changes: 4 additions & 3 deletions src/lib/vm/vm.js
Original file line number Diff line number Diff line change
Expand Up @@ -611,9 +611,10 @@ class VmStack {
} else if (basicElement === "a") {
Object.entries(attributes).forEach(([name, value]) => {
if (name.toLowerCase() === "href") {
attributes[name] = isValidAttribute("a", "href", value)
? value
: "about:blank";
attributes[name] =
isString(value) && isValidAttribute("a", "href", value)
? value
: "about:blank";
}
});
} else if (element === "Widget") {
Expand Down

0 comments on commit e9e6173

Please sign in to comment.