Skip to content

Commit

Permalink
fix(persona): check if requested scopes include email (#2789)
Browse files Browse the repository at this point in the history
  • Loading branch information
szkl authored Dec 12, 2023
1 parent 12ef66d commit 292a870
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/security/persona.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ export type ClaimData = {
}

export type ScopeClaimRetrieverFunction = (
scope: string[],
scopeEntry: ScopeValueName,
identityURN: IdentityURN,
clientId: string,
Expand Down Expand Up @@ -285,6 +286,7 @@ class InvalidPersonaDataError extends RollupError {

//These retriever functions will be moved elsewhere as part of ticket #2013
async function emailClaimRetriever(
scope: string[],
scopeEntry: ScopeValueName,
identityURN: IdentityURN,
clientId: string,
Expand Down Expand Up @@ -344,6 +346,7 @@ async function emailClaimRetriever(
}

async function profileClaimsRetriever(
scope: string[],
scopeEntry: ScopeValueName,
identityURN: IdentityURN,
clientId: string,
Expand Down Expand Up @@ -376,6 +379,7 @@ async function profileClaimsRetriever(
}

async function erc4337ClaimsRetriever(
scope: string[],
scopeEntry: ScopeValueName,
identityURN: IdentityURN,
clientId: string,
Expand Down Expand Up @@ -447,6 +451,7 @@ type ConnectedAccount = {
}

async function connectedAccountsClaimsRetriever(
scope: string[],
scopeEntry: ScopeValueName,
identityURN: IdentityURN,
clientId: string,
Expand Down Expand Up @@ -484,7 +489,7 @@ async function connectedAccountsClaimsRetriever(
({ rc: { addr_type } }) => addr_type !== CryptoAccountType.Wallet
)

if (personaData.email) {
if (scope.includes('email') && personaData.email) {
const [emailProfile] =
await coreClient.account.getAccountProfileBatch.query([
personaData.email,
Expand Down Expand Up @@ -584,6 +589,7 @@ export async function getClaimValues(
if (!retrieverFunction) return
else
return retrieverFunction(
scope,
scopeValue,
identityURN,
clientId,
Expand Down

0 comments on commit 292a870

Please sign in to comment.