
Security News
NVD Quietly Sweeps 100K+ CVEs Into a “Deferred” Black Hole
NVD now marks all pre-2018 CVEs as "Deferred," signaling it will no longer enrich older vulnerabilities, further eroding trust in its data.
@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.
The npm package @viewar/backend-api receives a total of 27 weekly downloads. As such, @viewar/backend-api popularity was classified as not popular.
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
NVD now marks all pre-2018 CVEs as "Deferred," signaling it will no longer enrich older vulnerabilities, further eroding trust in its data.
Research
Security News
Lazarus-linked threat actors expand their npm malware campaign with new RAT loaders, hex obfuscation, and over 5,600 downloads across 11 packages.
Security News
Safari 18.4 adds support for Iterator Helpers and two other TC39 JavaScript features, bringing full cross-browser coverage to key parts of the ECMAScript spec.