Socket
Socket
Sign inDemoInstall

@plasmohq/edge-addons-api

Package Overview
Dependencies
21
Maintainers
2
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.3.2 to 1.4.0

1

dist/index.d.ts

@@ -8,2 +8,3 @@ import { ReadStream } from 'fs';

accessTokenUrl: string;
uploadOnly?: boolean;
};

@@ -10,0 +11,0 @@ type OperationResponse = {

2

dist/index.js

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

import{createReadStream as m}from"fs";import n from"got";var h={productId:"Product ID is required. To get one, go to: https://partner.microsoft.com/en-us/dashboard/microsoftedge/{product-id}/package/dashboard",clientId:"Client ID is required. To get one: https://partner.microsoft.com/en-us/dashboard/microsoftedge/publishapi",clientSecret:"Client Secret is required. To get one: https://partner.microsoft.com/en-us/dashboard/microsoftedge/publishapi",accessTokenUrl:"Access token URL is required. To get one: https://partner.microsoft.com/en-us/dashboard/microsoftedge/publishapi"},T=Object.keys(h),f=a=>new Promise(t=>setTimeout(t,a)),u="https://api.addons.microsoftedge.microsoft.com",l=class{options={};constructor(t){for(let e of T)if(!t[e])throw new Error(h[e]);this.options={...t}}get productEndpoint(){return`${u}/v1/products/${this.options.productId}`}get publishEndpoint(){return`${this.productEndpoint}/submissions`}get uploadEndpoint(){return`${this.publishEndpoint}/draft/package`}async submit({filePath:t="",notes:e=""}){let o=await this.getAccessToken(),s=await this.upload(m(t),o);return await this.waitForUpload(s,o),this.publish(e,o)}async publish(t="",e=null){let s={headers:{Authorization:`Bearer ${e||await this.getAccessToken()}`,"Content-Type":"application/x-www-form-urlencoded"}};t.length>0&&(s.body=`{ "notes"="${t}" }`);let i=await n.post(this.publishEndpoint,s);return this.handleTempStatus(i.statusCode,"Submit"),i.headers.location}async upload(t=null,e=null){let o=e||await this.getAccessToken(),s=await n.post(this.uploadEndpoint,{body:t,headers:{Authorization:`Bearer ${o}`,"Content-Type":"application/zip"}});return this.handleTempStatus(s.statusCode,"Upload"),s.headers.location}async getPublishStatus(t,e=null){let o=e||await this.getAccessToken(),s=`${this.publishEndpoint}/operations/${t}`;return n.get(s,{headers:{Authorization:`Bearer ${o}`}}).json()}async waitForUpload(t,e=null,o=5,s=3e3){let i=e||await this.getAccessToken(),g=`${this.uploadEndpoint}/operations/${t}`,c,p,d=0;for(;p!=="Succeeded"&&d<o;){let r=await n.get(g,{headers:{Authorization:`Bearer ${i}`}}).json();if(r.status==="Failed")throw new Error(r.message||r.errorCode+":"+(r.errors||[]).join(","));r.status==="InProgress"?await f(s):r.status==="Succeeded"&&(c=r.message),p=r.status,d++}return c}handleTempStatus=(t,e)=>{if(t!==202)throw t>=500?new Error("Edge server error, please try again later"):new Error(`${e} failed, double check your api credentials`)};getAccessToken=async()=>(await n.post(`${this.options.accessTokenUrl}`,{body:`client_id=${this.options.clientId}&scope=${u}/.default&client_secret=${this.options.clientSecret}&grant_type=client_credentials`,headers:{"Content-Type":"application/x-www-form-urlencoded"}}).json()).access_token};export{l as EdgeAddonsAPI,h as errorMap,T as requiredFields};
import{createReadStream as m}from"fs";import r from"got";var h={productId:"Product ID is required. To get one, go to: https://partner.microsoft.com/en-us/dashboard/microsoftedge/{product-id}/package/dashboard",clientId:"Client ID is required. To get one: https://partner.microsoft.com/en-us/dashboard/microsoftedge/publishapi",clientSecret:"Client Secret is required. To get one: https://partner.microsoft.com/en-us/dashboard/microsoftedge/publishapi",accessTokenUrl:"Access token URL is required. To get one: https://partner.microsoft.com/en-us/dashboard/microsoftedge/publishapi"},f=Object.keys(h),T=a=>new Promise(t=>setTimeout(t,a)),u="https://api.addons.microsoftedge.microsoft.com",l=class{options={};constructor(t){for(let e of f)if(!t[e])throw new Error(h[e]);this.options={...t}}get productEndpoint(){return`${u}/v1/products/${this.options.productId}`}get publishEndpoint(){return`${this.productEndpoint}/submissions`}get uploadEndpoint(){return`${this.publishEndpoint}/draft/package`}async submit({filePath:t="",notes:e=""}){let o=await this.getAccessToken(),s=await this.upload(m(t),o);if(await this.waitForUpload(s,o),!this.options.uploadOnly)return this.publish(e,o)}async publish(t="",e=null){let s={headers:{Authorization:`Bearer ${e||await this.getAccessToken()}`,"Content-Type":"application/x-www-form-urlencoded"}};t.length>0&&(s.body=`{ "notes"="${t}" }`);let i=await r.post(this.publishEndpoint,s);return this.handleTempStatus(i.statusCode,"Submit"),i.headers.location}async upload(t=null,e=null){let o=e||await this.getAccessToken(),s=await r.post(this.uploadEndpoint,{body:t,headers:{Authorization:`Bearer ${o}`,"Content-Type":"application/zip"}});return this.handleTempStatus(s.statusCode,"Upload"),s.headers.location}async getPublishStatus(t,e=null){let o=e||await this.getAccessToken(),s=`${this.publishEndpoint}/operations/${t}`;return r.get(s,{headers:{Authorization:`Bearer ${o}`}}).json()}async waitForUpload(t,e=null,o=5,s=3e3){let i=e||await this.getAccessToken(),g=`${this.uploadEndpoint}/operations/${t}`,c,p,d=0;for(;p!=="Succeeded"&&d<o;){let n=await r.get(g,{headers:{Authorization:`Bearer ${i}`}}).json();if(n.status==="Failed")throw new Error(n.message||n.errorCode+":"+(n.errors||[]).join(","));n.status==="InProgress"?await T(s):n.status==="Succeeded"&&(c=n.message),p=n.status,d++}return c}handleTempStatus=(t,e)=>{if(t!==202)throw t>=500?new Error("Edge server error, please try again later"):new Error(`${e} failed, double check your api credentials`)};getAccessToken=async()=>(await r.post(`${this.options.accessTokenUrl}`,{body:`client_id=${this.options.clientId}&scope=${u}/.default&client_secret=${this.options.clientSecret}&grant_type=client_credentials`,headers:{"Content-Type":"application/x-www-form-urlencoded"}}).json()).access_token};export{l as EdgeAddonsAPI,h as errorMap,f as requiredFields};
{
"name": "@plasmohq/edge-addons-api",
"version": "1.3.2",
"version": "1.4.0",
"description": "Microsoft Edge Addons API for Node.js",

@@ -5,0 +5,0 @@ "exports": "./dist/index.js",

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc