Cookies conversion in Node.js - node.js

HI Guys Need a help in cookies
In one Login call i am getting this Cookie as response header but i need the format which is below for next requests:
Response header which i am getting [ 'ApplicationGatewayAffinityCORS=c26d807e1aaeccd5aadfffc649b97688; Path=/; SameSite=None; Secure',
'ApplicationGatewayAffinity=c26d807e1aaeccd5aadfffc649b97688; Path=/',
'.DWPLATFORMAUTH=; expires=Wed, 29-Apr-2020 13:39:20 GMT; path=/DocuWare/Platform; HttpOnly',
'.DWPLATFORMAUTH=BF0F76C29D2A57BBEC15244114BCE0ED2F81AF852C177C8C250C254F40454EAD1341AFAC394F9BF3261EC948C11D709CEBFE08F9F9683FCCB6BB9B7A56EE8C00BE3FDEEF5A9CA56BD9ABEAA651F7A5189698CEDFAAB3F29D1A46BD33E3FA1D692080B1DE68EA4C3A77BB7E9DE26B8F43ABB25575F6A40B223D55EACAA18DF365B98E88CC81D52098126E4FCC4DBF0C19768A1B100D50D0571EE65FF91BCD70CC23CAFEE3F484838AF70A7C995C89DC91CAC34F7A319F589DF00D534BDDF0D9E83791015969D532649981731E667D39A2D3F5D398CDF442E9FB65309282525CECC0BD01806B5CE4FA342A09F06D53E5D95A525470A323667463501EA105D5AD17B6D78EB27C5CEA047511BC55D55F2F2B34D5B196FAB5C69D07971435531CD786E324C2DA1EDEFE8509C863D7751D983A9EAE5BCDBB6556C0634E367BFDCA639FF2A6A56640D4E4D56FF92C4F5CB0CE083C113F05B537DC55C6C13206D865F9965448E4675D359981BD9E52B2E0A1570F831565B61635B4B5E26BB5E2F4EB890A4FC42E0EBEF4E7885DBA13AC8F0A44A4E91BFD7AB9846A906E449BBCE51AD532; path=/; HttpOnly',
'DWPLATFORMBROWSERID=; expires=Wed, 29-Apr-2020 13:39:20 GMT; path=/DocuWare/Platform; HttpOnly',
'DWPLATFORMBROWSERID=FF3A3868BB062A8E1C06EA73E419443B8DC6F073D8C3A8A3988AA9CC808C8FF369099345538486B3FA99DFEC097533BBBD621A12C12E0522521846D2D953F6D2C41DC91EAFFE3A442BC3DA738324F9A063DB88695243E19934325806DBF12D7579CA3BCCFF252A276F68334BD000358948860B23976C81326D8E571B0862045760C5B6FB9115C4F7715E951EC6AE0B779E017433676EAE7D7D202E9EE2ED83C1614317CE122828FF5D980BED4D57524F3BABF60AFFC70EA09D02E0001DD1603B952B03FE3436831E7E148EF1C76BB9A3B6F14940CFAA918A183664A586D049ED; expires=Fri, 30-Apr-2021 13:39:20 GMT; path=/; HttpOnly' ]
**but other request are accepting cookies in this format Which i need **:
'ApplicationGatewayAffinityCORS=71020739a3120956b31575e6a26cf347; ApplicationGatewayAffinity=71020739a3120956b31575e6a26cf347; .DWPLATFORMAUTH=22A566AC0C55B15C492B4CE3EEEFFB667BA0EA95DDA27084A8279F907AB2A475AF44E0D62C4733456628056F3F1E23AE8D60682A4305E8A43B95BC5F9A9A2B02B36B64892DAD484AE7C9C93430AE4B2276E591B2F9D0BCB33FBC14D3A5BF28951996029A55DD5C6B40630838A7A0770472FE8070CF546BF04AA7B31B6E4AD170C0A83FCDC253979084DAD5F23AE6B2DDEB9CF31968D67EBF1CA992B9B5FBFAA1BB3E59AF5F5E4A6D1F1CFFAFFC228CBA03561F60CAA0C47B4C01DA01909433ADF7132C114D98D36114976B9D31E669100EBF73F862ACA81781212819CB6D36A909D4BA9AB856F63B46EF95580A828AE9AB7E61C62F4C6DE925579B325330A6E77E786F0ACEF9C815B0559A7C5AAA12C733D1CE5A4B32ADF1919475C4C1451B304F4A778BD9DE4DD7B2BCCB30C159D503A634F8DA67308441C7A8B8B9B313CEED8C6EFACD20947670546C0EBCE4CC89498AD20CF566062128464077B6A7C12C77B0526F93AD7A6A2BD738C8A2CCAD8D864E23C11E2D0E036DF37E6A00E234B9B545B033929FB2ADB5880D4B8CF7D685ADB340083FFD671704A18259D6F9CD1C96; DWPLATFORMBROWSERID=D95CC701A52B6A15866C5A3966734BD6CF400DB18961F0E8FDA9B7D0F221544DC1D48799617FADC4CDA8F52CC5EBED9F1F8ECAB3969BA913E9DD3B2C346AB09E4083BABC307A4D41B0F3C436BCC5CBD2AC159480E5A48E7101B6BA0442F192B3AF38C00ECF9F3262FCFA911CF1EAF42BACAE869CCB176E49978860225D0FD614D4C2AA9B2BDE9CD376FBFFC16462622CB5235FF9D1F6DE2DDB2F4DADD2CA4497AE388C1745B12D7133FCCE0CF7A11292F49C33DDB25268C44C75C94BB381F2530D820A2FD886F5D36C1A853ECD84136B2541605C85C79C40DB73AF85DDA7701C'

Related

{"message": "Cannot send an empty message", "code": 50006} gitlab

I want to integrate a bot via a weebhook between Gitlab and discord, so I've configured the bot first, copied his url and put it into the gitlab weebhook configuration input and set it for sending push updates to the Discord server.
With a real push test, I have (with the body)
Request headers:
Content-Type: application/json
X-Gitlab-Event: Push Hook
and as response
Response headers:
Date: Tue, 26 May 2020 18:46:48 GMT
Content-Type: application/json
Content-Length: 58
Connection: close
Set-Cookie: __cfduid=d374998c2f84e3e20b75bbdec88fb63d91590518808; expires=Thu, 25-Jun-20 18:46:48 GMT; path=/; domain=.discordapp.com; HttpOnly; SameSite=Lax, __cfruid=418f7199379a53d23012d37b15f2ac5a3aac36b6-1590518808; path=/; domain=.discordapp.com; HttpOnly; Secure; SameSite=None
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Ratelimit-Bucket: 3cd1f278bd0ecaf11e0d2391374c011d
X-Ratelimit-Limit: 5
X-Ratelimit-Remaining: 4
X-Ratelimit-Reset: 1590518811
X-Ratelimit-Reset-After: 2
X-Envoy-Upstream-Service-Time: 12
Via: 1.1 google
Cf-Cache-Status: DYNAMIC
Cf-Request-Id: 02f3e816a1000004823d920200000001
Expect-Ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Server: cloudflare
Cf-Ray: 5999a9376a790482-CDG
but got the error:
Response body:
{"message": "Cannot send an empty message", "code": 50006}
or also
Hook executed successfully but returned HTTP 400 {"message": "Cannot send an empty message", "code": 50006}
Thanks for help
You need to use the "Integrations" feature for "Discord notifications" instead of regular webhook.
See documentation here

Getting Error while opening hosted KaiOS app

I have a manifest.webapp hosted at my application root (https://localhost:5001/manifest.webapp), when I open it in KaiOS simulator, I get the following error:
Unable to access the app starting document https://localhost:5001/,
got HTTP code 405
Curl of its response is:
HTTP/1.1 200 OK
Date: Wed, 02 Oct 2019 21:18:41 GMT
Content-Type: application/x-web-app-manifest+json
Content-Length: 6097
Cache-Control: no-cache
Pragma: no-cache
Expires: -1
Last-Modified: Tue, 01 Oct 2019 07:35:10 GMT
Accept-Ranges: bytes
ETag: "1d5782ac10b5cd1"
Set-Cookie: ClientId=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/; samesite=lax
Set-Cookie: ClientId=922A46E87C9646C18555E7E7DE84840F; expires=Mon, 02 Oct 2119 21:18:42 GMT; path=/; samesite=lax
Access-Control-Allow-Origin: *
x-frame-options: allow-from https://example.com/
x-web-server-version: 1.0.0.0
x-besku: UNKNOWN
{
"name": "abc",
"short_name": "abc",
"icons": [..],
"scope": "/",
"start_url": "/abc/?start_url=sss",
"display": "standalone",
"background_color": "#ffffff",
"theme_color": "#0078d7"
...
Any help would be appreciated.
Firefox os/kaios makes a HEAD call, before GET, so that should be implemented on your server, else this error will come.

After I getting a set-cookie in response, is not saved and transmitted in requests

Basically after an auth, I setting a cookie, but apparently after page refresh on the cookie that was set by cloudflare is saved
And the cookie that I transmitted with set-cookie is not used in after set-cookie requests
# Response headers
HTTP/2.0 200 OK
date: Thu, 18 Jul 2019 10:03:25 GMT
content-type: application/json; charset=utf-8
content-length: 29
set-cookie: __cfduid=d578c7a5e4378dc1b1946964a08ebc4ec1563444205; expires=Fri, 17-Jul-20 10:03:25 GMT; path=/; domain=.doc.io; HttpOnly; Secure
set-cookie: __doc=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlIjoiNzQ2NTczNzQ0MDY2NjE3Mzc0NmQ2MTY5NmMyZTZkNzgiLCJwIjoiNTUzMjQ2NzM2NDQ3NTY2YjU4MzEzODMzNTU0NjUwNTU2ZjRiMzkzMTY3NDUzNDY5NDc3MzM3MzgzOTU5MzczMDUxNjk0ZjQxNjQ0OTM5Nzg0YjZiNzU1Njc3Nzk0NDc0NjE3NDMxNTE0NzcwMzE0YjQxNmY1MjU5MzM3YTZhNDU2NDJiNmU0ZTc0NGE3NTMyNTQ1ODc2NjI1YTczNDc1MTQ1Njc0MjVhNGQ0MTNkM2QiLCJkIjoiMzEzNTM2MzMzNDM0MzQzMjMwMzUzNTM2MzMiLCJpYXQiOjE1NjM0NDQyMDV9.go1jDpc2rBe5FjK2sKX4ybW4PhCPFq1xT1WIX-mSI84; Domain=.doc.io; Path=/; Expires=Thu, 18 Jul 2019 16:03:25 GMT; HttpOnly; Secure
expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
server: cloudflare
cf-ray: 4f83a02a3dc36455-FRA
X-Firefox-Spdy: h2
reply
.code(200)
.header('Access-Control-Allow-Origin', '*')
.header('Content-Type', 'application/json; charset=utf-8')
.setCookie('__doc', token, {
domain: '.doc.io',
path: '/',
secure: true,
httpOnly: true,
expires: new Date(new Date().setHours(new Date().getHours() + 6))})
.send({ 'success': 'Sign In success' })
All my websites are https
First I do POST request for an auth on /auth, and you could see response in response headers above and after I do GET on (trying to load page) from /page and get cookies, but with reply.log.info(request.cookies) I see only cookies from cloudflare. Surely I tried to refresh and go to address in different table, there just no any cookies, but from cloudflare.
# Request headers
Host: test.doc.io
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:67.0) Gecko/20100101 Firefox/67.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
DNT: 1
Connection: keep-alive
Cookie: __cfduid=d578c7a5e4378dc1b1946964a08ebc4ec1563444205
Upgrade-Insecure-Requests: 1
TE: Trailers
After I tested it with an actual page with js code for a XHR request it works fine. However cookie was only displayed, but not actually saved in the storage when I was sending request directly in Firefox's inspector. Lost a day to figure out that created in inspector cookies seems preventing from installing

Where's the Correlation ID in the Graph API Response?

I'm trying to provide the correlation id for this issue but I'm not sure how to obtain it. I assume it should be in response, is that correct? Is it the client-request-id maybe?
HTTP Response
HTTP/1.1 403 Forbidden
Cache-Control: no-cache
Pragma: no-cache
Content-Type: application/json;odata=minimalmetadata;streaming=true;charset=utf-8
Expires: -1
Server: Microsoft-IIS/8.5
ocp-aad-diagnostics-server-name: CGa9FFPZASZM+usTGvTzaOZ4zSMxhpbWh2mO9+eJZWs=
request-id: 6ddd7a86-02c9-4dcf-9932-b17afc976107
client-request-id: 50478d75-542d-4e0e-96d9-de913d632471
x-ms-dirapi-data-contract-version: 1.6
ocp-aad-session-key: some-really-long-value
X-Content-Type-Options: nosniff
DataServiceVersion: 3.0;
Strict-Transport-Security: max-age=31536000; includeSubDomains
Access-Control-Allow-Origin: *
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Duration: 782602
X-Powered-By: ASP.NET
Date: Wed, 09 Aug 2017 14:22:21 GMT
Content-Length: 139
{"odata.error":{"code":"Authorization_RequestDenied","message":{"lang":"en","value":"Insufficient privileges to complete the operation."}}}
Token Request Response
HTTP/1.1 200 OK
Cache-Control: no-cache, no-store
Pragma: no-cache
Content-Type: application/json; charset=utf-8
Expires: -1
Server: Microsoft-IIS/8.5
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Content-Type-Options: nosniff
client-request-id: 8c500700-b75c-403a-a2c9-c6dfa27049d3
x-ms-request-id: 75627b63-fbd6-4fa8-95b5-b6a325d60900
P3P: CP="DSP CUR OTPi IND OTRi ONL FIN"
Set-Cookie: esctx=some-value; domain=.login.microsoftonline.com; path=/; secure; HttpOnly
Set-Cookie: x-ms-gateway-slice=006; path=/; secure; HttpOnly
Set-Cookie: stsservicecookie=ests; path=/; secure; HttpOnly
X-Powered-By: ASP.NET
Date: Wed, 09 Aug 2017 18:33:33 GMT
Content-Length: 1437
{"token_type":"Bearer","expires_in":"3599","ext_expires_in":"262800","expires_on":"1502307214","not_before":"1502303314","resource":"https://graph.windows.net/","access_token":"some-token-value"}
The correlation ID (also called client-request-id) can be found in interactions with the Azure AD service.
The request immediately before this when you were asking the Azure AD endpoints for tokens will include the ID in the response.
https://login.microsoftonline.com/...
https://login.windows.net/...

how to pass the cookies in the curl request

I have to send request using curl, in that request i needs to set the cookie from the below response.
So can some one help me how to pass all the cookies in the curl request
HTTP/1.1 200 OK
X-Powered-By: Express
Access-Control-Allow-Origin:undefined
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: GET,POST,OPTIONS
Access-Control-Allow-Headers: Content-Type
set-cookie: SESSIONID=agpuB2CqPDhkupxfbrZXCR; Path=/ABC
set-cookie: bac_cookie=7959aacd5cc48;Domain=abc.com;Expires=Mon, 05-Dec-2016 18:47:42 GMT; Path=/
set-cookie: beID=0023T21; Domain=abc.com; Expires=Mon,05-Dec-2016 18:47:42 GMT; Path=/
set-cookie:USER_JSESSIONID=agpuB2CqPDhkupxfbrJlbXF3;Domain=abc.com;Expires=Mon, 05-Dec-2016 18:47:42 GMT; Path=/
set-cookie:bac_user_info="UserName|UserLName|UserMailId"; Version=1;Domain=abc.com; Max-Age=3600; Path=/
set-cookie: beID=0023T21; Domain=abc.com; Expires=Mon, 05-Dec-2016 18:47:42 GMT; Path=/
set-cookie:NSC_WB2-CF-8080=ffffffff09ae530a45525d5f4f58455e445a4a4229a0;path=/;httponly
Content-Type: application/json; charset=utf-8
Content-Length: 131
ETag: W/"83-+Jfk31hxbwmLWd1hTlIO1Q"
Date: Mon, 05 Dec 2016 17:47:42 GMT
Connection: abc
If you want to send multiple cookies, just sepreate them by ;
curl -v --cookie "TOKEN1=Yes;TOKEN2=no" http://127.0.0.1:5000

Resources