RFC - API side utilities to help work with functions
See original GitHub issueIn recent projects, I have been repeating code to do some common tasks related to api side functions and it could be helpful to add this utilities to the RedwoodJS api package:
- Get the Netlify functions endpoint regardless of branch.
You will need to know the function endpoint url when invoking a background function from a RW api service – especially when you have multiple environments or deploy previews.
Something like:
export const siteUrl = () => {
const defaultUrl = `http://localhost:8910`
try {
const netlifySignature = context.clientContext?.custom?.netlify
if (netlifySignature === undefined) {
throw new Error('Undefined signature')
}
const signature = Buffer.from(netlifySignature, 'base64').toString('ascii')
const decoded = JSON.parse(signature)
if (decoded['site_url']) {
return decoded['site_url']
} else {
throw new Error('Could not find site_url in jwt')
}
} catch (error) {
console.error(`Unable to decode Netlify token from context: ${error}`)
return defaultUrl
}
}
const functionsUrl = ({ url }) => {
return `${url}/.netlify/functions`
}
- Sign function/background functions like webhooks to ensure these are not 100% open to execution by verifying the signature.
See https://github.com/quirrel-dev/secure-webhooks for some examples to sign a payload and verify it.
One might use JWS instead to sign the payload (the above uses a different technique).
- A utility to wrap signing and sending in a single method
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
How to use RFC adapter in SAP Cloud Platform Integration ...
The RFC interface system enables function calls between two SAP systems, or between an SAP system and an external system.
Read more >The RFC API
This documentation describes how to use RFC (Remote Function Call) from outside an SAP. System, that is, how to write your own RFC...
Read more >rfcs/0626-invoke-helper.md at master · emberjs/rfcs
This RFC proposes a new API, invokeHelper , which can be used to invoke a helper definition, creating an instance of the helper...
Read more >Session Traversal Utilities for NAT (STUN) RFC 5389
Abstract Session Traversal Utilities for NAT (STUN) is a protocol that serves as a tool for other protocols in dealing with Network Address...
Read more >RFC 8353: Generic Security Service API Version 2: Java ...
1. getInstance public static GSSManager getInstance() Returns the default GSSManager implementation. · 2. getMechs public abstract Oid[] getMechs() Returns an ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@jtoar Honestly, I forgot I wrote up this issue. The new webhook signature verifiers supports the features I needed when I wrote up this issue, so I think we can close this out.
Webhook helpers have been added! #1843