Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@forge/storage

Package Overview
Dependencies
Maintainers
8
Versions
109
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@forge/storage - npm Package Compare versions

Comparing version 0.0.0-experimental-819498d to 0.0.0-experimental-d18f8dd

42

CHANGELOG.md
# @forge/storage
## 0.0.0-experimental-819498d
## 0.0.0-experimental-d18f8dd
### Patch Changes
- d18f8dd: Force bump
## 1.1.0
### Minor Changes
- 78effb2: Remove engines.node declaration
- 0d7fe27: Support secret storage API
## 1.1.0-next.0
### Minor Changes
- 0d7fe27: Support secret storage API
## 1.0.5
### Patch Changes
- 0700578: Fix GraphQL query naming convention
## 1.0.5-next.0
### Patch Changes
- 0700578: Fix GraphQL query naming convention
## 1.0.4
### Patch Changes
- 5ff60ec: FRGE-273 Remove engines for storage and resolver
## 1.0.4-next.0
### Patch Changes
- 5ff60ec: FRGE-273 Remove engines for storage and resolver
## 1.0.3
### Patch Changes
- 9b496aa: Fixed parsing of response for cleanup functions

@@ -12,0 +50,0 @@

@@ -59,3 +59,4 @@ "use strict";

contextAri,
key: 'testKey'
key: 'testKey',
encrypted: false
});

@@ -76,3 +77,4 @@ expect(returnedValue).toEqual('testValue');

contextAri,
key: 'testKey'
key: 'testKey',
encrypted: false
});

@@ -93,3 +95,4 @@ expect(returnedValue).toEqual(undefined);

contextAri,
key: 'testKey'
key: 'testKey',
encrypted: false
});

@@ -110,3 +113,4 @@ expect(returnedValue).toEqual(0);

contextAri,
key: 'testKey'
key: 'testKey',
encrypted: false
});

@@ -146,2 +150,21 @@ expect(returnedValue).toEqual('');

});
describe('get secret', () => {
it('should call the storage API, passing the provided key and returning the stored value', async () => {
const apiClientMock = getApiClientMock({
data: {
appStoredEntity: {
value: 'testValue'
}
}
});
const globalStorage = getStorage(apiClientMock);
const returnedValue = await globalStorage.getSecret('testKey');
verifyApiClientCalledWith(apiClientMock, {
contextAri,
key: 'testKey',
encrypted: true
});
expect(returnedValue).toEqual('testValue');
});
});
describe('set', () => {

@@ -164,3 +187,4 @@ it('should call the storage API, passing the provided key and value', async () => {

key: 'testKey',
value: 'testValue'
value: 'testValue',
encrypted: false
}

@@ -208,3 +232,4 @@ });

key: 'testKey',
value: 'testValue'
value: 'testValue',
encrypted: false
}

@@ -214,2 +239,25 @@ });

});
describe('set secret', () => {
it('should call the storage API, passing the provided key and value', async () => {
const apiClientMock = getApiClientMock({
data: {
appStorage: {
setAppStoredEntity: {
success: true
}
}
}
});
const globalStorage = getStorage(apiClientMock);
await globalStorage.setSecret('testKey', 'testValue');
verifyApiClientCalledWith(apiClientMock, {
input: {
contextAri,
key: 'testKey',
value: 'testValue',
encrypted: true
}
});
});
});
describe('delete', () => {

@@ -231,3 +279,4 @@ it('should call the storage API, passing the provided key', async () => {

contextAri,
key: 'testKey'
key: 'testKey',
encrypted: false
}

@@ -260,2 +309,24 @@ });

});
describe('delete secret', () => {
it('should call the storage API, passing the provided key', async () => {
const apiClientMock = getApiClientMock({
data: {
appStorage: {
deleteAppStoredEntity: {
success: true
}
}
}
});
const globalStorage = getStorage(apiClientMock);
await globalStorage.deleteSecret('testKey');
verifyApiClientCalledWith(apiClientMock, {
input: {
contextAri,
key: 'testKey',
encrypted: true
}
});
});
});
describe('list', () => {

@@ -262,0 +333,0 @@ it('should call the storage API with the provided parameters', async () => {

@@ -18,5 +18,9 @@ import { FetchMethod } from './index';

get(key: string): Promise<any>;
getSecret(key: string): Promise<any>;
list(options: ListOptions): Promise<ListResults>;
set(key: string, value: any): Promise<void>;
setSecret(key: string, value: any): Promise<void>;
delete(key: string): Promise<void>;
deleteSecret(key: string): Promise<void>;
private getInternal;
private buildRequest;

@@ -23,0 +27,0 @@ private query;

24

out/global-storage.js

@@ -37,6 +37,7 @@ "use strict";

async get(key) {
const requestBody = queries_1.getQuery(this.doGetAppContextAri(), key);
const { appStoredEntity: { value } } = await this.query(requestBody);
return value !== null && value !== void 0 ? value : undefined;
return this.getInternal(key, false);
}
async getSecret(key) {
return this.getInternal(key, true);
}
async list(options) {

@@ -58,9 +59,22 @@ const requestBody = process.env.IS_CLEANUP_FUNCTION === 'true'

async set(key, value) {
const requestBody = queries_1.setQuery(this.doGetAppContextAri(), key, value);
const requestBody = queries_1.setQuery(this.doGetAppContextAri(), key, value, false);
await this.mutation(requestBody, 'setAppStoredEntity');
}
async setSecret(key, value) {
const requestBody = queries_1.setQuery(this.doGetAppContextAri(), key, value, true);
await this.mutation(requestBody, 'setAppStoredEntity');
}
async delete(key) {
const requestBody = queries_1.deleteQuery(this.doGetAppContextAri(), key);
const requestBody = queries_1.deleteQuery(this.doGetAppContextAri(), key, false);
await this.mutation(requestBody, 'deleteAppStoredEntity');
}
async deleteSecret(key) {
const requestBody = queries_1.deleteQuery(this.doGetAppContextAri(), key, true);
await this.mutation(requestBody, 'deleteAppStoredEntity');
}
async getInternal(key, encrypted) {
const requestBody = queries_1.getQuery(this.doGetAppContextAri(), key, encrypted);
const { appStoredEntity: { value } } = await this.query(requestBody);
return value !== null && value !== void 0 ? value : undefined;
}
buildRequest(requestBody) {

@@ -67,0 +81,0 @@ return {

@@ -10,2 +10,5 @@ import { RequestInit, Response } from 'node-fetch';

delete: (key: string) => Promise<void>;
getSecret: (key: string) => Promise<any>;
setSecret: (key: string, value: any) => Promise<void>;
deleteSecret: (key: string) => Promise<void>;
query: () => DefaultQueryBuilder;

@@ -12,0 +15,0 @@ };

@@ -10,2 +10,5 @@ "use strict";

delete: adapter.delete.bind(adapter),
getSecret: adapter.getSecret.bind(adapter),
setSecret: adapter.setSecret.bind(adapter),
deleteSecret: adapter.deleteSecret.bind(adapter),
query: () => new query_api_1.DefaultQueryBuilder(adapter)

@@ -12,0 +15,0 @@ };

@@ -1,2 +0,2 @@

export declare const getQuery: (contextAri: string, key: string) => {
export declare const getQuery: (contextAri: string, key: string, encrypted: boolean) => {
query: string;

@@ -6,2 +6,3 @@ variables: {

key: string;
encrypted: boolean;
};

@@ -37,3 +38,3 @@ };

};
export declare const setQuery: (contextAri: string, key: string, value: any) => {
export declare const setQuery: (contextAri: string, key: string, value: any, encrypted: boolean) => {
query: string;

@@ -45,6 +46,7 @@ variables: {

value: any;
encrypted: boolean;
};
};
};
export declare const deleteQuery: (contextAri: string, key: string) => {
export declare const deleteQuery: (contextAri: string, key: string, encrypted: boolean) => {
query: string;

@@ -55,2 +57,3 @@ variables: {

key: string;
encrypted: boolean;
};

@@ -57,0 +60,0 @@ };

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.deleteQuery = exports.setQuery = exports.listQueryForCleanup = exports.listQuery = exports.getQuery = void 0;
exports.getQuery = (contextAri, key) => ({
exports.getQuery = (contextAri, key, encrypted) => ({
query: `
query Get($contextAri: ID!, $key: ID!) {
appStoredEntity(contextAri: $contextAri, key: $key) {
query forge_app_getApplicationStorageEntity($contextAri: ID!, $key: ID!, $encrypted: Boolean!) {
appStoredEntity(contextAri: $contextAri, key: $key, encrypted: $encrypted) {
key

@@ -15,3 +15,4 @@ value

contextAri,
key
key,
encrypted
}

@@ -23,3 +24,3 @@ });

query: `
query List($contextAri: ID!, $where: [AppStoredEntityFilter!], $cursor: String, $limit: Int) {
query forge_app_getApplicationStorageEntities($contextAri: ID!, $where: [AppStoredEntityFilter!], $cursor: String, $limit: Int) {
appStoredEntities(contextAri: $contextAri, where: $where, after: $cursor, first: $limit) {

@@ -49,3 +50,3 @@ edges {

query: `
query List($contextAri: ID!, $where: [AppStoredEntityFilter!], $cursor: String, $limit: Int) {
query forge_app_getApplicationStorageEntitiesForCleanup($contextAri: ID!, $where: [AppStoredEntityFilter!], $cursor: String, $limit: Int) {
appStoredEntitiesForCleanup(contextAri: $contextAri, where: $where, after: $cursor, first: $limit) {

@@ -71,5 +72,5 @@ edges {

};
exports.setQuery = (contextAri, key, value) => ({
exports.setQuery = (contextAri, key, value, encrypted) => ({
query: `
mutation Set($input: SetAppStoredEntityMutationInput!) {
mutation forge_app_setApplicationStorageEntity($input: SetAppStoredEntityMutationInput!) {
appStorage{

@@ -93,9 +94,10 @@ setAppStoredEntity(input: $input) {

key,
value
value,
encrypted
}
}
});
exports.deleteQuery = (contextAri, key) => ({
exports.deleteQuery = (contextAri, key, encrypted) => ({
query: `
mutation Delete($input: DeleteAppStoredEntityMutationInput!) {
mutation forge_app_deleteApplicationStorageEntity($input: DeleteAppStoredEntityMutationInput!) {
appStorage {

@@ -118,5 +120,6 @@ deleteAppStoredEntity(input: $input) {

contextAri,
key
key,
encrypted
}
}
});

@@ -5,2 +5,5 @@ export interface StorageAdapter {

delete(key: string): Promise<void>;
getSecret(key: string): Promise<any>;
setSecret(key: string, value: any): Promise<void>;
deleteSecret(key: string): Promise<void>;
}

@@ -7,0 +10,0 @@ export interface QueryApi {

{
"name": "@forge/storage",
"version": "0.0.0-experimental-819498d",
"version": "0.0.0-experimental-d18f8dd",
"description": "Forge Storage methods",

@@ -5,0 +5,0 @@ "author": "Atlassian",

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

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