From 28b73a5022771b5cac5e51c6bc5425045bf02114 Mon Sep 17 00:00:00 2001 From: JanKulhavy Date: Wed, 2 Dec 2026 16:28:53 +0100 Subject: [PATCH 1/5] test: characterize isAPIKey rejecting malformed checksummed shapes Co-Authored-By: Claude Sonnet 5.5 --- test/utils.spec.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/utils.spec.ts b/test/utils.spec.ts index e64a8b1..fd01009 100644 --- a/test/utils.spec.ts +++ b/test/utils.spec.ts @@ -22,6 +22,11 @@ describe('Utils', () => { ['a non-v4 UUID', 'mku_2b58802d-d95a-1715-acd5-b65acaaef470'], ['an extra trailing character', 'mku_2b58802d-d95a-4715-acd5-b65acaaef470a'], ['no UUID', 'mku_'], + ['an uppercased checksummed body', 'mku_2B58802DD95A4715ACD5B65ACAAEF4701nJqvq'], + ['a 5-character checksum', 'mku_2b58802dd95a4715acd5b65acaaef4701nJqv'], + ['a 7-character checksum', 'mku_2b58802dd95a4715acd5b65acaaef4701nJqvqx'], + ['a non-base62 checksum character', 'mku_2b58802dd95a4715acd5b65acaaef4701nJq-q'], + ['a dashed UUID followed by a checksum', 'mku_2b58802d-d95a-4715-acd5-b65acaaef4701nJqvq'], ['a trailing newline', 'mku_2b58802d-d95a-4715-acd5-b65acaaef470\n'], ])('should reject an mku_ key with %s', (_label, value) => { expect(isAPIKey(value)).toBe(false); From ebcbadad2eefabffd9212f9f73f433dc1dc064b6 Mon Sep 17 00:00:00 2001 From: JanKulhavy Date: Wed, 2 Dec 2026 16:30:36 +0100 Subject: [PATCH 2/5] feat(auth): recognise checksummed mku_ Make API keys Co-Authored-By: Claude Sonnet 5.5 --- src/utils.ts | 15 ++++++++++++--- test/make.spec.ts | 10 ++++++++++ test/utils.spec.ts | 9 ++++++++- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index a9276eb..71e3f70 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -6,6 +6,13 @@ const UUIDv4_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a /** Prefix of Make API keys in the `mku_` format. Case-sensitive, unlike the UUID that follows it. */ const MKU_API_KEY_PREFIX = 'mku_'; +/** + * Shape of the checksummed `mku_` form: 32 lowercase hex characters (the UUID without dashes) and a 6-character + * base62 checksum. Only the shape is checked; the server verifies the checksum, and computing it here would need + * a CRC-32 implementation in runtimes where `node:zlib` is unavailable. + */ +const MKU_CHECKSUMMED_API_KEY_RE = /^mku_[0-9a-f]{32}[0-9A-Za-z]{6}$/; + /** * Check if a value is an object (not null and not an array) * @param value Value to check @@ -16,14 +23,16 @@ export function isObject(value: unknown): value is object { } /** - * Determine if a string is in API key format: either a UUIDv4 or an `mku_` prefixed key (`mku_` + UUIDv4). - * The prefixed form accepts whatever the bare form accepts, including an uppercase UUID. + * Determine if a string is in API key format: a UUIDv4, an `mku_` prefixed key (`mku_` + UUIDv4), or the + * checksummed `mku_` form (`mku_` + 32 lowercase hex characters + 6 base62 checksum characters). + * The prefixed UUID form accepts whatever the bare form accepts, including an uppercase UUID. + * The checksummed form is matched by shape only; its checksum is not verified. * @param value The string to check * @returns True if the string matches one of the API key formats, which are sent with the `Token` scheme */ export function isAPIKey(value: string): boolean { const uuid = value.startsWith(MKU_API_KEY_PREFIX) ? value.slice(MKU_API_KEY_PREFIX.length) : value; - return UUIDv4_RE.test(uuid); + return UUIDv4_RE.test(uuid) || MKU_CHECKSUMMED_API_KEY_RE.test(value); } /** diff --git a/test/make.spec.ts b/test/make.spec.ts index de96e81..0d5b0cb 100644 --- a/test/make.spec.ts +++ b/test/make.spec.ts @@ -41,6 +41,16 @@ describe('Make SDK', () => { expect(await mkuMake.users.me()).toBe(null); }); + it('should send a checksummed mku_ API key with the Token scheme', async () => { + const checksummedKey = 'mku_2b58802dd95a4715acd5b65acaaef4701nJqvq'; + const checksummedMake = new Make(checksummedKey, MAKE_ZONE); + mockFetch('GET https://make.local/api/v2/users/me', { authUser: null }, req => { + expect(req.headers.get('authorization')).toBe(`Token ${checksummedKey}`); + }); + + expect(await checksummedMake.users.me()).toBe(null); + }); + it('Should throw error when status code is 400', async () => { mockFetch( 'GET https://make.local/api/v2/users/me', diff --git a/test/utils.spec.ts b/test/utils.spec.ts index fd01009..78a28d9 100644 --- a/test/utils.spec.ts +++ b/test/utils.spec.ts @@ -15,10 +15,17 @@ describe('Utils', () => { expect(isAPIKey('mku_2B58802D-D95A-4715-ACD5-B65ACAAEF470')).toBe(true); }); + it('should accept an mku_ key in the checksummed form', () => { + expect(isAPIKey('mku_2b58802dd95a4715acd5b65acaaef4701nJqvq')).toBe(true); + }); + + it('should accept a checksummed-shape key without verifying the checksum', () => { + expect(isAPIKey('mku_2b58802dd95a4715acd5b65acaaef4701nJqvr')).toBe(true); + }); + it.each([ ['an uppercase prefix', 'MKU_2b58802d-d95a-4715-acd5-b65acaaef470'], ['an undashed 32 hex body', 'mku_2b58802dd95a4715acd5b65acaaef470'], - ['the old checksum shape', 'mku_2b58802dd95a4715acd5b65acaaef4701nJqvq'], ['a non-v4 UUID', 'mku_2b58802d-d95a-1715-acd5-b65acaaef470'], ['an extra trailing character', 'mku_2b58802d-d95a-4715-acd5-b65acaaef470a'], ['no UUID', 'mku_'], From 2d71c9a1530ccc861f6a77eadfd9096c07ba40df Mon Sep 17 00:00:00 2001 From: JanKulhavy Date: Wed, 2 Dec 2026 16:30:40 +0100 Subject: [PATCH 3/5] chore: bump to 1.21.0 Co-Authored-By: Claude Sonnet 5.5 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4000292..3cc7a8d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@makehq/sdk", - "version": "1.20.0", + "version": "1.21.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@makehq/sdk", - "version": "1.20.0", + "version": "1.21.0", "license": "MIT", "devDependencies": { "@eslint/js": "^9.22.0", diff --git a/package.json b/package.json index e642116..4eed603 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@makehq/sdk", - "version": "1.20.0", + "version": "1.21.0", "description": "Make TypeScript SDK", "license": "MIT", "author": "Make", From 39dbd8e4a7fa1bf9f791b91c199c22425294abc3 Mon Sep 17 00:00:00 2001 From: JanKulhavy Date: Thu, 3 Dec 2026 09:16:17 +0100 Subject: [PATCH 4/5] test: pin the checksummed mku_ key shape against looser patterns Checker findings (self-review). Each added case fails against one plausible wrong pattern that the existing cases let through: - a checksummed body without the mku_ prefix: matching the stripped body instead of the whole value - a leading space: a pattern without the start anchor - an underscore in the checksum: \w instead of the base62 class - a trailing newline after the checksummed form: the multiline flag Co-Authored-By: Claude Mythos 5.2 --- test/utils.spec.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/utils.spec.ts b/test/utils.spec.ts index 78a28d9..b176c08 100644 --- a/test/utils.spec.ts +++ b/test/utils.spec.ts @@ -33,12 +33,19 @@ describe('Utils', () => { ['a 5-character checksum', 'mku_2b58802dd95a4715acd5b65acaaef4701nJqv'], ['a 7-character checksum', 'mku_2b58802dd95a4715acd5b65acaaef4701nJqvqx'], ['a non-base62 checksum character', 'mku_2b58802dd95a4715acd5b65acaaef4701nJq-q'], + ['an underscore in the checksum', 'mku_2b58802dd95a4715acd5b65acaaef4701nJq_q'], ['a dashed UUID followed by a checksum', 'mku_2b58802d-d95a-4715-acd5-b65acaaef4701nJqvq'], ['a trailing newline', 'mku_2b58802d-d95a-4715-acd5-b65acaaef470\n'], + ['a trailing newline after the checksummed form', 'mku_2b58802dd95a4715acd5b65acaaef4701nJqvq\n'], + ['a leading space before the checksummed form', ' mku_2b58802dd95a4715acd5b65acaaef4701nJqvq'], ])('should reject an mku_ key with %s', (_label, value) => { expect(isAPIKey(value)).toBe(false); }); + it('should reject a checksummed body without the mku_ prefix', () => { + expect(isAPIKey('2b58802dd95a4715acd5b65acaaef4701nJqvq')).toBe(false); + }); + it('should reject a JWT-shaped token', () => { expect(isAPIKey('eyJhbGciOi.x.y')).toBe(false); }); From 7109fc1bd7f83f17e954b0c95f508947ae82ccd5 Mon Sep 17 00:00:00 2001 From: JanKulhavy Date: Thu, 3 Dec 2026 09:19:19 +0100 Subject: [PATCH 5/5] test: reject a non-hex letter in the checksummed mku_ key body No existing case put a lowercase letter outside a-f in the 32-character body, so a pattern written with a-z for "lowercase hex" passed every test. Co-Authored-By: Claude Mythos 5.2 --- test/utils.spec.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/test/utils.spec.ts b/test/utils.spec.ts index b176c08..fad2ce3 100644 --- a/test/utils.spec.ts +++ b/test/utils.spec.ts @@ -30,6 +30,7 @@ describe('Utils', () => { ['an extra trailing character', 'mku_2b58802d-d95a-4715-acd5-b65acaaef470a'], ['no UUID', 'mku_'], ['an uppercased checksummed body', 'mku_2B58802DD95A4715ACD5B65ACAAEF4701nJqvq'], + ['a non-hex letter in the checksummed body', 'mku_2b58802dd95a4715acd5b65acaaef47g1nJqvq'], ['a 5-character checksum', 'mku_2b58802dd95a4715acd5b65acaaef4701nJqv'], ['a 7-character checksum', 'mku_2b58802dd95a4715acd5b65acaaef4701nJqvqx'], ['a non-base62 checksum character', 'mku_2b58802dd95a4715acd5b65acaaef4701nJq-q'],