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

@forge/api

Package Overview
Dependencies
Maintainers
14
Versions
360
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@forge/api - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

2

out/index.d.ts
import { RequestInit, Response } from 'node-fetch';
export declare type APIResponse = Pick<Response, 'json' | 'text' | 'ok' | 'status' | 'statusText'>;
export declare type APIResponse = Pick<Response, 'json' | 'text' | 'arrayBuffer' | 'ok' | 'status' | 'statusText'>;
export declare type FetchMethod = (url: string, init?: RequestInit) => Promise<APIResponse>;

@@ -4,0 +4,0 @@ export interface FetchMethods {

{
"name": "@forge/api",
"version": "0.1.0",
"version": "0.1.1",
"description": "Forge API methods",

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

@@ -1,91 +0,24 @@

# Forge API methods
# Forge API
API methods exposed during runtime in `Forge` apps. These include methods to simplify common actions such as making
API methods exposed during runtime in Forge apps. These include methods to simplify common actions such as making
REST requests to Atlassian products.
See [developer.atlassian.com/platform/forge/](https://developer.atlassian.com/platform/forge) for documentation and tutorials
explaining Forge.
## Requirements
See [Set up Forge](https://developer.atlassian.com/platform/forge/set-up-forge/) for details of the software required to develop Forge apps.
## Usage
In your `Forge` app, include the following:
```
import API from '@forge/api';
```
In your Forge app, include the following:
## Methods
The API exposes the following methods:
### fetch
Fetches data from an HTTP server.
#### Signature:
```
fetch(url: string, options?: any) => Promise<object>
```
### requestJira
import api from '@forge/api';
Makes a request to the Jira REST API.
#### Signature:
```
requestJira(url: string, options?: any) => Promise<object>
```
### requestConfluence
See [Runtime API reference](https://developer.atlassian.com/platform/forge/runtime-api-reference/) for details of the methods available and how to use them.
Makes a request to the Confluence REST API.
#### Signature:
```
requestConfluence(url: string, options?: any) => Promise<object>
```
### asApp
Use this method to call an Atlassian API as the app developer. The method adds an `Authorization` header for the app
developer to a chained fetch call.
#### Signature
```
asApp() => { requestJira: Fetch, requestConfluence: Fetch }
```
### asUser
Use this method to call an Atlassian API as the person using the app. The method adds an `Authorization` header for the
request user to a chained `requestJira` or `requestConfluence` call.
If the user initiating the request has not granted permission to any sites, or the request is not made through a user
interaction (such as, using a trigger) the request is made without a valid Authorization header.
If the API returns a `401` and there is not a valid `Authorization` header, then an `Error` is thrown.
* If this error is left uncaught, the user is prompted to grant access to the app.
* If the user grants access, the app is re-initialized.
#### Signature
```
asUser() => { requestJira: Fetch, requestConfluence: Fetch }
```
## Example
Make an authenticated call to the Jira myself API as the user of the app.
```
const getUserDisplayName = async (): Promise<string> => {
// See https://developer.atlassian.com/cloud/jira/platform/rest/v3/#api-rest-api-3-myself-get
const response = API
.asUser()
.requestJira(`/rest/api/3/myself`);
const json = await response.json();
return json.displayName;
};
```
## Support
See [Get help](https://developer.atlassian.com/platform/forge/get-help/) for how to get help and provide feedback.

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