Skip to content

[Sample] Add vaulted state settings to checkout as guest / static / customer accounts#428

Merged
kieran-osgood-shopify merged 12 commits intomainfrom
feat/customer-auth
Feb 16, 2026
Merged

[Sample] Add vaulted state settings to checkout as guest / static / customer accounts#428
kieran-osgood-shopify merged 12 commits intomainfrom
feat/customer-auth

Conversation

@kieran-osgood-shopify
Copy link
Contributor

@kieran-osgood-shopify kieran-osgood-shopify commented Feb 6, 2026

What changes are you making?

Matches the implementation as in: https://github.com/Shopify/checkout-sheet-kit-swift/pull/523/changes

Adds setting to set the buyerIdentity for the cart, this allows testing of guest / hardCoded (.env values) / customerAccounts

Theres a number of changes to ensure that the sample appropriately logs out users when switching accounts, including a bug fix in the Context Providers where we never loaded dynamic values (used default context values) because of Context nesting order

This will allow testing for #427

Simulator.Screen.Recording.-.iPhone.16.Plus.-.2026-02-06.at.14.37.49.mov

PR Checklist

Important

Releasing a new version of the kit?


Tip

See the Contributing documentation for instructions on how to publish a new version of the library.

@github-actions
Copy link

github-actions bot commented Feb 6, 2026

Coverage Report

Lines Statements Branches Functions
Coverage: 99%
99.52% (209/210) 98.29% (115/117) 100% (61/61)

}, [shopify, eventHandlers]);

return (
<ConfigProvider
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was a bug introduced with a Provider refactor that meant we had providers incorrectly ordered - AppWithCheckoutKit would never have access to the Config because it was placed as a child

:ccache_enabled => true
)

# WORKAROUND
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving the pod inside the target removes the need for this workaround


target 'ReactNativeTests' do
inherit! :complete
inherit! :search_paths
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Newer modules (nitro modules) have checking to ensure there aren't duplicate dependencies linked, which :complete caused because its within the ReactNative target, just inheriting the search_paths makes sense here as he tests run on the host app

@kieran-osgood-shopify kieran-osgood-shopify marked this pull request as ready for review February 10, 2026 11:33
@kieran-osgood-shopify kieran-osgood-shopify requested a review from a team as a code owner February 10, 2026 11:33
Copy link
Contributor

@markmur markmur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but I think it would help to better organise the functions using self-contained classes. Easier to lift and shift into a merchant app that way.

If we have time I think we should try squeeze this in before we ship but won't block on it.

Comment on lines +19 to +53
function getShopId(): string {
const shopId = Config.CUSTOMER_ACCOUNT_API_SHOP_ID;
if (!shopId) {
throw new Error('CUSTOMER_ACCOUNT_API_SHOP_ID is not configured');
}
return shopId;
}

function getClientId(): string {
const clientId = Config.CUSTOMER_ACCOUNT_API_CLIENT_ID;
if (!clientId) {
throw new Error('CUSTOMER_ACCOUNT_API_CLIENT_ID is not configured');
}
return clientId;
}

function getAuthorizationEndpoint(): string {
return `https://shopify.com/authentication/${getShopId()}/oauth/authorize`;
}

function getTokenEndpoint(): string {
return `https://shopify.com/authentication/${getShopId()}/oauth/token`;
}

function getLogoutEndpoint(): string {
return `https://shopify.com/authentication/${getShopId()}/logout`;
}

export function getRedirectUri(): string {
return `shop.${getShopId()}.app://callback`;
}

export function getCallbackScheme(): string {
return `shop.${getShopId()}.app`;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we use a class for all of the functions in this file? Some functions seem private while others are exported. It would be cleaner to separate the two using a class. Any of the computed URLs can come from getter methods

Comment on lines +15 to +28
export function generateCodeVerifier(): string {
const bytes = crypto.randomBytes(32);
return base64URLEncode(bytes.buffer);
}

export function generateCodeChallenge(verifier: string): string {
const hash = crypto.createHash('sha256').update(verifier).digest();
return base64URLEncode(hash.buffer);
}

export function generateState(): string {
const bytes = crypto.randomBytes(27);
return base64URLEncode(bytes.buffer);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might also make sense to group these in a class

Comment on lines +95 to +96
await customerAccountManager.logout();
setSession(defaultSession);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could the customerAccountManager manage the session? 🤔

Copy link
Contributor

@markmur markmur Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use jotai in the sample already, so you could manage computed atoms in the class similarly to how we use signals

@kieran-osgood-shopify kieran-osgood-shopify enabled auto-merge (squash) February 16, 2026 13:17
@kieran-osgood-shopify kieran-osgood-shopify merged commit ed50490 into main Feb 16, 2026
7 checks passed
@kieran-osgood-shopify kieran-osgood-shopify deleted the feat/customer-auth branch February 16, 2026 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants