;ELC ;;; Compiled ;;; in Emacs version 28.0.50 ;;; with all optimizations. (byte-code "\300\301!\210\300\302!\210\303\304\305\306\307\310%\210\311\312\313\314\315DD\316\317\320%\210\311\321\313\314\322DD\323\317\324%\210\311\325\313\314\326DD\327\317\330%\210\311\331\313\314\332DD\333\317\330%\210\311\334\313\314\335DD\336\317\337%\207" [require request json custom-declare-group libbcel-oauth nil "Group for OAuth authentication to Basecamp." :group libbcel custom-declare-variable libbcel-oauth-store-filename funcall function #[0 "\301P\207" [user-emacs-directory "libbcel-oauth.el.gpg"] 2] "Filename where Basecamp 3 OAuth tokens are stored.\n\nIf the filename ends with .gpg, the file will be encrypted with\n`libbcel-oauth-store-encryption-keys' if non-nil." :type file libbcel-oauth-store-encryption-keys #[0 "\300\207" [nil] 1] "GPG keys to use to encrypt the store." (repeat string) libbcel-oauth-client-id #[0 "\300\207" [nil] 1] "Set your basecamp client id here." string libbcel-oauth-client-secret #[0 "\300\207" [nil] 1] "Set your basecamp client secret here." libbcel-oauth-local-http-port #[0 "\300\207" [9321] 1] "The port number used for the redirect uri.\n\nThis number should be specified when defining the integration on\nthe basecamp website." number] 6) #@46 Terminate the network PROCESS. (fn PROCESS) (defalias 'libbcel-oauth--kill-process #[257 "\300!\210\301!\207" [stop-process delete-process] 3 (#$ . 1292)]) #@345 Create a network process listening for HTTP connections. The port the server listens to is `libbcel-oauth-local-http-port'. CLIENT-ID and CLIENT-SECRET are provided by basecamp for each integration. CALLBACK is executed with the authentication data if the OAUTH authentication terminates successfully. (fn CLIENT-ID CLIENT-SECRET CALLBACK) (defalias 'libbcel-oauth--make-http-server #[771 "\301C\302\303\"\304\305\306\307\310\311\312\313\314!\315\316\317\320 &&\n\240\207" [libbcel-oauth-local-http-port nil make-closure #[0 "\301\300\242!\207" [V0 libbcel-oauth--kill-process] 2] make-network-process :server t :name "libbcel-oauth-http-server" :service :buffer generate-new-buffer "*libbcel-oauth-http-server*" :filter apply-partially libbcel-oauth--http-server-filter libbcel-oauth--redirect-uri] 23 (#$ . 1458)]) #@272 Open the user's favorite web browser so s·he can authorize libbcel. CLIENT-ID is provided by basecamp for each integration. REDIRECT-URI is specified when creating a new integration. It should be a string such as "http://localhost:9321". (fn CLIENT-ID REDIRECT-URI) (defalias 'libbcel-oauth--open-browser #[514 "\300\301\302#!\207" [browse-url format "https://launchpad.37signals.com/authorization/new?type=web_server&client_id=%s&redirect_uri=%s"] 7 (#$ . 2298)]) #@613 Analyze DATA and continue the OAUTH process if DATA has a code. CLIENT-ID and CLIENT-SECRET are provided by basecamp for each integration. REDIRECT-URI is specified when creating a new integration. It should be a string such as "http://localhost:9321". KILL-PROCESS-FN is a function to be called to kill the HTTP server. CALLBACK is executed with the authentication data if the OAUTH authentication terminates successfully. PROCESS is the HTTP process created to communicate with the HTTP client which opened the connection. (fn CLIENT-ID CLIENT-SECRET REDIRECT-URI KILL-PROCESS-FN CALLBACK PROCESS DATA) (defalias 'libbcel-oauth--http-server-filter #[1799 "\300 \301\302\"\216\303\304\305\"r\211q\210\301\306\"\216\307 \210c\210eb\210\310\311\312\305#\205J \313\314!\315\316\317\fB\320B\321 B\322B\257\301\323\n\n\n$ #\262*\262)\207" [match-data make-closure #[0 "\301\300\302\"\207" [V0 set-match-data evaporate] 3] generate-new-buffer " *temp*" t #[0 "\301\300!\205 \302\300!\207" [V0 buffer-name kill-buffer] 2] erase-buffer re-search-forward "^GET /\\?code=\\(?1:[^ ]+\\) " nil match-string 1 libbcel-oauth--send-auth-request (type . "web_server") client_id redirect_uri client_secret code #[257 "\303\302!\210\301!\210\304\302!\210\305\302!\210\300 \207" [V0 V1 V2 libbcel-oauth--http-respond stop-process delete-process] 3 "\n\n(fn DATA)"]] 17 (#$ . 2777)]) #@80 Respond to the http client in PROCESS that everything went well. (fn PROCESS) (defalias 'libbcel-oauth--http-respond #[257 "\300 \301\302\303\211\304\305%\"\207" [current-time-string send-string format "HTTP/1.1 200 OK\nDate: %s\nServer: Emacs\nLast-Modified: %s\nContent-Length: %s\nContent-Type: text/html\nConnection: Closed\n\n%s" 47 "
Everything ok, you may go back to Emacs.
"] 10 (#$ . 4173)]) #@81 Execute CALLBACK with a refreshed access token from STORE. (fn STORE CALLBACK) (defalias 'libbcel-oauth--refresh-access-token #[514 "\300\301\"\300\302\"\300\303\"\304\305\306B\307B\310\311 B\312B\257\313\314\"\313\315\"#\207" [map-elt :client-id :client-secret :refresh-token libbcel-oauth--send-auth-request (type . "refresh") refresh_token client_id redirect_uri libbcel-oauth--redirect-uri client_secret make-closure #[257 "\300!\207" [V0] 3 "\n\n(fn DATA)"] #[0 "\301\302!\210\300 \207" [V0 user-error "Failed to refresh basecamp access token"] 2]] 12 (#$ . 4588)]) #@134 Do a POST request with PARAMS on Basecamp auth URL. Execute SUCCESS with data upon success, or FAILURE. (fn PARAMS SUCCESS FAILURE) (defalias 'libbcel-oauth--send-auth-request #[771 "\300\301\302\303\304\305\306 \307\310\311\312\313\"\314\312\315\"& \207" [request "https://launchpad.37signals.com/authorization/token" :type "POST" :data "" :params :parser json-read :success make-closure #[128 "\301\302\"A@\300!\207" [V0 plist-member :data] 4 "\n\n(fn &key DATA &allow-other-keys)"] :error #[128 "\300 \207" [V0] 2 "\n\n(fn &rest ARGS)"]] 19 (#$ . 5181)]) #@178 Generate a local redirect-uri from `libbcel-oauth-local-http-port'. REDIRECT-URI is specified when creating a new integration. It is a string such as "http://localhost:9321". (defalias 'libbcel-oauth--redirect-uri #[0 "\301\302!P\207" [libbcel-oauth-local-http-port "http://localhost:" number-to-string] 3 (#$ . 5754)]) #@91 Get new tokens using credentials in STORE and pass them to CALLBACK. (fn STORE CALLBACK) (defalias 'libbcel-oauth--fetch #[514 "\300\301\"\300\302\"\303#\210\304\305 \"\207" [map-elt :client-id :client-secret libbcel-oauth--make-http-server libbcel-oauth--open-browser libbcel-oauth--redirect-uri] 8 (#$ . 6083)]) #@58 Return non-nil if STORE has an access token. (fn STORE) (defalias 'libbcel-oauth--store-has-access-token-p #[257 "\300\301\"\207" [map-contains-key :access-token] 4 (#$ . 6410)]) #@67 Return non-nil if STORE has an outdated access token. (fn STORE) (defalias 'libbcel-oauth--store-needs-refresh-p #[257 "\300\301\302\"\303 \"\207" [time-less-p map-elt :deadline current-time] 5 (#$ . 6597)]) #@83 Save AUTH-TOKEN within STORE. (fn STORE &key AUTH-TOKEN CLIENT-ID CLIENT-SECRET) (defalias 'libbcel-oauth--store-save #[385 "\303\304\"A@\303\305\"A@\303\306\"A@\211\203= \211@\307>\203&