Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
@viewar/backend-api
Advanced tools
Package to allow apps to change ViewAR content in the backend.
Package to allow apps to change ViewAR content in the backend.
Each request (read or write) will return the changed data from the server. This way the programmer can keep his own state in sync with the server state.
First a user must configure this module to get access to the backend. This should be done before any call to this API:
import { Configuration } from '@viewar/backend-api';
Configuration.setHost('https://dev2.viewar.com');
Second a user has to authenticate to set a valid token. The package internally saves the token during runtime.
One way is to authenticate with email and password:
import { Authentication } from '@viewar/backend-api';
const token = await Authentication.authenticate('john@viewar.com', '12345');
The other way is to directly use the token:
import { Authentication } from '@viewar/backend-api';
const token = 'token1234';
Authentication.useToken(token);
The storage is to read from ViewAR's cloud storage or write into it.
import { Storage } from '@viewar/backend-api';
const storageId = 'viewar.app.id';
// Write a file.
content = await Storage.write(storageId, 'test.json', {
test: 1234,
});
// Read from file.
let content = await Storage.read(storageId, 'test.json');
The resources namespace is used to handle resources on the ViewAR servers.
import { Resources } from '@viewar/backend-api';
const file = new File(['mocked file content'], 'filename.txt'); // Usually taken from UI input or from a filesystem read.
const name = 'Test Texture'; // Name of the texture.
const type = 'png'; // Either png or jpg.
// Create a new texture.
const texture = await Resources.createTexture(file, name, type);
ModelData is to read or write to a model's data field.
import { ModelData } from '@viewar/backend-api';
const modelId = '108721';
// Read model data.
let data = await ModelData.get(modelId);
// Update model data.
// Here we use object.assign to merge the new data with the
// existing ones (to avoid overwriting converter output).
data = await ModelData.save(
modelId,
Object.assign({}, data, {
test: 2345,
})
);
Every backend request can throw an error. If the request fails to reach the server a RequestError is thrown. If there is an error in the server response (e.g. authentication error) a BackendError is thrown.
import { Backend, ModelData, Authentication } from "@viewar/backend-api";
const token = "invalid token";
const modelId = "108721";
Authentication.useToken(token);
try {
// Try to get model data with invalid token.
await ModelData.get(modelId);
} catch(err) {
if (err instanceOf Backend.RequestError) {
// RequestError is thrown if connection to the server can't be established.
console.log("Failed to reach the server!", err.message);
} else if (err instanceOf Backend.BackendError) {
// BackendError will occur.
console.log("Server returned an error in response", err.message);
}
} else if (err instanceOf Backend.InvalidTokenError) {
// InvalidTokenError is thrown is neither Authentication.useToken nor Authentication.authenticate was called.
console.log("Please authenticate first.", err.message);
}
}
FAQs
Package to allow apps to change ViewAR content in the backend.
We found that @viewar/backend-api demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.