https://github.com/oada/oada-client-discovery-js
OADA client discovery middleware
https://github.com/oada/oada-client-discovery-js
Last synced: 12 months ago
JSON representation
OADA client discovery middleware
- Host: GitHub
- URL: https://github.com/oada/oada-client-discovery-js
- Owner: OADA
- License: apache-2.0
- Created: 2014-10-15T20:15:12.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2023-01-10T07:43:29.000Z (over 3 years ago)
- Last Synced: 2025-06-20T23:06:49.465Z (12 months ago)
- Language: JavaScript
- Size: 19.5 KB
- Stars: 0
- Watchers: 7
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
* This repository is deprecated. CLient discovery is no longer an OADA protocol. *
[](https://travis-ci.org/OADA/oada-client-discovery-js)
[](https://coveralls.io/r/OADA/oada-client-discovery-js?branch=master)
[](https://david-dm.org/oada/oada-client-discovery-js)
[](http://www.apache.org/licenses/LICENSE-2.0.html)
# oada-client-discovery-js
Connect style middleware for OADA (openag.io) client discovery.
## Getting Started
### Installation ###
The library can be installed with `npm` using
```sh
$ npm install oada-client-discovery
```
### Running the Examples ###
#### Minimal Example ##
See [examples README](examples/README.md)
### Running the tests, coverage, and style checks ###
The libraries test can be ran with:
```sh
$ npm test
```
The coverage report is generated by:
```sh
$ npm run cover
```
Gulp runs `jshint` (lint) and `jscs` (style) with:
```sh
$ gulp lint
$ gulp style
```
## API
### clientDiscovery(lookup, options) ###
Connect style middleware for [OADA][oada-docs] client discovery.
To eliminate a dependency on any particular storage system or database a
`lookup` function that fetches client registrations must be provided by the
caller.
[CORS][cors] is required by OADA client discovery and therefore automatically
enabled. See [node-cors][node-cors].
#### Parameters ####
`lookup` {Function} that resolves a client registration from a client ID. It
takes the form `function(lookup, callback)`.
`options` {Object, *Optional*} possibly containing the following properties:
* `cors` {Object} Options object for [node-cors][node-cors]. *Default: {}*
#### Client Registration Object ####
An OADA client registration is a JSON document with at least the following
properties:
* `clientId` {String} client ID
* `redirectUrls` {Array of Strings} Array of allowable OAuth 2.0 redirect URLs.
* `licenses` {Array of Strings} Array of license names the client developer has
agreed to.
* `keys` {[JSON Web Key (JWK) Set][jwks]} containing the client's JWKs for use
with OADA specific OAuth 2.0/OpenID Connect client secrets.
##### Example Client Registration #####
```json
{
"clientId": "123abc@agcloud.com",
"redirectUrls": [
"https://agcloud.com/redirect"
],
"licenses": [
"oada",
],
"keys": [
{
"kty": "RSA",
"use": "sig",
"alg": "RS256",
"kid": "ad8alkjca38afvudsZA",
"n": "AOtWalmH3vZ2q2Be ... SRQjYzxqpyVR9HEJYJ",
"e": "AQAB",
}
]
}
```
#### Usage Example ####
```javascript
var express = require('express');
var clientDiscovery = require('oada-client-discovery');
var app = express();
app.get('/clientDiscovery', clientDiscovery(
function(clientId, cb) {
clients.find({clientId: clientId}, function(err, clients) {
if(err) { return cb(err); }
cb(null, clients[0]);
})
}));
```
[oada-docs]: http://github.com/OADA/oada-docs
[cors]: http://www.w3.org/TR/cors/
[node-cors]: https://github.com/troygoode/node-cors
[jwks]: https://tools.ietf.org/html/draft-ietf-jose-json-web-key-33#section-5