Merged
Conversation
* Fix apple auth scope * Fix Apple auth scope test
…ession config helper
Review or Edit in CodeSandboxOpen the branch in Web Editor • VS Code • Insiders |
|
|
Reviewer's GuideImplements 3.0.0-beta.9 release wiring: adds explicit session configuration utilities and exports for the dapp client (including support for native token spending and EOA login), adjusts Apple auth flow to omit OAuth scope for Apple signups, and bumps/package-wires all affected packages and changelogs to the new beta version using changesets. Sequence diagram for building OAuth URL with conditional scopesequenceDiagram
actor User
participant DappClient
participant AuthCodeHandler
participant OAuthProvider
User->>DappClient: initiateLogin(loginMethod)
DappClient->>AuthCodeHandler: buildAuthUrl(loginMethod)
alt signupKind_is_apple
AuthCodeHandler->>AuthCodeHandler: setQuery(state)
AuthCodeHandler->>AuthCodeHandler: omit_scope_parameter
else other_login_methods
AuthCodeHandler->>AuthCodeHandler: setQuery(state, scope_openid_profile_email)
end
AuthCodeHandler-->>DappClient: oauthUrlWithQuery
DappClient-->>User: redirectTo(oauthUrlWithQuery)
User->>OAuthProvider: authorize
OAuthProvider-->>DappClient: redirect_back_with_code
Class diagram for explicit session configuration utilitiesclassDiagram
class SessionDuration {
number days
number hours
number minutes
}
class NativeTokenSpending {
bigint valueLimit
Address.Address[] allowedRecipients
}
class ExplicitSessionParams {
number chainId
SessionDuration expiresIn
Permission.Permission[] permissions
NativeTokenSpending nativeTokenSpending
}
class ExplicitSessionConfig {
number chainId
bigint valueLimit
bigint deadline
Permission.Permission[] permissions
}
class Permission.Permission {
Address.Address target
any[] rules
}
class Address.Address
class UtilsIndex {
+createExplicitSessionConfig(params ExplicitSessionParams) ExplicitSessionConfig
}
ExplicitSessionParams --> SessionDuration : has
ExplicitSessionParams --> NativeTokenSpending : optional
ExplicitSessionParams --> Permission.Permission : uses
NativeTokenSpending --> Address.Address : allowedRecipients
ExplicitSessionConfig --> Permission.Permission : permissions
UtilsIndex ..> ExplicitSessionParams : input
UtilsIndex ..> ExplicitSessionConfig : output
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- In
packages/wallet/dapp-client/src/utils/index.ts, the importedNetworksymbol from@0xsequence/wallet-primitivesis no longer used and can be removed to avoid an unused import. - In
createExplicitSessionConfig, consider validating that the computedsessionLifetimeSecondsis positive (e.g., reject an all-zeroexpiresIn) to avoid creating sessions that are already expired or effectively have no lifetime.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `packages/wallet/dapp-client/src/utils/index.ts`, the imported `Network` symbol from `@0xsequence/wallet-primitives` is no longer used and can be removed to avoid an unused import.
- In `createExplicitSessionConfig`, consider validating that the computed `sessionLifetimeSeconds` is positive (e.g., reject an all-zero `expiresIn`) to avoid creating sessions that are already expired or effectively have no lifetime.
## Individual Comments
### Comment 1
<location> `packages/wallet/dapp-client/src/utils/index.ts:147-153` </location>
<code_context>
+ nativeTokenSpending?: NativeTokenSpending
+}
+
+export const createExplicitSessionConfig = (params: ExplicitSessionParams): ExplicitSessionConfig => {
+ const nowInSeconds = BigInt(Math.floor(Date.now() / 1000))
+ const { days = 0, hours = 0, minutes = 0 } = params.expiresIn
+ const sessionLifetimeSeconds = days * 24 * 60 * 60 + hours * 60 * 60 + minutes * 60
+ const deadline = nowInSeconds + BigInt(sessionLifetimeSeconds)
+
+ if (params.permissions.length === 0) {
+ throw new Error('createExplicitSessionConfig: At least one permission is required.')
+ }
</code_context>
<issue_to_address>
**issue:** Consider validating that the session duration is positive and non-negative to avoid immediately-expired or retroactive sessions.
As written, `expiresIn` values of zero or negative (e.g., from unchecked user input) will compute a deadline `<= nowInSeconds`, so the session is expired immediately. Consider enforcing non-negative `days`/`hours`/`minutes` and requiring `sessionLifetimeSeconds > 0`, throwing otherwise.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary by Sourcery
Add support utilities and type exports needed for EOA login in the dapp client and propagate the 3.0.0-beta.9 patch release across wallet and service packages.
New Features:
Bug Fixes:
Enhancements:
Tests:
Chores: