Closed shlomoweb1 closed 3 months ago
Hi @shlomoweb1 Have you by any chance enabled logging info ?
Development System:
ProductName: macOS
ProductVersion: 14.2.1
BuildVersion: 23C71
NodeJS: 20.5.1
Using node:20.5.1-alpine inside production docker.
package.json
{
"name": "api",
"version": "1.0.44",
"scripts": {
.....
},
"module": "src/index.js",
"dependencies": {
"cookie-parser": "^1.4.6",
"dotenv": "^16.3.1",
"express": "^4.18.2",
"formidable": "^3.5.1",
"fs-extra": "^11.1.1",
"helmet": "^7.0.0",
"i18next": "^23.7.18",
"i18next-express-middleware": "^2.0.0",
"i18next-fs-backend": "^2.2.0",
"libphonenumber-js": "^1.10.41",
"module-alias": "^2.2.3",
"mongo-dot-notation": "^3.1.0",
"mongodb": "^5.7.0",
"mongoose": "^7.4.1",
"oci-common": "^2.79.1",
"oci-objectstorage": "^2.79.1",
"oci-sdk": "^2.79.1",
"readline": "^1.3.0",
"uuid": "^9.0.0",
"winston": "^3.10.0",
"winston-daily-rotate-file": "^4.7.1"
},
"devDependencies": {
"@types/cookie-parser": "^1.4.3",
"@types/formidable": "^3.4.2",
"@types/fs-extra": "^11.0.1",
"@types/module-alias": "^2.0.2",
"@types/node": "^20.5.0",
"@types/uuid": "^9.0.2",
"bun-types": "latest",
"patch-package": "^8.0.0",
"ts-node": "^10.9.1",
"ts-node-dev": "^2.0.0",
"typescript": "^5.1.6"
}
}
This is my oci_config
file.
[DEFAULT]
user=ocid1.user.oc1..aaaaaaaa.......[rest of user]
fingerprint=d5:a1:26:35:53:e4:9a:63:de:d0:a9:60:ba:41:74:48
tenancy=...some-tenancy
region=il-jerusalem-1
key_file=[location of pem file]
This is my wrapper to generate access keys to the bucket (object storage); I have nowhere else set for OCI, and the code work
import * as common from "oci-common";
import * as objectstorage from "oci-objectstorage";
import path from 'path';
import moment from 'moment';
// https://docs.oracle.com/en-us/iaas/api/#/en/objectstorage/20160918/PreauthenticatedRequest/CreatePreauthenticatedRequest
// Load OCI configuration from file
const configurationFilePath = path.join(__dirname, "oci_config"); // Update the path to your configuration file
const configProfile = "DEFAULT";
const provider: common.ConfigFileAuthenticationDetailsProvider = new common.ConfigFileAuthenticationDetailsProvider(
configurationFilePath,
configProfile
);
export const namespaceName = 'someNameSpace';
export const defaultBucket = "bucketName";
export const defaultRegion = 'il-jerusalem-1';
const client = new objectstorage.ObjectStorageClient({
authenticationDetailsProvider: provider
}, {});
// Function to generate a presigned URL
// https://docs.oracle.com/en-us/iaas/tools/typescript-sdk-examples/2.74.0/objectstorage/CreatePreauthenticatedRequest.ts.html
interface generatePresignedURLProps {
bucketName?: string;
objectName: string;
expirationInSeconds: number;
}
export const generatePresignedURL = async ({ bucketName, objectName, expirationInSeconds }: generatePresignedURLProps) => {
try {
// Create a service client
// const client = new objectstorage.ObjectStorageClient({
// authenticationDetailsProvider: provider
// });
const bucketListingAction = objectstorage.models.PreauthenticatedRequest.BucketListingAction.Deny;
const accessType = objectstorage.models.CreatePreauthenticatedRequestDetails.AccessType.AnyObjectReadWrite;
const timeExpires = moment().add(expirationInSeconds, 'seconds').toDate();
const random4DigitNumber = Math.floor(Math.random() * (9999 - 99 + 1)) + 99;
// https://docs.oracle.com/en-us/iaas/api/#/en/objectstorage/20160918/PreauthenticatedRequest/CreatePreauthenticatedRequest
const createPreauthenticatedRequestRequest: objectstorage.requests.CreatePreauthenticatedRequestRequest = {
namespaceName,
bucketName: bucketName || defaultBucket,
createPreauthenticatedRequestDetails: {
accessType,
name: `par-object-${moment().format('yyyymmDD')}-${random4DigitNumber.toString().padStart(4, '0')}`,
bucketListingAction,
objectName,
timeExpires
},
opcClientRequestId: (+new Date()).toString()
};
// Send request to the Client.
const createPreauthenticatedRequestResponse = await client.createPreauthenticatedRequest(
createPreauthenticatedRequestRequest
);
return createPreauthenticatedRequestResponse;
} catch (error) {
console.log("createPreauthenticatedRequest Failed with error " + error);
throw new Error('שגיאה בהרשאות יצירת אישור');
}
};
type generateViewURLprops = {
nameSpace: string;
bucketName: string;
objectName: string;
name: string;
expirationInSeconds: number;
}
export const generateViewURL = async (props: generateViewURLprops) => {
const bucketListingAction = objectstorage.models.PreauthenticatedRequest.BucketListingAction.Deny;
const accessType = objectstorage.models.CreatePreauthenticatedRequestDetails.AccessType.ObjectRead;
const timeExpires = moment().add(props.expirationInSeconds, 'seconds').toDate();
// https://docs.oracle.com/en-us/iaas/api/#/en/objectstorage/20160918/PreauthenticatedRequest/CreatePreauthenticatedRequest
const createPreauthenticatedRequestRequest: objectstorage.requests.CreatePreauthenticatedRequestRequest = {
namespaceName: props.nameSpace,
bucketName: props.bucketName,
createPreauthenticatedRequestDetails: {
accessType,
name: props.name,
bucketListingAction,
objectName: props.objectName,
timeExpires
},
opcClientRequestId: (+new Date()).toString()
};
try {
// Create a service client
const client = new objectstorage.ObjectStorageClient({
authenticationDetailsProvider: provider
});
// Send request to the Client.
const createPreauthenticatedRequestResponse = await client.createPreauthenticatedRequest(
createPreauthenticatedRequestRequest
);
return createPreauthenticatedRequestResponse;
} catch (error) {
console.log("generateViewURL Failed with error " + error);
throw new Error('שגיאה בהרשאות יצירת אישור');
}
}
// Usage
//const presignedURL = generatePresignedURL({ bucketName: "YOUR_BUCKET_NAME", objectName: "ANYTHING", expirationInSeconds: 300, fileName: "test-file.txt" }); // 5 minutes
Thanks for sharing @shlomoweb1 . We have figured out the issue. We are currently working on fixing it. I'll update here once its fixed.
@jyotisaini , is there any update on this issue? Thanks.
Fix available from 2.84.2 onwards
I am getting this message.
It is very annoying, and I do not want to have such messages in production; all the functions work, and I can't figure out why I keep seeing these messages