From eadb2368c80e702d125cd8f65ee8fa5e77db9e2c Mon Sep 17 00:00:00 2001 From: JanKulhavy Date: Tue, 1 Dec 2026 16:05:46 +0100 Subject: [PATCH 1/6] test(auth): characterize Bearer vs Token authorization scheme selection Co-Authored-By: Claude Opus 5.5 --- test/make.spec.ts | 9 +++++++++ test/utils.spec.ts | 16 +++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/test/make.spec.ts b/test/make.spec.ts index 78e6409..b2d985f 100644 --- a/test/make.spec.ts +++ b/test/make.spec.ts @@ -22,6 +22,15 @@ describe('Make SDK', () => { expect(await make.users.me()).toBe(null); }); + it('should send a non-key string as Bearer', async () => { + const oauthMake = new Make('eyJhbGciOi.x.y', MAKE_ZONE); + mockFetch('GET https://make.local/api/v2/users/me', { authUser: null }, req => { + expect(req.headers.get('authorization')).toBe('Bearer eyJhbGciOi.x.y'); + }); + + expect(await oauthMake.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 80a0c49..577e281 100644 --- a/test/utils.spec.ts +++ b/test/utils.spec.ts @@ -1,7 +1,21 @@ import { describe, expect, it } from '@jest/globals'; -import { buildUrl, createMakeError } from '../src/utils.js'; +import { buildUrl, createMakeError, isAPIKey } from '../src/utils.js'; describe('Utils', () => { + describe('isAPIKey', () => { + it('should accept a UUIDv4', () => { + expect(isAPIKey('2b58802d-d95a-4715-acd5-b65acaaef470')).toBe(true); + }); + + it('should reject a JWT-shaped token', () => { + expect(isAPIKey('eyJhbGciOi.x.y')).toBe(false); + }); + + it('should reject an empty string', () => { + expect(isAPIKey('')).toBe(false); + }); + }); + describe('buildUrl', () => { it('Should build URL without parameters', () => { expect(buildUrl('https://example.com')).toBe('https://example.com'); From f5eac394a115cc92760acbd1bef1f02f24ab0dca Mon Sep 17 00:00:00 2001 From: JanKulhavy Date: Tue, 1 Dec 2026 16:06:08 +0100 Subject: [PATCH 2/6] test(auth): specify mku_ API keys sent with the Token scheme Co-Authored-By: Claude Opus 5.5 --- test/make.spec.ts | 10 ++++++++++ test/utils.spec.ts | 17 +++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/test/make.spec.ts b/test/make.spec.ts index b2d985f..3648667 100644 --- a/test/make.spec.ts +++ b/test/make.spec.ts @@ -31,6 +31,16 @@ describe('Make SDK', () => { expect(await oauthMake.users.me()).toBe(null); }); + it('should send an mku_ API key with the Token scheme', async () => { + const mkuKey = 'mku_2b58802dd95a4715acd5b65acaaef4701nJqvq'; + const mkuMake = new Make(mkuKey, MAKE_ZONE); + mockFetch('GET https://make.local/api/v2/users/me', { authUser: null }, req => { + expect(req.headers.get('authorization')).toBe(`Token ${mkuKey}`); + }); + + expect(await mkuMake.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 577e281..f2b50eb 100644 --- a/test/utils.spec.ts +++ b/test/utils.spec.ts @@ -7,6 +7,23 @@ describe('Utils', () => { expect(isAPIKey('2b58802d-d95a-4715-acd5-b65acaaef470')).toBe(true); }); + it('should accept an mku_ key with 32 hex characters and a 6 character checksum', () => { + expect(isAPIKey('mku_2b58802dd95a4715acd5b65acaaef4701nJqvq')).toBe(true); + }); + + it.each([ + ['an uppercase prefix', 'MKU_2b58802dd95a4715acd5b65acaaef4701nJqvq'], + ['uppercase hex in the body', 'mku_2B58802dd95a4715acd5b65acaaef4701nJqvq'], + ['a non-hex body character', 'mku_2b58802dd95a4715acd5b65acaaef47g1nJqvq'], + ['a short body', 'mku_2b58802dd95a4715acd5b65acaaef4701nJqv'], + ['a long checksum', 'mku_2b58802dd95a4715acd5b65acaaef4701nJqvqx'], + ['a non-alphanumeric checksum', 'mku_2b58802dd95a4715acd5b65acaaef4701nJqv-'], + ['a missing prefix', '2b58802dd95a4715acd5b65acaaef4701nJqvq'], + ['a trailing newline', 'mku_2b58802dd95a4715acd5b65acaaef4701nJqvq\n'], + ])('should reject an mku_ key with %s', (_label, value) => { + expect(isAPIKey(value)).toBe(false); + }); + it('should reject a JWT-shaped token', () => { expect(isAPIKey('eyJhbGciOi.x.y')).toBe(false); }); From 4ee90374a243ac17dd6463dfc750e24792ff61fb Mon Sep 17 00:00:00 2001 From: JanKulhavy Date: Tue, 1 Dec 2026 16:06:53 +0100 Subject: [PATCH 3/6] feat(auth): recognise mku_-prefixed Make API keys Co-Authored-By: Claude Opus 5.5 --- src/utils.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index e11d216..f52e6f8 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -3,6 +3,12 @@ import type { QueryValue, JSONValue } from './types.js'; /** Regular expression to validate a UUIDv4 string format */ const UUIDv4_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i; +/** + * Regular expression to validate the `mku_` prefixed API key format: 32 hex characters followed by a 6 character checksum. + * The checksum is verified by the Make API, not by the SDK. + */ +const MKU_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 @@ -13,12 +19,14 @@ export function isObject(value: unknown): value is object { } /** - * Determine if a string is in API key format (UUIDv4) + * Determine if a string is in API key format: either a UUIDv4 or an `mku_` prefixed key + * (`mku_` + 32 lowercase hex characters + 6 alphanumeric checksum characters). + * Only the format is checked, the checksum is verified by the Make API. * @param value The string to check - * @returns True if the string matches UUIDv4 format used for API keys + * @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 { - return UUIDv4_RE.test(value); + return UUIDv4_RE.test(value) || MKU_API_KEY_RE.test(value); } /** From c7c27731f0ef19e7e673d80154634db06c0896da Mon Sep 17 00:00:00 2001 From: JanKulhavy Date: Wed, 2 Dec 2026 08:21:56 +0100 Subject: [PATCH 4/6] test(auth): specify mku_ API keys as mku_ + UUIDv4 Co-Authored-By: Claude Opus 5.5 --- test/make.spec.ts | 2 +- test/utils.spec.ts | 23 +++++++++++++---------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/test/make.spec.ts b/test/make.spec.ts index 3648667..de96e81 100644 --- a/test/make.spec.ts +++ b/test/make.spec.ts @@ -32,7 +32,7 @@ describe('Make SDK', () => { }); it('should send an mku_ API key with the Token scheme', async () => { - const mkuKey = 'mku_2b58802dd95a4715acd5b65acaaef4701nJqvq'; + const mkuKey = 'mku_2b58802d-d95a-4715-acd5-b65acaaef470'; const mkuMake = new Make(mkuKey, MAKE_ZONE); mockFetch('GET https://make.local/api/v2/users/me', { authUser: null }, req => { expect(req.headers.get('authorization')).toBe(`Token ${mkuKey}`); diff --git a/test/utils.spec.ts b/test/utils.spec.ts index f2b50eb..e64a8b1 100644 --- a/test/utils.spec.ts +++ b/test/utils.spec.ts @@ -7,19 +7,22 @@ describe('Utils', () => { expect(isAPIKey('2b58802d-d95a-4715-acd5-b65acaaef470')).toBe(true); }); - it('should accept an mku_ key with 32 hex characters and a 6 character checksum', () => { - expect(isAPIKey('mku_2b58802dd95a4715acd5b65acaaef4701nJqvq')).toBe(true); + it('should accept an mku_ key followed by a UUIDv4', () => { + expect(isAPIKey('mku_2b58802d-d95a-4715-acd5-b65acaaef470')).toBe(true); + }); + + it('should accept an mku_ key followed by an uppercase UUIDv4', () => { + expect(isAPIKey('mku_2B58802D-D95A-4715-ACD5-B65ACAAEF470')).toBe(true); }); it.each([ - ['an uppercase prefix', 'MKU_2b58802dd95a4715acd5b65acaaef4701nJqvq'], - ['uppercase hex in the body', 'mku_2B58802dd95a4715acd5b65acaaef4701nJqvq'], - ['a non-hex body character', 'mku_2b58802dd95a4715acd5b65acaaef47g1nJqvq'], - ['a short body', 'mku_2b58802dd95a4715acd5b65acaaef4701nJqv'], - ['a long checksum', 'mku_2b58802dd95a4715acd5b65acaaef4701nJqvqx'], - ['a non-alphanumeric checksum', 'mku_2b58802dd95a4715acd5b65acaaef4701nJqv-'], - ['a missing prefix', '2b58802dd95a4715acd5b65acaaef4701nJqvq'], - ['a trailing newline', 'mku_2b58802dd95a4715acd5b65acaaef4701nJqvq\n'], + ['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_'], + ['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 e02cdae0d01359c9b20202db96f0b5ed1d2fe76b Mon Sep 17 00:00:00 2001 From: JanKulhavy Date: Wed, 2 Dec 2026 08:22:21 +0100 Subject: [PATCH 5/6] feat(auth): accept mku_ + UUIDv4 as the prefixed API key format Co-Authored-By: Claude Opus 5.5 --- src/utils.ts | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index f52e6f8..a9276eb 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -3,11 +3,8 @@ import type { QueryValue, JSONValue } from './types.js'; /** Regular expression to validate a UUIDv4 string format */ const UUIDv4_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i; -/** - * Regular expression to validate the `mku_` prefixed API key format: 32 hex characters followed by a 6 character checksum. - * The checksum is verified by the Make API, not by the SDK. - */ -const MKU_API_KEY_RE = /^mku_[0-9a-f]{32}[0-9A-Za-z]{6}$/; +/** Prefix of Make API keys in the `mku_` format. Case-sensitive, unlike the UUID that follows it. */ +const MKU_API_KEY_PREFIX = 'mku_'; /** * Check if a value is an object (not null and not an array) @@ -19,14 +16,14 @@ 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_` + 32 lowercase hex characters + 6 alphanumeric checksum characters). - * Only the format is checked, the checksum is verified by the Make API. + * 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. * @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 { - return UUIDv4_RE.test(value) || MKU_API_KEY_RE.test(value); + const uuid = value.startsWith(MKU_API_KEY_PREFIX) ? value.slice(MKU_API_KEY_PREFIX.length) : value; + return UUIDv4_RE.test(uuid); } /** From 9e45904c427805cf53719927743944ae9af38d7d Mon Sep 17 00:00:00 2001 From: JanKulhavy Date: Tue, 1 Dec 2026 16:06:58 +0100 Subject: [PATCH 6/6] chore: bump to 1.20.0 Co-Authored-By: Claude Opus 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 eff9287..4000292 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@makehq/sdk", - "version": "1.19.0", + "version": "1.20.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@makehq/sdk", - "version": "1.19.0", + "version": "1.20.0", "license": "MIT", "devDependencies": { "@eslint/js": "^9.22.0", diff --git a/package.json b/package.json index 7804378..e642116 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@makehq/sdk", - "version": "1.19.0", + "version": "1.20.0", "description": "Make TypeScript SDK", "license": "MIT", "author": "Make",