@onesub/cli 0.1.15 → 0.1.16
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/dist/index.js +70 -70
- package/package.json +3 -3
- package/templates/_gitignore +7 -7
package/dist/index.js
CHANGED
|
@@ -14,35 +14,35 @@ import { fileURLToPath } from 'node:url';
|
|
|
14
14
|
const here = dirname(fileURLToPath(import.meta.url));
|
|
15
15
|
// dist/index.js → packages/cli/templates
|
|
16
16
|
const TEMPLATES_DIR = resolve(here, '..', 'templates');
|
|
17
|
-
const HELP = `onesub — scaffold and run a receipt-validation server locally
|
|
18
|
-
|
|
19
|
-
Usage:
|
|
20
|
-
onesub init [directory] Create a new onesub project in <directory> (default: .)
|
|
21
|
-
onesub dev [--port N] Start a fully-mocked onesub server for local testing
|
|
22
|
-
onesub --help Show this help
|
|
23
|
-
|
|
24
|
-
── init ─────────────────────────────────────────────────────────────────
|
|
25
|
-
Creates server.ts, .env.example, package.json, docker-compose.yml, README.md,
|
|
26
|
-
tsconfig.json, .gitignore. After:
|
|
27
|
-
cd <directory> && cp .env.example .env && npm install && npm start
|
|
28
|
-
|
|
29
|
-
── dev ──────────────────────────────────────────────────────────────────
|
|
30
|
-
Zero-config server with mock Apple / Google providers + in-memory stores.
|
|
31
|
-
No credentials needed. Use for local testing, CI, or AI-driven flows:
|
|
32
|
-
POST /onesub/validate { platform, receipt, userId, productId }
|
|
33
|
-
POST /onesub/purchase/validate { ...same + type }
|
|
34
|
-
GET /onesub/status?userId=
|
|
35
|
-
GET /onesub/purchase/status?userId=
|
|
36
|
-
|
|
37
|
-
Receipt patterns (prefix match):
|
|
38
|
-
MOCK_VALID_* / any other string → valid
|
|
39
|
-
MOCK_REVOKED_* → revoked/refunded (422)
|
|
40
|
-
MOCK_EXPIRED_* → 72h expired (422)
|
|
41
|
-
MOCK_INVALID_* / MOCK_BAD_SIG_* → bad signature (422)
|
|
42
|
-
MOCK_NETWORK_ERROR_* → simulated upstream failure (500)
|
|
43
|
-
MOCK_SANDBOX_* → valid but short expiry
|
|
44
|
-
|
|
45
|
-
No persistence — restarting clears all purchases.
|
|
17
|
+
const HELP = `onesub — scaffold and run a receipt-validation server locally
|
|
18
|
+
|
|
19
|
+
Usage:
|
|
20
|
+
onesub init [directory] Create a new onesub project in <directory> (default: .)
|
|
21
|
+
onesub dev [--port N] Start a fully-mocked onesub server for local testing
|
|
22
|
+
onesub --help Show this help
|
|
23
|
+
|
|
24
|
+
── init ─────────────────────────────────────────────────────────────────
|
|
25
|
+
Creates server.ts, .env.example, package.json, docker-compose.yml, README.md,
|
|
26
|
+
tsconfig.json, .gitignore. After:
|
|
27
|
+
cd <directory> && cp .env.example .env && npm install && npm start
|
|
28
|
+
|
|
29
|
+
── dev ──────────────────────────────────────────────────────────────────
|
|
30
|
+
Zero-config server with mock Apple / Google providers + in-memory stores.
|
|
31
|
+
No credentials needed. Use for local testing, CI, or AI-driven flows:
|
|
32
|
+
POST /onesub/validate { platform, receipt, userId, productId }
|
|
33
|
+
POST /onesub/purchase/validate { ...same + type }
|
|
34
|
+
GET /onesub/status?userId=
|
|
35
|
+
GET /onesub/purchase/status?userId=
|
|
36
|
+
|
|
37
|
+
Receipt patterns (prefix match):
|
|
38
|
+
MOCK_VALID_* / any other string → valid
|
|
39
|
+
MOCK_REVOKED_* → revoked/refunded (422)
|
|
40
|
+
MOCK_EXPIRED_* → 72h expired (422)
|
|
41
|
+
MOCK_INVALID_* / MOCK_BAD_SIG_* → bad signature (422)
|
|
42
|
+
MOCK_NETWORK_ERROR_* → simulated upstream failure (500)
|
|
43
|
+
MOCK_SANDBOX_* → valid but short expiry
|
|
44
|
+
|
|
45
|
+
No persistence — restarting clears all purchases.
|
|
46
46
|
`;
|
|
47
47
|
function parseArgs(argv) {
|
|
48
48
|
const args = argv.slice(2);
|
|
@@ -97,19 +97,19 @@ async function init(target) {
|
|
|
97
97
|
for (const f of files) {
|
|
98
98
|
await copyTemplate(f.src, dir, f.dst);
|
|
99
99
|
}
|
|
100
|
-
console.log(`
|
|
101
|
-
Done. Next steps:
|
|
102
|
-
|
|
103
|
-
cd ${target === '.' ? '.' : target}
|
|
104
|
-
cp .env.example .env # fill in Apple / Google credentials
|
|
105
|
-
npm install
|
|
106
|
-
npm run dev # http://localhost:4100
|
|
107
|
-
|
|
108
|
-
Or with Docker (Postgres + server):
|
|
109
|
-
|
|
110
|
-
docker compose up
|
|
111
|
-
|
|
112
|
-
Docs: https://github.com/jeonghwanko/onesub
|
|
100
|
+
console.log(`
|
|
101
|
+
Done. Next steps:
|
|
102
|
+
|
|
103
|
+
cd ${target === '.' ? '.' : target}
|
|
104
|
+
cp .env.example .env # fill in Apple / Google credentials
|
|
105
|
+
npm install
|
|
106
|
+
npm run dev # http://localhost:4100
|
|
107
|
+
|
|
108
|
+
Or with Docker (Postgres + server):
|
|
109
|
+
|
|
110
|
+
docker compose up
|
|
111
|
+
|
|
112
|
+
Docs: https://github.com/jeonghwanko/onesub
|
|
113
113
|
`);
|
|
114
114
|
}
|
|
115
115
|
async function dev(port) {
|
|
@@ -134,34 +134,34 @@ async function dev(port) {
|
|
|
134
134
|
// let anyone on the internet hit the mock admin routes with the well-known
|
|
135
135
|
// dev secret.
|
|
136
136
|
const server = app.listen(port, '127.0.0.1', () => {
|
|
137
|
-
console.log(`
|
|
138
|
-
onesub dev server — mocked Apple / Google providers
|
|
139
|
-
───────────────────────────────────────────────────
|
|
140
|
-
http://localhost:${port}/health
|
|
141
|
-
http://localhost:${port}/onesub/*
|
|
142
|
-
|
|
143
|
-
Try it:
|
|
144
|
-
|
|
145
|
-
# validate a mock subscription
|
|
146
|
-
curl -X POST http://localhost:${port}/onesub/validate \\
|
|
147
|
-
-H "Content-Type: application/json" \\
|
|
148
|
-
-d '{"platform":"apple","receipt":"MOCK_VALID_sub","userId":"u1","productId":"pro"}'
|
|
149
|
-
|
|
150
|
-
# validate a mock one-time purchase
|
|
151
|
-
curl -X POST http://localhost:${port}/onesub/purchase/validate \\
|
|
152
|
-
-H "Content-Type: application/json" \\
|
|
153
|
-
-d '{"platform":"google","receipt":"MOCK_VALID_prod","userId":"u1","productId":"premium","type":"non_consumable"}'
|
|
154
|
-
|
|
155
|
-
# check status
|
|
156
|
-
curl 'http://localhost:${port}/onesub/status?userId=u1'
|
|
157
|
-
|
|
158
|
-
# simulate a rejected receipt
|
|
159
|
-
curl -X POST http://localhost:${port}/onesub/purchase/validate \\
|
|
160
|
-
-H "Content-Type: application/json" \\
|
|
161
|
-
-d '{"platform":"apple","receipt":"MOCK_REVOKED","userId":"u1","productId":"premium","type":"non_consumable"}'
|
|
162
|
-
|
|
163
|
-
Admin secret: "dev-admin-secret"
|
|
164
|
-
Ctrl+C to stop. State is in-memory — restarts clear everything.
|
|
137
|
+
console.log(`
|
|
138
|
+
onesub dev server — mocked Apple / Google providers
|
|
139
|
+
───────────────────────────────────────────────────
|
|
140
|
+
http://localhost:${port}/health
|
|
141
|
+
http://localhost:${port}/onesub/*
|
|
142
|
+
|
|
143
|
+
Try it:
|
|
144
|
+
|
|
145
|
+
# validate a mock subscription
|
|
146
|
+
curl -X POST http://localhost:${port}/onesub/validate \\
|
|
147
|
+
-H "Content-Type: application/json" \\
|
|
148
|
+
-d '{"platform":"apple","receipt":"MOCK_VALID_sub","userId":"u1","productId":"pro"}'
|
|
149
|
+
|
|
150
|
+
# validate a mock one-time purchase
|
|
151
|
+
curl -X POST http://localhost:${port}/onesub/purchase/validate \\
|
|
152
|
+
-H "Content-Type: application/json" \\
|
|
153
|
+
-d '{"platform":"google","receipt":"MOCK_VALID_prod","userId":"u1","productId":"premium","type":"non_consumable"}'
|
|
154
|
+
|
|
155
|
+
# check status
|
|
156
|
+
curl 'http://localhost:${port}/onesub/status?userId=u1'
|
|
157
|
+
|
|
158
|
+
# simulate a rejected receipt
|
|
159
|
+
curl -X POST http://localhost:${port}/onesub/purchase/validate \\
|
|
160
|
+
-H "Content-Type: application/json" \\
|
|
161
|
+
-d '{"platform":"apple","receipt":"MOCK_REVOKED","userId":"u1","productId":"premium","type":"non_consumable"}'
|
|
162
|
+
|
|
163
|
+
Admin secret: "dev-admin-secret"
|
|
164
|
+
Ctrl+C to stop. State is in-memory — restarts clear everything.
|
|
165
165
|
`);
|
|
166
166
|
});
|
|
167
167
|
const shutdown = () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onesub/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.16",
|
|
4
4
|
"description": "CLI scaffolding for onesub — `npx onesub init` bootstraps a server + Expo app.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
},
|
|
36
36
|
"license": "MIT",
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@onesub/server": "0.
|
|
39
|
-
"@onesub/shared": "0.7.
|
|
38
|
+
"@onesub/server": "0.12.0",
|
|
39
|
+
"@onesub/shared": "0.7.5",
|
|
40
40
|
"express": "^5.2.1"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
package/templates/_gitignore
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
node_modules
|
|
2
|
-
dist
|
|
3
|
-
.env
|
|
4
|
-
.env.*
|
|
5
|
-
!.env.example
|
|
6
|
-
*.log
|
|
7
|
-
.DS_Store
|
|
1
|
+
node_modules
|
|
2
|
+
dist
|
|
3
|
+
.env
|
|
4
|
+
.env.*
|
|
5
|
+
!.env.example
|
|
6
|
+
*.log
|
|
7
|
+
.DS_Store
|