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/basic-auth/.gitignore
vendored
Normal file
63
vendor/zapier-platform/example-apps/basic-auth/.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/basic-auth/README.md
vendored
Normal file
34
vendor/zapier-platform/example-apps/basic-auth/README.md
vendored
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
# basic-auth
|
||||
|
||||
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.
|
||||
32
vendor/zapier-platform/example-apps/basic-auth/authentication.js
vendored
Normal file
32
vendor/zapier-platform/example-apps/basic-auth/authentication.js
vendored
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
'use strict';
|
||||
|
||||
// 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://auth-json-server.zapier-staging.com/me' });
|
||||
|
||||
module.exports = {
|
||||
// "basic" auth automatically creates "username" and "password" input fields. It
|
||||
// also registers default middleware to create the authentication header.
|
||||
type: 'basic',
|
||||
|
||||
// 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: '{{json.username}}',
|
||||
};
|
||||
26
vendor/zapier-platform/example-apps/basic-auth/index.js
vendored
Normal file
26
vendor/zapier-platform/example-apps/basic-auth/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: {},
|
||||
};
|
||||
19
vendor/zapier-platform/example-apps/basic-auth/middleware.js
vendored
Normal file
19
vendor/zapier-platform/example-apps/basic-auth/middleware.js
vendored
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
'use strict';
|
||||
|
||||
// This function runs after every outbound request. You can use it to check for
|
||||
// errors or modify the response. You can have as many as you need. They'll need
|
||||
// to each be registered in your index.js file.
|
||||
const handleBadResponses = (response, z, bundle) => {
|
||||
if (response.status === 401) {
|
||||
throw new z.errors.Error(
|
||||
// This message is surfaced to the user
|
||||
'The username and/or password you supplied is incorrect',
|
||||
'AuthenticationError',
|
||||
response.status,
|
||||
);
|
||||
}
|
||||
|
||||
return response;
|
||||
};
|
||||
|
||||
module.exports = { befores: [], afters: [handleBadResponses] };
|
||||
16
vendor/zapier-platform/example-apps/basic-auth/package.json
vendored
Normal file
16
vendor/zapier-platform/example-apps/basic-auth/package.json
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"name": "basic-auth",
|
||||
"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
|
||||
}
|
||||
43
vendor/zapier-platform/example-apps/basic-auth/test/authentication.test.js
vendored
Normal file
43
vendor/zapier-platform/example-apps/basic-auth/test/authentication.test.js
vendored
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
/* globals describe, it, expect */
|
||||
|
||||
const zapier = require('zapier-platform-core');
|
||||
|
||||
const App = require('../index');
|
||||
const appTester = zapier.createAppTester(App);
|
||||
|
||||
describe('basic auth', () => {
|
||||
it('automatically has Authorize Header add', async () => {
|
||||
const bundle = {
|
||||
authData: {
|
||||
username: 'user',
|
||||
password: 'secret',
|
||||
},
|
||||
};
|
||||
|
||||
const response = await appTester(App.authentication.test, bundle);
|
||||
|
||||
expect(response.status).toBe(200);
|
||||
expect(response.request.headers.Authorization).toBe(
|
||||
'Basic dXNlcjpzZWNyZXQ=',
|
||||
);
|
||||
});
|
||||
|
||||
it('fails on bad auth', async () => {
|
||||
const bundle = {
|
||||
authData: {
|
||||
username: 'user',
|
||||
password: 'badpwd',
|
||||
},
|
||||
};
|
||||
|
||||
try {
|
||||
await appTester(App.authentication.test, bundle);
|
||||
} catch (err) {
|
||||
expect(err.message).toContain(
|
||||
'The username and/or password you supplied is incorrect',
|
||||
);
|
||||
return;
|
||||
}
|
||||
throw new Error('appTester should have thrown');
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue