@hyodotdev/openiap 0.0.0-bootstrap.0 → 0.1.0-alpha.0
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 +150 -4
- package/bin/openiap.mjs +110 -0
- package/package.json +26 -5
- package/src/checks.mjs +597 -0
- package/src/doctor.mjs +183 -0
- package/src/findings.mjs +32 -0
- package/src/init.mjs +95 -0
- package/src/project.mjs +417 -0
package/README.md
CHANGED
|
@@ -1,8 +1,154 @@
|
|
|
1
1
|
# @hyodotdev/openiap
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Connect your app, paywall, commerce service, or data product to OpenIAP.
|
|
4
|
+
Choose your role, then give the implementation brief to your coding assistant
|
|
5
|
+
in your existing project. Use `doctor` to check local purchase configuration.
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
a usable implementation. Functional releases will be published separately.
|
|
7
|
+
Requires Node.js 20 or later.
|
|
7
8
|
|
|
8
|
-
[
|
|
9
|
+
[](https://www.npmjs.com/package/@hyodotdev/openiap)
|
|
10
|
+
|
|
11
|
+
## Start with your role
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npx @hyodotdev/openiap # choose a role in your terminal
|
|
15
|
+
npx @hyodotdev/openiap init ./my-product --role experience
|
|
16
|
+
npx @hyodotdev/openiap doctor ./my-app --json
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
| Role | Connect |
|
|
20
|
+
| --- | --- |
|
|
21
|
+
| `app` | Purchases to customer access |
|
|
22
|
+
| `experience` | Paywalls and experiments to the app's purchase flow |
|
|
23
|
+
| `commerce` | Verification and access through the Commerce Protocol |
|
|
24
|
+
| `data` | Normalized events to analytics and automation |
|
|
25
|
+
|
|
26
|
+
The brief points your assistant to the matching implementation guide. Fill in
|
|
27
|
+
the customer outcome, choose any missing product decisions, and review the
|
|
28
|
+
running result. Run again for each role your product supplies.
|
|
29
|
+
|
|
30
|
+
Both commands only read local files. They do not install dependencies, change
|
|
31
|
+
your project, contact a server, or invoke an AI. `init` prints a brief; your
|
|
32
|
+
coding assistant performs the implementation when you give it that brief.
|
|
33
|
+
For scripts, select a role explicitly with `--role`.
|
|
34
|
+
|
|
35
|
+
## Severity
|
|
36
|
+
|
|
37
|
+
**Error** means the checkout proves it: two files disagree, or a value is wrong
|
|
38
|
+
for its documented use. Errors exit `1`.
|
|
39
|
+
|
|
40
|
+
**Warning** means the checkout suggests it but cannot settle it — Gradle can
|
|
41
|
+
inject a manifest placeholder, a linked framework can supply a class, and no
|
|
42
|
+
file records whether the app reads a given variable. Warnings exit `0`.
|
|
43
|
+
|
|
44
|
+
A build for another store is settled but deliberate, so it is a warning too:
|
|
45
|
+
the tool cannot know which device you are about to install on.
|
|
46
|
+
|
|
47
|
+
**Both** means the level depends on what the checkout shows. A malformed base
|
|
48
|
+
URL is an error where something inlines the name it is assigned to, and a
|
|
49
|
+
warning where nothing does; a missing scene delegate is an error when the
|
|
50
|
+
Info.plist names the app's own module or no class at all, and a warning when the
|
|
51
|
+
name could come from a linked framework.
|
|
52
|
+
|
|
53
|
+
## What it finds
|
|
54
|
+
|
|
55
|
+
Most of these produce no error message that says what is actually wrong.
|
|
56
|
+
|
|
57
|
+
| Check | Level | What goes wrong without it |
|
|
58
|
+
| ----------------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
59
|
+
| `android-store-flavor-mismatch` | error | A half-finished regeneration links one store while the flags select another. |
|
|
60
|
+
| `android-store-flavor-conflict` | error | Both store flags are true. Gradle also refuses this; the doctor sees it before a build. |
|
|
61
|
+
| `android-store-not-play` | warning | The build targets Horizon or Amazon, so Play billing cannot connect on a Play device. |
|
|
62
|
+
| `android-horizon-app-id-missing` | warning | Horizon is selected but no manifest declares an app id. |
|
|
63
|
+
| `iapkit-secret-key-in-client` | error | A secret key is on a name that reaches the app bundle. |
|
|
64
|
+
| `iapkit-secret-key-in-env` | warning | A secret key is in an env file on a name nothing here proves is inlined. |
|
|
65
|
+
| `iapkit-env-missing-expo-prefix` | warning | Expo inlines only `EXPO_PUBLIC_` names, so the bare name reads as undefined. |
|
|
66
|
+
| `iapkit-env-unexpected-expo-prefix` | warning | An `EXPO_PUBLIC_` name is set where nothing inlines that prefix. |
|
|
67
|
+
| `iapkit-base-url-has-path` | both | The base URL is not a bare origin; every SDK rejects a path, userinfo, a query or a fragment. |
|
|
68
|
+
| `iapkit-base-url-invalid` | both | The base URL is not a URL. |
|
|
69
|
+
| `iapkit-base-url-scheme` | both | The base URL is not http or https. |
|
|
70
|
+
| `ios-scene-delegate-missing` | both | The Info.plist names a scene delegate the target lacks; the app opens to a black screen. Error when the plist names the app's own module or no class at all, warning when a linked framework could supply it. |
|
|
71
|
+
| `project-file-unreadable` | error | A path could not be read, so nothing in it was checked. |
|
|
72
|
+
| `project-manifest-unreadable` | error | package.json exists but will not parse, so framework detection read nothing. |
|
|
73
|
+
| `project-not-a-directory` | error | The path given is not a readable directory. |
|
|
74
|
+
|
|
75
|
+
## What it does not find
|
|
76
|
+
|
|
77
|
+
Dynamic app configuration is never executed. Reading an unprefixed environment
|
|
78
|
+
variable there does not prove it reaches the app; secret values stay warnings.
|
|
79
|
+
|
|
80
|
+
A checkout cannot answer for a device or a store account. The command prints
|
|
81
|
+
these as unchecked rather than guessing:
|
|
82
|
+
|
|
83
|
+
- Store account state: agreements, product status, and license testers.
|
|
84
|
+
- Device state: a scene session or an installed build left by another app that
|
|
85
|
+
shares the bundle id.
|
|
86
|
+
- Play billing availability on the device and its signed-in account.
|
|
87
|
+
|
|
88
|
+
## Usage
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
npx @hyodotdev/openiap doctor # the working directory
|
|
92
|
+
npx @hyodotdev/openiap doctor ./my-app # a project elsewhere
|
|
93
|
+
npx @hyodotdev/openiap doctor --json # one JSON report
|
|
94
|
+
npx @hyodotdev/openiap --version # the version and nothing else
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Exit code is `1` when there is an error, `0` otherwise.
|
|
98
|
+
|
|
99
|
+
`--json` emits `{framework, findings, errors, warnings, notCheckedLocally}`.
|
|
100
|
+
Each finding carries a stable `id`, a `level`, the `file` it was read from, a
|
|
101
|
+
`message`, a `fix`, and — where the check can point at one — a `line`,
|
|
102
|
+
`expected`, and `actual`. Match on `id`; the prose is for people.
|
|
103
|
+
|
|
104
|
+
<!-- sponsors:start -->
|
|
105
|
+
<!-- Generated by scripts/sync-sponsors.mjs from packages/docs/sponsor-registry.json. -->
|
|
106
|
+
|
|
107
|
+
## Sponsors
|
|
108
|
+
|
|
109
|
+
<p align="center">
|
|
110
|
+
<a href="https://meta.com">
|
|
111
|
+
<img src="https://openiap.dev/meta.svg" alt="Meta" height="80" align="middle">
|
|
112
|
+
</a>
|
|
113
|
+
|
|
114
|
+
<a href="https://developer.amazon.com/">
|
|
115
|
+
<picture>
|
|
116
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://openiap.dev/sponsors/amazon-dark.webp">
|
|
117
|
+
<img src="https://openiap.dev/sponsors/amazon.webp" alt="Amazon Developer" height="44" align="middle">
|
|
118
|
+
</picture>
|
|
119
|
+
</a>
|
|
120
|
+
</p>
|
|
121
|
+
|
|
122
|
+
Thank you to [Meta](https://meta.com) and [Amazon Developer](https://developer.amazon.com/) for supporting OpenIAP. [View sponsorship options](https://openiap.dev/sponsors).
|
|
123
|
+
|
|
124
|
+
### OpenCollective
|
|
125
|
+
|
|
126
|
+
We also recognize sponsors and backers through OpenCollective. The original react-native-iap collective now supports the broader OpenIAP ecosystem and is managed separately from the main sponsor program.
|
|
127
|
+
|
|
128
|
+
**Sponsors:** <a href="https://opencollective.com/openiap#sponsors"><img src="https://opencollective.com/openiap/sponsors.svg?width=890&cache=20260706" alt="OpenCollective sponsors" /></a>
|
|
129
|
+
|
|
130
|
+
**Backers:** <a href="https://opencollective.com/openiap#backers"><img src="https://opencollective.com/openiap/backers.svg?width=890&cache=20260706" alt="OpenCollective backers" /></a>
|
|
131
|
+
|
|
132
|
+
[Become a sponsor](https://opencollective.com/openiap#sponsor) | [Become a backer](https://opencollective.com/openiap#backer)
|
|
133
|
+
|
|
134
|
+
### Past supporters
|
|
135
|
+
|
|
136
|
+
Supported the project before the OpenIAP sponsor program.
|
|
137
|
+
|
|
138
|
+
<p align="center">
|
|
139
|
+
<a href="https://namiml.com">
|
|
140
|
+
<img src="https://openiap.dev/sponsors/nami.webp" alt="Nami" height="32" align="middle">
|
|
141
|
+
</a>
|
|
142
|
+
|
|
143
|
+
<a href="https://www.courier.com/?utm_source=react-native-iap&utm_campaign=osssponsors">
|
|
144
|
+
<img src="https://openiap.dev/sponsors/courier.webp" alt="Courier" height="32" align="middle">
|
|
145
|
+
</a>
|
|
146
|
+
</p>
|
|
147
|
+
|
|
148
|
+
[openiap-sponsors]: https://openiap.dev/sponsors
|
|
149
|
+
[openiap-github-sponsors]: https://github.com/sponsors/hyodotdev
|
|
150
|
+
[openiap-opencollective]: https://opencollective.com/openiap
|
|
151
|
+
[openiap-paypal]: https://www.paypal.me/dooboolab
|
|
152
|
+
[openiap-company-contact]: mailto:hyo@hyo.dev
|
|
153
|
+
|
|
154
|
+
<!-- sponsors:end -->
|
package/bin/openiap.mjs
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { readFileSync } from "node:fs";
|
|
4
|
+
import { doctor, formatText } from "../src/doctor.mjs";
|
|
5
|
+
import { chooseRole, implementationBrief } from "../src/init.mjs";
|
|
6
|
+
|
|
7
|
+
const USAGE = `openiap choose your role and get an AI implementation brief
|
|
8
|
+
openiap init [path] [--role app|experience|commerce|data]
|
|
9
|
+
openiap doctor [path] [--json]
|
|
10
|
+
|
|
11
|
+
Start an integration with init; check local configuration with doctor.
|
|
12
|
+
Both read local files without modifying them or contacting a server.
|
|
13
|
+
|
|
14
|
+
path project root (default: the working directory)
|
|
15
|
+
--role your product's role (init only; prompts in a terminal if omitted)
|
|
16
|
+
--json one machine-readable report (doctor only)
|
|
17
|
+
--help show this help (-h)
|
|
18
|
+
--version print the version and exit (-v)
|
|
19
|
+
`;
|
|
20
|
+
|
|
21
|
+
process.stdout.on("error", (error) => {
|
|
22
|
+
if (error.code === "EPIPE") process.exit(process.exitCode ?? 0);
|
|
23
|
+
throw error;
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const argv = process.argv.slice(2);
|
|
27
|
+
const beforeSeparator = argv.slice(
|
|
28
|
+
0,
|
|
29
|
+
argv.indexOf("--") < 0 ? undefined : argv.indexOf("--"),
|
|
30
|
+
);
|
|
31
|
+
if (beforeSeparator.includes("--version") || beforeSeparator.includes("-v")) {
|
|
32
|
+
const manifest = new URL("../package.json", import.meta.url);
|
|
33
|
+
process.stdout.write(
|
|
34
|
+
`${JSON.parse(readFileSync(manifest, "utf8")).version}\n`,
|
|
35
|
+
);
|
|
36
|
+
process.exit(0);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (
|
|
40
|
+
beforeSeparator.includes("--help") ||
|
|
41
|
+
beforeSeparator.includes("-h") ||
|
|
42
|
+
(argv.length === 0 && !process.stdin.isTTY)
|
|
43
|
+
) {
|
|
44
|
+
process.stdout.write(USAGE);
|
|
45
|
+
process.exit(0);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const command = argv[0] ?? "init";
|
|
49
|
+
if (command !== "doctor" && command !== "init") {
|
|
50
|
+
process.stderr.write(`Unknown command: ${argv[0]}\n\n${USAGE}`);
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Everything after `--` is a path, so a directory named `-x` is reachable.
|
|
55
|
+
const end = argv.indexOf("--");
|
|
56
|
+
const head = end < 0 ? argv.slice(1) : argv.slice(1, end);
|
|
57
|
+
const tail = end < 0 ? [] : argv.slice(end + 1);
|
|
58
|
+
|
|
59
|
+
let role;
|
|
60
|
+
let json = false;
|
|
61
|
+
const positional = [];
|
|
62
|
+
for (let index = 0; index < head.length; index += 1) {
|
|
63
|
+
const argument = head[index];
|
|
64
|
+
if (command === "doctor" && argument === "--json") json = true;
|
|
65
|
+
else if (
|
|
66
|
+
command === "init" &&
|
|
67
|
+
(argument === "--role" || argument.startsWith("--role="))
|
|
68
|
+
) {
|
|
69
|
+
const value =
|
|
70
|
+
argument === "--role" ? head[++index] : argument.slice("--role=".length);
|
|
71
|
+
if (role !== undefined || !value || value.startsWith("-")) {
|
|
72
|
+
process.stderr.write(
|
|
73
|
+
"Expected one --role value: app, experience, commerce, or data.\n",
|
|
74
|
+
);
|
|
75
|
+
process.exit(1);
|
|
76
|
+
}
|
|
77
|
+
role = value;
|
|
78
|
+
} else if (argument.startsWith("-")) {
|
|
79
|
+
process.stderr.write(`Unknown option: ${argument}\n\n${USAGE}`);
|
|
80
|
+
process.exit(1);
|
|
81
|
+
} else positional.push(argument);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
positional.push(...tail);
|
|
85
|
+
if (positional.length > 1) {
|
|
86
|
+
process.stderr.write(
|
|
87
|
+
`Expected one path, got ${positional.length}: ${positional.join(" ")}\n\n${USAGE}`,
|
|
88
|
+
);
|
|
89
|
+
process.exit(1);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const root = path.resolve(positional[0] ?? process.cwd());
|
|
93
|
+
|
|
94
|
+
if (command === "init") {
|
|
95
|
+
try {
|
|
96
|
+
process.stdout.write(
|
|
97
|
+
implementationBrief(root, role ?? (await chooseRole())),
|
|
98
|
+
);
|
|
99
|
+
} catch (error) {
|
|
100
|
+
process.stderr.write(`${error.message}\n`);
|
|
101
|
+
process.exitCode = 1;
|
|
102
|
+
}
|
|
103
|
+
} else {
|
|
104
|
+
const result = doctor(root);
|
|
105
|
+
// Set the code and let the write finish; `process.exit` would cut it short.
|
|
106
|
+
process.exitCode = result.errors > 0 ? 1 : 0;
|
|
107
|
+
process.stdout.write(
|
|
108
|
+
json ? `${JSON.stringify(result, null, 2)}\n` : `${formatText(result)}\n`,
|
|
109
|
+
);
|
|
110
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyodotdev/openiap",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.0-alpha.0",
|
|
4
|
+
"description": "Start an OpenIAP integration with AI and check local purchase configuration",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"openiap",
|
|
7
|
+
"in-app-purchase",
|
|
8
|
+
"doctor",
|
|
9
|
+
"cli"
|
|
10
|
+
],
|
|
11
|
+
"homepage": "https://github.com/hyodotdev/openiap/tree/main/packages/cli",
|
|
12
|
+
"type": "module",
|
|
5
13
|
"license": "MIT",
|
|
6
14
|
"author": "hyodotdev",
|
|
7
15
|
"repository": {
|
|
@@ -9,11 +17,24 @@
|
|
|
9
17
|
"url": "git+https://github.com/hyodotdev/openiap.git",
|
|
10
18
|
"directory": "packages/cli"
|
|
11
19
|
},
|
|
12
|
-
"
|
|
20
|
+
"bin": {
|
|
21
|
+
"openiap": "bin/openiap.mjs"
|
|
22
|
+
},
|
|
13
23
|
"files": [
|
|
14
|
-
"
|
|
15
|
-
"
|
|
24
|
+
"LICENSE",
|
|
25
|
+
"bin",
|
|
26
|
+
"src",
|
|
27
|
+
"README.md"
|
|
16
28
|
],
|
|
29
|
+
"engines": {
|
|
30
|
+
"node": ">=20"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"yaml": "^2.9.0"
|
|
34
|
+
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"test": "node --test test/*.test.mjs"
|
|
37
|
+
},
|
|
17
38
|
"publishConfig": {
|
|
18
39
|
"access": "public",
|
|
19
40
|
"registry": "https://registry.npmjs.org/"
|