Skip to content

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

Open
wants to merge 24 commits into
base: main
Choose a base branch
from

Conversation

MarioJGMsoft
Copy link
Contributor

@MarioJGMsoft MarioJGMsoft commented Jun 10, 2025

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

@github-actions github-actions bot added base: main PRs targeted against main branch area: driver Driver related issues area: odsp-driver labels Jun 10, 2025
@MarioJGMsoft MarioJGMsoft changed the title update the shareLink enum Update odsp driver for new header Jun 10, 2025
@github-actions github-actions bot added the public api change Changes to a public API label Jun 11, 2025
@MarioJGMsoft MarioJGMsoft marked this pull request as ready for review June 11, 2025 22:11
@Copilot Copilot AI review requested due to automatic review settings June 11, 2025 22:11
@MarioJGMsoft MarioJGMsoft requested a review from a team as a code owner June 11, 2025 22:11
Copy link
Contributor

@Copilot Copilot AI left a 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 to headers 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 be true (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.
Copy link
Contributor

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.

Copy link
Contributor Author

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;
Copy link
Contributor

Choose a reason for hiding this comment

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

isNonDurableRedeem -> doNonDurableRedeem?

Copy link
Contributor Author

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",
Copy link
Contributor

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.

Copy link
Contributor Author

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 ?? {}, {
Copy link
Contributor

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.

Copy link
Contributor Author

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) {
Copy link
Contributor

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.

Copy link
Contributor Author

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;
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Applied change

@github-actions github-actions bot added the area: framework Framework is a tag for issues involving the developer framework. Eg Aqueduct label Jun 17, 2025
@github-actions github-actions bot removed the area: framework Framework is a tag for issues involving the developer framework. Eg Aqueduct label Jun 17, 2025
* 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
Copy link
Contributor

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 =
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor

🔗 No broken links found! ✅

Your attention to detail is admirable.

linkcheck output


> fluid-framework-docs-site@0.0.0 ci:check-links /home/runner/work/FluidFramework/FluidFramework/docs
> start-server-and-test "npm run serve -- --no-open" 3000 check-links

1: starting server using command "npm run serve -- --no-open"
and when url "[ 'http://127.0.0.1:3000' ]" is responding with HTTP status code 200
running tests using command "npm run check-links"


> fluid-framework-docs-site@0.0.0 serve
> docusaurus serve --no-open

[SUCCESS] Serving "build" directory at: http://localhost:3000/

> fluid-framework-docs-site@0.0.0 check-links
> linkcheck http://localhost:3000 --skip-file skipped-urls.txt

Crawling...

Stats:
  225443 links
    1710 destination URLs
    1941 URLs ignored
       0 warnings
       0 errors


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: driver Driver related issues area: odsp-driver base: main PRs targeted against main branch public api change Changes to a public API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants