-
Notifications
You must be signed in to change notification settings - Fork 419
chore(backend): Rename M2M namespace from m2mTokens to m2m in api client
#6544
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| --- | ||
| "@clerk/backend": minor | ||
| --- | ||
|
|
||
| Rename M2M namespace from `m2mTokens` to `m2m` in Backend API client | ||
|
|
||
| Before: | ||
|
|
||
| ```ts | ||
| clerkClient.m2mTokens.create() | ||
|
|
||
| clerkClient.m2mTokens.revoke() | ||
|
|
||
| clerkClient.m2mTokens.verifySecret({ secret: 'ak_xxx' }) | ||
| ``` | ||
|
|
||
| After: | ||
|
|
||
| ```ts | ||
| clerkClient.m2m.createToken() | ||
|
|
||
| clerkClient.m2m.revokeToken() | ||
|
|
||
| clerkClient.m2m.verifyToken({ token: 'ak_xxx' }) | ||
| ``` | ||
|
Comment on lines
+5
to
+25
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainDouble-check repo-wide references to old namespace before merging. Ensure there are no lingering references to 🏁 Script executed: #!/bin/bash
# From repo root: find lingering references in source, tests, and docs (excluding node_modules, dist, build)
rg -n --hidden --glob '!**/node_modules/**' --glob '!**/dist/**' --glob '!**/build/**' $'\\bm2mTokens\\b|\\bverifySecret\\b' -SLength of output: 2060 Update all lingering A global search turned up several remaining instances that need to be renamed or removed: • packages/backend/src/tokens/verify.ts:235 Please replace all 🤖 Prompt for AI Agents
Comment on lines
+20
to
+25
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainConfirm and document any additional verifyToken parameters (if applicable). If Run this script to locate the source and confirm the signature, then update the example accordingly: 🏁 Script executed: #!/bin/bash
# Verify verifyToken signature and usages across the repo
rg -n -A2 -B2 $'verifyToken\\s*\\('
rg -n $'verifySecret\\s*\\('Length of output: 13802 Document optional The M2M clerkClient.m2m.createToken()
clerkClient.m2m.revokeToken()
- clerkClient.m2m.verifyToken({ token: 'mt_xxx' })
+ // Verify with the default API key configured on the client
+ clerkClient.m2m.verifyToken({ token: 'mt_xxx' })
+
+ // Verify using an explicit machineSecretKey
+ clerkClient.m2m.verifyToken({
+ token: 'mt_xxx',
+ machineSecretKey: 'sk_test_machine_secret'
+ })
🤖 Prompt for AI Agents |
||
|
|
||
| The `verifySecret()` method is removed. Please use `.verifyToken()` instead. | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -206,7 +206,7 @@ async function verifyM2MToken( | |||||||||||||||||||||||||||||||||||||||||
| ): Promise<MachineTokenReturnType<M2MToken, MachineTokenVerificationError>> { | ||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||
| const client = createBackendApiClient(options); | ||||||||||||||||||||||||||||||||||||||||||
| const verifiedToken = await client.m2mTokens.verifyToken({ token }); | ||||||||||||||||||||||||||||||||||||||||||
| const verifiedToken = await client.m2m.verifyToken({ token }); | ||||||||||||||||||||||||||||||||||||||||||
| return { data: verifiedToken, tokenType: TokenType.M2MToken, errors: undefined }; | ||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+209
to
210
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Pass per-call machineSecretKey and align the exported API type The low-level API supports a per-call machineSecretKey, but it’s not forwarded here. Also, Forward the per-call secret: - const verifiedToken = await client.m2m.verifyToken({ token });
+ const verifiedToken = await client.m2m.verifyToken({ token, machineSecretKey: options.machineSecretKey });And update the exported function type (outside this hunk; Lines 248-249) to accept the machine secret: -export async function verifyMachineAuthToken(token: string, options: VerifyTokenOptions) {
+export async function verifyMachineAuthToken(
+ token: string,
+ options: VerifyTokenOptions & { machineSecretKey?: string },
+) {This preserves generic usage while allowing proper auth for M2M verification without requiring an instance secret. 📝 Committable suggestion
Suggested change
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||
| } catch (err: any) { | ||||||||||||||||||||||||||||||||||||||||||
| return handleClerkAPIError(TokenType.M2MToken, err, 'Machine token not found'); | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Semantic version should be major, not minor (breaking public API).
This rename removes/renames public methods (namespace rename, create→createToken, revoke→revokeToken, verifySecret removed). That’s a breaking change for consumers and warrants a major bump for @clerk/backend.
Apply this diff:
📝 Committable suggestion
🤖 Prompt for AI Agents