lucid-extension-sdk 0.0.6 → 0.0.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lucid-extension-sdk",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "Utility classes for writing Lucid Software editor extensions",
5
5
  "main": "sdk/index.js",
6
6
  "types": "sdk/index.d.ts",
@@ -53,6 +53,7 @@ export declare const enum CommandName {
53
53
  OffsetItems = "oi",
54
54
  PatchDataItems = "pdi",
55
55
  ReloadExtension = "r",
56
+ SendOAuthRequest = "oauth",
56
57
  SendUIMessage = "suim",
57
58
  SendXHR = "xhr",
58
59
  SetCurrentPage = "scp",
@@ -243,6 +244,10 @@ export declare type CommandArgs = {
243
244
  query: ReloadExtensionQuery;
244
245
  result: ReloadExtensionResult;
245
246
  };
247
+ [CommandName.SendOAuthRequest]: {
248
+ query: SendOAuthRequestQuery;
249
+ result: SendOAuthRequestResponse;
250
+ };
246
251
  [CommandName.SendUIMessage]: {
247
252
  query: SendUIMessageQuery;
248
253
  result: SendUIMessageResult;
@@ -469,6 +474,10 @@ export declare type PatchDataItemsQuery = {
469
474
  export declare type PatchDataItemsResult = undefined;
470
475
  export declare type ReloadExtensionQuery = void;
471
476
  export declare type ReloadExtensionResult = undefined;
477
+ export declare type SendOAuthRequestQuery = SendXHRQuery & {
478
+ 'p': string;
479
+ };
480
+ export declare type SendOAuthRequestResponse = SendXHRResponse;
472
481
  export declare type SendUIMessageQuery = {
473
482
  'n': string;
474
483
  'd'?: JsonSerializable;
@@ -60,6 +60,7 @@ export declare class EditorClient {
60
60
  * code is not 2xx, the promise will reject.
61
61
  */
62
62
  xhr(request: XHRRequest): Promise<XHRResponse>;
63
+ oauthXhr(providerName: string, request: XHRRequest): Promise<XHRResponse>;
63
64
  /**
64
65
  * Register a named action. These actions can be triggered from custom UI, for example as the action of a
65
66
  * custom menu item.
@@ -81,6 +81,34 @@ class EditorClient {
81
81
  };
82
82
  });
83
83
  }
84
+ oauthXhr(providerName, request) {
85
+ return this.sendCommand("oauth" /* SendOAuthRequest */, {
86
+ 'url': request.url,
87
+ 'm': request.method,
88
+ 'd': request.data,
89
+ 'h': request.headers,
90
+ 'ms': request.timeoutMs,
91
+ 'p': providerName,
92
+ })
93
+ .then((raw) => {
94
+ return {
95
+ url: raw['url'],
96
+ responseText: raw['t'],
97
+ status: raw['s'],
98
+ headers: raw['h'],
99
+ timeout: raw['to'],
100
+ };
101
+ })
102
+ .catch((raw) => {
103
+ throw {
104
+ url: raw['url'],
105
+ responseText: raw['t'],
106
+ status: raw['s'],
107
+ headers: raw['h'],
108
+ timeout: raw['to'],
109
+ };
110
+ });
111
+ }
84
112
  /**
85
113
  * Register a named action. These actions can be triggered from custom UI, for example as the action of a
86
114
  * custom menu item.