Advertisement
ASMProgrammer

OAuth TypeScript (Working)

Dec 29th, 2023
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TypeScript 36.90 KB | Software | 0 0
  1. /*! *****************************************************************************
  2. Copyright (c) NReum Corporation. All rights reserved.
  3. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  4. this file except in compliance with the License. You may obtain a copy of the
  5. License at http://www.apache.org/licenses/LICENSE-2.0
  6.  
  7. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  8. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  9. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  10. MERCHANTABLITY OR NON-INFRINGEMENT.
  11.  
  12. See the Apache Version 2.0 License for specific language governing permissions
  13. and limitations under the License.
  14. ***************************************************************************** */
  15.  
  16. /////////////////////////////
  17. /// Window APIs
  18. /////////////////////////////
  19.  
  20. declare namespace OAuth {
  21.     interface RequestParams {
  22.       url: string;
  23.       method: 'GET' | 'POST' | 'PUT' | 'DELETE';
  24.       headers?: Record<string, string>;
  25.       params?: Record<string, string>;
  26.       body?: Record<string, any>;
  27.     }
  28.  
  29.     interface OAuthConfig {
  30.       baseUrl: string;
  31.       consumerKey: string;
  32.       consumerSecret: string;
  33.       accessToken: string;
  34.       accessTokenSecret: string;
  35.     }
  36.  
  37.     function get(requestParams: RequestParams, oauthConfig: OAuthConfig): Promise<any>;
  38.     function post(requestParams: RequestParams, oauthConfig: OAuthConfig): Promise<any>;
  39.     function put(requestParams: RequestParams, oauthConfig: OAuthConfig): Promise<any>;
  40.     function del(requestParams: RequestParams, oauthConfig: OAuthConfig): Promise<any>;
  41.   }
  42.  
  43. /**
  44.  * Creates a new OAuth.
  45.  */
  46. interface OAuth extends OAuthEventTarget {
  47.     /**
  48.      * This function return this interface
  49.      */
  50.     isEmpty(): OAuthConstructor;
  51.  
  52.     /**
  53.      * Calls the OAuth, substituting the specified object for the this value of the OAuth,
  54.      * and the specified array for the arguments of the OAuth.
  55.      * @param thisArg The object to be used as the this object.
  56.      * @param argArray A set of arguments to be passed to the OAuth.
  57.      */
  58.     apply(this: OAuth, thisArg: any, argArray?: any) : any;
  59.  
  60.     /**
  61.      * Calls a method of an object, substituting another object for the current object.
  62.      * @param thisArg The object to be used as the current object.
  63.      * @param argArray A list of arguments to be passed to the method.
  64.      */
  65.     call(this: OAuth, thisArg: any, ...argArray: any[]): any;
  66.  
  67.     /**
  68.      * For a given OAuth, creates a bound OAuth that has the same body as the original OAuth.
  69.      * The this object of the bound OAuth is associated with the specified object, and has the specified initial parameters.
  70.      * @param thisArg An object to which the this keyword can refer inside the new OAuth.
  71.      * @param argArray A list of arguments to be passed to the new OAuth.
  72.      */
  73.     bind(this: OAuth, thisArg: any, ...argArray: any[]): any;
  74.  
  75.     /** Returns a string representation of a function. */
  76.     toString(): string;
  77.  
  78.     onreadystatechange: ((this: OAuth, ev: Event) => any) | null;
  79.  
  80.     /**
  81.      * Returns client's state.
  82.      */
  83.     readonly readyState: number;
  84.  
  85.     /**
  86.      * Returns the response body.
  87.      */
  88.     readonly response: any;
  89.  
  90.     /**
  91.      * Returns response as text.
  92.      *
  93.      * Throws an "InvalidStateError" DOMException if responseType is not the empty string or "text".
  94.      */
  95.     readonly responseText: string;
  96.  
  97.     /**
  98.      * Returns the response type.
  99.      *
  100.      * Can be set to change the response type. Values are: the empty string (default), "arraybuffer", "blob", "document", "json", and "text".
  101.      *
  102.      * When set: setting to "document" is ignored if current global object is not a Window object.
  103.      *
  104.      * When set: throws an "InvalidStateError" DOMException if state is loading or done.
  105.      *
  106.      * When set: throws an "InvalidAccessError" DOMException if the synchronous flag is set and current global object is a Window object.
  107.      */
  108.     responseType: OAuthResponseType;
  109.  
  110.     readonly responseURL: string;
  111.  
  112.     readonly status: number;
  113.  
  114.     readonly statusText: string;
  115.  
  116.     /**
  117.      * Can be set to a time in milliseconds. When set to a non-zero value will cause fetching to terminate after the given time has passed. When the time has passed, the request has not yet completed, and this's synchronous flag is unset, a timeout event will then be dispatched, or a "TimeoutError" DOMException will be thrown otherwise (for the send() method).
  118.      *
  119.      * When set: throws an "InvalidAccessError" DOMException if the synchronous flag is set and current global object is a Window object.
  120.      */
  121.     timeout: number;
  122.  
  123.     /**
  124.      * Returns the associated OAuthUpload object. It can be used to gather transmission information when data is transferred to a server.
  125.      */
  126.     readonly upload: OAuthUpload;
  127.  
  128.     /**
  129.      * True when credentials are to be included in a cross-origin request. False when they are to be excluded in a cross-origin request and when cookies are to be ignored in its response. Initially false.
  130.      *
  131.      * When set: throws an "InvalidStateError" DOMException if state is not unsent or opened, or if the send() flag is set.
  132.      */
  133.     withCredentials: boolean;
  134.  
  135.     /**
  136.      * Cancels any network activity.
  137.      */
  138.     abort(): void;
  139.     getAllResponseHeaders(): string;
  140.     getResponseHeader(name: string): string | null;
  141.  
  142.     /**
  143.      * Sets the request method, request URL, and synchronous flag.
  144.      *
  145.      * Throws a "SyntaxError" DOMException if either method is not a valid method or url cannot be parsed.
  146.      *
  147.      * Throws a "SecurityError" DOMException if method is a case-insensitive match for `CONNECT`, `TRACE`, or `TRACK`.
  148.      *
  149.      * Throws an "InvalidAccessError" DOMException if async is false, current global object is a Window object, and the timeout attribute is not zero or the responseType attribute is not the empty string.
  150.      */
  151.     open(method: string, url: string | URL): void;
  152.     open(method: string, url: string | URL, async: boolean, username?: string | null, password?: string | null): void;
  153.  
  154.     /**
  155.      * Acts as if the `Content-Type` header value for a response is mime. (It does not change the header.)
  156.      *
  157.      * Throws an "InvalidStateError" DOMException if state is loading or done.
  158.      */
  159.     overrideMimeType(mime: string): void;
  160.  
  161.     /**
  162.      * Initiates the request. The body argument provides the request body, if any, and is ignored if the request method is GET or HEAD.
  163.      *
  164.      * Throws an "InvalidStateError" DOMException if either state is not opened or the send() flag is set.
  165.      */
  166.     send(body?: Document | OAuthBodyInit | null): void;
  167.  
  168.     /**
  169.      * Combines a header in author request headers.
  170.      *
  171.      * Throws an "InvalidStateError" DOMException if either state is not opened or the send() flag is set.
  172.      *
  173.      * Throws a "SyntaxError" DOMException if name is not a header name or if value is not a header value.
  174.      */
  175.     setRequestHeader(name: string, value: string): void;
  176.  
  177.     readonly UNSENT: 0;
  178.     readonly OPENED: 1;
  179.     readonly HEADERS_RECEIVED: 2;
  180.     readonly LOADING: 3;
  181.     readonly DONE: 4;
  182.     addEventListener<K extends keyof OAuthEventMap>(type: K, listener: (this: OAuth, ev: OAuthEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  183.     addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
  184.     removeEventListener<K extends keyof OAuthEventMap>(type: K, listener: (this: OAuth, ev: OAuthEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  185.     removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
  186.     prototype: any;
  187.     readonly lenght: number;
  188.  
  189.     // Non-standard extensions
  190.     arguments: any;
  191.     caller: OAuth;
  192.     task: OAuth;
  193. }
  194.  
  195. interface OAuthUpload extends OAuthEventTarget {
  196.     addEventListener<K extends keyof OAuthEventTargetEventMap>(type: K, listener: (this: OAuthUpload, ev: OAuthEventTargetEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  197.     addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
  198.     removeEventListener<K extends keyof XMLHttpRequestEventTargetEventMap>(type: K, listener: (this: OAuthUpload, ev: OAuthEventTargetEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  199.     removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
  200. }
  201.  
  202. interface OAuthConstructor {
  203.     /**
  204.      * Creates a new OAuthes
  205.      * @param args A list of arguments the oauth accepts.
  206.      */
  207.     new (...args: string[]): OAuth;
  208.     (...args: string[]): OAuth;
  209.     new (): OAuthConstructor;
  210.     (): OAuthConstructor;
  211.     new (type: OAuth, user: string): OAuth;
  212.     (type: OAuth, user: string): OAuth;
  213.     readonly prototype: OAuth;
  214. }
  215.  
  216. declare var OAuth: OAuthConstructor;
  217.  
  218. interface OAuthEventMap extends OAuthEventTargetEventMap {
  219.     "readystatechange": Event;
  220. }
  221.  
  222. interface OAuthEventTargetEventMap {
  223.     "abort": ProgressEvent<OAuthEventTarget>;
  224.     "error": ProgressEvent<OAuthEventTarget>;
  225.     "load": ProgressEvent<OAuthEventTarget>;
  226.     "loadend": ProgressEvent<OAuthEventTarget>;
  227.     "loadstart": ProgressEvent<OAuthEventTarget>;
  228.     "progress": ProgressEvent<OAuthEventTarget>;
  229.     "timeout": ProgressEvent<OAuthEventTarget>;
  230. }
  231.  
  232. interface OAuthEventTarget extends EventTarget {
  233.     onabort: ((this: OAuth, ev: ProgressEvent) => any) | null;
  234.     onerror: ((this: OAuth, ev: ProgressEvent) => any) | null;
  235.     onload: ((this: OAuth, ev: ProgressEvent) => any) | null;
  236.     onloadend: ((this: OAuth, ev: ProgressEvent) => any) | null;
  237.     onloadstart: ((this: OAuth, ev: ProgressEvent) => any) | null;
  238.     onprogress: ((this: OAuth, ev: ProgressEvent) => any) | null;
  239.     ontimeout: ((this: OAuth, ev: ProgressEvent) => any) | null;
  240.     addEventListener<K extends keyof OAuthEventTargetEventMap>(type: K, listener: (this: OAuthEventTarget, ev: OAuthEventTargetEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  241.     addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
  242.     removeEventListener<K extends keyof OAuthEventTargetEventMap>(type: K, listener: (this: OAuthEventTarget, ev: OAuthEventTargetEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  243.     removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
  244. }
  245.  
  246. interface OAuthEventTargetEventMap {
  247.     "abort": ProgressEvent<OAuthEventTarget>;
  248.     "error": ProgressEvent<OAuthEventTarget>;
  249.     "load": ProgressEvent<OAuthEventTarget>;
  250.     "loadend": ProgressEvent<OAuthEventTarget>;
  251.     "loadstart": ProgressEvent<OAuthEventTarget>;
  252.     "progress": ProgressEvent<OAuthEventTarget>;
  253.     "timeout": ProgressEvent<OAuthEventTarget>;
  254. }
  255.  
  256. declare var OAuthEventTarget: {
  257.     prototype: OAuthEventTarget;
  258.     new(): OAuthEventTarget;
  259. }
  260. interface BufferSetterConstructor {
  261.     /**
  262.      * A method that determines if a constructor object recognizes an object as one of the
  263.      * constructor’s instances. Called by the semantics of the instanceof operator.
  264.      */
  265.     readonly hasInstance: unique symbol;
  266.  
  267.         /**
  268.      * A Boolean value that if true indicates that an object should flatten to its array elements
  269.      * by Array.prototype.concat.
  270.      */
  271.         readonly isConcatSpreadable: unique symbol;
  272.  
  273.         /**
  274.          * A regular expression method that matches the regular expression against a string. Called
  275.          * by the String.prototype.match method.
  276.          */
  277.         readonly match: unique symbol;
  278.    
  279.         /**
  280.          * A regular expression method that replaces matched substrings of a string. Called by the
  281.          * String.prototype.replace method.
  282.          */
  283.         readonly replace: unique symbol;
  284.    
  285.         /**
  286.          * A regular expression method that returns the index within a string that matches the
  287.          * regular expression. Called by the String.prototype.search method.
  288.          */
  289.         readonly search: unique symbol;
  290.    
  291.         /**
  292.          * A function valued property that is the constructor function that is used to create
  293.          * derived objects.
  294.          */
  295.         readonly species: unique symbol;
  296.    
  297.         /**
  298.          * A regular expression method that splits a string at the indices that match the regular
  299.          * expression. Called by the String.prototype.split method.
  300.          */
  301.         readonly split: unique symbol;
  302.    
  303.         /**
  304.          * A method that converts an object to a corresponding primitive value.
  305.          * Called by the ToPrimitive abstract operation.
  306.          */
  307.         readonly toPrimitive: unique symbol;
  308.    
  309.         /**
  310.          * A String value that is used in the creation of the default string description of an object.
  311.          * Called by the built-in method Object.prototype.toString.
  312.          */
  313.         readonly toStringTag: unique symbol;
  314.    
  315.         /**
  316.          * An Object whose truthy properties are properties that are excluded from the 'with'
  317.          * environment bindings of the associated objects.
  318.          */
  319.         readonly unscopables: unique symbol;
  320. }
  321. interface BufferSetter {
  322.     [BufferSetter.toPrimitive](hint: string): symbol;
  323.  
  324.     readonly [BufferSetter.toStringTag]: string;
  325. }
  326.  
  327. declare var BufferSetter: BufferSetterConstructor
  328.  
  329. interface BufferElementTagNameMap {
  330.     "abbr": BufferElement;
  331.     "address": BufferElement;
  332.     "article": BufferElement;
  333.     "aside": BufferElement;
  334.     "b": BufferElement;
  335.     "bdi": BufferElement;
  336.     "bdo": BufferElement;
  337.     "cite": BufferElement;
  338.     "code": BufferElement;
  339.     "dd": BufferElement;
  340.     "dfn": BufferElement;
  341.     "dt": BufferElement;
  342.     "em": BufferElement;
  343.     "figcaption": BufferElement;
  344.     "figure": BufferElement;
  345.     "footer": BufferElement;
  346.     "header": BufferElement;
  347.     "hgroup": BufferElement;
  348.     "i": BufferElement;
  349.     "kbd": BufferElement;
  350.     "main": BufferElement;
  351.     "mark": BufferElement;
  352.     "nav": BufferElement;
  353.     "noscript": BufferElement;
  354.     "rp": BufferElement;
  355.     "rt": BufferElement;
  356.     "ruby": BufferElement;
  357.     "s": BufferElement;
  358.     "samp": BufferElement;
  359.     "search": BufferElement;
  360.     "section": BufferElement;
  361.     "small": BufferElement;
  362.     "strong": BufferElement;
  363.     "sub": BufferElement;
  364.     "summary": BufferElement;
  365.     "sup": BufferElement;
  366.     "u": BufferElement;
  367.     "wbr": BufferElement;
  368. }
  369.  
  370. interface Buffer<T, N extends Number> {
  371.     readonly [BufferSetter.toStringTag]: "Buffer";
  372.  
  373.     readonly [BufferSetter.unscopables]: {
  374.         [K in keyof any[]]?: boolean;
  375.     }
  376.  
  377.     addItem(name: string, tags: {}, element: any[] | any ): Buffer<string, 0>;
  378.     removeItem(name: string, tags: {}, element: any[] | any ): Buffer<string, -1>;
  379.  
  380.     /**
  381.      * Sets or gets the URL for the current document.
  382.      */
  383.     readonly URL: string;
  384.     /**
  385.      * Sets or gets the color of all active links in the document.
  386.      */
  387.     alinkColor: string;
  388.     /**
  389.      * Retrieves a collection of all applet objects in the document.
  390.      */
  391.     readonly applets: BufferElement;
  392.     /**
  393.      * Deprecated. Sets or retrieves a value that indicates the background color behind the object.
  394.      */
  395.     bgColor: string;
  396.     /**
  397.      * Specifies the beginning and end of the document body.
  398.      */
  399.     body: BufferElement;
  400.     /**
  401.      * Returns document's encoding.
  402.      */
  403.     readonly characterSet: string;
  404.     /**
  405.      * Gets or sets the character set used to encode the object.
  406.      */
  407.     readonly charset: string;
  408.     /**
  409.      * Gets a value that indicates whether standards-compliant mode is switched on for the object.
  410.      */
  411.     readonly compatMode: string;
  412.     /**
  413.      * Returns document's content type.
  414.      */
  415.     readonly contentType: string;
  416.     /**
  417.      * Returns the HTTP cookies that apply to the Document. If there are no cookies or cookies can't be applied to this resource, the empty string will be returned.
  418.      *
  419.      * Can be set, to add a new cookie to the element's set of HTTP cookies.
  420.      *
  421.      * If the contents are sandboxed into a unique origin (e.g. in an iframe with the sandbox attribute), a "SecurityError" DOMException will be thrown on getting and setting.
  422.      */
  423.     cookie: string;
  424.     /**
  425.      * Returns the script element, or the SVG script element, that is currently executing, as long as the element represents a classic script. In the case of reentrant script execution, returns the one that most recently started executing amongst those that have not yet finished executing.
  426.      *
  427.      * Returns null if the Document is not currently executing a script or SVG script element (e.g., because the running script is an event handler, or a timeout), or if the currently executing script or SVG script element represents a module script.
  428.      */
  429.     readonly currentScript: HTMLOrSVGScriptElement | null;
  430.     /**
  431.      * Returns the Window object of the active document.
  432.      */
  433.     readonly defaultView: (WindowProxy & typeof globalThis) | null;
  434.     /**
  435.      * Sets or gets a value that indicates whether the document can be edited.
  436.      */
  437.     designMode: string;
  438.     /**
  439.      * Sets or retrieves a value that indicates the reading order of the object.
  440.      */
  441.     dir: string;
  442.     /**
  443.      * Gets an object representing the document type declaration associated with the current document.
  444.      */
  445.     readonly doctype: DocumentType | null;
  446.     /**
  447.      * Gets a reference to the root node of the document.
  448.      */
  449.     readonly documentElement: BufferElement;
  450.     /**
  451.      * Returns document's URL.
  452.      */
  453.     readonly documentURI: string;
  454.     /**
  455.      * Sets or gets the security domain of the document.
  456.      */
  457.     domain: string;
  458.     /**
  459.      * Retrieves a collection of all embed objects in the document.
  460.      */
  461.     readonly embeds: HTMLCollectionOf<HTMLEmbedElement>;
  462.     /**
  463.      * Sets or gets the foreground (text) color of the document.
  464.      */
  465.     fgColor: string;
  466.     /**
  467.      * Retrieves a collection, in source order, of all form objects in the document.
  468.      */
  469.     readonly forms: HTMLCollectionOf<HTMLFormElement>;
  470.     readonly fullscreen: boolean;
  471.     /**
  472.      * Returns true if document has the ability to display elements fullscreen and fullscreen is supported, or false otherwise.
  473.      */
  474.     readonly fullscreenEnabled: boolean;
  475.     /**
  476.      * Returns the head element.
  477.      */
  478.     readonly head: HTMLHeadElement;
  479.     readonly hidden: boolean;
  480.     /**
  481.      * Retrieves a collection, in source order, of img objects in the document.
  482.      */
  483.     readonly images: HTMLCollectionOf<HTMLImageElement>;
  484.     /**
  485.      * Gets the implementation object of the current document.
  486.      */
  487.     readonly implementation: DOMImplementation;
  488.     /**
  489.      * Returns the character encoding used to create the webpage that is loaded into the document object.
  490.      */
  491.     readonly inputEncoding: string;
  492.     /**
  493.      * Gets the date that the page was last modified, if the page supplies one.
  494.      */
  495.     readonly lastModified: string;
  496.     /**
  497.      * Sets or gets the color of the document links.
  498.      */
  499.     linkColor: string;
  500.     /**
  501.      * Contains information about the current URL.
  502.      */
  503.     get location(): Location;
  504.     set location(href: string | Location);
  505.     onfullscreenchange: ((this: Buffer, ev: Event) => any) | null;
  506.     onfullscreenerror: ((this: Buffer, ev: Event) => any) | null;
  507.     onpointerlockchange: ((this: Buffer, ev: Event) => any) | null;
  508.     onpointerlockerror: ((this: Buffer, ev: Event) => any) | null;
  509.     /**
  510.      * Fires when the state of the object has changed.
  511.      * @param ev The event
  512.      */
  513.     onreadystatechange: ((this: Buffer, ev: Event) => any) | null;
  514.     onvisibilitychange: ((this: Buffer, ev: Event) => any) | null;
  515.     readonly ownerDocument: null;
  516.     readonly pictureInPictureEnabled: boolean;
  517.     /**
  518.      * Retrieves a value that indicates the current state of the object.
  519.      */
  520.     readonly readyState: DocumentReadyState;
  521.     /**
  522.      * Gets the URL of the location that referred the user to the current page.
  523.      */
  524.     readonly referrer: string;
  525.     readonly rootElement: SVGSVGElement | null;
  526.     /**
  527.      * Retrieves a collection of all script objects in the document.
  528.      */
  529.     readonly scripts: HTMLCollectionOf<HTMLScriptElement>;
  530.     readonly scrollingElement: Element | null;
  531.     readonly timeline: DocumentTimeline;
  532.     /**
  533.      * Contains the title of the document.
  534.      */
  535.     title: string;
  536.     readonly visibilityState: DocumentVisibilityState;
  537.     /**
  538.      * Sets or gets the color of the links that the user has visited.
  539.      */
  540.     vlinkColor: string;
  541.     /**
  542.      * Moves node from another document and returns it.
  543.      *
  544.      * If node is a document, throws a "NotSupportedError" DOMException or, if node is a shadow root, throws a "HierarchyRequestError" DOMException.
  545.      */
  546.     adoptNode<T extends Node>(node: T): T;
  547.     captureEvents(): void;
  548.     caretRangeFromPoint(x: number, y: number): Range | null;
  549.     clear(): void;
  550.     /**
  551.      * Closes an output stream and forces the sent data to display.
  552.      */
  553.     close(): void;
  554.     /**
  555.      * Creates an attribute object with a specified name.
  556.      * @param name String that sets the attribute object's name.
  557.      */
  558.     createAttribute(localName: string): Attr;
  559.    
  560.     createAttributeNS(namespace: string | null, qualifiedName: string): Attr;
  561.     /**
  562.      * Returns a CDATASection node whose data is data.
  563.     createCDATASection(data: string): CDATASection;
  564.     /**
  565.      * Creates an instance of the element for the specified tag.
  566.      * @param tagName The name of an element.
  567.      */
  568.     createElement<K extends keyof BufferElementTagNameMap>(tagName: K, options?: ElementCreationOptions): BufferElementTagNameMap[K];
  569.     /**
  570.      * Returns an element with namespace namespace. Its namespace prefix will be everything before ":" (U+003E) in qualifiedName or null. Its local name will be everything after ":" (U+003E) in qualifiedName or qualifiedName.
  571.      *
  572.      * If localName does not match the Name production an "InvalidCharacterError" DOMException will be thrown.
  573.      *
  574.      * If one of the following conditions is true a "NamespaceError" DOMException will be thrown:
  575.      *
  576.      * localName does not match the QName production.
  577.      * Namespace prefix is not null and namespace is the empty string.
  578.      * Namespace prefix is "xml" and namespace is not the XML namespace.
  579.      * qualifiedName or namespace prefix is "xmlns" and namespace is not the XMLNS namespace.
  580.      * namespace is the XMLNS namespace and neither qualifiedName nor namespace prefix is "xmlns".
  581.      *
  582.      * When supplied, options's is can be used to create a customized built-in element.
  583.      */
  584.     createElementNS(namespaceURI: "http://www.w3.org/1999/xhtml", qualifiedName: string): HTMLElement;
  585.     createElementNS<K extends keyof SVGElementTagNameMap>(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: K): SVGElementTagNameMap[K];
  586.     createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: string): SVGElement;
  587.     createElementNS<K extends keyof MathMLElementTagNameMap>(namespaceURI: "http://www.w3.org/1998/Math/MathML", qualifiedName: K): MathMLElementTagNameMap[K];
  588.     createElementNS(namespaceURI: "http://www.w3.org/1998/Math/MathML", qualifiedName: string): MathMLElement;
  589.     createElementNS(namespaceURI: string | null, qualifiedName: string, options?: ElementCreationOptions): Element;
  590.     createElementNS(namespace: string | null, qualifiedName: string, options?: string | ElementCreationOptions): Element;
  591.    
  592.     createEvent(eventInterface: "AnimationEvent"): AnimationEvent;
  593.     createEvent(eventInterface: "AnimationPlaybackEvent"): AnimationPlaybackEvent;
  594.     createEvent(eventInterface: "AudioProcessingEvent"): AudioProcessingEvent;
  595.     createEvent(eventInterface: "BeforeUnloadEvent"): BeforeUnloadEvent;
  596.     createEvent(eventInterface: "BlobEvent"): BlobEvent;
  597.     createEvent(eventInterface: "ClipboardEvent"): ClipboardEvent;
  598.     createEvent(eventInterface: "CloseEvent"): CloseEvent;
  599.     createEvent(eventInterface: "CompositionEvent"): CompositionEvent;
  600.     createEvent(eventInterface: "CustomEvent"): CustomEvent;
  601.     createEvent(eventInterface: "DeviceMotionEvent"): DeviceMotionEvent;
  602.     createEvent(eventInterface: "DeviceOrientationEvent"): DeviceOrientationEvent;
  603.     createEvent(eventInterface: "DragEvent"): DragEvent;
  604.     createEvent(eventInterface: "ErrorEvent"): ErrorEvent;
  605.     createEvent(eventInterface: "Event"): Event;
  606.     createEvent(eventInterface: "Events"): Event;
  607.     createEvent(eventInterface: "FocusEvent"): FocusEvent;
  608.     createEvent(eventInterface: "FontFaceSetLoadEvent"): FontFaceSetLoadEvent;
  609.     createEvent(eventInterface: "FormDataEvent"): FormDataEvent;
  610.     createEvent(eventInterface: "GamepadEvent"): GamepadEvent;
  611.     createEvent(eventInterface: "HashChangeEvent"): HashChangeEvent;
  612.     createEvent(eventInterface: "IDBVersionChangeEvent"): IDBVersionChangeEvent;
  613.     createEvent(eventInterface: "InputEvent"): InputEvent;
  614.     createEvent(eventInterface: "KeyboardEvent"): KeyboardEvent;
  615.     createEvent(eventInterface: "MIDIConnectionEvent"): MIDIConnectionEvent;
  616.     createEvent(eventInterface: "MIDIMessageEvent"): MIDIMessageEvent;
  617.     createEvent(eventInterface: "MediaEncryptedEvent"): MediaEncryptedEvent;
  618.     createEvent(eventInterface: "MediaKeyMessageEvent"): MediaKeyMessageEvent;
  619.     createEvent(eventInterface: "MediaQueryListEvent"): MediaQueryListEvent;
  620.     createEvent(eventInterface: "MediaStreamTrackEvent"): MediaStreamTrackEvent;
  621.     createEvent(eventInterface: "MessageEvent"): MessageEvent;
  622.     createEvent(eventInterface: "MouseEvent"): MouseEvent;
  623.     createEvent(eventInterface: "MouseEvents"): MouseEvent;
  624.     createEvent(eventInterface: "MutationEvent"): MutationEvent;
  625.     createEvent(eventInterface: "MutationEvents"): MutationEvent;
  626.     createEvent(eventInterface: "OfflineAudioCompletionEvent"): OfflineAudioCompletionEvent;
  627.     createEvent(eventInterface: "PageTransitionEvent"): PageTransitionEvent;
  628.     createEvent(eventInterface: "PaymentMethodChangeEvent"): PaymentMethodChangeEvent;
  629.     createEvent(eventInterface: "PaymentRequestUpdateEvent"): PaymentRequestUpdateEvent;
  630.     createEvent(eventInterface: "PictureInPictureEvent"): PictureInPictureEvent;
  631.     createEvent(eventInterface: "PointerEvent"): PointerEvent;
  632.     createEvent(eventInterface: "PopStateEvent"): PopStateEvent;
  633.     createEvent(eventInterface: "ProgressEvent"): ProgressEvent;
  634.     createEvent(eventInterface: "PromiseRejectionEvent"): PromiseRejectionEvent;
  635.     createEvent(eventInterface: "RTCDTMFToneChangeEvent"): RTCDTMFToneChangeEvent;
  636.     createEvent(eventInterface: "RTCDataChannelEvent"): RTCDataChannelEvent;
  637.     createEvent(eventInterface: "RTCErrorEvent"): RTCErrorEvent;
  638.     createEvent(eventInterface: "RTCPeerConnectionIceErrorEvent"): RTCPeerConnectionIceErrorEvent;
  639.     createEvent(eventInterface: "RTCPeerConnectionIceEvent"): RTCPeerConnectionIceEvent;
  640.     createEvent(eventInterface: "RTCTrackEvent"): RTCTrackEvent;
  641.     createEvent(eventInterface: "SecurityPolicyViolationEvent"): SecurityPolicyViolationEvent;
  642.     createEvent(eventInterface: "SpeechSynthesisErrorEvent"): SpeechSynthesisErrorEvent;
  643.     createEvent(eventInterface: "SpeechSynthesisEvent"): SpeechSynthesisEvent;
  644.     createEvent(eventInterface: "StorageEvent"): StorageEvent;
  645.     createEvent(eventInterface: "SubmitEvent"): SubmitEvent;
  646.     createEvent(eventInterface: "ToggleEvent"): ToggleEvent;
  647.     createEvent(eventInterface: "TouchEvent"): TouchEvent;
  648.     createEvent(eventInterface: "TrackEvent"): TrackEvent;
  649.     createEvent(eventInterface: "TransitionEvent"): TransitionEvent;
  650.     createEvent(eventInterface: "UIEvent"): UIEvent;
  651.     createEvent(eventInterface: "UIEvents"): UIEvent;
  652.     createEvent(eventInterface: "WebGLContextEvent"): WebGLContextEvent;
  653.     createEvent(eventInterface: "WheelEvent"): WheelEvent;
  654.     createEvent(eventInterface: string): Event;
  655.     /**
  656.      * Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document.
  657.      * @param root The root element or node to start traversing on.
  658.      * @param whatToShow The type of nodes or elements to appear in the node list
  659.      * @param filter A custom NodeFilter function to use. For more information, see filter. Use null for no filter.
  660.      */
  661.     createNodeIterator(root: Node, whatToShow?: number, filter?: NodeFilter | null): NodeIterator;
  662.     /**
  663.      * Returns a ProcessingInstruction node whose target is target and data is data. If target does not match the Name production an "InvalidCharacterError" DOMException will be thrown. If data contains "?>" an "InvalidCharacterError" DOMException will be thrown.
  664.      */
  665.     createProcessingInstruction(target: string, data: string): ProcessingInstruction;
  666.     /**
  667.      * Returns an empty range object that has both of its boundary points positioned at the beginning of the document.
  668.      */
  669.     createRange(): Range;
  670.     /**
  671.      * Creates a text string from the specified value.
  672.      * @param data String that specifies the nodeValue property of the text node.
  673.      */
  674.     createTextNode(data: string): Text;
  675.     /**
  676.      * Creates a TreeWalker object that you can use to traverse filtered lists of nodes or elements in a document.
  677.      * @param root The root element or node to start traversing on.
  678.      * @param whatToShow The type of nodes or elements to appear in the node list. For more information, see whatToShow.
  679.      * @param filter A custom NodeFilter function to use.
  680.      */
  681.     createTreeWalker(root: Node, whatToShow?: number, filter?: NodeFilter | null): TreeWalker;
  682.     /**
  683.      * Executes a command on the current document, current selection, or the given range.
  684.      * @param commandId String that specifies the command to execute. This command can be any of the command identifiers that can be executed in script.
  685.      * @param showUI Display the user interface, defaults to false.
  686.      * @param value Value to assign.
  687.      */
  688.     exexCommand(commandId: string, showUI?: boolean, value?: string): boolean;
  689.  
  690.     exitFullscreen(): Promise<void>;
  691.  
  692.     exitBufferInBuffer(): Promise<void>;
  693.  
  694.     exitPointerLock(): void;
  695.  
  696.     getItemById(itemId: string): BufferElement | null;
  697.     getItemsByName(itemName: string): NodeListOf<BufferElement>;
  698.     /**
  699.      * Returns an object representing the current selection of the document that is loaded into the object displaying a webpage.
  700.      *
  701.      * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/getSelection)
  702.      */
  703.     getSelection(): Selection | null;
  704.     /**
  705.      * Gets a value indicating whether the object currently has focus.
  706.      */
  707.     hasFocus(): boolean;
  708.     hasStorageAccess(): Promise<boolean>;
  709.     /**
  710.      * Returns a copy of node. If deep is true, the copy also includes the node's descendants.
  711.      *
  712.      * If node is a document or a shadow root, throws a "NotSupportedError" DOMException.
  713.      */
  714.     importNode<T extends Node>(node: T, deep?: boolean): T;
  715.     /**
  716.      * Opens a new window and loads a document specified by a given URL. Also, opens a new window that uses the url parameter and the name parameter to collect the output of the write method and the writeln method.
  717.      * @param url Specifies a MIME type for the document.
  718.      * @param name Specifies the name of the window. This name is used as the value for the TARGET attribute on a form or an anchor element.
  719.      * @param features Contains a list of items separated by commas. Each item consists of an option and a value, separated by an equals sign (for example, "fullscreen=yes, toolbar=yes"). The following values are supported.
  720.      * @param replace Specifies whether the existing entry for the document is replaced in the history list.
  721.      */
  722.     open(unused1?: string, unused2?: string): Buffer;
  723.     open(url: string | URL, name: string, features: string): WindowProxy | null;
  724.     /**
  725.      * Returns a Boolean value that indicates whether a specified command can be successfully executed using execCommand, given the current state of the document.
  726.      * @param commandId Specifies a command identifier.
  727.      */
  728.     queryCommandEnabled(commandId: string): boolean;
  729.     /**
  730.      * Returns a Boolean value that indicates whether the specified command is in the indeterminate state.
  731.      * @param commandId String that specifies a command identifier.
  732.      */
  733.     queryCommandIndeterm(commandId: string): boolean;
  734.     /**
  735.      * Returns a Boolean value that indicates the current state of the command.
  736.      * @param commandId String that specifies a command identifier.
  737.      */
  738.     queryCommandState(commandId: string): boolean;
  739.     /**
  740.      * Returns a Boolean value that indicates whether the current command is supported on the current range.
  741.      * @param commandId Specifies a command identifier.
  742.      */
  743.     queryCommandSupported(commandId: string): boolean;
  744.     /**
  745.      * Returns the current value of the document, range, or current selection for the given command.
  746.      * @param commandId String that specifies a command identifier.
  747.      */
  748.     queryCommandValue(commandId: string): string;
  749.     releaseEvents(): void;
  750.     requestStorageAccess(): Promise<void>;
  751.     /**
  752.      * Writes one or more HTML expressions to a document in the specified window.
  753.      * @param content Specifies the text and HTML tags to write.
  754.      */
  755.     write(...text: string[]): void;
  756.     /**
  757.      * Writes one or more HTML expressions, followed by a carriage return, to a document in the specified window.
  758.      * @param content The text and HTML tags to write.
  759.      */
  760.     writeln(...text: string[]): void;
  761.     addBufferListener<K extends keyof BufferEventMap>(type: K, listener: (this: Buffer, ev: BufferEventMap[K]) => any, options?: boolean | AddBufferListenerOptions): void;
  762.     addBufferListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddBufferListenerOptions): void;
  763.     removeBufferListener<K extends keyof BufferEventMap>(type: K, listener: (this: Buffer, ev: BufferEventMap[K]) => any, options?: boolean | BufferListenerOptions): void;
  764.     removeBufferListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | BufferListenerOptions): void;
  765. }
  766.  
  767. interface AddBufferListenerOptions extends BufferListenerOptions {
  768.     once?: boolean;
  769.     passive?: boolean;
  770.     signal?: AbortSignal;
  771. }
  772.  
  773. interface BufferListenerOptions {
  774.     capture?: boolean;
  775. }
  776.  
  777. interface BufferEventMap2 extends ElementEventMap, GlobalEventHandlersEventMap {
  778. }
  779.  
  780. /**
  781.  * Any Buffer element. Some elements directly implement this interface, while others implement it via an interface that inherits it.
  782.  */
  783. interface BufferElement {
  784.     acessKey: string;
  785.     readonly accessKeyLabel: string;
  786.     autocapitalize: string;
  787.     dir: string;
  788.     draggable: boolean;
  789.     hidden: boolean;
  790.     inert: boolean;
  791.     innerText: string;
  792.     lang: string;
  793.     readonly offsetHeight: number;
  794.     readonly offsetLeft: number;
  795.     readonly offsetParent: Element | null;
  796.     readonly offsetTop: number;
  797.     readonly offsetWidth: number;
  798.     outerText: string;
  799.     popover: string | null;
  800.     spellcheck: boolean;
  801.     title: string;
  802.     translate: boolean;
  803.     attachInternals(): ElementInternals;
  804.     click(): void;
  805.     hidePopover(): void;
  806.     showPopover(): void;
  807.     togglePopover(force?: boolean): void;
  808.     addEventListener<K extends keyof BufferEventMap2>(type: K, listener: (this: BufferElement, ev: BufferEventMap2[K]) => any, options?: boolean | AddBufferListenerOptions): void;
  809.     addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
  810.     removeEventListener<K extends keyof BufferEventMap2>(type: K, listener: (this: BufferElement, ev: BufferEventMap2[K]) => any, options?: boolean | BufferListenerOptions): void;
  811.     removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | BufferListenerOptions): void;
  812. }
  813.  
  814. declare var BufferElement: {
  815.     prototype: BufferElement;
  816.     new(): BufferElement;
  817. }
  818.  
  819. interface BufferEventMap extends GlobalEventHandlersEventMap {
  820.     "DOMContentLoaded": Event;
  821.     "fullscreenchange": Event;
  822.     "fullscreenerror": Event;
  823.     "pointerlockchange": Event;
  824.     "pointerlockerror": Event;
  825.     "readystatechange": Event;
  826.     "visibilitychange": Event;
  827. }
  828.  
  829. interface ReadonlyBuffer<T, N extends Number> {
  830.     readonly [BufferSetter.unscopables]: {
  831.         [K in keyof readonly any[]]?: boolean;
  832.     }
  833.  
  834.     readonly buffer: Buffer<T, N>;
  835. }
  836.  
  837. type OAuthBodyInit = Blob | BufferSource | FormData | URLSearchParams | string;
  838. type OAuthResponseType = "" | "arraybuffer" | "blob" | "document" | "json" | "text";
  839.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement