Milestone 0: import zappier billing, Verae middleware, and Zapier research
Compose-ready workspace: packages/zappier (rate card, portal, Stripe), packages/verae-zapier-middleware (timestamp + NATS), packages/verae-zapier (CLI app), vendor/zapier-platform, and research/zapier vendor corpus. Gate 0 structure checks pass. Product code and research are not yet wired.
This commit is contained in:
commit
b4150c8250
1364 changed files with 6814366 additions and 0 deletions
63
vendor/zapier-platform/example-apps/oauth1-trello/.gitignore
vendored
Normal file
63
vendor/zapier-platform/example-apps/oauth1-trello/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/
|
||||
dist/
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# Typescript v1 declaration files
|
||||
typings/
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# environment variables file
|
||||
.env
|
||||
.environment
|
||||
|
||||
# next.js build output
|
||||
.next
|
||||
34
vendor/zapier-platform/example-apps/oauth1-trello/README.md
vendored
Normal file
34
vendor/zapier-platform/example-apps/oauth1-trello/README.md
vendored
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
# oauth1-trello
|
||||
|
||||
This Zapier integration project is generated by the `zapier-platform init` CLI command.
|
||||
|
||||
These are what you normally do next:
|
||||
|
||||
```bash
|
||||
# Install dependencies
|
||||
npm install # or you can use yarn
|
||||
|
||||
# Run tests
|
||||
zapier-platform test
|
||||
|
||||
# Register the integration on Zapier if you haven't
|
||||
zapier-platform register "App Title"
|
||||
|
||||
# Or you can link to an existing integration on Zapier
|
||||
zapier-platform link
|
||||
|
||||
# Push it to Zapier
|
||||
zapier-platform push
|
||||
```
|
||||
|
||||
Then, to add more features, you can use the `zapier-platform scaffold` command, for example:
|
||||
|
||||
```bash
|
||||
# Add a trigger
|
||||
zapier-platform scaffold trigger contact
|
||||
|
||||
# Add an action
|
||||
zapier-platform scaffold create contact
|
||||
```
|
||||
|
||||
Find out more on the latest docs: https://github.com/zapier/zapier-platform/blob/main/packages/cli/README.md.
|
||||
82
vendor/zapier-platform/example-apps/oauth1-trello/authentication.js
vendored
Normal file
82
vendor/zapier-platform/example-apps/oauth1-trello/authentication.js
vendored
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
'use strict';
|
||||
|
||||
const querystring = require('querystring');
|
||||
|
||||
const REQUEST_TOKEN_URL = 'https://trello.com/1/OAuthGetRequestToken';
|
||||
const ACCESS_TOKEN_URL = 'https://trello.com/1/OAuthGetAccessToken';
|
||||
const AUTHORIZE_URL = 'https://trello.com/1/OAuthAuthorizeToken';
|
||||
|
||||
const getRequestToken = async (z, bundle) => {
|
||||
const response = await z.request({
|
||||
url: REQUEST_TOKEN_URL,
|
||||
method: 'POST',
|
||||
auth: {
|
||||
oauth_consumer_key: process.env.CLIENT_ID,
|
||||
oauth_consumer_secret: process.env.CLIENT_SECRET,
|
||||
oauth_signature_method: 'HMAC-SHA1',
|
||||
oauth_callback: bundle.inputData.redirect_uri,
|
||||
|
||||
// oauth_version: '1.0' // sometimes required
|
||||
},
|
||||
});
|
||||
return querystring.parse(response.content);
|
||||
};
|
||||
|
||||
const getAccessToken = async (z, bundle) => {
|
||||
const response = await z.request({
|
||||
url: ACCESS_TOKEN_URL,
|
||||
method: 'POST',
|
||||
auth: {
|
||||
oauth_consumer_key: process.env.CLIENT_ID,
|
||||
oauth_consumer_secret: process.env.CLIENT_SECRET,
|
||||
oauth_token: bundle.inputData.oauth_token,
|
||||
oauth_token_secret: bundle.inputData.oauth_token_secret,
|
||||
oauth_verifier: bundle.inputData.oauth_verifier,
|
||||
},
|
||||
});
|
||||
return querystring.parse(response.content);
|
||||
};
|
||||
|
||||
// You want to make a request to an endpoint that is either specifically designed
|
||||
// to test auth, or one that every user will have access to. eg: `/me`.
|
||||
// By returning the entire request object, you have access to the request and
|
||||
// response data for testing purposes. Your connection label can access any data
|
||||
// from the returned response using the `json.` prefix. eg: `{{json.username}}`.
|
||||
const test = (z, bundle) =>
|
||||
z.request({ url: 'https://api.trello.com/1/members/me/' });
|
||||
|
||||
module.exports = {
|
||||
// OAuth1 is an older form of OAuth
|
||||
type: 'oauth1',
|
||||
oauth1Config: {
|
||||
// We have to define getRequestToken and getAccessToken functions to explicitly
|
||||
// parse the response like it has a form body here, since Trello responds
|
||||
// 'text/plain' for the Content-Type header
|
||||
getRequestToken,
|
||||
getAccessToken,
|
||||
authorizeUrl: {
|
||||
url: AUTHORIZE_URL,
|
||||
params: {
|
||||
oauth_token: '{{bundle.inputData.oauth_token}}',
|
||||
name: 'Zapier/Trello OAuth1 Test',
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
// Define any input app's auth requires here. The user will be prompted to enter
|
||||
// this info when they connect their account.
|
||||
fields: [],
|
||||
|
||||
// The test method allows Zapier to verify that the credentials a user provides
|
||||
// are valid. We'll execute this method whenever a user connects their account for
|
||||
// the first time.
|
||||
test,
|
||||
|
||||
// This template string can access all the data returned from the auth test. If
|
||||
// you return the test object, you'll access the returned data with a label like
|
||||
// `{{json.X}}`. If you return `response.data` from your test, then your label can
|
||||
// be `{{X}}`. This can also be a function that returns a label. That function has
|
||||
// the standard args `(z, bundle)` and data returned from the test can be accessed
|
||||
// in `bundle.inputData.X`.
|
||||
connectionLabel: '{{username}}',
|
||||
};
|
||||
26
vendor/zapier-platform/example-apps/oauth1-trello/index.js
vendored
Normal file
26
vendor/zapier-platform/example-apps/oauth1-trello/index.js
vendored
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
const authentication = require('./authentication');
|
||||
const { befores = [], afters = [] } = require('./middleware');
|
||||
|
||||
module.exports = {
|
||||
// This is just shorthand to reference the installed dependencies you have.
|
||||
// Zapier will need to know these before we can upload.
|
||||
version: require('./package.json').version,
|
||||
platformVersion: require('zapier-platform-core').version,
|
||||
|
||||
authentication,
|
||||
|
||||
beforeRequest: [...befores],
|
||||
|
||||
afterResponse: [...afters],
|
||||
|
||||
// If you want your trigger to show up, you better include it here!
|
||||
triggers: {},
|
||||
|
||||
// If you want your searches to show up, you better include it here!
|
||||
searches: {},
|
||||
|
||||
// If you want your creates to show up, you better include it here!
|
||||
creates: {},
|
||||
|
||||
resources: {},
|
||||
};
|
||||
27
vendor/zapier-platform/example-apps/oauth1-trello/middleware.js
vendored
Normal file
27
vendor/zapier-platform/example-apps/oauth1-trello/middleware.js
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
'use strict';
|
||||
|
||||
// This function runs before every outbound request. You can have as many as you
|
||||
// need. They'll need to each be registered in your index.js file.
|
||||
const includeAccessToken = (request, z, bundle) => {
|
||||
if (
|
||||
bundle.authData &&
|
||||
bundle.authData.oauth_token &&
|
||||
bundle.authData.oauth_token_secret
|
||||
) {
|
||||
// Put your OAuth1 credentials in `req.auth`, Zapier will sign the request for
|
||||
// you.
|
||||
request.auth = {
|
||||
oauth_consumer_key: process.env.CLIENT_ID,
|
||||
oauth_consumer_secret: process.env.CLIENT_SECRET,
|
||||
oauth_token: bundle.authData.oauth_token,
|
||||
oauth_token_secret: bundle.authData.oauth_token_secret,
|
||||
|
||||
// oauth_version: '1.0', // sometimes required
|
||||
...(request.auth || {}),
|
||||
};
|
||||
}
|
||||
|
||||
return request;
|
||||
};
|
||||
|
||||
module.exports = { befores: [includeAccessToken], afters: [] };
|
||||
16
vendor/zapier-platform/example-apps/oauth1-trello/package.json
vendored
Normal file
16
vendor/zapier-platform/example-apps/oauth1-trello/package.json
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"name": "oauth1-trello",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "jest --testTimeout 10000"
|
||||
},
|
||||
"dependencies": {
|
||||
"zapier-platform-core": "19.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"jest": "^29.6.0"
|
||||
},
|
||||
"private": true
|
||||
}
|
||||
65
vendor/zapier-platform/example-apps/oauth1-trello/test/authentication.test.js
vendored
Normal file
65
vendor/zapier-platform/example-apps/oauth1-trello/test/authentication.test.js
vendored
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
/* globals describe, it, expect, beforeAll */
|
||||
|
||||
const zapier = require('zapier-platform-core');
|
||||
|
||||
zapier.tools.env.inject(); // read from the .env file
|
||||
|
||||
const App = require('../index');
|
||||
const appTester = zapier.createAppTester(App);
|
||||
|
||||
// You should create a `.env` file and populate it with your actual Trello
|
||||
// client ID and secret (called "API Key" and "API Secret" by Trello), which you
|
||||
// can find on https://trello.com/app-key.
|
||||
// The `.env` file should look like
|
||||
/*
|
||||
CLIENT_ID=<trello_api_key>
|
||||
CLIENT_SECRET=<trello_api_secret>
|
||||
*/
|
||||
// then you can delete the following 2 lines
|
||||
process.env.CLIENT_ID = process.env.CLIENT_ID || '<trello_api_key>';
|
||||
process.env.CLIENT_SECRET = process.env.CLIENT_SECRET || '<trello_api_secret>';
|
||||
|
||||
describe('oauth1 app', () => {
|
||||
beforeAll(() => {
|
||||
// It's a good idea to store your Client ID and Secret in the environment rather than in code.
|
||||
if (!(process.env.CLIENT_ID && process.env.CLIENT_SECRET)) {
|
||||
throw new Error(
|
||||
`Before running the tests, make sure CLIENT_ID and CLIENT_SECRET are available in the environment.`,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
it('fetch a request token', async () => {
|
||||
const bundle = {
|
||||
inputData: {
|
||||
// You should add your redirect URI to https://trello.com/app-key
|
||||
redirect_uri: 'https://zapier.com',
|
||||
},
|
||||
};
|
||||
const tokens = await appTester(
|
||||
App.authentication.oauth1Config.getRequestToken,
|
||||
bundle,
|
||||
);
|
||||
expect(tokens).toHaveProperty('oauth_token');
|
||||
expect(tokens).toHaveProperty('oauth_token_secret');
|
||||
});
|
||||
|
||||
it('generates an authorize URL', async () => {
|
||||
const bundle = {
|
||||
// In production, these will be generated by Zapier and set automatically
|
||||
inputData: {
|
||||
oauth_token: '4444',
|
||||
redirect_uri: 'https://zapier.com/',
|
||||
},
|
||||
};
|
||||
|
||||
const authorizeUrl = await appTester(
|
||||
App.authentication.oauth1Config.authorizeUrl,
|
||||
bundle,
|
||||
);
|
||||
|
||||
expect(authorizeUrl).toBe(
|
||||
'https://trello.com/1/OAuthAuthorizeToken?oauth_token=4444&name=Zapier%2FTrello%20OAuth1%20Test',
|
||||
);
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue