lucid-extension-sdk 0.0.72 → 0.0.73

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.72",
3
+ "version": "0.0.73",
4
4
  "description": "Utility classes for writing Lucid Software editor extensions",
5
5
  "main": "sdk/index.js",
6
6
  "types": "sdk/index.d.ts",
@@ -81,6 +81,7 @@ export declare const enum CommandName {
81
81
  RegisterUnfurl = "ru",
82
82
  ReloadExtension = "r",
83
83
  SendOAuthRequest = "oauth",
84
+ SendPermanentTokenRequest = "perm",
84
85
  SendUIMessage = "suim",
85
86
  SendXHR = "xhr",
86
87
  SetCurrentPage = "scp",
@@ -358,6 +359,10 @@ export declare type CommandArgs = {
358
359
  query: SendOAuthRequestQuery;
359
360
  result: SendOAuthRequestResponse;
360
361
  };
362
+ [CommandName.SendPermanentTokenRequest]: {
363
+ query: SendPermanentTokenRequestQuery;
364
+ result: SendOAuthRequestResponse;
365
+ };
361
366
  [CommandName.SendUIMessage]: {
362
367
  query: SendUIMessageQuery;
363
368
  result: SendUIMessageResult;
@@ -887,7 +892,12 @@ export declare type SendOAuthRequestQuery = SendXHRQuery & {
887
892
  /** OAuth provider name as specified in the package manifest */
888
893
  'p': string;
889
894
  };
895
+ export declare type SendPermanentTokenRequestQuery = SendXHRQuery & {
896
+ /** Permanent token provider name as specified in the package manifest */
897
+ 'p': string;
898
+ };
890
899
  export declare type SendOAuthRequestResponse = SendXHRResponse;
900
+ export declare type SendPermanentTokenRequestResponse = SendXHRResponse;
891
901
  export declare type SendUIMessageQuery = {
892
902
  /** Name of the UI component's action for receiving events, e.g. ShowModalQuery['n'] */
893
903
  'n': string;
@@ -82,6 +82,20 @@ export declare class EditorClient {
82
82
  responseFormat: 'binary';
83
83
  }): Promise<BinaryXHRResponse>;
84
84
  oauthXhr(providerName: string, request: XHRRequest): Promise<XHRResponse>;
85
+ /**
86
+ * Make a request with a permanent token like a merge account token or API key.
87
+ * @param providerName The name of the authorization provider from the manifest
88
+ * @param request Settings for the network request
89
+ * @returns A promise that will either resolve or reject with an XHRResponse. If the HTTP status
90
+ * code is not 2xx, the promise will reject.
91
+ * @ignore */
92
+ permanentTokenXhr(providerName: string, request: XHRRequest & {
93
+ responseFormat: 'utf8';
94
+ }): Promise<TextXHRResponse>;
95
+ permanentTokenXhr(providerName: string, request: XHRRequest & {
96
+ responseFormat: 'binary';
97
+ }): Promise<BinaryXHRResponse>;
98
+ permanentTokenXhr(providerName: string, request: XHRRequest): Promise<XHRResponse>;
85
99
  /**
86
100
  * Register a named action. These actions can be triggered from custom UI, for example as the action of a
87
101
  * custom menu item.
@@ -159,6 +159,25 @@ class EditorClient {
159
159
  throw parseRawXHRResponse(responseFormat, raw);
160
160
  });
161
161
  }
162
+ permanentTokenXhr(providerName, request) {
163
+ const responseFormat = request.responseFormat || 'utf8';
164
+ return this.sendCommand("perm" /* CommandName.SendPermanentTokenRequest */, {
165
+ 'url': request.url,
166
+ 'm': request.method,
167
+ 'd': request.data,
168
+ 'h': request.headers,
169
+ 'ms': request.timeoutMs,
170
+ 'p': providerName,
171
+ 'f': responseFormat,
172
+ })
173
+ .then((raw) => {
174
+ return parseRawXHRResponse(responseFormat, raw);
175
+ })
176
+ .catch((error) => {
177
+ const raw = (0, commandtypes_1.isRawSendXHRResponse)(error) ? error : undefined;
178
+ throw parseRawXHRResponse(responseFormat, raw);
179
+ });
180
+ }
162
181
  /**
163
182
  * Register a named action. These actions can be triggered from custom UI, for example as the action of a
164
183
  * custom menu item.