@placeos/ts-client 4.7.4 → 4.7.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/functions.d.ts +1 -0
- package/dist/auth/interfaces.d.ts +2 -0
- package/dist/auth.d.ts +1 -1
- package/dist/index.cjs.js +2 -2
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +1155 -1132
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +2 -2
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/auth/functions.ts +9 -2
- package/src/auth/interfaces.ts +2 -0
- package/src/auth.ts +1 -0
package/package.json
CHANGED
package/src/auth/functions.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as base64 from 'byte-base64';
|
|
2
2
|
import * as sha256 from 'fast-sha256';
|
|
3
|
-
import { BehaviorSubject, Observable } from 'rxjs';
|
|
3
|
+
import { BehaviorSubject, Observable, lastValueFrom, timer } from 'rxjs';
|
|
4
4
|
import { fromFetch } from 'rxjs/fetch';
|
|
5
5
|
import { map } from 'rxjs/operators';
|
|
6
6
|
import { Md5 } from 'ts-md5';
|
|
@@ -259,7 +259,7 @@ export function checkStoreForAuthParam(
|
|
|
259
259
|
}
|
|
260
260
|
|
|
261
261
|
/** Initialise authentication for the http and realtime APIs */
|
|
262
|
-
export function setup(options: PlaceAuthOptions): Promise<void> {
|
|
262
|
+
export async function setup(options: PlaceAuthOptions): Promise<void> {
|
|
263
263
|
_options = options || _options;
|
|
264
264
|
_options.token_header = _options.token_header ?? isNestedFrame();
|
|
265
265
|
if (!window.AbortController) {
|
|
@@ -268,9 +268,16 @@ export function setup(options: PlaceAuthOptions): Promise<void> {
|
|
|
268
268
|
// Intialise storage
|
|
269
269
|
_storage = _options.storage === 'session' ? sessionStorage : localStorage;
|
|
270
270
|
_client_id = Md5.hashStr(_options.redirect_uri, false);
|
|
271
|
+
if (_options.delay && _options.delay > 0) {
|
|
272
|
+
await lastValueFrom(timer(_options.delay!));
|
|
273
|
+
}
|
|
271
274
|
return loadAuthority();
|
|
272
275
|
}
|
|
273
276
|
|
|
277
|
+
export function setStorage(type: 'session' | 'local'): void {
|
|
278
|
+
_storage = type === 'session' ? sessionStorage : localStorage;
|
|
279
|
+
}
|
|
280
|
+
|
|
274
281
|
/**
|
|
275
282
|
* @private
|
|
276
283
|
*/
|
package/src/auth/interfaces.ts
CHANGED
|
@@ -85,6 +85,8 @@ export interface PlaceAuthOptions {
|
|
|
85
85
|
version?: 'ACA Engine' | 'PlaceOS';
|
|
86
86
|
/** Whether X-API-KEY values should be ignored */
|
|
87
87
|
ignore_api_key?: boolean;
|
|
88
|
+
/** Delay authentication by X milliseconds */
|
|
89
|
+
delay?: number;
|
|
88
90
|
}
|
|
89
91
|
|
|
90
92
|
export interface PlaceTokenResponse {
|