@silkweave/auth 2.0.0 → 2.2.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@silkweave/auth",
3
- "version": "2.0.0",
3
+ "version": "2.2.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.0.0"
25
+ "@silkweave/core": "2.2.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
  }
@@ -1,12 +0,0 @@
1
- $ tsdown
2
- ℹ tsdown v0.21.10 powered by rolldown v1.0.0-rc.17
3
- ℹ config file: /Users/atomic/projects/silkweave/silkweave/packages/auth/tsdown.config.ts
4
- ℹ entry: ./src/index.ts
5
- ℹ tsconfig: tsconfig.json
6
- ℹ Build start
7
- ℹ build/index.mjs 24.50 kB │ gzip: 5.84 kB
8
- ℹ build/index.mjs.map 46.64 kB │ gzip: 11.33 kB
9
- ℹ build/index.d.mts.map  3.35 kB │ gzip: 0.96 kB
10
- ℹ build/index.d.mts  6.26 kB │ gzip: 1.51 kB
11
- ℹ 4 files, total: 80.75 kB
12
- ✔ Build complete in 487ms
@@ -1,3 +0,0 @@
1
- $ pnpm lint && pnpm typecheck
2
- $ eslint
3
- $ tsc --noEmit
@@ -1,2 +0,0 @@
1
-
2
- $ eslint
@@ -1,14 +0,0 @@
1
- $ pnpm clean && pnpm build
2
- $ rimraf build
3
- $ tsdown
4
- ℹ tsdown v0.21.10 powered by rolldown v1.0.0-rc.17
5
- ℹ config file: /Users/atomic/projects/silkweave/silkweave/packages/auth/tsdown.config.ts
6
- ℹ entry: ./src/index.ts
7
- ℹ tsconfig: tsconfig.json
8
- ℹ Build start
9
- ℹ build/index.mjs 24.50 kB │ gzip: 5.84 kB
10
- ℹ build/index.mjs.map 46.64 kB │ gzip: 11.33 kB
11
- ℹ build/index.d.mts.map  3.35 kB │ gzip: 0.96 kB
12
- ℹ build/index.d.mts  6.26 kB │ gzip: 1.51 kB
13
- ℹ 4 files, total: 80.75 kB
14
- ✔ Build complete in 669ms
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
- }
@@ -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
- }
@@ -1,5 +0,0 @@
1
- export * from './google.js'
2
- export * from './proxy.js'
3
- export * from './store.js'
4
- export * from './types.js'
5
- export * from './uri.js'