Skip to content

Commit

Permalink
fix: Replace POHTTP_TLS_REQUIRED env var with useTls option (#219)
Browse files Browse the repository at this point in the history
  • Loading branch information
gnarea authored Aug 2, 2022
1 parent dd4b8ee commit 811f253
Show file tree
Hide file tree
Showing 7 changed files with 333 additions and 105 deletions.
10 changes: 3 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,21 @@ relaynet-pohttp-js is meant to be used with the [core library](https://www.npmjs
```javascript
import { deliverParcel } from '@relaycorp/relaynet-pohttp';

const relayAddress = 'rng+https://relay.relaycorp.tech';

async function main() {
// `parcelSerialized` is the ArrayBuffer representation of the parcel as a RAMF message
const parcelSerialized = await yourFunctionToRetrieveTheParcel();

await deliverParcel('https://ping.relaycorp.tech', parcelSerialized, {
relayAddress,
});
await deliverParcel('https://ping.relaycorp.tech', parcelSerialized);
}
```

By default, a timeout of 3 seconds will be used and up to 3 consecutive redirects would be followed. `deliverParcel` takes an optional `options` argument to customize these and other options.
By default, a timeout of 3 seconds will be used and up to 3 consecutive redirects would be followed. `deliverParcel()` takes an optional `options` argument to customize these and other options.

TypeScript type declarations are included with this library.

## Use in integration or functional tests

Per the Relaynet specs, bindings like PoHTTP must be used over TLS, but this validation can be turned off in test suites that send requests to a mock HTTP server by setting the environment variable `POHTTP_TLS_REQUIRED` to `false`.
Per the Relaynet specs, bindings like PoHTTP must be used over TLS, but this validation can be turned off in test suites that send requests to a mock HTTP server by passing the options `useTls=false` to `deliverParcel()`.

## Support

Expand Down
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ module.exports = {
setupFiles: ["jest-date-mock"],

// A list of paths to modules that run some code to configure or set up the testing framework before each test
setupFilesAfterEnv: ["jest-extended"],
setupFilesAfterEnv: ["jest-extended/all"],

// A list of paths to snapshot serializer modules Jest should use for snapshot testing
// snapshotSerializers: [],
Expand Down
280 changes: 252 additions & 28 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,8 @@
"access": "public"
},
"dependencies": {
"@relaycorp/relaynet-core": "^1.81.11",
"axios": "^0.27.2",
"env-var": "^7.1.1"
"@relaycorp/relaynet-core": "< 2",
"axios": "^0.27.2"
},
"devDependencies": {
"@relaycorp/shared-config": "^1.9.1",
Expand All @@ -60,7 +59,7 @@
"buffer-to-arraybuffer": "0.0.6",
"jest": "^28.1.3",
"jest-date-mock": "^1.0.8",
"jest-extended": "^3.0.1",
"jest-extended": "^2.0.0",
"npm-run-all": "^4.1.5",
"prettier": "^2.7.1",
"rimraf": "^3.0.2",
Expand Down
Loading

0 comments on commit 811f253

Please sign in to comment.