createSpendPermissionTypedDataWithSeconds: soft production guard (console.warn) should be a hard throw to prevent silent misuse
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- typescript
- Domain
- testing
Research direction
Open packages/account-sdk/src/interface/public-utilities/spend-permission/utils.ts and inspect createSpendPermissionTypedDataWithSeconds around lines 109–154, especially the production guard at lines 126–131. Replace the soft warning behavior with the requested fail-fast behavior, then verify that production calls no longer return typed data while non-production behavior remains usable.
Written by the indexing model from the issue text.
Description
File: packages/account-sdk/src/interface/public-utilities/spend-permission/utils.ts
Lines: 109–154 (HEAD 24ab30c)
Summary
createSpendPermissionTypedDataWithSeconds is documented as test-only (@testOnly JSDoc, warning comment). Its production guard (line 126–131) is:
if (process.env.NODE_ENV === 'production') {
console.warn(
'⚠️ createSpendPermissionTypedDataWithSeconds is being used. ' +
'This function is intended for testing purposes only.'
);
}
The function then continues and returns valid SpendPermissionTypedData regardless of environment. A console.warn in a production bundle is typically invisible to end-users and silently swallowed by logging pipelines. The "guard" does not guard: a developer who accidentally ships a call to this function in production will receive a fully-formed typed-data object that can be signed and submitted on-chain.
Expected behavior
The guard should be a hard throw (or at minimum prevent returning typed data) so that production callers fail fast and loudly:
if (process.env.NODE_ENV === 'production') {
throw new Error(
'createSpendPermissionTypedDataWithSeconds is for testing only and must not be called in production.'
);
}
Why this matters
Spend permissions authorise recurring token withdrawals from user accounts. A test utility that creates permissions with arbitrary second-level periods could be used (accidentally or intentionally) in production, creating permissions with very short periods that drain allowances rapidly and are not supported by the production UX.
No existing issue found (searched createSpendPermissionTypedDataWithSeconds, testOnly production guard, console.warn throw across all states).
- Dominant language
- TypeScript
- Stars
- 172
- Forks
- 207
- Avg merge
- 49m
- Merged PRs (30d)
- 1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from base/account-sdk
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
base/account-sdk#405 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
base/account-sdk#391 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
base/account-sdk#376 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
base/account-sdk#361 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
base/account-sdk#326 ·
All issues in base/account-sdk
Similar issues
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 91/100
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 95/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Automattic/studio#4908 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100