Skip to content

Commit 2c16e42

Browse files
committed
Revert "Merge pull request #145 from mishamo/main"
This reverts commit 4b74cb1, reversing changes made to 9ca9662.
1 parent a82684a commit 2c16e42

File tree

3 files changed

+1
-303
lines changed

3 files changed

+1
-303
lines changed

src/lib/node-oauth-client-provider.test.ts

Lines changed: 0 additions & 257 deletions
This file was deleted.

src/lib/node-oauth-client-provider.ts

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ export class NodeOAuthClientProvider implements OAuthClientProvider {
2727
private staticOAuthClientMetadata: StaticOAuthClientMetadata
2828
private staticOAuthClientInfo: StaticOAuthClientInformationFull
2929
private authorizeResource: string | undefined
30-
private _scopes: string | undefined
3130
private _state: string
3231

3332
/**
@@ -44,7 +43,6 @@ export class NodeOAuthClientProvider implements OAuthClientProvider {
4443
this.staticOAuthClientMetadata = options.staticOAuthClientMetadata
4544
this.staticOAuthClientInfo = options.staticOAuthClientInfo
4645
this.authorizeResource = options.authorizeResource
47-
this._scopes = options.scopes || 'openid email profile'
4846
this._state = randomUUID()
4947
}
5048

@@ -62,7 +60,6 @@ export class NodeOAuthClientProvider implements OAuthClientProvider {
6260
client_uri: this.clientUri,
6361
software_id: this.softwareId,
6462
software_version: this.softwareVersion,
65-
scope: this._scopes,
6663
...this.staticOAuthClientMetadata,
6764
}
6865
}
@@ -86,50 +83,17 @@ export class NodeOAuthClientProvider implements OAuthClientProvider {
8683
'client_info.json',
8784
OAuthClientInformationFullSchema,
8885
)
89-
90-
// Also load stored scopes from registration (these override options-based scopes)
91-
if (clientInfo) {
92-
const scopesData = await readJsonFile<{ scopes: string }>(this.serverUrlHash, 'scopes.json', {
93-
parseAsync: async (data: any) => data,
94-
})
95-
if (scopesData?.scopes) {
96-
this._scopes = scopesData.scopes
97-
debugLog('Loaded stored scopes from registration', { scopes: this._scopes })
98-
}
99-
}
100-
10186
debugLog('Client info result:', clientInfo ? 'Found' : 'Not found')
10287
return clientInfo
10388
}
10489

105-
/**
106-
* Extracts scopes from OAuth registration response
107-
* @param clientInfo The client registration response
108-
* @returns The extracted scopes as a space-separated string
109-
*/
110-
private extractScopesFromRegistration(clientInfo: any): string {
111-
if (clientInfo.scope) return clientInfo.scope
112-
if (clientInfo.default_scope) return clientInfo.default_scope
113-
if (Array.isArray(clientInfo.scopes)) return clientInfo.scopes.join(' ')
114-
if (Array.isArray(clientInfo.default_scopes)) return clientInfo.default_scopes.join(' ')
115-
116-
return 'openid email profile'
117-
}
118-
11990
/**
12091
* Saves client information
12192
* @param clientInformation The client information to save
12293
*/
12394
async saveClientInformation(clientInformation: OAuthClientInformationFull): Promise<void> {
12495
debugLog('Saving client info', { client_id: clientInformation.client_id })
125-
126-
const scopes = this.extractScopesFromRegistration(clientInformation as any)
127-
128-
debugLog('Extracted scopes from registration response', { scopes })
129-
this._scopes = scopes
130-
13196
await writeJsonFile(this.serverUrlHash, 'client_info.json', clientInformation)
132-
await writeJsonFile(this.serverUrlHash, 'scopes.json', { scopes })
13397
}
13498

13599
/**
@@ -204,11 +168,6 @@ export class NodeOAuthClientProvider implements OAuthClientProvider {
204168
authorizationUrl.searchParams.set('resource', this.authorizeResource)
205169
}
206170

207-
if (this._scopes) {
208-
authorizationUrl.searchParams.set('scope', this._scopes)
209-
debugLog('Added scope parameter to authorization URL', { scopes: this._scopes })
210-
}
211-
212171
log(`\nPlease authorize this client by visiting:\n${authorizationUrl.toString()}\n`)
213172

214173
debugLog('Redirecting to authorization URL', authorizationUrl.toString())
@@ -255,14 +214,12 @@ export class NodeOAuthClientProvider implements OAuthClientProvider {
255214
deleteConfigFile(this.serverUrlHash, 'client_info.json'),
256215
deleteConfigFile(this.serverUrlHash, 'tokens.json'),
257216
deleteConfigFile(this.serverUrlHash, 'code_verifier.txt'),
258-
deleteConfigFile(this.serverUrlHash, 'scopes.json'),
259217
])
260218
debugLog('All credentials invalidated')
261219
break
262220

263221
case 'client':
264-
await Promise.all([deleteConfigFile(this.serverUrlHash, 'client_info.json'), deleteConfigFile(this.serverUrlHash, 'scopes.json')])
265-
this._scopes = this.options.scopes || 'openid email profile'
222+
await deleteConfigFile(this.serverUrlHash, 'client_info.json')
266223
debugLog('Client information invalidated')
267224
break
268225

src/lib/types.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ export interface OAuthProviderOptions {
2929
staticOAuthClientInfo?: StaticOAuthClientInformationFull
3030
/** Resource parameter to send to the authorization server */
3131
authorizeResource?: string
32-
/** OAuth scopes to request (default: 'openid email profile') */
33-
scopes?: string
3432
}
3533

3634
/**

0 commit comments

Comments
 (0)