I am using @pnp/sp 3.7.0 version I had a function that is not working.
I've tried the below function but never got it working.
public async shareLinkWithPassword(fileUrl: string, password: string): Promise<string> {
const file = await this._sp.web.getFileByServerRelativePath("<file-url>");
const sharingLink = await file.shareObject().createAnonymousLink();
}