Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
"scratch-paint": "https://codeload.github.com/MistWarp/scratch-paint/tar.gz/52db8c8ede05ab2f925148ec1e783ea39b9dfca0",
"scratch-render": "https://codeload.github.com/MistWarp/scratch-render/tar.gz/ce8e30cb75fcba486d20a453bd51127f5a145a1a",
"scratch-render-fonts": "https://codeload.github.com/PenguinMod/penguinmod-render-fonts/tar.gz/4dda62c707f64505266aa62f7a6cc84f0e5812fd",
"scratch-vm": "https://codeload.github.com/MistWarp/scratch-vm/tar.gz/4e8113e2546ff406644f4099f99ef5a7e85aa4c5",
"scratch-vm": "https://codeload.github.com/MistWarp/scratch-vm/tar.gz/c775381a55c13029d15ae7fe87fdae24a6998cf9",
"scratchblocks": "3.7.1",
"sha.js": "^2.4.12",
"to-style": "1.3.3",
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 8 additions & 17 deletions src/community/components/RoturConsentModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const groupScopes = scopes => {
// it can request an action but never approve one on the user's behalf.
const RoturConsentModal = ({type, data, onAllow, onBlock, onDeny, onShareThis, onShareAll, onShareNo}) => {
const {text: communityText} = useCommunityText();
const payment = type === 'confirm' && data.confirmation && data.confirmation.type === 'payment';
const projectName = data.name || communityText('This project');
if (type === 'share') {
return (
Expand Down Expand Up @@ -52,11 +51,7 @@ const RoturConsentModal = ({type, data, onAllow, onBlock, onDeny, onShareThis, o
}
const groups = groupScopes(data.scopes);
let confirmLead = null;
if (payment) {
confirmLead = communityText('Allow payment of {value1} credits to @{value2}?', {
value1: data.confirmation.amount, value2: data.confirmation.recipient
});
} else if (type === 'confirm') {
if (type === 'confirm') {
confirmLead = data.username ?
communityText('Allow this project to {value1} as @{value2}?', {value1: data.label, value2: data.username}) :
communityText('Allow this project to {value1}?', {value1: data.label});
Expand All @@ -65,7 +60,7 @@ const RoturConsentModal = ({type, data, onAllow, onBlock, onDeny, onShareThis, o
<Modal
icon={ShieldCheck}
title={type === 'confirm' ?
(payment ? communityText('Confirm payment') : communityText('Confirm account action')) :
communityText('Confirm account action') :
communityText('Connect to Rotur')}
onDismiss={onDeny}
actions={
Expand All @@ -78,23 +73,19 @@ const RoturConsentModal = ({type, data, onAllow, onBlock, onDeny, onShareThis, o
variant="primary"
onClick={onAllow}
>
{payment ?
communityText('Allow payment') :
(type === 'confirm' ? communityText('Allow once') : communityText('Connect'))}
{type === 'confirm' ? communityText('Allow once') : communityText('Connect')}
</Button>
</React.Fragment>
}
>
{type === 'confirm' ? (
<React.Fragment>
<p className={styles.lead}>{confirmLead}</p>
{payment ? null : (
<p className={styles.lead}>
{communityText(
'This action will happen once. It does not give the project ongoing approval.'
)}
</p>
)}
<p className={styles.lead}>
{communityText(
'This action will happen once. It does not give the project ongoing approval.'
)}
</p>
</React.Fragment>
) : (
<React.Fragment>
Expand Down
51 changes: 21 additions & 30 deletions src/community/translations/_sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@
"src/community/components/GameMarketplaceModal.jsx:224",
"src/community/components/ProjectInfoPanel.jsx:382",
"src/community/components/ReportModal.jsx:106",
"src/community/components/RoturConsentModal.jsx:75",
"src/community/components/RoturConsentModal.jsx:70",
"src/community/components/SocialPost.jsx:218",
"src/community/components/SocialPost.jsx:264",
"src/community/components/ui/ConfirmModal.jsx:22",
Expand Down Expand Up @@ -792,8 +792,8 @@
],
"Block this project": [
"src/community/components/GameMarketplaceModal.jsx:179",
"src/community/components/RoturConsentModal.jsx:33",
"src/community/components/RoturConsentModal.jsx:73"
"src/community/components/RoturConsentModal.jsx:32",
"src/community/components/RoturConsentModal.jsx:68"
],
"Loading shop…": [
"src/community/components/GameMarketplaceModal.jsx:182"
Expand Down Expand Up @@ -2167,65 +2167,56 @@
"src/community/components/ReportModal.jsx:157"
],
"This project": [
"src/community/components/RoturConsentModal.jsx:24"
"src/community/components/RoturConsentModal.jsx:23"
],
"Show activity on your profile?": [
"src/community/components/RoturConsentModal.jsx:29"
"src/community/components/RoturConsentModal.jsx:28"
],
"Not now": [
"src/community/components/RoturConsentModal.jsx:34",
"src/community/components/RoturConsentModal.jsx:75"
"src/community/components/RoturConsentModal.jsx:33",
"src/community/components/RoturConsentModal.jsx:70"
],
"Allow all": [
"src/community/components/RoturConsentModal.jsx:35"
"src/community/components/RoturConsentModal.jsx:34"
],
"Just this project": [
"src/community/components/RoturConsentModal.jsx:39"
"src/community/components/RoturConsentModal.jsx:38"
],
"\"{value1}\" (@{value2}) wants to show it on your Rotur profile.": [
"src/community/components/RoturConsentModal.jsx:45"
"src/community/components/RoturConsentModal.jsx:44"
],
"\"{value1}\" wants to show it on your Rotur profile.": [
"src/community/components/RoturConsentModal.jsx:48"
],
"Allow payment of {value1} credits to @{value2}?": [
"src/community/components/RoturConsentModal.jsx:56"
"src/community/components/RoturConsentModal.jsx:47"
],
"Allow this project to {value1} as @{value2}?": [
"src/community/components/RoturConsentModal.jsx:61"
"src/community/components/RoturConsentModal.jsx:56"
],
"Allow this project to {value1}?": [
"src/community/components/RoturConsentModal.jsx:62"
],
"Confirm payment": [
"src/community/components/RoturConsentModal.jsx:68"
"src/community/components/RoturConsentModal.jsx:57"
],
"Confirm account action": [
"src/community/components/RoturConsentModal.jsx:68"
"src/community/components/RoturConsentModal.jsx:63"
],
"Connect to Rotur": [
"src/community/components/RoturConsentModal.jsx:69"
],
"Allow payment": [
"src/community/components/RoturConsentModal.jsx:82"
"src/community/components/RoturConsentModal.jsx:64"
],
"Allow once": [
"src/community/components/RoturConsentModal.jsx:83"
"src/community/components/RoturConsentModal.jsx:76"
],
"Connect": [
"src/community/components/RoturConsentModal.jsx:83"
"src/community/components/RoturConsentModal.jsx:76"
],
"This action will happen once. It does not give the project ongoing approval.": [
"src/community/components/RoturConsentModal.jsx:94"
"src/community/components/RoturConsentModal.jsx:86"
],
"\"{value1}\" (@{value2}) wants to use your Rotur account to:": [
"src/community/components/RoturConsentModal.jsx:103"
"src/community/components/RoturConsentModal.jsx:94"
],
"\"{value1}\" wants to use your Rotur account to:": [
"src/community/components/RoturConsentModal.jsx:106"
"src/community/components/RoturConsentModal.jsx:97"
],
"This only reads your public Rotur info.": [
"src/community/components/RoturConsentModal.jsx:122"
"src/community/components/RoturConsentModal.jsx:113"
],
"Paste a Scratch project link": [
"src/community/components/ScratchImport.jsx:34"
Expand Down
3 changes: 0 additions & 3 deletions src/community/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -334,10 +334,8 @@
"Not now": "Not now",
"Allow all": "Allow all",
"Just this project": "Just this project",
"Confirm payment": "Confirm payment",
"Confirm account action": "Confirm account action",
"Connect to Rotur": "Connect to Rotur",
"Allow payment": "Allow payment",
"Allow once": "Allow once",
"Connect": "Connect",
"This only reads your public Rotur info.": "This only reads your public Rotur info.",
Expand Down Expand Up @@ -1863,7 +1861,6 @@
"This project": "This project",
"\"{value1}\" (@{value2}) wants to show it on your Rotur profile.": "\"{value1}\" (@{value2}) wants to show it on your Rotur profile.",
"\"{value1}\" wants to show it on your Rotur profile.": "\"{value1}\" wants to show it on your Rotur profile.",
"Allow payment of {value1} credits to @{value2}?": "Allow payment of {value1} credits to @{value2}?",
"Allow this project to {value1} as @{value2}?": "Allow this project to {value1} as @{value2}?",
"Allow this project to {value1}?": "Allow this project to {value1}?",
"This action will happen once. It does not give the project ongoing approval.": "This action will happen once. It does not give the project ongoing approval.",
Expand Down
27 changes: 8 additions & 19 deletions src/components/mw-rotur-consent-modal/consent-modal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const groupScopes = scopes => {
const RoturConsentModal = props => {
const {type, data} = props;
const groups = groupScopes(data.scopes || []);
const payment = type === 'confirm' && data.confirmation && data.confirmation.type === 'payment';
if (type === 'share') {
return (
<Modal
Expand Down Expand Up @@ -78,23 +77,13 @@ const RoturConsentModal = props => {
<Box className={styles.body}>
{type === 'confirm' ? (
<React.Fragment>
<h2>{payment ? 'Confirm payment' : 'Confirm account action'}</h2>
{payment ? (
<p>
{`Allow payment of ${data.confirmation.amount} credits to `}
<b>{`@${data.confirmation.recipient}`}</b>
{'?'}
</p>
) : (
<React.Fragment>
<p>
{'Allow this project to '}
<b>{data.label}</b>
{data.username ? ` as @${data.username}?` : '?'}
</p>
<p>{'This action will happen once. It does not give the project ongoing approval.'}</p>
</React.Fragment>
)}
<h2>{'Confirm account action'}</h2>
<p>
{'Allow this project to '}
<b>{data.label}</b>
{data.username ? ` as @${data.username}?` : '?'}
</p>
<p>{'This action will happen once. It does not give the project ongoing approval.'}</p>
</React.Fragment>
) : (
<React.Fragment>
Expand Down Expand Up @@ -140,7 +129,7 @@ const RoturConsentModal = props => {
className={styles.allowButton}
onClick={props.onAllowed}
>
{payment ? 'Allow payment' : (type === 'confirm' ? 'Allow once' : 'Connect')}
{type === 'confirm' ? 'Allow once' : 'Connect'}
</button>
</Box>
</Box>
Expand Down
35 changes: 3 additions & 32 deletions src/lib/rotur/project-methods.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
// The only Rotur SDK methods a project may reach through a Rotur host (the
// editor, the community project page and packaged exports). Each entry lists
// the scopes that cover it (any one is enough; an empty list means it needs no
// grant) and, for actions that spend, give away or destroy something, the
// confirmation the host shows before every call.
// grant) and, for actions that give away or destroy something, the
// confirmation the host shows before every call. Nothing here spends credits:
// projects can't.
//
// The host decides all of this. Nothing the project sends (labels,
// confirmation text, a "sensitive" flag, a project name) is trusted, because a
// custom extension running next to the project can send any message it likes.
// Never resolve a method path that is not a key of this table.

const text = value => String(typeof value === 'undefined' || value === null ? '' : value).slice(0, 200);
const amount = value => {
const number = Number(value);
return Number.isFinite(number) ? number : 0;
};

const PROJECT_METHODS = Object.freeze({
'me.abilities': {scopes: []},
Expand All @@ -25,8 +22,6 @@ const PROJECT_METHODS = Object.freeze({
'me.block': {scopes: ['blocked:manage']},
'me.unblock': {scopes: ['blocked:manage']},
'me.requests': {scopes: ['friends:view']},
'me.claimTime': {scopes: ['credits:view']},
'me.transactions': {scopes: ['credits:view']},

'profiles.get': {scopes: []},
'profiles.exists': {scopes: []},
Expand All @@ -35,10 +30,6 @@ const PROJECT_METHODS = Object.freeze({
'check.banned': {scopes: []},
'notifications.list': {scopes: ['notifications:view']},

'gifts.create': {
scopes: ['gifts:create'],
confirm: args => ({label: `create a gift of ${amount(args[0])} credits`})
},
'gifts.get': {scopes: []},
'gifts.claim': {
scopes: ['gifts:claim'],
Expand All @@ -52,10 +43,6 @@ const PROJECT_METHODS = Object.freeze({
'keys.mine': {scopes: ['keys:view']},
'keys.get': {scopes: []},
'keys.check': {scopes: []},
'keys.buy': {
scopes: [],
confirm: args => ({label: `buy key ${text(args[0])}`})
},
'keys.cancel': {
scopes: [],
confirm: args => ({label: `cancel your subscription to key ${text(args[0])}`})
Expand Down Expand Up @@ -102,10 +89,6 @@ const PROJECT_METHODS = Object.freeze({
'items.get': {scopes: []},
'items.selling': {scopes: []},
'items.list': {scopes: []},
'items.buy': {
scopes: ['items:buy'],
confirm: args => ({label: `buy item ${text(args[0])}`})
},
'items.sell': {scopes: ['items:sell']},
'items.stopSelling': {scopes: ['items:sell']},
'items.setPrice': {scopes: ['items:sell']},
Expand All @@ -115,10 +98,6 @@ const PROJECT_METHODS = Object.freeze({
},
'cosmetics.shop': {scopes: []},
'cosmetics.mine': {scopes: ['cosmetics:view']},
'cosmetics.purchase': {
scopes: ['cosmetics:buy'],
confirm: args => ({label: `buy cosmetic ${text(args[0])}`})
},
'cosmetics.equip': {scopes: ['cosmetics:equip']},
'cosmetics.unequip': {scopes: ['cosmetics:equip']},
'cosmetics.forUser': {scopes: []},
Expand All @@ -134,14 +113,6 @@ const PROJECT_METHODS = Object.freeze({
'groups.announcements': {scopes: []},
'groups.events': {scopes: ['groups:view']},
'groups.products': {scopes: ['groups:view']},
'groups.sendTip': {
scopes: ['credits:manage'],
confirm: args => ({label: `tip ${amount(args[1])} credits to group ${text(args[0])}`})
},
'groups.purchaseProduct': {
scopes: ['credits:manage'],
confirm: args => ({label: `buy product ${text(args[1])} in group ${text(args[0])}`})
},

// Projects only reach MistWarp's own Origin FS folder, never the whole drive.
'files.index': {scopes: ['files:app']},
Expand Down
12 changes: 6 additions & 6 deletions test/unit/community-project-rotur-bridge.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const mockClient = {
get: jest.fn(() => Promise.resolve({username: 'Viewer'}))
},
profiles: {get: jest.fn(() => Promise.resolve({username: 'someone'}))},
gifts: {create: jest.fn(() => Promise.resolve({ok: true}))},
gifts: {claim: jest.fn(() => Promise.resolve({ok: true}))},
storage: {get: jest.fn(() => Promise.resolve({data: {}}))}
};

Expand Down Expand Up @@ -132,18 +132,18 @@ describe('community project page Rotur bridge', () => {
wrapper.unmount();
});

test('spending always shows the real amount, whatever the frame claims', async () => {
test('a confirmation shows what the host builds, whatever the frame claims', async () => {
const {wrapper, send} = await mountProject();
const pending = send({
kind: 'call',
id: 6,
method: 'gifts.create',
args: [5000],
method: 'gifts.claim',
args: ['REAL-CODE'],
opts: {sensitive: false, label: 'claim a free hat'}
});
await pending;
expect(mockClient.gifts.create).not.toHaveBeenCalled();
expect(wrapper.text()).toContain('create a gift of 5000 credits');
expect(mockClient.gifts.claim).not.toHaveBeenCalled();
expect(wrapper.text()).toContain('claim gift code REAL-CODE');
expect(wrapper.text()).not.toContain('free hat');
wrapper.unmount();
});
Expand Down
Loading
Loading