@atproto/oauth-client-node 0.2.24 → 0.3.1
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/README.md +5 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/node-oauth-client.d.ts +16 -5
- package/dist/node-oauth-client.d.ts.map +1 -1
- package/dist/node-oauth-client.js +12 -16
- package/dist/node-oauth-client.js.map +1 -1
- package/dist/util.d.ts +5 -0
- package/dist/util.d.ts.map +1 -0
- package/dist/util.js +3 -0
- package/dist/util.js.map +1 -0
- package/package.json +8 -8
package/README.md
CHANGED
@@ -38,9 +38,11 @@ const client = new NodeOAuthClient({
|
|
38
38
|
policy_uri: 'https://my-app.com/policy',
|
39
39
|
redirect_uris: ['https://my-app.com/callback'],
|
40
40
|
grant_types: ['authorization_code', 'refresh_token'],
|
41
|
+
scope: 'atproto transition:generic',
|
41
42
|
response_types: ['code'],
|
42
43
|
application_type: 'web',
|
43
44
|
token_endpoint_auth_method: 'private_key_jwt',
|
45
|
+
token_endpoint_auth_signing_alg: 'RS256',
|
44
46
|
dpop_bound_access_tokens: true,
|
45
47
|
jwks_uri: 'https://my-app.com/jwks.json',
|
46
48
|
},
|
@@ -48,9 +50,9 @@ const client = new NodeOAuthClient({
|
|
48
50
|
// Used to authenticate the client to the token endpoint. Will be used to
|
49
51
|
// build the jwks object to be exposed on the "jwks_uri" endpoint.
|
50
52
|
keyset: await Promise.all([
|
51
|
-
JoseKey.fromImportable(process.env.PRIVATE_KEY_1),
|
52
|
-
JoseKey.fromImportable(process.env.PRIVATE_KEY_2),
|
53
|
-
JoseKey.fromImportable(process.env.PRIVATE_KEY_3),
|
53
|
+
JoseKey.fromImportable(process.env.PRIVATE_KEY_1, 'key1'),
|
54
|
+
JoseKey.fromImportable(process.env.PRIVATE_KEY_2, 'key2'),
|
55
|
+
JoseKey.fromImportable(process.env.PRIVATE_KEY_3, 'key3'),
|
54
56
|
]),
|
55
57
|
|
56
58
|
// Interface to store authorization state data (during authorization flows)
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oCAAoC,CAAA;AAClD,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA;
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oCAAoC,CAAA;AAClD,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA;AACrC,cAAc,mBAAmB,CAAA;AAEjC,cAAc,wBAAwB,CAAA"}
|
package/dist/index.js
CHANGED
@@ -17,5 +17,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("@atproto-labs/handle-resolver-node"), exports);
|
18
18
|
__exportStar(require("@atproto/jwk-webcrypto"), exports);
|
19
19
|
__exportStar(require("@atproto/oauth-client"), exports);
|
20
|
+
__exportStar(require("@atproto/jwk-jose"), exports);
|
20
21
|
__exportStar(require("./node-oauth-client.js"), exports);
|
21
22
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qEAAkD;AAClD,yDAAsC;AACtC,wDAAqC;
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qEAAkD;AAClD,yDAAsC;AACtC,wDAAqC;AACrC,oDAAiC;AAEjC,yDAAsC"}
|
@@ -1,19 +1,30 @@
|
|
1
|
-
import { OAuthClient, OAuthClientFetchMetadataOptions, OAuthClientOptions, RuntimeLock } from '@atproto/oauth-client';
|
1
|
+
import { HandleResolver, OAuthClient, OAuthClientFetchMetadataOptions, OAuthClientOptions, RuntimeImplementation, RuntimeLock } from '@atproto/oauth-client';
|
2
2
|
import { OAuthResponseMode } from '@atproto/oauth-types';
|
3
3
|
import { AtprotoHandleResolverNodeOptions } from '@atproto-labs/handle-resolver-node';
|
4
4
|
import { NodeSavedSessionStore, NodeSavedStateStore } from './node-dpop-store.js';
|
5
|
+
import { Override } from './util.js';
|
5
6
|
export type * from './node-dpop-store.js';
|
6
7
|
export type { OAuthClientOptions, OAuthResponseMode, RuntimeLock };
|
7
|
-
export type NodeOAuthClientOptions =
|
8
|
+
export type NodeOAuthClientOptions = Override<OAuthClientOptions, {
|
8
9
|
responseMode?: Exclude<OAuthResponseMode, 'fragment'>;
|
9
10
|
stateStore: NodeSavedStateStore;
|
10
11
|
sessionStore: NodeSavedSessionStore;
|
12
|
+
/**
|
13
|
+
* Used to build a {@link NodeOAuthClientOptions.handleResolver} if none is
|
14
|
+
* provided.
|
15
|
+
*/
|
11
16
|
fallbackNameservers?: AtprotoHandleResolverNodeOptions['fallbackNameservers'];
|
17
|
+
handleResolver?: HandleResolver | string | URL;
|
18
|
+
/**
|
19
|
+
* Used to build a {@link NodeOAuthClientOptions.runtimeImplementation} if
|
20
|
+
* none is provided. Pass in `requestLocalLock` from `@atproto/oauth-client`
|
21
|
+
* to mute warning.
|
22
|
+
*/
|
12
23
|
requestLock?: RuntimeLock;
|
13
|
-
|
24
|
+
runtimeImplementation?: RuntimeImplementation;
|
25
|
+
}>;
|
14
26
|
export type NodeOAuthClientFromMetadataOptions = OAuthClientFetchMetadataOptions & Omit<NodeOAuthClientOptions, 'clientMetadata'>;
|
15
27
|
export declare class NodeOAuthClient extends OAuthClient {
|
16
|
-
|
17
|
-
constructor({ fetch, responseMode, fallbackNameservers, stateStore, sessionStore, requestLock, ...options }: NodeOAuthClientOptions);
|
28
|
+
constructor({ requestLock, fallbackNameservers, fetch, responseMode, stateStore, sessionStore, handleResolver, runtimeImplementation, ...options }: NodeOAuthClientOptions);
|
18
29
|
}
|
19
30
|
//# sourceMappingURL=node-oauth-client.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"node-oauth-client.d.ts","sourceRoot":"","sources":["../src/node-oauth-client.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,WAAW,EACX,+BAA+B,EAC/B,kBAAkB,EAClB,WAAW,EACZ,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,EAEL,gCAAgC,EACjC,MAAM,oCAAoC,CAAA;AAC3C,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EAEpB,MAAM,sBAAsB,CAAA;
|
1
|
+
{"version":3,"file":"node-oauth-client.d.ts","sourceRoot":"","sources":["../src/node-oauth-client.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,cAAc,EACd,WAAW,EACX,+BAA+B,EAC/B,kBAAkB,EAClB,qBAAqB,EACrB,WAAW,EACZ,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,EAEL,gCAAgC,EACjC,MAAM,oCAAoC,CAAA;AAC3C,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EAEpB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAEpC,mBAAmB,sBAAsB,CAAA;AACzC,YAAY,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,WAAW,EAAE,CAAA;AAElE,MAAM,MAAM,sBAAsB,GAAG,QAAQ,CAC3C,kBAAkB,EAClB;IACE,YAAY,CAAC,EAAE,OAAO,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAA;IAErD,UAAU,EAAE,mBAAmB,CAAA;IAC/B,YAAY,EAAE,qBAAqB,CAAA;IAEnC;;;OAGG;IACH,mBAAmB,CAAC,EAAE,gCAAgC,CAAC,qBAAqB,CAAC,CAAA;IAE7E,cAAc,CAAC,EAAE,cAAc,GAAG,MAAM,GAAG,GAAG,CAAA;IAE9C;;;;OAIG;IACH,WAAW,CAAC,EAAE,WAAW,CAAA;IAEzB,qBAAqB,CAAC,EAAE,qBAAqB,CAAA;CAC9C,CACF,CAAA;AAED,MAAM,MAAM,kCAAkC,GAC5C,+BAA+B,GAC7B,IAAI,CAAC,sBAAsB,EAAE,gBAAgB,CAAC,CAAA;AAElD,qBAAa,eAAgB,SAAQ,WAAW;gBAClC,EACV,WAAuB,EACvB,mBAA+B,EAE/B,KAAK,EACL,YAAsB,EAEtB,UAAU,EACV,YAAY,EAEZ,cAGE,EAEF,qBAMC,EAED,GAAG,OAAO,EACX,EAAE,sBAAsB;CAkB1B"}
|
@@ -7,12 +7,16 @@ const oauth_client_1 = require("@atproto/oauth-client");
|
|
7
7
|
const handle_resolver_node_1 = require("@atproto-labs/handle-resolver-node");
|
8
8
|
const node_dpop_store_js_1 = require("./node-dpop-store.js");
|
9
9
|
class NodeOAuthClient extends oauth_client_1.OAuthClient {
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
}
|
14
|
-
|
15
|
-
|
10
|
+
constructor({ requestLock = undefined, fallbackNameservers = undefined, fetch, responseMode = 'query', stateStore, sessionStore, handleResolver = new handle_resolver_node_1.AtprotoHandleResolverNode({
|
11
|
+
fetch,
|
12
|
+
fallbackNameservers,
|
13
|
+
}), runtimeImplementation = {
|
14
|
+
requestLock,
|
15
|
+
createKey: (algs) => jwk_jose_1.JoseKey.generate(algs),
|
16
|
+
getRandomValues: node_crypto_1.randomBytes,
|
17
|
+
digest: (bytes, algorithm) => (0, node_crypto_1.createHash)(algorithm.name).update(bytes).digest(),
|
18
|
+
}, ...options }) {
|
19
|
+
if (!runtimeImplementation.requestLock) {
|
16
20
|
// Ok if only one instance of the client is running at a time.
|
17
21
|
console.warn('No lock mechanism provided. Credentials might get revoked.');
|
18
22
|
}
|
@@ -20,16 +24,8 @@ class NodeOAuthClient extends oauth_client_1.OAuthClient {
|
|
20
24
|
...options,
|
21
25
|
fetch,
|
22
26
|
responseMode,
|
23
|
-
handleResolver
|
24
|
-
|
25
|
-
fallbackNameservers,
|
26
|
-
}),
|
27
|
-
runtimeImplementation: {
|
28
|
-
requestLock,
|
29
|
-
createKey: (algs) => jwk_jose_1.JoseKey.generate(algs),
|
30
|
-
getRandomValues: node_crypto_1.randomBytes,
|
31
|
-
digest: (bytes, algorithm) => (0, node_crypto_1.createHash)(algorithm.name).update(bytes).digest(),
|
32
|
-
},
|
27
|
+
handleResolver,
|
28
|
+
runtimeImplementation,
|
33
29
|
stateStore: (0, node_dpop_store_js_1.toDpopKeyStore)(stateStore),
|
34
30
|
sessionStore: (0, node_dpop_store_js_1.toDpopKeyStore)(sessionStore),
|
35
31
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"node-oauth-client.js","sourceRoot":"","sources":["../src/node-oauth-client.ts"],"names":[],"mappings":";;;AAAA,6CAAqD;AACrD,gDAA2C;AAC3C,
|
1
|
+
{"version":3,"file":"node-oauth-client.js","sourceRoot":"","sources":["../src/node-oauth-client.ts"],"names":[],"mappings":";;;AAAA,6CAAqD;AACrD,gDAA2C;AAC3C,wDAO8B;AAE9B,6EAG2C;AAC3C,6DAI6B;AAqC7B,MAAa,eAAgB,SAAQ,0BAAW;IAC9C,YAAY,EACV,WAAW,GAAG,SAAS,EACvB,mBAAmB,GAAG,SAAS,EAE/B,KAAK,EACL,YAAY,GAAG,OAAO,EAEtB,UAAU,EACV,YAAY,EAEZ,cAAc,GAAG,IAAI,gDAAyB,CAAC;QAC7C,KAAK;QACL,mBAAmB;KACpB,CAAC,EAEF,qBAAqB,GAAG;QACtB,WAAW;QACX,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,kBAAO,CAAC,QAAQ,CAAC,IAAI,CAAC;QAC3C,eAAe,EAAE,yBAAW;QAC5B,MAAM,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,CAC3B,IAAA,wBAAU,EAAC,SAAS,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE;KACpD,EAED,GAAG,OAAO,EACa;QACvB,IAAI,CAAC,qBAAqB,CAAC,WAAW,EAAE,CAAC;YACvC,8DAA8D;YAC9D,OAAO,CAAC,IAAI,CAAC,4DAA4D,CAAC,CAAA;QAC5E,CAAC;QAED,KAAK,CAAC;YACJ,GAAG,OAAO;YAEV,KAAK;YACL,YAAY;YACZ,cAAc;YACd,qBAAqB;YAErB,UAAU,EAAE,IAAA,mCAAc,EAAC,UAAU,CAAC;YACtC,YAAY,EAAE,IAAA,mCAAc,EAAC,YAAY,CAAC;SAC3C,CAAC,CAAA;IACJ,CAAC;CACF;AA3CD,0CA2CC"}
|
package/dist/util.d.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAE,GAAG,EAAE,CAAA;AACvD,MAAM,MAAM,QAAQ,CAAC,CAAC,EAAE,CAAC,IAAI,QAAQ,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAA"}
|
package/dist/util.js
ADDED
package/dist/util.js.map
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@atproto/oauth-client-node",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.3.1",
|
4
4
|
"license": "MIT",
|
5
5
|
"description": "ATPROTO OAuth client for the NodeJS",
|
6
6
|
"keywords": [
|
@@ -31,15 +31,15 @@
|
|
31
31
|
"dist"
|
32
32
|
],
|
33
33
|
"dependencies": {
|
34
|
-
"@atproto-labs/did-resolver": "0.
|
35
|
-
"@atproto-labs/handle-resolver-node": "0.1.
|
34
|
+
"@atproto-labs/did-resolver": "0.2.0",
|
35
|
+
"@atproto-labs/handle-resolver-node": "0.1.18",
|
36
36
|
"@atproto-labs/simple-store": "0.2.0",
|
37
37
|
"@atproto/did": "0.1.5",
|
38
|
-
"@atproto/jwk": "0.
|
39
|
-
"@atproto/jwk-jose": "0.1.
|
40
|
-
"@atproto/jwk-webcrypto": "0.1.
|
41
|
-
"@atproto/oauth-client": "0.4.
|
42
|
-
"@atproto/oauth-types": "0.3.
|
38
|
+
"@atproto/jwk": "0.4.0",
|
39
|
+
"@atproto/jwk-jose": "0.1.9",
|
40
|
+
"@atproto/jwk-webcrypto": "0.1.9",
|
41
|
+
"@atproto/oauth-client": "0.4.2",
|
42
|
+
"@atproto/oauth-types": "0.3.1"
|
43
43
|
},
|
44
44
|
"devDependencies": {
|
45
45
|
"typescript": "^5.6.3"
|