@crouter/identity 0.3.392 → 0.3.393
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 +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.js +8 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -45,7 +45,7 @@ export async function authorize(request: Request) {
|
|
|
45
45
|
|
|
46
46
|
| Function | Checks | Returns |
|
|
47
47
|
|---|---|---|
|
|
48
|
-
| `verifyAccessToken` | `typ: at+jwt`, ES256, signature, `iss`, `aud`, `exp`; `sub` is `user:<id>`, `grantee` is `app:<id
|
|
48
|
+
| `verifyAccessToken` | `typ: at+jwt`, ES256, signature, `iss`, `aud`, `exp`; `sub` is `user:<id>`, `grantee` is `app:<id>`; `rev` is a positive integer (a token without `rev` throws `MissingRevClaimError`) | `AccessTokenClaims` (`sub`, `grantee`, `client_id`, `grant`, `rev`, `exp`) |
|
|
49
49
|
| `verifyOutboundToken` | `typ: at+jwt`, ES256 or RS256 with a `kid`, signature, `iss`, `aud`, `exp`; claim presence and types, including `scope`, `initiating_app`, `act`, `jti` | `OutboundTokenClaims` |
|
|
50
50
|
| `verifyIdToken` | ES256, signature, `iss`, `aud`, `exp`; `sub` is `user:<id>` | `IdTokenClaims` (`email*` when `email` was granted; `name`, `given_name`, `family_name` when `profile` was) |
|
|
51
51
|
| `verifySyncNotice` | ES256 with a `kid`, `purpose: grant_sync`, lifetime of at most five minutes, 30 s clock tolerance | `SyncNoticeClaims` (`jti`, `iat`, `exp`) |
|
package/dist/index.d.ts
CHANGED
|
@@ -4,8 +4,14 @@ export interface AccessTokenClaims extends JWTPayload {
|
|
|
4
4
|
grantee: string;
|
|
5
5
|
client_id: string;
|
|
6
6
|
grant: string;
|
|
7
|
+
/** The grant revision the directory minted against: a freshness floor, never authorization (contract 1). */
|
|
8
|
+
rev: number;
|
|
7
9
|
exp: number;
|
|
8
10
|
}
|
|
11
|
+
/** Thrown by `verifyAccessToken` for a signed token with no `rev` claim: the directory predates the claim. */
|
|
12
|
+
export declare class MissingRevClaimError extends Error {
|
|
13
|
+
constructor();
|
|
14
|
+
}
|
|
9
15
|
/** `email*` appear when `email` was granted; `name`, `given_name`, `family_name` when `profile` was granted and the person has a name. A person with no name has none of the three: never the phone number. `picture` (an https URL of the person's Google photo) when `profile` was granted and the account has one. */
|
|
10
16
|
export interface IdTokenClaims extends JWTPayload {
|
|
11
17
|
sub: string;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { createLocalJWKSet, decodeProtectedHeader, jwtVerify } from 'jose';
|
|
2
|
+
/** Thrown by `verifyAccessToken` for a signed token with no `rev` claim: the directory predates the claim. */
|
|
3
|
+
export class MissingRevClaimError extends Error {
|
|
4
|
+
constructor() { super('access token has no rev claim: the directory is older than this runtime'); this.name = 'MissingRevClaimError'; }
|
|
5
|
+
}
|
|
2
6
|
/** App-memory form keys omit the app id. */
|
|
3
7
|
export const ENFORCED = new Set(['crtr:llm', 'crtr:act', 'crtr:schedule', 'crtr:memory:read:user', 'crtr:memory:read:app', 'crtr:memory:rw:app', 'crtr:files:read:user:.', 'crtr:files:rw:user:.']);
|
|
4
8
|
const id = /^[A-Za-z0-9_-]{1,64}$/;
|
|
@@ -147,6 +151,10 @@ export async function verifyAccessToken(options) {
|
|
|
147
151
|
typeof payload.exp !== 'number') {
|
|
148
152
|
throw new Error('Invalid access token claims');
|
|
149
153
|
}
|
|
154
|
+
if (payload.rev === undefined)
|
|
155
|
+
throw new MissingRevClaimError();
|
|
156
|
+
if (typeof payload.rev !== 'number' || !Number.isInteger(payload.rev) || payload.rev < 1)
|
|
157
|
+
throw new Error('Invalid access token claims');
|
|
150
158
|
return payload;
|
|
151
159
|
}
|
|
152
160
|
function nonEmptyString(value) {
|