imagevault-client
TypeScript icon, indicating that this package has built-in type declarations

0.0.26-beta • Public • Published

Build Status

imagevault-client

TypeScript implementation of an ImageVault client.

Table of Contents

  1. Installation
  2. Usage
  3. Supported grant types
  4. Supported services
  5. License and legal

Installation

npm install imagevault-client

Usage

This package is meant to be used from TypeScript and transpiled to javascript for use in webbrowsers.

TypeScript

// Here we import everything from the module
// under the ImageVault namespace.
import * as ImageVault from "imagevault-client";
 
// To authorize, we use authorization code grant.
// Read more on grant types at imagevault.se/doc
let grant = new ImageVault.AuthorizationCodeGrant("clientId",
                "clientSecret",
                false,
                "http://localhost:8080/posthere",
                null,
                codeUrlCallback);
 
// This client will be used for the actual API calls.
let client = new ImageVault.Client("https://my.imagevaulturl.com",
                grant,
                saveRefreshToken,
                retrieveRefreshToken);
 
// Example using MediaService Find with a search string
// and maximum result.
let filter = new ImageVault.MediaItemFilter();
 
filter.searchString = "when dolphins left the planet";
filter.take = 42;
 
// Set up the query and call Find
let query = new ImageVault.MediaItemQuery(filter);
let result = await ImageVault.MediaService.find(client, query);
 

Some callbacks are used for authorization flow and to allow re-use of Oauth tokens.

// With authorization code grant a URL needs to be opened
// to handle the code part. This is called when the URL should
// be opened.
function codeUrlCallback(url: string) {
    // Open URL here.
    // To complete authentication flow,
    // send code to client: client.sendAuthorizationCode
}
// This is called when the Authorization code grant
// has received a refresh token. The token can be saved
// to re-use for new access token.
function saveRefreshToken(refreshToken: string) {
    // Save refresh token for future use
}
// If you have a valid refresh token stored
// you can return it here and don't have
// to go through the entire Oauth
// authorization flow.
function retrieveRefreshToken(): string {
    // Return previously stored refresh token
}

Node.js

Currently not supported. The package uses native XMLHttpRequest which is currently not handled Node.js.

Supported Grant types

The following grant types are supported:

  • Authorization Code Grant
  • Authorization Pin Code Grant

You can get more information on ImageVault grant types on the official ImageVault REST authentication documentation.

Supported services

The following services and methods are supported:

  • CategoryService
    • GetCategories
  • InfoService
    • Version
  • MediaContentService
    • PublishMedia
  • MediaConversionService
    • GetMediaContentReferences
  • MediaService
    • Find
  • Assets
    • Info
    • Search

You can get more information on ImageVault services in the official ImageVault API service documentation and the new assets endpoint.

License and legal

This package is licensed under ISC, see included LICENSE file or here. ImageVault is a registered trademark of Meriworks Holding AB.

Note: Although the creator is an employee at ImageVault, this is not an official Meriworks or ImageVault product.

Dependencies (0)

    Dev Dependencies (4)

    Package Sidebar

    Install

    npm i imagevault-client

    Weekly Downloads

    1

    Version

    0.0.26-beta

    License

    ISC

    Unpacked Size

    95.5 kB

    Total Files

    71

    Last publish

    Collaborators

    • roqvist