@silkweave/auth 2.0.0 → 2.3.0
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/package.json +15 -8
- package/.turbo/turbo-build.log +0 -12
- package/.turbo/turbo-check.log +0 -3
- package/.turbo/turbo-lint.log +0 -2
- package/.turbo/turbo-prepack.log +0 -14
- package/eslint.config.mjs +0 -99
- package/src/errors.ts +0 -18
- package/src/extract.ts +0 -23
- package/src/index.ts +0 -9
- package/src/metadata.ts +0 -17
- package/src/provider/google.ts +0 -41
- package/src/provider/index.ts +0 -5
- package/src/provider/proxy.ts +0 -500
- package/src/provider/store.ts +0 -60
- package/src/provider/types.ts +0 -29
- package/src/provider/uri.ts +0 -13
- package/src/store/json-store.ts +0 -97
- package/src/store/memory-store.ts +0 -50
- package/src/store/redis-store.ts +0 -69
- package/src/types.ts +0 -16
- package/src/validate.ts +0 -89
- package/tsconfig.json +0 -22
- package/tsconfig.tsbuildinfo +0 -1
- package/tsdown.config.ts +0 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@silkweave/auth",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "Silkweave Auth - Bearer token and OAuth 2.1 support for MCP servers",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -8,10 +8,21 @@
|
|
|
8
8
|
"directory": "packages/auth"
|
|
9
9
|
},
|
|
10
10
|
"type": "module",
|
|
11
|
-
"main": "build/index.mjs",
|
|
11
|
+
"main": "./build/index.mjs",
|
|
12
|
+
"types": "./build/index.d.mts",
|
|
13
|
+
"files": [
|
|
14
|
+
"build"
|
|
15
|
+
],
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"@silkweave/source": "./src/index.ts",
|
|
19
|
+
"types": "./build/index.d.mts",
|
|
20
|
+
"default": "./build/index.mjs"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
12
23
|
"dependencies": {
|
|
13
24
|
"jose": "^6.0.0",
|
|
14
|
-
"@silkweave/core": "2.
|
|
25
|
+
"@silkweave/core": "2.3.0"
|
|
15
26
|
},
|
|
16
27
|
"devDependencies": {
|
|
17
28
|
"@eslint/js": "^10.0.1",
|
|
@@ -31,9 +42,5 @@
|
|
|
31
42
|
"typecheck": "tsc --noEmit",
|
|
32
43
|
"lint": "eslint",
|
|
33
44
|
"check": "pnpm lint && pnpm typecheck"
|
|
34
|
-
}
|
|
35
|
-
"exports": {
|
|
36
|
-
".": "./build/index.mjs"
|
|
37
|
-
},
|
|
38
|
-
"types": "./build/index.d.ts"
|
|
45
|
+
}
|
|
39
46
|
}
|
package/.turbo/turbo-build.log
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
[2m$ tsdown[22m
|
|
2
|
-
[34mℹ[39m [34mtsdown v0.21.10[39m powered by [38;2;255;126;23mrolldown v1.0.0-rc.17[39m
|
|
3
|
-
[34mℹ[39m config file: [4m/Users/atomic/projects/silkweave/silkweave/packages/auth/tsdown.config.ts[24m
|
|
4
|
-
[34mℹ[39m entry: [34m./src/index.ts[39m
|
|
5
|
-
[34mℹ[39m tsconfig: [34mtsconfig.json[39m
|
|
6
|
-
[34mℹ[39m Build start
|
|
7
|
-
[34mℹ[39m [2mbuild/[22m[1mindex.mjs[22m [2m24.50 kB[22m [2m│ gzip: 5.84 kB[22m
|
|
8
|
-
[34mℹ[39m [2mbuild/[22mindex.mjs.map [2m46.64 kB[22m [2m│ gzip: 11.33 kB[22m
|
|
9
|
-
[34mℹ[39m [2mbuild/[22mindex.d.mts.map [2m 3.35 kB[22m [2m│ gzip: 0.96 kB[22m
|
|
10
|
-
[34mℹ[39m [2mbuild/[22m[32m[1mindex.d.mts[22m[39m [2m 6.26 kB[22m [2m│ gzip: 1.51 kB[22m
|
|
11
|
-
[34mℹ[39m 4 files, total: 80.75 kB
|
|
12
|
-
[32m✔[39m Build complete in [32m487ms[39m
|
package/.turbo/turbo-check.log
DELETED
package/.turbo/turbo-lint.log
DELETED
package/.turbo/turbo-prepack.log
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
[2m$ pnpm clean && pnpm build[22m
|
|
2
|
-
[2m$ rimraf build[22m
|
|
3
|
-
[2m$ tsdown[22m
|
|
4
|
-
[34mℹ[39m [34mtsdown v0.21.10[39m powered by [38;2;255;126;23mrolldown v1.0.0-rc.17[39m
|
|
5
|
-
[34mℹ[39m config file: [4m/Users/atomic/projects/silkweave/silkweave/packages/auth/tsdown.config.ts[24m
|
|
6
|
-
[34mℹ[39m entry: [34m./src/index.ts[39m
|
|
7
|
-
[34mℹ[39m tsconfig: [34mtsconfig.json[39m
|
|
8
|
-
[34mℹ[39m Build start
|
|
9
|
-
[34mℹ[39m [2mbuild/[22m[1mindex.mjs[22m [2m24.50 kB[22m [2m│ gzip: 5.84 kB[22m
|
|
10
|
-
[34mℹ[39m [2mbuild/[22mindex.mjs.map [2m46.64 kB[22m [2m│ gzip: 11.33 kB[22m
|
|
11
|
-
[34mℹ[39m [2mbuild/[22mindex.d.mts.map [2m 3.35 kB[22m [2m│ gzip: 0.96 kB[22m
|
|
12
|
-
[34mℹ[39m [2mbuild/[22m[32m[1mindex.d.mts[22m[39m [2m 6.26 kB[22m [2m│ gzip: 1.51 kB[22m
|
|
13
|
-
[34mℹ[39m 4 files, total: 80.75 kB
|
|
14
|
-
[32m✔[39m Build complete in [32m669ms[39m
|
package/eslint.config.mjs
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import eslint from '@eslint/js'
|
|
2
|
-
import stylistic from '@stylistic/eslint-plugin'
|
|
3
|
-
import { defineConfig } from 'eslint/config'
|
|
4
|
-
import tseslint from 'typescript-eslint'
|
|
5
|
-
|
|
6
|
-
export default defineConfig(eslint.configs.recommended, tseslint.configs.recommendedTypeChecked, tseslint.configs.stylisticTypeChecked, {
|
|
7
|
-
languageOptions: {
|
|
8
|
-
parserOptions: {
|
|
9
|
-
project: 'tsconfig.json',
|
|
10
|
-
tsconfigRootDir: import.meta.dirname
|
|
11
|
-
}
|
|
12
|
-
},
|
|
13
|
-
plugins: { '@stylistic': stylistic },
|
|
14
|
-
rules: {
|
|
15
|
-
'@stylistic/space-in-parens': ['error'],
|
|
16
|
-
'@stylistic/comma-spacing': ['error'],
|
|
17
|
-
'@stylistic/no-multi-spaces': ['error'],
|
|
18
|
-
'@stylistic/no-trailing-spaces': ['error'],
|
|
19
|
-
'@stylistic/no-whitespace-before-property': ['error'],
|
|
20
|
-
'@stylistic/array-bracket-newline': ['error', 'consistent'],
|
|
21
|
-
'@stylistic/array-bracket-spacing': ['error'],
|
|
22
|
-
'@stylistic/arrow-spacing': ['error'],
|
|
23
|
-
'@stylistic/arrow-parens': ['error', 'always'],
|
|
24
|
-
'@stylistic/block-spacing': ['error', 'always'],
|
|
25
|
-
'@stylistic/brace-style': ['error', '1tbs', { 'allowSingleLine': true }],
|
|
26
|
-
'@stylistic/comma-dangle': ['error', 'never'],
|
|
27
|
-
'@stylistic/key-spacing': ['error'],
|
|
28
|
-
'@stylistic/keyword-spacing': ['error'],
|
|
29
|
-
'@stylistic/member-delimiter-style': ['error', { 'multiline': { 'delimiter': 'none' } }],
|
|
30
|
-
'@stylistic/no-extra-semi': ['error'],
|
|
31
|
-
'@stylistic/indent': ['error', 2],
|
|
32
|
-
'@stylistic/no-multiple-empty-lines': ['error', { 'max': 1, 'maxEOF': 0, 'maxBOF': 0 }],
|
|
33
|
-
'@stylistic/object-curly-spacing': ['error', 'always'],
|
|
34
|
-
'@stylistic/quotes': ['error', 'single'],
|
|
35
|
-
'@stylistic/semi': ['error', 'never'],
|
|
36
|
-
'@stylistic/space-before-blocks': ['error', 'always'],
|
|
37
|
-
'@stylistic/space-before-function-paren': ['error', { 'anonymous': 'always', 'named': 'never', 'asyncArrow': 'always' }],
|
|
38
|
-
'@typescript-eslint/adjacent-overload-signatures': 'error',
|
|
39
|
-
'@typescript-eslint/array-type': 'off',
|
|
40
|
-
'@typescript-eslint/await-thenable': 'error',
|
|
41
|
-
'@typescript-eslint/ban-types': 'off',
|
|
42
|
-
'@typescript-eslint/consistent-type-assertions': 'off',
|
|
43
|
-
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
44
|
-
'@typescript-eslint/explicit-member-accessibility': 'off',
|
|
45
|
-
'@typescript-eslint/no-angle-bracket-type-assertion': 'off',
|
|
46
|
-
'@typescript-eslint/no-empty-function': 'off',
|
|
47
|
-
'@typescript-eslint/no-empty-interface': 'off',
|
|
48
|
-
'@typescript-eslint/no-extra-non-null-assertion': 'error',
|
|
49
|
-
'@typescript-eslint/no-floating-promises': 'off',
|
|
50
|
-
'@typescript-eslint/no-misused-new': 'error',
|
|
51
|
-
'@typescript-eslint/no-misused-promises': 'off',
|
|
52
|
-
'@typescript-eslint/no-namespace': 'off',
|
|
53
|
-
'@typescript-eslint/no-non-null-asserted-optional-chain': 'error',
|
|
54
|
-
'@typescript-eslint/no-non-null-assertion': 'off',
|
|
55
|
-
'@typescript-eslint/no-object-literal-type-assertion': 'off',
|
|
56
|
-
'@typescript-eslint/no-parameter-properties': 'off',
|
|
57
|
-
'@typescript-eslint/no-shadow': 'error',
|
|
58
|
-
'@typescript-eslint/no-triple-slash-reference': 'off',
|
|
59
|
-
'@typescript-eslint/no-unused-vars': ['error', {
|
|
60
|
-
'args': 'all',
|
|
61
|
-
'argsIgnorePattern': '^_',
|
|
62
|
-
'caughtErrors': 'all',
|
|
63
|
-
'caughtErrorsIgnorePattern': '^_',
|
|
64
|
-
'destructuredArrayIgnorePattern': '^_',
|
|
65
|
-
'varsIgnorePattern': '^_',
|
|
66
|
-
'ignoreRestSiblings': true
|
|
67
|
-
}],
|
|
68
|
-
'@typescript-eslint/no-use-before-define': 'off',
|
|
69
|
-
'@typescript-eslint/no-var-requires': 'off',
|
|
70
|
-
'@typescript-eslint/prefer-for-of': 'error',
|
|
71
|
-
'@typescript-eslint/prefer-interface': 'off',
|
|
72
|
-
'@typescript-eslint/prefer-nullish-coalescing': 'off',
|
|
73
|
-
'@typescript-eslint/prefer-optional-chain': 'error',
|
|
74
|
-
'@typescript-eslint/return-await': 'error',
|
|
75
|
-
'@typescript-eslint/unified-signatures': 'error',
|
|
76
|
-
'@typescript-eslint/no-unsafe-return': 'off',
|
|
77
|
-
'@typescript-eslint/no-redundant-type-constituents': 'off',
|
|
78
|
-
'@typescript-eslint/no-unsafe-member-access': 'off',
|
|
79
|
-
'@typescript-eslint/no-unsafe-call': 'off',
|
|
80
|
-
'@typescript-eslint/no-unsafe-argument': 'off',
|
|
81
|
-
'@typescript-eslint/no-unsafe-assignment': 'off',
|
|
82
|
-
'@typescript-eslint/dot-notation': 'off',
|
|
83
|
-
'@typescript-eslint/prefer-regexp-exec': 'off',
|
|
84
|
-
'@typescript-eslint/require-await': 'off',
|
|
85
|
-
'@typescript-eslint/only-throw-error': ['error', {
|
|
86
|
-
'allow': [
|
|
87
|
-
{ from: 'package', name: 'TypedResponse', package: '@remix-run/server-runtime' },
|
|
88
|
-
{ from: 'lib', name: 'Response' }
|
|
89
|
-
]
|
|
90
|
-
}],
|
|
91
|
-
'@typescript-eslint/no-base-to-string': 'off',
|
|
92
|
-
'@typescript-eslint/restrict-template-expressions': 'off'
|
|
93
|
-
}
|
|
94
|
-
}, {
|
|
95
|
-
files: ['eslint.config.mjs'],
|
|
96
|
-
extends: [tseslint.configs.disableTypeChecked]
|
|
97
|
-
}, {
|
|
98
|
-
ignores: ['build', 'tsdown.config.ts']
|
|
99
|
-
})
|
package/src/errors.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export class AuthError extends Error {
|
|
2
|
-
constructor(
|
|
3
|
-
message: string,
|
|
4
|
-
public readonly code: string,
|
|
5
|
-
public readonly statusCode = 401
|
|
6
|
-
) {
|
|
7
|
-
super(message)
|
|
8
|
-
this.name = 'AuthError'
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function invalidToken(message = 'Invalid token') {
|
|
13
|
-
return new AuthError(message, 'invalid_token', 401)
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function insufficientScope(message = 'Insufficient scope') {
|
|
17
|
-
return new AuthError(message, 'insufficient_scope', 403)
|
|
18
|
-
}
|
package/src/extract.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export function extractBearerToken(header: string | null | undefined): string | null {
|
|
2
|
-
if (!header) { return null }
|
|
3
|
-
const match = /^Bearer\s+(.+)$/i.exec(header)
|
|
4
|
-
return match?.[1] ?? null
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export function buildWWWAuthenticate(
|
|
8
|
-
error?: string,
|
|
9
|
-
description?: string,
|
|
10
|
-
resourceMetadataUrl?: string
|
|
11
|
-
): string {
|
|
12
|
-
const parts: string[] = []
|
|
13
|
-
if (error) {
|
|
14
|
-
parts.push(`error="${error}"`)
|
|
15
|
-
}
|
|
16
|
-
if (description) {
|
|
17
|
-
parts.push(`error_description="${description}"`)
|
|
18
|
-
}
|
|
19
|
-
if (resourceMetadataUrl) {
|
|
20
|
-
parts.push(`resource_metadata="${resourceMetadataUrl}"`)
|
|
21
|
-
}
|
|
22
|
-
return parts.length > 0 ? `Bearer ${parts.join(', ')}` : 'Bearer'
|
|
23
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export * from './errors.js'
|
|
2
|
-
export * from './extract.js'
|
|
3
|
-
export * from './metadata.js'
|
|
4
|
-
export * from './provider/index.js'
|
|
5
|
-
export * from './store/json-store.js'
|
|
6
|
-
export * from './store/memory-store.js'
|
|
7
|
-
export * from './store/redis-store.js'
|
|
8
|
-
export * from './types.js'
|
|
9
|
-
export * from './validate.js'
|
package/src/metadata.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export interface ProtectedResourceMetadata {
|
|
2
|
-
resource: string
|
|
3
|
-
authorization_servers: string[]
|
|
4
|
-
scopes_supported?: string[]
|
|
5
|
-
bearer_methods_supported?: string[]
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export function generateProtectedResourceMetadata(
|
|
9
|
-
resourceUrl: string,
|
|
10
|
-
authorizationServers: string[]
|
|
11
|
-
): ProtectedResourceMetadata {
|
|
12
|
-
return {
|
|
13
|
-
resource: resourceUrl,
|
|
14
|
-
authorization_servers: authorizationServers,
|
|
15
|
-
bearer_methods_supported: ['header']
|
|
16
|
-
}
|
|
17
|
-
}
|
package/src/provider/google.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { AuthConfig } from '../types.js'
|
|
2
|
-
import { createOAuthProxy } from './proxy.js'
|
|
3
|
-
import { OAuthStore } from './store.js'
|
|
4
|
-
|
|
5
|
-
export interface GoogleOAuthOptions {
|
|
6
|
-
clientId: string
|
|
7
|
-
clientSecret: string
|
|
8
|
-
resourceUrl: string
|
|
9
|
-
redirectUris: string[]
|
|
10
|
-
requiredScopes?: string[]
|
|
11
|
-
callbackPath?: string
|
|
12
|
-
signingKey?: string
|
|
13
|
-
tokenTtl?: number
|
|
14
|
-
store?: OAuthStore
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function google(options: GoogleOAuthOptions): AuthConfig {
|
|
18
|
-
const provider = createOAuthProxy({
|
|
19
|
-
authorizeUrl: 'https://accounts.google.com/o/oauth2/v2/auth',
|
|
20
|
-
tokenUrl: 'https://oauth2.googleapis.com/token',
|
|
21
|
-
userinfoUrl: 'https://openidconnect.googleapis.com/v1/userinfo',
|
|
22
|
-
clientId: options.clientId,
|
|
23
|
-
clientSecret: options.clientSecret,
|
|
24
|
-
resourceUrl: options.resourceUrl,
|
|
25
|
-
redirectUris: options.redirectUris,
|
|
26
|
-
requiredScopes: options.requiredScopes ?? ['openid', 'email'],
|
|
27
|
-
callbackPath: options.callbackPath,
|
|
28
|
-
signingKey: options.signingKey,
|
|
29
|
-
tokenTtl: options.tokenTtl,
|
|
30
|
-
store: options.store
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
return {
|
|
34
|
-
verifyToken: (token) => provider.verifyToken(token),
|
|
35
|
-
required: true,
|
|
36
|
-
resourceUrl: options.resourceUrl,
|
|
37
|
-
authorizationServers: [options.resourceUrl],
|
|
38
|
-
provider,
|
|
39
|
-
callbackPath: options.callbackPath ?? '/auth/callback'
|
|
40
|
-
}
|
|
41
|
-
}
|