Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
@sp-api-sdk/auth
Advanced tools
@sp-api-sdk/auth
Amazon Selling Partner API authentication helper class
yarn add @sp-api-sdk/auth
npm install @sp-api-sdk/auth
This library supports both authentication models: IAM user credentials, or an IAM role (using STS AssumeRole).
import {SellingPartnerApiAuth} from '@sp-api-sdk/auth'
const auth = new SellingPartnerApiAuth({
clientId: '',
clientSecret: '',
refreshToken: 'Atzr|...',
accessKeyId: '',
secretAccessKey: '',
sessionToken: '' // If you’re authenticated using temporary credentials
})
const accessToken = await auth.accessToken.get()
const {AccessKeyId, SecretAccessKey} = await auth.getCredentials()
import {SellingPartnerApiAuth} from '@sp-api-sdk/auth'
const auth = new SellingPartnerApiAuth({
clientId: '',
clientSecret: '',
refreshToken: 'Atzr|...',
accessKeyId: '',
secretAccessKey: '',
region: '', // You can provide an AWS region that will be used for the STS calls
role: {
arn: '',
sessionName: 'SellingPartnerAPI' // Optional
}
})
const accessToken = await auth.accessToken.get()
const {AccessKeyId, SecretAccessKey, SessionToken} = await auth.getCredentials()
getCredentials
will return a set of temporary security credentials that last for 1 hour.
These constructor options can be passed using environment variables:
Property Name | Environement variable |
---|---|
clientId | LWA_CLIENT_ID |
clientSecret | LWA_CLIENT_SECRET |
accessKeyId | AWS_ACCESS_KEY_ID |
secretAccessKey | AWS_SECRET_ACCESS_KEY |
sessionToken | AWS_SESSION_TOKEN |
region | AWS_DEFAULT_REGION |
role.arn | AWS_ROLE_ARN |
role.sessionName | AWS_ROLE_SESSION_NAME |
Some APIs require grantless authentication, which is done by passing scopes, instead of a refresh token.
The available scopes are exposed in the AuthorizationScope
enum from this library.
import {SellingPartnerApiAuth, AuthorizationScope} from '@sp-api-sdk/auth'
import {AuthorizationApiClient} from '@sp-api-sdk/authorization-api-v1'
const auth = new SellingPartnerApiAuth({
clientId: '',
clientSecret: '',
scopes: Object.values(AuthorizationScope), // Or choose the only ones you need
accessKeyId: '',
secretAccessKey: ''
})
const accessToken = await auth.accessToken.get()
const credentials = await auth.getCredentials()
accessToken.get()
caches the access token for its whole duration, it will only request a new token if the current one has expired.
The same goes for the STS temporary credentials returned by getCredentials
, the credentials are cached until they expire.
FAQs
Amazon Selling Partner API authentication package
The npm package @sp-api-sdk/auth receives a total of 135 weekly downloads. As such, @sp-api-sdk/auth popularity was classified as not popular.
We found that @sp-api-sdk/auth demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
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.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.