@atproto/oauth-client-browser 0.4.4 → 0.4.5
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 +619 -0
- package/dist/browser-oauth-client.d.ts +1 -1
- package/dist/browser-oauth-client.d.ts.map +1 -1
- package/dist/browser-oauth-client.js +2 -2
- package/dist/browser-oauth-client.js.map +1 -1
- package/dist/browser-oauth-database.js +1 -1
- package/dist/browser-oauth-database.js.map +1 -1
- package/dist/indexed-db/db.d.ts +2 -2
- package/dist/indexed-db/db.d.ts.map +1 -1
- package/dist/indexed-db/db.js +2 -2
- package/dist/indexed-db/db.js.map +1 -1
- package/dist/indexed-db-store.js +1 -1
- package/dist/indexed-db-store.js.map +1 -1
- package/package.json +17 -16
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,619 @@
|
|
|
1
|
+
# @atproto/oauth-client-browser
|
|
2
|
+
|
|
3
|
+
## 0.4.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#5099](https://github.com/bluesky-social/atproto/pull/5099) [`b43ec31`](https://github.com/bluesky-social/atproto/commit/b43ec31f247f4461725b01226885f88bd430ca07) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Update TypeScript build to rely on references to composite internal projects
|
|
8
|
+
|
|
9
|
+
- [#5099](https://github.com/bluesky-social/atproto/pull/5099) [`b43ec31`](https://github.com/bluesky-social/atproto/commit/b43ec31f247f4461725b01226885f88bd430ca07) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Bundle only necessary files in the NPM tarball, including the `CHANGELOG.md` and `README.md` files (if present).
|
|
10
|
+
|
|
11
|
+
- [#5099](https://github.com/bluesky-social/atproto/pull/5099) [`b43ec31`](https://github.com/bluesky-social/atproto/commit/b43ec31f247f4461725b01226885f88bd430ca07) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Build with `noImplicitAny` enabled
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [[`b43ec31`](https://github.com/bluesky-social/atproto/commit/b43ec31f247f4461725b01226885f88bd430ca07), [`b43ec31`](https://github.com/bluesky-social/atproto/commit/b43ec31f247f4461725b01226885f88bd430ca07), [`b43ec31`](https://github.com/bluesky-social/atproto/commit/b43ec31f247f4461725b01226885f88bd430ca07)]:
|
|
14
|
+
- @atproto-labs/handle-resolver@0.4.4
|
|
15
|
+
- @atproto-labs/did-resolver@0.3.4
|
|
16
|
+
- @atproto-labs/simple-store@0.4.3
|
|
17
|
+
- @atproto/jwk-webcrypto@0.3.3
|
|
18
|
+
- @atproto/oauth-client@0.7.7
|
|
19
|
+
- @atproto/oauth-types@0.7.4
|
|
20
|
+
- @atproto/jwk@0.7.3
|
|
21
|
+
- @atproto/did@0.5.3
|
|
22
|
+
|
|
23
|
+
## 0.4.4
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- Updated dependencies [[`8bcba69`](https://github.com/bluesky-social/atproto/commit/8bcba69cf1f02d09e07b51ce091918312029df63)]:
|
|
28
|
+
- @atproto/oauth-client@0.7.6
|
|
29
|
+
|
|
30
|
+
## 0.4.3
|
|
31
|
+
|
|
32
|
+
### Patch Changes
|
|
33
|
+
|
|
34
|
+
- [#5151](https://github.com/bluesky-social/atproto/pull/5151) [`a51c45d`](https://github.com/bluesky-social/atproto/commit/a51c45d38f6bd7b8765f640e564cf921d52162e7) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Update dependencies
|
|
35
|
+
|
|
36
|
+
- Updated dependencies [[`a51c45d`](https://github.com/bluesky-social/atproto/commit/a51c45d38f6bd7b8765f640e564cf921d52162e7)]:
|
|
37
|
+
- @atproto/did@0.5.2
|
|
38
|
+
- @atproto-labs/did-resolver@0.3.3
|
|
39
|
+
- @atproto-labs/handle-resolver@0.4.3
|
|
40
|
+
- @atproto-labs/simple-store@0.4.2
|
|
41
|
+
- @atproto/jwk@0.7.2
|
|
42
|
+
- @atproto/jwk-webcrypto@0.3.2
|
|
43
|
+
- @atproto/oauth-client@0.7.5
|
|
44
|
+
- @atproto/oauth-types@0.7.3
|
|
45
|
+
|
|
46
|
+
## 0.4.2
|
|
47
|
+
|
|
48
|
+
### Patch Changes
|
|
49
|
+
|
|
50
|
+
- [#4967](https://github.com/bluesky-social/atproto/pull/4967) [`9fc720c`](https://github.com/bluesky-social/atproto/commit/9fc720ce75f3ee88a5e48a9be919b07c7647f6f5) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Use TypeScript 7 to build package
|
|
51
|
+
|
|
52
|
+
- Updated dependencies [[`9fc720c`](https://github.com/bluesky-social/atproto/commit/9fc720ce75f3ee88a5e48a9be919b07c7647f6f5)]:
|
|
53
|
+
- @atproto-labs/handle-resolver@0.4.2
|
|
54
|
+
- @atproto-labs/did-resolver@0.3.2
|
|
55
|
+
- @atproto-labs/simple-store@0.4.1
|
|
56
|
+
- @atproto/jwk-webcrypto@0.3.1
|
|
57
|
+
- @atproto/oauth-client@0.7.3
|
|
58
|
+
- @atproto/oauth-types@0.7.2
|
|
59
|
+
- @atproto/jwk@0.7.1
|
|
60
|
+
- @atproto/did@0.5.1
|
|
61
|
+
|
|
62
|
+
## 0.4.1
|
|
63
|
+
|
|
64
|
+
### Patch Changes
|
|
65
|
+
|
|
66
|
+
- Updated dependencies [[`622d365`](https://github.com/bluesky-social/atproto/commit/622d365aeb240133f40763a3b1c43981112837fc)]:
|
|
67
|
+
- @atproto/did@0.5.0
|
|
68
|
+
- @atproto-labs/did-resolver@0.3.1
|
|
69
|
+
- @atproto-labs/handle-resolver@0.4.1
|
|
70
|
+
- @atproto/oauth-client@0.7.2
|
|
71
|
+
- @atproto/oauth-types@0.7.1
|
|
72
|
+
|
|
73
|
+
## 0.4.0
|
|
74
|
+
|
|
75
|
+
### Minor Changes
|
|
76
|
+
|
|
77
|
+
- [#4929](https://github.com/bluesky-social/atproto/pull/4929) [`f01c59f`](https://github.com/bluesky-social/atproto/commit/f01c59f5bd3f75fb8b47a9eecd4858b84033fb7c) Thanks [@devinivy](https://github.com/devinivy)! - **BREAKING:** Drop support for Node.js 18 and 20. Node.js 22 is now the minimum supported version. Docker images now use Node.js 24.
|
|
78
|
+
|
|
79
|
+
- [#4943](https://github.com/bluesky-social/atproto/pull/4943) [`c459153`](https://github.com/bluesky-social/atproto/commit/c459153395a30ce89e050892c8fab7dc98e019b9) Thanks [@devinivy](https://github.com/devinivy)! - **BREAKING:** Convert to pure ESM. All packages now ship `"type": "module"` with ES module output and Node16 module resolution.
|
|
80
|
+
|
|
81
|
+
Node.js 22's `require()` compatibility layer can still load these packages in CommonJS code.
|
|
82
|
+
|
|
83
|
+
- [#4930](https://github.com/bluesky-social/atproto/pull/4930) [`908bece`](https://github.com/bluesky-social/atproto/commit/908bece169258bff5ad121e5eec157d6ded6f705) Thanks [@devinivy](https://github.com/devinivy)! - Build with TypeScript 6.0.
|
|
84
|
+
|
|
85
|
+
### Patch Changes
|
|
86
|
+
|
|
87
|
+
- Updated dependencies [[`f01c59f`](https://github.com/bluesky-social/atproto/commit/f01c59f5bd3f75fb8b47a9eecd4858b84033fb7c), [`c459153`](https://github.com/bluesky-social/atproto/commit/c459153395a30ce89e050892c8fab7dc98e019b9), [`affb50c`](https://github.com/bluesky-social/atproto/commit/affb50c040b497a12631df99a6310f8e78cab557), [`908bece`](https://github.com/bluesky-social/atproto/commit/908bece169258bff5ad121e5eec157d6ded6f705)]:
|
|
88
|
+
- @atproto/did@0.4.0
|
|
89
|
+
- @atproto/jwk@0.7.0
|
|
90
|
+
- @atproto/jwk-webcrypto@0.3.0
|
|
91
|
+
- @atproto/oauth-client@0.7.0
|
|
92
|
+
- @atproto/oauth-types@0.7.0
|
|
93
|
+
- @atproto-labs/did-resolver@0.3.0
|
|
94
|
+
- @atproto-labs/handle-resolver@0.4.0
|
|
95
|
+
- @atproto-labs/simple-store@0.4.0
|
|
96
|
+
|
|
97
|
+
## 0.3.42
|
|
98
|
+
|
|
99
|
+
### Patch Changes
|
|
100
|
+
|
|
101
|
+
- [#4896](https://github.com/bluesky-social/atproto/pull/4896) [`087515e`](https://github.com/bluesky-social/atproto/commit/087515e6a414aedbf0b7bd36139ed020dc7e0dae) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Allow configuring the popupName and popupFeatures
|
|
102
|
+
|
|
103
|
+
- Updated dependencies [[`087515e`](https://github.com/bluesky-social/atproto/commit/087515e6a414aedbf0b7bd36139ed020dc7e0dae)]:
|
|
104
|
+
- @atproto/oauth-client@0.6.1
|
|
105
|
+
|
|
106
|
+
## 0.3.41
|
|
107
|
+
|
|
108
|
+
### Patch Changes
|
|
109
|
+
|
|
110
|
+
- [#4642](https://github.com/bluesky-social/atproto/pull/4642) [`a23d132`](https://github.com/bluesky-social/atproto/commit/a23d13268ccfd51a54d21256469b8cb43f7b07df) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Properly await disposal of underlying indexed db when disposing a `BrowserOAuthClient`
|
|
111
|
+
|
|
112
|
+
- Updated dependencies [[`a23d132`](https://github.com/bluesky-social/atproto/commit/a23d13268ccfd51a54d21256469b8cb43f7b07df), [`a23d132`](https://github.com/bluesky-social/atproto/commit/a23d13268ccfd51a54d21256469b8cb43f7b07df), [`a23d132`](https://github.com/bluesky-social/atproto/commit/a23d13268ccfd51a54d21256469b8cb43f7b07df), [`a23d132`](https://github.com/bluesky-social/atproto/commit/a23d13268ccfd51a54d21256469b8cb43f7b07df)]:
|
|
113
|
+
- @atproto/oauth-client@0.6.0
|
|
114
|
+
|
|
115
|
+
## 0.3.40
|
|
116
|
+
|
|
117
|
+
### Patch Changes
|
|
118
|
+
|
|
119
|
+
- Updated dependencies [[`d54d707`](https://github.com/bluesky-social/atproto/commit/d54d7077eb32041e1f61c312efa1dd0d768c774e), [`d54d707`](https://github.com/bluesky-social/atproto/commit/d54d7077eb32041e1f61c312efa1dd0d768c774e)]:
|
|
120
|
+
- @atproto/did@0.3.0
|
|
121
|
+
- @atproto-labs/did-resolver@0.2.6
|
|
122
|
+
- @atproto-labs/handle-resolver@0.3.6
|
|
123
|
+
- @atproto/oauth-client@0.5.14
|
|
124
|
+
- @atproto/oauth-types@0.6.2
|
|
125
|
+
|
|
126
|
+
## 0.3.39
|
|
127
|
+
|
|
128
|
+
### Patch Changes
|
|
129
|
+
|
|
130
|
+
- Updated dependencies [[`2f78893`](https://github.com/bluesky-social/atproto/commit/2f78893ace3bbf14d4bac36837820ddb46658c98)]:
|
|
131
|
+
- @atproto/did@0.2.4
|
|
132
|
+
- @atproto/oauth-client@0.5.13
|
|
133
|
+
- @atproto-labs/did-resolver@0.2.5
|
|
134
|
+
- @atproto-labs/handle-resolver@0.3.5
|
|
135
|
+
- @atproto/oauth-types@0.6.1
|
|
136
|
+
|
|
137
|
+
## 0.3.38
|
|
138
|
+
|
|
139
|
+
### Patch Changes
|
|
140
|
+
|
|
141
|
+
- Updated dependencies [[`95ef3c2`](https://github.com/bluesky-social/atproto/commit/95ef3c24e8072e9d49412950b033cb8607764ee0), [`5d8e7a6`](https://github.com/bluesky-social/atproto/commit/5d8e7a6588fc9e57e15d83d47bb45103205e3e41)]:
|
|
142
|
+
- @atproto/oauth-types@0.6.0
|
|
143
|
+
- @atproto/oauth-client@0.5.12
|
|
144
|
+
|
|
145
|
+
## 0.3.37
|
|
146
|
+
|
|
147
|
+
### Patch Changes
|
|
148
|
+
|
|
149
|
+
- Updated dependencies []:
|
|
150
|
+
- @atproto/oauth-client@0.5.11
|
|
151
|
+
|
|
152
|
+
## 0.3.36
|
|
153
|
+
|
|
154
|
+
### Patch Changes
|
|
155
|
+
|
|
156
|
+
- Updated dependencies [[`8012627`](https://github.com/bluesky-social/atproto/commit/8012627a1226cb2f1c753385ad2497b6b43ffd2e), [`d396de0`](https://github.com/bluesky-social/atproto/commit/d396de016d1d55d08cfad1dabd3ffd9eaeea76ea)]:
|
|
157
|
+
- @atproto/did@0.2.3
|
|
158
|
+
- @atproto-labs/did-resolver@0.2.4
|
|
159
|
+
- @atproto-labs/handle-resolver@0.3.4
|
|
160
|
+
- @atproto/oauth-client@0.5.10
|
|
161
|
+
- @atproto/oauth-types@0.5.2
|
|
162
|
+
|
|
163
|
+
## 0.3.35
|
|
164
|
+
|
|
165
|
+
### Patch Changes
|
|
166
|
+
|
|
167
|
+
- Updated dependencies [[`261968fd6`](https://github.com/bluesky-social/atproto/commit/261968fd65014ded613e2bf085d61a7864b8fba7), [`261968fd6`](https://github.com/bluesky-social/atproto/commit/261968fd65014ded613e2bf085d61a7864b8fba7), [`261968fd6`](https://github.com/bluesky-social/atproto/commit/261968fd65014ded613e2bf085d61a7864b8fba7)]:
|
|
168
|
+
- @atproto-labs/handle-resolver@0.3.3
|
|
169
|
+
- @atproto-labs/did-resolver@0.2.3
|
|
170
|
+
- @atproto/did@0.2.2
|
|
171
|
+
- @atproto/oauth-client@0.5.9
|
|
172
|
+
- @atproto/oauth-types@0.5.1
|
|
173
|
+
|
|
174
|
+
## 0.3.34
|
|
175
|
+
|
|
176
|
+
### Patch Changes
|
|
177
|
+
|
|
178
|
+
- Updated dependencies [[`8ff5ec4ca`](https://github.com/bluesky-social/atproto/commit/8ff5ec4caa9a1f5c1e453a416ba2af22d1ee4f58), [`8ff5ec4ca`](https://github.com/bluesky-social/atproto/commit/8ff5ec4caa9a1f5c1e453a416ba2af22d1ee4f58), [`8ff5ec4ca`](https://github.com/bluesky-social/atproto/commit/8ff5ec4caa9a1f5c1e453a416ba2af22d1ee4f58)]:
|
|
179
|
+
- @atproto/oauth-types@0.5.0
|
|
180
|
+
- @atproto/oauth-client@0.5.8
|
|
181
|
+
|
|
182
|
+
## 0.3.33
|
|
183
|
+
|
|
184
|
+
### Patch Changes
|
|
185
|
+
|
|
186
|
+
- [#4220](https://github.com/bluesky-social/atproto/pull/4220) [`fefe70126`](https://github.com/bluesky-social/atproto/commit/fefe70126d0ea82507ac750f669b3478290f186b) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Improve typings of `init` and `signIn` methods
|
|
187
|
+
|
|
188
|
+
- [#4220](https://github.com/bluesky-social/atproto/pull/4220) [`fefe70126`](https://github.com/bluesky-social/atproto/commit/fefe70126d0ea82507ac750f669b3478290f186b) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Use `core-js` to polyfill `Symbol.dispose`
|
|
189
|
+
|
|
190
|
+
- [#4220](https://github.com/bluesky-social/atproto/pull/4220) [`fefe70126`](https://github.com/bluesky-social/atproto/commit/fefe70126d0ea82507ac750f669b3478290f186b) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Avoid module loading error in SSR environments (in which `navigator` is not present)
|
|
191
|
+
|
|
192
|
+
- Updated dependencies [[`09439d7d6`](https://github.com/bluesky-social/atproto/commit/09439d7d688294ad1a0c78a74b901ba2f7c5f4c3), [`fefe70126`](https://github.com/bluesky-social/atproto/commit/fefe70126d0ea82507ac750f669b3478290f186b), [`f560cf226`](https://github.com/bluesky-social/atproto/commit/f560cf2266715666ce5852ab095fcfb3876ae815), [`fefe70126`](https://github.com/bluesky-social/atproto/commit/fefe70126d0ea82507ac750f669b3478290f186b), [`09439d7d6`](https://github.com/bluesky-social/atproto/commit/09439d7d688294ad1a0c78a74b901ba2f7c5f4c3), [`f560cf226`](https://github.com/bluesky-social/atproto/commit/f560cf2266715666ce5852ab095fcfb3876ae815), [`f560cf226`](https://github.com/bluesky-social/atproto/commit/f560cf2266715666ce5852ab095fcfb3876ae815), [`09439d7d6`](https://github.com/bluesky-social/atproto/commit/09439d7d688294ad1a0c78a74b901ba2f7c5f4c3), [`f560cf226`](https://github.com/bluesky-social/atproto/commit/f560cf2266715666ce5852ab095fcfb3876ae815), [`09439d7d6`](https://github.com/bluesky-social/atproto/commit/09439d7d688294ad1a0c78a74b901ba2f7c5f4c3), [`09439d7d6`](https://github.com/bluesky-social/atproto/commit/09439d7d688294ad1a0c78a74b901ba2f7c5f4c3)]:
|
|
193
|
+
- @atproto/oauth-types@0.4.2
|
|
194
|
+
- @atproto/oauth-client@0.5.7
|
|
195
|
+
- @atproto/jwk@0.6.0
|
|
196
|
+
- @atproto/jwk-webcrypto@0.2.0
|
|
197
|
+
- @atproto/did@0.2.1
|
|
198
|
+
- @atproto-labs/did-resolver@0.2.2
|
|
199
|
+
- @atproto-labs/handle-resolver@0.3.2
|
|
200
|
+
|
|
201
|
+
## 0.3.32
|
|
202
|
+
|
|
203
|
+
### Patch Changes
|
|
204
|
+
|
|
205
|
+
- Updated dependencies []:
|
|
206
|
+
- @atproto/oauth-client@0.5.6
|
|
207
|
+
|
|
208
|
+
## 0.3.31
|
|
209
|
+
|
|
210
|
+
### Patch Changes
|
|
211
|
+
|
|
212
|
+
- [#4150](https://github.com/bluesky-social/atproto/pull/4150) [`86c4699da`](https://github.com/bluesky-social/atproto/commit/86c4699da8cf184c251e58c0a3a2612dd676f0ea) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Allow forcing OAuth callback instead of automated init.
|
|
213
|
+
|
|
214
|
+
- Updated dependencies [[`f9dc9aa4c`](https://github.com/bluesky-social/atproto/commit/f9dc9aa4c9eaf2f82d140fbf011a9015e7f1a00d), [`f9dc9aa4c`](https://github.com/bluesky-social/atproto/commit/f9dc9aa4c9eaf2f82d140fbf011a9015e7f1a00d), [`f9dc9aa4c`](https://github.com/bluesky-social/atproto/commit/f9dc9aa4c9eaf2f82d140fbf011a9015e7f1a00d), [`f9dc9aa4c`](https://github.com/bluesky-social/atproto/commit/f9dc9aa4c9eaf2f82d140fbf011a9015e7f1a00d), [`86c4699da`](https://github.com/bluesky-social/atproto/commit/86c4699da8cf184c251e58c0a3a2612dd676f0ea), [`f9dc9aa4c`](https://github.com/bluesky-social/atproto/commit/f9dc9aa4c9eaf2f82d140fbf011a9015e7f1a00d), [`f9dc9aa4c`](https://github.com/bluesky-social/atproto/commit/f9dc9aa4c9eaf2f82d140fbf011a9015e7f1a00d)]:
|
|
215
|
+
- @atproto/did@0.2.0
|
|
216
|
+
- @atproto-labs/simple-store@0.3.0
|
|
217
|
+
- @atproto/oauth-client@0.5.5
|
|
218
|
+
- @atproto-labs/did-resolver@0.2.1
|
|
219
|
+
- @atproto-labs/handle-resolver@0.3.1
|
|
220
|
+
|
|
221
|
+
## 0.3.30
|
|
222
|
+
|
|
223
|
+
### Patch Changes
|
|
224
|
+
|
|
225
|
+
- Updated dependencies [[`6231c8730`](https://github.com/bluesky-social/atproto/commit/6231c8730adb3a4c17dec417e5332b2be61070e5)]:
|
|
226
|
+
- @atproto/oauth-client@0.5.4
|
|
227
|
+
|
|
228
|
+
## 0.3.29
|
|
229
|
+
|
|
230
|
+
### Patch Changes
|
|
231
|
+
|
|
232
|
+
- Updated dependencies []:
|
|
233
|
+
- @atproto/oauth-client@0.5.3
|
|
234
|
+
|
|
235
|
+
## 0.3.28
|
|
236
|
+
|
|
237
|
+
### Patch Changes
|
|
238
|
+
|
|
239
|
+
- Updated dependencies [[`8a88e2c15`](https://github.com/bluesky-social/atproto/commit/8a88e2c15451f5e8239400eeb277ad31d178b8e6), [`8a88e2c15`](https://github.com/bluesky-social/atproto/commit/8a88e2c15451f5e8239400eeb277ad31d178b8e6)]:
|
|
240
|
+
- @atproto/jwk@0.5.0
|
|
241
|
+
- @atproto/jwk-webcrypto@0.1.10
|
|
242
|
+
- @atproto/oauth-client@0.5.2
|
|
243
|
+
- @atproto/oauth-types@0.4.1
|
|
244
|
+
|
|
245
|
+
## 0.3.27
|
|
246
|
+
|
|
247
|
+
### Patch Changes
|
|
248
|
+
|
|
249
|
+
- Updated dependencies []:
|
|
250
|
+
- @atproto/oauth-client@0.5.1
|
|
251
|
+
|
|
252
|
+
## 0.3.26
|
|
253
|
+
|
|
254
|
+
### Patch Changes
|
|
255
|
+
|
|
256
|
+
- Updated dependencies [[`4c2d49917`](https://github.com/bluesky-social/atproto/commit/4c2d499178c61eb8a9d7f658e89fe68fa07f81e7), [`4c2d49917`](https://github.com/bluesky-social/atproto/commit/4c2d499178c61eb8a9d7f658e89fe68fa07f81e7), [`3a1e010e1`](https://github.com/bluesky-social/atproto/commit/3a1e010e148476bfdc0028c37cafbce85a46605a), [`3a1e010e1`](https://github.com/bluesky-social/atproto/commit/3a1e010e148476bfdc0028c37cafbce85a46605a)]:
|
|
257
|
+
- @atproto/oauth-client@0.5.0
|
|
258
|
+
- @atproto/oauth-types@0.4.0
|
|
259
|
+
|
|
260
|
+
## 0.3.25
|
|
261
|
+
|
|
262
|
+
### Patch Changes
|
|
263
|
+
|
|
264
|
+
- Updated dependencies [[`9dac8b0c6`](https://github.com/bluesky-social/atproto/commit/9dac8b0c600520ecb0066ac104787b27668dea47), [`9dac8b0c6`](https://github.com/bluesky-social/atproto/commit/9dac8b0c600520ecb0066ac104787b27668dea47)]:
|
|
265
|
+
- @atproto-labs/handle-resolver@0.3.0
|
|
266
|
+
- @atproto/oauth-client@0.4.2
|
|
267
|
+
|
|
268
|
+
## 0.3.24
|
|
269
|
+
|
|
270
|
+
### Patch Changes
|
|
271
|
+
|
|
272
|
+
- Updated dependencies [[`90b4775fc`](https://github.com/bluesky-social/atproto/commit/90b4775fc9c6959171bc12b961ce9421cc14d6ee), [`90b4775fc`](https://github.com/bluesky-social/atproto/commit/90b4775fc9c6959171bc12b961ce9421cc14d6ee), [`90b4775fc`](https://github.com/bluesky-social/atproto/commit/90b4775fc9c6959171bc12b961ce9421cc14d6ee), [`90b4775fc`](https://github.com/bluesky-social/atproto/commit/90b4775fc9c6959171bc12b961ce9421cc14d6ee), [`90b4775fc`](https://github.com/bluesky-social/atproto/commit/90b4775fc9c6959171bc12b961ce9421cc14d6ee), [`90b4775fc`](https://github.com/bluesky-social/atproto/commit/90b4775fc9c6959171bc12b961ce9421cc14d6ee), [`90b4775fc`](https://github.com/bluesky-social/atproto/commit/90b4775fc9c6959171bc12b961ce9421cc14d6ee)]:
|
|
273
|
+
- @atproto-labs/handle-resolver@0.2.0
|
|
274
|
+
- @atproto/oauth-client@0.4.1
|
|
275
|
+
- @atproto-labs/did-resolver@0.2.0
|
|
276
|
+
- @atproto/jwk@0.4.0
|
|
277
|
+
- @atproto/jwk-webcrypto@0.1.9
|
|
278
|
+
- @atproto/oauth-types@0.3.1
|
|
279
|
+
|
|
280
|
+
## 0.3.23
|
|
281
|
+
|
|
282
|
+
### Patch Changes
|
|
283
|
+
|
|
284
|
+
- Updated dependencies [[`349b59175`](https://github.com/bluesky-social/atproto/commit/349b59175e82ceb9500ae7c6a9a0b9b6aec9d1b6), [`349b59175`](https://github.com/bluesky-social/atproto/commit/349b59175e82ceb9500ae7c6a9a0b9b6aec9d1b6), [`349b59175`](https://github.com/bluesky-social/atproto/commit/349b59175e82ceb9500ae7c6a9a0b9b6aec9d1b6), [`349b59175`](https://github.com/bluesky-social/atproto/commit/349b59175e82ceb9500ae7c6a9a0b9b6aec9d1b6), [`349b59175`](https://github.com/bluesky-social/atproto/commit/349b59175e82ceb9500ae7c6a9a0b9b6aec9d1b6), [`349b59175`](https://github.com/bluesky-social/atproto/commit/349b59175e82ceb9500ae7c6a9a0b9b6aec9d1b6), [`349b59175`](https://github.com/bluesky-social/atproto/commit/349b59175e82ceb9500ae7c6a9a0b9b6aec9d1b6)]:
|
|
285
|
+
- @atproto/oauth-types@0.3.0
|
|
286
|
+
- @atproto/oauth-client@0.4.0
|
|
287
|
+
- @atproto/jwk@0.3.0
|
|
288
|
+
- @atproto/jwk-webcrypto@0.1.8
|
|
289
|
+
|
|
290
|
+
## 0.3.22
|
|
291
|
+
|
|
292
|
+
### Patch Changes
|
|
293
|
+
|
|
294
|
+
- Updated dependencies [[`192f3ab89`](https://github.com/bluesky-social/atproto/commit/192f3ab89c943216683541f42cc1332e9c305eee), [`4e96e2c7b`](https://github.com/bluesky-social/atproto/commit/4e96e2c7b7cc0231607d3065c95704069c4ca2a2)]:
|
|
295
|
+
- @atproto/oauth-client@0.3.22
|
|
296
|
+
|
|
297
|
+
## 0.3.21
|
|
298
|
+
|
|
299
|
+
### Patch Changes
|
|
300
|
+
|
|
301
|
+
- Updated dependencies [[`cd4bed3c9`](https://github.com/bluesky-social/atproto/commit/cd4bed3c9e68878c3f79620fe19f6994ebcb932e)]:
|
|
302
|
+
- @atproto/oauth-client@0.3.21
|
|
303
|
+
|
|
304
|
+
## 0.3.20
|
|
305
|
+
|
|
306
|
+
### Patch Changes
|
|
307
|
+
|
|
308
|
+
- Updated dependencies [[`3fa2ee3b6`](https://github.com/bluesky-social/atproto/commit/3fa2ee3b6a382709b10921da53e69a901bccbb05), [`a3b24ca77`](https://github.com/bluesky-social/atproto/commit/a3b24ca77ca24ac19b17cf9ee2a5ca9612ccf96c), [`a3b24ca77`](https://github.com/bluesky-social/atproto/commit/a3b24ca77ca24ac19b17cf9ee2a5ca9612ccf96c)]:
|
|
309
|
+
- @atproto/jwk@0.2.0
|
|
310
|
+
- @atproto/oauth-types@0.2.8
|
|
311
|
+
- @atproto/oauth-client@0.3.20
|
|
312
|
+
- @atproto/jwk-webcrypto@0.1.7
|
|
313
|
+
|
|
314
|
+
## 0.3.19
|
|
315
|
+
|
|
316
|
+
### Patch Changes
|
|
317
|
+
|
|
318
|
+
- Updated dependencies [[`a03f0b906`](https://github.com/bluesky-social/atproto/commit/a03f0b906b108f8c766a5700f0d68b55748f23bd)]:
|
|
319
|
+
- @atproto/oauth-client@0.3.19
|
|
320
|
+
|
|
321
|
+
## 0.3.18
|
|
322
|
+
|
|
323
|
+
### Patch Changes
|
|
324
|
+
|
|
325
|
+
- Updated dependencies [[`36d0d370c`](https://github.com/bluesky-social/atproto/commit/36d0d370c24498f74c243ebfb01564e5050c672d)]:
|
|
326
|
+
- @atproto/oauth-client@0.3.18
|
|
327
|
+
|
|
328
|
+
## 0.3.17
|
|
329
|
+
|
|
330
|
+
### Patch Changes
|
|
331
|
+
|
|
332
|
+
- Updated dependencies []:
|
|
333
|
+
- @atproto-labs/did-resolver@0.1.13
|
|
334
|
+
- @atproto/oauth-client@0.3.17
|
|
335
|
+
|
|
336
|
+
## 0.3.16
|
|
337
|
+
|
|
338
|
+
### Patch Changes
|
|
339
|
+
|
|
340
|
+
- Updated dependencies [[`a48b093f0`](https://github.com/bluesky-social/atproto/commit/a48b093f0ba3cf67b7abc50d309afcb336d8ead8)]:
|
|
341
|
+
- @atproto/oauth-types@0.2.7
|
|
342
|
+
- @atproto/oauth-client@0.3.16
|
|
343
|
+
|
|
344
|
+
## 0.3.15
|
|
345
|
+
|
|
346
|
+
### Patch Changes
|
|
347
|
+
|
|
348
|
+
- Updated dependencies [[`0d77d1b55`](https://github.com/bluesky-social/atproto/commit/0d77d1b550a58117aee8f7f1e2be24d255ade9e4), [`30f9b6690`](https://github.com/bluesky-social/atproto/commit/30f9b6690e0e2c5810772e94e631322b9d89c65a), [`30f9b6690`](https://github.com/bluesky-social/atproto/commit/30f9b6690e0e2c5810772e94e631322b9d89c65a), [`0d77d1b55`](https://github.com/bluesky-social/atproto/commit/0d77d1b550a58117aee8f7f1e2be24d255ade9e4)]:
|
|
349
|
+
- @atproto-labs/simple-store@0.2.0
|
|
350
|
+
- @atproto/oauth-types@0.2.6
|
|
351
|
+
- @atproto-labs/did-resolver@0.1.12
|
|
352
|
+
- @atproto-labs/handle-resolver@0.1.8
|
|
353
|
+
- @atproto/oauth-client@0.3.15
|
|
354
|
+
|
|
355
|
+
## 0.3.14
|
|
356
|
+
|
|
357
|
+
### Patch Changes
|
|
358
|
+
|
|
359
|
+
- Updated dependencies [[`371e04aad`](https://github.com/bluesky-social/atproto/commit/371e04aad2a3e8ae3fe185ce15fc8eb051cab78e), [`26a077716`](https://github.com/bluesky-social/atproto/commit/26a07771673bf1090a61efb7c970235f0b2509fc)]:
|
|
360
|
+
- @atproto/oauth-types@0.2.5
|
|
361
|
+
- @atproto/jwk@0.1.5
|
|
362
|
+
- @atproto/oauth-client@0.3.14
|
|
363
|
+
- @atproto/jwk-webcrypto@0.1.6
|
|
364
|
+
|
|
365
|
+
## 0.3.13
|
|
366
|
+
|
|
367
|
+
### Patch Changes
|
|
368
|
+
|
|
369
|
+
- Updated dependencies []:
|
|
370
|
+
- @atproto/oauth-client@0.3.13
|
|
371
|
+
|
|
372
|
+
## 0.3.12
|
|
373
|
+
|
|
374
|
+
### Patch Changes
|
|
375
|
+
|
|
376
|
+
- Updated dependencies []:
|
|
377
|
+
- @atproto/oauth-client@0.3.12
|
|
378
|
+
|
|
379
|
+
## 0.3.11
|
|
380
|
+
|
|
381
|
+
### Patch Changes
|
|
382
|
+
|
|
383
|
+
- Updated dependencies [[`850e39843`](https://github.com/bluesky-social/atproto/commit/850e39843cb0ec9ea716675f7568c0c601f45e29), [`850e39843`](https://github.com/bluesky-social/atproto/commit/850e39843cb0ec9ea716675f7568c0c601f45e29)]:
|
|
384
|
+
- @atproto/oauth-types@0.2.4
|
|
385
|
+
- @atproto/jwk@0.1.4
|
|
386
|
+
- @atproto/oauth-client@0.3.11
|
|
387
|
+
- @atproto-labs/did-resolver@0.1.11
|
|
388
|
+
- @atproto/jwk-webcrypto@0.1.5
|
|
389
|
+
|
|
390
|
+
## 0.3.10
|
|
391
|
+
|
|
392
|
+
### Patch Changes
|
|
393
|
+
|
|
394
|
+
- Updated dependencies []:
|
|
395
|
+
- @atproto/oauth-client@0.3.10
|
|
396
|
+
|
|
397
|
+
## 0.3.9
|
|
398
|
+
|
|
399
|
+
### Patch Changes
|
|
400
|
+
|
|
401
|
+
- [#3220](https://github.com/bluesky-social/atproto/pull/3220) [`61dc0d60e`](https://github.com/bluesky-social/atproto/commit/61dc0d60e19b88c6427a54c6d95a391b5f4da7bd) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Apply new linting rules regarding import order
|
|
402
|
+
|
|
403
|
+
- Updated dependencies [[`61dc0d60e`](https://github.com/bluesky-social/atproto/commit/61dc0d60e19b88c6427a54c6d95a391b5f4da7bd), [`61dc0d60e`](https://github.com/bluesky-social/atproto/commit/61dc0d60e19b88c6427a54c6d95a391b5f4da7bd)]:
|
|
404
|
+
- @atproto-labs/handle-resolver@0.1.7
|
|
405
|
+
- @atproto-labs/did-resolver@0.1.10
|
|
406
|
+
- @atproto-labs/simple-store@0.1.2
|
|
407
|
+
- @atproto/jwk-webcrypto@0.1.4
|
|
408
|
+
- @atproto/oauth-client@0.3.9
|
|
409
|
+
- @atproto/oauth-types@0.2.3
|
|
410
|
+
- @atproto/jwk@0.1.3
|
|
411
|
+
- @atproto/did@0.1.5
|
|
412
|
+
|
|
413
|
+
## 0.3.8
|
|
414
|
+
|
|
415
|
+
### Patch Changes
|
|
416
|
+
|
|
417
|
+
- Updated dependencies [[`cc2a1222b`](https://github.com/bluesky-social/atproto/commit/cc2a1222bd2b8ddd70d70dad174c1c63246a2d87), [`cc2a1222b`](https://github.com/bluesky-social/atproto/commit/cc2a1222bd2b8ddd70d70dad174c1c63246a2d87)]:
|
|
418
|
+
- @atproto-labs/did-resolver@0.1.9
|
|
419
|
+
- @atproto/did@0.1.4
|
|
420
|
+
- @atproto/oauth-client@0.3.8
|
|
421
|
+
- @atproto-labs/handle-resolver@0.1.6
|
|
422
|
+
|
|
423
|
+
## 0.3.7
|
|
424
|
+
|
|
425
|
+
### Patch Changes
|
|
426
|
+
|
|
427
|
+
- Updated dependencies [[`2889c7699`](https://github.com/bluesky-social/atproto/commit/2889c76995ce3c569f595ac3c678218e9ce659f0), [`2889c7699`](https://github.com/bluesky-social/atproto/commit/2889c76995ce3c569f595ac3c678218e9ce659f0), [`2889c7699`](https://github.com/bluesky-social/atproto/commit/2889c76995ce3c569f595ac3c678218e9ce659f0), [`2889c7699`](https://github.com/bluesky-social/atproto/commit/2889c76995ce3c569f595ac3c678218e9ce659f0)]:
|
|
428
|
+
- @atproto/jwk@0.1.2
|
|
429
|
+
- @atproto/jwk-webcrypto@0.1.3
|
|
430
|
+
- @atproto/oauth-client@0.3.7
|
|
431
|
+
- @atproto/oauth-types@0.2.2
|
|
432
|
+
- @atproto-labs/did-resolver@0.1.8
|
|
433
|
+
|
|
434
|
+
## 0.3.6
|
|
435
|
+
|
|
436
|
+
### Patch Changes
|
|
437
|
+
|
|
438
|
+
- Updated dependencies [[`72eba67af`](https://github.com/bluesky-social/atproto/commit/72eba67af1af8320b5400bcb9319d5c3c8407d99)]:
|
|
439
|
+
- @atproto-labs/did-resolver@0.1.7
|
|
440
|
+
- @atproto/oauth-client@0.3.6
|
|
441
|
+
|
|
442
|
+
## 0.3.5
|
|
443
|
+
|
|
444
|
+
### Patch Changes
|
|
445
|
+
|
|
446
|
+
- Updated dependencies [[`a200e5095`](https://github.com/bluesky-social/atproto/commit/a200e50951d297c3f9670e96027262196bc29b0b)]:
|
|
447
|
+
- @atproto-labs/handle-resolver@0.1.5
|
|
448
|
+
- @atproto/oauth-client@0.3.5
|
|
449
|
+
|
|
450
|
+
## 0.3.4
|
|
451
|
+
|
|
452
|
+
### Patch Changes
|
|
453
|
+
|
|
454
|
+
- Updated dependencies []:
|
|
455
|
+
- @atproto/oauth-client@0.3.4
|
|
456
|
+
|
|
457
|
+
## 0.3.3
|
|
458
|
+
|
|
459
|
+
### Patch Changes
|
|
460
|
+
|
|
461
|
+
- Updated dependencies []:
|
|
462
|
+
- @atproto-labs/did-resolver@0.1.6
|
|
463
|
+
- @atproto/oauth-client@0.3.3
|
|
464
|
+
|
|
465
|
+
## 0.3.2
|
|
466
|
+
|
|
467
|
+
### Patch Changes
|
|
468
|
+
|
|
469
|
+
- Updated dependencies [[`5ddd51235`](https://github.com/bluesky-social/atproto/commit/5ddd51235c7e064bddcad2dd218df05d144d18d3), [`5ddd51235`](https://github.com/bluesky-social/atproto/commit/5ddd51235c7e064bddcad2dd218df05d144d18d3), [`5ddd51235`](https://github.com/bluesky-social/atproto/commit/5ddd51235c7e064bddcad2dd218df05d144d18d3), [`5ddd51235`](https://github.com/bluesky-social/atproto/commit/5ddd51235c7e064bddcad2dd218df05d144d18d3), [`5ddd51235`](https://github.com/bluesky-social/atproto/commit/5ddd51235c7e064bddcad2dd218df05d144d18d3), [`5ddd51235`](https://github.com/bluesky-social/atproto/commit/5ddd51235c7e064bddcad2dd218df05d144d18d3)]:
|
|
470
|
+
- @atproto/oauth-types@0.2.1
|
|
471
|
+
- @atproto/oauth-client@0.3.2
|
|
472
|
+
|
|
473
|
+
## 0.3.1
|
|
474
|
+
|
|
475
|
+
### Patch Changes
|
|
476
|
+
|
|
477
|
+
- Updated dependencies []:
|
|
478
|
+
- @atproto/oauth-client@0.3.1
|
|
479
|
+
|
|
480
|
+
## 0.3.0
|
|
481
|
+
|
|
482
|
+
### Minor Changes
|
|
483
|
+
|
|
484
|
+
- [#2871](https://github.com/bluesky-social/atproto/pull/2871) [`9d40ccbb6`](https://github.com/bluesky-social/atproto/commit/9d40ccbb69103fae9aae7e3cec31e9b3116f3ba2) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Use `"auto"` instead of `undefined` to descibe the refresh mechanism to use in various methods.
|
|
485
|
+
|
|
486
|
+
### Patch Changes
|
|
487
|
+
|
|
488
|
+
- [#2874](https://github.com/bluesky-social/atproto/pull/2874) [`7f26b1765`](https://github.com/bluesky-social/atproto/commit/7f26b176526b9856a8f61faca6f065f0afd43abf) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Add `allowHttp` OAuthClient construction option to allow working with "http:" oauth providers (for development & testing purposes).
|
|
489
|
+
|
|
490
|
+
- Updated dependencies [[`7f26b1765`](https://github.com/bluesky-social/atproto/commit/7f26b176526b9856a8f61faca6f065f0afd43abf), [`7f26b1765`](https://github.com/bluesky-social/atproto/commit/7f26b176526b9856a8f61faca6f065f0afd43abf), [`9d40ccbb6`](https://github.com/bluesky-social/atproto/commit/9d40ccbb69103fae9aae7e3cec31e9b3116f3ba2), [`7f26b1765`](https://github.com/bluesky-social/atproto/commit/7f26b176526b9856a8f61faca6f065f0afd43abf), [`9d40ccbb6`](https://github.com/bluesky-social/atproto/commit/9d40ccbb69103fae9aae7e3cec31e9b3116f3ba2), [`9d40ccbb6`](https://github.com/bluesky-social/atproto/commit/9d40ccbb69103fae9aae7e3cec31e9b3116f3ba2), [`9d40ccbb6`](https://github.com/bluesky-social/atproto/commit/9d40ccbb69103fae9aae7e3cec31e9b3116f3ba2), [`9d40ccbb6`](https://github.com/bluesky-social/atproto/commit/9d40ccbb69103fae9aae7e3cec31e9b3116f3ba2), [`9d40ccbb6`](https://github.com/bluesky-social/atproto/commit/9d40ccbb69103fae9aae7e3cec31e9b3116f3ba2), [`9d40ccbb6`](https://github.com/bluesky-social/atproto/commit/9d40ccbb69103fae9aae7e3cec31e9b3116f3ba2), [`9d40ccbb6`](https://github.com/bluesky-social/atproto/commit/9d40ccbb69103fae9aae7e3cec31e9b3116f3ba2), [`7f26b1765`](https://github.com/bluesky-social/atproto/commit/7f26b176526b9856a8f61faca6f065f0afd43abf), [`9d40ccbb6`](https://github.com/bluesky-social/atproto/commit/9d40ccbb69103fae9aae7e3cec31e9b3116f3ba2), [`9d40ccbb6`](https://github.com/bluesky-social/atproto/commit/9d40ccbb69103fae9aae7e3cec31e9b3116f3ba2), [`7f26b1765`](https://github.com/bluesky-social/atproto/commit/7f26b176526b9856a8f61faca6f065f0afd43abf)]:
|
|
491
|
+
- @atproto/oauth-client@0.3.0
|
|
492
|
+
- @atproto/oauth-types@0.2.0
|
|
493
|
+
- @atproto-labs/did-resolver@0.1.5
|
|
494
|
+
- @atproto-labs/handle-resolver@0.1.4
|
|
495
|
+
- @atproto/did@0.1.3
|
|
496
|
+
|
|
497
|
+
## 0.2.2
|
|
498
|
+
|
|
499
|
+
### Patch Changes
|
|
500
|
+
|
|
501
|
+
- [#2755](https://github.com/bluesky-social/atproto/pull/2755) [`ed325d863`](https://github.com/bluesky-social/atproto/commit/ed325d863ce8ea5986c5a45c3188aaa35288b7a8) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Improve invalid client_id error messages from BrowserOAuthClient.from()
|
|
502
|
+
|
|
503
|
+
- [#2755](https://github.com/bluesky-social/atproto/pull/2755) [`ed325d863`](https://github.com/bluesky-social/atproto/commit/ed325d863ce8ea5986c5a45c3188aaa35288b7a8) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Do not strip query string from URL after oauth redirect in fragment mode
|
|
504
|
+
|
|
505
|
+
- [#2755](https://github.com/bluesky-social/atproto/pull/2755) [`ed325d863`](https://github.com/bluesky-social/atproto/commit/ed325d863ce8ea5986c5a45c3188aaa35288b7a8) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Relax type restriction on clientId option
|
|
506
|
+
|
|
507
|
+
- Updated dependencies [[`ed325d863`](https://github.com/bluesky-social/atproto/commit/ed325d863ce8ea5986c5a45c3188aaa35288b7a8), [`ed325d863`](https://github.com/bluesky-social/atproto/commit/ed325d863ce8ea5986c5a45c3188aaa35288b7a8), [`ed325d863`](https://github.com/bluesky-social/atproto/commit/ed325d863ce8ea5986c5a45c3188aaa35288b7a8), [`ed325d863`](https://github.com/bluesky-social/atproto/commit/ed325d863ce8ea5986c5a45c3188aaa35288b7a8), [`ed325d863`](https://github.com/bluesky-social/atproto/commit/ed325d863ce8ea5986c5a45c3188aaa35288b7a8), [`ed325d863`](https://github.com/bluesky-social/atproto/commit/ed325d863ce8ea5986c5a45c3188aaa35288b7a8), [`ed325d863`](https://github.com/bluesky-social/atproto/commit/ed325d863ce8ea5986c5a45c3188aaa35288b7a8), [`ed325d863`](https://github.com/bluesky-social/atproto/commit/ed325d863ce8ea5986c5a45c3188aaa35288b7a8), [`ed325d863`](https://github.com/bluesky-social/atproto/commit/ed325d863ce8ea5986c5a45c3188aaa35288b7a8), [`ed325d863`](https://github.com/bluesky-social/atproto/commit/ed325d863ce8ea5986c5a45c3188aaa35288b7a8), [`ed325d863`](https://github.com/bluesky-social/atproto/commit/ed325d863ce8ea5986c5a45c3188aaa35288b7a8), [`ed325d863`](https://github.com/bluesky-social/atproto/commit/ed325d863ce8ea5986c5a45c3188aaa35288b7a8), [`ed325d863`](https://github.com/bluesky-social/atproto/commit/ed325d863ce8ea5986c5a45c3188aaa35288b7a8)]:
|
|
508
|
+
- @atproto/oauth-types@0.1.5
|
|
509
|
+
- @atproto/oauth-client@0.2.2
|
|
510
|
+
- @atproto-labs/did-resolver@0.1.4
|
|
511
|
+
|
|
512
|
+
## 0.2.1
|
|
513
|
+
|
|
514
|
+
### Patch Changes
|
|
515
|
+
|
|
516
|
+
- Updated dependencies [[`cb4abbb67`](https://github.com/bluesky-social/atproto/commit/cb4abbb673c69a8a89b49dca5c038f3da2153c6c), [`cb4abbb67`](https://github.com/bluesky-social/atproto/commit/cb4abbb673c69a8a89b49dca5c038f3da2153c6c), [`cb4abbb67`](https://github.com/bluesky-social/atproto/commit/cb4abbb673c69a8a89b49dca5c038f3da2153c6c)]:
|
|
517
|
+
- @atproto/did@0.1.2
|
|
518
|
+
- @atproto-labs/did-resolver@0.1.3
|
|
519
|
+
- @atproto-labs/handle-resolver@0.1.3
|
|
520
|
+
- @atproto/oauth-client@0.2.1
|
|
521
|
+
|
|
522
|
+
## 0.2.0
|
|
523
|
+
|
|
524
|
+
### Minor Changes
|
|
525
|
+
|
|
526
|
+
- [#2714](https://github.com/bluesky-social/atproto/pull/2714) [`d9ffa3c46`](https://github.com/bluesky-social/atproto/commit/d9ffa3c460924010d7002b616cb7a0c66111cc6c) Thanks [@matthieusieben](https://github.com/matthieusieben)! - The `OAuthClient` (and runtime specific sub-classes) no longer return @atproto/api `Agent` instances. Instead, they return `OAuthSession` instances that can be used to instantiate the `Agent` class.
|
|
527
|
+
|
|
528
|
+
- [#2734](https://github.com/bluesky-social/atproto/pull/2734) [`dee817b6e`](https://github.com/bluesky-social/atproto/commit/dee817b6e0fc02351d51ce310b5e65239b7c5ed7) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Remove "openid" compatibility. The reason is that although we were technically "openid" compatible, ATProto identifiers are distributed identifiers. When a client relies on OpenID to authenticate users, it will use the auth provider in combination with the identifier to uniquely identify the user. Since ATProto identifiers are meant to be able to move from one provider to the other, OpenID compatibility could break authentication after a user was migrated to a different provider.
|
|
529
|
+
|
|
530
|
+
The way OpenID compliant clients would adapt to this particularity would typically be to remove the provider + identifier combination and use the identifier alone. While this is indeed the right way to handle ATProto identifiers, it requires more work to avoid impersonation. In particular, when obtaining a user identifier, the client **must** verify that the issuer of the identity token is indeed the server responsible for that user. This mechanism being not enforced by the OpenID standard, OpenID compatibility could lead to security issues. For this reason, we decided to remove OpenID compatibility from the OAuth provider.
|
|
531
|
+
|
|
532
|
+
Note that a trusted central authority could still offer OpenID compatibility by relying on ATProto's regular OAuth flow under the hood. This capability is out of the scope of this library.
|
|
533
|
+
|
|
534
|
+
### Patch Changes
|
|
535
|
+
|
|
536
|
+
- Updated dependencies [[`d9ffa3c46`](https://github.com/bluesky-social/atproto/commit/d9ffa3c460924010d7002b616cb7a0c66111cc6c), [`dee817b6e`](https://github.com/bluesky-social/atproto/commit/dee817b6e0fc02351d51ce310b5e65239b7c5ed7), [`dee817b6e`](https://github.com/bluesky-social/atproto/commit/dee817b6e0fc02351d51ce310b5e65239b7c5ed7), [`dee817b6e`](https://github.com/bluesky-social/atproto/commit/dee817b6e0fc02351d51ce310b5e65239b7c5ed7), [`d9ffa3c46`](https://github.com/bluesky-social/atproto/commit/d9ffa3c460924010d7002b616cb7a0c66111cc6c), [`dee817b6e`](https://github.com/bluesky-social/atproto/commit/dee817b6e0fc02351d51ce310b5e65239b7c5ed7), [`dee817b6e`](https://github.com/bluesky-social/atproto/commit/dee817b6e0fc02351d51ce310b5e65239b7c5ed7), [`dee817b6e`](https://github.com/bluesky-social/atproto/commit/dee817b6e0fc02351d51ce310b5e65239b7c5ed7), [`dee817b6e`](https://github.com/bluesky-social/atproto/commit/dee817b6e0fc02351d51ce310b5e65239b7c5ed7), [`d9ffa3c46`](https://github.com/bluesky-social/atproto/commit/d9ffa3c460924010d7002b616cb7a0c66111cc6c), [`d9ffa3c46`](https://github.com/bluesky-social/atproto/commit/d9ffa3c460924010d7002b616cb7a0c66111cc6c), [`d9ffa3c46`](https://github.com/bluesky-social/atproto/commit/d9ffa3c460924010d7002b616cb7a0c66111cc6c)]:
|
|
537
|
+
- @atproto/oauth-client@0.2.0
|
|
538
|
+
- @atproto/oauth-types@0.1.4
|
|
539
|
+
|
|
540
|
+
## 0.1.7
|
|
541
|
+
|
|
542
|
+
### Patch Changes
|
|
543
|
+
|
|
544
|
+
- Updated dependencies []:
|
|
545
|
+
- @atproto/oauth-client@0.1.7
|
|
546
|
+
|
|
547
|
+
## 0.1.6
|
|
548
|
+
|
|
549
|
+
### Patch Changes
|
|
550
|
+
|
|
551
|
+
- Updated dependencies []:
|
|
552
|
+
- @atproto/oauth-client@0.1.6
|
|
553
|
+
|
|
554
|
+
## 0.1.5
|
|
555
|
+
|
|
556
|
+
### Patch Changes
|
|
557
|
+
|
|
558
|
+
- Updated dependencies [[`35a126429`](https://github.com/bluesky-social/atproto/commit/35a1264297bc22acaa6e5ed3f4aed8c351be8bbb), [`35a126429`](https://github.com/bluesky-social/atproto/commit/35a1264297bc22acaa6e5ed3f4aed8c351be8bbb), [`35a126429`](https://github.com/bluesky-social/atproto/commit/35a1264297bc22acaa6e5ed3f4aed8c351be8bbb), [`3ebcd4e61`](https://github.com/bluesky-social/atproto/commit/3ebcd4e6161291d3649d7f8a9c5ee4ac26d590a2), [`35a126429`](https://github.com/bluesky-social/atproto/commit/35a1264297bc22acaa6e5ed3f4aed8c351be8bbb)]:
|
|
559
|
+
- @atproto/oauth-client@0.1.5
|
|
560
|
+
- @atproto/oauth-types@0.1.3
|
|
561
|
+
|
|
562
|
+
## 0.1.4
|
|
563
|
+
|
|
564
|
+
### Patch Changes
|
|
565
|
+
|
|
566
|
+
- Updated dependencies [[`04112783d`](https://github.com/bluesky-social/atproto/commit/04112783db17f865c9e2b673190f77dd0b7461e3)]:
|
|
567
|
+
- @atproto/oauth-client@0.1.4
|
|
568
|
+
|
|
569
|
+
## 0.1.3
|
|
570
|
+
|
|
571
|
+
### Patch Changes
|
|
572
|
+
|
|
573
|
+
- Updated dependencies []:
|
|
574
|
+
- @atproto/oauth-client@0.1.3
|
|
575
|
+
|
|
576
|
+
## 0.1.2
|
|
577
|
+
|
|
578
|
+
### Patch Changes
|
|
579
|
+
|
|
580
|
+
- Updated dependencies [[`b934b396b`](https://github.com/bluesky-social/atproto/commit/b934b396b13ba32bf2bf7e75ecdf6871e5f310dd), [`b934b396b`](https://github.com/bluesky-social/atproto/commit/b934b396b13ba32bf2bf7e75ecdf6871e5f310dd), [`b934b396b`](https://github.com/bluesky-social/atproto/commit/b934b396b13ba32bf2bf7e75ecdf6871e5f310dd), [`b934b396b`](https://github.com/bluesky-social/atproto/commit/b934b396b13ba32bf2bf7e75ecdf6871e5f310dd)]:
|
|
581
|
+
- @atproto/oauth-client@0.1.2
|
|
582
|
+
- @atproto/oauth-types@0.1.2
|
|
583
|
+
- @atproto-labs/handle-resolver@0.1.2
|
|
584
|
+
- @atproto/did@0.1.1
|
|
585
|
+
- @atproto/jwk-webcrypto@0.1.2
|
|
586
|
+
- @atproto-labs/did-resolver@0.1.2
|
|
587
|
+
|
|
588
|
+
## 0.1.1
|
|
589
|
+
|
|
590
|
+
### Patch Changes
|
|
591
|
+
|
|
592
|
+
- [#2633](https://github.com/bluesky-social/atproto/pull/2633) [`acc9093d2`](https://github.com/bluesky-social/atproto/commit/acc9093d2845eba02b68fb2f9db33e4f1b59bb10) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Add event emitting capability to OAuthClient
|
|
593
|
+
|
|
594
|
+
- Updated dependencies [[`acc9093d2`](https://github.com/bluesky-social/atproto/commit/acc9093d2845eba02b68fb2f9db33e4f1b59bb10), [`acc9093d2`](https://github.com/bluesky-social/atproto/commit/acc9093d2845eba02b68fb2f9db33e4f1b59bb10), [`acc9093d2`](https://github.com/bluesky-social/atproto/commit/acc9093d2845eba02b68fb2f9db33e4f1b59bb10), [`acc9093d2`](https://github.com/bluesky-social/atproto/commit/acc9093d2845eba02b68fb2f9db33e4f1b59bb10), [`acc9093d2`](https://github.com/bluesky-social/atproto/commit/acc9093d2845eba02b68fb2f9db33e4f1b59bb10)]:
|
|
595
|
+
- @atproto/oauth-types@0.1.1
|
|
596
|
+
- @atproto/jwk@0.1.1
|
|
597
|
+
- @atproto-labs/handle-resolver@0.1.1
|
|
598
|
+
- @atproto-labs/did-resolver@0.1.1
|
|
599
|
+
- @atproto-labs/simple-store@0.1.1
|
|
600
|
+
- @atproto/oauth-client@0.1.1
|
|
601
|
+
- @atproto/jwk-webcrypto@0.1.1
|
|
602
|
+
|
|
603
|
+
## 0.1.0
|
|
604
|
+
|
|
605
|
+
### Minor Changes
|
|
606
|
+
|
|
607
|
+
- [#2482](https://github.com/bluesky-social/atproto/pull/2482) [`a8d6c1123`](https://github.com/bluesky-social/atproto/commit/a8d6c112359f5c4c0cfbe2df63443ed275f2a646) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Add OAuth provider capability & support for DPoP signed tokens
|
|
608
|
+
|
|
609
|
+
### Patch Changes
|
|
610
|
+
|
|
611
|
+
- Updated dependencies [[`a8d6c1123`](https://github.com/bluesky-social/atproto/commit/a8d6c112359f5c4c0cfbe2df63443ed275f2a646)]:
|
|
612
|
+
- @atproto-labs/handle-resolver@0.1.0
|
|
613
|
+
- @atproto-labs/did-resolver@0.1.0
|
|
614
|
+
- @atproto-labs/simple-store@0.1.0
|
|
615
|
+
- @atproto/jwk-webcrypto@0.1.0
|
|
616
|
+
- @atproto/oauth-client@0.1.0
|
|
617
|
+
- @atproto/oauth-types@0.1.0
|
|
618
|
+
- @atproto/jwk@0.1.0
|
|
619
|
+
- @atproto/did@0.1.0
|
|
@@ -53,6 +53,6 @@ export declare class BrowserOAuthClient extends OAuthClient implements AsyncDisp
|
|
|
53
53
|
state: string | null;
|
|
54
54
|
}>;
|
|
55
55
|
[Symbol.asyncDispose](): Promise<void>;
|
|
56
|
-
dispose(): void
|
|
56
|
+
dispose(): Promise<void>;
|
|
57
57
|
}
|
|
58
58
|
//# sourceMappingURL=browser-oauth-client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser-oauth-client.d.ts","sourceRoot":"","sources":["../src/browser-oauth-client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAEhB,KAAK,EAEL,WAAW,EACX,kBAAkB,EAClB,YAAY,EAEb,MAAM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MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAA;QAClD,CAAC;IACH,CAAC;IAED,MAAM,IAAI,KAAK,CACb,iDAAiD,WAAW,EAAE,CAC/D,CAAA;AACH,CAAC","sourcesContent":["import {\n AuthorizeOptions,\n ClientMetadata,\n Fetch,\n OAuthCallbackError,\n OAuthClient,\n OAuthClientOptions,\n OAuthSession,\n SessionHooks,\n} from '@atproto/oauth-client'\nimport {\n OAuthClientMetadataInput,\n OAuthResponseMode,\n assertOAuthDiscoverableClientId,\n atprotoLoopbackClientMetadata,\n isOAuthClientIdLoopback,\n} from '@atproto/oauth-types'\nimport { BrowserOAuthDatabase } from './browser-oauth-database.js'\nimport { BrowserRuntimeImplementation } from './browser-runtime-implementation.js'\nimport { LoginContinuedInParentWindowError } from './errors.js'\nimport { Simplify, buildLoopbackClientId } from './util.js'\n\nexport type BrowserOAuthClientOptions = Simplify<\n {\n clientMetadata?: Readonly<OAuthClientMetadataInput>\n responseMode?: Exclude<OAuthResponseMode, 'form_post'>\n fetch?: Fetch\n } & Omit<\n OAuthClientOptions,\n // Overridden by this lib\n | 'clientMetadata'\n | 'responseMode'\n | 'keyset'\n | 'fetch'\n // Provided by this lib\n | 'runtimeImplementation'\n | 'sessionStore'\n | 'stateStore'\n | 'didCache'\n | 'handleCache'\n | 'dpopNonceCache'\n | 'authorizationServerMetadataCache'\n | 'protectedResourceMetadataCache'\n >\n>\n\nconst NAMESPACE = `@@atproto/oauth-client-browser`\n\n//- Popup channel\n\nconst POPUP_CHANNEL_NAME = `${NAMESPACE}(popup-channel)`\nconst POPUP_STATE_PREFIX = `${NAMESPACE}(popup-state):`\n\ntype PopupChannelResultData = {\n key: string\n result: PromiseRejectedResult | PromiseFulfilledResult<string>\n}\n\ntype PopupChannelAckData = {\n key: string\n ack: true\n}\n\ntype PopupChannelData = PopupChannelResultData | PopupChannelAckData\n\n//- State synchronization channel\n\ntype SyncChannelMessage = {\n [K in keyof SessionHooks & string]: {\n name: K\n args: Parameters<NonNullable<SessionHooks[K]>>\n }\n}[keyof SessionHooks]\n\nconst syncChannel = new BroadcastChannel(\n `${NAMESPACE}(synchronization-channel:2)`,\n)\n\nexport type BrowserOAuthClientLoadOptions = Simplify<\n {\n clientId: string\n signal?: AbortSignal\n } & Omit<BrowserOAuthClientOptions, 'clientMetadata'>\n>\n\nconst runtimeImplementation = new BrowserRuntimeImplementation()\n\nexport class BrowserOAuthClient extends OAuthClient implements AsyncDisposable {\n static async load({ clientId, ...options }: BrowserOAuthClientLoadOptions) {\n if (clientId.startsWith('http:')) {\n const clientMetadata = atprotoLoopbackClientMetadata(clientId)\n return new BrowserOAuthClient({ clientMetadata, ...options })\n } else if (clientId.startsWith('https:')) {\n assertOAuthDiscoverableClientId(clientId)\n const clientMetadata = await OAuthClient.fetchMetadata({\n clientId,\n ...options,\n })\n return new BrowserOAuthClient({ ...options, clientMetadata })\n } else {\n throw new TypeError(`Invalid client id: ${clientId}`)\n }\n }\n\n private readonly ac = new AbortController()\n\n private readonly database: BrowserOAuthDatabase\n\n constructor({\n clientMetadata = atprotoLoopbackClientMetadata(\n buildLoopbackClientId(window.location),\n ),\n // \"fragment\" is a safer default as the query params will not be sent to the server\n responseMode = 'fragment',\n ...options\n }: BrowserOAuthClientOptions) {\n if (!globalThis.crypto?.subtle) {\n throw new Error('WebCrypto API is required')\n }\n\n if (!['query', 'fragment'].includes(responseMode)) {\n // Make sure \"form_post\" is not used as it is not supported in the browser\n throw new TypeError(`Invalid response mode: ${responseMode}`)\n }\n\n const database = new BrowserOAuthDatabase()\n\n super({\n ...options,\n\n clientMetadata,\n responseMode,\n keyset: undefined,\n\n runtimeImplementation,\n\n sessionStore: database.getSessionStore(),\n stateStore: database.getStateStore(),\n\n didCache: database.getDidCache(),\n handleCache: database.getHandleCache(),\n dpopNonceCache: database.getDpopNonceCache(),\n authorizationServerMetadataCache:\n database.getAuthorizationServerMetadataCache(),\n protectedResourceMetadataCache:\n database.getProtectedResourceMetadataCache(),\n\n onDelete: async (sub, cause) => {\n if (localStorage.getItem(`${NAMESPACE}(sub)`) === sub) {\n localStorage.removeItem(`${NAMESPACE}(sub)`)\n }\n\n syncChannel.postMessage({\n name: 'onDelete',\n args: [sub, cause],\n } satisfies SyncChannelMessage)\n\n return options.onDelete?.call(null, sub, cause)\n },\n\n onUpdate: async (sub, session) => {\n syncChannel.postMessage({\n name: 'onUpdate',\n args: [sub, session],\n } satisfies SyncChannelMessage)\n\n return options.onUpdate?.call(null, sub, session)\n },\n })\n\n this.database = database\n\n const { signal } = this.ac\n\n // Trigger hooks when an event is emitted in another tab\n syncChannel.addEventListener(\n 'message',\n (event) => {\n if (event.source === window) return\n\n const { name, args } = event.data as SyncChannelMessage\n\n const hook = options[name]\n\n // @ts-expect-error TS has a hard time matching the args with the hook\n void hook?.(...args)\n },\n // Remove the listener when the client is disposed\n { signal },\n )\n }\n\n /**\n * This method will automatically restore any existing session, or attempt to\n * process login callback if the URL contains oauth parameters.\n *\n * Use {@link BrowserOAuthClient.initCallback} instead of this method if you\n * want to force a login callback. This can be esp. useful if you are using\n * this lib from a framework that has some kind of URL manipulation (like a\n * client side router).\n *\n * Use {@link BrowserOAuthClient.initRestore} instead of this method if you\n * want to only restore existing sessions, and bypass the automatic processing\n * of login callbacks.\n */\n async init(refresh?: boolean): Promise<\n // Session restored\n | { session: OAuthSession; state?: never }\n // Login callback processed\n | { session: OAuthSession; state: string | null }\n // No session or callback\n | undefined\n > {\n // If the URL currently contains oauth query parameters (\"state\" + \"code\" or\n // \"state\" + \"error\"), let's automatically process them.\n const params = this.readCallbackParams()\n if (params) {\n const redirectUri = this.findRedirectUrl()\n if (redirectUri) return this.initCallback(params, redirectUri)\n }\n\n return this.initRestore(refresh)\n }\n\n async initRestore(refresh?: boolean) {\n // @NOTE Fixing the location should not be needed from callback endpoints\n // since callback endpoint are required to use IP based URLs (for localhost)\n await fixLocation(this.clientMetadata)\n\n const sub = localStorage.getItem(`${NAMESPACE}(sub)`)\n if (sub) {\n try {\n const session = await this.restore(sub, refresh)\n return { session }\n } catch (err) {\n localStorage.removeItem(`${NAMESPACE}(sub)`)\n throw err\n }\n }\n }\n\n async restore(sub: string, refresh?: boolean): Promise<OAuthSession> {\n const session = await super.restore(sub, refresh)\n localStorage.setItem(`${NAMESPACE}(sub)`, session.sub)\n return session\n }\n\n async revoke(sub: string) {\n localStorage.removeItem(`${NAMESPACE}(sub)`)\n return super.revoke(sub)\n }\n\n async signIn(\n input: string,\n options?: AuthorizeOptions,\n ): Promise<OAuthSession> {\n if (options?.display === 'popup') {\n return this.signInPopup(input, options)\n } else {\n return this.signInRedirect(input, options)\n }\n }\n\n async signInRedirect(\n input: string,\n options?: AuthorizeOptions,\n ): Promise<never> {\n const url = await this.authorize(input, options)\n\n window.location.href = url.href\n\n // back-forward cache\n return new Promise<never>((resolve, reject) => {\n setTimeout(\n (err: Error) => {\n // Take the opportunity to proactively cancel the pending request\n this.abortRequest(url).then(\n () => reject(err),\n (reason) => reject(new AggregateError([err, reason])),\n )\n },\n 5e3,\n new Error('User navigated back'),\n )\n })\n }\n\n async signInPopup(\n input: string,\n options?: Omit<AuthorizeOptions, 'state'> & {\n popupName?: string\n popupFeatures?: string\n },\n ): Promise<OAuthSession> {\n const popupTarget = options?.popupName ?? '_blank'\n\n // Open new window asap to prevent popup busting by browsers\n const popupFeatures =\n options?.popupFeatures ?? 'width=600,height=600,menubar=no,toolbar=no'\n let popup: Window | null = window.open(\n 'about:blank',\n popupTarget,\n popupFeatures,\n )\n\n const stateKey = `${Math.random().toString(36).slice(2)}`\n\n const url = await this.authorize(input, {\n ...options,\n state: `${POPUP_STATE_PREFIX}${stateKey}`,\n display: options?.display ?? 'popup',\n })\n\n options?.signal?.throwIfAborted()\n\n if (popup) {\n popup.window.location.href = url.href\n } else {\n popup = window.open(url.href, popupTarget, popupFeatures)\n }\n\n popup?.focus()\n\n return new Promise<OAuthSession>((resolve, reject) => {\n const popupChannel = new BroadcastChannel(POPUP_CHANNEL_NAME)\n\n const cleanup = () => {\n clearTimeout(timeout)\n popupChannel.removeEventListener('message', onMessage)\n popupChannel.close()\n options?.signal?.removeEventListener('abort', cancel)\n popup?.close()\n }\n\n const cancel = () => {\n // @TODO Store fact that the request was cancelled, allowing any\n // callback (e.g. in the popup) to revoke the session or credentials.\n\n reject(new Error(options?.signal?.aborted ? 'Aborted' : 'Timeout'))\n cleanup()\n }\n\n options?.signal?.addEventListener('abort', cancel)\n\n const timeout = setTimeout(cancel, 5 * 60e3)\n\n const onMessage = async ({ data }: MessageEvent<PopupChannelData>) => {\n if (data.key !== stateKey) return\n if (!('result' in data)) return\n\n // Send acknowledgment to popup window\n popupChannel.postMessage({ key: stateKey, ack: true })\n\n cleanup()\n\n const { result } = data\n if (result.status === 'fulfilled') {\n const sub = result.value\n try {\n options?.signal?.throwIfAborted()\n resolve(await this.restore(sub, false))\n } catch (err) {\n reject(err)\n void this.revoke(sub)\n }\n } else {\n const { message, params } = result.reason\n reject(new OAuthCallbackError(new URLSearchParams(params), message))\n }\n }\n\n popupChannel.addEventListener('message', onMessage)\n })\n }\n\n public findRedirectUrl() {\n for (const uri of this.clientMetadata.redirect_uris) {\n const url = new URL(uri)\n if (\n location.origin === url.origin &&\n location.pathname === url.pathname\n ) {\n return uri\n }\n }\n\n return undefined\n }\n\n public readCallbackParams(): URLSearchParams | null {\n const params =\n this.responseMode === 'fragment'\n ? new URLSearchParams(location.hash.slice(1))\n : new URLSearchParams(location.search)\n\n // Only if the current URL contains a valid oauth response params\n if (!params.has('state') || !(params.has('code') || params.has('error'))) {\n return null\n }\n\n return params\n }\n\n public async initCallback(\n params = this.readCallbackParams(),\n redirectUri = this.findRedirectUrl(),\n ): Promise<{\n session: OAuthSession\n state: string | null\n }> {\n if (!params) {\n throw new TypeError('No OAuth callback parameters found in the URL')\n }\n\n // Replace the current history entry without the params (this will prevent\n // the following code to run again if the user refreshes the page)\n if (this.responseMode === 'fragment') {\n history.replaceState(null, '', location.pathname + location.search)\n } else if (this.responseMode === 'query') {\n history.replaceState(null, '', location.pathname)\n }\n\n // Utility function to send the result of the popup to the parent window\n const sendPopupResult = (message: PopupChannelResultData) => {\n const popupChannel = new BroadcastChannel(POPUP_CHANNEL_NAME)\n\n return new Promise<boolean>((resolve) => {\n const cleanup = (result: boolean) => {\n clearTimeout(timer)\n popupChannel.removeEventListener('message', onMessage)\n popupChannel.close()\n resolve(result)\n }\n\n const onMessage = ({ data }: MessageEvent<PopupChannelData>) => {\n if ('ack' in data && message.key === data.key) cleanup(true)\n }\n\n popupChannel.addEventListener('message', onMessage)\n popupChannel.postMessage(message)\n // Receiving of \"ack\" should be very fast, giving it 500 ms anyway\n const timer = setTimeout(cleanup, 500, false)\n })\n }\n\n return this.callback(params, { redirect_uri: redirectUri })\n .then(async (result) => {\n if (result.state?.startsWith(POPUP_STATE_PREFIX)) {\n const receivedByParent = await sendPopupResult({\n key: result.state.slice(POPUP_STATE_PREFIX.length),\n result: {\n status: 'fulfilled',\n value: result.session.sub,\n },\n })\n\n // Revoke the credentials if the parent window was closed\n if (!receivedByParent) await result.session.signOut()\n\n throw new LoginContinuedInParentWindowError() // signInPopup\n }\n\n localStorage.setItem(`${NAMESPACE}(sub)`, result.session.sub)\n\n return result\n })\n .catch(async (err) => {\n if (\n err instanceof OAuthCallbackError &&\n err.state?.startsWith(POPUP_STATE_PREFIX)\n ) {\n await sendPopupResult({\n key: err.state.slice(POPUP_STATE_PREFIX.length),\n result: {\n status: 'rejected',\n reason: {\n message: err.message,\n params: Array.from(err.params.entries()),\n },\n },\n })\n\n throw new LoginContinuedInParentWindowError() // signInPopup\n }\n\n // Most probable cause at this point is that the \"state\" parameter is\n // invalid.\n throw err\n })\n .catch((err) => {\n if (err instanceof LoginContinuedInParentWindowError) {\n // parent will also try to close the popup\n window.close()\n }\n\n throw err\n })\n }\n\n async [Symbol.asyncDispose]() {\n try {\n this.ac.abort()\n } finally {\n await this.database[Symbol.asyncDispose]()\n }\n }\n\n dispose() {\n this[Symbol.dispose]()\n }\n}\n\n/**\n * Since \"localhost\" is often used either in IP mode or in hostname mode,\n * and because the redirect uris must use the IP mode, we need to make sure\n * that the current location url is not using \"localhost\".\n *\n * This is required for the IndexedDB to work properly. Indeed, the IndexedDB\n * is shared by origin, so we must ensure to be on the same origin as the\n * redirect uris.\n */\nfunction fixLocation(clientMetadata: ClientMetadata) {\n if (!isOAuthClientIdLoopback(clientMetadata.client_id)) return\n if (window.location.hostname !== 'localhost') return\n\n const locationUrl = new URL(window.location.href)\n\n for (const uri of clientMetadata.redirect_uris) {\n const url = new URL(uri)\n if (\n (url.hostname === '127.0.0.1' || url.hostname === '[::1]') &&\n (!url.port || url.port === locationUrl.port) &&\n url.protocol === locationUrl.protocol &&\n url.pathname === locationUrl.pathname\n ) {\n url.port = locationUrl.port\n window.location.href = url.href\n\n // Prevent init() on the wrong origin\n throw new Error('Redirecting to loopback IP...')\n }\n }\n\n throw new Error(\n `Please use the loopback IP address instead of ${locationUrl}`,\n )\n}\n"]}
|
|
1
|
+
{"version":3,"file":"browser-oauth-client.js","sourceRoot":"","sources":["../src/browser-oauth-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,kBAAkB,EAClB,WAAW,GAIZ,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAGL,+BAA+B,EAC/B,6BAA6B,EAC7B,uBAAuB,GACxB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AAClE,OAAO,EAAE,4BAA4B,EAAE,MAAM,qCAAqC,CAAA;AAClF,OAAO,EAAE,iCAAiC,EAAE,MAAM,aAAa,CAAA;AAC/D,OAAO,EAAY,qBAAqB,EAAE,MAAM,WAAW,CAAA;AA0B3D,MAAM,SAAS,GAAG,gCAAgC,CAAA;AAElD,iBAAiB;AAEjB,MAAM,kBAAkB,GAAG,GAAG,SAAS,iBAAiB,CAAA;AACxD,MAAM,kBAAkB,GAAG,GAAG,SAAS,gBAAgB,CAAA;AAuBvD,MAAM,WAAW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IACH,CAAC;IAED,KAAK,CAAC,OAAO;QACX,MAAM,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,CAAA;IACnC,CAAC;CACF;AAED;;;;;;;;GAQG;AACH,SAAS,WAAW,CAAC,cAA8B;IACjD,IAAI,CAAC,uBAAuB,CAAC,cAAc,CAAC,SAAS,CAAC;QAAE,OAAM;IAC9D,IAAI,MAAM,CAAC,QAAQ,CAAC,QAAQ,KAAK,WAAW;QAAE,OAAM;IAEpD,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;IAEjD,KAAK,MAAM,GAAG,IAAI,cAAc,CAAC,aAAa,EAAE,CAAC;QAC/C,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAA;QACxB,IACE,CAAC,GAAG,CAAC,QAAQ,KAAK,WAAW,IAAI,GAAG,CAAC,QAAQ,KAAK,OAAO,CAAC;YAC1D,CAAC,CAAC,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,IAAI,KAAK,WAAW,CAAC,IAAI,CAAC;YAC5C,GAAG,CAAC,QAAQ,KAAK,WAAW,CAAC,QAAQ;YACrC,GAAG,CAAC,QAAQ,KAAK,WAAW,CAAC,QAAQ,EACrC,CAAC;YACD,GAAG,CAAC,IAAI,GAAG,WAAW,CAAC,IAAI,CAAA;YAC3B,MAAM,CAAC,QAAQ,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,CAAA;YAE/B,qCAAqC;YACrC,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAA;QAClD,CAAC;IACH,CAAC;IAED,MAAM,IAAI,KAAK,CACb,iDAAiD,WAAW,EAAE,CAC/D,CAAA;AACH,CAAC","sourcesContent":["import {\n AuthorizeOptions,\n ClientMetadata,\n Fetch,\n OAuthCallbackError,\n OAuthClient,\n OAuthClientOptions,\n OAuthSession,\n SessionHooks,\n} from '@atproto/oauth-client'\nimport {\n OAuthClientMetadataInput,\n OAuthResponseMode,\n assertOAuthDiscoverableClientId,\n atprotoLoopbackClientMetadata,\n isOAuthClientIdLoopback,\n} from '@atproto/oauth-types'\nimport { BrowserOAuthDatabase } from './browser-oauth-database.js'\nimport { BrowserRuntimeImplementation } from './browser-runtime-implementation.js'\nimport { LoginContinuedInParentWindowError } from './errors.js'\nimport { Simplify, buildLoopbackClientId } from './util.js'\n\nexport type BrowserOAuthClientOptions = Simplify<\n {\n clientMetadata?: Readonly<OAuthClientMetadataInput>\n responseMode?: Exclude<OAuthResponseMode, 'form_post'>\n fetch?: Fetch\n } & Omit<\n OAuthClientOptions,\n // Overridden by this lib\n | 'clientMetadata'\n | 'responseMode'\n | 'keyset'\n | 'fetch'\n // Provided by this lib\n | 'runtimeImplementation'\n | 'sessionStore'\n | 'stateStore'\n | 'didCache'\n | 'handleCache'\n | 'dpopNonceCache'\n | 'authorizationServerMetadataCache'\n | 'protectedResourceMetadataCache'\n >\n>\n\nconst NAMESPACE = `@@atproto/oauth-client-browser`\n\n//- Popup channel\n\nconst POPUP_CHANNEL_NAME = `${NAMESPACE}(popup-channel)`\nconst POPUP_STATE_PREFIX = `${NAMESPACE}(popup-state):`\n\ntype PopupChannelResultData = {\n key: string\n result: PromiseRejectedResult | PromiseFulfilledResult<string>\n}\n\ntype PopupChannelAckData = {\n key: string\n ack: true\n}\n\ntype PopupChannelData = PopupChannelResultData | PopupChannelAckData\n\n//- State synchronization channel\n\ntype SyncChannelMessage = {\n [K in keyof SessionHooks & string]: {\n name: K\n args: Parameters<NonNullable<SessionHooks[K]>>\n }\n}[keyof SessionHooks]\n\nconst syncChannel = new BroadcastChannel(\n `${NAMESPACE}(synchronization-channel:2)`,\n)\n\nexport type BrowserOAuthClientLoadOptions = Simplify<\n {\n clientId: string\n signal?: AbortSignal\n } & Omit<BrowserOAuthClientOptions, 'clientMetadata'>\n>\n\nconst runtimeImplementation = new BrowserRuntimeImplementation()\n\nexport class BrowserOAuthClient extends OAuthClient implements AsyncDisposable {\n static async load({ clientId, ...options }: BrowserOAuthClientLoadOptions) {\n if (clientId.startsWith('http:')) {\n const clientMetadata = atprotoLoopbackClientMetadata(clientId)\n return new BrowserOAuthClient({ clientMetadata, ...options })\n } else if (clientId.startsWith('https:')) {\n assertOAuthDiscoverableClientId(clientId)\n const clientMetadata = await OAuthClient.fetchMetadata({\n clientId,\n ...options,\n })\n return new BrowserOAuthClient({ ...options, clientMetadata })\n } else {\n throw new TypeError(`Invalid client id: ${clientId}`)\n }\n }\n\n private readonly ac = new AbortController()\n\n private readonly database: BrowserOAuthDatabase\n\n constructor({\n clientMetadata = atprotoLoopbackClientMetadata(\n buildLoopbackClientId(window.location),\n ),\n // \"fragment\" is a safer default as the query params will not be sent to the server\n responseMode = 'fragment',\n ...options\n }: BrowserOAuthClientOptions) {\n if (!globalThis.crypto?.subtle) {\n throw new Error('WebCrypto API is required')\n }\n\n if (!['query', 'fragment'].includes(responseMode)) {\n // Make sure \"form_post\" is not used as it is not supported in the browser\n throw new TypeError(`Invalid response mode: ${responseMode}`)\n }\n\n const database = new BrowserOAuthDatabase()\n\n super({\n ...options,\n\n clientMetadata,\n responseMode,\n keyset: undefined,\n\n runtimeImplementation,\n\n sessionStore: database.getSessionStore(),\n stateStore: database.getStateStore(),\n\n didCache: database.getDidCache(),\n handleCache: database.getHandleCache(),\n dpopNonceCache: database.getDpopNonceCache(),\n authorizationServerMetadataCache:\n database.getAuthorizationServerMetadataCache(),\n protectedResourceMetadataCache:\n database.getProtectedResourceMetadataCache(),\n\n onDelete: async (sub, cause) => {\n if (localStorage.getItem(`${NAMESPACE}(sub)`) === sub) {\n localStorage.removeItem(`${NAMESPACE}(sub)`)\n }\n\n syncChannel.postMessage({\n name: 'onDelete',\n args: [sub, cause],\n } satisfies SyncChannelMessage)\n\n return options.onDelete?.call(null, sub, cause)\n },\n\n onUpdate: async (sub, session) => {\n syncChannel.postMessage({\n name: 'onUpdate',\n args: [sub, session],\n } satisfies SyncChannelMessage)\n\n return options.onUpdate?.call(null, sub, session)\n },\n })\n\n this.database = database\n\n const { signal } = this.ac\n\n // Trigger hooks when an event is emitted in another tab\n syncChannel.addEventListener(\n 'message',\n (event) => {\n if (event.source === window) return\n\n const { name, args } = event.data as SyncChannelMessage\n\n const hook = options[name]\n\n // @ts-expect-error TS has a hard time matching the args with the hook\n void hook?.(...args)\n },\n // Remove the listener when the client is disposed\n { signal },\n )\n }\n\n /**\n * This method will automatically restore any existing session, or attempt to\n * process login callback if the URL contains oauth parameters.\n *\n * Use {@link BrowserOAuthClient.initCallback} instead of this method if you\n * want to force a login callback. This can be esp. useful if you are using\n * this lib from a framework that has some kind of URL manipulation (like a\n * client side router).\n *\n * Use {@link BrowserOAuthClient.initRestore} instead of this method if you\n * want to only restore existing sessions, and bypass the automatic processing\n * of login callbacks.\n */\n async init(refresh?: boolean): Promise<\n // Session restored\n | { session: OAuthSession; state?: never }\n // Login callback processed\n | { session: OAuthSession; state: string | null }\n // No session or callback\n | undefined\n > {\n // If the URL currently contains oauth query parameters (\"state\" + \"code\" or\n // \"state\" + \"error\"), let's automatically process them.\n const params = this.readCallbackParams()\n if (params) {\n const redirectUri = this.findRedirectUrl()\n if (redirectUri) return this.initCallback(params, redirectUri)\n }\n\n return this.initRestore(refresh)\n }\n\n async initRestore(refresh?: boolean) {\n // @NOTE Fixing the location should not be needed from callback endpoints\n // since callback endpoint are required to use IP based URLs (for localhost)\n await fixLocation(this.clientMetadata)\n\n const sub = localStorage.getItem(`${NAMESPACE}(sub)`)\n if (sub) {\n try {\n const session = await this.restore(sub, refresh)\n return { session }\n } catch (err) {\n localStorage.removeItem(`${NAMESPACE}(sub)`)\n throw err\n }\n }\n }\n\n async restore(sub: string, refresh?: boolean): Promise<OAuthSession> {\n const session = await super.restore(sub, refresh)\n localStorage.setItem(`${NAMESPACE}(sub)`, session.sub)\n return session\n }\n\n async revoke(sub: string) {\n localStorage.removeItem(`${NAMESPACE}(sub)`)\n return super.revoke(sub)\n }\n\n async signIn(\n input: string,\n options?: AuthorizeOptions,\n ): Promise<OAuthSession> {\n if (options?.display === 'popup') {\n return this.signInPopup(input, options)\n } else {\n return this.signInRedirect(input, options)\n }\n }\n\n async signInRedirect(\n input: string,\n options?: AuthorizeOptions,\n ): Promise<never> {\n const url = await this.authorize(input, options)\n\n window.location.href = url.href\n\n // back-forward cache\n return new Promise<never>((resolve, reject) => {\n setTimeout(\n (err: Error) => {\n // Take the opportunity to proactively cancel the pending request\n this.abortRequest(url).then(\n () => reject(err),\n (reason) => reject(new AggregateError([err, reason])),\n )\n },\n 5e3,\n new Error('User navigated back'),\n )\n })\n }\n\n async signInPopup(\n input: string,\n options?: Omit<AuthorizeOptions, 'state'> & {\n popupName?: string\n popupFeatures?: string\n },\n ): Promise<OAuthSession> {\n const popupTarget = options?.popupName ?? '_blank'\n\n // Open new window asap to prevent popup busting by browsers\n const popupFeatures =\n options?.popupFeatures ?? 'width=600,height=600,menubar=no,toolbar=no'\n let popup: Window | null = window.open(\n 'about:blank',\n popupTarget,\n popupFeatures,\n )\n\n const stateKey = `${Math.random().toString(36).slice(2)}`\n\n const url = await this.authorize(input, {\n ...options,\n state: `${POPUP_STATE_PREFIX}${stateKey}`,\n display: options?.display ?? 'popup',\n })\n\n options?.signal?.throwIfAborted()\n\n if (popup) {\n popup.window.location.href = url.href\n } else {\n popup = window.open(url.href, popupTarget, popupFeatures)\n }\n\n popup?.focus()\n\n return new Promise<OAuthSession>((resolve, reject) => {\n const popupChannel = new BroadcastChannel(POPUP_CHANNEL_NAME)\n\n const cleanup = () => {\n clearTimeout(timeout)\n popupChannel.removeEventListener('message', onMessage)\n popupChannel.close()\n options?.signal?.removeEventListener('abort', cancel)\n popup?.close()\n }\n\n const cancel = () => {\n // @TODO Store fact that the request was cancelled, allowing any\n // callback (e.g. in the popup) to revoke the session or credentials.\n\n reject(new Error(options?.signal?.aborted ? 'Aborted' : 'Timeout'))\n cleanup()\n }\n\n options?.signal?.addEventListener('abort', cancel)\n\n const timeout = setTimeout(cancel, 5 * 60e3)\n\n const onMessage = async ({ data }: MessageEvent<PopupChannelData>) => {\n if (data.key !== stateKey) return\n if (!('result' in data)) return\n\n // Send acknowledgment to popup window\n popupChannel.postMessage({ key: stateKey, ack: true })\n\n cleanup()\n\n const { result } = data\n if (result.status === 'fulfilled') {\n const sub = result.value\n try {\n options?.signal?.throwIfAborted()\n resolve(await this.restore(sub, false))\n } catch (err) {\n reject(err)\n void this.revoke(sub)\n }\n } else {\n const { message, params } = result.reason\n reject(new OAuthCallbackError(new URLSearchParams(params), message))\n }\n }\n\n popupChannel.addEventListener('message', onMessage)\n })\n }\n\n public findRedirectUrl() {\n for (const uri of this.clientMetadata.redirect_uris) {\n const url = new URL(uri)\n if (\n location.origin === url.origin &&\n location.pathname === url.pathname\n ) {\n return uri\n }\n }\n\n return undefined\n }\n\n public readCallbackParams(): URLSearchParams | null {\n const params =\n this.responseMode === 'fragment'\n ? new URLSearchParams(location.hash.slice(1))\n : new URLSearchParams(location.search)\n\n // Only if the current URL contains a valid oauth response params\n if (!params.has('state') || !(params.has('code') || params.has('error'))) {\n return null\n }\n\n return params\n }\n\n public async initCallback(\n params = this.readCallbackParams(),\n redirectUri = this.findRedirectUrl(),\n ): Promise<{\n session: OAuthSession\n state: string | null\n }> {\n if (!params) {\n throw new TypeError('No OAuth callback parameters found in the URL')\n }\n\n // Replace the current history entry without the params (this will prevent\n // the following code to run again if the user refreshes the page)\n if (this.responseMode === 'fragment') {\n history.replaceState(null, '', location.pathname + location.search)\n } else if (this.responseMode === 'query') {\n history.replaceState(null, '', location.pathname)\n }\n\n // Utility function to send the result of the popup to the parent window\n const sendPopupResult = (message: PopupChannelResultData) => {\n const popupChannel = new BroadcastChannel(POPUP_CHANNEL_NAME)\n\n return new Promise<boolean>((resolve) => {\n const cleanup = (result: boolean) => {\n clearTimeout(timer)\n popupChannel.removeEventListener('message', onMessage)\n popupChannel.close()\n resolve(result)\n }\n\n const onMessage = ({ data }: MessageEvent<PopupChannelData>) => {\n if ('ack' in data && message.key === data.key) cleanup(true)\n }\n\n popupChannel.addEventListener('message', onMessage)\n popupChannel.postMessage(message)\n // Receiving of \"ack\" should be very fast, giving it 500 ms anyway\n const timer = setTimeout(cleanup, 500, false)\n })\n }\n\n return this.callback(params, { redirect_uri: redirectUri })\n .then(async (result) => {\n if (result.state?.startsWith(POPUP_STATE_PREFIX)) {\n const receivedByParent = await sendPopupResult({\n key: result.state.slice(POPUP_STATE_PREFIX.length),\n result: {\n status: 'fulfilled',\n value: result.session.sub,\n },\n })\n\n // Revoke the credentials if the parent window was closed\n if (!receivedByParent) await result.session.signOut()\n\n throw new LoginContinuedInParentWindowError() // signInPopup\n }\n\n localStorage.setItem(`${NAMESPACE}(sub)`, result.session.sub)\n\n return result\n })\n .catch(async (err) => {\n if (\n err instanceof OAuthCallbackError &&\n err.state?.startsWith(POPUP_STATE_PREFIX)\n ) {\n await sendPopupResult({\n key: err.state.slice(POPUP_STATE_PREFIX.length),\n result: {\n status: 'rejected',\n reason: {\n message: err.message,\n params: Array.from(err.params.entries()),\n },\n },\n })\n\n throw new LoginContinuedInParentWindowError() // signInPopup\n }\n\n // Most probable cause at this point is that the \"state\" parameter is\n // invalid.\n throw err\n })\n .catch((err) => {\n if (err instanceof LoginContinuedInParentWindowError) {\n // parent will also try to close the popup\n window.close()\n }\n\n throw err\n })\n }\n\n async [Symbol.asyncDispose]() {\n try {\n this.ac.abort()\n } finally {\n await this.database[Symbol.asyncDispose]()\n }\n }\n\n async dispose() {\n await this[Symbol.asyncDispose]()\n }\n}\n\n/**\n * Since \"localhost\" is often used either in IP mode or in hostname mode,\n * and because the redirect uris must use the IP mode, we need to make sure\n * that the current location url is not using \"localhost\".\n *\n * This is required for the IndexedDB to work properly. Indeed, the IndexedDB\n * is shared by origin, so we must ensure to be on the same origin as the\n * redirect uris.\n */\nfunction fixLocation(clientMetadata: ClientMetadata) {\n if (!isOAuthClientIdLoopback(clientMetadata.client_id)) return\n if (window.location.hostname !== 'localhost') return\n\n const locationUrl = new URL(window.location.href)\n\n for (const uri of clientMetadata.redirect_uris) {\n const url = new URL(uri)\n if (\n (url.hostname === '127.0.0.1' || url.hostname === '[::1]') &&\n (!url.port || url.port === locationUrl.port) &&\n url.protocol === locationUrl.protocol &&\n url.pathname === locationUrl.pathname\n ) {\n url.port = locationUrl.port\n window.location.href = url.href\n\n // Prevent init() on the wrong origin\n throw new Error('Redirecting to loopback IP...')\n }\n }\n\n throw new Error(\n `Please use the loopback IP address instead of ${locationUrl}`,\n )\n}\n"]}
|
|
@@ -154,7 +154,7 @@ export class BrowserOAuthDatabase {
|
|
|
154
154
|
// Spec recommends not to throw errors in dispose
|
|
155
155
|
const db = await dbPromise.catch(() => null);
|
|
156
156
|
if (db)
|
|
157
|
-
await
|
|
157
|
+
await db[Symbol.asyncDispose]();
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
160
|
//# sourceMappingURL=browser-oauth-database.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser-oauth-database.js","sourceRoot":"","sources":["../src/browser-oauth-database.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAQrD,OAAO,EAAE,EAAE,EAAiB,MAAM,uBAAuB,CAAA;AAazD,SAAS,SAAS,CAAC,GAAQ;IACzB,IAAI,CAAC,CAAC,GAAG,YAAY,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;QAC/C,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAA;IACvC,CAAC;IACD,OAAO;QACL,KAAK,EAAE,GAAG,CAAC,GAAG;QACd,OAAO,EAAE,GAAG,CAAC,aAAa;KAC3B,CAAA;AACH,CAAC;AAED,KAAK,UAAU,SAAS,CAAC,OAAmB;IAC1C,OAAO,YAAY,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,CAAA;AACjE,CAAC;AAcD,MAAM,MAAM,G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AA;QAC5C,IAAI,EAAE;YAAE,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACxE,CAAC;CACF","sourcesContent":["import { DidDocument } from '@atproto/did'\nimport { Key } from '@atproto/jwk'\nimport { WebcryptoKey } from '@atproto/jwk-webcrypto'\nimport { InternalStateData, Session } from '@atproto/oauth-client'\nimport {\n OAuthAuthorizationServerMetadata,\n OAuthProtectedResourceMetadata,\n} from '@atproto/oauth-types'\nimport { ResolvedHandle } from '@atproto-labs/handle-resolver'\nimport { SimpleStore, Value } from '@atproto-labs/simple-store'\nimport { DB, DBObjectStore } from './indexed-db/index.js'\nimport { TupleUnion } from './util.js'\n\ntype Item<V> = {\n value: V\n expiresAt?: string // ISO Date\n}\n\ntype EncodedKey = {\n keyId: string\n keyPair: CryptoKeyPair\n}\n\nfunction encodeKey(key: Key): EncodedKey {\n if (!(key instanceof WebcryptoKey) || !key.kid) {\n throw new Error('Invalid key object')\n }\n return {\n keyId: key.kid,\n keyPair: key.cryptoKeyPair,\n }\n}\n\nasync function decodeKey(encoded: EncodedKey): Promise<Key> {\n return WebcryptoKey.fromKeypair(encoded.keyPair, encoded.keyId)\n}\n\nexport type Schema = {\n state: Item<Omit<InternalStateData, 'dpopKey'> & { dpopKey: EncodedKey }>\n session: Item<Omit<Session, 'dpopKey'> & { dpopKey: EncodedKey }>\n didCache: Item<DidDocument>\n dpopNonceCache: Item<string>\n handleCache: Item<ResolvedHandle>\n authorizationServerMetadataCache: Item<OAuthAuthorizationServerMetadata>\n protectedResourceMetadataCache: Item<OAuthProtectedResourceMetadata | null>\n}\n\nexport type DatabaseStore<V extends Value> = SimpleStore<string, V>\n\nconst STORES: TupleUnion<keyof Schema> = [\n 'state',\n 'session',\n\n 'didCache',\n 'dpopNonceCache',\n 'handleCache',\n 'authorizationServerMetadataCache',\n 'protectedResourceMetadataCache',\n]\n\nexport type BrowserOAuthDatabaseOptions = {\n name?: string\n durability?: 'strict' | 'relaxed'\n cleanupInterval?: number\n}\n\nexport class BrowserOAuthDatabase {\n #dbPromise: Promise<DB<Schema>>\n #cleanupInterval?: ReturnType<typeof setInterval>\n\n constructor(options?: BrowserOAuthDatabaseOptions) {\n this.#dbPromise = DB.open<Schema>(\n options?.name ?? '@atproto-oauth-client',\n [\n (db) => {\n for (const name of STORES) {\n const store = db.createObjectStore(name, { autoIncrement: true })\n store.createIndex('expiresAt', 'expiresAt', { unique: false })\n }\n },\n ],\n { durability: options?.durability ?? 'strict' },\n )\n\n this.#cleanupInterval = setInterval(() => {\n void this.cleanup()\n }, options?.cleanupInterval ?? 30e3)\n }\n\n protected async run<N extends keyof Schema, R>(\n storeName: N,\n mode: 'readonly' | 'readwrite',\n fn: (s: DBObjectStore<Schema[N]>) => R | Promise<R>,\n ): Promise<R> {\n const db = await this.#dbPromise\n return await db.transaction([storeName], mode, (tx) =>\n fn(tx.objectStore(storeName)),\n )\n }\n\n protected createStore<N extends keyof Schema, V extends Value>(\n name: N,\n {\n encode,\n decode,\n expiresAt,\n }: {\n encode: (value: V) => Schema[N]['value'] | PromiseLike<Schema[N]['value']>\n decode: (encoded: Schema[N]['value']) => V | PromiseLike<V>\n expiresAt: (value: V) => null | Date\n },\n ): DatabaseStore<V> {\n return {\n get: async (key) => {\n // Find item in store\n const item = await this.run(name, 'readonly', (store) => store.get(key))\n\n // Not found\n if (item === undefined) return undefined\n\n // Too old (delete)\n if (item.expiresAt != null && new Date(item.expiresAt) < new Date()) {\n await this.run(name, 'readwrite', (store) => store.delete(key))\n return undefined\n }\n\n // Item found and valid. Decode\n return decode(item.value)\n },\n\n set: async (key, value) => {\n // Create encoded item record\n const item = {\n value: await encode(value),\n expiresAt: expiresAt(value)?.toISOString(),\n } as Schema[N]\n\n // Store item record\n await this.run(name, 'readwrite', (store) => store.put(item, key))\n },\n\n del: async (key) => {\n // Delete\n await this.run(name, 'readwrite', (store) => store.delete(key))\n },\n }\n }\n\n getSessionStore(): DatabaseStore<Session> {\n return this.createStore('session', {\n expiresAt: ({ tokenSet }) =>\n tokenSet.refresh_token || tokenSet.expires_at == null\n ? null\n : new Date(tokenSet.expires_at),\n encode: ({ dpopKey, ...session }) => ({\n ...session,\n dpopKey: encodeKey(dpopKey),\n }),\n decode: async ({ dpopKey, ...encoded }) => ({\n ...encoded,\n dpopKey: await decodeKey(dpopKey),\n }),\n })\n }\n\n getStateStore(): DatabaseStore<InternalStateData> {\n return this.createStore('state', {\n expiresAt: (_value) => new Date(Date.now() + 10 * 60e3),\n encode: ({ dpopKey, ...session }) => ({\n ...session,\n dpopKey: encodeKey(dpopKey),\n }),\n decode: async ({ dpopKey, ...encoded }) => ({\n ...encoded,\n dpopKey: await decodeKey(dpopKey),\n }),\n })\n }\n\n getDpopNonceCache(): DatabaseStore<string> {\n return this.createStore('dpopNonceCache', {\n expiresAt: (_value) => new Date(Date.now() + 600e3),\n encode: (value) => value,\n decode: (encoded) => encoded,\n })\n }\n\n getDidCache(): DatabaseStore<DidDocument> {\n return this.createStore('didCache', {\n expiresAt: (_value) => new Date(Date.now() + 60e3),\n encode: (value) => value,\n decode: (encoded) => encoded,\n })\n }\n\n getHandleCache(): DatabaseStore<ResolvedHandle> {\n return this.createStore('handleCache', {\n expiresAt: (_value) => new Date(Date.now() + 60e3),\n encode: (value) => value,\n decode: (encoded) => encoded,\n })\n }\n\n getAuthorizationServerMetadataCache():\n | undefined\n | DatabaseStore<OAuthAuthorizationServerMetadata> {\n return this.createStore('authorizationServerMetadataCache', {\n expiresAt: (_value) => new Date(Date.now() + 60e3),\n encode: (value) => value,\n decode: (encoded) => encoded,\n })\n }\n\n getProtectedResourceMetadataCache():\n | undefined\n | DatabaseStore<OAuthProtectedResourceMetadata | null> {\n return this.createStore('protectedResourceMetadataCache', {\n expiresAt: (_value) => new Date(Date.now() + 60e3),\n encode: (value) => value,\n decode: (encoded) => encoded,\n })\n }\n\n async cleanup() {\n const db = await this.#dbPromise\n\n for (const name of STORES) {\n await db.transaction([name], 'readwrite', (tx) =>\n tx\n .objectStore(name)\n .index('expiresAt')\n .deleteAll(IDBKeyRange.upperBound(Date.now())),\n )\n }\n }\n\n async [Symbol.asyncDispose]() {\n clearInterval(this.#cleanupInterval)\n this.#cleanupInterval = undefined\n\n const dbPromise = this.#dbPromise\n this.#dbPromise = Promise.reject(new Error('Database has been disposed'))\n\n // Avoid \"unhandled promise rejection\"\n this.#dbPromise.catch(() => null)\n\n // Spec recommends not to throw errors in dispose\n const db = await dbPromise.catch(() => null)\n if (db) await (db[Symbol.asyncDispose] || db[Symbol.dispose]).call(db)\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"browser-oauth-database.js","sourceRoot":"","sources":["../src/browser-oauth-database.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAQrD,OAAO,EAAE,EAAE,EAAiB,MAAM,uBAAuB,CAAA;AAazD,SAAS,SAAS,CAAC,GAAQ;IACzB,IAAI,CAAC,CAAC,GAAG,YAAY,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;QAC/C,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAA;IACvC,CAAC;IACD,OAAO;QACL,KAAK,EAAE,GAAG,CAAC,GAAG;QACd,OAAO,EAAE,GAAG,CAAC,aAAa;KAC3B,CAAA;AACH,CAAC;AAED,KAAK,UAAU,SAAS,CAAC,OAAmB;IAC1C,OAAO,YAAY,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,CAAA;AACjE,CAAC;AAcD,MAAM,MAAM,GAA6B;IACvC,OAAO;IACP,SAAS;IAET,UAAU;IACV,gBAAgB;IAChB,aAAa;IACb,kCAAkC;IAClC,gCAAgC;CACjC,CAAA;AAQD,MAAM,OAAO,oBAAoB;IAC/B,UAAU,CAAqB;IAC/B,gBAA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ptoKey } from '@atproto/jwk-webcrypto'\nimport { InternalStateData, Session } from '@atproto/oauth-client'\nimport {\n OAuthAuthorizationServerMetadata,\n OAuthProtectedResourceMetadata,\n} from '@atproto/oauth-types'\nimport { ResolvedHandle } from '@atproto-labs/handle-resolver'\nimport { SimpleStore, Value } from '@atproto-labs/simple-store'\nimport { DB, DBObjectStore } from './indexed-db/index.js'\nimport { TupleUnion } from './util.js'\n\ntype Item<V> = {\n value: V\n expiresAt?: string // ISO Date\n}\n\ntype EncodedKey = {\n keyId: string\n keyPair: CryptoKeyPair\n}\n\nfunction encodeKey(key: Key): EncodedKey {\n if (!(key instanceof WebcryptoKey) || !key.kid) {\n throw new Error('Invalid key object')\n }\n return {\n keyId: key.kid,\n keyPair: key.cryptoKeyPair,\n }\n}\n\nasync function decodeKey(encoded: EncodedKey): Promise<Key> {\n return WebcryptoKey.fromKeypair(encoded.keyPair, encoded.keyId)\n}\n\nexport type Schema = {\n state: Item<Omit<InternalStateData, 'dpopKey'> & { dpopKey: EncodedKey }>\n session: Item<Omit<Session, 'dpopKey'> & { dpopKey: EncodedKey }>\n didCache: Item<DidDocument>\n dpopNonceCache: Item<string>\n handleCache: Item<ResolvedHandle>\n authorizationServerMetadataCache: Item<OAuthAuthorizationServerMetadata>\n protectedResourceMetadataCache: Item<OAuthProtectedResourceMetadata | null>\n}\n\nexport type DatabaseStore<V extends Value> = SimpleStore<string, V>\n\nconst STORES: TupleUnion<keyof Schema> = [\n 'state',\n 'session',\n\n 'didCache',\n 'dpopNonceCache',\n 'handleCache',\n 'authorizationServerMetadataCache',\n 'protectedResourceMetadataCache',\n]\n\nexport type BrowserOAuthDatabaseOptions = {\n name?: string\n durability?: 'strict' | 'relaxed'\n cleanupInterval?: number\n}\n\nexport class BrowserOAuthDatabase {\n #dbPromise: Promise<DB<Schema>>\n #cleanupInterval?: ReturnType<typeof setInterval>\n\n constructor(options?: BrowserOAuthDatabaseOptions) {\n this.#dbPromise = DB.open<Schema>(\n options?.name ?? '@atproto-oauth-client',\n [\n (db) => {\n for (const name of STORES) {\n const store = db.createObjectStore(name, { autoIncrement: true })\n store.createIndex('expiresAt', 'expiresAt', { unique: false })\n }\n },\n ],\n { durability: options?.durability ?? 'strict' },\n )\n\n this.#cleanupInterval = setInterval(() => {\n void this.cleanup()\n }, options?.cleanupInterval ?? 30e3)\n }\n\n protected async run<N extends keyof Schema, R>(\n storeName: N,\n mode: 'readonly' | 'readwrite',\n fn: (s: DBObjectStore<Schema[N]>) => R | Promise<R>,\n ): Promise<R> {\n const db = await this.#dbPromise\n return await db.transaction([storeName], mode, (tx) =>\n fn(tx.objectStore(storeName)),\n )\n }\n\n protected createStore<N extends keyof Schema, V extends Value>(\n name: N,\n {\n encode,\n decode,\n expiresAt,\n }: {\n encode: (value: V) => Schema[N]['value'] | PromiseLike<Schema[N]['value']>\n decode: (encoded: Schema[N]['value']) => V | PromiseLike<V>\n expiresAt: (value: V) => null | Date\n },\n ): DatabaseStore<V> {\n return {\n get: async (key) => {\n // Find item in store\n const item = await this.run(name, 'readonly', (store) => store.get(key))\n\n // Not found\n if (item === undefined) return undefined\n\n // Too old (delete)\n if (item.expiresAt != null && new Date(item.expiresAt) < new Date()) {\n await this.run(name, 'readwrite', (store) => store.delete(key))\n return undefined\n }\n\n // Item found and valid. Decode\n return decode(item.value)\n },\n\n set: async (key, value) => {\n // Create encoded item record\n const item = {\n value: await encode(value),\n expiresAt: expiresAt(value)?.toISOString(),\n } as Schema[N]\n\n // Store item record\n await this.run(name, 'readwrite', (store) => store.put(item, key))\n },\n\n del: async (key) => {\n // Delete\n await this.run(name, 'readwrite', (store) => store.delete(key))\n },\n }\n }\n\n getSessionStore(): DatabaseStore<Session> {\n return this.createStore('session', {\n expiresAt: ({ tokenSet }) =>\n tokenSet.refresh_token || tokenSet.expires_at == null\n ? null\n : new Date(tokenSet.expires_at),\n encode: ({ dpopKey, ...session }) => ({\n ...session,\n dpopKey: encodeKey(dpopKey),\n }),\n decode: async ({ dpopKey, ...encoded }) => ({\n ...encoded,\n dpopKey: await decodeKey(dpopKey),\n }),\n })\n }\n\n getStateStore(): DatabaseStore<InternalStateData> {\n return this.createStore('state', {\n expiresAt: (_value) => new Date(Date.now() + 10 * 60e3),\n encode: ({ dpopKey, ...session }) => ({\n ...session,\n dpopKey: encodeKey(dpopKey),\n }),\n decode: async ({ dpopKey, ...encoded }) => ({\n ...encoded,\n dpopKey: await decodeKey(dpopKey),\n }),\n })\n }\n\n getDpopNonceCache(): DatabaseStore<string> {\n return this.createStore('dpopNonceCache', {\n expiresAt: (_value) => new Date(Date.now() + 600e3),\n encode: (value) => value,\n decode: (encoded) => encoded,\n })\n }\n\n getDidCache(): DatabaseStore<DidDocument> {\n return this.createStore('didCache', {\n expiresAt: (_value) => new Date(Date.now() + 60e3),\n encode: (value) => value,\n decode: (encoded) => encoded,\n })\n }\n\n getHandleCache(): DatabaseStore<ResolvedHandle> {\n return this.createStore('handleCache', {\n expiresAt: (_value) => new Date(Date.now() + 60e3),\n encode: (value) => value,\n decode: (encoded) => encoded,\n })\n }\n\n getAuthorizationServerMetadataCache():\n | undefined\n | DatabaseStore<OAuthAuthorizationServerMetadata> {\n return this.createStore('authorizationServerMetadataCache', {\n expiresAt: (_value) => new Date(Date.now() + 60e3),\n encode: (value) => value,\n decode: (encoded) => encoded,\n })\n }\n\n getProtectedResourceMetadataCache():\n | undefined\n | DatabaseStore<OAuthProtectedResourceMetadata | null> {\n return this.createStore('protectedResourceMetadataCache', {\n expiresAt: (_value) => new Date(Date.now() + 60e3),\n encode: (value) => value,\n decode: (encoded) => encoded,\n })\n }\n\n async cleanup() {\n const db = await this.#dbPromise\n\n for (const name of STORES) {\n await db.transaction([name], 'readwrite', (tx) =>\n tx\n .objectStore(name)\n .index('expiresAt')\n .deleteAll(IDBKeyRange.upperBound(Date.now())),\n )\n }\n }\n\n async [Symbol.asyncDispose]() {\n clearInterval(this.#cleanupInterval)\n this.#cleanupInterval = undefined\n\n const dbPromise = this.#dbPromise\n this.#dbPromise = Promise.reject(new Error('Database has been disposed'))\n\n // Avoid \"unhandled promise rejection\"\n this.#dbPromise.catch(() => null)\n\n // Spec recommends not to throw errors in dispose\n const db = await dbPromise.catch(() => null)\n if (db) await db[Symbol.asyncDispose]()\n }\n}\n"]}
|
package/dist/indexed-db/db.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import 'core-js/es/symbol/dispose.js';
|
|
2
2
|
import { DBTransaction } from './db-transaction.js';
|
|
3
3
|
import { DatabaseSchema } from './schema.js';
|
|
4
|
-
export declare class DB<Schema extends DatabaseSchema> implements
|
|
4
|
+
export declare class DB<Schema extends DatabaseSchema> implements AsyncDisposable {
|
|
5
5
|
#private;
|
|
6
6
|
protected readonly txOptions?: IDBTransactionOptions | undefined;
|
|
7
7
|
static open<Schema extends DatabaseSchema = DatabaseSchema>(dbName: string, migrations: ReadonlyArray<(db: IDBDatabase) => void>, txOptions?: IDBTransactionOptions): Promise<DB<Schema>>;
|
|
@@ -12,6 +12,6 @@ export declare class DB<Schema extends DatabaseSchema> implements Disposable {
|
|
|
12
12
|
get version(): number;
|
|
13
13
|
transaction<T extends readonly (keyof Schema & string)[], R>(storeNames: T, mode: IDBTransactionMode, run: (tx: DBTransaction<Pick<Schema, T[number]>>) => R | PromiseLike<R>): Promise<R>;
|
|
14
14
|
close(): void;
|
|
15
|
-
[Symbol.
|
|
15
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
16
16
|
}
|
|
17
17
|
//# sourceMappingURL=db.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../src/indexed-db/db.ts"],"names":[],"mappings":"AAAA,OAAO,8BAA8B,CAAA;AAErC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAE5C,qBAAa,EAAE,CAAC,MAAM,SAAS,cAAc,CAAE,YAAW,
|
|
1
|
+
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../src/indexed-db/db.ts"],"names":[],"mappings":"AAAA,OAAO,8BAA8B,CAAA;AAErC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAE5C,qBAAa,EAAE,CAAC,MAAM,SAAS,cAAc,CAAE,YAAW,eAAe;;IAqCrE,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,qBAAqB;IApCtD,OAAa,IAAI,CAAC,MAAM,SAAS,cAAc,GAAG,cAAc,EAC9D,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,aAAa,CAAC,CAAC,EAAE,EAAE,WAAW,KAAK,IAAI,CAAC,EACpD,SAAS,CAAC,EAAE,qBAAqB,uBA2BlC;IAID,YACE,EAAE,EAAE,WAAW,EACI,SAAS,CAAC,EAAE,qBAAqB,YAAA,EAarD;IAED,SAAS,KAAK,EAAE,IAAI,WAAW,CAG9B;IAED,IAAI,IAAI,WAEP;IAED,IAAI,gBAAgB,kBAEnB;IAED,IAAI,OAAO,WAEV;IAEK,WAAW,CAAC,CAAC,SAAS,SAAS,CAAC,MAAM,MAAM,GAAG,MAAM,CAAC,EAAE,EAAE,CAAC,EAC/D,UAAU,EAAE,CAAC,EACb,IAAI,EAAE,kBAAkB,EACxB,GAAG,EAAE,CAAC,EAAE,EAAE,aAAa,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,GACtE,OAAO,CAAC,CAAC,CAAC,CA0BZ;IAED,KAAK,SAIJ;IAEK,CAAC,MAAM,CAAC,YAAY,CAAC,kBAE1B;CACF"}
|
package/dist/indexed-db/db.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db.js","sourceRoot":"","sources":["../../src/indexed-db/db.ts"],"names":[],"mappings":"AA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AAC,MAAM,CAAC,KAAK,CAAC,CAAA;;wBACjC,MAAM,CAAC,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC,CAAA;gBAChE,CAAC,CAAA;gBACD,EAAE,CAAC,OAAO,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,CAAA;gBACnC,EAAE,CAAC,OAAO,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,IAAI,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC,CAAA;gBAEvE,IAAI,CAAC;oBACH,MAAM,KAAK,GAAG,MAAM,GAAG,CAAC,IAAI,aAAa,CAAC,EAAE,CAAC,CAAC,CAAA;oBAC9C,MAAM,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAA;oBAC9B,EAAE,CAAC,MAAM,EAAE,CAAA;gBACb,CAAC;gBAAC,OAAO,GAAG,EAAE,CAAC;oBACb,EAAE,CAAC,KAAK,EAAE,CAAA;oBACV,MAAM,GAAG,CAAA;gBACX,CAAC;YACH,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,MAAM,CAAC,GAAG,CAAC,CAAA;YACb,CAAC;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,KAAK;QACH,MAAM,EAAE,EAAE,EAAE,GAAG,IAAI,CAAA;QACnB,IAAI,CAAC,GAAG,GAAG,IAAI,CAAA;QACf,EAAE,CAAC,KAAK,EAAE,CAAA;IACZ,CAAC;IAED,KAAK,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC;QACzB,IAAI,IAAI,CAAC,GAAG;YAAE,MAAM,IAAI,CAAC,KAAK,EAAE,CAAA;IAClC,CAAC;CACF","sourcesContent":["import 'core-js/es/symbol/dispose.js'\n\nimport { DBTransaction } from './db-transaction.js'\nimport { DatabaseSchema } from './schema.js'\n\nexport class DB<Schema extends DatabaseSchema> implements AsyncDisposable {\n static async open<Schema extends DatabaseSchema = DatabaseSchema>(\n dbName: string,\n migrations: ReadonlyArray<(db: IDBDatabase) => void>,\n txOptions?: IDBTransactionOptions,\n ) {\n const db = await new Promise<IDBDatabase>((resolve, reject) => {\n const request = indexedDB.open(dbName, migrations.length)\n\n request.onerror = () => reject(request.error)\n request.onsuccess = () => resolve(request.result)\n request.onupgradeneeded = ({ oldVersion, newVersion }) => {\n const db = request.result\n try {\n for (\n let version = oldVersion;\n version < (newVersion ?? migrations.length);\n ++version\n ) {\n const migration = migrations[version]\n if (migration) migration(db)\n else throw new Error(`Missing migration for version ${version}`)\n }\n } catch (err) {\n db.close()\n reject(err)\n }\n }\n })\n\n return new DB<Schema>(db, txOptions)\n }\n\n #db: null | IDBDatabase\n\n constructor(\n db: IDBDatabase,\n protected readonly txOptions?: IDBTransactionOptions,\n ) {\n this.#db = db\n\n const cleanup = () => {\n this.#db = null\n db.removeEventListener('versionchange', cleanup)\n db.removeEventListener('close', cleanup)\n db.close() // Can we call close on a \"closed\" database?\n }\n\n db.addEventListener('versionchange', cleanup)\n db.addEventListener('close', cleanup)\n }\n\n protected get db(): IDBDatabase {\n if (!this.#db) throw new Error('Database closed')\n return this.#db\n }\n\n get name() {\n return this.db.name\n }\n\n get objectStoreNames() {\n return this.db.objectStoreNames\n }\n\n get version() {\n return this.db.version\n }\n\n async transaction<T extends readonly (keyof Schema & string)[], R>(\n storeNames: T,\n mode: IDBTransactionMode,\n run: (tx: DBTransaction<Pick<Schema, T[number]>>) => R | PromiseLike<R>,\n ): Promise<R> {\n // eslint-disable-next-line no-async-promise-executor\n return new Promise<R>(async (resolve, reject) => {\n try {\n const tx = this.db.transaction(storeNames, mode, this.txOptions)\n let result: { done: false } | { done: true; value: R } = { done: false }\n\n tx.oncomplete = () => {\n if (result.done) resolve(result.value)\n else reject(new Error('Transaction completed without result'))\n }\n tx.onerror = () => reject(tx.error)\n tx.onabort = () => reject(tx.error || new Error('Transaction aborted'))\n\n try {\n const value = await run(new DBTransaction(tx))\n result = { done: true, value }\n tx.commit()\n } catch (err) {\n tx.abort()\n throw err\n }\n } catch (err) {\n reject(err)\n }\n })\n }\n\n close() {\n const { db } = this\n this.#db = null\n db.close()\n }\n\n async [Symbol.asyncDispose]() {\n if (this.#db) await this.close()\n }\n}\n"]}
|
package/dist/indexed-db-store.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"indexed-db-store.js","sourceRoot":"","sources":["../src/indexed-db-store.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAiB,MAAM,uBAAuB,CAAA;AAEzD,MAAM,SAAS,GAAG,OAAO,CAAA;AAMzB,MAAM,OAAO,cAAc;IAKzB,YACU,MAAc,EACZ,MAAM,GAAG,KAAK;sBADhB,MAAM;sBACJ,MAAM;IACf,CAAC;IAEM,KAAK,CAAC,GAAG,CACjB,IAA8B,EAC9B,EAAiD;QAEjD,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,IAAI,CACtB,IAAI,CAAC,MAAM,EACX;YACE,CAAC,EAAE,EAAE,EAAE;gBACL,MAAM,KAAK,GAAG,EAAE,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAA;gBAC7C,KAAK,CAAC,WAAW,CAAC,WAAW,EAAE,WAAW,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAA;YAChE,CAAC;SACF,EACD,EAAE,UAAU,EAAE,QAAQ,EAAE,CACzB,CAAA;QACD,IAAI,CAAC;YACH,OAAO,MAAM,EAAE,CAAC,WAAW,CAAC,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,CACpD,EAAE,CAAC,EAAE,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CAC9B,CAAA;QACH,CAAC;gBAAS,CAAC;YACT,MAAM,EAAE,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"indexed-db-store.js","sourceRoot":"","sources":["../src/indexed-db-store.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAi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ACtB,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;YACnB,OAAO,SAAS,CAAA;QAClB,CAAC;QAED,OAAO,IAAI,EAAE,KAAK,CAAA;IACpB,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,GAAM,EAAE,KAAQ;QACxB,MAAM,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,KAAK,EAAE,EAAE;YACpC,KAAK,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC,CAAA;QAClD,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,GAAM;QACd,MAAM,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,KAAK,EAAE,EAAE;YACpC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;QACnB,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,KAAK,CAAC,cAAc;QAClB,MAAM,UAAU,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,CAAA;QACrD,MAAM,KAAK,GAAG,WAAW,CAAC,UAAU,CAAC,UAAU,CAAC,CAAA;QAEhD,MAAM,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;YAC1C,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,CAAA;YACtC,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;YAC1C,KAAK,MAAM,GAAG,IAAI,IAAI;gBAAE,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;QAC3C,CAAC,CAAC,CAAA;IACJ,CAAC;CACF","sourcesContent":["import { Key, SimpleStore, Value } from '@atproto-labs/simple-store'\nimport { DB, DBObjectStore } from './indexed-db/index.js'\n\nconst storeName = 'store'\ntype Item<V> = {\n value: V\n createdAt: Date\n}\n\nexport class IndexedDBStore<\n K extends Extract<IDBValidKey, Key>,\n V extends Value,\n> implements SimpleStore<K, V>\n{\n constructor(\n private dbName: string,\n protected maxAge = 600e3,\n ) {}\n\n protected async run<R>(\n mode: 'readonly' | 'readwrite',\n fn: (s: DBObjectStore<Item<V>>) => R | Promise<R>,\n ): Promise<R> {\n const db = await DB.open<{ store: Item<V> }>(\n this.dbName,\n [\n (db) => {\n const store = db.createObjectStore(storeName)\n store.createIndex('createdAt', 'createdAt', { unique: false })\n },\n ],\n { durability: 'strict' },\n )\n try {\n return await db.transaction([storeName], mode, (tx) =>\n fn(tx.objectStore(storeName)),\n )\n } finally {\n await db[Symbol.asyncDispose]()\n }\n }\n\n async get(key: K): Promise<V | undefined> {\n const item = await this.run('readonly', (store) => store.get(key))\n\n if (!item) return undefined\n\n const age = Date.now() - item.createdAt.getTime()\n if (age > this.maxAge) {\n await this.del(key)\n return undefined\n }\n\n return item?.value\n }\n\n async set(key: K, value: V): Promise<void> {\n await this.run('readwrite', (store) => {\n store.put({ value, createdAt: new Date() }, key)\n })\n }\n\n async del(key: K): Promise<void> {\n await this.run('readwrite', (store) => {\n store.delete(key)\n })\n }\n\n async deleteOutdated() {\n const upperBound = new Date(Date.now() - this.maxAge)\n const query = IDBKeyRange.upperBound(upperBound)\n\n await this.run('readwrite', async (store) => {\n const index = store.index('createdAt')\n const keys = await index.getAllKeys(query)\n for (const key of keys) store.delete(key)\n })\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atproto/oauth-client-browser",
|
|
3
|
-
"version": "0.4.
|
|
4
|
-
"engines": {
|
|
5
|
-
"node": ">=22"
|
|
6
|
-
},
|
|
3
|
+
"version": "0.4.5",
|
|
7
4
|
"license": "MIT",
|
|
8
5
|
"description": "ATPROTO OAuth client for the browser (relies on WebCrypto & Indexed DB)",
|
|
9
6
|
"keywords": [
|
|
@@ -21,6 +18,11 @@
|
|
|
21
18
|
"url": "https://github.com/bluesky-social/atproto",
|
|
22
19
|
"directory": "packages/oauth/oauth-client-browser"
|
|
23
20
|
},
|
|
21
|
+
"files": [
|
|
22
|
+
"./dist",
|
|
23
|
+
"./README.md",
|
|
24
|
+
"./CHANGELOG.md"
|
|
25
|
+
],
|
|
24
26
|
"type": "module",
|
|
25
27
|
"exports": {
|
|
26
28
|
".": {
|
|
@@ -28,21 +30,20 @@
|
|
|
28
30
|
"default": "./dist/index.js"
|
|
29
31
|
}
|
|
30
32
|
},
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
|
|
33
|
+
"engines": {
|
|
34
|
+
"node": ">=22"
|
|
35
|
+
},
|
|
34
36
|
"dependencies": {
|
|
35
37
|
"core-js": "^3",
|
|
36
|
-
"@atproto-labs/did-resolver": "^0.3.
|
|
37
|
-
"@atproto-labs/
|
|
38
|
-
"@atproto/
|
|
39
|
-
"@atproto/
|
|
40
|
-
"@atproto/jwk": "^0.
|
|
41
|
-
"@atproto/
|
|
42
|
-
"@atproto/
|
|
43
|
-
"@atproto
|
|
38
|
+
"@atproto-labs/did-resolver": "^0.3.4",
|
|
39
|
+
"@atproto-labs/simple-store": "^0.4.3",
|
|
40
|
+
"@atproto/jwk": "^0.7.3",
|
|
41
|
+
"@atproto-labs/handle-resolver": "^0.4.4",
|
|
42
|
+
"@atproto/jwk-webcrypto": "^0.3.3",
|
|
43
|
+
"@atproto/did": "^0.5.3",
|
|
44
|
+
"@atproto/oauth-client": "^0.7.7",
|
|
45
|
+
"@atproto/oauth-types": "^0.7.4"
|
|
44
46
|
},
|
|
45
|
-
"devDependencies": {},
|
|
46
47
|
"scripts": {
|
|
47
48
|
"build": "tsgo --build tsconfig.build.json"
|
|
48
49
|
}
|