diff --git a/package.json b/package.json index b3e7be0bdbe..0dee7d759ce 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 73dabb007c9..f854c9de9bc 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -197,8 +197,8 @@ importers: specifier: https://codeload.github.com/PenguinMod/penguinmod-render-fonts/tar.gz/4dda62c707f64505266aa62f7a6cc84f0e5812fd version: https://codeload.github.com/PenguinMod/penguinmod-render-fonts/tar.gz/4dda62c707f64505266aa62f7a6cc84f0e5812fd scratch-vm: - specifier: https://codeload.github.com/MistWarp/scratch-vm/tar.gz/4e8113e2546ff406644f4099f99ef5a7e85aa4c5 - version: https://codeload.github.com/MistWarp/scratch-vm/tar.gz/4e8113e2546ff406644f4099f99ef5a7e85aa4c5(@turbowarp/scratch-svg-renderer@1.1.0(patch_hash=81a01d6d472570d53eec593be679e84867db1ba1410f5ef084d5c404068481b9)(scratch-render-fonts@https://codeload.github.com/PenguinMod/penguinmod-render-fonts/tar.gz/4dda62c707f64505266aa62f7a6cc84f0e5812fd))(eslint@8.55.0)(webpack@4.47.0) + specifier: https://codeload.github.com/MistWarp/scratch-vm/tar.gz/c775381a55c13029d15ae7fe87fdae24a6998cf9 + version: https://codeload.github.com/MistWarp/scratch-vm/tar.gz/c775381a55c13029d15ae7fe87fdae24a6998cf9(@turbowarp/scratch-svg-renderer@1.1.0(patch_hash=81a01d6d472570d53eec593be679e84867db1ba1410f5ef084d5c404068481b9)(scratch-render-fonts@https://codeload.github.com/PenguinMod/penguinmod-render-fonts/tar.gz/4dda62c707f64505266aa62f7a6cc84f0e5812fd))(eslint@8.55.0)(webpack@4.47.0) scratchblocks: specifier: 3.7.1 version: 3.7.1 @@ -5493,8 +5493,8 @@ packages: scratch-translate-extension-languages@1.0.7: resolution: {integrity: sha512-6+bQU9iVYv23T8J0SjpV6MTugm0y8myh/4DPgu1BGfccysdkaWzu3MkNGQyQRUlbqAiW9wM7ctfv3USPEkzTgg==} - scratch-vm@https://codeload.github.com/MistWarp/scratch-vm/tar.gz/4e8113e2546ff406644f4099f99ef5a7e85aa4c5: - resolution: {tarball: https://codeload.github.com/MistWarp/scratch-vm/tar.gz/4e8113e2546ff406644f4099f99ef5a7e85aa4c5} + scratch-vm@https://codeload.github.com/MistWarp/scratch-vm/tar.gz/c775381a55c13029d15ae7fe87fdae24a6998cf9: + resolution: {tarball: https://codeload.github.com/MistWarp/scratch-vm/tar.gz/c775381a55c13029d15ae7fe87fdae24a6998cf9} version: 2.1.46 peerDependencies: '@turbowarp/scratch-svg-renderer': ^1.1.0 @@ -12627,7 +12627,7 @@ snapshots: scratch-translate-extension-languages@1.0.7: {} - scratch-vm@https://codeload.github.com/MistWarp/scratch-vm/tar.gz/4e8113e2546ff406644f4099f99ef5a7e85aa4c5(@turbowarp/scratch-svg-renderer@1.1.0(patch_hash=81a01d6d472570d53eec593be679e84867db1ba1410f5ef084d5c404068481b9)(scratch-render-fonts@https://codeload.github.com/PenguinMod/penguinmod-render-fonts/tar.gz/4dda62c707f64505266aa62f7a6cc84f0e5812fd))(eslint@8.55.0)(webpack@4.47.0): + scratch-vm@https://codeload.github.com/MistWarp/scratch-vm/tar.gz/c775381a55c13029d15ae7fe87fdae24a6998cf9(@turbowarp/scratch-svg-renderer@1.1.0(patch_hash=81a01d6d472570d53eec593be679e84867db1ba1410f5ef084d5c404068481b9)(scratch-render-fonts@https://codeload.github.com/PenguinMod/penguinmod-render-fonts/tar.gz/4dda62c707f64505266aa62f7a6cc84f0e5812fd))(eslint@8.55.0)(webpack@4.47.0): dependencies: '@turbowarp/json': 0.1.2 '@turbowarp/jszip': 3.12.0 diff --git a/src/community/components/RoturConsentModal.jsx b/src/community/components/RoturConsentModal.jsx index cf758e9fa41..a3b7da24295 100644 --- a/src/community/components/RoturConsentModal.jsx +++ b/src/community/components/RoturConsentModal.jsx @@ -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 ( @@ -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}); @@ -65,7 +60,7 @@ const RoturConsentModal = ({type, data, onAllow, onBlock, onDeny, onShareThis, o - {payment ? - communityText('Allow payment') : - (type === 'confirm' ? communityText('Allow once') : communityText('Connect'))} + {type === 'confirm' ? communityText('Allow once') : communityText('Connect')} } @@ -88,13 +81,11 @@ const RoturConsentModal = ({type, data, onAllow, onBlock, onDeny, onShareThis, o {type === 'confirm' ? (

{confirmLead}

- {payment ? null : ( -

- {communityText( - 'This action will happen once. It does not give the project ongoing approval.' - )} -

- )} +

+ {communityText( + 'This action will happen once. It does not give the project ongoing approval.' + )} +

) : ( diff --git a/src/community/translations/_sources.json b/src/community/translations/_sources.json index a51bb2e451c..3e884333a48 100644 --- a/src/community/translations/_sources.json +++ b/src/community/translations/_sources.json @@ -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", @@ -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" @@ -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" diff --git a/src/community/translations/en.json b/src/community/translations/en.json index 6d59ba0c941..95b4f25b0d2 100644 --- a/src/community/translations/en.json +++ b/src/community/translations/en.json @@ -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.", @@ -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.", diff --git a/src/components/mw-rotur-consent-modal/consent-modal.jsx b/src/components/mw-rotur-consent-modal/consent-modal.jsx index 616615cc475..7dd8c3e7deb 100644 --- a/src/components/mw-rotur-consent-modal/consent-modal.jsx +++ b/src/components/mw-rotur-consent-modal/consent-modal.jsx @@ -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 ( { {type === 'confirm' ? ( -

{payment ? 'Confirm payment' : 'Confirm account action'}

- {payment ? ( -

- {`Allow payment of ${data.confirmation.amount} credits to `} - {`@${data.confirmation.recipient}`} - {'?'} -

- ) : ( - -

- {'Allow this project to '} - {data.label} - {data.username ? ` as @${data.username}?` : '?'} -

-

{'This action will happen once. It does not give the project ongoing approval.'}

-
- )} +

{'Confirm account action'}

+

+ {'Allow this project to '} + {data.label} + {data.username ? ` as @${data.username}?` : '?'} +

+

{'This action will happen once. It does not give the project ongoing approval.'}

) : ( @@ -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'}
diff --git a/src/lib/rotur/project-methods.js b/src/lib/rotur/project-methods.js index 797f1d8a104..7b7c70d8bf5 100644 --- a/src/lib/rotur/project-methods.js +++ b/src/lib/rotur/project-methods.js @@ -1,8 +1,9 @@ // 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 @@ -10,10 +11,6 @@ // 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: []}, @@ -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: []}, @@ -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'], @@ -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])}`}) @@ -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']}, @@ -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: []}, @@ -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']}, diff --git a/test/unit/community-project-rotur-bridge.test.jsx b/test/unit/community-project-rotur-bridge.test.jsx index 0d4c66d8837..1015fe3fca9 100644 --- a/test/unit/community-project-rotur-bridge.test.jsx +++ b/test/unit/community-project-rotur-bridge.test.jsx @@ -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: {}}))} }; @@ -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(); }); diff --git a/test/unit/packager-account.test.js b/test/unit/packager-account.test.js index eb9921d3ac8..dc284e6d4a5 100644 --- a/test/unit/packager-account.test.js +++ b/test/unit/packager-account.test.js @@ -57,17 +57,17 @@ test('extensions in an export cannot reach the token or unlisted SDK methods', a test('a payment is confirmed with the real amount even when the caller says it is not sensitive', async () => { const sdk = client(); - sdk.gifts = {create: jest.fn()}; + sdk.gifts = {claim: jest.fn()}; const runtime = runtimeFor('roturEconomy_pay'); const host = createAccountHost(runtime, {title: 'Game'}, function () { return sdk; }); const ready = host.prepare(); await document.querySelector('button').onclick(); await ready; const confirm = jest.spyOn(window, 'confirm').mockReturnValue(false); - await expect(runtime.roturHost.call('gifts.create', [500], {sensitive: false})) + await expect(runtime.roturHost.call('gifts.claim', ['CODE'], {sensitive: false})) .rejects.toThrow('cancelled'); - expect(confirm).toHaveBeenCalledWith('Allow Game to create a gift of 500 credits?'); - expect(sdk.gifts.create).not.toHaveBeenCalled(); + expect(confirm).toHaveBeenCalledWith('Allow Game to claim gift code CODE?'); + expect(sdk.gifts.claim).not.toHaveBeenCalled(); }); test('failed authentication keeps project gated and permits retry', async () => { @@ -114,16 +114,16 @@ test('published game data uses a player capability and the authenticated session test('sensitive Rotur actions retain a separate confirmation after login', async () => { const sdk = client(); - sdk.gifts = {create: jest.fn()}; + sdk.gifts = {claim: jest.fn()}; const runtime = runtimeFor('roturEconomy_transfer'); const host = createAccountHost(runtime, {}, function () { return sdk; }); const ready = host.prepare(); await document.querySelector('button').onclick(); await ready; jest.spyOn(window, 'confirm').mockReturnValue(false); - await expect(runtime.roturHost.call('gifts.create', [5], {sensitive: true})) + await expect(runtime.roturHost.call('gifts.claim', ['CODE'], {sensitive: true})) .rejects.toThrow('cancelled'); - expect(sdk.gifts.create).not.toHaveBeenCalled(); + expect(sdk.gifts.claim).not.toHaveBeenCalled(); }); test('preview storage supports browser storage methods and property access without sharing data', () => { diff --git a/test/unit/rotur-extension-host.test.js b/test/unit/rotur-extension-host.test.js index 754304c3c8a..ad8640cf48e 100644 --- a/test/unit/rotur-extension-host.test.js +++ b/test/unit/rotur-extension-host.test.js @@ -49,18 +49,17 @@ test('trusted projects still confirm sensitive Rotur actions', async () => { const showModal = jest.fn(() => Promise.resolve(true)); host.acquireModalLock = jest.fn(() => Promise.resolve({showModal})); - await host.call('gifts.create', [10], { + await host.call('gifts.claim', ['CODE'], { sensitive: false, - label: 'claim a free hat', - confirmation: {type: 'payment', amount: 1, recipient: 'friend'} + label: 'claim a free hat' }); expect(showModal).toHaveBeenCalledWith('confirm', { - label: 'create a gift of 10 credits', + label: 'claim gift code CODE', confirmation: null, username: 'user' }); - expect(callRotur).toHaveBeenCalledWith('gifts.create', [10]); + expect(callRotur).toHaveBeenCalledWith('gifts.claim', ['CODE']); }); test('authenticated reads expand scopes without prompting', async () => { @@ -120,9 +119,9 @@ test('blocked projects cannot reopen Rotur prompts', async () => { await expect(host.ensureConsent(['posts:create'], {name: 'Blocked project'})).resolves.toBe(false); await expect(host.ensureActivitySharing()).resolves.toBe(false); - await expect(host.call('gifts.create', [10], { + await expect(host.call('gifts.claim', ['CODE'], { sensitive: true, - label: 'gifts.create' + label: 'gifts.claim' })).rejects.toThrow('cancelled'); expect(host.state.type).toBe(null); diff --git a/test/unit/rotur-project-methods.test.js b/test/unit/rotur-project-methods.test.js index 5b816a0324d..17670f32f59 100644 --- a/test/unit/rotur-project-methods.test.js +++ b/test/unit/rotur-project-methods.test.js @@ -49,8 +49,6 @@ test('every method the built-in Rotur extensions call is allowlisted with its sc const calls = await recordExtensionCalls(); expect(calls.length).toBeGreaterThan(80); for (const {method, opts, scopes} of calls) { - // The "send credits" block: projects can't send credits any more. - if (method === 'me.transfer') continue; const spec = projectMethod(method); expect({method, allowed: Boolean(spec)}).toEqual({method, allowed: true}); // A block's scope is what the host grants for it, after mapping. @@ -85,6 +83,14 @@ test.each([ 'admin.transferCredits', 'me.transfer', 'me.transfer.call', + 'me.claimTime', + 'me.transactions', + 'gifts.create', + 'keys.buy', + 'groups.sendTip', + 'groups.purchaseProduct', + 'items.buy', + 'cosmetics.purchase', 'socket.token', 'socket.send', '' @@ -114,15 +120,11 @@ test('a scoped method needs a grant for one of its scopes', () => { expect(authorizeProjectCall('profiles.get', ['someone'], [], 'p').args).toEqual(['someone']); }); -test('spending methods are confirmed with text the host builds from the arguments', () => { - expect(authorizeProjectCall('gifts.create', ['999'], [], 'p').confirm.label) - .toBe('create a gift of 999 credits'); - expect(authorizeProjectCall('groups.sendTip', ['tag', '5'], [], 'p').confirm.label) - .toBe('tip 5 credits to group tag'); +test('actions that give something away or destroy it are confirmed with text the host builds', () => { + expect(authorizeProjectCall('items.transfer', ['hat', 'sam'], [], 'p').confirm.label).toBe('give item hat to @sam'); + expect(authorizeProjectCall('gifts.claim', ['CODE'], [], 'p').confirm.label).toBe('claim gift code CODE'); for (const method of [ - 'gifts.create', 'gifts.claim', 'keys.buy', 'keys.cancel', 'keys.delete', - 'posts.delete', 'items.buy', 'items.transfer', 'cosmetics.purchase', - 'groups.sendTip', 'groups.purchaseProduct' + 'gifts.claim', 'keys.cancel', 'keys.delete', 'posts.delete', 'items.transfer' ]) { expect({method, confirm: Boolean(projectMethod(method).confirm)}).toEqual({method, confirm: true}); } @@ -149,7 +151,7 @@ test('projects may only ask for scopes their blocks can use', () => { test('only read scopes and per-call-confirmed scopes are granted without asking', () => { expect(grantsSilently(['credits:view', 'account:view'])).toBe(true); - expect(grantsSilently(['gifts:create'])).toBe(true); + expect(grantsSilently(['gifts:claim'])).toBe(true); expect(grantsSilently(['posts:delete'])).toBe(true); expect(grantsSilently(['posts:create'])).toBe(false); expect(grantsSilently(['keys:manage'])).toBe(false);