@kaltiot/ks-secret-api
v1.0.0
Published
Helper library for fetching a secret for a username.
Downloads
1
Readme
ks-secret-api
Helper library for fetching a secret for a username.
API
secret.fetch(opts [, callback])
Fetch a secret for a username. Provide a callback function if you want to use that. Or use the returned promise.
opts
can have the following fields:
Field | Type | Description ------|------|------------ address | string | (optional) Server address. sessionId | string | (required) Session ID. username | string | (required) The username to fetch the secret for.
Usage
node.js
var secret = require("@kaltiot/ks-secret-api");
secret.fetch({ ... }).then(function (secret) {
// do something
}):;
Browser
There's a pre-compiled file for the browser in dist/secret.js
. Include it and window.KSSecretAPI
will be set.
<!DOCTYPE html>
<html>
<head>
<title>secret fetch</title>
</head>
<body>
<script type="text/javascript" src="/dist/secret.js"></script>
<script type="text/javascript">
var secret = window.KSSecretAPI;
secret.fetch({ ... }).then(function (secret) {
// do something
});
</script>
</body>
</html>