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

Forge Storage methods

  • 0.0.2
  • npm
  • Socket score

Version published
Weekly downloads
7.6K
decreased by-49%
Maintainers
8
Weekly downloads
 
Created
Source

Common library for both Forge environment and Harmonised Connect app environment.

Usage example:

// https://hello.atlassian.net/wiki/spaces/ECO/pages/955640295/Explore+-+Making+a+Hosted+storage+call+from+a+Harmonised+app

import fetch, { RequestInit } from 'node-fetch';

import { GlobalStorage } from './global-storage';
import { APIResponse, getStorageInstanceWithQuery } from './index';

const API_BASE = 'https://api.atlassian.com';

// For user agent header
const version = '0.0.1';
const appAri = 'ari:cloud:ecosystem::app/7746820b-fbb0-48d1-a251-7b802ba1aab8';

// For Storage service auth
const appContextAri = 'ari:cloud:jira::site/dd7fa939-ad77-48c9-894f-bd7da936d769';
const token =
  'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6Ik16bERNemsxTVRoRlFVRTJRa0ZGT0VGRk9URkJOREJDTVRRek5EZzJSRVpDT1VKRFJrVXdNZyJ9.eyJodHRwczovL2F0bGFzc2lhbi5jb20vc3lzdGVtQWNjb3VudElkIjoiNWZkMDAyZjFmZWU3OTMwMDc1MTRiODFjIiwiaHR0cHM6Ly9hdGxhc3NpYW4uY29tL3N5c3RlbUFjY291bnRFbWFpbCI6IjQ1ZWM2ODE4LWNjNmQtNGI5OC1iOWU4LWZlODI1NDIwZmQ0MUBjb25uZWN0LmF0bGFzc2lhbi5jb20iLCJodHRwczovL2F0bGFzc2lhbi5jb20vZmlyc3RQYXJ0eSI6ZmFsc2UsImh0dHBzOi8vYXRsYXNzaWFuLmNvbS8zbG8iOmZhbHNlLCJpc3MiOiJodHRwczovL2F0bGFzc2lhbi1hY2NvdW50LXByb2QucHVzMi5hdXRo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v3b1bcd2taJtfNrsZvIzw7UQ5n9VA0xIiAouoFCb7h4JHB4ROL2CkaN8MPA68wn0xSCDPim24hR2mFVw42dZayG19rmoWJ3Uzi3_sJw7yOXxpmDO1x5_7DG9Mgr58gN2fuDZ9XfMDO0LWjxcjBSUDKTZkZVe-fv4p0kNDBrwwkijVQWewr3G64LP9nD85TdEFaVxMdEo-eRlaMhNOmvVkkn_9LtzTJD85n_a3MWwAjtLbbBPwNfghzOi_7T6yH7FAa3oOog1IipdmApbFWPPuWIQ';

async function apiClient(path: string, init: RequestInit): Promise<APIResponse> {
  const url = API_BASE + path;

  const extraHeaders = {
    // See add-forge-user-agent.ts
    'User-Agent': `H11n/${version} ${appAri}`,
    'X-Forge-Context': appContextAri,

    Authorization: `Bearer ${token}`

    // Only required when accessing Storage service via the GraphQL gateway
    // https://api.atlassian.com/graphql
    // 'X-ExperimentalApi': 'AppEntityStorage'
  };

  init.headers = Object.assign(init.headers!, extraHeaders);
  return fetch(url, init);
}

const adapter = new GlobalStorage(() => appContextAri, apiClient);
const storage = getStorageInstanceWithQuery(adapter);

async function demo() {
  await storage.set('key', 'vvv');
  console.log(await storage.get('key'));
  await storage.delete('key');
}

demo();

FAQs

Package last updated on 01 Feb 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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