Macaroons: cookies with contextual caveats for decentralized authorization in the cloud.
npm install macaroon
* macaroon
* Macaroon#caveats ⇒ Array ⏏
* Macaroon#location ⇒ string ⏏
* Macaroon#identifier ⇒ Uint8Array ⏏
* Macaroon#signature ⇒ Uint8Array ⏏
* base64ToBytes(s) ⇒ Uint8Array ⏏
* bytesToBase64(bytes) ⇒ string ⏏
* [Macaroon#addThirdPartyCaveat(rootKeyBytes, caveatIdBytes, [locationStr])](#exp_module_macaroon--Macaroon+addThirdPartyCaveat) ⏏
* Macaroon#addFirstPartyCaveat(caveatIdBytes) ⏏
* Macaroon#bindToRoot(rootSig) ⏏
* Macaroon#clone() ⇒ Macaroon ⏏
* Macaroon#verify(rootKeyBytes, check, discharges) ⏏
* Macaroon#exportJSON() ⇒ Object ⏏
* Macaroon#exportBinary() ⇒ Uint8Array ⏏
* importMacaroon(obj) ⇒ Macaroon \| Array.<Macaroon> ⏏
* importMacaroons(obj) ⇒ Array.<Macaroon> ⏏
* newMacaroon() ⇒ Macaroon ⏏
* dischargeMacaroon(macaroon, getDischarge, onOk, onError) ⏏
Kind: Exported member
Returns: Array - - The macaroon's caveats.
Kind: Exported member
Returns: string - - The macaroon's location.
Kind: Exported member
Returns: Uint8Array - - The macaroon's identifier.
Kind: Exported member
Returns: Uint8Array - - The macaroon's signature.
Kind: Exported function
Returns: Uint8Array - - The decoded bytes.
| Param | Type | Description |
| --- | --- | --- |
| s | string | The base64 string to decode. |
Kind: Exported function
Returns: string - - The base64-encoded result.
| Param | Type | Description |
| --- | --- | --- |
| bytes | Uint8Array | The bytes to encode. |
Kind: Exported function
| Param | Type |
| --- | --- |
| rootKeyBytes | Uint8Array |
| caveatIdBytes | Uint8Array \| string |
| [locationStr] | String |
Kind: Exported function
| Param | Type |
| --- | --- |
| caveatIdBytes | String \| Uint8Array |
Kind: Exported function
| Param | Type |
| --- | --- |
| rootSig | Uint8Array |
Kind: Exported function
Returns: Macaroon - - The cloned macaroon.
Kind: Exported function
| Param | Type | Description |
| --- | --- | --- |
| rootKeyBytes | Uint8Array | Must be the same that the macaroon was originally created with. |
| check | function | Called to verify each first-party caveat. It is passed the condition to check (a string) and should return an error string if the condition is not met, or null if satisfied. |
| discharges | Array | |
Kind: Exported function
| Param | Description |
| --- | --- |
| obj | A deserialized JSON macaroon. |
This function accepts a strict superset of the formats accepted
by importMacaroons. When decoding a single macaroon,
it will return an array with one macaroon element.
Kind: Exported function
| Param | Description |
| --- | --- |
| obj | A deserialized JSON macaroon or macaroons. |
Kind: Exported function
| Type | Description |
| --- | --- |
| Object | The necessary values to generate a macaroon. It contains the following fields: identifier: {String | Uint8Array} location: {String} (optional) rootKey: {String | Uint8Array} version: {int} (optional; defaults to 2). |
Kind: Exported function
| Param | Type | Description |
| --- | --- | --- |
| macaroon | Macaroon | The macaroon to discharge. |
| getDischarge | function | Called with 5 arguments. macaroon.location {String} caveat.location {String} caveat.id {String} success {Function} failure {Function} |
| onOk | function | Called with an array argument holding the macaroon as the first element followed by all the discharge macaroons. All the discharge macaroons will be bound to the primary macaroon. |
| onError | function | Called if an error occurs during discharge. |