@acceleratxr/core_sdk
TypeScript icon, indicating that this package has built-in type declarations

3.1.0-alpha.12 • Public • Published

client_sdk_nodejs

Client SDK for working with AcceleratXR powered services.

Yarn

yarn add @acceleratxr/core_sdk

NPM

npm i @acceleratxr/core_sdk

Usage

SDK Initialization

To setup and initilize the SDK...

JavaScript

const { Configuration, CoreSDK } = require("@acceleratxr/core_sdk");

var config = new Configuration({
    baseUrl: "http://localhost:3000",
});
var sdk = new CoreSDK(config);

TypeScript

import { Configuration, CoreSDK } from "@acceleratxr/core_sdk";

const config: Configuration = new Configuration({
    baseUrl: "http://localhost:3000",
});
const sdk: CoreSDK = CoreSDK(config);

Account Registration

To register a new user account...

JavaScript

const { Profile, User } = require("@acceleratxr/core_sdk");

var user = new User({
    name: "username",
    givenName: "John",
    familyName: "Smith",
    email: "john.smith@gmail.com"
});

user = await sdk.registerUser(user);
// or
user = await sdk.registerUserAndPassword(user, "password");

TypeScript

import { Profile, User } from "@acceleratxr/core_sdk";

let user: User = new User({
    name: "username",
    givenName: "John",
    familyName: "Smith",
    email: "john.smith@gmail.com"
});

user = await sdk.registerUser(user);
// or
user = await sdk.registerUserAndPassword(user, "password");

Device Login

JavaScript

const { User } = require("@acceleratxr/core_sdk");

await sdk.loginDevice();
var user = sdk.loggedInUser;

TypeScript

import { User } from "@acceleratxr/core_sdk";

await sdk.loginDevice();
const user: User = sdk.loggedInUser;

User/Pass Login

To authenticate using basic username and password...

JavaScript

const { User } = require("@acceleratxr/core_sdk");

sdk.onAuthChallenge = async () => {
    // Capture TOTP code from user
    return totp;
}
await sdk.loginPassword("username","password");
var user = sdk.loggedInUser;

TypeScript

import { User } from "@acceleratxr/core_sdk";

sdk.onAuthChallenge = async () => {
    // Capture TOTP code from user
    return totp;
}
await sdk.loginPassword("username","password");
var user = sdk.loggedInUser;

Password-less Login

To authenticate using password-less login via e-mail or phone...

JavaScript

const { User } = require("@acceleratxr/core_sdk");

await sdk.loginEmail("username");
// or
await sdk.loginPhone("username");

// Wait for user input of code
await sdk.loginEmail("username","code");
// or
await sdk.loginPhone("username", "code");

var user = sdk.loggedInUser;

TypeScript

import { User } from "@acceleratxr/core_sdk";

await sdk.loginEmail("username");
// or
await sdk.loginPhone("username");

// Wait for user input of code
await sdk.loginEmail("username","code");
// or
await sdk.loginPhone("username", "code");

const user: User = sdk.loggedInUser;

Single-Sign On (OAuth)

To authenticate using an OAuth compatible single-sign on provider...

JavaScript

const { User } = require("@acceleratxr/core_sdk");

// Retrieve the auth URL of the OAuth provider
var url = await sdk.requestOAuth2(OAuth2Provider.DISCORD);

// Redirect user to URL and await callback return
await sdk.loginOAuth2(OAuth2Provider.DISCORD, code);

var user = sdk.loggedInUser;

TypeScript

import { User } from "@acceleratxr/core_sdk";

// Retrieve the auth URL of the OAuth provider
var url = await sdk.requestOAuth2(OAuth2Provider.DISCORD);

// Redirect user to URL and await callback return
await sdk.loginOAuth2(OAuth2Provider.DISCORD, code);

const user: User = sdk.loggedInUser;

License

This software is licensed under a custom XBE EULA. By using it, you agree to the terms.

Readme

Keywords

none

Package Sidebar

Install

npm i @acceleratxr/core_sdk

Weekly Downloads

571

Version

3.1.0-alpha.12

License

SEE LICENSE in LICENSE.md

Unpacked Size

7.36 MB

Total Files

832

Last publish

Collaborators

  • acceleratxr