Dynamic redirects with declarativeNetRequest - google-chrome

I want to use declarativeNetRequest to redirect all URLs from a domain to a URL with the initiator URL as an encoded parameter e.g.
http://www.google.com --> http://www.newsite.com?url=http%3A%2F%2Fwww.google.com
http://www.google.com?param1=true --> http://www.newsite.com?url=http%3A%2F%2Fwww.google.com%3Fparam1%3Dtrue
Something like...
{
"id": 1,
"priority": 1,
"action": {
"type": "redirect",
"redirect": {
"url": `http://www.newsite.com?url=${encodeURIComponent(url)}`
}
}
}
Is this possible to do? If not is there another way to achieve this?

[
{
"id": 1,
"priority": 1,
"action": {
"type": "redirect",
"redirect": {
"regexSubstitution": "http://www.newsite.com?url=\\0"
}
},
"condition": {
"regexFilter": "^https://www.google.com(.*)",
"resourceTypes": ["main_frame"]
}
}
]
It won't URL encode it but I've found it's not really an issue provided the parameter is at the end. Also be careful to limit it to particular sites in the regex or else you could end up with an endless loop.

Related

Integrating Docusign Identity Verification (Phone Authentication) with an envelope

I was using identity verification feature from Docusign with envelopes. Previously, envelopes are working fine without it. Then I enabled this feature and searched on the Docusign API Documentation, how to implement this feature. I got the necessary details like authentication token, workflow id. Try to hit the endpoint using Post request. Everything's fine but having issues in the body part of the post request getting invalid phone number response. Thank you for your time! Please help!
//Post request endpoint
https://demo.docusign.net/restapi/v2.1/accounts/f8594d59-9d52-xxxx-xxxx-xxxxxxxxxxxx/envelopes
//header
Authorization: Bearer {accestoken}
Content-Type: application/json
Acces: application/json
//request body
{
"accountId": "f8594d59-9d52-xxxx-xxxx-xxxxxxxxxxxx",
"templateId": "4e2ba389-5d26-xxxx-xxxx-xxxxxxxxxxxx",
"emailSubject": "Please sign the contract",
"templateRoles": [
{
"roleName": "Sender",
"name": "Name",
"email": "fName.lName#xyz.com",
"identityVerification": {
"workflowId": "c368e411-1592-xxxx-xxxx-xxxxxxxxxxxx",
"steps": null,
"inputOptions": [
{
"name": "phone_number_list",
"valueType": "PhoneNumberList",
"phoneNumberList": [
{
"countryCode": "1",
"number": "8956324511"
}
]
}
]
}
},
{
"roleName": "Customer",
"name": "cFName",
"email": "cFName.cLName#gmail.com"
}
],
"status": "sent"
}
//Response
{
"errorCode": "PHONE_NUMBER_INVALID",
"message": "Phone number is not valid."
}
//Expected Response can vary
{
"envelopeId": "e8342cd0-ea2b-xxxx-xxxx-xxxxxxxxxx",
"uri": "/envelopes/e8342cd0-ea2b-xxxx-xxxx-xxxxxxxxxx",
"statusDateTime": "2023-01-13T05:22:35.0100000Z",
"status": "sent"
}
According to https://www.areacodehelp.com/where/area_code_895.shtml area code 895 is not valid.
Try with a valid phone number to confirm the issue, but to me it looks like the number you used here is indeed not a valid phone number.
PS
If you meant to use a number in Azerbaijan, you need to change the country code from "1" to "895" as it's a country code for a different country (the way you have is if for the USA)
So, basically what I found is ID verification won't work with template roles because of the syntax compatibility. But it will work with composite templates, I made it work with composite template.
Additionally, both of the methods are compatible idVerification or phoneAuthentication. I am using idVerification for the first Signer and phone Authentication for the second signer
Docusign docs have more methods as well like sms auth, etc. Explore it from these links:
https://developers.docusign.com/docs/esign-rest-api/how-to/phone-auth/
https://developers.docusign.com/docs/esign-rest-api/reference/envelopes/envelopes/create/
Check examples, in my usecase I explored Generic JSON Request/Response
Thanks for all the support from Inbar and the community!
{
"accountId": "f8594d59-9d52-xxxx-xxxx-xxxxxxxxxx",
"emailSubject": "Please sign the contract",
"status": "sent",
"compositeTemplates": [
{
"compositeTemplateId": "1",
"serverTemplates": [
{
"sequence": "1",
"templateId": "4e2ba389-5d26-xxxx-xxxx-xxxxxxxxxx"
}
],
"inlineTemplates": [
{
"sequence": "2",
"recipients": {
"signers": [
{
"roleName": "Sender",
"recipientId": "1",
"name": "Name",
"email": "fName.lName#xyz.com",
"identityVerification": {
"workflowId": "c368e411-1592-xxxx-xxxx-xxxxxxxxxx",
"steps": null,
"inputOptions": [
{
"name": "phone_number_list",
"valueType": "PhoneNumberList",
"phoneNumberList": [
{
"countryCode": "1",
"number": "1234567890"
}
]
}
]
}
},
{
"roleName": "Customer",
"recipientId": "2",
"name": "cName",
"email": "cfName.clName#gmail.com",
"phoneAuthentication": {
"senderProvidedNumbers": [
"+11234567890"
],
"recipMayProvideNumber": false
},
"idCheckConfigurationName": "Phone Auth $"
}
]
}
}
]
}
]
}
Note: Use valid phone number!

Redirects in declarativeNetRequests to Local Resource

I am trying to redirect the request sent to https://site/script1.js to a modified script stored locally chrome-extension://ext_id/my_script.js.
(Basically trying to emulate the behaviour of webRequests.onBeforeRequest -> return redirect to local file)
My rules.json :
[
{
"id": 1,
"priority": 10,
"action":
{ "type": "redirect",
"redirect" : {"extensionPath" : "/my_script.js"}
},
"condition":
{"urlFilter": "https://site/script1.js",
"resourceTypes": ["script"]
}
}
]
If I change the action type to block the chrome dev tools shows the request as blocked, and the website doesnt load, however on redirects, nothing happens and the request goes through. It doesnt work for Images either.
Is there possibly a workaround for this (to modify the script a site receives from a request)?
Edit:
I'll just try to get an image to work first, the declarativeNetRequest Docs single out Redirects for a script.
The website (https://www.example.com/a/b) sends a request to https://cdn.example.com/file.jpg. I want that request to return a file `my_file.jpg' stored locally .
I have :
Rules.json
[
{
"id": 2,
"priority": 9,
"action":
{ "type": "redirect",
"redirect" : {"extensionPath" : "/my_file.jpg"}
},
"condition":
{"urlFilter": "https://cdn.example.com/file.jpg",
"resourceTypes": ["image"]
}
}
]
and Manifest.json includes:
"host_permissions": [
"https://www.example.com/*"
],
"web_accessible_resources":[
{
"resources": ["my_file.jpg"],
"matches" :["https://www.example.com/*"]
}
]

Get Smooch Whatsapp user number

I'm testing Smooch Javascript SDK (https://docs.smooch.io/rest/#introduction) integrated to Whatsapp. I want to know if its possible to get user's phone number when I recieve a webhook request, the phone number is not in the request body.
// This is the request body I get
{
"trigger": "message:appUser",
"app": { "_id": "5d308957198c1f00104a3b88" },
"version": "v1.1",
"messages": [
{
"type": "text",
"text": "Hello",
"role": "appUser",
"received": 1563472958.747,
"name": "Kevin Arias",
"authorId": "2d4628bcb45b234a1ff",
"_id": "5d30b43ee223faa28f",
"source": {
"type": "whatsapp",
"integrationId": "5d308964a75fd5a457f",
"originalMessageId": "ABEGVzElE6JZEN_vQ92XFBiIrb4S",
"originalMessageTimestamp": 1563472958
}
}
],
"appUser": {
"_id": "2d4628b5cb45b234a1ff",
"conversationStarted": true,
"surname": "Arias",
"givenName": "Kevin",
"signedUpAt": "2019-07-18T15:00:45.883Z",
"properties": {}
},
"conversation": { "_id": "84860727bddac962a8b" }
}
Thanks,
If you enable the includeClient option on your Smooch webhook, there will be a client object included in the webhook payload, representing the source of the message. The WhatsApp username (typically the user's phone number) will be available under client.externalId

How to add inline image by Microsoft Graph API?

Background
When I use Outlook client to send a mail with inline image.
The image in html email looks like this, which has cid:
<img size="100" src="cid:3bb599fc-f3eb-465b-af83-aa6a495f563a" style="max-width:100%">
When I use
GET /me/messages/{messageId}/attachments
The contentId in the result returned matched the cid in html.
{
"value": [
{
"#odata.type": "#microsoft.graph.fileAttachment",
"id": "aaa",
"lastModifiedDateTime": "2017-11-30T09:32:09Z",
"name": "image.png",
"contentType": "image/png",
"size": 100,
"isInline": true,
"contentId": "3bb599fc-f3eb-465b-af83-aa6a495f563a",
"contentLocation": null,
"contentBytes": "validBase64Bytes"
}
]
}
Using Microsoft Graph API
Now I am trying to use Microsoft Graph API to add inline image.
POST /me/messages/{messageId}/attachments
{
"#odata.type": "#microsoft.graph.fileAttachment",
"name": "1.jpg",
"isInline": true,
"contentBytes": "validBase64Bytes"
}
However, the contentId is null in the result returned.
{
"#odata.type": "#microsoft.graph.fileAttachment",
"id": "aaa",
"lastModifiedDateTime": "2017-11-30T09:35:50Z",
"name": "1.jpg",
"contentType": "image/jpeg",
"size": 100,
"isInline": true,
"contentId": null,
"contentLocation": null,
"contentBytes": "validBase64Bytes"
}
And if I set contentId manually in POST
POST /me/messages/{messageId}/attachments
{
"#odata.type": "#microsoft.graph.fileAttachment",
"name": "1.jpg",
"isInline": true,
"contentId": "myContentId",
"contentBytes": "validBase64Bytes"
}
It will return the error
{
"error": {
"code": "BadRequest",
"message": "Unable to read JSON request payload. Please ensure Content-Type header is set and payload is of valid JSON format.",
"innerError": {
"request-id": "36e95f0a-ad75-46c6-b86c-d585a150b96d",
"date": "2017-11-30T09:37:41"
}
}
}
So how to add inline image correctly?
Weird, I tried to run the exact same code again, it won't give me any error now.
POST /me/messages/{messageId}/attachments
{
"#odata.type": "#microsoft.graph.fileAttachment",
"name": "1.jpg",
"isInline": true,
"contentId": "myContentId",
"contentBytes": "validBase64Bytes"
}
Not sure whether it is a temporary issue. I will inform Microsoft team to check the log.
If I am wrong for how to use the API, please definitely point out. Thanks.
I will leave it here for future people to save some time to implement adding inline image.

Regex on Zabbix API?

After some hours spent reading Zabbix Api's documentation, I haven't found a way of doing a search by key with more than one possible value.
So, with this code:
{
"jsonrpc": "2.0",
"method": "item.get",
"params": {
"output": "extend",
"hostids": " 10355",
"search": {
"key_": "[in_*|out_*]"
},
"sortfield": "name"
},
"auth": "15729708df1f5936f6ea840ae1b41cb6",
"id": 0
}
I'm trying to get every item which key is in_<anything> OR out_<anything> so, the output would be the combination of all the items related to the interfaces. Instead, I get this:
{"jsonrpc":"2.0","result":[],"id":0}
I know that there's the possibility to use filter instead of search but, from what I read, it is used when you want exact match, which is not the case.
Zabbix API (and filtering in other places) does not support regexp. In some versions you could pass wildcards, but that won't solve your current issue. You will have to do two separate API queries.
To answer the question in the comment here, search can be negated with the excludeSearch parameter - see the API documentation for more detail.
To this work you need put this key searchWildcardsEnabled
{
"jsonrpc": "2.0",
"method": "item.get",
"params": {
"output": "extend",
"hostids": " 10355",
"searchWildcardsEnabled": "true",
"search": {
"key_": "[in_*|out_*]"
},
"sortfield": "name"
},
"auth": "15729708df1f5936f6ea840ae1b41cb6",
"id": 0
}
I think you should consider using the searchByAny parameter that let's you find items that matchs any of the search criteria. Here is the correct json that you should try :
{
"jsonrpc": "2.0",
"method": "item.get",
"params": {
"output": "extend",
"hostids": " 10355",
"searchWildcardsEnabled": "true",
"search": {
"key_": [
"in_*",
"out_*"
]
},
"sortfield": "name"
},
"auth": "15729708df1f5936f6ea840ae1b41cb6",
"id": 1
}