@atproto/oauth-client-node 0.1.3 → 0.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/README.md CHANGED
@@ -22,9 +22,10 @@ needs of your application, and must respect the [ATPROTO].
22
22
  The `client_metadata` object will typically be built by the backend at startup.
23
23
 
24
24
  ```ts
25
- import { NodeOAuthClientOptions } from '@atproto/oauth-client-node'
25
+ import { NodeOAuthClient, Session } from '@atproto/oauth-client-node'
26
+ import { JoseKey } from '@atproto/jwk-jose'
26
27
 
27
- const client = new NodeOAuthClientOptions({
28
+ const client = new NodeOAuthClient({
28
29
  // This object will be used to build the payload of the /client-metadata.json
29
30
  // endpoint metadata, exposing the client metadata to the OAuth server.
30
31
  clientMetadata: {
@@ -54,16 +55,16 @@ const client = new NodeOAuthClientOptions({
54
55
 
55
56
  // Interface to store authorization state data (during authorization flows)
56
57
  stateStore: {
57
- set(key: string, internalState: NodeSavedState): Promise<void> {},
58
- get(key: string): Promise<NodeSavedState | undefined> {},
59
- del(key: string): Promise<void> {},
58
+ async set(key: string, internalState: NodeSavedState): Promise<void> {},
59
+ async get(key: string): Promise<NodeSavedState | undefined> {},
60
+ async del(key: string): Promise<void> {},
60
61
  },
61
62
 
62
63
  // Interface to store authenticated session data
63
64
  sessionStore: {
64
- set(sub: string, session: Session): Promise<void> {},
65
- get(sub: string): Promise<Session | undefined> {},
66
- del(sub: string): Promise<void> {},
65
+ async set(sub: string, session: Session): Promise<void> {},
66
+ async get(sub: string): Promise<Session | undefined> {},
67
+ async del(sub: string): Promise<void> {},
67
68
  },
68
69
 
69
70
  // A lock to prevent concurrent access to the session store. Optional if only one instance is running.
@@ -170,21 +171,21 @@ Instead of hard-coding the client metadata in your app, you can fetch it when
170
171
  the app starts:
171
172
 
172
173
  ```ts
173
- import { NodeOAuthClientOptions } from '@atproto/oauth-client-node'
174
+ import { NodeOAuthClient } from '@atproto/oauth-client-node'
174
175
 
175
- const client = await NodeOAuthClientOptions.fromClientId({
176
+ const client = await NodeOAuthClient.fromClientId({
176
177
  clientId: 'https://my-app.com/client-metadata.json',
177
178
 
178
179
  stateStore: {
179
- set(key: string, internalState: NodeSavedState): Promise<void> {},
180
- get(key: string): Promise<NodeSavedState | undefined> {},
181
- del(key: string): Promise<void> {},
180
+ async set(key: string, internalState: NodeSavedState): Promise<void> {},
181
+ async get(key: string): Promise<NodeSavedState | undefined> {},
182
+ async del(key: string): Promise<void> {},
182
183
  },
183
184
 
184
185
  sessionStore: {
185
- set(sub: string, session: Session): Promise<void> {},
186
- get(sub: string): Promise<Session | undefined> {},
187
- del(sub: string): Promise<void> {},
186
+ async set(sub: string, session: Session): Promise<void> {},
187
+ async get(sub: string): Promise<Session | undefined> {},
188
+ async del(sub: string): Promise<void> {},
188
189
  },
189
190
 
190
191
  // A lock to prevent concurrent access to the session store. Optional if only one instance is running.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toDpopKeyStore = void 0;
3
+ exports.toDpopKeyStore = toDpopKeyStore;
4
4
  const jwk_jose_1 = require("@atproto/jwk-jose");
5
5
  /**
6
6
  * Utility function that allows to simplify the store interface by exposing a
@@ -26,5 +26,4 @@ function toDpopKeyStore(store) {
26
26
  clear: store.clear?.bind(store),
27
27
  };
28
28
  }
29
- exports.toDpopKeyStore = toDpopKeyStore;
30
29
  //# sourceMappingURL=node-dpop-store.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"node-dpop-store.js","sourceRoot":"","sources":["../src/node-dpop-store.ts"],"names":[],"mappings":";;;AAEA,gDAA2C;AAO3C;;;GAGG;AACH,SAAgB,cAAc,CAC5B,KAAwC;IAExC,OAAO;QACL,KAAK,CAAC,GAAG,CAAC,GAAM,EAAE,EAAE,OAAO,EAAE,GAAG,IAAI,EAAK;YACvC,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAA;YAClC,IAAI,CAAC,OAAO;gBAAE,MAAM,IAAI,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AAC,GAAG,CAAC,GAAG,CAAC,CAAA;YACnC,IAAI,CAAC,MAAM;gBAAE,OAAO,SAAS,CAAA;YAE7B,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAA;YACnC,MAAM,OAAO,GAAG,MAAM,kBAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;YAC9C,OAAO,EAAE,GAAG,IAAI,EAAE,OAAO,EAAkB,CAAA;QAC7C,CAAC;QAED,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC;QAC1B,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC;KAChC,CAAA;AACH,CAAC"}
@@ -4,11 +4,11 @@ import { OAuthResponseMode } from '@atproto/oauth-types';
4
4
  import { NodeSavedSessionStore, NodeSavedStateStore } from './node-dpop-store.js';
5
5
  export type * from './node-dpop-store.js';
6
6
  export type { OAuthClientOptions, OAuthResponseMode, RuntimeLock };
7
- export type NodeOAuthClientOptions = Omit<OAuthClientOptions, 'responseMode' | 'runtimeImplementation' | 'handleResolver' | 'sessionStore' | 'stateStore'> & {
8
- fallbackNameservers?: AtprotoHandleResolverNodeOptions['fallbackNameservers'];
9
- responseMode?: OAuthResponseMode;
7
+ export type NodeOAuthClientOptions = Omit<OAuthClientOptions, 'responseMode' | 'stateStore' | 'sessionStore' | 'runtimeImplementation' | 'handleResolver'> & {
8
+ responseMode?: Exclude<OAuthResponseMode, 'fragment'>;
10
9
  stateStore: NodeSavedStateStore;
11
10
  sessionStore: NodeSavedSessionStore;
11
+ fallbackNameservers?: AtprotoHandleResolverNodeOptions['fallbackNameservers'];
12
12
  requestLock?: RuntimeLock;
13
13
  };
14
14
  export type NodeOAuthClientFromMetadataOptions = OAuthClientFetchMetadataOptions & Omit<NodeOAuthClientOptions, 'clientMetadata'>;
@@ -1 +1 @@
1
- {"version":3,"file":"node-oauth-client.d.ts","sourceRoot":"","sources":["../src/node-oauth-client.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,gCAAgC,EACjC,MAAM,oCAAoC,CAAA;AAE3C,OAAO,EACL,WAAW,EACX,+BAA+B,EAC/B,kBAAkB,EAClB,WAAW,EACZ,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAExD,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EAEpB,MAAM,sBAAsB,CAAA;AAE7B,mBAAmB,sBAAsB,CAAA;AACzC,YAAY,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,WAAW,EAAE,CAAA;AAElE,MAAM,MAAM,sBAAsB,GAAG,IAAI,CACvC,kBAAkB,EAChB,cAAc,GACd,uBAAuB,GACvB,gBAAgB,GAChB,cAAc,GACd,YAAY,CACf,GAAG;IACF,mBAAmB,CAAC,EAAE,gCAAgC,CAAC,qBAAqB,CAAC,CAAA;IAC7E,YAAY,CAAC,EAAE,iBAAiB,CAAA;IAEhC,UAAU,EAAE,mBAAmB,CAAA;IAC/B,YAAY,EAAE,qBAAqB,CAAA;IACnC,WAAW,CAAC,EAAE,WAAW,CAAA;CAC1B,CAAA;AAED,MAAM,MAAM,kCAAkC,GAC5C,+BAA+B,GAC7B,IAAI,CAAC,sBAAsB,EAAE,gBAAgB,CAAC,CAAA;AAElD,qBAAa,eAAgB,SAAQ,WAAW;WACjC,YAAY,CAAC,OAAO,EAAE,kCAAkC;gBAKzD,EACV,KAAK,EACL,YAAsB,EACtB,mBAAmB,EAEnB,UAAU,EACV,YAAY,EACZ,WAAuB,EAEvB,GAAG,OAAO,EACX,EAAE,sBAAsB;CA2B1B"}
1
+ {"version":3,"file":"node-oauth-client.d.ts","sourceRoot":"","sources":["../src/node-oauth-client.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,gCAAgC,EACjC,MAAM,oCAAoC,CAAA;AAE3C,OAAO,EACL,WAAW,EACX,+BAA+B,EAC/B,kBAAkB,EAClB,WAAW,EACZ,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAExD,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EAEpB,MAAM,sBAAsB,CAAA;AAE7B,mBAAmB,sBAAsB,CAAA;AACzC,YAAY,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,WAAW,EAAE,CAAA;AAElE,MAAM,MAAM,sBAAsB,GAAG,IAAI,CACvC,kBAAkB,EAEhB,cAAc,GACd,YAAY,GACZ,cAAc,GAEd,uBAAuB,GACvB,gBAAgB,CACnB,GAAG;IACF,YAAY,CAAC,EAAE,OAAO,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAA;IAErD,UAAU,EAAE,mBAAmB,CAAA;IAC/B,YAAY,EAAE,qBAAqB,CAAA;IAEnC,mBAAmB,CAAC,EAAE,gCAAgC,CAAC,qBAAqB,CAAC,CAAA;IAC7E,WAAW,CAAC,EAAE,WAAW,CAAA;CAC1B,CAAA;AAED,MAAM,MAAM,kCAAkC,GAC5C,+BAA+B,GAC7B,IAAI,CAAC,sBAAsB,EAAE,gBAAgB,CAAC,CAAA;AAElD,qBAAa,eAAgB,SAAQ,WAAW;WACjC,YAAY,CAAC,OAAO,EAAE,kCAAkC;gBAKzD,EACV,KAAK,EACL,YAAsB,EACtB,mBAAmB,EAEnB,UAAU,EACV,YAAY,EACZ,WAAuB,EAEvB,GAAG,OAAO,EACX,EAAE,sBAAsB;CA2B1B"}
@@ -17,6 +17,7 @@ class NodeOAuthClient extends oauth_client_1.OAuthClient {
17
17
  console.warn('No lock mechanism provided. Credentials might get revoked.');
18
18
  }
19
19
  super({
20
+ ...options,
20
21
  fetch,
21
22
  responseMode,
22
23
  handleResolver: new handle_resolver_node_1.AtprotoHandleResolverNode({
@@ -31,7 +32,6 @@ class NodeOAuthClient extends oauth_client_1.OAuthClient {
31
32
  },
32
33
  stateStore: (0, node_dpop_store_js_1.toDpopKeyStore)(stateStore),
33
34
  sessionStore: (0, node_dpop_store_js_1.toDpopKeyStore)(sessionStore),
34
- ...options,
35
35
  });
36
36
  }
37
37
  }
@@ -1 +1 @@
1
- {"version":3,"file":"node-oauth-client.js","sourceRoot":"","sources":["../src/node-oauth-client.ts"],"names":[],"mappings":";;;AAAA,6CAAqD;AAErD,6EAG2C;AAC3C,gDAA2C;AAC3C,wDAK8B;AAG9B,6DAI6B;AAyB7B,MAAa,eAAgB,SAAQ,0BAAW;IAC9C,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,OAA2C;QACnE,MAAM,cAAc,GAAG,MAAM,0BAAW,CAAC,aAAa,CAAC,OAAO,CAAC,CAAA;QAC/D,OAAO,IAAI,eAAe,CAAC,EAAE,GAAG,OAAO,EAAE,cAAc,EAAE,CAAC,CAAA;IAC5D,CAAC;IAED,YAAY,EACV,KAAK,EACL,YAAY,GAAG,OAAO,EACtB,mBAAmB,EAEnB,UAAU,EACV,YAAY,EACZ,WAAW,GAAG,SAAS,EAEvB,GAAG,OAAO,EACa;QACvB,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,8DAA8D;YAC9D,OAAO,CAAC,IAAI,CAAC,4DAA4D,CAAC,CAAA;QAC5E,CAAC;QAED,KAAK,CAAC;YACJ,KAAK;YACL,YAAY;YACZ,cAAc,EAAE,IAAI,gDAAyB,CAAC;gBAC5C,KAAK;gBACL,mBAAmB;aACpB,CAAC;YACF,qBAAqB,EAAE;gBACrB,WAAW;gBACX,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,kBAAO,CAAC,QAAQ,CAAC,IAAI,CAAC;gBAC3C,eAAe,EAAE,yBAAW;gBAC5B,MAAM,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,CAC3B,IAAA,wBAAU,EAAC,SAAS,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE;aACpD;YAED,UAAU,EAAE,IAAA,mCAAc,EAAC,UAAU,CAAC;YACtC,YAAY,EAAE,IA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C,UAAU,CAAC;YACtC,YAAY,EAAE,IAAA,mCAAc,EAAC,YAAY,CAAC;SAC3C,CAAC,CAAA;IACJ,CAAC;CACF;AA3CD,0CA2CC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atproto/oauth-client-node",
3
- "version": "0.1.3",
3
+ "version": "0.2.0",
4
4
  "license": "MIT",
5
5
  "description": "ATPROTO OAuth client for the NodeJS",
6
6
  "keywords": [
@@ -28,18 +28,18 @@
28
28
  "dist"
29
29
  ],
30
30
  "dependencies": {
31
- "@atproto-labs/did-resolver": "0.1.4",
32
- "@atproto-labs/handle-resolver-node": "0.1.5",
33
- "@atproto/did": "0.1.2",
34
- "@atproto/jwk-jose": "0.1.2",
31
+ "@atproto-labs/did-resolver": "0.1.5",
32
+ "@atproto-labs/handle-resolver-node": "0.1.7",
33
+ "@atproto-labs/simple-store": "0.1.1",
34
+ "@atproto/did": "0.1.3",
35
35
  "@atproto/jwk": "0.1.1",
36
+ "@atproto/jwk-jose": "0.1.2",
36
37
  "@atproto/jwk-webcrypto": "0.1.2",
37
- "@atproto/oauth-types": "0.1.5",
38
- "@atproto/oauth-client": "0.2.2",
39
- "@atproto-labs/simple-store": "0.1.1"
38
+ "@atproto/oauth-client": "0.3.0",
39
+ "@atproto/oauth-types": "0.2.0"
40
40
  },
41
41
  "devDependencies": {
42
- "typescript": "^5.3.3"
42
+ "typescript": "^5.6.3"
43
43
  },
44
44
  "scripts": {
45
45
  "build": "tsc --build tsconfig.build.json"