startgg-oauth2-full 0.1.0 → 0.2.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/.github/workflows/release.yml +60 -0
- package/AGENTS.md +46 -0
- package/README.md +14 -5
- package/package.json +1 -1
- package/tsconfig.json +3 -1
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
name: Release Publish
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
publish:
|
|
10
|
+
name: Publish to npm
|
|
11
|
+
if: github.event.release.draft == false && github.event.release.prerelease == false || github.event_name == 'workflow_dispatch'
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
permissions:
|
|
14
|
+
contents: read
|
|
15
|
+
packages: write
|
|
16
|
+
steps:
|
|
17
|
+
- name: Checkout
|
|
18
|
+
uses: actions/checkout@v4
|
|
19
|
+
|
|
20
|
+
- name: Setup Node
|
|
21
|
+
uses: actions/setup-node@v4
|
|
22
|
+
with:
|
|
23
|
+
node-version: 20
|
|
24
|
+
registry-url: https://registry.npmjs.org
|
|
25
|
+
cache: npm
|
|
26
|
+
|
|
27
|
+
- name: Install dependencies
|
|
28
|
+
run: npm ci
|
|
29
|
+
|
|
30
|
+
- name: Verify tag matches package version
|
|
31
|
+
if: github.event_name == 'release'
|
|
32
|
+
run: |
|
|
33
|
+
TAG="${{ github.event.release.tag_name }}"
|
|
34
|
+
PKG_VERSION=$(node -p "require('./package.json').version")
|
|
35
|
+
if [ "$TAG" != "v$PKG_VERSION" ]; then
|
|
36
|
+
echo "Release tag $TAG does not match package version $PKG_VERSION"
|
|
37
|
+
exit 1
|
|
38
|
+
fi
|
|
39
|
+
|
|
40
|
+
- name: Build
|
|
41
|
+
run: npm run build
|
|
42
|
+
|
|
43
|
+
- name: Test
|
|
44
|
+
run: npm test -- --ci
|
|
45
|
+
|
|
46
|
+
- name: Publish
|
|
47
|
+
run: npm publish --access public
|
|
48
|
+
env:
|
|
49
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
50
|
+
|
|
51
|
+
- name: Publish to GitHub Packages
|
|
52
|
+
env:
|
|
53
|
+
NODE_AUTH_TOKEN: ${{ github.token }}
|
|
54
|
+
run: |
|
|
55
|
+
ORIGINAL_NAME=$(node -p "require('./package.json').name")
|
|
56
|
+
OWNER_SCOPE=$(echo "${GITHUB_REPOSITORY_OWNER}" | tr '[:upper:]' '[:lower:]')
|
|
57
|
+
SCOPED_NAME="@${OWNER_SCOPE}/startgg-oauth2-full"
|
|
58
|
+
npm pkg set name="$SCOPED_NAME"
|
|
59
|
+
npm publish --registry https://npm.pkg.github.com
|
|
60
|
+
npm pkg set name="$ORIGINAL_NAME"
|
package/AGENTS.md
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Repository Guidelines
|
|
2
|
+
|
|
3
|
+
## Project Structure & Module Organization
|
|
4
|
+
- `src/` contains the TypeScript OAuth2 helpers (PKCE generation, token exchange, authorize URL builder).
|
|
5
|
+
- `__tests__/` mirrors the source with Jest specs (e.g., `pkce.test.ts`, `authorize-url.test.ts`).
|
|
6
|
+
- `examples/` includes Node, server, and browser demos; use them to validate end-to-end flows.
|
|
7
|
+
- Root config (`tsconfig.json`, `jest.config.ts`, `package.json`) defines tooling standards—change only with consensus.
|
|
8
|
+
|
|
9
|
+
## Build, Test, and Development Commands
|
|
10
|
+
- `npm run build` compiles TypeScript via `tsc`; run before opening a PR.
|
|
11
|
+
- `npm test` runs the full Jest suite; add `-- pkce` (or similar) to target individual specs.
|
|
12
|
+
- `npm run dev:node`, `npm run dev:node:server`, and `npm run dev:browser` start interactive demos for manual OAuth verification.
|
|
13
|
+
|
|
14
|
+
## Coding Style & Naming Conventions
|
|
15
|
+
- Write modern TypeScript (ES2022 target) with strict null checks enabled in `tsconfig.json`.
|
|
16
|
+
- Use two-space indentation, semicolons, and single quotes to match the existing codebase.
|
|
17
|
+
- Functions and variables use `camelCase`, classes and enums use `PascalCase`, constants use `SCREAMING_SNAKE_CASE` where appropriate.
|
|
18
|
+
- Prefer small, self-documenting helpers; add concise comments only when logic is non-obvious.
|
|
19
|
+
|
|
20
|
+
## Testing Guidelines
|
|
21
|
+
- Jest with `ts-jest` handles unit tests; new behaviour requires corresponding specs in `__tests__/`.
|
|
22
|
+
- Name test files after the module under test (e.g., `foo.test.ts`); keep describe blocks aligned with exported functions.
|
|
23
|
+
- Ensure deterministic randomness in tests (stub RNGs) and cover error cases like PKCE validation failures.
|
|
24
|
+
|
|
25
|
+
## Commit & Pull Request Guidelines
|
|
26
|
+
- Craft commits in the form `type(scope): summary` (examples in history: `fix(pkce): cap verifier length`).
|
|
27
|
+
- Each PR should explain the change, list validation steps (e.g., `npm test` output), and link related issues or tickets.
|
|
28
|
+
- Include screenshots or curl transcripts when work affects interactive flows or API responses.
|
|
29
|
+
|
|
30
|
+
## Security & Configuration Tips
|
|
31
|
+
- PKCE relies on WebCrypto; document fallbacks if new runtimes lack `crypto.subtle`.
|
|
32
|
+
- Never log tokens or verifiers in examples; scrub debug statements before merging.
|
|
33
|
+
- Keep secrets out of version control and reference sample env files instead.
|
|
34
|
+
|
|
35
|
+
## Agent Workflow Checklist
|
|
36
|
+
- Sync `main`, install modules (`npm install`), and confirm `npm run build` passes.
|
|
37
|
+
- Add focused Jest coverage for new logic and ensure `npm test` is green.
|
|
38
|
+
- Update docs (`README.md`, `AGENTS.md`) when behaviour or workflows shift.
|
|
39
|
+
- Capture manual verification steps (demo URLs, curl output) in the PR description.
|
|
40
|
+
|
|
41
|
+
## Release Process
|
|
42
|
+
- Bump `package.json` version and update changelog/notes as needed.
|
|
43
|
+
- Commit and tag in `vX.Y.Z` form, then push the tag (`git push origin vX.Y.Z`).
|
|
44
|
+
- Create a GitHub release using that tag; the `Release Publish` workflow runs automatically (or run it manually via **Run workflow**).
|
|
45
|
+
- Ensure `NPM_TOKEN` is configured as a repository secret with publish rights to npm.
|
|
46
|
+
- The workflow also publishes to GitHub Packages using `GITHUB_TOKEN`; consumers can install via `npm install @${repo_owner}/startgg-oauth2-full`.
|
package/README.md
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
<a href="https://github.com/0xabadbabe-ops/startgg-oauth2-full/actions/workflows/ci.yml">
|
|
5
5
|
<img alt="CI" src="https://img.shields.io/github/actions/workflow/status/0xabadbabe-ops/startgg-oauth2-full/ci.yml?branch=main">
|
|
6
6
|
</a>
|
|
7
|
-
<a href="https://www.npmjs.com/package/startgg-oauth2-
|
|
8
|
-
<img alt="npm" src="https://img.shields.io/npm/v/startgg-oauth2-
|
|
7
|
+
<a href="https://www.npmjs.com/package/startgg-oauth2-full">
|
|
8
|
+
<img alt="npm" src="https://img.shields.io/npm/v/startgg-oauth2-full">
|
|
9
9
|
</a>
|
|
10
10
|
<a href="./LICENSE">
|
|
11
11
|
<img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-green.svg">
|
|
@@ -51,10 +51,19 @@ Ran all test suites matching /pkce/i.
|
|
|
51
51
|
## Installation
|
|
52
52
|
|
|
53
53
|
```bash
|
|
54
|
-
npm i startgg-oauth2-
|
|
54
|
+
npm i startgg-oauth2-full
|
|
55
55
|
# or copy src/auth/StartGGOAuth2.ts into your project
|
|
56
56
|
```
|
|
57
57
|
|
|
58
|
+
### GitHub Packages (optional)
|
|
59
|
+
|
|
60
|
+
This library is also mirrored to GitHub Packages if your environment prefers that registry:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
npm set //npm.pkg.github.com/:_authToken=<GH_TOKEN_WITH_PACKAGES_SCOPE>
|
|
64
|
+
npm install @0xabadbabe-ops/startgg-oauth2-full
|
|
65
|
+
```
|
|
66
|
+
|
|
58
67
|
---
|
|
59
68
|
|
|
60
69
|
## Requirements
|
|
@@ -69,7 +78,7 @@ npm i startgg-oauth2-pkce
|
|
|
69
78
|
### Browser (PKCE → Exchange)
|
|
70
79
|
|
|
71
80
|
```ts
|
|
72
|
-
import { buildAuthorizeUrl, StartGGScope } from 'startgg-oauth2-
|
|
81
|
+
import { buildAuthorizeUrl, StartGGScope } from 'startgg-oauth2-full';
|
|
73
82
|
|
|
74
83
|
const cfg = {
|
|
75
84
|
clientId: '<client-id>',
|
|
@@ -90,7 +99,7 @@ location.href = url;
|
|
|
90
99
|
### Callback (Exchange + Bearer)
|
|
91
100
|
|
|
92
101
|
```ts
|
|
93
|
-
import { createStartGGAuth2Handler, BearerToken, StartGGScope } from 'startgg-oauth2-
|
|
102
|
+
import { createStartGGAuth2Handler, BearerToken, StartGGScope } from 'startgg-oauth2-full';
|
|
94
103
|
|
|
95
104
|
const params = new URLSearchParams(location.search);
|
|
96
105
|
const code = params.get('code')!;
|
package/package.json
CHANGED