Giter Site home page Giter Site logo

socketdev / socket-sdk-js Goto Github PK

View Code? Open in Web Editor NEW
23.0 10.0 6.0 2.12 MB

Socket SDK for JavaScript / TypeScript

Home Page: https://socket.dev/npm/package/@socketsecurity/sdk

License: MIT License

JavaScript 99.63% Shell 0.37%
api javascript sdk security socket typescript

socket-sdk-js's Introduction

@socketsecurity/sdk

Socket Badge npm version TypeScript types js-standard-style Follow @SocketSecurity

SDK for the Socket API client, generated by api.

Usage

npm install @socketsecurity/sdk

ESM / TypeScript

import { SocketSdk } from '@socketsecurity/sdk'

const client = new SocketSdk('yourApiKeyHere')

const res = await client.getQuota()

if (res.success) {
  // Will output { quota: 123 } if the quota you have left is 123
  console.log(res.data)
}

CommonJS

const { SocketSdk } = require('@socketsecurity/sdk')

SocketSdk Methods

Package methods

  • getIssuesByNPMPackage(packageName, version)
    • packageName: A string representing the name of the npm package you want the issues for
    • version: A string representing the version of the npm package to return the issues for
  • getScoreByNPMPackage(packageName, version)
    • packageName: A string representing the name of the npm package you want the score for
    • version: A string representing the version of the npm package to return the score for

Report methods

  • createReportFromFilePaths(filePaths, pathsRelativeTo=., [issueRules])
    • filePaths: An array of absolute or relative string paths to package.json and any corresponding package-lock.json files
    • pathsRelativeTo: A string path that the absolute paths filePaths are relative to. This to calculate where in your project the package.json/package-lock.json files lives
    • issueRules: An object that follows the format of the socket.yml issue rules. Keys being issue names, values being a boolean that activates or deactivates it. Is applied on top of default config and organization config.
  • getReportList()
  • getReportSupportedFiles()
  • getReport(id)
    • id: A string representing the id of a created report

Utility methods

  • getQuota()
  • getOrganizations()
  • postSettings(selectors)
    • selectors: An array of settings selectors, e.g. [{ organization: 'id' }]

Additional exports

  • createUserAgentFromPkgJson(pkgJson)
    • pkgJson: The content of the package.json you want to create a User-Agent string for

Advanced

Specifying custom user agent

The SocketSdk constructor accepts an options object as its second argument and there a userAgent key with a string value can be specified. If specified then that user agent will be prepended to the SDK user agent. See this example:

const client = new SocketSdk('yourApiKeyHere', {
  userAgent: 'example/1.2.3 (http://example.com/)'
})

Which results in the HTTP User-Agent header:

User-Agent: example/1.2.3 (http://example.com/) socketsecurity-sdk/0.5.2 (https://github.com/SocketDev/socket-sdk-js)

To easily create a user agent for your code you can use the additional export createUserAgentFromPkgJson() like this, assuming pkgJson contains your parsed package.json:

const client = new SocketSdk('yourApiKeyHere', {
  userAgent: createUserAgentFromPkgJson(pkgJson)
})

Specifying a custom user agent is good practice when shipping a piece of code that others can use to make requests. Eg. our CLI uses this option to identify requests coming from it + mentioning which version of it that is used.

See also

socket-sdk-js's People

Contributors

101arrowz avatar bcomnes avatar bmeck avatar charliegerard avatar dependabot[bot] avatar feross avatar github-actions[bot] avatar raynos avatar voxpelli avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

socket-sdk-js's Issues

## Explanation

Explanation

Migrating the Icon component to TypeScript following the TS enum conventions in notion

  • Migrated all .js to .tsx or .ts files
  • Updated ICON_NAMES => IconName as well as keys from UPPERCASE to PascalCase
  • Updated ICON_SIZES => IconSize as well as keys from UPPERCASE to PascalCase
  • Removed generateIconNames script which automatically generated the ICON_NAME object and stored it as json in an environment variable in favour of a static enum. This adds some manual overhead which can be eventually automated. But with the number of icon updates it's not required and can be an improvement made in another PR.
  • Updated storybook documentation as well as how to add a new icon
  • Fixes #18326

Screenshots/Screencaps

Before

before.mov

After

after.mov

Test coverage 💯

Screenshot 2023-03-25 at 10 04 44 AM

How I searched for icon names

To ensure I caught all old casing of icon names below are the searches I did in vs code

Screenshot 2023-03-24 at 5 03 44 PM
Screenshot 2023-03-24 at 5 04 09 PM

I also did a search for uppercase names IconName.UPPERCASE using this regex ^IconName\.(?=[A-Z0-9]{2,})[A-Z0-9_]+$

Screenshot 2023-03-24 at 6 14 06 PM

It wasn't that robust so I also went through alphabetically e.g. IconName.A, IconName.B IconName.C etc and checked the results for any ones I missed.

Manual Testing Steps

Pre-merge author checklist

  • I've clearly explained:
    • What problem this PR is solving
    • How this problem was solved
    • How reviewers can test my changes
  • Sufficient automated test coverage has been added

Pre-merge reviewer checklist

  • Manual testing (e.g. pull and build branch, run in browser, test code being changed)
  • PR is linked to the appropriate GitHub issue
  • IF this PR fixes a bug in the release milestone, add this PR to the release milestone

If further QA is required (e.g. new feature, complex testing steps, large refactor), add the Extension QA Board label.

In this case, a QA Engineer approval will be be required.

Originally posted by @georgewrmarshall in MetaMask/metamask-extension#18330

Convert to CommonJS

Since I copied the new SDK from the upcoming CLI it became ESM, but for compatibility’s sake we should make it CJS

Wrongly reported dependency changes in GitHub app

Hey there, I hope this issue is in the correct place. Happy to report it in a different place, let me know where.

I have recently found more and more comments by the GitHub App that claim a dependency has been removed in a pure dependency upgrade PR.

There are plenty of examples in the xmldom repo

but the most recent on is here:
xmldom/xmldom#521 (comment)

All of these are really bumping a dependency version, not dropping it.

I'm currently assuming this also relates to issues where already approved issues have to be approved again, but I don't have an example I can share of that right now. (And maybe this is a separate issue? But I think it makes sense to first solve this one.)

pull issue resolever

Please confirm these before moving forward

  • I have searched for my issue and not found a work-in-progress/duplicate/resolved issue.
  • I have not been informed if the issue is resolved in a preview version of the winget client.

Category of the issue

Installation issue.

Brief description of your issue

download url issue

winget install -e --id Apple.iTunes Trouvé iTunes [Apple.iTunes] Version 12.12.7.1 La licence d’utilisation de cette application vous est octroyée par son propriétaire. Microsoft n’est pas responsable des paquets tiers et n’accorde pas de licences à ceux-ci. Téléchargement en cours https://secure-appldnld.apple.com/itunes12/032-11199-20221212-7680817F-9CEC-4DD3-9191-8D0C20E8A548/iTunes64Setup.exe Une erreur inattendue s'est produite lors de l'exécution de la commande : InternetOpenUrl() failed. 0x80072efd : unknown error

Steps to reproduce

winget install -e --id Apple.iTunes

Actual behavior

download url issue

Expected behavior

correct download and install

Environment

winget --info
Gestionnaire de package Windows v1.4.10173
Copyright (c) Microsoft Corporation. Tous droits réservés.

Windows: Windows.Desktop v10.0.22621.1105
Architecture du système : X64
Package : Microsoft.DesktopAppInstaller v1.19.10173.0

Journaux : %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\DiagOutputDir

Paramètres utilisateur : %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json

Liens
---------------------------------------------------------------------------------------------
Déclaration de confidentialité        https://aka.ms/winget-privacy
Contrat de licence                    https://aka.ms/winget-license
Avis de tiers                         https://aka.ms/winget-3rdPartyNotice
Page d’accueil                        https://aka.ms/winget
Conditions générales du Windows Store https://www.microsoft.com/en-us/storedocs/terms-of-sale

Stratégie de groupe                                                                 État
------------------------------------------------------------------------------------------
Activer les paramètres du Gestionnaire de package Windows                           Activé
Activer la source Microsoft Store du Programme d’installation d’application Windows Activé

Screenshots and Logs

image

Originally posted by @tvanparys in microsoft/winget-pkgs#97614

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.