@suprsend/web-sdk 4.1.2 → 4.3.0
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/cjs/index.cjs +1 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/es/index.js +479 -416
- package/dist/es/index.js.map +1 -1
- package/dist/types/api.d.ts +0 -1
- package/dist/types/feed.d.ts +0 -1
- package/dist/types/interface.d.ts +20 -0
- package/dist/types/main.d.ts +7 -6
- package/dist/types/preferences.d.ts +0 -1
- package/dist/types/user.d.ts +0 -1
- package/dist/types/utils.d.ts +14 -3
- package/dist/types/webpush.d.ts +0 -1
- package/package.json +6 -6
package/dist/types/api.d.ts
CHANGED
package/dist/types/feed.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Emitter } from 'mitt';
|
|
2
2
|
import { default as SuprSend } from './main';
|
|
3
3
|
import { IFeedOptions, IInboxFetchOptions, InboxEmitterEvents, ApiResponse, IFeedData } from './interface';
|
|
4
|
-
|
|
5
4
|
export default class FeedsFactory {
|
|
6
5
|
private config;
|
|
7
6
|
feedInstances: Feed[];
|
|
@@ -1,12 +1,32 @@
|
|
|
1
1
|
export type Dictionary = Record<string, unknown>;
|
|
2
|
+
export interface AppInfo {
|
|
3
|
+
name?: string;
|
|
4
|
+
version?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface ClientUserAgentConfig {
|
|
7
|
+
sdk?: string;
|
|
8
|
+
sdk_version?: string;
|
|
9
|
+
lang?: string;
|
|
10
|
+
platform?: string;
|
|
11
|
+
environment?: string;
|
|
12
|
+
os?: string;
|
|
13
|
+
os_version?: string;
|
|
14
|
+
app_info?: AppInfo;
|
|
15
|
+
browser?: string;
|
|
16
|
+
browser_version?: string;
|
|
17
|
+
device_model?: string;
|
|
18
|
+
}
|
|
2
19
|
export interface SuprSendOptions {
|
|
3
20
|
host?: string;
|
|
4
21
|
vapidKey?: string;
|
|
5
22
|
swFileName?: string;
|
|
23
|
+
appInfo?: AppInfo;
|
|
24
|
+
clientUserAgent?: ClientUserAgentConfig;
|
|
6
25
|
}
|
|
7
26
|
export type RefreshTokenCallback = (oldUserToken: string, tokenPayload: Dictionary) => Promise<string>;
|
|
8
27
|
export interface AuthenticateOptions {
|
|
9
28
|
refreshUserToken?: RefreshTokenCallback;
|
|
29
|
+
createUser?: boolean;
|
|
10
30
|
}
|
|
11
31
|
export interface ResponseOptions {
|
|
12
32
|
status: RESPONSE_STATUS.ERROR | RESPONSE_STATUS.SUCCESS;
|
package/dist/types/main.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { Emitter } from 'mitt';
|
|
2
|
-
import { SuprSendOptions, Dictionary, EmitterEvents, AuthenticateOptions } from './interface';
|
|
2
|
+
import { SuprSendOptions, Dictionary, EmitterEvents, AuthenticateOptions, ApiResponse, ClientUserAgentConfig } from './interface';
|
|
3
3
|
import { default as ApiClient } from './api';
|
|
4
4
|
import { default as User } from './user';
|
|
5
5
|
import { default as WebPush } from './webpush';
|
|
6
6
|
import { default as FeedsFactory } from './feed';
|
|
7
|
-
|
|
8
7
|
export default class SuprSend {
|
|
9
8
|
host: string;
|
|
10
9
|
publicApiKey: string;
|
|
@@ -12,6 +11,8 @@ export default class SuprSend {
|
|
|
12
11
|
userToken?: string;
|
|
13
12
|
vapidKey: string;
|
|
14
13
|
swFileName: string;
|
|
14
|
+
clientUserAgent: ClientUserAgentConfig;
|
|
15
|
+
userAgent: string;
|
|
15
16
|
private apiClient;
|
|
16
17
|
private userTokenExpirationTimer;
|
|
17
18
|
authenticateOptions?: AuthenticateOptions;
|
|
@@ -22,12 +23,12 @@ export default class SuprSend {
|
|
|
22
23
|
constructor(publicApiKey: string, options?: SuprSendOptions);
|
|
23
24
|
private handleRefreshUserToken;
|
|
24
25
|
client(): ApiClient;
|
|
25
|
-
eventApi(payload: Dictionary): Promise<
|
|
26
|
+
eventApi(payload: Dictionary): Promise<ApiResponse>;
|
|
26
27
|
/**
|
|
27
28
|
* Used to authenticate user. Usually called just after successful login and on reload of loggedin route to re-authenticate loggedin user.
|
|
28
29
|
* In production env's userToken is mandatory for security purposes.
|
|
29
30
|
*/
|
|
30
|
-
identify(distinctId: unknown, userToken?: string, options?: AuthenticateOptions): Promise<
|
|
31
|
+
identify(distinctId: unknown, userToken?: string, options?: AuthenticateOptions): Promise<ApiResponse>;
|
|
31
32
|
/**
|
|
32
33
|
* Check's if SuprSend instance is authenticated. To check if userToken is also present pass true.
|
|
33
34
|
*/
|
|
@@ -35,11 +36,11 @@ export default class SuprSend {
|
|
|
35
36
|
/**
|
|
36
37
|
* Used to trigger events to suprsend.
|
|
37
38
|
*/
|
|
38
|
-
track(event: string, properties?: Dictionary): Promise<
|
|
39
|
+
track(event: string, properties?: Dictionary): Promise<ApiResponse>;
|
|
39
40
|
/**
|
|
40
41
|
* Clears user related data attached to SuprSend instance. Usually called during logout.
|
|
41
42
|
*/
|
|
42
43
|
reset(options?: {
|
|
43
44
|
unsubscribePush?: boolean;
|
|
44
|
-
}): Promise<
|
|
45
|
+
}): Promise<ApiResponse>;
|
|
45
46
|
}
|
package/dist/types/user.d.ts
CHANGED
package/dist/types/utils.d.ts
CHANGED
|
@@ -1,15 +1,26 @@
|
|
|
1
|
-
import { ApiResponse, Dictionary, ResponseOptions } from './interface';
|
|
2
|
-
|
|
1
|
+
import { ApiResponse, AppInfo, ClientUserAgentConfig, Dictionary, ResponseOptions } from './interface';
|
|
3
2
|
export declare function uuid(): string;
|
|
4
3
|
export declare function epochMs(): number;
|
|
5
4
|
export declare function isObjectEmpty(objectName: Dictionary): boolean;
|
|
6
5
|
export declare function isArrayEmpty(arrayName: unknown[]): boolean;
|
|
7
|
-
export declare function urlB64ToUint8Array(base64String: string): Uint8Array
|
|
6
|
+
export declare function urlB64ToUint8Array(base64String: string): Uint8Array<ArrayBuffer>;
|
|
8
7
|
export declare function debounce<T extends unknown[], U>(callback: (...args: T) => PromiseLike<U> | U, wait: number): (...args: T) => Promise<U>;
|
|
9
8
|
export declare function debounceByType(func: any, wait: any): (...args: any[]) => any;
|
|
10
9
|
export declare function getResponsePayload(options: ResponseOptions): ApiResponse;
|
|
11
10
|
export declare function windowSupport(): boolean;
|
|
11
|
+
export declare function localStorageSupport(): boolean;
|
|
12
12
|
export declare function setLocalStorageData(key: string, value: string): void;
|
|
13
13
|
export declare function getLocalStorageData(key: string): any;
|
|
14
14
|
export declare function removeLocalStorageData(key: string): void;
|
|
15
|
+
export declare function detectOS(ua?: string): {
|
|
16
|
+
os: string;
|
|
17
|
+
os_version: string;
|
|
18
|
+
};
|
|
19
|
+
export declare function detectBrowser(ua?: string): {
|
|
20
|
+
browser: string;
|
|
21
|
+
browser_version: string;
|
|
22
|
+
};
|
|
23
|
+
export declare function detectEnvironment(ua?: string): string;
|
|
24
|
+
export declare function buildClientUserAgent(appInfo?: AppInfo, override?: ClientUserAgentConfig): ClientUserAgentConfig;
|
|
25
|
+
export declare function buildUserAgent(config: ClientUserAgentConfig): string;
|
|
15
26
|
export declare function sha256Hash(input: string): Promise<string>;
|
package/dist/types/webpush.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@suprsend/web-sdk",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.3.0",
|
|
4
4
|
"description": "The client side javascript library for interacting with SuprSend",
|
|
5
5
|
"author": "SuprSend Developers",
|
|
6
6
|
"type": "module",
|
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
"typings": "./dist/types/index.d.ts",
|
|
12
12
|
"exports": {
|
|
13
13
|
".": {
|
|
14
|
-
"
|
|
14
|
+
"types": "./dist/types/index.d.ts",
|
|
15
15
|
"import": "./dist/es/index.js",
|
|
16
|
-
"
|
|
17
|
-
"
|
|
16
|
+
"require": "./dist/cjs/index.cjs",
|
|
17
|
+
"default": "./dist/es/index.js"
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
"files": [
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
"rimraf": "4.4.1",
|
|
49
49
|
"typescript": "^5.5.3",
|
|
50
50
|
"typescript-eslint": "^7.16.1",
|
|
51
|
-
"vite": "^
|
|
52
|
-
"vite-plugin-dts": "^
|
|
51
|
+
"vite": "^6.4.2",
|
|
52
|
+
"vite-plugin-dts": "^4.5.4"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"jwt-decode": "3.1.2",
|