const secret = new KojiBackend.Secret({ res });
Handles sensitive data used in your Koji app.
Instantiates the Secret class.
config
- BackendConfigurationInput, Configuration information for the Koji app.
const secret = new KojiBackend.Secret({ res });
Generates a signed URL for securely serving a file, without exposing the permanent URI. This method provides additional security against sharing or rehosting of protected content.
resource
- String, Full URL of the resource. If the resource is an image hosted on the Koji CDN, you can pass in query parameters to transform it. For example, resize or crop the image.
expireSeconds
- Number (Optional), Amount of time for which the signed URL remains valid, in seconds. If undefined, signed videos expire after 1 hour, and any other resource expires after 5 minutes.
Promise<String>, Signed URL for the resource.
const temporaryImagePath = await secret.generateSignedUrl('https://images.koji-cdn.com/e83eaff0-279f-4403-951b-e56507af923d/userData/emfga-icon.png');
// Blur the image
const temporaryBlurredImagePath = await secret.generateSignedUrl('https://images.koji-cdn.com/e83eaff0-279f-4403-951b-e56507af923d/userData/emfga-icon.png?blur=10');
Source: backend/secret/index.ts#L122
Resolves sensitive data that was stored as an encrypted value on the base project from the Koji Developer Console. This is useful for securely storing things like API keys and other tokens.
keyPath
- String, Encrypted key name.
Promise<Any>, Decrypted value.
const decryptedValue = await secret.resolveEnvironmentValue('instagram_api_key');
Source: backend/secret/index.ts#L89
Resolves sensitive data that was {@doclink core-frontend-remix#encryptValue | stored as an encrypted value}.
keyPath
- String, Encrypted key name.
Promise<Any>, Decrypted value.
const decryptedValue = await secret.resolveValue(encryptedValue);
Source: backend/secret/index.ts#L61
Configuration information for the Koji app.
projectId
- String (Optional), Unique identifier for the Koji app. Will override data passed through `res`.
projectToken
- String (Optional), Secret key for the Koji app. Will override data passed through `res`.
res
- Response (Optional), Express response object. Used in conjunction with middleware to scope environment variables for customized versions of the original Koji app. For the original definition see [[https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/express/index.d.ts#L127 | @types/express]].