Socket
Socket
Sign inDemoInstall

@adobe/fetch

Package Overview
Dependencies
Maintainers
44
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@adobe/fetch - npm Package Compare versions

Comparing version 0.1.4 to 0.1.5

test/storage.test.js

12

index.js

@@ -81,3 +81,4 @@ /*

privateKey,
metaScopes
metaScopes,
storage
} = options;

@@ -106,2 +107,11 @@

}
if (storage) {
let { read, write } = storage;
if (!read) {
throw 'Storage read method missing!';
} else if (!write) {
throw 'Storage write method missing!';
}
}
}

@@ -108,0 +118,0 @@

2

package.json
{
"name": "@adobe/fetch",
"version": "0.1.4",
"version": "0.1.5",
"description": "Call Adobe APIs",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -65,3 +65,3 @@ [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)

| metaScopes | | true | Comma separated Sting or an Array | |
| ims | | false | String | https://ims-na1.adobelogin.com |
| ims | | false | String | <https://ims-na1.adobelogin.com> |

@@ -72,4 +72,4 @@ In order to determine which **metaScopes** you need to register for you can look them up by product in this [handy table](https://www.adobe.io/authentication/auth-methods.html#!AdobeDocs/adobeio-auth/master/JWT/Scopes.md).

- GDPR: https://ims-na1.adobelogin.com/s/ent_gdpr_sdk
- User Management: https://ims-na1.adobelogin.com/s/ent_user_sdk
- GDPR: <https://ims-na1.adobelogin.com/s/ent_gdpr_sdk>
- User Management: <https://ims-na1.adobelogin.com/s/ent_user_sdk>

@@ -109,2 +109,60 @@ They you would create an array of **metaScopes** as part of the config object. For instance:

#### Custom Storage
By default, [node-persist](https://github.com/bitinn/node-persist) is used to store all the active tokens locally.
Tokens will be stored under **/.node-perist/storage**
It is possible to use any other storage for token persistance. This is done by providing **read** and **write** methods as follows:
```javascript
const config = {
auth: {
clientId: 'asasdfasf',
...
storage: {
read: function() {
return new Promise(function(resolve, reject) {
let tokens;
// .. Some logic to read the tokens ..
resolve(tokens);
});
},
write: function(tokens) {
return new Promise(function(resolve, reject) {
// .. Some logic to save the tokens ..
resolve();
});
}
}
}
};
```
Alternatively, use async/await:
```javascript
const config = {
auth: {
clientId: 'asasdfasf',
...
storage: {
read: async function() {
return await myGetTokensImplementation();
},
write: async function(tokens) {
await myStoreTokensImplementation(tokens);
}
}
}
};
```
### Contributing

@@ -111,0 +169,0 @@

@@ -26,3 +26,3 @@ /* eslint-disable require-atomic-updates */

if (!cache.disableStorage) {
cache.tokens = await storage.read();
cache.tokens = await cache.read();
cache.readOnce = true;

@@ -39,3 +39,3 @@ }

if (!cache.disableStorage) {
await storage.save(cache.tokens);
await cache.write(cache.tokens);
}

@@ -94,5 +94,10 @@ }

const disableStorage = (options && options.disableStorage) || false;
const readFunc = options.storage ? options.storage.read : storage.read;
const writeFunc = options.storage ? options.storage.write : storage.write;
const cache = {
disableStorage: disableStorage,
readOnce: disableStorage,
read: readFunc,
write: writeFunc,
tokens: {}

@@ -99,0 +104,0 @@ };

@@ -52,3 +52,3 @@ /*

*/
async function save(tokens) {
async function write(tokens) {
return await storage.setItem(TOKENS, tokens);

@@ -58,2 +58,2 @@ }

module.exports.read = read;
module.exports.save = save;
module.exports.write = write;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc