Skip to content

Commit

Permalink
sdk: Add NodeJS SDK (#94)
Browse files Browse the repository at this point in the history
Signed-off-by: arekkas <aeneas@ory.am>
  • Loading branch information
arekkas committed Aug 1, 2018
1 parent e46065a commit 7505b71
Show file tree
Hide file tree
Showing 105 changed files with 7,659 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,19 @@ jobs:
gox -parallel=2 -ldflags "-X github.com/ory/oathkeeper/cmd.Version=`git describe --tags` -X github.com/ory/oathkeeper/cmd.BuildTime=`TZ=UTC date -u '+%Y-%m-%dT%H:%M:%SZ'` -X github.com/ory/oathkeeper/cmd.GitHash=`git rev-parse HEAD`" -output "dist/{{.Dir}}-{{.OS}}-{{.Arch}}";
- run: ghr -t $GITHUB_TOKEN -u $CIRCLE_PROJECT_USERNAME -r $CIRCLE_PROJECT_REPONAME --replace `git describe --tags` dist/

release-npm:
docker:
- image: circleci/node:8.9.3
working_directory: ~/hydra
steps:
- checkout
- run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/.npmrc
- run: |
npm version -f --no-git-tag-version $CIRCLE_TAG
- run: npm view ory-hydra-sdk
- run: npm whoami
- run: npm publish

workflows:
version: 2
"test, build, and relase":
Expand Down Expand Up @@ -175,10 +188,19 @@ workflows:
only: /.*/
branches:
ignore: /.*/
- release-npm:
requires:
- build-docker
filters:
tags:
only: /.*/
branches:
ignore: /.*/
- release-changelog:
requires:
- release-docker
- release-binaries
- release-npm
filters:
tags:
only: /.*/
Expand Down
26 changes: 26 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "ory-oathkeeper-sdk",
"version": "0.0.0",
"description": "The official JavaScript / NodeJS SDK for ORY Oathkeeper.",
"license": "Apache-2.0",
"main": "sdk/js/swagger/src/index.js",
"scripts": {
"prettier": "prettier --single-quote --parser flow --no-semi --write \"sdk/js/**/*.js\"",
"postinstall": "opencollective postinstall"
},
"browser": {
"fs": false
},
"dependencies": {
"opencollective": "^1.0.3",
"superagent": "3.5.2"
},
"devDependencies": {
"prettier": "^1.12.1"
},
"collective": {
"type": "opencollective",
"url": "https://opencollective.com/ory",
"logo": "https://opencollective.com/ory/logo.txt"
}
}
6 changes: 6 additions & 0 deletions scripts/run-gensdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,15 @@ rm -rf ./sdk/js/swagger
# curl -O scripts/swagger-codegen-cli-2.2.3.jar http://central.maven.org/maven2/io/swagger/swagger-codegen-cli/2.2.3/swagger-codegen-cli-2.2.3.jar

java -jar scripts/swagger-codegen-cli-2.2.3.jar generate -i ./docs/api.swagger.json -l go -o ./sdk/go/oathkeeper/swagger
java -jar scripts/swagger-codegen-cli-2.2.3.jar generate -i ./docs/api.swagger.json -l javascript -o ./sdk/js/swagger

scripts/run-format.sh

git checkout HEAD -- sdk/go/oathkeeper/swagger/rule_handler.go

git add -A .

rm -f ./sdk/js/swagger/package.json
rm -rf ./sdk/js/swagger/test

npm run prettier
23 changes: 23 additions & 0 deletions sdk/js/swagger/.swagger-codegen-ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Swagger Codegen Ignore
# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen

# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.

# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line:
#ApiClient.cs

# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux

# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux

# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md
1 change: 1 addition & 0 deletions sdk/js/swagger/.swagger-codegen/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.2.3
7 changes: 7 additions & 0 deletions sdk/js/swagger/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
language: node_js
node_js:
- "6"
- "6.1"
- "5"
- "5.11"

163 changes: 163 additions & 0 deletions sdk/js/swagger/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
# ory_oathkeeper

OryOathkeeper - JavaScript client for ory_oathkeeper
ORY Oathkeeper is a reverse proxy that checks the HTTP Authorization for validity against a set of rules. This service uses Hydra to validate access tokens and policies.
This SDK is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:

- API version: Latest
- Package version: Latest
- Build package: io.swagger.codegen.languages.JavascriptClientCodegen
For more information, please visit [https://www.ory.am](https://www.ory.am)

## Installation

### For [Node.js](https://nodejs.org/)

#### npm

To publish the library as a [npm](https://www.npmjs.com/),
please follow the procedure in ["Publishing npm packages"](https://docs.npmjs.com/getting-started/publishing-npm-packages).

Then install it via:

```shell
npm install ory_oathkeeper --save
```

##### Local development

To use the library locally without publishing to a remote npm registry, first install the dependencies by changing
into the directory containing `package.json` (and this README). Let's call this `JAVASCRIPT_CLIENT_DIR`. Then run:

```shell
npm install
```

Next, [link](https://docs.npmjs.com/cli/link) it globally in npm with the following, also from `JAVASCRIPT_CLIENT_DIR`:

```shell
npm link
```

Finally, switch to the directory you want to use your ory_oathkeeper from, and run:

```shell
npm link /path/to/<JAVASCRIPT_CLIENT_DIR>
```

You should now be able to `require('ory_oathkeeper')` in javascript files from the directory you ran the last
command above from.

#### git
#
If the library is hosted at a git repository, e.g.
https://github.com/GIT_USER_ID/GIT_REPO_ID
then install it via:

```shell
npm install GIT_USER_ID/GIT_REPO_ID --save
```

### For browser

The library also works in the browser environment via npm and [browserify](http://browserify.org/). After following
the above steps with Node.js and installing browserify with `npm install -g browserify`,
perform the following (assuming *main.js* is your entry file, that's to say your javascript file where you actually
use this library):

```shell
browserify main.js > bundle.js
```

Then include *bundle.js* in the HTML pages.

### Webpack Configuration

Using Webpack you may encounter the following error: "Module not found: Error:
Cannot resolve module", most certainly you should disable AMD loader. Add/merge
the following section to your webpack config:

```javascript
module: {
rules: [
{
parser: {
amd: false
}
}
]
}
```

## Getting Started

Please follow the [installation](#installation) instruction and execute the following JS code:

```javascript
var OryOathkeeper = require('ory_oathkeeper');

var api = new OryOathkeeper.DefaultApi()

var callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
};
api.getWellKnown(callback);

```

## Documentation for API Endpoints

All URIs are relative to *http://localhost*

Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*OryOathkeeper.DefaultApi* | [**getWellKnown**](docs/DefaultApi.md#getWellKnown) | **GET** /.well-known/jwks.json | Returns well known keys
*OryOathkeeper.HealthApi* | [**isInstanceAlive**](docs/HealthApi.md#isInstanceAlive) | **GET** /health/alive | Check the Alive Status
*OryOathkeeper.HealthApi* | [**isInstanceReady**](docs/HealthApi.md#isInstanceReady) | **GET** /health/ready | Check the Readiness Status
*OryOathkeeper.JudgeApi* | [**judge**](docs/JudgeApi.md#judge) | **GET** /judge | Judge if a request should be allowed or not
*OryOathkeeper.RuleApi* | [**createRule**](docs/RuleApi.md#createRule) | **POST** /rules | Create a rule
*OryOathkeeper.RuleApi* | [**deleteRule**](docs/RuleApi.md#deleteRule) | **DELETE** /rules/{id} | Delete a rule
*OryOathkeeper.RuleApi* | [**getRule**](docs/RuleApi.md#getRule) | **GET** /rules/{id} | Retrieve a rule
*OryOathkeeper.RuleApi* | [**listRules**](docs/RuleApi.md#listRules) | **GET** /rules | List all rules
*OryOathkeeper.RuleApi* | [**updateRule**](docs/RuleApi.md#updateRule) | **PUT** /rules/{id} | Update a rule
*OryOathkeeper.VersionApi* | [**getVersion**](docs/VersionApi.md#getVersion) | **GET** /version | Get the version of Oathkeeper


## Documentation for Models

- [OryOathkeeper.AuthenticationDefaultSession](docs/AuthenticationDefaultSession.md)
- [OryOathkeeper.AuthenticationOAuth2ClientCredentialsRequest](docs/AuthenticationOAuth2ClientCredentialsRequest.md)
- [OryOathkeeper.AuthenticationOAuth2ClientCredentialsSession](docs/AuthenticationOAuth2ClientCredentialsSession.md)
- [OryOathkeeper.AuthenticationOAuth2IntrospectionRequest](docs/AuthenticationOAuth2IntrospectionRequest.md)
- [OryOathkeeper.AuthenticationOAuth2Session](docs/AuthenticationOAuth2Session.md)
- [OryOathkeeper.Authenticator](docs/Authenticator.md)
- [OryOathkeeper.HealthNotReadyStatus](docs/HealthNotReadyStatus.md)
- [OryOathkeeper.HealthStatus](docs/HealthStatus.md)
- [OryOathkeeper.InlineResponse401](docs/InlineResponse401.md)
- [OryOathkeeper.IntrospectionResponse](docs/IntrospectionResponse.md)
- [OryOathkeeper.JsonWebKey](docs/JsonWebKey.md)
- [OryOathkeeper.JsonWebKeySet](docs/JsonWebKeySet.md)
- [OryOathkeeper.OAuth2ClientCredentialsAuthentication](docs/OAuth2ClientCredentialsAuthentication.md)
- [OryOathkeeper.OAuth2IntrospectionAuthentication](docs/OAuth2IntrospectionAuthentication.md)
- [OryOathkeeper.Rule](docs/Rule.md)
- [OryOathkeeper.RuleHandler](docs/RuleHandler.md)
- [OryOathkeeper.RuleMatch](docs/RuleMatch.md)
- [OryOathkeeper.Session](docs/Session.md)
- [OryOathkeeper.SwaggerCreateRuleParameters](docs/SwaggerCreateRuleParameters.md)
- [OryOathkeeper.SwaggerGetRuleParameters](docs/SwaggerGetRuleParameters.md)
- [OryOathkeeper.SwaggerListRulesParameters](docs/SwaggerListRulesParameters.md)
- [OryOathkeeper.SwaggerRuleResponse](docs/SwaggerRuleResponse.md)
- [OryOathkeeper.SwaggerRulesResponse](docs/SwaggerRulesResponse.md)
- [OryOathkeeper.SwaggerUpdateRuleParameters](docs/SwaggerUpdateRuleParameters.md)
- [OryOathkeeper.Upstream](docs/Upstream.md)
- [OryOathkeeper.Version](docs/Version.md)


## Documentation for Authorization

All endpoints do not require authorization.

9 changes: 9 additions & 0 deletions sdk/js/swagger/docs/AuthenticationDefaultSession.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# OryOathkeeper.AuthenticationDefaultSession

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**allowed** | **Boolean** | Allowed is true if the request is allowed and false otherwise. | [optional]
**sub** | **String** | Subject is the identity that authorized issuing the token, for example a user or an OAuth2 app. This is usually a uuid but you can choose a urn or some other id too. | [optional]


Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# OryOathkeeper.AuthenticationOAuth2ClientCredentialsRequest

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **String** | Token is the token to introspect. | [optional]
**scope** | **[String]** | Scope is an array of scopes that are required. | [optional]
**secret** | **String** | | [optional]


Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# OryOathkeeper.AuthenticationOAuth2ClientCredentialsSession

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**allowed** | **Boolean** | Allowed is true if the request is allowed and false otherwise. | [optional]
**sub** | **String** | Subject is the identity that authorized issuing the token, for example a user or an OAuth2 app. This is usually a uuid but you can choose a urn or some other id too. | [optional]


Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# OryOathkeeper.AuthenticationOAuth2IntrospectionRequest

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**scope** | **[String]** | Scope is an array of scopes that are required. | [optional]
**token** | **String** | Token is the token to introspect. | [optional]


18 changes: 18 additions & 0 deletions sdk/js/swagger/docs/AuthenticationOAuth2Session.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# OryOathkeeper.AuthenticationOAuth2Session

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**allowed** | **Boolean** | Allowed is true if the request is allowed and false otherwise. | [optional]
**aud** | **[String]** | | [optional]
**clientId** | **String** | ClientID is the id of the OAuth2 client that requested the token. | [optional]
**exp** | **Date** | ExpiresAt is the expiry timestamp. | [optional]
**iat** | **Date** | IssuedAt is the token creation time stamp. | [optional]
**iss** | **String** | Issuer is the id of the issuer, typically an hydra instance. | [optional]
**nbf** | **Date** | | [optional]
**scope** | **String** | GrantedScopes is a list of scopes that the subject authorized when asked for consent. | [optional]
**session** | **{String: Object}** | Session represents arbitrary session data. | [optional]
**sub** | **String** | Subject is the identity that authorized issuing the token, for example a user or an OAuth2 app. This is usually a uuid but you can choose a urn or some other id too. | [optional]
**username** | **String** | | [optional]


7 changes: 7 additions & 0 deletions sdk/js/swagger/docs/Authenticator.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# OryOathkeeper.Authenticator

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------


Loading

0 comments on commit 7505b71

Please sign in to comment.