Open
Description
For example,
const { token } = await generateAPIKey({
keyPrefix: "mycompany_token",
});
const shortToken = extractShortToken(token); // resolves to 'token'
This is caused by the implementation splitting the token on _
and always fetching the second element:
export const extractShortToken = (token: string) => token.split("_")?.[1]
One possible solution would be to adjust the logic to index backwards from the end:
export const extractShortToken = (token: string) => token.split("_").reverse()?.[1]
There could be a way to use template literal types to prevent the usage of _
in the prefix, but that would be challenging to implement if it was even possible.
Metadata
Metadata
Assignees
Labels
No labels