@gpc-cli/auth 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +67 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# @gpc-cli/auth
|
|
2
|
+
|
|
3
|
+
Authentication strategies for Google Play Developer API. Supports service accounts, OAuth 2.0, and Application Default Credentials.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @gpc-cli/auth
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import {
|
|
15
|
+
resolveAuth,
|
|
16
|
+
createServiceAccountAuth,
|
|
17
|
+
loadServiceAccountKey,
|
|
18
|
+
} from "@gpc-cli/auth";
|
|
19
|
+
|
|
20
|
+
// Auto-resolve from config
|
|
21
|
+
const auth = await resolveAuth({
|
|
22
|
+
serviceAccount: "./service-account.json",
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// Or create directly
|
|
26
|
+
const key = loadServiceAccountKey("./service-account.json");
|
|
27
|
+
const auth = createServiceAccountAuth(key);
|
|
28
|
+
|
|
29
|
+
// Use with @gpc-cli/api
|
|
30
|
+
import { createApiClient } from "@gpc-cli/api";
|
|
31
|
+
const client = createApiClient({ auth });
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Auth Methods
|
|
35
|
+
|
|
36
|
+
| Method | Best For | Config |
|
|
37
|
+
|--------|----------|--------|
|
|
38
|
+
| Service account | CI/CD, automation | `serviceAccount` path or JSON string |
|
|
39
|
+
| OAuth 2.0 | Local development | Interactive login flow |
|
|
40
|
+
| ADC | GCP-hosted runners | `GPC_USE_ADC=1` or `--adc` flag |
|
|
41
|
+
| Env var | Docker, ephemeral | `GPC_SERVICE_ACCOUNT` env var |
|
|
42
|
+
|
|
43
|
+
## API
|
|
44
|
+
|
|
45
|
+
### `resolveAuth(options)`
|
|
46
|
+
|
|
47
|
+
Resolves the auth strategy from config options. Tries service account, then ADC, then cached OAuth tokens.
|
|
48
|
+
|
|
49
|
+
### `loadServiceAccountKey(pathOrJson)`
|
|
50
|
+
|
|
51
|
+
Loads and validates a service account key from a file path or JSON string.
|
|
52
|
+
|
|
53
|
+
### `createServiceAccountAuth(key)`
|
|
54
|
+
|
|
55
|
+
Creates an auth client from a parsed service account key. Handles token generation and caching.
|
|
56
|
+
|
|
57
|
+
### `clearTokenCache()`
|
|
58
|
+
|
|
59
|
+
Clears all cached OAuth/service account tokens.
|
|
60
|
+
|
|
61
|
+
## Part of the GPC Monorepo
|
|
62
|
+
|
|
63
|
+
This is the auth layer for [GPC](https://github.com/yasserstudio/gpc). Use it standalone or with `@gpc-cli/api`.
|
|
64
|
+
|
|
65
|
+
## License
|
|
66
|
+
|
|
67
|
+
MIT
|