-
Notifications
You must be signed in to change notification settings - Fork 548
Update odsp driver for new header #24819
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Update odsp driver for new header #24819
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Adds support for a new isNonDurableRedeem
header to enable temporal, non-durable access via share links. Key changes include:
- Extending the resolver and contracts to extract and propagate the new header.
- Modifying snapshot redemption and download flows to honor the non-durable flag.
- Updating public API definitions and adding unit tests for the new behavior.
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
packages/drivers/odsp-driver/src/test/odspDriverUrlResolverForShareLink.spec.ts | Added tests verifying isNonDurableRedeem is set or ignored |
packages/drivers/odsp-driver/src/odspDriverUrlResolverForShareLink.ts | Extract and attach isNonDurableRedeem to shareLinkInfo |
packages/drivers/odsp-driver/src/fetchSnapshot.ts | Propagate isNonDurableRedeem into prefer headers for redeem and download APIs |
packages/drivers/odsp-driver/src/contractsPublic.ts | Extended SharingLinkHeader enum and internal interface |
packages/drivers/odsp-driver-definitions/src/resolvedUrl.ts | Added isNonDurableRedeem to ShareLinkInfoType |
packages/drivers/odsp-driver-definitions/api-report/odsp-driver-definitions.legacy.alpha.api.md | Updated API report with new field |
Comments suppressed due to low confidence (4)
packages/drivers/odsp-driver/src/contractsPublic.ts:37
- This header may be omitted in normal requests. Consider making the property optional (
[SharingLinkHeader.isNonDurableRedeem]?: boolean
) to reflect its conditional presence.
[SharingLinkHeader.isNonDurableRedeem]: boolean;
packages/drivers/odsp-driver/src/fetchSnapshot.ts:740
- [nitpick] Rename
header
toheaders
to clarify that this object holds multiple HTTP headers and align with the naming used elsewhere in the file.
const header = isNonDurableRedeem
packages/drivers/odsp-driver/src/test/odspDriverUrlResolverForShareLink.spec.ts:373
- [nitpick] The assertion message is generic. Consider specifying that you expect the
isNonDurableRedeem
flag to betrue
(e.g.,Expected isNonDurableRedeem to be true
).
"Sharing link should be set in resolved url",
packages/drivers/odsp-driver/src/test/odspDriverUrlResolverForShareLink.spec.ts:390
- [nitpick] This assertion message could more clearly reference
isNonDurableRedeem
(e.g.,Expected isNonDurableRedeem to be undefined
).
"Sharing link should not be set in resolved url",
@@ -95,6 +95,11 @@ export interface ShareLinkInfoType { | |||
* permission then this link can be redeemed for the permissions in the same network call. | |||
*/ | |||
sharingLinkToRedeem?: string; | |||
|
|||
/** | |||
* If the sharing link to redeem is a non-durable link, this flag will be set to true. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Link is not non durable. its redeem is non durable. Please update the comment accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Applied changes
/** | ||
* If the sharing link to redeem is a non-durable link, this flag will be set to true. | ||
*/ | ||
isNonDurableRedeem?: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isNonDurableRedeem -> doNonDurableRedeem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Applied changes
@@ -24,13 +24,17 @@ export enum SharingLinkHeader { | |||
// Can be used in request made to resolver, to tell the resolver that the passed in URL is a sharing link | |||
// which can be redeemed at server to get permissions. | |||
isSharingLinkToRedeem = "isSharingLinkToRedeem", | |||
// When isSharingLinkToRedeem is true, this header can be used to tell the server that the sharing link | |||
// is a non-durable link | |||
NonDurableRedeem = "NonDurableRedeem", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets use camel case, same as above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Applied change
@@ -168,6 +170,11 @@ export class OdspDriverUrlResolverForShareLink implements IUrlResolver { | |||
odspResolvedUrl.shareLinkInfo = Object.assign(odspResolvedUrl.shareLinkInfo ?? {}, { | |||
sharingLinkToRedeem: this.removeNavParam(request.url), | |||
}); | |||
if (isNonDurableRedeem) { | |||
odspResolvedUrl.shareLinkInfo = Object.assign(odspResolvedUrl.shareLinkInfo ?? {}, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of doing it again, you can just do this above in the same assignment and set to true/false.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Applied change
@@ -241,6 +245,10 @@ async function redeemSharingLink( | |||
); | |||
const headers = getHeadersWithAuth(authHeader); | |||
headers.prefer = "redeemSharingLink"; | |||
if (isNonDurableRedeem) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use if/else to set to one or the other instead of setting it again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Applied change
@@ -241,6 +245,10 @@ async function redeemSharingLink( | |||
); | |||
const headers = getHeadersWithAuth(authHeader); | |||
headers.prefer = "redeemSharingLink"; | |||
if (isNonDurableRedeem) { | |||
headers.prefer = "nonDurableRedeem"; | |||
setNDRHeader = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, need of this. Just directly check and set in event.end and cancel.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Applied change
packages/drivers/odsp-driver-definitions/api-report/odsp-driver-definitions.legacy.alpha.api.md
Outdated
Show resolved
Hide resolved
* When a sharingLinkToRedeem is used, this parameter can be set to make the request with | ||
* the redemption expire after a certain time period. | ||
* The duration of the redemption is not set by Fluid. | ||
* @defaultValue false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@defaultValue
is intended to describe the behavior that results from not specifying a value (or setting it to undefined). So here it should describe the default boolean value that will be used when this is undefined.
@@ -724,11 +727,16 @@ export const downloadSnapshot = mockify( | |||
const queryString = getQueryString(queryParams); | |||
const url = `${snapshotUrl}/trees/latest${queryString}`; | |||
const method = "POST"; | |||
const isRedemptionNonDurable: boolean = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can also set this in the event.end event of the fetchsnapshot function just like you are doing when doing redeem inside the fallback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you referring to the event.end in fetchLatestSnapshotCore
?
I decided to set it inside downloadSnapshot since that is where the authHeader with the header.prefer options are being set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that is fine. I am talkign about the telemetry event.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the telemetry parameter to fetchLatestSnapshotCore
🔗 No broken links found! ✅ Your attention to detail is admirable. linkcheck output
|
Description
A new header variable is necessary when redeeming a share link so that a certain type of user has temporal access to the document to which the link points to.
Reviewer Guidance
Let me know if there's something I need to add or be aware of.
Fixes: AB#41357