How to use project Secret in NodeJs with truffle hdwallet

I am trying to use project secret but it constantly throws error “rejected due to project ID settings”
There are no other security settings enabled in my project except Require project secret for all requests
Also i used it liked this
var options = {
headers: {
authorization: ‘Basic base64encodedUserName&Password’
}
};
Contract.setProvider(provider,options);
i did base64encoding as following ofcourse i used the actual id and secret
username=PROJECT ID
Password=PROJECT SECRET

Hi @hassan4621, and welcome to the Infura community!

I think I may be a little confused with how you’re using your project ID and secret. Your project ID should be used as follows:
https://<network>.infura.io/v3/YOUR-PROJECT-ID

Does the request work when you send a curl command that includes both Project ID and Project Secret, as demonstrated on this page of our docs?

"use strict";
const Web3 = require('web3');
var Contract = require('web3-eth-contract');
const fs = require('fs');
const HDWalletProvider = require("@truffle/hdwallet-provider");
const provider = new HDWalletProvider({
    mnemonic: {
        phrase: process.env.MNEMONIC
    },
    providerOrUrl: `https://ropsten.infura.io/v3/${process.env.INFURA_API_KEY}`
});
var roptions = {
    headers: {
      authorization: 'Basic MDViYjg1ZDYyNDY1NDZmZDljN2Y5MTY5OTU4MDUxMWI='
    }
};
Contract.setProvider(provider,roptions);
const contractABI = JSON.parse(fs.readFileSync('./contractABI.json', 'utf8'));
const web3 = new Web3(provider,roptions);
const contractAddress = '0x00';
let contract = new Contract(contractABI, contractAddress);

const options = {
    from: '0x00',
    gas: 150000,
    gasPrice: web3.utils.toWei('300', "gwei")
}
module.exports.buy = async (destAccount, amount) => {
    let response = {
        success: false,
        txHash: null,
        blockNumber: null,
        error: { status: false, msg: null, receipt: null },
    }
    let isValidEthAddress = web3.utils.checkAddressChecksum(destAccount);
    if (isValidEthAddress != true) {        // Don't send tx if destination address is not valid - save gas
        response.error.failCheck = 'Transaction not sent Invalid Address Checksum Failed '
        return response;
    }
    let result = new Promise((resolve, _reject) => {
        contract.methods.transfer(destAccount, web3.utils.toWei(amount, "ether")).send(options) //used instead of 10e18
            .on('receipt', function (receipt) {
                if (receipt.status == true && receipt.transactionHash) {
                    response.success = receipt.status;
                    response.txHash = receipt.transactionHash;
                    response.blockNumber = receipt.blockNumber;
                    resolve(response);
                }
                else if (receipt.status == false || !receipt.status || receipt.status == undefined) {
                    throw Error('Unexpected receipt triggered Error it is')
                }
            })
            .on('error', function (error, receipt) { // If the transaction was rejected by the network with a receipt, the second parameter will be the receipt.
                if (error && !receipt) {
                    response.error.status = true;
                    response.error.msg = error.msg;
                }
                else if (error && receipt) {
                    response.error.status = true;
                    response.error.msg = error.msg;
                    response.error.receipt = receipt;
                }
                else if (!error && !receipt) {
                    response.error.status = true;
                    response.error.msg = "Unexpected Error thrown"
                }
                // console.log('Here goes the error', error);
                // console.log('Here goes the errorReceipt', receipt);
                resolve(response);
            })
            .catch(function (error) {
                response.error.status = true;
                response.error.msg = error
                resolve(response);
            })
    })
    return result;
}

Here is the code I am using project ID as you suggested but how do we use project secret after we turn on in settings to use secret with all requests.
Secondly the basic auth header is generated using base64encoding of my project ID as username and secret as password
I put the projectID as secret is postman authorization tab(as shown in image attached in question) and got the encoded form in headers tab.
I have redacted the contract address and account address in here.
Also if i uncheck the settings to use project secret with each request in my project dashboard in INFURA the everything works fine.

Ah, yes! So when you uncheck the “Use Project Secret,” it will work because the Secret is only required when that item is checked off.
Since it works with Postman, we know that your ID and Secret are correct and functioning. However, for some reason, sometimes it will work if you have no username but you put your Secret as the password in the authorization section of the code. I would suggest trying that and seeing what happens.