@atlasauth/pca-idjag 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/LICENSE +21 -0
- package/README.md +67 -0
- package/package.json +28 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Atlas Authorization
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# @atlasauth/pca-idjag
|
|
2
|
+
|
|
3
|
+
ID-JAG / OAuth Cross-App Access bridge for Proof-Carrying Authority (PCA). An ID-JAG (Identity Assertion Authorization Grant, `draft-ietf-oauth-identity-assertion-authz-grant`) is a JWT an enterprise identity provider mints so an agent app can act on a named user's behalf against one other app: `sub` is the human, `act` is the agent, `aud` is the single target app, and `scope` is the delegated authority. This package verifies such a grant, projects it onto a PCA principal and a signed root capability, and builds the two OAuth requests used in the flow (RFC 8693 token exchange to obtain a grant, RFC 7523 jwt-bearer to redeem one).
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm i @atlasauth/pca-idjag @atlasauth/pca @atlasauth/pca-oidc
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { generateKeyPair, encodeKey, verifyChain } from '@atlasauth/pca';
|
|
15
|
+
import { verifyIdJag, idJagToCapability, tokenExchangeRequest, jwtBearerAssertion } from '@atlasauth/pca-idjag';
|
|
16
|
+
|
|
17
|
+
// 1. Verify the ID-JAG. Fails closed (throws IdJagVerificationError) on any signature, issuer,
|
|
18
|
+
// audience, expiry, nonce, actor or scope problem.
|
|
19
|
+
const grant = await verifyIdJag(idJagJwt, {
|
|
20
|
+
issuer: 'https://idp.example.com',
|
|
21
|
+
audience: 'https://resource.example.com', // must be the single audience of the grant
|
|
22
|
+
jwksUri: 'https://idp.example.com/.well-known/jwks.json', // or `discover: true`, or an injected `key`
|
|
23
|
+
requiredScopes: ['calendar.read'],
|
|
24
|
+
});
|
|
25
|
+
grant.sub; // the human
|
|
26
|
+
grant.agent; // the acting app (act.sub)
|
|
27
|
+
grant.scopes; // ['calendar.read', 'mail.send']
|
|
28
|
+
|
|
29
|
+
// 2. Project it onto a signed PCA root capability: authority = scopes, holder = the agent's PCA key.
|
|
30
|
+
const human = generateKeyPair(); // the human root key that signs the capability
|
|
31
|
+
const agentKey = generateKeyPair();
|
|
32
|
+
const { capability } = idJagToCapability(grant, {
|
|
33
|
+
principalSecret: human.secretKey,
|
|
34
|
+
principalPublic: encodeKey(human.publicKey),
|
|
35
|
+
holder: encodeKey(agentKey.publicKey),
|
|
36
|
+
});
|
|
37
|
+
verifyChain([capability], encodeKey(human.publicKey)); // { ok: true }
|
|
38
|
+
|
|
39
|
+
// 3. The OAuth legs of the flow (plain request descriptions; you send them).
|
|
40
|
+
const obtain = tokenExchangeRequest({
|
|
41
|
+
tokenEndpoint: 'https://idp.example.com/oauth2/token',
|
|
42
|
+
subjectToken: userIdToken,
|
|
43
|
+
audience: 'https://resource.example.com',
|
|
44
|
+
scope: ['calendar.read'],
|
|
45
|
+
clientId: 'agent-app-7',
|
|
46
|
+
});
|
|
47
|
+
const redeem = jwtBearerAssertion({
|
|
48
|
+
tokenEndpoint: 'https://resource.example.com/token',
|
|
49
|
+
assertion: idJagJwt,
|
|
50
|
+
scope: 'calendar.read',
|
|
51
|
+
}).request; // { url, method, headers, params, body }
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## API
|
|
55
|
+
|
|
56
|
+
- `verifyIdJag(jwt, options)` returns an `IdJagGrant`; throws `IdJagVerificationError` (with a `code`).
|
|
57
|
+
- `idJagToPcaPrincipal(grant, opts?)`, `idJagToCapability(grant, opts)` map a grant to a PCA principal / signed root capability.
|
|
58
|
+
- `readIdJagAuthority(cap)`, `readIdJagProvenance(cap)`, `isIdJagAuthorityCaveat`, `isIdJagProvenanceCaveat` read the caveats back.
|
|
59
|
+
- `tokenExchangeRequest(opts)`, `jwtBearerAssertion(opts)` build the RFC 8693 / RFC 7523 requests; the `GRANT_TYPE_*`, `TOKEN_TYPE_*` and `CLIENT_ASSERTION_TYPE_JWT_BEARER` URN constants are exported.
|
|
60
|
+
|
|
61
|
+
## Status
|
|
62
|
+
|
|
63
|
+
The ID-JAG specification is an IETF draft and may change. JWT checks are delegated to `@atlasauth/pca-oidc`; only asymmetric algorithms are accepted by default. This package does not send any network request except the optional JWKS / discovery fetch. PCA cryptography has not been independently audited.
|
|
64
|
+
|
|
65
|
+
## License
|
|
66
|
+
|
|
67
|
+
MIT - see LICENSE
|
package/package.json
CHANGED
|
@@ -1,7 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlasauth/pca-idjag",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "ID-JAG / OAuth Cross-App-Access bridge for PCA: verify an identity-assertion authorization grant (sub=human, act=agent, scoped, single-audience) and map it to a PCA principal/capability; RFC 8693/7523 token-exchange.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"id-jag",
|
|
7
|
+
"cross app access",
|
|
8
|
+
"oauth",
|
|
9
|
+
"identity assertion",
|
|
10
|
+
"agent authorization",
|
|
11
|
+
"proof-carrying authority",
|
|
12
|
+
"pca",
|
|
13
|
+
"ai agents"
|
|
14
|
+
],
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"homepage": "https://github.com/Atlas-Authorization/pca#readme",
|
|
17
|
+
"bugs": {
|
|
18
|
+
"url": "https://github.com/Atlas-Authorization/pca/issues"
|
|
19
|
+
},
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/Atlas-Authorization/pca.git",
|
|
23
|
+
"directory": "packages/pca-idjag"
|
|
24
|
+
},
|
|
5
25
|
"main": "./dist/index.js",
|
|
6
26
|
"types": "./dist/index.d.ts",
|
|
7
27
|
"exports": {
|
|
@@ -13,8 +33,8 @@
|
|
|
13
33
|
},
|
|
14
34
|
"dependencies": {
|
|
15
35
|
"jose": "^5.9.6",
|
|
16
|
-
"@atlasauth/pca": "0.
|
|
17
|
-
"@atlasauth/pca-oidc": "0.
|
|
36
|
+
"@atlasauth/pca": "0.2.0",
|
|
37
|
+
"@atlasauth/pca-oidc": "0.2.0"
|
|
18
38
|
},
|
|
19
39
|
"devDependencies": {
|
|
20
40
|
"typescript": "^5.6.3",
|
|
@@ -22,8 +42,12 @@
|
|
|
22
42
|
},
|
|
23
43
|
"files": [
|
|
24
44
|
"dist",
|
|
25
|
-
"README.md"
|
|
45
|
+
"README.md",
|
|
46
|
+
"LICENSE"
|
|
26
47
|
],
|
|
48
|
+
"engines": {
|
|
49
|
+
"node": ">=20"
|
|
50
|
+
},
|
|
27
51
|
"publishConfig": {
|
|
28
52
|
"access": "public"
|
|
29
53
|
},
|