@mastra/auth-auth0 0.0.0-declaration-maps-20250729231921 → 0.0.0-fix-9244-clickhouse-metadata-20251104213434
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +51 -1
- package/README.md +2 -6
- package/dist/index.cjs +12 -248
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +12 -248
- package/dist/index.js.map +1 -1
- package/package.json +19 -5
- package/dist/chunk-32EQK4OY.js +0 -974
- package/dist/chunk-32EQK4OY.js.map +0 -1
- package/dist/chunk-B2N25K77.cjs +0 -979
- package/dist/chunk-B2N25K77.cjs.map +0 -1
- package/dist/chunk-G7ML3FDV.js +0 -9
- package/dist/chunk-G7ML3FDV.js.map +0 -1
- package/dist/chunk-UYPX6MT6.cjs +0 -32
- package/dist/chunk-UYPX6MT6.cjs.map +0 -1
- package/dist/getMachineId-bsd-G4THBH3V.js +0 -23
- package/dist/getMachineId-bsd-G4THBH3V.js.map +0 -1
- package/dist/getMachineId-bsd-GQTQCD37.cjs +0 -25
- package/dist/getMachineId-bsd-GQTQCD37.cjs.map +0 -1
- package/dist/getMachineId-darwin-3P7FJFHV.js +0 -24
- package/dist/getMachineId-darwin-3P7FJFHV.js.map +0 -1
- package/dist/getMachineId-darwin-43NRSF2D.cjs +0 -26
- package/dist/getMachineId-darwin-43NRSF2D.cjs.map +0 -1
- package/dist/getMachineId-linux-H4F4I7A5.js +0 -19
- package/dist/getMachineId-linux-H4F4I7A5.js.map +0 -1
- package/dist/getMachineId-linux-TZ3NOAZ5.cjs +0 -21
- package/dist/getMachineId-linux-TZ3NOAZ5.cjs.map +0 -1
- package/dist/getMachineId-unsupported-EZLLFFYA.cjs +0 -13
- package/dist/getMachineId-unsupported-EZLLFFYA.cjs.map +0 -1
- package/dist/getMachineId-unsupported-T3AERO5R.js +0 -11
- package/dist/getMachineId-unsupported-T3AERO5R.js.map +0 -1
- package/dist/getMachineId-win-B5AEGZT7.cjs +0 -47
- package/dist/getMachineId-win-B5AEGZT7.cjs.map +0 -1
- package/dist/getMachineId-win-Z5QAASBF.js +0 -25
- package/dist/getMachineId-win-Z5QAASBF.js.map +0 -1
- package/eslint.config.js +0 -6
- package/src/index.test.ts +0 -112
- package/src/index.ts +0 -49
- package/tsconfig.build.json +0 -9
- package/tsconfig.json +0 -5
- package/tsup.config.ts +0 -25
- package/vitest.config.ts +0 -8
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { execAsync } from './chunk-G7ML3FDV.js';
|
|
2
|
-
import { diag } from './chunk-32EQK4OY.js';
|
|
3
|
-
import * as process from 'process';
|
|
4
|
-
|
|
5
|
-
async function getMachineId() {
|
|
6
|
-
const args = "QUERY HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography /v MachineGuid";
|
|
7
|
-
let command = "%windir%\\System32\\REG.exe";
|
|
8
|
-
if (process.arch === "ia32" && "PROCESSOR_ARCHITEW6432" in process.env) {
|
|
9
|
-
command = "%windir%\\sysnative\\cmd.exe /c " + command;
|
|
10
|
-
}
|
|
11
|
-
try {
|
|
12
|
-
const result = await execAsync(`${command} ${args}`);
|
|
13
|
-
const parts = result.stdout.split("REG_SZ");
|
|
14
|
-
if (parts.length === 2) {
|
|
15
|
-
return parts[1].trim();
|
|
16
|
-
}
|
|
17
|
-
} catch (e) {
|
|
18
|
-
diag.debug(`error reading machine id: ${e}`);
|
|
19
|
-
}
|
|
20
|
-
return void 0;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export { getMachineId };
|
|
24
|
-
//# sourceMappingURL=getMachineId-win-Z5QAASBF.js.map
|
|
25
|
-
//# sourceMappingURL=getMachineId-win-Z5QAASBF.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../node_modules/.pnpm/@opentelemetry+resources@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/resources/src/detectors/platform/node/machine-id/getMachineId-win.ts"],"names":[],"mappings":";;;;AAoBA,eAAsB,YAAA,GAAY;AAChC,EAAA,MAAM,IAAA,GACJ,4EAAA;AACF,EAAA,IAAI,OAAA,GAAU,6BAAA;AACd,EAAA,IAAY,OAAA,CAAA,IAAA,KAAS,MAAA,IAAU,wBAAA,IAAoC,OAAA,CAAA,GAAA,EAAK;AACtE,IAAA,OAAA,GAAU,kCAAA,GAAqC,OAAA;;AAGjD,EAAA,IAAI;AACF,IAAA,MAAM,SAAS,MAAM,SAAA,CAAU,GAAG,OAAO,CAAA,CAAA,EAAI,IAAI,CAAA,CAAE,CAAA;AACnD,IAAA,MAAM,KAAA,GAAQ,MAAA,CAAO,MAAA,CAAO,KAAA,CAAM,QAAQ,CAAA;AAC1C,IAAA,IAAI,KAAA,CAAM,WAAW,CAAA,EAAG;AACtB,MAAA,OAAO,KAAA,CAAM,CAAC,CAAA,CAAE,IAAA,EAAI;;WAEf,CAAA,EAAG;AACV,IAAA,IAAA,CAAK,KAAA,CAAM,CAAA,0BAAA,EAA6B,CAAC,CAAA,CAAE,CAAA;;AAG7C,EAAA,OAAO,MAAA;AACT","file":"getMachineId-win-Z5QAASBF.js","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as process from 'process';\nimport { execAsync } from './execAsync';\nimport { diag } from '@opentelemetry/api';\n\nexport async function getMachineId(): Promise<string | undefined> {\n const args =\n 'QUERY HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\Microsoft\\\\Cryptography /v MachineGuid';\n let command = '%windir%\\\\System32\\\\REG.exe';\n if (process.arch === 'ia32' && 'PROCESSOR_ARCHITEW6432' in process.env) {\n command = '%windir%\\\\sysnative\\\\cmd.exe /c ' + command;\n }\n\n try {\n const result = await execAsync(`${command} ${args}`);\n const parts = result.stdout.split('REG_SZ');\n if (parts.length === 2) {\n return parts[1].trim();\n }\n } catch (e) {\n diag.debug(`error reading machine id: ${e}`);\n }\n\n return undefined;\n}\n"]}
|
package/eslint.config.js
DELETED
package/src/index.test.ts
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { jwtVerify, createRemoteJWKSet } from 'jose';
|
|
2
|
-
import { beforeEach, afterEach, describe, expect, test, vi } from 'vitest';
|
|
3
|
-
import { MastraAuthAuth0 } from './index';
|
|
4
|
-
|
|
5
|
-
// Mock jose library
|
|
6
|
-
vi.mock('jose', () => ({
|
|
7
|
-
createRemoteJWKSet: vi.fn(),
|
|
8
|
-
jwtVerify: vi.fn(),
|
|
9
|
-
}));
|
|
10
|
-
|
|
11
|
-
describe('MastraAuthAuth0', () => {
|
|
12
|
-
beforeEach(() => {
|
|
13
|
-
process.env.AUTH0_DOMAIN = 'test-domain.auth0.com';
|
|
14
|
-
process.env.AUTH0_AUDIENCE = 'test-audience';
|
|
15
|
-
vi.clearAllMocks();
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
afterEach(() => {
|
|
19
|
-
delete process.env.AUTH0_DOMAIN;
|
|
20
|
-
delete process.env.AUTH0_AUDIENCE;
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
describe('constructor', () => {
|
|
24
|
-
test('initializes with environment variables', () => {
|
|
25
|
-
const auth0 = new MastraAuthAuth0();
|
|
26
|
-
expect(auth0['domain']).toBe('test-domain.auth0.com');
|
|
27
|
-
expect(auth0['audience']).toBe('test-audience');
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
test('initializes with provided options', () => {
|
|
31
|
-
const auth0 = new MastraAuthAuth0({
|
|
32
|
-
domain: 'custom-domain.auth0.com',
|
|
33
|
-
audience: 'custom-audience',
|
|
34
|
-
});
|
|
35
|
-
expect(auth0['domain']).toBe('custom-domain.auth0.com');
|
|
36
|
-
expect(auth0['audience']).toBe('custom-audience');
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
test('throws error when domain is missing', () => {
|
|
40
|
-
delete process.env.AUTH0_DOMAIN;
|
|
41
|
-
expect(() => new MastraAuthAuth0()).toThrow();
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
test('throws error when audience is missing', () => {
|
|
45
|
-
delete process.env.AUTH0_AUDIENCE;
|
|
46
|
-
expect(() => new MastraAuthAuth0()).toThrow();
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
describe('authenticateToken', () => {
|
|
51
|
-
test('verifies JWT and returns payload', async () => {
|
|
52
|
-
const mockJWKS = vi.fn();
|
|
53
|
-
(createRemoteJWKSet as any).mockReturnValue(mockJWKS);
|
|
54
|
-
(jwtVerify as any).mockResolvedValue({
|
|
55
|
-
payload: { sub: 'user123', permissions: ['read'] },
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
const auth0 = new MastraAuthAuth0();
|
|
59
|
-
const result = await auth0.authenticateToken('test-token');
|
|
60
|
-
|
|
61
|
-
expect(createRemoteJWKSet).toHaveBeenCalledWith(new URL('https://test-domain.auth0.com/.well-known/jwks.json'));
|
|
62
|
-
expect(jwtVerify).toHaveBeenCalledWith('test-token', mockJWKS, {
|
|
63
|
-
issuer: 'https://test-domain.auth0.com/',
|
|
64
|
-
audience: 'test-audience',
|
|
65
|
-
});
|
|
66
|
-
expect(result).toEqual({ sub: 'user123', permissions: ['read'] });
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
test('handles JWT verification failure', async () => {
|
|
70
|
-
(createRemoteJWKSet as any).mockReturnValue(vi.fn());
|
|
71
|
-
(jwtVerify as any).mockRejectedValue(new Error('Invalid token'));
|
|
72
|
-
|
|
73
|
-
const auth0 = new MastraAuthAuth0();
|
|
74
|
-
await expect(auth0.authenticateToken('invalid-token')).rejects.toThrow('Invalid token');
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
describe('authorizeUser', () => {
|
|
79
|
-
test('returns true for valid user', async () => {
|
|
80
|
-
const auth0 = new MastraAuthAuth0();
|
|
81
|
-
const result = await auth0.authorizeUser({ sub: 'user123' });
|
|
82
|
-
expect(result).toBe(true);
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
test('returns false for null/undefined user', async () => {
|
|
86
|
-
const auth0 = new MastraAuthAuth0();
|
|
87
|
-
const result = await auth0.authorizeUser(null as any);
|
|
88
|
-
expect(result).toBe(false);
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
test('can be overridden with custom authorization logic', async () => {
|
|
92
|
-
const auth0 = new MastraAuthAuth0({
|
|
93
|
-
async authorizeUser(user: any): Promise<boolean> {
|
|
94
|
-
// Custom authorization logic that checks for specific permissions
|
|
95
|
-
return user?.permissions?.includes('admin') ?? false;
|
|
96
|
-
},
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
// Test with admin user
|
|
100
|
-
const adminUser = { sub: 'user123', permissions: ['admin'] };
|
|
101
|
-
expect(await auth0.authorizeUser(adminUser)).toBe(true);
|
|
102
|
-
|
|
103
|
-
// Test with non-admin user
|
|
104
|
-
const regularUser = { sub: 'user456', permissions: ['read'] };
|
|
105
|
-
expect(await auth0.authorizeUser(regularUser)).toBe(false);
|
|
106
|
-
|
|
107
|
-
// Test with user without permissions
|
|
108
|
-
const noPermissionsUser = { sub: 'user789' };
|
|
109
|
-
expect(await auth0.authorizeUser(noPermissionsUser)).toBe(false);
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
});
|
package/src/index.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { MastraAuthProvider } from '@mastra/core/server';
|
|
2
|
-
import type { MastraAuthProviderOptions } from '@mastra/core/server';
|
|
3
|
-
|
|
4
|
-
import { createRemoteJWKSet, jwtVerify } from 'jose';
|
|
5
|
-
import type { JWTPayload } from 'jose';
|
|
6
|
-
|
|
7
|
-
type Auth0User = JWTPayload;
|
|
8
|
-
|
|
9
|
-
interface MastraAuthAuth0Options extends MastraAuthProviderOptions<Auth0User> {
|
|
10
|
-
domain?: string; // set this to your Auth0 domain
|
|
11
|
-
audience?: string; // set this to your Auth0 API identifier
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export class MastraAuthAuth0 extends MastraAuthProvider<Auth0User> {
|
|
15
|
-
protected domain: string;
|
|
16
|
-
protected audience: string;
|
|
17
|
-
constructor(options?: MastraAuthAuth0Options) {
|
|
18
|
-
super({ name: options?.name ?? 'auth0' });
|
|
19
|
-
|
|
20
|
-
const domain = options?.domain ?? process.env.AUTH0_DOMAIN;
|
|
21
|
-
const audience = options?.audience ?? process.env.AUTH0_AUDIENCE;
|
|
22
|
-
|
|
23
|
-
if (!domain || !audience) {
|
|
24
|
-
throw new Error(
|
|
25
|
-
'Auth0 domain and audience are required, please provide them in the options or set the environment variables AUTH0_DOMAIN and AUTH0_AUDIENCE',
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
this.domain = domain;
|
|
30
|
-
this.audience = audience;
|
|
31
|
-
|
|
32
|
-
this.registerOptions(options);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
async authenticateToken(token: string): Promise<Auth0User | null> {
|
|
36
|
-
const JWKS = createRemoteJWKSet(new URL(`https://${this.domain}/.well-known/jwks.json`));
|
|
37
|
-
|
|
38
|
-
const { payload } = await jwtVerify(token, JWKS, {
|
|
39
|
-
issuer: `https://${this.domain}/`,
|
|
40
|
-
audience: this.audience,
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
return payload;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
async authorizeUser(user: Auth0User) {
|
|
47
|
-
return !!user;
|
|
48
|
-
}
|
|
49
|
-
}
|
package/tsconfig.build.json
DELETED
package/tsconfig.json
DELETED
package/tsup.config.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { spawn } from 'child_process';
|
|
2
|
-
import { promisify } from 'util';
|
|
3
|
-
import { defineConfig } from 'tsup';
|
|
4
|
-
import type { Options } from 'tsup';
|
|
5
|
-
|
|
6
|
-
type Plugin = NonNullable<Options['plugins']>[number];
|
|
7
|
-
|
|
8
|
-
const exec = promisify(spawn);
|
|
9
|
-
|
|
10
|
-
export default defineConfig({
|
|
11
|
-
entry: ['src/index.ts'],
|
|
12
|
-
format: ['esm', 'cjs'],
|
|
13
|
-
clean: true,
|
|
14
|
-
dts: false,
|
|
15
|
-
splitting: true,
|
|
16
|
-
treeshake: {
|
|
17
|
-
preset: 'smallest',
|
|
18
|
-
},
|
|
19
|
-
sourcemap: true,
|
|
20
|
-
onSuccess: async () => {
|
|
21
|
-
await exec('pnpm', ['tsc', '-p', 'tsconfig.build.json'], {
|
|
22
|
-
stdio: 'inherit',
|
|
23
|
-
});
|
|
24
|
-
},
|
|
25
|
-
});
|