@vitia.ai/secure-api-client-vue 0.1.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/LICENSE +21 -0
- package/README.md +46 -0
- package/dist/index.cjs +65 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +104 -0
- package/dist/index.mjs +3084 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +55 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { App } from 'vue';
|
|
2
|
+
|
|
3
|
+
declare type EventType = 'request' | 'status' | 'topic';
|
|
4
|
+
|
|
5
|
+
export declare type LoginOptions = {
|
|
6
|
+
username: string;
|
|
7
|
+
password: string;
|
|
8
|
+
scope: string;
|
|
9
|
+
} | {
|
|
10
|
+
email: string;
|
|
11
|
+
socialLoginId: string;
|
|
12
|
+
scope: string;
|
|
13
|
+
} | {
|
|
14
|
+
jwt: string;
|
|
15
|
+
} | {
|
|
16
|
+
refreshToken: string;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export declare class Notifications {
|
|
20
|
+
private client;
|
|
21
|
+
private ws;
|
|
22
|
+
private listeners;
|
|
23
|
+
private subscriptions;
|
|
24
|
+
private _shouldReconnect;
|
|
25
|
+
private _reconnectAttempt;
|
|
26
|
+
private _connectPromise?;
|
|
27
|
+
constructor(client: SecureApiClient);
|
|
28
|
+
private scheduleReconnect;
|
|
29
|
+
close(): void;
|
|
30
|
+
connect(): Promise<void>;
|
|
31
|
+
generateRandomString: (length: number) => string;
|
|
32
|
+
unsuscribe(eventType: EventType, eventValue: string, label: string): void;
|
|
33
|
+
unlisten(label: string): void;
|
|
34
|
+
suscribe(eventType: EventType, eventValue: string, fn: (msg: any) => void, label?: string): () => void;
|
|
35
|
+
onMessage(fn: (msg: any) => void, label?: string): () => void;
|
|
36
|
+
disconnect(): void;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export declare const SDK_CLIENT: unique symbol;
|
|
40
|
+
|
|
41
|
+
export declare const SdkPlugin: {
|
|
42
|
+
install(app: App, options: SdkPluginOptions): void;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
declare type SdkPluginOptions = SecureApiClientConfig;
|
|
46
|
+
|
|
47
|
+
export declare class SecureApiClient {
|
|
48
|
+
private baseUrl;
|
|
49
|
+
private clientId;
|
|
50
|
+
private session;
|
|
51
|
+
private serverPublicKeyPem;
|
|
52
|
+
private clientIdentityKeyPromise;
|
|
53
|
+
notifications: Notifications;
|
|
54
|
+
constructor(config: SecureApiClientConfig);
|
|
55
|
+
private loadPersistedSession;
|
|
56
|
+
private persistSession;
|
|
57
|
+
handshake(): Promise<void>;
|
|
58
|
+
getUserId(): string | undefined;
|
|
59
|
+
getAccessToken(): string | undefined;
|
|
60
|
+
updateSession(partial: Partial<SessionState>): void;
|
|
61
|
+
getSession(): Readonly<SessionState>;
|
|
62
|
+
private encryptBody;
|
|
63
|
+
private signRequest;
|
|
64
|
+
get<T = any>(path: string): Promise<T>;
|
|
65
|
+
post<T = any>(path: string, body: any): Promise<T>;
|
|
66
|
+
ensureSession(): Promise<void>;
|
|
67
|
+
extendHandshake(): Promise<void>;
|
|
68
|
+
decryptAndVerify(msg: any): Promise<any>;
|
|
69
|
+
private constantTimeEqual;
|
|
70
|
+
login(options: LoginOptions): Promise<{
|
|
71
|
+
accessToken: any;
|
|
72
|
+
tokenType: any;
|
|
73
|
+
expiresAt: any;
|
|
74
|
+
refreshToken: any;
|
|
75
|
+
}>;
|
|
76
|
+
refresh(): Promise<{
|
|
77
|
+
accessToken: any;
|
|
78
|
+
tokenType: any;
|
|
79
|
+
expiresAt: any;
|
|
80
|
+
refreshToken: any;
|
|
81
|
+
} | undefined>;
|
|
82
|
+
isTokenExpired(): boolean | undefined;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export declare type SecureApiClientConfig = {
|
|
86
|
+
baseUrl: string;
|
|
87
|
+
clientId: string;
|
|
88
|
+
serverPublicKeyPem: string;
|
|
89
|
+
clientIdentityPrivateKeyPem: string;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export declare type SessionState = {
|
|
93
|
+
sessionId: string;
|
|
94
|
+
encKey: CryptoKey;
|
|
95
|
+
macKey: CryptoKey;
|
|
96
|
+
sessionExpiresAt: string;
|
|
97
|
+
userId?: string;
|
|
98
|
+
accessToken?: string;
|
|
99
|
+
tokenType?: string;
|
|
100
|
+
expiresAt?: number;
|
|
101
|
+
refreshToken?: string;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
export { }
|