@@ -235,35 +235,5 @@ describe('LegacyTokenHandler', () => {
|
||||
).toThrowErrorMatchingInlineSnapshot(
|
||||
`"Invalid type in config for key 'subject' in 'mock-config', got number, wanted string"`,
|
||||
);
|
||||
|
||||
// // old style add
|
||||
// expect(() =>
|
||||
// handler.addOld(new ConfigReader({ secret: 'b2s=' })),
|
||||
// ).not.toThrow();
|
||||
// expect(() =>
|
||||
// handler.addOld(new ConfigReader({ _missingsecret: true })),
|
||||
// ).toThrowErrorMatchingInlineSnapshot(
|
||||
// `"Missing required config value at 'secret' in 'mock-config'"`,
|
||||
// );
|
||||
// expect(() =>
|
||||
// handler.addOld(new ConfigReader({ secret: '' })),
|
||||
// ).toThrowErrorMatchingInlineSnapshot(
|
||||
// `"Invalid type in config for key 'secret' in 'mock-config', got empty-string, wanted string"`,
|
||||
// );
|
||||
// expect(() =>
|
||||
// handler.addOld(new ConfigReader({ secret: 'has spaces' })),
|
||||
// ).toThrowErrorMatchingInlineSnapshot(
|
||||
// `"Illegal secret, must be a valid base64 string"`,
|
||||
// );
|
||||
// expect(() =>
|
||||
// handler.addOld(new ConfigReader({ secret: 'hasnewline\n' })),
|
||||
// ).toThrowErrorMatchingInlineSnapshot(
|
||||
// `"Illegal secret, must be a valid base64 string"`,
|
||||
// );
|
||||
// expect(() =>
|
||||
// handler.addOld(new ConfigReader({ secret: 3 })),
|
||||
// ).toThrowErrorMatchingInlineSnapshot(
|
||||
// `"Invalid type in config for key 'secret' in 'mock-config', got number, wanted string"`,
|
||||
// );
|
||||
});
|
||||
});
|
||||
|
||||
@@ -50,50 +50,3 @@ export const staticTokenHandler = createExternalTokenHandler<{
|
||||
return undefined;
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
* Handles `type: static` access.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
// export class StaticTokenHandler implements TokenHandler {
|
||||
// #entries = new Map<
|
||||
// string,
|
||||
// {
|
||||
// subject: string;
|
||||
// allAccessRestrictions?: AccessRestrictionsMap;
|
||||
// }
|
||||
// >();
|
||||
|
||||
// constructor(configs: Config[]) {
|
||||
// for (const config of configs) {
|
||||
// this.add(config);
|
||||
// }
|
||||
// }
|
||||
// private add(config: Config) {
|
||||
// const token = config.getString('options.token');
|
||||
// const subject = config.getString('options.subject');
|
||||
// const allAccessRestrictions = readAccessRestrictionsFromConfig(config);
|
||||
|
||||
// if (!token.match(/^\S+$/)) {
|
||||
// throw new Error('Illegal token, must be a set of non-space characters');
|
||||
// } else if (token.length < MIN_TOKEN_LENGTH) {
|
||||
// throw new Error(
|
||||
// `Illegal token, must be at least ${MIN_TOKEN_LENGTH} characters length`,
|
||||
// );
|
||||
// } else if (!subject.match(/^\S+$/)) {
|
||||
// throw new Error('Illegal subject, must be a set of non-space characters');
|
||||
// } else if (this.#entries.has(token)) {
|
||||
// throw new Error(
|
||||
// 'Static externalAccess token was declared more than once',
|
||||
// );
|
||||
// }
|
||||
|
||||
// this.#entries.set(token, { subject, allAccessRestrictions });
|
||||
// return this;
|
||||
// }
|
||||
|
||||
// async verifyToken(token: string) {
|
||||
// return this.#entries.get(token);
|
||||
// }
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user