Skip to content

Commit

Permalink
feat: support hasCrossSiteAncestor
Browse files Browse the repository at this point in the history
  • Loading branch information
OrKoN committed Jul 26, 2024
1 parent bed13dc commit bd80a3f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/bidiMapper/modules/network/NetworkUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,9 @@ export function bidiToCdpCookie(
httpOnly: params.cookie.httpOnly ?? false,
...(partitionKey.sourceOrigin !== undefined && {
partitionKey: {
hasCrossSiteAncestor: false,
hasCrossSiteAncestor: Boolean(
partitionKey['goog:hasCrossSiteAncestor']
),
// CDP's `partitionKey.topLevelSite` is the BiDi's `partition.sourceOrigin`.
topLevelSite: partitionKey.sourceOrigin,
},
Expand Down
14 changes: 12 additions & 2 deletions src/bidiMapper/modules/storage/StorageProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ export class StorageProcessor {
// are returned.
(c) =>
partitionKey.sourceOrigin === undefined ||
c.partitionKey?.topLevelSite === partitionKey.sourceOrigin
(c.partitionKey?.topLevelSite === partitionKey.sourceOrigin &&
c.partitionKey?.hasCrossSiteAncestor ===
partitionKey['goog:hasCrossSiteAncestor'])
)
.filter((cdpCookie) => {
const bidiCookie = cdpToBiDiCookie(cdpCookie);
Expand Down Expand Up @@ -212,7 +214,12 @@ export class StorageProcessor {
if (
key !== undefined &&
value !== undefined &&
!['type', 'sourceOrigin', 'userContext'].includes(key)
![
'type',
'sourceOrigin',
'userContext',
'goog:hasCrossSiteAncestor',
].includes(key)
) {
unsupportedPartitionKeys.set(key, value);
}
Expand All @@ -229,10 +236,13 @@ export class StorageProcessor {

// Set `userContext` to `default` if not provided, as it's required in Chromium.
const userContext = descriptor.userContext ?? 'default';
const hasCrossSiteAncestor =
descriptor['goog:hasCrossSiteAncestor'] ?? false;

return {
userContext,
...(sourceOrigin === undefined ? {} : {sourceOrigin}),
...(sourceOrigin === undefined ? {} : {'goog:hasCrossSiteAncestor': hasCrossSiteAncestor}),
};
}

Expand Down

0 comments on commit bd80a3f

Please sign in to comment.