@atproto/oauth-provider 0.24.0 → 0.24.2
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
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @atproto/oauth-provider
|
|
2
2
|
|
|
3
|
+
## 0.24.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`fc60876`](https://github.com/bluesky-social/atproto/commit/fc60876949cca1ca28e98273ecfc97a151d3ebfc)]:
|
|
8
|
+
- @atproto-labs/fetch-node@0.4.2
|
|
9
|
+
|
|
10
|
+
## 0.24.1
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies [[`f98b78a`](https://github.com/bluesky-social/atproto/commit/f98b78adbc8963e49823117b007422211f6d3ff2), [`f98b78a`](https://github.com/bluesky-social/atproto/commit/f98b78adbc8963e49823117b007422211f6d3ff2), [`f98b78a`](https://github.com/bluesky-social/atproto/commit/f98b78adbc8963e49823117b007422211f6d3ff2), [`f98b78a`](https://github.com/bluesky-social/atproto/commit/f98b78adbc8963e49823117b007422211f6d3ff2), [`f98b78a`](https://github.com/bluesky-social/atproto/commit/f98b78adbc8963e49823117b007422211f6d3ff2)]:
|
|
15
|
+
- @atproto/lex-resolver@0.4.0
|
|
16
|
+
- @atproto/syntax@0.7.7
|
|
17
|
+
- @atproto-labs/fetch-node@0.4.1
|
|
18
|
+
- @atproto/oauth-provider-ui@0.10.7
|
|
19
|
+
- @atproto/lex-document@0.1.14
|
|
20
|
+
- @atproto/oauth-provider-api@0.10.1
|
|
21
|
+
- @atproto/oauth-scopes@0.5.14
|
|
22
|
+
- @atproto/common@0.8.6
|
|
23
|
+
|
|
3
24
|
## 0.24.0
|
|
4
25
|
|
|
5
26
|
### Minor Changes
|
|
@@ -44,11 +44,11 @@ export class LexiconManager {
|
|
|
44
44
|
async getPermissionSet(nsid) {
|
|
45
45
|
const { lexicon } = await this.lexiconGetter.get(nsid);
|
|
46
46
|
if (!lexicon) {
|
|
47
|
-
throw LexResolverError
|
|
47
|
+
throw new LexResolverError(nsid);
|
|
48
48
|
}
|
|
49
49
|
if (lexicon.defs.main?.type !== 'permission-set') {
|
|
50
50
|
const description = 'Lexicon document is not a permission set';
|
|
51
|
-
throw LexResolverError
|
|
51
|
+
throw new LexResolverError(nsid, description);
|
|
52
52
|
}
|
|
53
53
|
return lexicon.defs.main;
|
|
54
54
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lexicon-manager.js","sourceRoot":"","sources":["../../src/lexicon/lexicon-manager.ts"],"names":[],"mappings":"AACA,OAAO,EAAoB,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAC1E,OAAO,EAAE,YAAY,EAAa,MAAM,uBAAuB,CAAA;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAGnD,cAAc,oBAAoB,CAAA;AAElC,MAAM,OAAO,cAAc;IAGzB,YAAY,KAAmB,EAAE,WAAwB;QACvD,IAAI,CAAC,aAAa,GAAG,IAAI,aAAa,CAAC,KAAK,EAAE,WAAW,CAAC,CAAA;IAC5D,CAAC;IAEM,KAAK,CAAC,0BAA0B,CAAC,KAAc;QACpD,MAAM,EAAE,aAAa,EAAE,GAAG,UAAU,CAAC,KAAK,CAAC,CAAA;QAC3C,OAAO,IAAI,CAAC,qBAAqB,CAAC,aAAa,CAAC,CAAA;IAClD,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,eAAe,CAAC,KAAa;QACxC,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,GAAG,UAAU,CAAC,KAAK,CAAC,CAAA;QAExD,8EAA8E;QAC9E,IAAI,CAAC,aAAa,CAAC,MAAM;YAAE,OAAO,KAAK,CAAA;QAEvC,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,qBAAqB,CAAC,aAAa,CAAC,CAAA;Q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AC,SAAuB;IAC1C,OAAO,SAAS,CAAC,IAAI,CAAA;AACvB,CAAC;AAED,MAAM,UAAU,sBAAsB,CAEpC,YAA0B;IAE1B,MAAM,aAAa,GAAG,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC,CAAA;IACjD,IAAI,aAAa;QAAE,OAAO,YAAY,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAA;IAE9D,uEAAuE;IACvE,MAAM,IAAI,KAAK,CAAC,oCAAoC,YAAY,CAAC,IAAI,EAAE,CAAC,CAAA;AAC1E,CAAC","sourcesContent":["import type { LexiconPermissionSet } from '@atproto/lex-document'\nimport { type LexResolver, LexResolverError } from '@atproto/lex-resolver'\nimport { IncludeScope, type Nsid } from '@atproto/oauth-scopes'\nimport { LexiconGetter } from './lexicon-getter.js'\nimport type { LexiconStore } from './lexicon-store.js'\n\nexport * from './lexicon-store.js'\n\nexport class LexiconManager {\n protected readonly lexiconGetter: LexiconGetter\n\n constructor(store: LexiconStore, lexResolver: LexResolver) {\n this.lexiconGetter = new LexiconGetter(store, lexResolver)\n }\n\n public async getPermissionSetsFromScope(scope?: string) {\n const { includeScopes } = parseScope(scope)\n return this.extractPermissionSets(includeScopes)\n }\n\n /**\n * Transforms a scope string from an authorization request into a scope\n * composed solely of granular permission scopes, transforming any NSID\n * into its corresponding permission scopes.\n */\n public async buildTokenScope(scope: string): Promise<string> {\n const { includeScopes, otherScopes } = parseScope(scope)\n\n // If the scope does not contain any \"include:<nsid>\" scopes, return it as-is.\n if (!includeScopes.length) return scope\n\n const permissionSets = await this.extractPermissionSets(includeScopes)\n\n return Array.from(includeScopes)\n .flatMap(nsidToPermissionScopes, permissionSets)\n .concat(otherScopes)\n .join(' ')\n }\n\n /**\n * Given a list of scope values, extract those that are NSIDs and return their\n * corresponding permission sets.\n */\n protected async extractPermissionSets(includeScopes: IncludeScope[]) {\n const nsids = extractNsids(includeScopes)\n return this.getPermissionSets(nsids)\n }\n\n protected async getPermissionSets(nsids: Set<Nsid>) {\n return new Map<string, LexiconPermissionSet>(\n await Promise.all(Array.from(nsids, this.getPermissionSetEntry, this)),\n )\n }\n\n protected async getPermissionSetEntry(\n nsid: Nsid,\n ): Promise<[nsid: Nsid, permissionSet: LexiconPermissionSet]> {\n const permissionSet = await this.getPermissionSet(nsid)\n return [nsid, permissionSet]\n }\n\n protected async getPermissionSet(nsid: Nsid): Promise<LexiconPermissionSet> {\n const { lexicon } = await this.lexiconGetter.get(nsid)\n\n if (!lexicon) {\n throw new LexResolverError(nsid)\n }\n\n if (lexicon.defs.main?.type !== 'permission-set') {\n const description = 'Lexicon document is not a permission set'\n throw new LexResolverError(nsid, description)\n }\n\n return lexicon.defs.main\n }\n}\n\nfunction parseScope(scope?: string) {\n const includeScopes: IncludeScope[] = []\n const otherScopes: string[] = []\n\n if (scope) {\n for (const scopeValue of scope.split(' ')) {\n const parsed = IncludeScope.fromString(scopeValue)\n if (parsed) {\n includeScopes.push(parsed)\n } else {\n otherScopes.push(scopeValue)\n }\n }\n }\n\n return {\n includeScopes,\n otherScopes,\n }\n}\n\nfunction extractNsids(includeScopes: IncludeScope[]): Set<Nsid> {\n return new Set(Array.from(includeScopes, extractNsid))\n}\n\nfunction extractNsid(nsidScope: IncludeScope): Nsid {\n return nsidScope.nsid\n}\n\nexport function nsidToPermissionScopes(\n this: Map<string, LexiconPermissionSet>,\n includeScope: IncludeScope,\n): string[] {\n const permissionSet = this.get(includeScope.nsid)\n if (permissionSet) return includeScope.toScopes(permissionSet)\n\n // Should never happen (mostly there for type safety & future proofing)\n throw new Error(`Missing permission set for NSID: ${includeScope.nsid}`)\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atproto/oauth-provider",
|
|
3
|
-
"version": "0.24.
|
|
3
|
+
"version": "0.24.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Generic OAuth2 and OpenID Connect provider for Node.js. Currently only supports features needed for Atproto.",
|
|
6
6
|
"keywords": [
|
|
@@ -72,21 +72,21 @@
|
|
|
72
72
|
"ioredis": "^5.3.2",
|
|
73
73
|
"jose": "^5.2.0",
|
|
74
74
|
"zod": "^3.23.8",
|
|
75
|
-
"@atproto-labs/fetch-node": "^0.4.
|
|
75
|
+
"@atproto-labs/fetch-node": "^0.4.2",
|
|
76
76
|
"@atproto-labs/pipe": "^0.2.4",
|
|
77
77
|
"@atproto-labs/simple-store": "^0.5.1",
|
|
78
78
|
"@atproto-labs/simple-store-memory": "^0.2.6",
|
|
79
|
-
"@atproto/common": "^0.8.
|
|
79
|
+
"@atproto/common": "^0.8.6",
|
|
80
80
|
"@atproto/did": "^0.5.6",
|
|
81
|
-
"@atproto/jwk": "^0.7.4",
|
|
82
81
|
"@atproto/jwk-jose": "^0.2.4",
|
|
83
|
-
"@atproto/lex-document": "^0.1.
|
|
82
|
+
"@atproto/lex-document": "^0.1.14",
|
|
83
|
+
"@atproto/lex-resolver": "^0.4.0",
|
|
84
|
+
"@atproto/oauth-provider-api": "0.10.1",
|
|
85
|
+
"@atproto/oauth-provider-ui": "0.10.7",
|
|
86
|
+
"@atproto/syntax": "^0.7.7",
|
|
84
87
|
"@atproto/oauth-types": "^0.7.7",
|
|
85
|
-
"@atproto/
|
|
86
|
-
"@atproto/
|
|
87
|
-
"@atproto/oauth-provider-ui": "0.10.6",
|
|
88
|
-
"@atproto/oauth-scopes": "^0.5.13",
|
|
89
|
-
"@atproto/syntax": "^0.7.6"
|
|
88
|
+
"@atproto/oauth-scopes": "^0.5.14",
|
|
89
|
+
"@atproto/jwk": "^0.7.4"
|
|
90
90
|
},
|
|
91
91
|
"devDependencies": {
|
|
92
92
|
"@types/cookie": "^0.6.0",
|