Leon4gr45 commited on
Commit
963a65f
·
verified ·
1 Parent(s): 9ae09a4

Upload folder using huggingface_hub (part 24)

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +3 -0
  2. node_modules/@scarf/scarf/LICENSE +201 -0
  3. node_modules/@scarf/scarf/README.md +198 -0
  4. node_modules/@scarf/scarf/package.json +36 -0
  5. node_modules/@scarf/scarf/report.js +574 -0
  6. node_modules/@simplewebauthn/server/LICENSE.md +18 -0
  7. node_modules/@simplewebauthn/server/README.md +47 -0
  8. node_modules/@simplewebauthn/server/esm/authentication/generateAuthenticationOptions.d.ts +26 -0
  9. node_modules/@simplewebauthn/server/esm/authentication/generateAuthenticationOptions.d.ts.map +1 -0
  10. node_modules/@simplewebauthn/server/esm/authentication/generateAuthenticationOptions.js +41 -0
  11. node_modules/@simplewebauthn/server/esm/authentication/verifyAuthenticationResponse.d.ts +67 -0
  12. node_modules/@simplewebauthn/server/esm/authentication/verifyAuthenticationResponse.d.ts.map +1 -0
  13. node_modules/@simplewebauthn/server/esm/authentication/verifyAuthenticationResponse.js +171 -0
  14. node_modules/@simplewebauthn/server/esm/helpers/convertAAGUIDToString.d.ts +6 -0
  15. node_modules/@simplewebauthn/server/esm/helpers/convertAAGUIDToString.d.ts.map +1 -0
  16. node_modules/@simplewebauthn/server/esm/helpers/convertAAGUIDToString.js +17 -0
  17. node_modules/@simplewebauthn/server/esm/helpers/convertCOSEtoPKCS.d.ts +6 -0
  18. node_modules/@simplewebauthn/server/esm/helpers/convertCOSEtoPKCS.d.ts.map +1 -0
  19. node_modules/@simplewebauthn/server/esm/helpers/convertCOSEtoPKCS.js +21 -0
  20. node_modules/@simplewebauthn/server/esm/helpers/convertCertBufferToPEM.d.ts +6 -0
  21. node_modules/@simplewebauthn/server/esm/helpers/convertCertBufferToPEM.d.ts.map +1 -0
  22. node_modules/@simplewebauthn/server/esm/helpers/convertCertBufferToPEM.js +31 -0
  23. node_modules/@simplewebauthn/server/esm/helpers/convertPEMToBytes.d.ts +6 -0
  24. node_modules/@simplewebauthn/server/esm/helpers/convertPEMToBytes.d.ts.map +1 -0
  25. node_modules/@simplewebauthn/server/esm/helpers/convertPEMToBytes.js +11 -0
  26. node_modules/@simplewebauthn/server/esm/helpers/convertX509PublicKeyToCOSE.d.ts +4 -0
  27. node_modules/@simplewebauthn/server/esm/helpers/convertX509PublicKeyToCOSE.d.ts.map +1 -0
  28. node_modules/@simplewebauthn/server/esm/helpers/convertX509PublicKeyToCOSE.js +73 -0
  29. node_modules/@simplewebauthn/server/esm/helpers/cose.d.ts +122 -0
  30. node_modules/@simplewebauthn/server/esm/helpers/cose.d.ts.map +1 -0
  31. node_modules/@simplewebauthn/server/esm/helpers/cose.js +90 -0
  32. node_modules/@simplewebauthn/server/esm/helpers/decodeAttestationObject.d.ts +35 -0
  33. node_modules/@simplewebauthn/server/esm/helpers/decodeAttestationObject.d.ts.map +1 -0
  34. node_modules/@simplewebauthn/server/esm/helpers/decodeAttestationObject.js +16 -0
  35. node_modules/@simplewebauthn/server/esm/helpers/decodeAuthenticatorExtensions.d.ts +12 -0
  36. node_modules/@simplewebauthn/server/esm/helpers/decodeAuthenticatorExtensions.d.ts.map +1 -0
  37. node_modules/@simplewebauthn/server/esm/helpers/decodeAuthenticatorExtensions.js +34 -0
  38. node_modules/@simplewebauthn/server/esm/helpers/decodeClientDataJSON.d.ts +23 -0
  39. node_modules/@simplewebauthn/server/esm/helpers/decodeClientDataJSON.d.ts.map +1 -0
  40. node_modules/@simplewebauthn/server/esm/helpers/decodeClientDataJSON.js +16 -0
  41. node_modules/@simplewebauthn/server/esm/helpers/decodeCredentialPublicKey.d.ts +11 -0
  42. node_modules/@simplewebauthn/server/esm/helpers/decodeCredentialPublicKey.d.ts.map +1 -0
  43. node_modules/@simplewebauthn/server/esm/helpers/decodeCredentialPublicKey.js +11 -0
  44. node_modules/@simplewebauthn/server/esm/helpers/fetch.d.ts +13 -0
  45. node_modules/@simplewebauthn/server/esm/helpers/fetch.d.ts.map +1 -0
  46. node_modules/@simplewebauthn/server/esm/helpers/fetch.js +14 -0
  47. node_modules/@simplewebauthn/server/esm/helpers/generateChallenge.d.ts +13 -0
  48. node_modules/@simplewebauthn/server/esm/helpers/generateChallenge.d.ts.map +1 -0
  49. node_modules/@simplewebauthn/server/esm/helpers/generateChallenge.js +24 -0
  50. node_modules/@simplewebauthn/server/esm/helpers/generateUserID.d.ts +13 -0
.gitattributes CHANGED
@@ -41,3 +41,6 @@ node_modules/@rolldown/binding-linux-x64-gnu/rolldown-binding.linux-x64-gnu.node
41
  node_modules/@rolldown/binding-linux-x64-musl/rolldown-binding.linux-x64-musl.node filter=lfs diff=lfs merge=lfs -text
42
  node_modules/@rollup/rollup-linux-x64-gnu/rollup.linux-x64-gnu.node filter=lfs diff=lfs merge=lfs -text
43
  node_modules/@rollup/rollup-linux-x64-musl/rollup.linux-x64-musl.node filter=lfs diff=lfs merge=lfs -text
 
 
 
 
41
  node_modules/@rolldown/binding-linux-x64-musl/rolldown-binding.linux-x64-musl.node filter=lfs diff=lfs merge=lfs -text
42
  node_modules/@rollup/rollup-linux-x64-gnu/rollup.linux-x64-gnu.node filter=lfs diff=lfs merge=lfs -text
43
  node_modules/@rollup/rollup-linux-x64-musl/rollup.linux-x64-musl.node filter=lfs diff=lfs merge=lfs -text
44
+ node_modules/@swc/core-linux-x64-gnu/swc.linux-x64-gnu.node filter=lfs diff=lfs merge=lfs -text
45
+ node_modules/@swc/core-linux-x64-musl/swc.linux-x64-musl.node filter=lfs diff=lfs merge=lfs -text
46
+ node_modules/@trivago/prettier-plugin-sort-imports/.yarn/install-state.gz filter=lfs diff=lfs merge=lfs -text
node_modules/@scarf/scarf/LICENSE ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2020 Scarf Systems, Inc.
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
node_modules/@scarf/scarf/README.md ADDED
@@ -0,0 +1,198 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # scarf-js
2
+
3
+ ![](https://github.com/scarf-sh/scarf-js/workflows/CI/badge.svg)
4
+ [![npm version](https://badge.fury.io/js/%40scarf%2Fscarf.svg)](https://badge.fury.io/js/%40scarf%2Fscarf)
5
+ <a href="https://www.npmjs.com/package/@scarf/scarf">![](https://img.shields.io/npm/dw/@scarf/scarf)</a>
6
+ <img referrerpolicy="no-referrer-when-downgrade" src="https://static.scarf.sh/a.png?x-pxid=fc72d03c-c3a2-4736-b243-10eeff839778" />
7
+ <a href="https://tinyurl.com/scarf-community-slack"><img src="https://img.shields.io/badge/Scarf%20Community%20-Slack-blue" alt="Join the Scarf Community Slack" />
8
+ </a>
9
+
10
+ Scarf is like Google Analytics for your npm packages. By sending some basic
11
+ details after installation, this package can help you can gain insight into how
12
+ your packages are used and by which companies. Scarf aims to help open-source developers
13
+ fund their work when it is used commercially.
14
+
15
+ To read more about why we wrote this library, check out [this post](https://github.com/scarf-sh/scarf-js/blob/master/WHY.org) on the topic.
16
+
17
+ ### Features
18
+
19
+ - No dependencies.
20
+ - Fully transparent to the user. Scarf will log its behavior to the console
21
+ during installation. It will never silently report analytics for someone that
22
+ hasn't explictly given permission to do so.
23
+ - Never interrupts your package installation. Reporting is done on a best effort basis.
24
+
25
+ ### Installing
26
+
27
+ You'll first need to create a library entry on [Scarf](https://scarf.sh). Once
28
+ created, add a dependency on this library to your own:
29
+
30
+ ```bash
31
+ npm i --save @scarf/scarf
32
+ ```
33
+
34
+ Once your library is published to npm with this change, Scarf will automatically
35
+ collect stats on install, no additional code is required!
36
+
37
+ Head to your package's dashboard on Scarf to see your reports when available.
38
+
39
+ ### Configuring
40
+
41
+ Users of your package will be opted in by default and can opt out by setting the
42
+ `SCARF_ANALYTICS=false` environment variable. If you'd like Scarf analytics to
43
+ instead be opt-in, you can set this by adding an entry to your `package.json`
44
+
45
+
46
+ ```json5
47
+ // your-package/package.json
48
+
49
+ {
50
+ // ...
51
+ "scarfSettings": {
52
+ "defaultOptIn": false
53
+ }
54
+ // ...
55
+ }
56
+ ```
57
+
58
+ Scarf will now be opt-out by default, and users can set `SCARF_ANALYTICS=true`
59
+ to opt in.
60
+
61
+ Regardless of the default state, Scarf will log what it is doing to users who
62
+ haven't explictly opted in or out.
63
+
64
+ By default, scarf-js will only trigger analytics when your package is installed as a dependency of another package, or is being installed globally. This ensures that scarf-js analytics will not be triggered on `npm install` being run _within your project_. To change this, you can add:
65
+
66
+ ```json5
67
+ // your-package/package.json
68
+
69
+ {
70
+ // ...
71
+ "scarfSettings": {
72
+ "allowTopLevel": true
73
+ }
74
+ // ...
75
+ }
76
+ ```
77
+
78
+
79
+ #### Full Configuration Example
80
+
81
+ ```json5
82
+ // your-package/package.json
83
+
84
+ {
85
+ // ...
86
+ "scarfSettings": {
87
+ // Toggles whether Scarf is enabled for this package
88
+ "enabled": true,
89
+ // Enables Scarf when users run npm install directly in your repository
90
+ // Scarf will try to report the Git commit SHA of your repository if it can
91
+ // be obtained.
92
+ "allowTopLevel": true,
93
+ // Users will be opted into analytics by default
94
+ "defaultOptIn": true,
95
+ // By default, Scarf searches for its own location in your build's dependency
96
+ // graph to ensure reporting can be done for all packages using Scarf.
97
+ // For large projects with lots of dependencies, generating that dependency
98
+ // graph takes more time than Scarf allots for its entire process, so Scarf
99
+ // will always time out. `skipTraversal` is an optional flag for large
100
+ // applications to skip that traversal entirely. Use this flag with caution and
101
+ // care, as it will break Scarf analytics for all other packages you depend
102
+ // on in your build.
103
+ "skipTraversal": false
104
+ }
105
+ // ...
106
+ }
107
+ ```
108
+
109
+ ### FAQ
110
+
111
+ #### What information does scarf-js provide me as a package author?
112
+
113
+ - Understanding your user-base
114
+ - Which companies are using your package?
115
+ - Is your project growing or shrinking? Where? On which platforms?
116
+ - Which versions of your package are being used?
117
+
118
+ #### As a user of a package using scarf-js, what information does scarf-js send about me?
119
+
120
+ *Scarf does not store personally identifying information.* Scarf aims to collect information that is helpful for:
121
+ - Open Source package maintainence
122
+ - Open Source commercialization
123
+
124
+ Specifically, scarf-js sends:
125
+
126
+ - The operating system you are using
127
+ - Your IP address will be used to look up any available company information. _Scarf does not store the actual IP address_
128
+ - Limited dependency tree information. Scarf sends the name and version of the package(s) that directly depend on scarf-js. Additionally, scarf-js will send SHA256-hashed name and version for the following packages in the dependency tree:
129
+ - Packages that depend on a package that depends on scarf-js.
130
+ - The root package of the dependency tree.
131
+ This allows Scarf to provide information for maintainers about which public packages are using their own, without exposing identifying details of non-public packages.
132
+
133
+ You can have scarf-js print the exact JSON payload it sends by setting `SCARF_VERBOSE=true` in your environment.
134
+
135
+ #### As a user of a package using scarf-js, how can I opt out of analytics?
136
+
137
+ Scarf's analytics help support developers of the open source packages you are
138
+ using, so enabling analytics is appreciated. However, if you'd like to opt out,
139
+ you can add your preference to your project's `package.json`:
140
+
141
+
142
+ ```json5
143
+ // your-package/package.json
144
+
145
+ {
146
+ // ...
147
+ "scarfSettings": {
148
+ "enabled": false
149
+ }
150
+ // ...
151
+ }
152
+ ```
153
+
154
+ Alternatively, you can set this variable in your environment:
155
+
156
+ ```shell
157
+ export SCARF_ANALYTICS=false
158
+ ```
159
+
160
+ You can also set this variable in accordance to the [Console Do Not Track](https://consoledonottrack.com/) standard:
161
+ ```shell
162
+ export DO_NOT_TRACK=1
163
+ ```
164
+
165
+ Either route will disable Scarf for all packages.
166
+
167
+ #### I distribute a package on npm, and scarf-js is in our dependency tree. Can I disable the analytics for my downstream dependents?
168
+
169
+ Yes. By opting out of analytics via `package.json`, any package upstream will have analytics disbabled.
170
+
171
+ ```json5
172
+ // your-package/package.json
173
+
174
+ {
175
+ // ...
176
+ "scarfSettings": {
177
+ "enabled": false
178
+ }
179
+ // ...
180
+ }
181
+ ```
182
+
183
+ Installers of your packages will have scarf-js disabled for all dependencies upstream from yours.
184
+
185
+
186
+ ### Developing
187
+
188
+ Setting the environment variable `SCARF_LOCAL_PORT=8080` will configure Scarf to
189
+ use http://localhost:8080 as the analytics endpoint host.
190
+
191
+ ### Future work
192
+
193
+ Future releases of scarf-js will provide a module of utility functions to
194
+ collect usage analytics in addition to the current installation analytics.
195
+
196
+ ### Community
197
+
198
+ Join the [Scarf-Community workspace](https://tinyurl.com/scarf-community-slack) on Slack and find us in the #scarf-js channel. We'll keep an eye out for your questions and concerns.
node_modules/@scarf/scarf/package.json ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@scarf/scarf",
3
+ "version": "1.4.0",
4
+ "description": "Scarf is like Google Analytics for your npm packages. Gain insights into how your packages are installed and used, and by which companies.",
5
+ "main": "report.js",
6
+ "homepage": "https://github.com/scarf-sh/scarf-js",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/scarf-sh/scarf-js.git"
10
+ },
11
+ "files": [
12
+ "report.js"
13
+ ],
14
+ "scripts": {
15
+ "postinstall": "node ./report.js",
16
+ "test": "jest --verbose"
17
+ },
18
+ "author": "Scarf Systems",
19
+ "license": "Apache-2.0",
20
+ "devDependencies": {
21
+ "jest": "^25.3.0",
22
+ "minimist": "^1.2.2",
23
+ "standard": "^14.3.1"
24
+ },
25
+ "standard": {
26
+ "globals": [
27
+ "expect",
28
+ "test",
29
+ "jest",
30
+ "beforeAll",
31
+ "afterAll",
32
+ "fail",
33
+ "describe"
34
+ ]
35
+ }
36
+ }
node_modules/@scarf/scarf/report.js ADDED
@@ -0,0 +1,574 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const path = require('path')
2
+ const os = require('os')
3
+ const exec = require('child_process').exec
4
+ const localDevPort = process.env.SCARF_LOCAL_PORT
5
+ const https = localDevPort ? require('http') : require('https')
6
+ const fs = require('fs')
7
+ const fsAsync = fs.promises
8
+ const util = require('util')
9
+
10
+ const scarfHost = localDevPort ? 'localhost' : 'scarf.sh'
11
+ const scarfLibName = '@scarf/scarf'
12
+ const privatePackageRewrite = '@private/private'
13
+ const privateVersionRewrite = '0'
14
+
15
+ const rootPath = process.env.INIT_CWD
16
+
17
+ // Pulled into a function for test mocking
18
+ function tmpFileName () {
19
+ // throttle per user
20
+ const username = os.userInfo().username
21
+ return path.join(os.tmpdir(), `scarf-js-history-${username}.log`)
22
+ }
23
+
24
+ // Pulled into a function for test mocking
25
+ function dirName () {
26
+ return __dirname
27
+ }
28
+
29
+ function npmExecPath () {
30
+ return process.env.npm_execpath
31
+ }
32
+
33
+ const userMessageThrottleTime = 1000 * 60 // 1 minute
34
+
35
+ const execTimeout = 3000
36
+
37
+ // In general, these keys should never change to remain backwards compatible
38
+ // with previous versions of Scarf. If we need to update them, we'll need to
39
+ // make sure we can read the previous values as well
40
+ const optedInLogRateLimitKey = 'optedInLastLog'
41
+ const optedOutLogRateLimitKey = 'optedOutLastLog'
42
+
43
+ const makeDefaultSettings = () => {
44
+ return {
45
+ defaultOptIn: true
46
+ }
47
+ }
48
+
49
+ function logIfVerbose (toLog, stream) {
50
+ if (process.env.SCARF_VERBOSE === 'true') {
51
+ (stream || console.log)(toLog)
52
+ }
53
+ }
54
+
55
+ // SCARF_NO_ANALYTICS was the original variable, we'll get rid of it eventually
56
+ const userHasOptedOut = (rootPackage) => {
57
+ return (rootPackage && rootPackage.scarfSettings && rootPackage.scarfSettings.enabled === false) ||
58
+ (process.env.SCARF_ANALYTICS === 'false' || process.env.SCARF_NO_ANALYTICS === 'true' || process.env.DO_NOT_TRACK === '1')
59
+ }
60
+
61
+ const userHasOptedIn = (rootPackage) => {
62
+ return (rootPackage && rootPackage.scarfSettings && rootPackage.scarfSettings.enabled) || process.env.SCARF_ANALYTICS === 'true'
63
+ }
64
+
65
+ // Packages that depend on Scarf can configure whether to should fire when
66
+ // `npm install` is being run directly from within the package, rather than from a
67
+ // dependent package
68
+ function allowTopLevel (rootPackage) {
69
+ return rootPackage && rootPackage.scarfSettings && rootPackage.scarfSettings.allowTopLevel
70
+ }
71
+
72
+ function skipTraversal (rootPackage) {
73
+ return rootPackage && rootPackage.scarfSettings && rootPackage.scarfSettings.skipTraversal
74
+ }
75
+
76
+ function parentIsRoot (dependencyToReport) {
77
+ const parent = dependencyToReport.parent
78
+ const rootPackage = dependencyToReport.rootPackage
79
+
80
+ return parent && rootPackage && parent.name === rootPackage.name && parent.version === rootPackage.version
81
+ }
82
+
83
+ function isTopLevel (dependencyToReport) {
84
+ return parentIsRoot(dependencyToReport) && !process.env.npm_config_global
85
+ }
86
+
87
+ function isGlobal (dependencyToReport) {
88
+ return parentIsRoot(dependencyToReport) && !!process.env.npm_config_global
89
+ }
90
+
91
+ function hashWithDefault (toHash, defaultReturn) {
92
+ let crypto
93
+ try {
94
+ crypto = require('crypto')
95
+ } catch (err) {
96
+ logIfVerbose('node crypto module unavailable')
97
+ }
98
+
99
+ if (crypto && toHash) {
100
+ return crypto.createHash('sha256').update(toHash, 'utf-8').digest('hex')
101
+ } else {
102
+ return defaultReturn
103
+ }
104
+ }
105
+
106
+ // We don't send any paths, hash package names and versions
107
+ function redactSensitivePackageInfo (dependencyInfo) {
108
+ if (dependencyInfo.grandparent && dependencyInfo.grandparent.name) {
109
+ dependencyInfo.grandparent.nameHash = hashWithDefault(dependencyInfo.grandparent.name, privatePackageRewrite)
110
+ dependencyInfo.grandparent.versionHash = hashWithDefault(dependencyInfo.grandparent.version, privateVersionRewrite)
111
+ }
112
+
113
+ if (dependencyInfo.rootPackage && dependencyInfo.rootPackage.name) {
114
+ dependencyInfo.rootPackage.nameHash = hashWithDefault(dependencyInfo.rootPackage.name, privatePackageRewrite)
115
+ dependencyInfo.rootPackage.versionHash = hashWithDefault(dependencyInfo.rootPackage.version, privateVersionRewrite)
116
+ }
117
+
118
+ delete (dependencyInfo.rootPackage.packageJsonPath)
119
+ delete (dependencyInfo.rootPackage.path)
120
+ delete (dependencyInfo.rootPackage.name)
121
+ delete (dependencyInfo.rootPackage.version)
122
+ delete (dependencyInfo.parent.path)
123
+ delete (dependencyInfo.scarf.path)
124
+ if (dependencyInfo.grandparent) {
125
+ delete (dependencyInfo.grandparent.path)
126
+ delete (dependencyInfo.grandparent.name)
127
+ delete (dependencyInfo.grandparent.version)
128
+ }
129
+ return dependencyInfo
130
+ }
131
+
132
+ /*
133
+ Scarf-js is automatically disabled when being run inside of a yarn install.
134
+ The `npm_execpath` environment variable tells us which package manager is
135
+ running our install
136
+ */
137
+ function isYarn () {
138
+ const execPath = module.exports.npmExecPath() || ''
139
+ return ['yarn', 'yarn.js', 'yarnpkg', 'yarn.cmd', 'yarnpkg.cmd']
140
+ .some(packageManBinName => execPath.endsWith(packageManBinName))
141
+ }
142
+
143
+ function processDependencyTreeOutput (resolve, reject) {
144
+ return function (error, stdout, stderr) {
145
+ if (error && !stdout) {
146
+ return reject(new Error(`Scarf received an error from npm -ls: ${error} | ${stderr}`))
147
+ }
148
+
149
+ try {
150
+ const output = JSON.parse(stdout)
151
+
152
+ const depsToScarf = findScarfInFullDependencyTree(output).filter(depChain => depChain.length >= 2)
153
+ if (!depsToScarf.length) {
154
+ return reject(new Error('No Scarf parent package found'))
155
+ }
156
+ const rootPackageDetails = rootPackageDepInfo(output)
157
+
158
+ const dependencyInfo = depsToScarf.map(depChain => {
159
+ return {
160
+ scarf: depChain[depChain.length - 1],
161
+ parent: depChain[depChain.length - 2],
162
+ grandparent: depChain[depChain.length - 3],
163
+ rootPackage: rootPackageDetails,
164
+ anyInChainDisabled: depChain.some(dep => {
165
+ return (dep.scarfSettings || {}).enabled === false
166
+ })
167
+ }
168
+ })
169
+
170
+ dependencyInfo.forEach(d => {
171
+ d.parent.scarfSettings = Object.assign(makeDefaultSettings(), d.parent.scarfSettings || {})
172
+ })
173
+
174
+ // Here, we find the dependency chain that corresponds to the scarf package we're currently in
175
+ const dependencyToReport = dependencyInfo.find(dep => (dep.scarf.path === module.exports.dirName())) || dependencyInfo[0]
176
+ if (!dependencyToReport) {
177
+ return reject(new Error(`Couldn't find dependency info for path ${module.exports.dirName()}`))
178
+ }
179
+
180
+ // If any intermediate dependency in the chain of deps that leads to scarf
181
+ // has disabled Scarf, we must respect that setting unless the user overrides it.
182
+ if (dependencyToReport.anyInChainDisabled && !userHasOptedIn(dependencyToReport.rootPackage)) {
183
+ return reject(new Error('Scarf has been disabled via a package.json in the dependency chain.'))
184
+ }
185
+
186
+ if (isTopLevel(dependencyToReport) && !isGlobal(dependencyToReport) && !allowTopLevel(rootPackageDetails)) {
187
+ return reject(new Error('The package depending on Scarf is the root package being installed, but Scarf is not configured to run in this case. To enable it, set `scarfSettings.allowTopLevel = true` in your package.json'))
188
+ }
189
+
190
+ return resolve(dependencyToReport)
191
+ } catch (err) {
192
+ logIfVerbose(err, console.error)
193
+ return reject(err)
194
+ }
195
+ }
196
+ }
197
+
198
+ function processGitRevParseOutput (resolve, reject) {
199
+ return function (error, stdout, stderr) {
200
+ if (error && !stdout) {
201
+ return reject(new Error(`Scarf received an error from git rev-parse: ${error} | ${stderr}`))
202
+ }
203
+
204
+ const output = String(stdout).trim()
205
+
206
+ if (output.length > 0) {
207
+ return resolve(output)
208
+ } else {
209
+ return reject(new Error('Scarf did not receive usable output from git rev-parse'))
210
+ }
211
+ }
212
+ }
213
+
214
+ // packageJSONOverride: a test convenience to set a packageJSON explicitly.
215
+ // Leave empty to use the actual root package.json.
216
+ async function getDependencyInfo (packageJSONOverride) {
217
+ try {
218
+ const rootPackageJSON = require(packageJSONOverride || path.join(rootPath, 'package.json'))
219
+ const scarfPackageJSON = require(path.join(dirName(), 'package.json'))
220
+
221
+ if (skipTraversal(rootPackageJSON)) {
222
+ logIfVerbose('skipping dependency tree traversal')
223
+ const rootInfoToReport = {
224
+ name: rootPackageJSON.name,
225
+ version: rootPackageJSON.version,
226
+ scarfSettings: { ...makeDefaultSettings(), ...rootPackageJSON.scarfSettings }
227
+ }
228
+ const shallowDepInfo = {
229
+ scarf: { name: '@scarf/scarf', version: scarfPackageJSON.version },
230
+ parent: { ...rootInfoToReport },
231
+ rootPackage: { ...rootInfoToReport },
232
+ anyInChainDisabled: false,
233
+ skippedTraversal: true
234
+ }
235
+ logIfVerbose(util.inspect(shallowDepInfo))
236
+ return shallowDepInfo
237
+ }
238
+ } catch (err) {
239
+ logIfVerbose(err, console.error)
240
+ }
241
+
242
+ return new Promise((resolve, reject) => {
243
+ exec(`cd ${rootPath} && npm ls @scarf/scarf --json --long`, { timeout: execTimeout, maxBuffer: 1024 * 1024 * 1024 }, processDependencyTreeOutput(resolve, reject))
244
+ })
245
+ }
246
+
247
+ async function getGitShaFromRootPath () {
248
+ const promise = new Promise((resolve, reject) => {
249
+ exec(`cd ${rootPath} && git rev-parse HEAD`, { timeout: execTimeout, maxBuffer: 1024 * 1024 * 1024 }, processGitRevParseOutput(resolve, reject))
250
+ })
251
+ try {
252
+ return await promise
253
+ } catch (e) {
254
+ logIfVerbose(e)
255
+ return undefined
256
+ }
257
+ }
258
+
259
+ async function reportPostInstall () {
260
+ const scarfApiToken = process.env.SCARF_API_TOKEN
261
+
262
+ const dependencyInfo = await module.exports.getDependencyInfo()
263
+ logIfVerbose(dependencyInfo)
264
+ if (!dependencyInfo.parent || !dependencyInfo.parent.name) {
265
+ return Promise.reject(new Error('No parent found, nothing to report'))
266
+ }
267
+
268
+ if (parentIsRoot(dependencyInfo) && allowTopLevel(dependencyInfo.rootPackage)) {
269
+ const gitSha = await getGitShaFromRootPath()
270
+ logIfVerbose(`Injecting sha to parent: ${gitSha}`)
271
+ dependencyInfo.parent.gitSha = gitSha
272
+ }
273
+
274
+ const rootPackage = dependencyInfo.rootPackage
275
+
276
+ if (!userHasOptedIn(rootPackage) && isYarn()) {
277
+ return Promise.reject(new Error('Package manager is yarn. scarf-js is unable to inform user of analytics. Aborting.'))
278
+ }
279
+
280
+ await new Promise((resolve, reject) => {
281
+ if (dependencyInfo.parent.scarfSettings.defaultOptIn) {
282
+ if (userHasOptedOut(rootPackage)) {
283
+ return reject(new Error('User has opted out'))
284
+ }
285
+
286
+ if (!userHasOptedIn(rootPackage)) {
287
+ rateLimitedUserLog(optedInLogRateLimitKey, `
288
+ The dependency '${dependencyInfo.parent.name}' is tracking installation
289
+ statistics using scarf-js (https://scarf.sh), which helps open-source developers
290
+ fund and maintain their projects. Scarf securely logs basic installation
291
+ details when this package is installed. The Scarf npm library is open source
292
+ and permissively licensed at https://github.com/scarf-sh/scarf-js. For more
293
+ details about your project's dependencies, try running 'npm ls'. To opt out of
294
+ analytics, set the environment variable 'SCARF_ANALYTICS=false'.
295
+ `)
296
+ }
297
+ resolve(dependencyInfo)
298
+ } else {
299
+ if (!userHasOptedIn(rootPackage)) {
300
+ if (!userHasOptedOut(rootPackage)) {
301
+ // We'll only print the 'please opt in' text if the user hasn't
302
+ // already opted out, and our logging rate limit hasn't been reached
303
+ if (hasHitRateLimit(optedOutLogRateLimitKey, getRateLimitedLogHistory())) {
304
+ return reject(new Error('Analytics are opt-out by default, but rate limit already hit for prompting opt-in.'))
305
+ }
306
+ rateLimitedUserLog(optedOutLogRateLimitKey, `
307
+ The dependency '${dependencyInfo.parent.name}' would like to track
308
+ installation statistics using scarf-js (https://scarf.sh), which helps
309
+ open-source developers fund and maintain their projects. Reporting is disabled
310
+ by default for this package. When enabled, Scarf securely logs basic
311
+ installation details when this package is installed. The Scarf npm library is
312
+ open source and permissively licensed at https://github.com/scarf-sh/scarf-js.
313
+ For more details about your project's dependencies, try running 'npm ls'.
314
+ `
315
+ )
316
+ const stdin = process.stdin
317
+ stdin.setEncoding('utf-8')
318
+
319
+ process.stdout.write(`Would you like to support ${dependencyInfo.parent.name} by sending analytics for this install? (y/N): `)
320
+
321
+ const timeout1 = setTimeout(() => {
322
+ console.log('')
323
+ console.log('No opt in received, skipping analytics')
324
+ reject(new Error('Timeout waiting for user opt in'))
325
+ }, 7000)
326
+
327
+ stdin.on('data', async function (data) {
328
+ clearTimeout(timeout1)
329
+ const enabled = data.trim().toLowerCase() === 'y'
330
+
331
+ const afterUserInput = (enabled, saved) => {
332
+ if (enabled) {
333
+ console.log('Thanks for enabling analytics!')
334
+ }
335
+
336
+ if (!saved) {
337
+ console.log('To prevent this message in the future, you can also set the `SCARF_ANALYTICS=true|false` environment variable')
338
+ }
339
+
340
+ if (enabled) {
341
+ return resolve(dependencyInfo)
342
+ } else {
343
+ return reject(new Error('Not enabled via cli'))
344
+ }
345
+ }
346
+
347
+ process.stdout.write('Save this preference to your project\'s package.json file? (y/N): ')
348
+
349
+ setTimeout(() => {
350
+ console.log('')
351
+ return afterUserInput(enabled, false)
352
+ }, 15000)
353
+
354
+ stdin.removeAllListeners('data')
355
+ stdin.on('data', async function (data) {
356
+ try {
357
+ const savePreference = data.trim().toLowerCase() === 'y'
358
+ if (savePreference) {
359
+ await savePreferencesToRootPackage(dependencyInfo.rootPackage.packageJsonPath, enabled)
360
+ }
361
+ return afterUserInput(enabled, savePreference)
362
+ } catch (err) {
363
+ logIfVerbose(err, console.error)
364
+ return reject(err)
365
+ }
366
+ })
367
+ })
368
+ }
369
+ } else {
370
+ resolve(dependencyInfo)
371
+ }
372
+ }
373
+ })
374
+
375
+ redactSensitivePackageInfo(dependencyInfo)
376
+
377
+ const infoPayload = {
378
+ libraryType: 'npm',
379
+ rawPlatform: os.platform(),
380
+ rawArch: os.arch(),
381
+ nodeVersion: process.versions.node,
382
+ dependencyInfo: dependencyInfo
383
+ }
384
+
385
+ const data = JSON.stringify(infoPayload)
386
+ logIfVerbose(`Scarf payload: ${data}`)
387
+
388
+ const reqOptions = {
389
+ host: scarfHost,
390
+ port: localDevPort,
391
+ method: 'POST',
392
+ path: '/package-event/install',
393
+ headers: {
394
+ 'Content-Type': 'application/json',
395
+ 'Content-Length': data.length
396
+ },
397
+ timeout: execTimeout
398
+ }
399
+
400
+ if (scarfApiToken) {
401
+ const authToken = Buffer.from(`n/a:${scarfApiToken}`).toString('base64')
402
+ reqOptions.headers.Authorization = `Basic ${authToken}`
403
+ }
404
+
405
+ await new Promise((resolve, reject) => {
406
+ const req = https.request(reqOptions, (res) => {
407
+ logIfVerbose(`Response status: ${res.statusCode}`)
408
+ resolve()
409
+ })
410
+
411
+ req.on('error', error => {
412
+ logIfVerbose(error, console.error)
413
+ reject(error)
414
+ })
415
+
416
+ req.on('timeout', error => {
417
+ logIfVerbose(error, console.error)
418
+ reject(error)
419
+ })
420
+
421
+ req.write(data)
422
+ req.end()
423
+ })
424
+ }
425
+
426
+ // Find all paths to Scarf from the json output of npm ls @scarf/scarf --json in
427
+ // the root package being installed by the user
428
+ //
429
+ // [{
430
+ // scarf: {name: `@scarf/scarf`, version: '0.0.1'},
431
+ // parent: { name: 'scarfed-library', version: '1.0.0', scarfSettings: { defaultOptIn: true } },
432
+ // grandparent: { name: 'scarfed-lib-consumer', version: '1.0.0' }
433
+ // }]
434
+ function findScarfInSubDepTree (pathToDep, deps) {
435
+ const depNames = Object.keys(deps || {})
436
+
437
+ if (!depNames) {
438
+ return []
439
+ }
440
+
441
+ const scarfFound = depNames.find(depName => depName === scarfLibName)
442
+ const output = []
443
+ if (scarfFound) {
444
+ output.push(pathToDep.concat([{ name: scarfLibName, version: deps[scarfLibName].version, path: deps[scarfLibName].path }]))
445
+ }
446
+ for (let i = 0; i < depNames.length; i++) {
447
+ const depName = depNames[i]
448
+ const newPathToDep = pathToDep.concat([
449
+ {
450
+ name: depName,
451
+ version: deps[depName].version,
452
+ scarfSettings: deps[depName].scarfSettings,
453
+ path: deps[depName].path
454
+ }
455
+ ])
456
+ const results = findScarfInSubDepTree(newPathToDep, deps[depName].dependencies)
457
+ if (results) {
458
+ for (let j = 0; j < results.length; j++) {
459
+ output.push(results[j])
460
+ }
461
+ }
462
+ }
463
+
464
+ return output
465
+ }
466
+
467
+ function findScarfInFullDependencyTree (tree) {
468
+ if (tree.name === scarfLibName) {
469
+ return [[{ name: scarfLibName, version: tree.version }]]
470
+ } else {
471
+ return findScarfInSubDepTree([packageDetailsFromDepInfo(tree)], tree.dependencies)
472
+ }
473
+ }
474
+
475
+ function packageDetailsFromDepInfo (tree) {
476
+ return {
477
+ name: tree.name,
478
+ version: tree.version,
479
+ scarfSettings: tree.scarfSettings,
480
+ path: tree.path
481
+ }
482
+ }
483
+
484
+ function rootPackageDepInfo (packageInfo) {
485
+ if (process.env.npm_config_global) {
486
+ packageInfo = Object.values(packageInfo.dependencies)[0]
487
+ }
488
+ const info = packageDetailsFromDepInfo(packageInfo)
489
+ info.packageJsonPath = `${packageInfo.path}/package.json`
490
+ return info
491
+ }
492
+
493
+ async function savePreferencesToRootPackage (path, optIn) {
494
+ const packageJsonString = await fsAsync.readFile(path)
495
+ const parsed = JSON.parse(packageJsonString)
496
+ parsed.scarfSettings = {
497
+ enabled: optIn
498
+ }
499
+ await fsAsync.writeFile(path, JSON.stringify(parsed, null, 2))
500
+ }
501
+
502
+ /*
503
+ If Scarf-js appears in many different spots in a package's dependency tree, we
504
+ want to avoid spamming the user with the same message informing them of
505
+ Scarf's analytics. Rate limited logs will record timestamps of logging in a
506
+ temp file. Before logging something to the user, we will verify we're not over
507
+ the rate limit.
508
+ */
509
+ function rateLimitedUserLog (rateLimitKey, toLog) {
510
+ const history = getRateLimitedLogHistory()
511
+ if (!hasHitRateLimit(rateLimitKey, history)) {
512
+ writeCurrentTimeToLogHistory(rateLimitKey, history)
513
+ console.log(toLog)
514
+ } else {
515
+ logIfVerbose(`[SUPPRESSED USER MESSAGE, RATE LIMIT HIT] ${toLog}`)
516
+ }
517
+ }
518
+
519
+ function getRateLimitedLogHistory () {
520
+ let history
521
+ try {
522
+ history = JSON.parse(fs.readFileSync(module.exports.tmpFileName()))
523
+ } catch (e) {
524
+ logIfVerbose(e)
525
+ }
526
+ return history || {}
527
+ }
528
+
529
+ // Current rate limit: 1/minute
530
+ function hasHitRateLimit (rateLimitKey, history) {
531
+ if (!history || !history[rateLimitKey]) {
532
+ return false
533
+ }
534
+
535
+ const lastLog = history[rateLimitKey]
536
+ return (new Date().getTime() - lastLog) < userMessageThrottleTime
537
+ }
538
+
539
+ function writeCurrentTimeToLogHistory (rateLimitKey, history) {
540
+ history[rateLimitKey] = new Date().getTime()
541
+ fs.writeFileSync(module.exports.tmpFileName(), JSON.stringify(history))
542
+ }
543
+
544
+ module.exports = {
545
+ redactSensitivePackageInfo,
546
+ hasHitRateLimit,
547
+ getRateLimitedLogHistory,
548
+ rateLimitedUserLog,
549
+ tmpFileName,
550
+ dirName,
551
+ processDependencyTreeOutput,
552
+ processGitRevParseOutput,
553
+ npmExecPath,
554
+ getDependencyInfo,
555
+ getGitShaFromRootPath,
556
+ reportPostInstall,
557
+ hashWithDefault,
558
+ findScarfInFullDependencyTree
559
+ }
560
+
561
+ if (require.main === module) {
562
+ try {
563
+ reportPostInstall().catch(e => {
564
+ // This is an optional, best effort attempt. If there are any errors in
565
+ // Scarf, we must not interfere with whatever the user is doing
566
+ logIfVerbose(`\n\n${e}`, console.error)
567
+ }).finally(() => {
568
+ process.exit(0)
569
+ })
570
+ } catch (e) {
571
+ logIfVerbose(`\n\nTop level error: ${e}`, console.error)
572
+ process.exit(0)
573
+ }
574
+ }
node_modules/@simplewebauthn/server/LICENSE.md ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Matthew Miller
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
6
+ associated documentation files (the "Software"), to deal in the Software without restriction,
7
+ including without limitation the rights to use, copy, modify, merge, publish, distribute,
8
+ sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all copies or substantial
12
+ portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
15
+ NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
16
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
17
+ OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
node_modules/@simplewebauthn/server/README.md ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # @simplewebauthn/server <!-- omit in toc -->
2
+
3
+ ![WebAuthn](https://img.shields.io/badge/WebAuthn-Simplified-blueviolet?style=for-the-badge&logo=WebAuthn)
4
+ [![npm (scoped)](https://img.shields.io/npm/v/@simplewebauthn/server?style=for-the-badge&logo=npm)](https://www.npmjs.com/package/@simplewebauthn/server)
5
+ [![JSR](https://jsr.io/badges/@simplewebauthn/server?style=for-the-badge)](https://jsr.io/@simplewebauthn/server)
6
+
7
+ - [Installation](#installation)
8
+ - [Node LTS 20.x and higher](#node-lts-20x-and-higher)
9
+ - [Deno v1.43 and higher](#deno-v143-and-higher)
10
+ - [Documentation](#documentation)
11
+ - [Supported Attestation Formats](#supported-attestation-formats)
12
+
13
+ ## Installation
14
+
15
+ This package can be installed from **[NPM](https://www.npmjs.com/package/@simplewebauthn/server)**
16
+ and **[JSR](https://jsr.io/@simplewebauthn/server)**:
17
+
18
+ ### Node LTS 20.x and higher
19
+
20
+ ```sh
21
+ npm install @simplewebauthn/server
22
+ ```
23
+
24
+ ### Deno v1.43 and higher
25
+
26
+ ```sh
27
+ deno add jsr:@simplewebauthn/server
28
+ ```
29
+
30
+ ## Documentation
31
+
32
+ You can find in-depth documentation on this package here:
33
+ https://simplewebauthn.dev/docs/packages/server
34
+
35
+ ## Supported Attestation Formats
36
+
37
+ SimpleWebAuthn supports
38
+ [all current WebAuthn attestation formats](https://w3c.github.io/webauthn/#sctn-defined-attestation-formats),
39
+ including:
40
+
41
+ - **Android Key**
42
+ - **Android SafetyNet**
43
+ - **Apple**
44
+ - **FIDO U2F**
45
+ - **Packed**
46
+ - **TPM**
47
+ - **None**
node_modules/@simplewebauthn/server/esm/authentication/generateAuthenticationOptions.d.ts ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { AuthenticationExtensionsClientInputs, AuthenticatorTransportFuture, Base64URLString, PublicKeyCredentialRequestOptionsJSON, Uint8Array_ } from '../types/index.js';
2
+ export type GenerateAuthenticationOptionsOpts = Parameters<typeof generateAuthenticationOptions>[0];
3
+ /**
4
+ * Prepare a value to pass into navigator.credentials.get(...) for authenticator authentication
5
+ *
6
+ * **Options:**
7
+ *
8
+ * @param rpID - Valid domain name (after `https://`)
9
+ * @param allowCredentials **(Optional)** - Authenticators previously registered by the user, if any. If undefined the client will ask the user which credential they want to use
10
+ * @param challenge **(Optional)** - Random value the authenticator needs to sign and pass back user for authentication. Defaults to generating a random value
11
+ * @param timeout **(Optional)** - How long (in ms) the user can take to complete authentication. Defaults to `60000`
12
+ * @param userVerification **(Optional)** - Set to `'discouraged'` when asserting as part of a 2FA flow, otherwise set to `'preferred'` or `'required'` as desired. Defaults to `"preferred"`
13
+ * @param extensions **(Optional)** - Additional plugins the authenticator or browser should use during authentication
14
+ */
15
+ export declare function generateAuthenticationOptions(options: {
16
+ rpID: string;
17
+ allowCredentials?: {
18
+ id: Base64URLString;
19
+ transports?: AuthenticatorTransportFuture[];
20
+ }[];
21
+ challenge?: string | Uint8Array_;
22
+ timeout?: number;
23
+ userVerification?: 'required' | 'preferred' | 'discouraged';
24
+ extensions?: AuthenticationExtensionsClientInputs;
25
+ }): Promise<PublicKeyCredentialRequestOptionsJSON>;
26
+ //# sourceMappingURL=generateAuthenticationOptions.d.ts.map
node_modules/@simplewebauthn/server/esm/authentication/generateAuthenticationOptions.d.ts.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"file":"generateAuthenticationOptions.d.ts","sourceRoot":"","sources":["../../src/authentication/generateAuthenticationOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oCAAoC,EACpC,4BAA4B,EAC5B,eAAe,EACf,qCAAqC,EACrC,WAAW,EACZ,MAAM,mBAAmB,CAAC;AAI3B,MAAM,MAAM,iCAAiC,GAAG,UAAU,CAAC,OAAO,6BAA6B,CAAC,CAAC,CAAC,CAAC,CAAC;AAEpG;;;;;;;;;;;GAWG;AACH,wBAAsB,6BAA6B,CACjD,OAAO,EAAE;IACP,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB,CAAC,EAAE;QACjB,EAAE,EAAE,eAAe,CAAC;QACpB,UAAU,CAAC,EAAE,4BAA4B,EAAE,CAAC;KAC7C,EAAE,CAAC;IACJ,SAAS,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAE,UAAU,GAAG,WAAW,GAAG,aAAa,CAAC;IAC5D,UAAU,CAAC,EAAE,oCAAoC,CAAC;CACnD,GACA,OAAO,CAAC,qCAAqC,CAAC,CAoChD"}
node_modules/@simplewebauthn/server/esm/authentication/generateAuthenticationOptions.js ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { isoBase64URL, isoUint8Array } from '../helpers/iso/index.js';
2
+ import { generateChallenge } from '../helpers/generateChallenge.js';
3
+ /**
4
+ * Prepare a value to pass into navigator.credentials.get(...) for authenticator authentication
5
+ *
6
+ * **Options:**
7
+ *
8
+ * @param rpID - Valid domain name (after `https://`)
9
+ * @param allowCredentials **(Optional)** - Authenticators previously registered by the user, if any. If undefined the client will ask the user which credential they want to use
10
+ * @param challenge **(Optional)** - Random value the authenticator needs to sign and pass back user for authentication. Defaults to generating a random value
11
+ * @param timeout **(Optional)** - How long (in ms) the user can take to complete authentication. Defaults to `60000`
12
+ * @param userVerification **(Optional)** - Set to `'discouraged'` when asserting as part of a 2FA flow, otherwise set to `'preferred'` or `'required'` as desired. Defaults to `"preferred"`
13
+ * @param extensions **(Optional)** - Additional plugins the authenticator or browser should use during authentication
14
+ */
15
+ export async function generateAuthenticationOptions(options) {
16
+ const { allowCredentials, challenge = await generateChallenge(), timeout = 60000, userVerification = 'preferred', extensions, rpID, } = options;
17
+ /**
18
+ * Preserve ability to specify `string` values for challenges
19
+ */
20
+ let _challenge = challenge;
21
+ if (typeof _challenge === 'string') {
22
+ _challenge = isoUint8Array.fromUTF8String(_challenge);
23
+ }
24
+ return {
25
+ rpId: rpID,
26
+ challenge: isoBase64URL.fromBuffer(_challenge),
27
+ allowCredentials: allowCredentials?.map((cred) => {
28
+ if (!isoBase64URL.isBase64URL(cred.id)) {
29
+ throw new Error(`allowCredential id "${cred.id}" is not a valid base64url string`);
30
+ }
31
+ return {
32
+ ...cred,
33
+ id: isoBase64URL.trimPadding(cred.id),
34
+ type: 'public-key',
35
+ };
36
+ }),
37
+ timeout,
38
+ userVerification,
39
+ extensions,
40
+ };
41
+ }
node_modules/@simplewebauthn/server/esm/authentication/verifyAuthenticationResponse.d.ts ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { AuthenticationResponseJSON, Base64URLString, CredentialDeviceType, UserVerificationRequirement, WebAuthnCredential } from '../types/index.js';
2
+ import type { AuthenticationExtensionsAuthenticatorOutputs } from '../helpers/decodeAuthenticatorExtensions.js';
3
+ /**
4
+ * Configurable options when calling `verifyAuthenticationResponse()`
5
+ */
6
+ export type VerifyAuthenticationResponseOpts = Parameters<typeof verifyAuthenticationResponse>[0];
7
+ /**
8
+ * Verify that the user has legitimately completed the authentication process
9
+ *
10
+ * **Options:**
11
+ *
12
+ * @param response - Response returned by **@simplewebauthn/browser**'s `startAuthentication()`
13
+ * @param expectedChallenge - The base64url-encoded `options.challenge` returned by `generateAuthenticationOptions()`
14
+ * @param expectedOrigin - Website URL (or array of URLs) that the registration should have occurred on
15
+ * @param expectedRPID - RP ID (or array of IDs) that was specified in the registration options
16
+ * @param credential - An internal {@link WebAuthnCredential} corresponding to `id` in the authentication response
17
+ * @param expectedType **(Optional)** - The response type expected ('webauthn.get')
18
+ * @param requireUserVerification **(Optional)** - Enforce user verification by the authenticator (via PIN, fingerprint, etc...) Defaults to `true`
19
+ * @param advancedFIDOConfig **(Optional)** - Options for satisfying more stringent FIDO RP feature requirements
20
+ * @param advancedFIDOConfig.userVerification **(Optional)** - Enable alternative rules for evaluating the User Presence and User Verified flags in authenticator data: UV (and UP) flags are optional unless this value is `"required"`
21
+ */
22
+ export declare function verifyAuthenticationResponse(options: {
23
+ response: AuthenticationResponseJSON;
24
+ expectedChallenge: string | ((challenge: string) => boolean | Promise<boolean>);
25
+ expectedOrigin: string | string[];
26
+ expectedRPID: string | string[];
27
+ credential: WebAuthnCredential;
28
+ expectedType?: string | string[];
29
+ requireUserVerification?: boolean;
30
+ advancedFIDOConfig?: {
31
+ userVerification?: UserVerificationRequirement;
32
+ };
33
+ }): Promise<VerifiedAuthenticationResponse>;
34
+ /**
35
+ * Result of authentication verification
36
+ *
37
+ * @param verified If the authentication response could be verified
38
+ * @param authenticationInfo.credentialID The ID of the authenticator used during authentication.
39
+ * Should be used to identify which DB authenticator entry needs its `counter` updated to the value
40
+ * below
41
+ * @param authenticationInfo.newCounter The number of times the authenticator identified above
42
+ * reported it has been used. **Should be kept in a DB for later reference to help prevent replay
43
+ * attacks!**
44
+ * @param authenticationInfo.credentialDeviceType Whether this is a single-device or multi-device
45
+ * credential. **Should be kept in a DB for later reference!**
46
+ * @param authenticationInfo.credentialBackedUp Whether or not the multi-device credential has been
47
+ * backed up. Always `false` for single-device credentials. **Should be kept in a DB for later
48
+ * reference!**
49
+ * @param authenticationInfo.origin The origin of the website that the authentication occurred on
50
+ * @param authenticationInfo.rpID The RP ID that the authentication occurred on
51
+ * @param authenticationInfo?.authenticatorExtensionResults The authenticator extensions returned
52
+ * by the browser
53
+ */
54
+ export type VerifiedAuthenticationResponse = {
55
+ verified: boolean;
56
+ authenticationInfo: {
57
+ credentialID: Base64URLString;
58
+ newCounter: number;
59
+ userVerified: boolean;
60
+ credentialDeviceType: CredentialDeviceType;
61
+ credentialBackedUp: boolean;
62
+ origin: string;
63
+ rpID: string;
64
+ authenticatorExtensionResults?: AuthenticationExtensionsAuthenticatorOutputs;
65
+ };
66
+ };
67
+ //# sourceMappingURL=verifyAuthenticationResponse.d.ts.map
node_modules/@simplewebauthn/server/esm/authentication/verifyAuthenticationResponse.d.ts.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"file":"verifyAuthenticationResponse.d.ts","sourceRoot":"","sources":["../../src/authentication/verifyAuthenticationResponse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,0BAA0B,EAC1B,eAAe,EACf,oBAAoB,EACpB,2BAA2B,EAC3B,kBAAkB,EACnB,MAAM,mBAAmB,CAAC;AAM3B,OAAO,KAAK,EAAE,4CAA4C,EAAE,MAAM,6CAA6C,CAAC;AAIhH;;GAEG;AACH,MAAM,MAAM,gCAAgC,GAAG,UAAU,CAAC,OAAO,4BAA4B,CAAC,CAAC,CAAC,CAAC,CAAC;AAElG;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,4BAA4B,CAChD,OAAO,EAAE;IACP,QAAQ,EAAE,0BAA0B,CAAC;IACrC,iBAAiB,EAAE,MAAM,GAAG,CAAC,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;IAChF,cAAc,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAClC,YAAY,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAChC,UAAU,EAAE,kBAAkB,CAAC;IAC/B,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACjC,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,kBAAkB,CAAC,EAAE;QACnB,gBAAgB,CAAC,EAAE,2BAA2B,CAAC;KAChD,CAAC;CACH,GACA,OAAO,CAAC,8BAA8B,CAAC,CAmNzC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,MAAM,8BAA8B,GAAG;IAC3C,QAAQ,EAAE,OAAO,CAAC;IAClB,kBAAkB,EAAE;QAClB,YAAY,EAAE,eAAe,CAAC;QAC9B,UAAU,EAAE,MAAM,CAAC;QACnB,YAAY,EAAE,OAAO,CAAC;QACtB,oBAAoB,EAAE,oBAAoB,CAAC;QAC3C,kBAAkB,EAAE,OAAO,CAAC;QAC5B,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;QACb,6BAA6B,CAAC,EAAE,4CAA4C,CAAC;KAC9E,CAAC;CACH,CAAC"}
node_modules/@simplewebauthn/server/esm/authentication/verifyAuthenticationResponse.js ADDED
@@ -0,0 +1,171 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { decodeClientDataJSON } from '../helpers/decodeClientDataJSON.js';
2
+ import { toHash } from '../helpers/toHash.js';
3
+ import { verifySignature } from '../helpers/verifySignature.js';
4
+ import { parseAuthenticatorData } from '../helpers/parseAuthenticatorData.js';
5
+ import { parseBackupFlags } from '../helpers/parseBackupFlags.js';
6
+ import { matchExpectedRPID } from '../helpers/matchExpectedRPID.js';
7
+ import { isoBase64URL, isoUint8Array } from '../helpers/iso/index.js';
8
+ /**
9
+ * Verify that the user has legitimately completed the authentication process
10
+ *
11
+ * **Options:**
12
+ *
13
+ * @param response - Response returned by **@simplewebauthn/browser**'s `startAuthentication()`
14
+ * @param expectedChallenge - The base64url-encoded `options.challenge` returned by `generateAuthenticationOptions()`
15
+ * @param expectedOrigin - Website URL (or array of URLs) that the registration should have occurred on
16
+ * @param expectedRPID - RP ID (or array of IDs) that was specified in the registration options
17
+ * @param credential - An internal {@link WebAuthnCredential} corresponding to `id` in the authentication response
18
+ * @param expectedType **(Optional)** - The response type expected ('webauthn.get')
19
+ * @param requireUserVerification **(Optional)** - Enforce user verification by the authenticator (via PIN, fingerprint, etc...) Defaults to `true`
20
+ * @param advancedFIDOConfig **(Optional)** - Options for satisfying more stringent FIDO RP feature requirements
21
+ * @param advancedFIDOConfig.userVerification **(Optional)** - Enable alternative rules for evaluating the User Presence and User Verified flags in authenticator data: UV (and UP) flags are optional unless this value is `"required"`
22
+ */
23
+ export async function verifyAuthenticationResponse(options) {
24
+ const { response, expectedChallenge, expectedOrigin, expectedRPID, expectedType, credential, requireUserVerification = true, advancedFIDOConfig, } = options;
25
+ const { id, rawId, type: credentialType, response: assertionResponse } = response;
26
+ // Ensure credential specified an ID
27
+ if (!id) {
28
+ throw new Error('Missing credential ID');
29
+ }
30
+ // Ensure ID is base64url-encoded
31
+ if (id !== rawId) {
32
+ throw new Error('Credential ID was not base64url-encoded');
33
+ }
34
+ // Make sure credential type is public-key
35
+ if (credentialType !== 'public-key') {
36
+ throw new Error(`Unexpected credential type ${credentialType}, expected "public-key"`);
37
+ }
38
+ if (!response) {
39
+ throw new Error('Credential missing response');
40
+ }
41
+ if (typeof assertionResponse?.clientDataJSON !== 'string') {
42
+ throw new Error('Credential response clientDataJSON was not a string');
43
+ }
44
+ const clientDataJSON = decodeClientDataJSON(assertionResponse.clientDataJSON);
45
+ const { type, origin, challenge, tokenBinding } = clientDataJSON;
46
+ // Make sure we're handling an authentication
47
+ if (Array.isArray(expectedType)) {
48
+ if (!expectedType.includes(type)) {
49
+ const joinedExpectedType = expectedType.join(', ');
50
+ throw new Error(`Unexpected authentication response type "${type}", expected one of: ${joinedExpectedType}`);
51
+ }
52
+ }
53
+ else if (expectedType) {
54
+ if (type !== expectedType) {
55
+ throw new Error(`Unexpected authentication response type "${type}", expected "${expectedType}"`);
56
+ }
57
+ }
58
+ else if (type !== 'webauthn.get') {
59
+ throw new Error(`Unexpected authentication response type: ${type}`);
60
+ }
61
+ // Ensure the device provided the challenge we gave it
62
+ if (typeof expectedChallenge === 'function') {
63
+ if (!(await expectedChallenge(challenge))) {
64
+ throw new Error(`Custom challenge verifier returned false for registration response challenge "${challenge}"`);
65
+ }
66
+ }
67
+ else if (challenge !== expectedChallenge) {
68
+ throw new Error(`Unexpected authentication response challenge "${challenge}", expected "${expectedChallenge}"`);
69
+ }
70
+ // Check that the origin is our site
71
+ if (Array.isArray(expectedOrigin)) {
72
+ if (!expectedOrigin.includes(origin)) {
73
+ const joinedExpectedOrigin = expectedOrigin.join(', ');
74
+ throw new Error(`Unexpected authentication response origin "${origin}", expected one of: ${joinedExpectedOrigin}`);
75
+ }
76
+ }
77
+ else {
78
+ if (origin !== expectedOrigin) {
79
+ throw new Error(`Unexpected authentication response origin "${origin}", expected "${expectedOrigin}"`);
80
+ }
81
+ }
82
+ if (!isoBase64URL.isBase64URL(assertionResponse.authenticatorData)) {
83
+ throw new Error('Credential response authenticatorData was not a base64url string');
84
+ }
85
+ if (!isoBase64URL.isBase64URL(assertionResponse.signature)) {
86
+ throw new Error('Credential response signature was not a base64url string');
87
+ }
88
+ if (assertionResponse.userHandle &&
89
+ typeof assertionResponse.userHandle !== 'string') {
90
+ throw new Error('Credential response userHandle was not a string');
91
+ }
92
+ if (tokenBinding) {
93
+ if (typeof tokenBinding !== 'object') {
94
+ throw new Error('ClientDataJSON tokenBinding was not an object');
95
+ }
96
+ if (['present', 'supported', 'notSupported'].indexOf(tokenBinding.status) < 0) {
97
+ throw new Error(`Unexpected tokenBinding status ${tokenBinding.status}`);
98
+ }
99
+ }
100
+ const authDataBuffer = isoBase64URL.toBuffer(assertionResponse.authenticatorData);
101
+ const parsedAuthData = parseAuthenticatorData(authDataBuffer);
102
+ const { rpIdHash, flags, counter, extensionsData } = parsedAuthData;
103
+ // Make sure the response's RP ID is ours
104
+ let expectedRPIDs = [];
105
+ if (typeof expectedRPID === 'string') {
106
+ expectedRPIDs = [expectedRPID];
107
+ }
108
+ else {
109
+ expectedRPIDs = expectedRPID;
110
+ }
111
+ const matchedRPID = await matchExpectedRPID(rpIdHash, expectedRPIDs);
112
+ if (advancedFIDOConfig !== undefined) {
113
+ const { userVerification: fidoUserVerification } = advancedFIDOConfig;
114
+ /**
115
+ * Use FIDO Conformance-defined rules for verifying UP and UV flags
116
+ */
117
+ if (fidoUserVerification === 'required') {
118
+ // Require `flags.uv` be true (implies `flags.up` is true)
119
+ if (!flags.uv) {
120
+ throw new Error('User verification required, but user could not be verified');
121
+ }
122
+ }
123
+ else if (fidoUserVerification === 'preferred' ||
124
+ fidoUserVerification === 'discouraged') {
125
+ // Ignore `flags.uv`
126
+ }
127
+ }
128
+ else {
129
+ /**
130
+ * Use WebAuthn spec-defined rules for verifying UP and UV flags
131
+ */
132
+ // WebAuthn only requires the user presence flag be true
133
+ if (!flags.up) {
134
+ throw new Error('User not present during authentication');
135
+ }
136
+ // Enforce user verification if required
137
+ if (requireUserVerification && !flags.uv) {
138
+ throw new Error('User verification required, but user could not be verified');
139
+ }
140
+ }
141
+ const clientDataHash = await toHash(isoBase64URL.toBuffer(assertionResponse.clientDataJSON));
142
+ const signatureBase = isoUint8Array.concat([authDataBuffer, clientDataHash]);
143
+ const signature = isoBase64URL.toBuffer(assertionResponse.signature);
144
+ if ((counter > 0 || credential.counter > 0) &&
145
+ counter <= credential.counter) {
146
+ // Error out when the counter in the DB is greater than or equal to the counter in the
147
+ // dataStruct. It's related to how the authenticator maintains the number of times its been
148
+ // used for this client. If this happens, then someone's somehow increased the counter
149
+ // on the device without going through this site
150
+ throw new Error(`Response counter value ${counter} was lower than expected ${credential.counter}`);
151
+ }
152
+ const { credentialDeviceType, credentialBackedUp } = parseBackupFlags(flags);
153
+ const toReturn = {
154
+ verified: await verifySignature({
155
+ signature,
156
+ data: signatureBase,
157
+ credentialPublicKey: credential.publicKey,
158
+ }),
159
+ authenticationInfo: {
160
+ newCounter: counter,
161
+ credentialID: credential.id,
162
+ userVerified: flags.uv,
163
+ credentialDeviceType,
164
+ credentialBackedUp,
165
+ authenticatorExtensionResults: extensionsData,
166
+ origin: clientDataJSON.origin,
167
+ rpID: matchedRPID,
168
+ },
169
+ };
170
+ return toReturn;
171
+ }
node_modules/@simplewebauthn/server/esm/helpers/convertAAGUIDToString.d.ts ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ import type { Uint8Array_ } from '../types/index.js';
2
+ /**
3
+ * Convert the aaguid buffer in authData into a UUID string
4
+ */
5
+ export declare function convertAAGUIDToString(aaguid: Uint8Array_): string;
6
+ //# sourceMappingURL=convertAAGUIDToString.d.ts.map
node_modules/@simplewebauthn/server/esm/helpers/convertAAGUIDToString.d.ts.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"file":"convertAAGUIDToString.d.ts","sourceRoot":"","sources":["../../src/helpers/convertAAGUIDToString.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAcjE"}
node_modules/@simplewebauthn/server/esm/helpers/convertAAGUIDToString.js ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { isoUint8Array } from './iso/index.js';
2
+ /**
3
+ * Convert the aaguid buffer in authData into a UUID string
4
+ */
5
+ export function convertAAGUIDToString(aaguid) {
6
+ // Raw Hex: adce000235bcc60a648b0b25f1f05503
7
+ const hex = isoUint8Array.toHex(aaguid);
8
+ const segments = [
9
+ hex.slice(0, 8), // 8
10
+ hex.slice(8, 12), // 4
11
+ hex.slice(12, 16), // 4
12
+ hex.slice(16, 20), // 4
13
+ hex.slice(20, 32), // 8
14
+ ];
15
+ // Formatted: adce0002-35bc-c60a-648b-0b25f1f05503
16
+ return segments.join('-');
17
+ }
node_modules/@simplewebauthn/server/esm/helpers/convertCOSEtoPKCS.d.ts ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ import type { Uint8Array_ } from '../types/index.js';
2
+ /**
3
+ * Takes COSE-encoded public key and converts it to PKCS key
4
+ */
5
+ export declare function convertCOSEtoPKCS(cosePublicKey: Uint8Array_): Uint8Array_;
6
+ //# sourceMappingURL=convertCOSEtoPKCS.d.ts.map
node_modules/@simplewebauthn/server/esm/helpers/convertCOSEtoPKCS.d.ts.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"file":"convertCOSEtoPKCS.d.ts","sourceRoot":"","sources":["../../src/helpers/convertCOSEtoPKCS.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,WAAW,GAAG,WAAW,CAmBzE"}
node_modules/@simplewebauthn/server/esm/helpers/convertCOSEtoPKCS.js ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { isoCBOR, isoUint8Array } from './iso/index.js';
2
+ import { COSEKEYS } from './cose.js';
3
+ /**
4
+ * Takes COSE-encoded public key and converts it to PKCS key
5
+ */
6
+ export function convertCOSEtoPKCS(cosePublicKey) {
7
+ // This is a little sloppy, I'm using COSEPublicKeyEC2 since it could have both x and y, but when
8
+ // there's no y it means it's probably better typed as COSEPublicKeyOKP. I'll leave this for now
9
+ // and revisit it later if it ever becomes an actual problem.
10
+ const struct = isoCBOR.decodeFirst(cosePublicKey);
11
+ const tag = Uint8Array.from([0x04]);
12
+ const x = struct.get(COSEKEYS.x);
13
+ const y = struct.get(COSEKEYS.y);
14
+ if (!x) {
15
+ throw new Error('COSE public key was missing x');
16
+ }
17
+ if (y) {
18
+ return isoUint8Array.concat([tag, x, y]);
19
+ }
20
+ return isoUint8Array.concat([tag, x]);
21
+ }
node_modules/@simplewebauthn/server/esm/helpers/convertCertBufferToPEM.d.ts ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ import type { Base64URLString, Uint8Array_ } from '../types/index.js';
2
+ /**
3
+ * Convert buffer to an OpenSSL-compatible PEM text format.
4
+ */
5
+ export declare function convertCertBufferToPEM(certBuffer: Uint8Array_ | Base64URLString): string;
6
+ //# sourceMappingURL=convertCertBufferToPEM.d.ts.map
node_modules/@simplewebauthn/server/esm/helpers/convertCertBufferToPEM.d.ts.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"file":"convertCertBufferToPEM.d.ts","sourceRoot":"","sources":["../../src/helpers/convertCertBufferToPEM.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGtE;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,WAAW,GAAG,eAAe,GACxC,MAAM,CA4BR"}
node_modules/@simplewebauthn/server/esm/helpers/convertCertBufferToPEM.js ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { isoBase64URL } from './iso/index.js';
2
+ /**
3
+ * Convert buffer to an OpenSSL-compatible PEM text format.
4
+ */
5
+ export function convertCertBufferToPEM(certBuffer) {
6
+ let b64cert;
7
+ /**
8
+ * Get certBuffer to a base64 representation
9
+ */
10
+ if (typeof certBuffer === 'string') {
11
+ if (isoBase64URL.isBase64URL(certBuffer)) {
12
+ b64cert = isoBase64URL.toBase64(certBuffer);
13
+ }
14
+ else if (isoBase64URL.isBase64(certBuffer)) {
15
+ b64cert = certBuffer;
16
+ }
17
+ else {
18
+ throw new Error('Certificate is not a valid base64 or base64url string');
19
+ }
20
+ }
21
+ else {
22
+ b64cert = isoBase64URL.fromBuffer(certBuffer, 'base64');
23
+ }
24
+ let PEMKey = '';
25
+ for (let i = 0; i < Math.ceil(b64cert.length / 64); i += 1) {
26
+ const start = 64 * i;
27
+ PEMKey += `${b64cert.substr(start, 64)}\n`;
28
+ }
29
+ PEMKey = `-----BEGIN CERTIFICATE-----\n${PEMKey}-----END CERTIFICATE-----\n`;
30
+ return PEMKey;
31
+ }
node_modules/@simplewebauthn/server/esm/helpers/convertPEMToBytes.d.ts ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ import type { Uint8Array_ } from '../types/index.js';
2
+ /**
3
+ * Take a certificate in PEM format and convert it to bytes
4
+ */
5
+ export declare function convertPEMToBytes(pem: string): Uint8Array_;
6
+ //# sourceMappingURL=convertPEMToBytes.d.ts.map
node_modules/@simplewebauthn/server/esm/helpers/convertPEMToBytes.d.ts.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"file":"convertPEMToBytes.d.ts","sourceRoot":"","sources":["../../src/helpers/convertPEMToBytes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,CAO1D"}
node_modules/@simplewebauthn/server/esm/helpers/convertPEMToBytes.js ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { isoBase64URL } from './iso/index.js';
2
+ /**
3
+ * Take a certificate in PEM format and convert it to bytes
4
+ */
5
+ export function convertPEMToBytes(pem) {
6
+ const certBase64 = pem
7
+ .replace('-----BEGIN CERTIFICATE-----', '')
8
+ .replace('-----END CERTIFICATE-----', '')
9
+ .replace(/[\n ]/g, '');
10
+ return isoBase64URL.toBuffer(certBase64, 'base64');
11
+ }
node_modules/@simplewebauthn/server/esm/helpers/convertX509PublicKeyToCOSE.d.ts ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ import { COSEPublicKey } from './cose.js';
2
+ import type { Uint8Array_ } from '../types/index.js';
3
+ export declare function convertX509PublicKeyToCOSE(x509Certificate: Uint8Array_): COSEPublicKey;
4
+ //# sourceMappingURL=convertX509PublicKeyToCOSE.d.ts.map
node_modules/@simplewebauthn/server/esm/helpers/convertX509PublicKeyToCOSE.d.ts.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"file":"convertX509PublicKeyToCOSE.d.ts","sourceRoot":"","sources":["../../src/helpers/convertX509PublicKeyToCOSE.ts"],"names":[],"mappings":"AAKA,OAAO,EAIL,aAAa,EAGd,MAAM,WAAW,CAAC;AAEnB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,wBAAgB,0BAA0B,CACxC,eAAe,EAAE,WAAW,GAC3B,aAAa,CA+Ff"}
node_modules/@simplewebauthn/server/esm/helpers/convertX509PublicKeyToCOSE.js ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { AsnParser } from '@peculiar/asn1-schema';
2
+ import { Certificate } from '@peculiar/asn1-x509';
3
+ import { ECParameters, id_ecPublicKey, id_secp256r1, id_secp384r1 } from '@peculiar/asn1-ecc';
4
+ import { id_rsaEncryption, RSAPublicKey } from '@peculiar/asn1-rsa';
5
+ import { COSECRV, COSEKEYS, COSEKTY, } from './cose.js';
6
+ import { mapX509SignatureAlgToCOSEAlg } from './mapX509SignatureAlgToCOSEAlg.js';
7
+ export function convertX509PublicKeyToCOSE(x509Certificate) {
8
+ let cosePublicKey = new Map();
9
+ /**
10
+ * Time to extract the public key from an X.509 certificate
11
+ */
12
+ const x509 = AsnParser.parse(x509Certificate, Certificate);
13
+ const { tbsCertificate } = x509;
14
+ const { subjectPublicKeyInfo, signature: _tbsSignature } = tbsCertificate;
15
+ const signatureAlgorithm = _tbsSignature.algorithm;
16
+ const publicKeyAlgorithmID = subjectPublicKeyInfo.algorithm.algorithm;
17
+ if (publicKeyAlgorithmID === id_ecPublicKey) {
18
+ /**
19
+ * EC2 Public Key
20
+ */
21
+ if (!subjectPublicKeyInfo.algorithm.parameters) {
22
+ throw new Error('Certificate public key was missing parameters (EC2)');
23
+ }
24
+ const ecParameters = AsnParser.parse(new Uint8Array(subjectPublicKeyInfo.algorithm.parameters), ECParameters);
25
+ let crv = -999;
26
+ const { namedCurve } = ecParameters;
27
+ if (namedCurve === id_secp256r1) {
28
+ crv = COSECRV.P256;
29
+ }
30
+ else if (namedCurve === id_secp384r1) {
31
+ crv = COSECRV.P384;
32
+ }
33
+ else {
34
+ throw new Error(`Certificate public key contained unexpected namedCurve ${namedCurve} (EC2)`);
35
+ }
36
+ const subjectPublicKey = new Uint8Array(subjectPublicKeyInfo.subjectPublicKey);
37
+ let x;
38
+ let y;
39
+ if (subjectPublicKey[0] === 0x04) {
40
+ // Public key is in "uncompressed form", so we can split the remaining bytes in half
41
+ let pointer = 1;
42
+ const halfLength = (subjectPublicKey.length - 1) / 2;
43
+ x = subjectPublicKey.slice(pointer, pointer += halfLength);
44
+ y = subjectPublicKey.slice(pointer);
45
+ }
46
+ else {
47
+ throw new Error('TODO: Figure out how to handle public keys in "compressed form"');
48
+ }
49
+ const coseEC2PubKey = new Map();
50
+ coseEC2PubKey.set(COSEKEYS.kty, COSEKTY.EC2);
51
+ coseEC2PubKey.set(COSEKEYS.alg, mapX509SignatureAlgToCOSEAlg(signatureAlgorithm));
52
+ coseEC2PubKey.set(COSEKEYS.crv, crv);
53
+ coseEC2PubKey.set(COSEKEYS.x, x);
54
+ coseEC2PubKey.set(COSEKEYS.y, y);
55
+ cosePublicKey = coseEC2PubKey;
56
+ }
57
+ else if (publicKeyAlgorithmID === id_rsaEncryption) {
58
+ /**
59
+ * RSA public key
60
+ */
61
+ const rsaPublicKey = AsnParser.parse(subjectPublicKeyInfo.subjectPublicKey, RSAPublicKey);
62
+ const coseRSAPubKey = new Map();
63
+ coseRSAPubKey.set(COSEKEYS.kty, COSEKTY.RSA);
64
+ coseRSAPubKey.set(COSEKEYS.alg, mapX509SignatureAlgToCOSEAlg(signatureAlgorithm));
65
+ coseRSAPubKey.set(COSEKEYS.n, new Uint8Array(rsaPublicKey.modulus));
66
+ coseRSAPubKey.set(COSEKEYS.e, new Uint8Array(rsaPublicKey.publicExponent));
67
+ cosePublicKey = coseRSAPubKey;
68
+ }
69
+ else {
70
+ throw new Error(`Certificate public key contained unexpected algorithm ID ${publicKeyAlgorithmID}`);
71
+ }
72
+ return cosePublicKey;
73
+ }
node_modules/@simplewebauthn/server/esm/helpers/cose.d.ts ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { Uint8Array_ } from '../types/index.js';
2
+ /**
3
+ * Fundamental values that are needed to discern the more specific COSE public key types below.
4
+ *
5
+ * The use of `Maps` here is due to CBOR encoding being used with public keys, and the CBOR "Map"
6
+ * type is being decoded to JavaScript's `Map` type instead of, say, a basic Object as us JS
7
+ * developers might prefer.
8
+ *
9
+ * These types are an unorthodox way of saying "these Maps should involve these discrete lists of
10
+ * keys", but it works.
11
+ * @module
12
+ */
13
+ /**
14
+ * COSE public key common values
15
+ */
16
+ export type COSEPublicKey = {
17
+ get(key: COSEKEYS.kty): COSEKTY | undefined;
18
+ get(key: COSEKEYS.alg): COSEALG | undefined;
19
+ set(key: COSEKEYS.kty, value: COSEKTY): void;
20
+ set(key: COSEKEYS.alg, value: COSEALG): void;
21
+ };
22
+ /**
23
+ * Values specific to Octet Key Pair public keys
24
+ */
25
+ export type COSEPublicKeyOKP = COSEPublicKey & {
26
+ get(key: COSEKEYS.crv): number | undefined;
27
+ get(key: COSEKEYS.x): Uint8Array_ | undefined;
28
+ set(key: COSEKEYS.crv, value: number): void;
29
+ set(key: COSEKEYS.x, value: Uint8Array_): void;
30
+ };
31
+ /**
32
+ * Values specific to Elliptic Curve Cryptography public keys
33
+ */
34
+ export type COSEPublicKeyEC2 = COSEPublicKey & {
35
+ get(key: COSEKEYS.crv): number | undefined;
36
+ get(key: COSEKEYS.x): Uint8Array_ | undefined;
37
+ get(key: COSEKEYS.y): Uint8Array_ | undefined;
38
+ set(key: COSEKEYS.crv, value: number): void;
39
+ set(key: COSEKEYS.x, value: Uint8Array_): void;
40
+ set(key: COSEKEYS.y, value: Uint8Array_): void;
41
+ };
42
+ /**
43
+ * Values specific to RSA public keys
44
+ */
45
+ export type COSEPublicKeyRSA = COSEPublicKey & {
46
+ get(key: COSEKEYS.n): Uint8Array_ | undefined;
47
+ get(key: COSEKEYS.e): Uint8Array_ | undefined;
48
+ set(key: COSEKEYS.n, value: Uint8Array_): void;
49
+ set(key: COSEKEYS.e, value: Uint8Array_): void;
50
+ };
51
+ /**
52
+ * A type guard for determining if a COSE public key is an OKP key pair
53
+ */
54
+ export declare function isCOSEPublicKeyOKP(cosePublicKey: COSEPublicKey): cosePublicKey is COSEPublicKeyOKP;
55
+ /**
56
+ * A type guard for determining if a COSE public key is an EC2 key pair
57
+ */
58
+ export declare function isCOSEPublicKeyEC2(cosePublicKey: COSEPublicKey): cosePublicKey is COSEPublicKeyEC2;
59
+ /**
60
+ * A type guard for determining if a COSE public key is an RSA key pair
61
+ */
62
+ export declare function isCOSEPublicKeyRSA(cosePublicKey: COSEPublicKey): cosePublicKey is COSEPublicKeyRSA;
63
+ /**
64
+ * COSE Keys
65
+ *
66
+ * https://www.iana.org/assignments/cose/cose.xhtml#key-common-parameters
67
+ * https://www.iana.org/assignments/cose/cose.xhtml#key-type-parameters
68
+ */
69
+ export declare enum COSEKEYS {
70
+ kty = 1,
71
+ alg = 3,
72
+ crv = -1,
73
+ x = -2,
74
+ y = -3,
75
+ n = -1,
76
+ e = -2
77
+ }
78
+ /**
79
+ * COSE Key Types
80
+ *
81
+ * https://www.iana.org/assignments/cose/cose.xhtml#key-type
82
+ */
83
+ export declare enum COSEKTY {
84
+ OKP = 1,
85
+ EC2 = 2,
86
+ RSA = 3
87
+ }
88
+ export declare function isCOSEKty(kty: number | undefined): kty is COSEKTY;
89
+ /**
90
+ * COSE Curves
91
+ *
92
+ * https://www.iana.org/assignments/cose/cose.xhtml#elliptic-curves
93
+ */
94
+ export declare enum COSECRV {
95
+ P256 = 1,
96
+ P384 = 2,
97
+ P521 = 3,
98
+ ED25519 = 6,
99
+ SECP256K1 = 8
100
+ }
101
+ export declare function isCOSECrv(crv: number | undefined): crv is COSECRV;
102
+ /**
103
+ * COSE Algorithms
104
+ *
105
+ * https://www.iana.org/assignments/cose/cose.xhtml#algorithms
106
+ */
107
+ export declare enum COSEALG {
108
+ ES256 = -7,
109
+ EdDSA = -8,
110
+ ES384 = -35,
111
+ ES512 = -36,
112
+ PS256 = -37,
113
+ PS384 = -38,
114
+ PS512 = -39,
115
+ ES256K = -47,
116
+ RS256 = -257,
117
+ RS384 = -258,
118
+ RS512 = -259,
119
+ RS1 = -65535
120
+ }
121
+ export declare function isCOSEAlg(alg: number | undefined): alg is COSEALG;
122
+ //# sourceMappingURL=cose.d.ts.map
node_modules/@simplewebauthn/server/esm/helpers/cose.d.ts.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"file":"cose.d.ts","sourceRoot":"","sources":["../../src/helpers/cose.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD;;;;;;;;;;GAUG;AAEH;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAE1B,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,GAAG,GAAG,OAAO,GAAG,SAAS,CAAC;IAC5C,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,GAAG,GAAG,OAAO,GAAG,SAAS,CAAC;IAE5C,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,GAAG,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IAC7C,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,GAAG,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;CAC9C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG;IAE7C,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,GAAG,GAAG,MAAM,GAAG,SAAS,CAAC;IAC3C,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,GAAG,WAAW,GAAG,SAAS,CAAC;IAE9C,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5C,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,WAAW,GAAG,IAAI,CAAC;CAChD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG;IAE7C,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,GAAG,GAAG,MAAM,GAAG,SAAS,CAAC;IAC3C,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,GAAG,WAAW,GAAG,SAAS,CAAC;IAC9C,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,GAAG,WAAW,GAAG,SAAS,CAAC;IAE9C,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5C,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,WAAW,GAAG,IAAI,CAAC;IAC/C,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,WAAW,GAAG,IAAI,CAAC;CAChD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG;IAE7C,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,GAAG,WAAW,GAAG,SAAS,CAAC;IAC9C,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,GAAG,WAAW,GAAG,SAAS,CAAC;IAE9C,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,WAAW,GAAG,IAAI,CAAC;IAC/C,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,WAAW,GAAG,IAAI,CAAC;CAChD,CAAC;AAEF;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,aAAa,EAAE,aAAa,GAC3B,aAAa,IAAI,gBAAgB,CAGnC;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,aAAa,EAAE,aAAa,GAC3B,aAAa,IAAI,gBAAgB,CAGnC;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,aAAa,EAAE,aAAa,GAC3B,aAAa,IAAI,gBAAgB,CAGnC;AAED;;;;;GAKG;AACH,oBAAY,QAAQ;IAClB,GAAG,IAAI;IACP,GAAG,IAAI;IACP,GAAG,KAAK;IACR,CAAC,KAAK;IACN,CAAC,KAAK;IACN,CAAC,KAAK;IACN,CAAC,KAAK;CACP;AAED;;;;GAIG;AACH,oBAAY,OAAO;IACjB,GAAG,IAAI;IACP,GAAG,IAAI;IACP,GAAG,IAAI;CACR;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,GAAG,IAAI,OAAO,CAEjE;AAED;;;;GAIG;AACH,oBAAY,OAAO;IACjB,IAAI,IAAI;IACR,IAAI,IAAI;IACR,IAAI,IAAI;IACR,OAAO,IAAI;IACX,SAAS,IAAI;CACd;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,GAAG,IAAI,OAAO,CAEjE;AAED;;;;GAIG;AACH,oBAAY,OAAO;IACjB,KAAK,KAAK;IACV,KAAK,KAAK;IACV,KAAK,MAAM;IACX,KAAK,MAAM;IACX,KAAK,MAAM;IACX,KAAK,MAAM;IACX,KAAK,MAAM;IACX,MAAM,MAAM;IACZ,KAAK,OAAO;IACZ,KAAK,OAAO;IACZ,KAAK,OAAO;IACZ,GAAG,SAAS;CACb;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,GAAG,IAAI,OAAO,CAEjE"}
node_modules/@simplewebauthn/server/esm/helpers/cose.js ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * A type guard for determining if a COSE public key is an OKP key pair
3
+ */
4
+ export function isCOSEPublicKeyOKP(cosePublicKey) {
5
+ const kty = cosePublicKey.get(COSEKEYS.kty);
6
+ return isCOSEKty(kty) && kty === COSEKTY.OKP;
7
+ }
8
+ /**
9
+ * A type guard for determining if a COSE public key is an EC2 key pair
10
+ */
11
+ export function isCOSEPublicKeyEC2(cosePublicKey) {
12
+ const kty = cosePublicKey.get(COSEKEYS.kty);
13
+ return isCOSEKty(kty) && kty === COSEKTY.EC2;
14
+ }
15
+ /**
16
+ * A type guard for determining if a COSE public key is an RSA key pair
17
+ */
18
+ export function isCOSEPublicKeyRSA(cosePublicKey) {
19
+ const kty = cosePublicKey.get(COSEKEYS.kty);
20
+ return isCOSEKty(kty) && kty === COSEKTY.RSA;
21
+ }
22
+ /**
23
+ * COSE Keys
24
+ *
25
+ * https://www.iana.org/assignments/cose/cose.xhtml#key-common-parameters
26
+ * https://www.iana.org/assignments/cose/cose.xhtml#key-type-parameters
27
+ */
28
+ export var COSEKEYS;
29
+ (function (COSEKEYS) {
30
+ COSEKEYS[COSEKEYS["kty"] = 1] = "kty";
31
+ COSEKEYS[COSEKEYS["alg"] = 3] = "alg";
32
+ COSEKEYS[COSEKEYS["crv"] = -1] = "crv";
33
+ COSEKEYS[COSEKEYS["x"] = -2] = "x";
34
+ COSEKEYS[COSEKEYS["y"] = -3] = "y";
35
+ COSEKEYS[COSEKEYS["n"] = -1] = "n";
36
+ COSEKEYS[COSEKEYS["e"] = -2] = "e";
37
+ })(COSEKEYS || (COSEKEYS = {}));
38
+ /**
39
+ * COSE Key Types
40
+ *
41
+ * https://www.iana.org/assignments/cose/cose.xhtml#key-type
42
+ */
43
+ export var COSEKTY;
44
+ (function (COSEKTY) {
45
+ COSEKTY[COSEKTY["OKP"] = 1] = "OKP";
46
+ COSEKTY[COSEKTY["EC2"] = 2] = "EC2";
47
+ COSEKTY[COSEKTY["RSA"] = 3] = "RSA";
48
+ })(COSEKTY || (COSEKTY = {}));
49
+ export function isCOSEKty(kty) {
50
+ return Object.values(COSEKTY).indexOf(kty) >= 0;
51
+ }
52
+ /**
53
+ * COSE Curves
54
+ *
55
+ * https://www.iana.org/assignments/cose/cose.xhtml#elliptic-curves
56
+ */
57
+ export var COSECRV;
58
+ (function (COSECRV) {
59
+ COSECRV[COSECRV["P256"] = 1] = "P256";
60
+ COSECRV[COSECRV["P384"] = 2] = "P384";
61
+ COSECRV[COSECRV["P521"] = 3] = "P521";
62
+ COSECRV[COSECRV["ED25519"] = 6] = "ED25519";
63
+ COSECRV[COSECRV["SECP256K1"] = 8] = "SECP256K1";
64
+ })(COSECRV || (COSECRV = {}));
65
+ export function isCOSECrv(crv) {
66
+ return Object.values(COSECRV).indexOf(crv) >= 0;
67
+ }
68
+ /**
69
+ * COSE Algorithms
70
+ *
71
+ * https://www.iana.org/assignments/cose/cose.xhtml#algorithms
72
+ */
73
+ export var COSEALG;
74
+ (function (COSEALG) {
75
+ COSEALG[COSEALG["ES256"] = -7] = "ES256";
76
+ COSEALG[COSEALG["EdDSA"] = -8] = "EdDSA";
77
+ COSEALG[COSEALG["ES384"] = -35] = "ES384";
78
+ COSEALG[COSEALG["ES512"] = -36] = "ES512";
79
+ COSEALG[COSEALG["PS256"] = -37] = "PS256";
80
+ COSEALG[COSEALG["PS384"] = -38] = "PS384";
81
+ COSEALG[COSEALG["PS512"] = -39] = "PS512";
82
+ COSEALG[COSEALG["ES256K"] = -47] = "ES256K";
83
+ COSEALG[COSEALG["RS256"] = -257] = "RS256";
84
+ COSEALG[COSEALG["RS384"] = -258] = "RS384";
85
+ COSEALG[COSEALG["RS512"] = -259] = "RS512";
86
+ COSEALG[COSEALG["RS1"] = -65535] = "RS1";
87
+ })(COSEALG || (COSEALG = {}));
88
+ export function isCOSEAlg(alg) {
89
+ return Object.values(COSEALG).indexOf(alg) >= 0;
90
+ }
node_modules/@simplewebauthn/server/esm/helpers/decodeAttestationObject.d.ts ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { Uint8Array_ } from '../types/index.js';
2
+ /**
3
+ * Convert an AttestationObject buffer to a proper object
4
+ *
5
+ * @param base64AttestationObject Attestation Object buffer
6
+ */
7
+ export declare function decodeAttestationObject(attestationObject: Uint8Array_): AttestationObject;
8
+ export type AttestationFormat = 'fido-u2f' | 'packed' | 'android-safetynet' | 'android-key' | 'tpm' | 'apple' | 'none';
9
+ export type AttestationObject = {
10
+ get(key: 'fmt'): AttestationFormat;
11
+ get(key: 'attStmt'): AttestationStatement;
12
+ get(key: 'authData'): Uint8Array_;
13
+ };
14
+ /**
15
+ * `AttestationStatement` will be an instance of `Map`, but these keys help make finite the list of
16
+ * possible values within it.
17
+ */
18
+ export type AttestationStatement = {
19
+ get(key: 'sig'): Uint8Array_ | undefined;
20
+ get(key: 'x5c'): Uint8Array_[] | undefined;
21
+ get(key: 'response'): Uint8Array_ | undefined;
22
+ get(key: 'alg'): number | undefined;
23
+ get(key: 'ver'): string | undefined;
24
+ get(key: 'certInfo'): Uint8Array_ | undefined;
25
+ get(key: 'pubArea'): Uint8Array_ | undefined;
26
+ readonly size: number;
27
+ };
28
+ /**
29
+ * Make it possible to stub the return value during testing
30
+ * @ignore Don't include this in docs output
31
+ */
32
+ export declare const _decodeAttestationObjectInternals: {
33
+ stubThis: (value: AttestationObject) => AttestationObject;
34
+ };
35
+ //# sourceMappingURL=decodeAttestationObject.d.ts.map
node_modules/@simplewebauthn/server/esm/helpers/decodeAttestationObject.d.ts.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"file":"decodeAttestationObject.d.ts","sourceRoot":"","sources":["../../src/helpers/decodeAttestationObject.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,iBAAiB,EAAE,WAAW,GAC7B,iBAAiB,CAInB;AAED,MAAM,MAAM,iBAAiB,GACzB,UAAU,GACV,QAAQ,GACR,mBAAmB,GACnB,aAAa,GACb,KAAK,GACL,OAAO,GACP,MAAM,CAAC;AAEX,MAAM,MAAM,iBAAiB,GAAG;IAC9B,GAAG,CAAC,GAAG,EAAE,KAAK,GAAG,iBAAiB,CAAC;IACnC,GAAG,CAAC,GAAG,EAAE,SAAS,GAAG,oBAAoB,CAAC;IAC1C,GAAG,CAAC,GAAG,EAAE,UAAU,GAAG,WAAW,CAAC;CACnC,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC,GAAG,CAAC,GAAG,EAAE,KAAK,GAAG,WAAW,GAAG,SAAS,CAAC;IACzC,GAAG,CAAC,GAAG,EAAE,KAAK,GAAG,WAAW,EAAE,GAAG,SAAS,CAAC;IAC3C,GAAG,CAAC,GAAG,EAAE,UAAU,GAAG,WAAW,GAAG,SAAS,CAAC;IAC9C,GAAG,CAAC,GAAG,EAAE,KAAK,GAAG,MAAM,GAAG,SAAS,CAAC;IACpC,GAAG,CAAC,GAAG,EAAE,KAAK,GAAG,MAAM,GAAG,SAAS,CAAC;IACpC,GAAG,CAAC,GAAG,EAAE,UAAU,GAAG,WAAW,GAAG,SAAS,CAAC;IAC9C,GAAG,CAAC,GAAG,EAAE,SAAS,GAAG,WAAW,GAAG,SAAS,CAAC;IAE7C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,iCAAiC;sBAC1B,iBAAiB;CACpC,CAAC"}
node_modules/@simplewebauthn/server/esm/helpers/decodeAttestationObject.js ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { isoCBOR } from './iso/index.js';
2
+ /**
3
+ * Convert an AttestationObject buffer to a proper object
4
+ *
5
+ * @param base64AttestationObject Attestation Object buffer
6
+ */
7
+ export function decodeAttestationObject(attestationObject) {
8
+ return _decodeAttestationObjectInternals.stubThis(isoCBOR.decodeFirst(attestationObject));
9
+ }
10
+ /**
11
+ * Make it possible to stub the return value during testing
12
+ * @ignore Don't include this in docs output
13
+ */
14
+ export const _decodeAttestationObjectInternals = {
15
+ stubThis: (value) => value,
16
+ };
node_modules/@simplewebauthn/server/esm/helpers/decodeAuthenticatorExtensions.d.ts ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { Uint8Array_ } from '../types/index.js';
2
+ /**
3
+ * Convert authenticator extension data buffer to a proper object
4
+ *
5
+ * @param extensionData Authenticator Extension Data buffer
6
+ */
7
+ export declare function decodeAuthenticatorExtensions(extensionData: Uint8Array_): AuthenticationExtensionsAuthenticatorOutputs | undefined;
8
+ /**
9
+ * Attempt to support authenticator extensions we might not know about in WebAuthn
10
+ */
11
+ export type AuthenticationExtensionsAuthenticatorOutputs = unknown;
12
+ //# sourceMappingURL=decodeAuthenticatorExtensions.d.ts.map
node_modules/@simplewebauthn/server/esm/helpers/decodeAuthenticatorExtensions.d.ts.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"file":"decodeAuthenticatorExtensions.d.ts","sourceRoot":"","sources":["../../src/helpers/decodeAuthenticatorExtensions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD;;;;GAIG;AACH,wBAAgB,6BAA6B,CAC3C,aAAa,EAAE,WAAW,GACzB,4CAA4C,GAAG,SAAS,CAU1D;AAED;;GAEG;AACH,MAAM,MAAM,4CAA4C,GAAG,OAAO,CAAC"}
node_modules/@simplewebauthn/server/esm/helpers/decodeAuthenticatorExtensions.js ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { isoCBOR } from './iso/index.js';
2
+ /**
3
+ * Convert authenticator extension data buffer to a proper object
4
+ *
5
+ * @param extensionData Authenticator Extension Data buffer
6
+ */
7
+ export function decodeAuthenticatorExtensions(extensionData) {
8
+ let toCBOR;
9
+ try {
10
+ toCBOR = isoCBOR.decodeFirst(extensionData);
11
+ }
12
+ catch (err) {
13
+ const _err = err;
14
+ throw new Error(`Error decoding authenticator extensions: ${_err.message}`);
15
+ }
16
+ return convertMapToObjectDeep(toCBOR);
17
+ }
18
+ /**
19
+ * CBOR-encoded extensions can be deeply-nested Maps, which are too deep for a simple
20
+ * `Object.entries()`. This method will recursively make sure that all Maps are converted into
21
+ * basic objects.
22
+ */
23
+ function convertMapToObjectDeep(input) {
24
+ const mapped = {};
25
+ for (const [key, value] of input) {
26
+ if (value instanceof Map) {
27
+ mapped[key] = convertMapToObjectDeep(value);
28
+ }
29
+ else {
30
+ mapped[key] = value;
31
+ }
32
+ }
33
+ return mapped;
34
+ }
node_modules/@simplewebauthn/server/esm/helpers/decodeClientDataJSON.d.ts ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { Base64URLString } from '../types/index.js';
2
+ /**
3
+ * Decode an authenticator's base64url-encoded clientDataJSON to JSON
4
+ */
5
+ export declare function decodeClientDataJSON(data: Base64URLString): ClientDataJSON;
6
+ export type ClientDataJSON = {
7
+ type: string;
8
+ challenge: string;
9
+ origin: string;
10
+ crossOrigin?: boolean;
11
+ tokenBinding?: {
12
+ id?: string;
13
+ status: 'present' | 'supported' | 'not-supported';
14
+ };
15
+ };
16
+ /**
17
+ * Make it possible to stub the return value during testing
18
+ * @ignore Don't include this in docs output
19
+ */
20
+ export declare const _decodeClientDataJSONInternals: {
21
+ stubThis: (value: ClientDataJSON) => ClientDataJSON;
22
+ };
23
+ //# sourceMappingURL=decodeClientDataJSON.d.ts.map
node_modules/@simplewebauthn/server/esm/helpers/decodeClientDataJSON.d.ts.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"file":"decodeClientDataJSON.d.ts","sourceRoot":"","sources":["../../src/helpers/decodeClientDataJSON.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGzD;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,eAAe,GAAG,cAAc,CAK1E;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,YAAY,CAAC,EAAE;QACb,EAAE,CAAC,EAAE,MAAM,CAAC;QACZ,MAAM,EAAE,SAAS,GAAG,WAAW,GAAG,eAAe,CAAC;KACnD,CAAC;CACH,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,8BAA8B;sBACvB,cAAc;CACjC,CAAC"}
node_modules/@simplewebauthn/server/esm/helpers/decodeClientDataJSON.js ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { isoBase64URL } from './iso/index.js';
2
+ /**
3
+ * Decode an authenticator's base64url-encoded clientDataJSON to JSON
4
+ */
5
+ export function decodeClientDataJSON(data) {
6
+ const toString = isoBase64URL.toUTF8String(data);
7
+ const clientData = JSON.parse(toString);
8
+ return _decodeClientDataJSONInternals.stubThis(clientData);
9
+ }
10
+ /**
11
+ * Make it possible to stub the return value during testing
12
+ * @ignore Don't include this in docs output
13
+ */
14
+ export const _decodeClientDataJSONInternals = {
15
+ stubThis: (value) => value,
16
+ };
node_modules/@simplewebauthn/server/esm/helpers/decodeCredentialPublicKey.d.ts ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { COSEPublicKey } from './cose.js';
2
+ import type { Uint8Array_ } from '../types/index.js';
3
+ export declare function decodeCredentialPublicKey(publicKey: Uint8Array_): COSEPublicKey;
4
+ /**
5
+ * Make it possible to stub the return value during testing
6
+ * @ignore Don't include this in docs output
7
+ */
8
+ export declare const _decodeCredentialPublicKeyInternals: {
9
+ stubThis: (value: COSEPublicKey) => COSEPublicKey;
10
+ };
11
+ //# sourceMappingURL=decodeCredentialPublicKey.d.ts.map
node_modules/@simplewebauthn/server/esm/helpers/decodeCredentialPublicKey.d.ts.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"file":"decodeCredentialPublicKey.d.ts","sourceRoot":"","sources":["../../src/helpers/decodeCredentialPublicKey.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,wBAAgB,yBAAyB,CACvC,SAAS,EAAE,WAAW,GACrB,aAAa,CAIf;AAED;;;GAGG;AACH,eAAO,MAAM,mCAAmC;sBAC5B,aAAa;CAChC,CAAC"}
node_modules/@simplewebauthn/server/esm/helpers/decodeCredentialPublicKey.js ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { isoCBOR } from './iso/index.js';
2
+ export function decodeCredentialPublicKey(publicKey) {
3
+ return _decodeCredentialPublicKeyInternals.stubThis(isoCBOR.decodeFirst(publicKey));
4
+ }
5
+ /**
6
+ * Make it possible to stub the return value during testing
7
+ * @ignore Don't include this in docs output
8
+ */
9
+ export const _decodeCredentialPublicKeyInternals = {
10
+ stubThis: (value) => value,
11
+ };
node_modules/@simplewebauthn/server/esm/helpers/fetch.d.ts ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * A simple method for requesting data via standard `fetch`. Should work
3
+ * across multiple runtimes.
4
+ */
5
+ export declare function fetch(url: string): Promise<Response>;
6
+ /**
7
+ * Make it possible to stub the return value during testing
8
+ * @ignore Don't include this in docs output
9
+ */
10
+ export declare const _fetchInternals: {
11
+ stubThis: (url: string) => Promise<Response>;
12
+ };
13
+ //# sourceMappingURL=fetch.d.ts.map
node_modules/@simplewebauthn/server/esm/helpers/fetch.d.ts.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src/helpers/fetch.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAEpD;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe;oBACV,MAAM;CACvB,CAAC"}
node_modules/@simplewebauthn/server/esm/helpers/fetch.js ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * A simple method for requesting data via standard `fetch`. Should work
3
+ * across multiple runtimes.
4
+ */
5
+ export function fetch(url) {
6
+ return _fetchInternals.stubThis(url);
7
+ }
8
+ /**
9
+ * Make it possible to stub the return value during testing
10
+ * @ignore Don't include this in docs output
11
+ */
12
+ export const _fetchInternals = {
13
+ stubThis: (url) => globalThis.fetch(url),
14
+ };
node_modules/@simplewebauthn/server/esm/helpers/generateChallenge.d.ts ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { Uint8Array_ } from '../types/index.js';
2
+ /**
3
+ * Generate a suitably random value to be used as an attestation or assertion challenge
4
+ */
5
+ export declare function generateChallenge(): Promise<Uint8Array_>;
6
+ /**
7
+ * Make it possible to stub the return value during testing
8
+ * @ignore Don't include this in docs output
9
+ */
10
+ export declare const _generateChallengeInternals: {
11
+ stubThis: (value: Uint8Array_) => Uint8Array;
12
+ };
13
+ //# sourceMappingURL=generateChallenge.d.ts.map
node_modules/@simplewebauthn/server/esm/helpers/generateChallenge.d.ts.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"file":"generateChallenge.d.ts","sourceRoot":"","sources":["../../src/helpers/generateChallenge.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD;;GAEG;AACH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,WAAW,CAAC,CAc9D;AAED;;;GAGG;AACH,eAAO,MAAM,2BAA2B;sBACpB,WAAW;CAC9B,CAAC"}
node_modules/@simplewebauthn/server/esm/helpers/generateChallenge.js ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { isoCrypto } from './iso/index.js';
2
+ /**
3
+ * Generate a suitably random value to be used as an attestation or assertion challenge
4
+ */
5
+ export async function generateChallenge() {
6
+ /**
7
+ * WebAuthn spec says that 16 bytes is a good minimum:
8
+ *
9
+ * "In order to prevent replay attacks, the challenges MUST contain enough entropy to make
10
+ * guessing them infeasible. Challenges SHOULD therefore be at least 16 bytes long."
11
+ *
12
+ * Just in case, let's double it
13
+ */
14
+ const challenge = new Uint8Array(32);
15
+ await isoCrypto.getRandomValues(challenge);
16
+ return _generateChallengeInternals.stubThis(challenge);
17
+ }
18
+ /**
19
+ * Make it possible to stub the return value during testing
20
+ * @ignore Don't include this in docs output
21
+ */
22
+ export const _generateChallengeInternals = {
23
+ stubThis: (value) => value,
24
+ };
node_modules/@simplewebauthn/server/esm/helpers/generateUserID.d.ts ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { Uint8Array_ } from '../types/index.js';
2
+ /**
3
+ * Generate a suitably random value to be used as user ID
4
+ */
5
+ export declare function generateUserID(): Promise<Uint8Array_>;
6
+ /**
7
+ * Make it possible to stub the return value during testing
8
+ * @ignore Don't include this in docs output
9
+ */
10
+ export declare const _generateUserIDInternals: {
11
+ stubThis: (value: Uint8Array_) => Uint8Array;
12
+ };
13
+ //# sourceMappingURL=generateUserID.d.ts.map