@vuu-ui/vuu-data-remote 0.13.73 → 0.13.74
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/cjs/ConnectionManager.js +3 -1
- package/cjs/ConnectionManager.js.map +1 -1
- package/cjs/authenticate.js +41 -20
- package/cjs/authenticate.js.map +1 -1
- package/cjs/index.js +1 -0
- package/cjs/index.js.map +1 -1
- package/cjs/inlined-worker.js +3 -6
- package/cjs/inlined-worker.js.map +1 -1
- package/esm/ConnectionManager.js +3 -1
- package/esm/ConnectionManager.js.map +1 -1
- package/esm/authenticate.js +41 -21
- package/esm/authenticate.js.map +1 -1
- package/esm/index.js +1 -1
- package/esm/inlined-worker.js +3 -6
- package/esm/inlined-worker.js.map +1 -1
- package/package.json +7 -7
- package/types/ConnectionManager.d.ts +1 -1
- package/types/authenticate.d.ts +11 -1
- package/types/index.d.ts +1 -1
- package/types/inlined-worker.d.ts +1 -1
- package/types/server-proxy/server-proxy.d.ts +1 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConnectionManager.js","sources":["../../../packages/vuu-data-remote/src/ConnectionManager.ts"],"sourcesContent":["import {\n ConnectOptions,\n DataSourceCallbackMessage,\n ServerAPI,\n ServerProxySubscribeMessage,\n TableSchema,\n VuuUIMessageIn,\n} from \"@vuu-ui/vuu-data-types\";\nimport {\n SelectRequest,\n SelectResponse,\n VuuCreateVisualLink,\n VuuLoginResponse,\n VuuRemoveVisualLink,\n VuuRpcMenuRequest,\n VuuRpcServiceRequest,\n VuuTableList,\n VuuTableListRequest,\n VuuTableMetaRequest,\n} from \"@vuu-ui/vuu-protocol-types\";\nimport {\n DeferredPromise,\n EventEmitter,\n isConnectionQualityMetrics,\n isLoginResponse,\n isRequestResponse,\n isTableSchemaMessage,\n messageHasResult,\n uuid,\n} from \"@vuu-ui/vuu-utils\";\nimport {\n WebSocketConnectionEvents,\n WebSocketConnectionState,\n isWebSocketConnectionMessage,\n} from \"./WebSocketConnection\";\nimport { DedicatedWorker } from \"./DedicatedWorker\";\nimport { shouldMessageBeRoutedToDataSource } from \"./data-source\";\n\nimport { ConnectionQualityMetrics } from \"@vuu-ui/vuu-data-types\";\n\nexport type PostMessageToClientCallback = (\n msg: DataSourceCallbackMessage,\n) => void;\n\nexport type ConnectionEvents = WebSocketConnectionEvents & {\n \"connection-metrics\": (message: ConnectionQualityMetrics) => void;\n \"session-status\": (loginResponse: VuuLoginResponse) => void;\n};\n\ntype RegisteredViewport = {\n postMessageToClientDataSource: PostMessageToClientCallback;\n request: ServerProxySubscribeMessage;\n status: \"subscribing\";\n};\n\nclass ConnectionManager extends EventEmitter<ConnectionEvents> {\n #connectionState: WebSocketConnectionState = {\n connectionPhase: \"connecting\",\n connectionStatus: \"closed\",\n retryAttemptsTotal: -1,\n retryAttemptsRemaining: -1,\n secondsToNextRetry: -1,\n };\n static #instance: ConnectionManager;\n #deferredServerAPI = new DeferredPromise<ServerAPI>();\n #pendingRequests = new Map();\n #viewports = new Map<string, RegisteredViewport>();\n // #worker?: Worker;\n #worker: DedicatedWorker;\n\n private constructor() {\n super();\n this.#worker = new DedicatedWorker(this.handleMessageFromWorker);\n }\n\n public static get instance(): ConnectionManager {\n if (!ConnectionManager.#instance) {\n ConnectionManager.#instance = new ConnectionManager();\n }\n return ConnectionManager.#instance;\n }\n\n /**\n * Open a connection to the VuuServer. This method opens the websocket connection\n * and logs in. It can be called from whichever client code has access to the auth\n * token (eg. the login page, or just a hardcoded login script in a sample).\n * This will unblock any DataSources which may have already tried to subscribe to data,\n * but lacked access to the auth token.\n *\n * @param serverUrl\n * @param token\n */\n async connect(options: ConnectOptions) {\n const result = await this.#worker.connect(options);\n if (result === \"connected\") {\n this.#deferredServerAPI.resolve(this.connectedServerAPI);\n }\n return result;\n }\n\n private handleMessageFromWorker = (\n message: VuuUIMessageIn | DataSourceCallbackMessage,\n ) => {\n if (shouldMessageBeRoutedToDataSource(message)) {\n const viewport = this.#viewports.get(message.clientViewportId);\n if (viewport) {\n viewport.postMessageToClientDataSource(message);\n } else {\n console.error(\n `[ConnectionManager] ${message.type} message received, viewport not found`,\n );\n }\n } else if (isLoginResponse(message)) {\n this.emit(\"session-status\", message);\n } else if (isWebSocketConnectionMessage(message)) {\n this.#connectionState = message;\n this.emit(\"connection-status\", message);\n } else if (isConnectionQualityMetrics(message)) {\n this.emit(\"connection-metrics\", message);\n } else if (isRequestResponse(message)) {\n const { requestId } = message;\n if (this.#pendingRequests.has(requestId)) {\n const { resolve } = this.#pendingRequests.get(requestId);\n this.#pendingRequests.delete(requestId);\n const { requestId: _, ...messageWithoutRequestId } = message;\n\n if (messageHasResult(message)) {\n resolve(message.result);\n } else if (\n message.type === \"VP_EDIT_RPC_RESPONSE\" ||\n message.type === \"VP_EDIT_RPC_REJECT\"\n ) {\n resolve(message);\n } else if (isTableSchemaMessage(message)) {\n resolve(message.tableSchema);\n } else {\n resolve(messageWithoutRequestId);\n }\n } else {\n console.warn(\n \"%cConnectionManager Unexpected message from the worker\",\n \"color:red;font-weight:bold;\",\n );\n }\n }\n };\n\n get connectionStatus() {\n return this.#connectionState.connectionStatus;\n }\n\n get serverAPI() {\n return this.#deferredServerAPI.promise;\n }\n\n private connectedServerAPI: ServerAPI = {\n subscribe: (message, callback) => {\n if (this.#viewports.get(message.viewport)) {\n throw Error(\n `ConnectionManager attempting to subscribe with an existing viewport id`,\n );\n }\n // TODO we never use this status\n this.#viewports.set(message.viewport, {\n status: \"subscribing\",\n request: message,\n postMessageToClientDataSource: callback,\n });\n this.#worker.send({ type: \"subscribe\", ...message });\n },\n\n unsubscribe: (viewport) => {\n this.#worker.send({ type: \"unsubscribe\", viewport });\n },\n\n send: (message) => {\n this.#worker.send(message);\n },\n\n destroy: (viewportId?: string) => {\n if (viewportId && this.#viewports.has(viewportId)) {\n this.#viewports.delete(viewportId);\n }\n },\n\n rpcCall: async <T = unknown>(\n message:\n | VuuRpcServiceRequest\n | VuuRpcMenuRequest\n | VuuCreateVisualLink\n | VuuRemoveVisualLink,\n ) => this.asyncRequest<T>(message),\n\n select: async (selectRequest: SelectRequest) =>\n this.asyncRequest<SelectResponse>(selectRequest),\n\n getTableList: async () =>\n this.asyncRequest<VuuTableList>({ type: \"GET_TABLE_LIST\" }),\n\n getTableSchema: async (table) =>\n this.asyncRequest<TableSchema>({\n type: \"GET_TABLE_META\",\n table,\n }),\n };\n\n private asyncRequest = <T = unknown>(\n msg:\n | VuuRpcServiceRequest\n | VuuRpcMenuRequest\n | VuuTableListRequest\n | VuuTableMetaRequest\n | VuuCreateVisualLink\n | VuuRemoveVisualLink\n | SelectRequest,\n ): Promise<T> => {\n const requestId = uuid();\n this.#worker.send({\n requestId,\n ...msg,\n });\n return new Promise((resolve, reject) => {\n this.#pendingRequests.set(requestId, { resolve, reject });\n });\n };\n\n async disconnect() {\n try {\n this.#worker.send({ type: \"disconnect\" });\n this.#deferredServerAPI = new DeferredPromise<ServerAPI>();\n return \"disconnected\";\n } catch (err: unknown) {\n return \"rejected\";\n }\n }\n\n destroy() {\n this.#worker.terminate();\n }\n}\n\nexport default ConnectionManager.instance;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,IAAA,gBAAA,EAAA,SAAA,EAAA,kBAAA,EAAA,gBAAA,EAAA,UAAA,EAAA,OAAA;AAuDA,MAAM,kBAAA,GAAN,MAAM,kBAAA,SAA0B,YAA+B,CAAA;AAAA,EAerD,WAAc,GAAA;AACpB,IAAM,KAAA,EAAA;AAfR,IAA6C,YAAA,CAAA,IAAA,EAAA,gBAAA,EAAA;AAAA,MAC3C,eAAiB,EAAA,YAAA;AAAA,MACjB,gBAAkB,EAAA,QAAA;AAAA,MAClB,kBAAoB,EAAA,CAAA,CAAA;AAAA,MACpB,sBAAwB,EAAA,CAAA,CAAA;AAAA,MACxB,kBAAoB,EAAA,CAAA;AAAA,KACtB,CAAA;AAEA,IAAA,YAAA,CAAA,IAAA,EAAA,kBAAA,EAAqB,IAAI,eAA2B,EAAA,CAAA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B,EAAA,CAAA;AACzD,MAAO,OAAA,cAAA;AAAA,aACA,GAAc,EAAA;AACrB,MAAO,OAAA,UAAA;AAAA;AACT;AACF,EAEA,OAAU,GAAA;AACR,IAAA,YAAA,CAAA,IAAA,EAAK,SAAQ,SAAU,EAAA;AAAA;AAE3B,CAAA;AAvLE,gBAAA,GAAA,IAAA,OAAA,EAAA;AAOO,SAAA,GAAA,IAAA,OAAA,EAAA;AACP,kBAAA,GAAA,IAAA,OAAA,EAAA;AACA,gBAAA,GAAA,IAAA,OAAA,EAAA;AACA,UAAA,GAAA,IAAA,OAAA,EAAA;AAEA,OAAA,GAAA,IAAA,OAAA,EAAA;AALA,YAAA,CARI,kBAQG,EAAA,SAAA,CAAA;AART,IAAM,iBAAN,GAAA,kBAAA;AA0LA,0BAAe,iBAAkB,CAAA,QAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"ConnectionManager.js","sources":["../../../packages/vuu-data-remote/src/ConnectionManager.ts"],"sourcesContent":["import {\n ConnectOptions,\n DataSourceCallbackMessage,\n ServerAPI,\n ServerProxySubscribeMessage,\n TableSchema,\n VuuUIMessageIn,\n} from \"@vuu-ui/vuu-data-types\";\nimport {\n SelectRequest,\n SelectResponse,\n VuuCreateVisualLink,\n VuuLoginResponse,\n VuuRemoveVisualLink,\n VuuRpcMenuRequest,\n VuuRpcServiceRequest,\n VuuTableList,\n VuuTableListRequest,\n VuuTableMetaRequest,\n} from \"@vuu-ui/vuu-protocol-types\";\nimport {\n DeferredPromise,\n EventEmitter,\n isConnectionQualityMetrics,\n isLoginResponse,\n isRequestResponse,\n isTableSchemaMessage,\n messageHasResult,\n uuid,\n} from \"@vuu-ui/vuu-utils\";\nimport {\n WebSocketConnectionEvents,\n WebSocketConnectionState,\n isWebSocketConnectionMessage,\n} from \"./WebSocketConnection\";\nimport { DedicatedWorker } from \"./DedicatedWorker\";\nimport { shouldMessageBeRoutedToDataSource } from \"./data-source\";\n\nimport { ConnectionQualityMetrics } from \"@vuu-ui/vuu-data-types\";\n\nexport type PostMessageToClientCallback = (\n msg: DataSourceCallbackMessage,\n) => void;\n\nexport type ConnectionEvents = WebSocketConnectionEvents & {\n \"connection-metrics\": (message: ConnectionQualityMetrics) => void;\n \"session-status\": (loginResponse: VuuLoginResponse) => void;\n};\n\ntype RegisteredViewport = {\n postMessageToClientDataSource: PostMessageToClientCallback;\n request: ServerProxySubscribeMessage;\n status: \"subscribing\";\n};\n\nclass ConnectionManager extends EventEmitter<ConnectionEvents> {\n #connectionState: WebSocketConnectionState = {\n connectionPhase: \"connecting\",\n connectionStatus: \"closed\",\n retryAttemptsTotal: -1,\n retryAttemptsRemaining: -1,\n secondsToNextRetry: -1,\n };\n static #instance: ConnectionManager;\n #deferredServerAPI = new DeferredPromise<ServerAPI>();\n #pendingRequests = new Map();\n #viewports = new Map<string, RegisteredViewport>();\n // #worker?: Worker;\n #worker: DedicatedWorker;\n\n private constructor() {\n super();\n this.#worker = new DedicatedWorker(this.handleMessageFromWorker);\n }\n\n public static get instance(): ConnectionManager {\n if (!ConnectionManager.#instance) {\n ConnectionManager.#instance = new ConnectionManager();\n }\n return ConnectionManager.#instance;\n }\n\n /**\n * Open a connection to the VuuServer. This method opens the websocket connection\n * and logs in. It can be called from whichever client code has access to the auth\n * token (eg. the login page, or just a hardcoded login script in a sample).\n * This will unblock any DataSources which may have already tried to subscribe to data,\n * but lacked access to the auth token.\n *\n * @param serverUrl\n * @param token\n */\n async connect(options: ConnectOptions, throwOnRejected = false) {\n const result = await this.#worker.connect(options);\n if (result === \"connected\") {\n this.#deferredServerAPI.resolve(this.connectedServerAPI);\n } else if (result === \"rejected\" && throwOnRejected) {\n throw Error(\"[ConnectionManager] connection rejected\");\n }\n return result;\n }\n\n private handleMessageFromWorker = (\n message: VuuUIMessageIn | DataSourceCallbackMessage,\n ) => {\n if (shouldMessageBeRoutedToDataSource(message)) {\n const viewport = this.#viewports.get(message.clientViewportId);\n if (viewport) {\n viewport.postMessageToClientDataSource(message);\n } else {\n console.error(\n `[ConnectionManager] ${message.type} message received, viewport not found`,\n );\n }\n } else if (isLoginResponse(message)) {\n this.emit(\"session-status\", message);\n } else if (isWebSocketConnectionMessage(message)) {\n this.#connectionState = message;\n this.emit(\"connection-status\", message);\n } else if (isConnectionQualityMetrics(message)) {\n this.emit(\"connection-metrics\", message);\n } else if (isRequestResponse(message)) {\n const { requestId } = message;\n if (this.#pendingRequests.has(requestId)) {\n const { resolve } = this.#pendingRequests.get(requestId);\n this.#pendingRequests.delete(requestId);\n const { requestId: _, ...messageWithoutRequestId } = message;\n\n if (messageHasResult(message)) {\n resolve(message.result);\n } else if (\n message.type === \"VP_EDIT_RPC_RESPONSE\" ||\n message.type === \"VP_EDIT_RPC_REJECT\"\n ) {\n resolve(message);\n } else if (isTableSchemaMessage(message)) {\n resolve(message.tableSchema);\n } else {\n resolve(messageWithoutRequestId);\n }\n } else {\n console.warn(\n \"%cConnectionManager Unexpected message from the worker\",\n \"color:red;font-weight:bold;\",\n );\n }\n }\n };\n\n get connectionStatus() {\n return this.#connectionState.connectionStatus;\n }\n\n get serverAPI() {\n return this.#deferredServerAPI.promise;\n }\n\n private connectedServerAPI: ServerAPI = {\n subscribe: (message, callback) => {\n if (this.#viewports.get(message.viewport)) {\n throw Error(\n `ConnectionManager attempting to subscribe with an existing viewport id`,\n );\n }\n // TODO we never use this status\n this.#viewports.set(message.viewport, {\n status: \"subscribing\",\n request: message,\n postMessageToClientDataSource: callback,\n });\n this.#worker.send({ type: \"subscribe\", ...message });\n },\n\n unsubscribe: (viewport) => {\n this.#worker.send({ type: \"unsubscribe\", viewport });\n },\n\n send: (message) => {\n this.#worker.send(message);\n },\n\n destroy: (viewportId?: string) => {\n if (viewportId && this.#viewports.has(viewportId)) {\n this.#viewports.delete(viewportId);\n }\n },\n\n rpcCall: async <T = unknown>(\n message:\n | VuuRpcServiceRequest\n | VuuRpcMenuRequest\n | VuuCreateVisualLink\n | VuuRemoveVisualLink,\n ) => this.asyncRequest<T>(message),\n\n select: async (selectRequest: SelectRequest) =>\n this.asyncRequest<SelectResponse>(selectRequest),\n\n getTableList: async () =>\n this.asyncRequest<VuuTableList>({ type: \"GET_TABLE_LIST\" }),\n\n getTableSchema: async (table) =>\n this.asyncRequest<TableSchema>({\n type: \"GET_TABLE_META\",\n table,\n }),\n };\n\n private asyncRequest = <T = unknown>(\n msg:\n | VuuRpcServiceRequest\n | VuuRpcMenuRequest\n | VuuTableListRequest\n | VuuTableMetaRequest\n | VuuCreateVisualLink\n | VuuRemoveVisualLink\n | SelectRequest,\n ): Promise<T> => {\n const requestId = uuid();\n this.#worker.send({\n requestId,\n ...msg,\n });\n return new Promise((resolve, reject) => {\n this.#pendingRequests.set(requestId, { resolve, reject });\n });\n };\n\n async disconnect() {\n try {\n this.#worker.send({ type: \"disconnect\" });\n this.#deferredServerAPI = new DeferredPromise<ServerAPI>();\n return \"disconnected\";\n } catch (err: unknown) {\n return \"rejected\";\n }\n }\n\n destroy() {\n this.#worker.terminate();\n }\n}\n\nexport default ConnectionManager.instance;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,IAAA,gBAAA,EAAA,SAAA,EAAA,kBAAA,EAAA,gBAAA,EAAA,UAAA,EAAA,OAAA;AAuDA,MAAM,kBAAA,GAAN,MAAM,kBAAA,SAA0B,YAA+B,CAAA;AAAA,EAerD,WAAc,GAAA;AACpB,IAAM,KAAA,EAAA;AAfR,IAA6C,YAAA,CAAA,IAAA,EAAA,gBAAA,EAAA;AAAA,MAC3C,eAAiB,EAAA,YAAA;AAAA,MACjB,gBAAkB,EAAA,QAAA;AAAA,MAClB,kBAAoB,EAAA,CAAA,CAAA;AAAA,MACpB,sBAAwB,EAAA,CAAA,CAAA;AAAA,MACxB,kBAAoB,EAAA,CAAA;AAAA,KACtB,CAAA;AAEA,IAAA,YAAA,CAAA,IAAA,EAAA,kBAAA,EAAqB,IAAI,eAA2B,EAAA,CAAA;AACpD,IAAA,YAAA,CAAA,IAAA,EAAA,gBAAA,sBAAuB,G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AAM,cAAc,CAAA;AACxC,MAAK,YAAA,CAAA,IAAA,EAAA,kBAAA,EAAqB,IAAI,eAA2B,EAAA,CAAA;AACzD,MAAO,OAAA,cAAA;AAAA,aACA,GAAc,EAAA;AACrB,MAAO,OAAA,UAAA;AAAA;AACT;AACF,EAEA,OAAU,GAAA;AACR,IAAA,YAAA,CAAA,IAAA,EAAK,SAAQ,SAAU,EAAA;AAAA;AAE3B,CAAA;AAzLE,gBAAA,GAAA,IAAA,OAAA,EAAA;AAOO,SAAA,GAAA,IAAA,OAAA,EAAA;AACP,kBAAA,GAAA,IAAA,OAAA,EAAA;AACA,gBAAA,GAAA,IAAA,OAAA,EAAA;AACA,UAAA,GAAA,IAAA,OAAA,EAAA;AAEA,OAAA,GAAA,IAAA,OAAA,EAAA;AALA,YAAA,CARI,kBAQG,EAAA,SAAA,CAAA;AART,IAAM,iBAAN,GAAA,kBAAA;AA4LA,0BAAe,iBAAkB,CAAA,QAAA;;;;"}
|
package/esm/authenticate.js
CHANGED
|
@@ -1,26 +1,46 @@
|
|
|
1
1
|
const defaultAuthUrl = "api/authn";
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
body: JSON.stringify({ username, password })
|
|
10
|
-
}).then((response) => {
|
|
11
|
-
if (response.ok) {
|
|
12
|
-
const authToken = response.headers.get("vuu-auth-token");
|
|
13
|
-
if (typeof authToken === "string" && authToken.length > 0) {
|
|
14
|
-
return authToken;
|
|
15
|
-
} else {
|
|
16
|
-
throw Error(`Authentication failed auth token not returned by server`);
|
|
17
|
-
}
|
|
2
|
+
const isValidVuuUser = (response) => typeof response === "object" && response !== null && "name" in response && "authorizations" in response && typeof response.name === "string" && Array.isArray(response.authorizations);
|
|
3
|
+
const parseVuuUserFromToken = (token) => {
|
|
4
|
+
const [base64EncodedVuuUser] = token.split(".");
|
|
5
|
+
const jsonString = atob(base64EncodedVuuUser);
|
|
6
|
+
const response = JSON.parse(jsonString);
|
|
7
|
+
if (isValidVuuUser(response)) {
|
|
8
|
+
return response;
|
|
18
9
|
} else {
|
|
19
|
-
throw Error(
|
|
20
|
-
`Authentication failed ${response.status} ${response.statusText}`
|
|
21
|
-
);
|
|
10
|
+
throw Error(`auth token does not containe VuuUser`);
|
|
22
11
|
}
|
|
23
|
-
}
|
|
12
|
+
};
|
|
13
|
+
const authenticate = async (username, password, authUrl = defaultAuthUrl) => {
|
|
14
|
+
return fetch(authUrl, {
|
|
15
|
+
method: "POST",
|
|
16
|
+
credentials: "include",
|
|
17
|
+
headers: {
|
|
18
|
+
"Content-Type": "application/json",
|
|
19
|
+
"access-control-allow-origin": location.host
|
|
20
|
+
},
|
|
21
|
+
body: JSON.stringify({ username, password })
|
|
22
|
+
}).then((response) => {
|
|
23
|
+
if (response.ok) {
|
|
24
|
+
const authToken = response.headers.get("vuu-auth-token");
|
|
25
|
+
if (typeof authToken === "string" && authToken.length > 0) {
|
|
26
|
+
try {
|
|
27
|
+
return {
|
|
28
|
+
token: authToken,
|
|
29
|
+
user: parseVuuUserFromToken(authToken)
|
|
30
|
+
};
|
|
31
|
+
} catch (e) {
|
|
32
|
+
throw Error(`Authentication error: vuu auth token decoding failed.`);
|
|
33
|
+
}
|
|
34
|
+
} else {
|
|
35
|
+
throw Error(`Authentication failed auth token not returned by server`);
|
|
36
|
+
}
|
|
37
|
+
} else {
|
|
38
|
+
throw Error(
|
|
39
|
+
`Authentication failed ${response.status} ${response.statusText}`
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
};
|
|
24
44
|
|
|
25
|
-
export { authenticate };
|
|
45
|
+
export { authenticate, parseVuuUserFromToken };
|
|
26
46
|
//# sourceMappingURL=authenticate.js.map
|
package/esm/authenticate.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authenticate.js","sources":["../../../packages/vuu-data-remote/src/authenticate.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"authenticate.js","sources":["../../../packages/vuu-data-remote/src/authenticate.ts"],"sourcesContent":["import type { VuuUser } from \"@vuu-ui/vuu-protocol-types\";\n\nconst defaultAuthUrl = \"api/authn\";\n\nconst isValidVuuUser = (response: unknown): response is VuuUser =>\n typeof response === \"object\" &&\n response !== null &&\n \"name\" in response &&\n \"authorizations\" in response &&\n typeof response.name === \"string\" &&\n Array.isArray(response.authorizations);\n\n/**\n * The auth token returned from authn call encodes (Base64) a VuuUser\n * within the first part of the token.\n */\nexport const parseVuuUserFromToken = (token: string) => {\n const [base64EncodedVuuUser] = token.split(\".\");\n const jsonString = atob(base64EncodedVuuUser);\n const response = JSON.parse(jsonString);\n if (isValidVuuUser(response)) {\n return response;\n } else {\n throw Error(`auth token does not containe VuuUser`);\n }\n};\n\nexport type AuthenticationResponse = {\n token: string;\n user: VuuUser;\n};\n\nexport const authenticate = async (\n username: string,\n password: string,\n authUrl = defaultAuthUrl,\n): Promise<AuthenticationResponse> => {\n return fetch(authUrl, {\n method: \"POST\",\n credentials: \"include\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"access-control-allow-origin\": location.host,\n },\n body: JSON.stringify({ username, password }),\n }).then((response) => {\n if (response.ok) {\n const authToken = response.headers.get(\"vuu-auth-token\");\n if (typeof authToken === \"string\" && authToken.length > 0) {\n try {\n return {\n token: authToken,\n user: parseVuuUserFromToken(authToken),\n };\n } catch (e) {\n throw Error(`Authentication error: vuu auth token decoding failed.`);\n }\n } else {\n throw Error(`Authentication failed auth token not returned by server`);\n }\n } else {\n throw Error(\n `Authentication failed ${response.status} ${response.statusText}`,\n );\n }\n });\n};\n"],"names":[],"mappings":"AAEA,MAAM,cAAiB,GAAA,WAAA;AAEvB,MAAM,iBAAiB,CAAC,QAAA,KACtB,OAAO,QAAa,KAAA,QAAA,IACpB,aAAa,IACb,IAAA,MAAA,IAAU,YACV,gBAAoB,IAAA,QAAA,IACpB,OAAO,QAAS,CAAA,IAAA,KAAS,YACzB,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ACL,QAAA,MAAM,MAAM,CAAyD,uDAAA,CAAA,CAAA;AAAA;AACvE,KACK,MAAA;AACL,MAAM,MAAA,KAAA;AAAA,QACJ,CAAyB,sBAAA,EAAA,QAAA,CAAS,MAAM,CAAA,CAAA,EAAI,SAAS,UAAU,CAAA;AAAA,OACjE;AAAA;AACF,GACD,CAAA;AACH;;;;"}
|
package/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { authenticate } from './authenticate.js';
|
|
1
|
+
export { authenticate, parseVuuUserFromToken } from './authenticate.js';
|
|
2
2
|
export { default as ConnectionManager } from './ConnectionManager.js';
|
|
3
3
|
export { connectionId, msgType } from './constants.js';
|
|
4
4
|
export { isDataSourceConfigMessage, isSizeOnly, shouldMessageBeRoutedToDataSource, toDataSourceConfig } from './data-source.js';
|
package/esm/inlined-worker.js
CHANGED
|
@@ -1586,7 +1586,6 @@ var ServerProxy = class {
|
|
|
1586
1586
|
__publicField(this, "viewports");
|
|
1587
1587
|
__publicField(this, "mapClientToServerViewport");
|
|
1588
1588
|
__publicField(this, "authToken", "");
|
|
1589
|
-
__publicField(this, "user", "user");
|
|
1590
1589
|
__publicField(this, "pendingLogin");
|
|
1591
1590
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1592
1591
|
__publicField(this, "pendingRequests", /* @__PURE__ */ new Map());
|
|
@@ -1644,10 +1643,9 @@ var ServerProxy = class {
|
|
|
1644
1643
|
connection.on("closed", this.connectionClosed);
|
|
1645
1644
|
connection.on("connection-status", this.connectionStatusChanged);
|
|
1646
1645
|
}
|
|
1647
|
-
async login(authToken
|
|
1646
|
+
async login(authToken) {
|
|
1648
1647
|
if (authToken) {
|
|
1649
1648
|
this.authToken = authToken;
|
|
1650
|
-
this.user = user;
|
|
1651
1649
|
return new Promise((resolve, reject) => {
|
|
1652
1650
|
this.sendMessageToServer({ type: "LOGIN", token: this.authToken }, "");
|
|
1653
1651
|
this.pendingLogin = { resolve, reject };
|
|
@@ -2842,7 +2840,7 @@ var ws;
|
|
|
2842
2840
|
var sendMessageToClient = (message) => {
|
|
2843
2841
|
postMessage(message);
|
|
2844
2842
|
};
|
|
2845
|
-
async function connectToServer(url, protocols, token,
|
|
2843
|
+
async function connectToServer(url, protocols, token, retryLimitDisconnect, retryLimitStartup) {
|
|
2846
2844
|
const websocketConnection = ws = new WebSocketConnection({
|
|
2847
2845
|
callback: (msg) => {
|
|
2848
2846
|
if (isConnectionQualityMetrics(msg)) {
|
|
@@ -2861,7 +2859,7 @@ async function connectToServer(url, protocols, token, username, retryLimitDiscon
|
|
|
2861
2859
|
await websocketConnection.connect();
|
|
2862
2860
|
server = new ServerProxy(websocketConnection, sendMessageToClient);
|
|
2863
2861
|
if (websocketConnection.requiresLogin) {
|
|
2864
|
-
await server.login(token
|
|
2862
|
+
await server.login(token);
|
|
2865
2863
|
}
|
|
2866
2864
|
}
|
|
2867
2865
|
var handleMessageFromClient = async ({
|
|
@@ -2874,7 +2872,6 @@ var handleMessageFromClient = async ({
|
|
|
2874
2872
|
message.url,
|
|
2875
2873
|
message.protocol,
|
|
2876
2874
|
message.token,
|
|
2877
|
-
message.username,
|
|
2878
2875
|
message.retryLimitDisconnect,
|
|
2879
2876
|
message.retryLimitStartup
|
|
2880
2877
|
);
|