@edge-sky/dsh-oauth-adapter 0.1.3-beta.3 → 0.1.3-beta.4
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/README.i18n.yaml +2 -2
- package/lib/client.js +27 -3
- package/lib/types/client/store.d.ts +7 -0
- package/package.json +2 -2
package/README.i18n.yaml
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
# Bilingual-pair consistency record: the git blob hash of each side as of the
|
|
2
2
|
# last confirmed-consistent state. Both languages carry equal authority.
|
|
3
|
-
README.md:
|
|
4
|
-
README.zh.md:
|
|
3
|
+
README.md: c30bed23d84ddcd11616cb323d9698c0105ac0dd
|
|
4
|
+
README.zh.md: e77381a4a09dcf7bdfc88d2ec65d57df894f931b
|
package/lib/client.js
CHANGED
|
@@ -769,8 +769,20 @@ window.__ModuleLoader__.load({
|
|
|
769
769
|
//#endregion
|
|
770
770
|
//#region src/client/store.ts
|
|
771
771
|
/** Browser state machine for the plugin-owned OAuth WebSocket. */
|
|
772
|
-
|
|
773
|
-
|
|
772
|
+
/**
|
|
773
|
+
* Resolve the OAuth socket against the browser page or its desktop-owned Host.
|
|
774
|
+
* @param page - Current page location.
|
|
775
|
+
* @param streamBaseUrl - Desktop shell's authenticated local Host origin.
|
|
776
|
+
* @returns WebSocket URL for the OAuth route.
|
|
777
|
+
*/
|
|
778
|
+
function socketUrl(page, streamBaseUrl) {
|
|
779
|
+
const pageUrl = new URL(page.href);
|
|
780
|
+
const base = pageUrl.protocol === "http:" || pageUrl.protocol === "https:" ? page.href : streamBaseUrl;
|
|
781
|
+
if (base === void 0) throw new Error("The DSH Host has no WebSocket origin.");
|
|
782
|
+
const url = new URL(OAUTH_SOCKET_PATH, base);
|
|
783
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") throw new Error("The DSH Host has no WebSocket origin.");
|
|
784
|
+
url.protocol = url.protocol === "https:" ? "wss:" : "ws:";
|
|
785
|
+
return url.href;
|
|
774
786
|
}
|
|
775
787
|
function isServerMessage(value) {
|
|
776
788
|
return typeof value === "object" && value !== null && typeof value.type === "string";
|
|
@@ -947,7 +959,19 @@ window.__ModuleLoader__.load({
|
|
|
947
959
|
...this.snapshot,
|
|
948
960
|
connection: this.socket === void 0 ? "connecting" : "reconnecting"
|
|
949
961
|
});
|
|
950
|
-
const
|
|
962
|
+
const transport = globalThis.__DSH_TRANSPORT__;
|
|
963
|
+
let url;
|
|
964
|
+
try {
|
|
965
|
+
url = socketUrl(window.location, transport?.streamBaseUrl);
|
|
966
|
+
} catch {
|
|
967
|
+
this.update({
|
|
968
|
+
...this.snapshot,
|
|
969
|
+
connection: "closed",
|
|
970
|
+
error: "The DSH Host connection address is unavailable."
|
|
971
|
+
});
|
|
972
|
+
return;
|
|
973
|
+
}
|
|
974
|
+
const socket = new WebSocket(url, OAUTH_SOCKET_PROTOCOL);
|
|
951
975
|
this.socket = socket;
|
|
952
976
|
socket.addEventListener("open", () => {
|
|
953
977
|
if (this.socket !== socket) return;
|
|
@@ -33,6 +33,13 @@ export interface OAuthAccountsSnapshot {
|
|
|
33
33
|
errorDetail?: string;
|
|
34
34
|
}
|
|
35
35
|
type Listener = () => void;
|
|
36
|
+
/**
|
|
37
|
+
* Resolve the OAuth socket against the browser page or its desktop-owned Host.
|
|
38
|
+
* @param page - Current page location.
|
|
39
|
+
* @param streamBaseUrl - Desktop shell's authenticated local Host origin.
|
|
40
|
+
* @returns WebSocket URL for the OAuth route.
|
|
41
|
+
*/
|
|
42
|
+
export declare function socketUrl(page: Pick<Location, 'href'>, streamBaseUrl?: string): string;
|
|
36
43
|
/** Remove interaction-only content once an authorization attempt settles. */
|
|
37
44
|
export declare function settleAttemptView(attempt: AttemptView, status: Extract<ServerMessage, {
|
|
38
45
|
type: 'settled';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@edge-sky/dsh-oauth-adapter",
|
|
3
|
-
"description": "Web OAuth account surface for official DSH authorization flows",
|
|
4
|
-
"version": "0.1.3-beta.
|
|
3
|
+
"description": "Web and Desktop OAuth account surface for official DSH authorization flows",
|
|
4
|
+
"version": "0.1.3-beta.4",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "edge-sky",
|
|
7
7
|
"url": "https://github.com/edge-sky"
|