@byterm/agc-sdk
v0.2.0
Published
AppGallery Connect API SDK for Node.js (Service Account auth)
Maintainers
Readme
@byterm/agc-sdk
A typed Node.js + TypeScript client for the AppGallery Connect (AGC) API,
using Service Account authentication. Part of the
agc-ts monorepo — see also
@byterm/agc-cli for the
command-line tool.
Requirements
- Node.js >= 18 (uses the built-in
fetchand WebCrypto)
Install
npm i @byterm/agc-sdkAuthentication (Service Account only)
- In AGC → Users and permissions → API key → Connect API → Service Account,
create a developer-level Service Account and download the
*.private.jsoncredential file. - Pass that file to
AgcClient.fromFile(...).
The SDK signs a PS256 JWT (RSASSA-PSS, SHA-256) from key_id,
sub_account and private_key, and sends it directly as
Authorization: Bearer <jwt>. Tokens are cached and refreshed automatically
(1 h lifetime, refreshed ~5 min early). There is no separate token-exchange
step for Service Account auth.
Keep the credential file secret — never commit it.
Usage
import { AgcClient } from '@byterm/agc-sdk';
const agc = AgcClient.fromFile('./my-key.private.json', { site: 'CN' });
const res = await agc.publishing.getAppInfo({ appId: '1234567890', lang: 'zh-CN' });
console.log(res.appInfo?.versionNumber);
// Upload a package and bind it
const { objectId } = await agc.upload.uploadFile({ appId: '1234567890', filePath: './app.app' });
await agc.publishing.updatePackageInfo('1234567890', { fileName: 'app.app', objectId });
await agc.publishing.submitPublish({ appId: '1234567890' });Errors are typed: AgcCredentialsError, AgcHttpError (transport/non-2xx),
AgcApiError (2xx with non-zero ret.code). The client automatically checks
the ret envelope and throws AgcApiError on business failures.
Resource coverage
agc.publishing, agc.provisioning, agc.testing, agc.reports,
agc.upload, agc.domain — covering the Publishing, Provisioning, Testing,
Reports, Upload Management and Domain Management API groups. Method names map
1:1 to AGC endpoints. For anything not yet wrapped, drop to the raw client:
agc.http.get(...) / .post(...) etc., which still applies auth and the
ret check.
Region sites
| Site | Domain |
| --- | --- |
| CN | connect-api.cloud.huawei.com |
| DE | connect-api-dre.cloud.huawei.com |
| SG | connect-api-dra.cloud.huawei.com |
| RU | connect-api-drru.cloud.huawei.com |
The site must match the project's configured data-processing location.
License
MIT © Term
