UNPKG

@trimble-oss/trimble-id

Version:

Trimble Identity SDK for JavaScript/ TypeScript

57 lines (52 loc) 1.83 kB
'use strict'; // implements ITokenProvider (function (root, factory) { /* istanbul ignore next */ if (typeof define === 'function' && define.amd) { // AMD define(['./AnalyticsHttpClient'], (AnalyticsHttpClient) => { return factory({ AnalyticsHttpClient: AnalyticsHttpClient, }); }); } else if (typeof exports === 'object') { // CommonJS module.exports = factory({ AnalyticsHttpClient: require('./AnalyticsHttpClient'), }); } else { // Browser globals (Note: root is window) root.FixedTokenProvider = factory(root); } }(this, function (imports) { /** * @implements {ITokenProvider} * @description FixedTokenProvider helps to return a fixed tokens */ class FixedTokenProvider { /** * @description Public constructor for FixedTokenProvider class * @param {string} token The fixed token to return */ constructor(token) { this._accessToken = token; //Send analytics this._analyticshttpclient = imports.AnalyticsHttpClient; this._analyticshttpclient.sendInitEvent(this.constructor.name); } /** * @description Retrieves an access token for the user or application * @returns {PromiseLike<string>} A Task that resolves to the value of the access token on completion */ RetrieveToken() { //Send analytics this._analyticshttpclient.sendMethodEvent(this.RetrieveToken.name); var self = this; return new Promise(function (resolve, reject) { resolve(self._accessToken); }); } } // Exposed public methods return FixedTokenProvider; }));