Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
node-apple-vpp
Advanced tools
Readme
This module servers as a NodeJS wrapper around Apple's VPP API. This can be useful when building an MDM server, or anywhere you would like to monitor VPP accounts.
npm install node-apple-vpp
All methods return a Promise, except for the constructor
options
An object containing the some of the keys belowlet options = {
stoken_path: '/path/to/token.vpptoken', //REQUIRED: Path to VPP Token File
country_code: 'au' // Used for content metadata lookups
}
Used to request the vpp service config. Required to be used before all other methods. The apple VPP API specification states that the service config should be redownloaded every 5 minutes. This module leaves that up to you to implement. An example is given below:
let vpp = new NodeAppleVPP({ stoken_path: 'test.vpptoken'});
vpp.init().then(() => {
// Do VPP Logic Here
});
setInterval(vpp.init(), 300000)
Retrieves a batch of licenses from VPP. Has assignedOnly set to true to avoid downloading excessive amounts of licenses.
batchToken
The batchToken returned from a previous requestsinceModifiedToken
The sinceModifiedToken from a previous requestReturns:
{
status: 0,
licenses: [
{
adamId:645859810,
adamIdStr:"645859810",
isIrrevocable:false,
licenseId:967494668,
licenseIdStr:"967494668",
pricingParam:"STDQ",
productTypeId:8,
productTypeName:"Application",
serialNumber:"C39N3035G68P",
status:"Associated"
}
],
totalCount: 1,
totalBatchCount: 1,
sinceModifiedToken: "YzA7OSc0pTUoNSSzKLUFJAyQ6CSWgCS88JnkgAAAA=="
}
Retrieves a listing of assets from VPP. has licenseCounts set to true.
Returns:
{
status: 0,
assets: [
{
adamIdStr:"375380948",
assignedCount:2,
availableCount:8,
deviceAssignable:true,
isIrrevocable:false,
pricingParam:"STDQ",
productTypeId:8,
productTypeName:"Application",
retiredCount:0,
totalCount:10
}
],
totalCount: 1
}
Associates a given asset to a given array of serial numbers
asset
A required object detailing the asset to assign licenses forlet asset = {
adamIdStr: "375380948",
pricingParam: "STDQ"
}
serialNumbers
An array containing serial numbers to assign the asset tolet serialNumbers = ["C39N3035G68P"]
Returns:
{
status: 0,
adamIdStr: "375380948",
pricingParam: "STDQ",
productTypeId:8,
productTypeName:"Application",
associations: [
{
"serialNumber":"C39N3035G68P",
"licenseIdStr":"4"
}
]
}
Revokes a given asset from an array of serials
asset
A required object detailing the asset to revoke licenses forlet asset = {
adamIdStr: "375380948",
pricingParam: "STDQ"
}
serialNumbers
An array containing serial numbers to revoke the asset fromlet serialNumbers = ["C39N3035G68P"]
Returns:
{
status: 0,
adamIdStr: "375380948",
pricingParam: "STDQ",
productTypeId:8,
productTypeName:"Application",
disassociations: [
{
"serialNumber":"C39N3035G68P",
"licenseIdStr":"4"
}
]
}
Revokes given asset for devices/users by a given array of licenseIds
asset
A required object detailing the asset to revoke licenses forlet asset = {
adamIdStr: "375380948",
pricingParam: "STDQ"
}
licenseIds
An array containing license ids to revoke the asset fromlet licenseIds = ["4"]
Returns:
{
status: 0,
adamIdStr: "375380948",
pricingParam: "STDQ",
productTypeId:8,
productTypeName:"Application",
disassociations: [
{
"serialNumber":"C39N3035G68P",
"licenseIdStr":"4"
}
]
}
A common problem is how to download all the licenses for a given account, as the VPP API requires batch requests for large license numbers. The code below will execute the saving mechanism before it starts the next round of downloads.
let NodeVPP = require('./src/lib/vpp');
let asyncEach = require('async/each');
let vpp = new NodeVPP({
stoken_path: 'test.vpptoken',
country_code: 'au'
});
return vpp.init().then(()=>{
updateLicenseInStorage().then((sinceModifiedToken) => {
console.log('License Download Completed!');
});
});
function updateLicensesInStorage(startingToken){
function callLicenseApi(batchToken, sinceModifiedToken){
let roundResponse = {};
return vpp.getLicenseBatch(batchToken, sinceModifiedToken)
.then(response => {
roundResponse = response;
return response.licenses;
})
.then(updateLicenses)
.then(() => {
if('batchToken' in roundResponse){
console.log('Got Batch Token');
return callLicenseApi(roundResponse.batchToken);
} else {
console.log('All Licenses Received, returning sinceModifiedToken');
return roundResponse.sinceModifiedToken;
}
})
}
function updateLicenses(licenses){
return new Promise((resolve, reject) => {
console.log('Beginning license import for round');
asyncEach(licenses, (license, cb) => {
// Do something with the license here
console.log(`Got license: $(license.licenceIdStr)`);
}, (err) => {
console.log('Finished Round Import');
if(err){
return reject(err)
} else {
return resolve()
}
})
})
}
return callLicenseApi(null, startingToken);
}
To test run npm test
FAQs
A NodeJS Apple VPP API Client
The npm package node-apple-vpp receives a total of 0 weekly downloads. As such, node-apple-vpp popularity was classified as not popular.
We found that node-apple-vpp demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.