@crvouga/mockingbird-service-cognito 3.10.7 → 3.10.9
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/CHANGELOG.md +12 -0
- package/README.md +1 -1
- package/SUPPORT.md +1 -1
- package/dist/{chunk-AQ2JBHMK.js → chunk-7Q2C5EBR.js} +68 -24
- package/dist/{chunk-AQ2JBHMK.js.map → chunk-7Q2C5EBR.js.map} +2 -2
- package/dist/{chunk-3MP7CS3M.js → chunk-LUCXSAHG.js} +3 -3
- package/dist/cli.js +2 -2
- package/dist/index.d.ts +15 -1
- package/dist/index.js +1 -1
- package/dist/server.d.ts +15 -1
- package/dist/server.js +2 -2
- package/openapi.yaml +1 -1
- package/package.json +1 -1
- /package/dist/{chunk-3MP7CS3M.js.map → chunk-LUCXSAHG.js.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog — @crvouga/mockingbird-service-cognito
|
|
2
2
|
|
|
3
|
+
## 3.10.9 (2026-11-02)
|
|
4
|
+
|
|
5
|
+
### Fixes and improvements
|
|
6
|
+
|
|
7
|
+
- save and replay a 500 the endpoint produced under an Idempotency-Key ([789bbcc](https://github.com/crvouga/mockingbird/commit/789bbcccb792cddaf27f4f6db6d2fcf2da1d07fe))
|
|
8
|
+
|
|
9
|
+
## 3.10.8 (2026-11-02)
|
|
10
|
+
|
|
11
|
+
### Fixes and improvements
|
|
12
|
+
|
|
13
|
+
- sign ID and access tokens with separate keys and add jti, origin_jti and event_id ([647326d](https://github.com/crvouga/mockingbird/commit/647326d2d52b5358e7e4d9ccd06004be2ab7265c))
|
|
14
|
+
|
|
3
15
|
## 3.10.7 (2026-11-02)
|
|
4
16
|
|
|
5
17
|
### Fixes and improvements
|
package/README.md
CHANGED
|
@@ -68,7 +68,7 @@ Responses contain SDK-consumed Cognito fields and AWS-shaped exceptions (`__type
|
|
|
68
68
|
- `GET/POST /__admin/users` lists redacted users or seeds one. Passwords and tokens are never returned.
|
|
69
69
|
- `GET /__admin/codes?username=…` returns local confirmation/reset codes without sending mail.
|
|
70
70
|
- `POST /__admin/sessions/revoke {"username":"…"}` invalidates access and refresh sessions.
|
|
71
|
-
- `POST /__admin/keys/rotate {"retainPrevious":true}` rotates signing keys and retains at most two prior keys. Every new key receives a fresh random UUID `kid`, independently of the virtual clock. Reset starts a fresh key ring.
|
|
71
|
+
- `POST /__admin/keys/rotate {"retainPrevious":true}` rotates signing keys and retains at most two prior keys. As in Cognito, ID and access tokens are signed with different keys, so the JWKS lists one key of each kind per generation and rotation replaces both (the response names them `kid` and `accessKid`). Every new key receives a fresh random UUID `kid`, independently of the virtual clock. Reset starts a fresh key ring.
|
|
72
72
|
- Fault presets: `throttled`, `unavailable`.
|
|
73
73
|
|
|
74
74
|
The shared runtime supplies reset, clock, snapshots, journals, metrics, faults, branches, and namespace isolation. Select namespaces through `x-mockingbird-namespace`, `/__admin/ns/<name>`, or SigV4 access-key mappings.
|
package/SUPPORT.md
CHANGED
|
@@ -10,4 +10,4 @@ Generated from `openapi.yaml`; do not edit by hand.
|
|
|
10
10
|
| --- | --- | --- | --- | --- |
|
|
11
11
|
| `CognitoRpc` | `POST /` | ✅ supported | ⚠️ unsafe (opt-in) | |
|
|
12
12
|
| `Discovery` | `GET /{poolId}/.well-known/openid-configuration` | ✅ supported | ❌ disabled | Namespace-scoped local issuer metadata with configured public origin/prefix. |
|
|
13
|
-
| `Jwks` | `GET /{poolId}/.well-known/jwks.json` | ✅ supported | ❌ disabled | Namespace-scoped RS256 keys; portable snapshots retain the current
|
|
13
|
+
| `Jwks` | `GET /{poolId}/.well-known/jwks.json` | ✅ supported | ❌ disabled | Namespace-scoped RS256 keys; one key signs ID tokens and another signs access tokens as in Cognito; portable snapshots retain the current pair and two prior pairs. |
|
|
@@ -3876,7 +3876,7 @@ var stateAdminRoutes = (routes) => {
|
|
|
3876
3876
|
};
|
|
3877
3877
|
|
|
3878
3878
|
// ../core/dist/version.js
|
|
3879
|
-
var PACKAGE_VERSION = true ? "3.10.
|
|
3879
|
+
var PACKAGE_VERSION = true ? "3.10.9" : UNRELEASED_VERSION;
|
|
3880
3880
|
|
|
3881
3881
|
// ../core/dist/webhooks.js
|
|
3882
3882
|
var json4 = (status, body) => new Response(JSON.stringify(body), {
|
|
@@ -5343,7 +5343,7 @@ var redactedUser = (user) => ({
|
|
|
5343
5343
|
});
|
|
5344
5344
|
|
|
5345
5345
|
// src/generated/openapi.ts
|
|
5346
|
-
var document = JSON.parse(`{"openapi":"3.1.0","info":{"title":"Amazon Cognito Identity Provider (Mockingbird subset)","version":"2016-04-18","description":"Hand-trimmed AWS JSON 1.1 user-pools contract used by the AWS SDK clients."},"servers":[{"url":"https://cognito-idp.us-east-1.amazonaws.com"}],"security":[{"sigv4":[]}],"paths":{"/":{"post":{"operationId":"CognitoRpc","x-mockingbird":{"supported":true,"parity":{"enabled":true,"safe":false}},"parameters":[{"name":"X-Amz-Target","in":"header","required":true,"schema":{"type":"string","pattern":"^AWSCognitoIdentityProviderService\\\\.[A-Za-z]+$"}}],"requestBody":{"required":true,"content":{"application/x-amz-json-1.1":{"schema":{"type":"object","additionalProperties":true}},"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"responses":{"200":{"description":"Operation-specific AWS JSON response.","content":{"application/x-amz-json-1.1":{"schema":{"type":"object","additionalProperties":true}}}},"400":{"description":"Cognito service exception.","content":{"application/x-amz-json-1.1":{"schema":{"type":"object","required":["__type","message"],"properties":{"__type":{"type":"string"},"message":{"type":"string"}},"additionalProperties":true}}}}}}},"/{poolId}/.well-known/openid-configuration":{"get":{"operationId":"Discovery","security":[],"x-mockingbird":{"supported":true,"parity":{"enabled":false,"reason":"Namespace-scoped local issuer metadata with configured public origin/prefix."}},"parameters":[{"name":"poolId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OIDC discovery.","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}}}}},"/{poolId}/.well-known/jwks.json":{"get":{"operationId":"Jwks","security":[],"x-mockingbird":{"supported":true,"parity":{"enabled":false,"reason":"Namespace-scoped RS256 keys; portable snapshots retain the current
|
|
5346
|
+
var document = JSON.parse(`{"openapi":"3.1.0","info":{"title":"Amazon Cognito Identity Provider (Mockingbird subset)","version":"2016-04-18","description":"Hand-trimmed AWS JSON 1.1 user-pools contract used by the AWS SDK clients."},"servers":[{"url":"https://cognito-idp.us-east-1.amazonaws.com"}],"security":[{"sigv4":[]}],"paths":{"/":{"post":{"operationId":"CognitoRpc","x-mockingbird":{"supported":true,"parity":{"enabled":true,"safe":false}},"parameters":[{"name":"X-Amz-Target","in":"header","required":true,"schema":{"type":"string","pattern":"^AWSCognitoIdentityProviderService\\\\.[A-Za-z]+$"}}],"requestBody":{"required":true,"content":{"application/x-amz-json-1.1":{"schema":{"type":"object","additionalProperties":true}},"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"responses":{"200":{"description":"Operation-specific AWS JSON response.","content":{"application/x-amz-json-1.1":{"schema":{"type":"object","additionalProperties":true}}}},"400":{"description":"Cognito service exception.","content":{"application/x-amz-json-1.1":{"schema":{"type":"object","required":["__type","message"],"properties":{"__type":{"type":"string"},"message":{"type":"string"}},"additionalProperties":true}}}}}}},"/{poolId}/.well-known/openid-configuration":{"get":{"operationId":"Discovery","security":[],"x-mockingbird":{"supported":true,"parity":{"enabled":false,"reason":"Namespace-scoped local issuer metadata with configured public origin/prefix."}},"parameters":[{"name":"poolId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OIDC discovery.","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}}}}},"/{poolId}/.well-known/jwks.json":{"get":{"operationId":"Jwks","security":[],"x-mockingbird":{"supported":true,"parity":{"enabled":false,"reason":"Namespace-scoped RS256 keys; one key signs ID tokens and another signs access tokens as in Cognito; portable snapshots retain the current pair and two prior pairs."}},"parameters":[{"name":"poolId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"JSON Web Key Set.","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}}}}}},"components":{"securitySchemes":{"sigv4":{"type":"apiKey","in":"header","name":"Authorization","description":"AWS SigV4; fixture signatures are accepted and access-key ids select namespaces."}}}}`);
|
|
5347
5347
|
var operationIds = ["CognitoRpc", "Discovery", "Jwks"];
|
|
5348
5348
|
var supportedOperationIds = ["CognitoRpc", "Discovery", "Jwks"];
|
|
5349
5349
|
|
|
@@ -5396,6 +5396,12 @@ var CognitoState = class {
|
|
|
5396
5396
|
token(prefix) {
|
|
5397
5397
|
return this.ids.next(prefix, 32);
|
|
5398
5398
|
}
|
|
5399
|
+
/** A version-4-shaped UUID from the namespace's seeded sequence, so runs stay reproducible. */
|
|
5400
|
+
uuid(sequence) {
|
|
5401
|
+
const hex = [...this.ids.next(`${sequence}:`, 32).slice(sequence.length + 1)].map((char) => (char.charCodeAt(0) % 16).toString(16)).join("");
|
|
5402
|
+
const variant = (Number.parseInt(hex[16], 16) & 3 | 8).toString(16);
|
|
5403
|
+
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-4${hex.slice(13, 16)}-${variant}${hex.slice(17, 20)}-${hex.slice(20, 32)}`;
|
|
5404
|
+
}
|
|
5399
5405
|
};
|
|
5400
5406
|
|
|
5401
5407
|
// src/runtime.ts
|
|
@@ -5498,6 +5504,7 @@ var headers = (requestId) => ({
|
|
|
5498
5504
|
"cache-control": "no-store"
|
|
5499
5505
|
});
|
|
5500
5506
|
var attr = (user, name2) => user.attributes.find((value) => value.Name === name2)?.Value;
|
|
5507
|
+
var KEY_RINGS = { id: "ring", access: "access-ring" };
|
|
5501
5508
|
var publicUser = (user) => ({
|
|
5502
5509
|
Username: user.username,
|
|
5503
5510
|
Attributes: [{ Name: "sub", Value: user.sub }, ...user.attributes],
|
|
@@ -5509,7 +5516,7 @@ var publicUser = (user) => ({
|
|
|
5509
5516
|
var CognitoAPI = class {
|
|
5510
5517
|
state;
|
|
5511
5518
|
signingKeys;
|
|
5512
|
-
initializingKeys;
|
|
5519
|
+
initializingKeys = /* @__PURE__ */ new Map();
|
|
5513
5520
|
publicNamespace;
|
|
5514
5521
|
adminPrefix;
|
|
5515
5522
|
baseUrl;
|
|
@@ -5539,24 +5546,47 @@ var CognitoAPI = class {
|
|
|
5539
5546
|
clearNamespace(this.sqlite, this.namespace);
|
|
5540
5547
|
this.state.seed();
|
|
5541
5548
|
}
|
|
5542
|
-
async keyRing() {
|
|
5543
|
-
const stored = this.signingKeys.get(
|
|
5549
|
+
async keyRing(name2) {
|
|
5550
|
+
const stored = this.signingKeys.get(name2);
|
|
5544
5551
|
if (stored) return stored;
|
|
5545
|
-
|
|
5546
|
-
|
|
5547
|
-
|
|
5548
|
-
|
|
5549
|
-
|
|
5550
|
-
|
|
5551
|
-
|
|
5552
|
-
|
|
5552
|
+
let pending = this.initializingKeys.get(name2);
|
|
5553
|
+
if (!pending) {
|
|
5554
|
+
pending = new CognitoSigner().export().then((key) => {
|
|
5555
|
+
const ring = this.signingKeys.get(name2) ?? [key];
|
|
5556
|
+
this.signingKeys.insert(name2, ring);
|
|
5557
|
+
return ring;
|
|
5558
|
+
}).finally(() => this.initializingKeys.delete(name2));
|
|
5559
|
+
this.initializingKeys.set(name2, pending);
|
|
5560
|
+
}
|
|
5561
|
+
return pending;
|
|
5553
5562
|
}
|
|
5554
5563
|
async rotateSigningKey(retainPrevious = true) {
|
|
5555
|
-
|
|
5556
|
-
|
|
5557
|
-
|
|
5558
|
-
|
|
5559
|
-
|
|
5564
|
+
const rotate = async (name2) => {
|
|
5565
|
+
await this.keyRing(name2);
|
|
5566
|
+
const key = await new CognitoSigner().export();
|
|
5567
|
+
const retained = retainPrevious ? (this.signingKeys.get(name2) ?? []).slice(0, 2) : [];
|
|
5568
|
+
this.signingKeys.insert(name2, [key, ...retained]);
|
|
5569
|
+
return key.kid;
|
|
5570
|
+
};
|
|
5571
|
+
return { kid: await rotate(KEY_RINGS.id), accessKid: await rotate(KEY_RINGS.access) };
|
|
5572
|
+
}
|
|
5573
|
+
/**
|
|
5574
|
+
* Signs each token with its type's current key (picked by `token_use`) and stamps a fresh
|
|
5575
|
+
* `jti` plus the sign-in's `origin_jti` and `event_id`.
|
|
5576
|
+
*/
|
|
5577
|
+
async tokenSigner(origin) {
|
|
5578
|
+
const signers = {
|
|
5579
|
+
id: new CognitoSigner((await this.keyRing(KEY_RINGS.id))[0]),
|
|
5580
|
+
access: new CognitoSigner((await this.keyRing(KEY_RINGS.access))[0])
|
|
5581
|
+
};
|
|
5582
|
+
return {
|
|
5583
|
+
sign: (claims) => signers[claims.token_use].sign({
|
|
5584
|
+
...claims,
|
|
5585
|
+
jti: this.state.uuid("jti"),
|
|
5586
|
+
origin_jti: origin.originJti,
|
|
5587
|
+
event_id: origin.eventId
|
|
5588
|
+
})
|
|
5589
|
+
};
|
|
5560
5590
|
}
|
|
5561
5591
|
issuer(request, poolId = this.poolId) {
|
|
5562
5592
|
const prefix = this.publicNamespace === "default" ? "" : `${this.adminPrefix}/ns/${encodeURIComponent(this.publicNamespace)}`;
|
|
@@ -5577,7 +5607,10 @@ var CognitoAPI = class {
|
|
|
5577
5607
|
passwordValid(value) {
|
|
5578
5608
|
return typeof value === "string" && value.length >= 8 && /[A-Z]/.test(value) && /[a-z]/.test(value) && /\d/.test(value);
|
|
5579
5609
|
}
|
|
5580
|
-
async tokens(request, user, clientId, includeRefresh = true
|
|
5610
|
+
async tokens(request, user, clientId, includeRefresh = true, origin = {
|
|
5611
|
+
originJti: this.state.uuid("origin_jti"),
|
|
5612
|
+
eventId: this.state.uuid("event_id")
|
|
5613
|
+
}) {
|
|
5581
5614
|
const now = Math.floor(this.now() / 1e3);
|
|
5582
5615
|
const issuer = this.issuer(request);
|
|
5583
5616
|
const identities = redactedUser(user).identities;
|
|
@@ -5589,7 +5622,7 @@ var CognitoAPI = class {
|
|
|
5589
5622
|
exp: now + 3600,
|
|
5590
5623
|
...user.groups.length ? { "cognito:groups": user.groups } : {}
|
|
5591
5624
|
};
|
|
5592
|
-
const signer =
|
|
5625
|
+
const signer = await this.tokenSigner(origin);
|
|
5593
5626
|
const access = await signer.sign({
|
|
5594
5627
|
...common,
|
|
5595
5628
|
username: user.username,
|
|
@@ -5621,7 +5654,8 @@ var CognitoAPI = class {
|
|
|
5621
5654
|
clientId,
|
|
5622
5655
|
expires: (now + 2592e3) * 1e3,
|
|
5623
5656
|
revoked: false,
|
|
5624
|
-
kind: "refresh"
|
|
5657
|
+
kind: "refresh",
|
|
5658
|
+
origin
|
|
5625
5659
|
});
|
|
5626
5660
|
}
|
|
5627
5661
|
return {
|
|
@@ -5650,7 +5684,11 @@ var CognitoAPI = class {
|
|
|
5650
5684
|
const jwks = /^\/([^/]+)\/\.well-known\/jwks\.json$/.exec(url.pathname);
|
|
5651
5685
|
if (request.method === "GET" && jwks)
|
|
5652
5686
|
return Response.json({
|
|
5653
|
-
keys: (await Promise.all(
|
|
5687
|
+
keys: (await Promise.all(
|
|
5688
|
+
[...await this.keyRing(KEY_RINGS.id), ...await this.keyRing(KEY_RINGS.access)].map(
|
|
5689
|
+
(key) => new CognitoSigner(key).jwks()
|
|
5690
|
+
)
|
|
5691
|
+
)).flatMap((set) => set.keys)
|
|
5654
5692
|
});
|
|
5655
5693
|
if (request.method !== "POST" || url.pathname !== "/")
|
|
5656
5694
|
return this.error("ResourceNotFoundException", "Not found", 404);
|
|
@@ -5725,7 +5763,13 @@ var CognitoAPI = class {
|
|
|
5725
5763
|
if (session?.kind !== "refresh" || session.clientId !== clientId || session.revoked || session.expires <= this.now() || !user2)
|
|
5726
5764
|
return this.error("NotAuthorizedException", "Invalid Refresh Token");
|
|
5727
5765
|
return this.response({
|
|
5728
|
-
AuthenticationResult: await this.tokens(
|
|
5766
|
+
AuthenticationResult: await this.tokens(
|
|
5767
|
+
request,
|
|
5768
|
+
user2,
|
|
5769
|
+
session.clientId,
|
|
5770
|
+
false,
|
|
5771
|
+
session.origin
|
|
5772
|
+
)
|
|
5729
5773
|
});
|
|
5730
5774
|
}
|
|
5731
5775
|
const user = this.requireUser(parameters.USERNAME);
|
|
@@ -5923,4 +5967,4 @@ export {
|
|
|
5923
5967
|
accessKeyCredential,
|
|
5924
5968
|
CognitoAPI
|
|
5925
5969
|
};
|
|
5926
|
-
//# sourceMappingURL=chunk-
|
|
5970
|
+
//# sourceMappingURL=chunk-7Q2C5EBR.js.map
|