@dbsc-toolkit/client 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +132 -0
- package/README.md +30 -0
- package/dist/detect.d.ts +3 -0
- package/dist/detect.d.ts.map +1 -0
- package/dist/detect.js +20 -0
- package/dist/detect.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/signals.d.ts +9 -0
- package/dist/signals.d.ts.map +1 -0
- package/dist/signals.js +13 -0
- package/dist/signals.js.map +1 -0
- package/dist/webauthn.d.ts +3 -0
- package/dist/webauthn.d.ts.map +1 -0
- package/dist/webauthn.js +8 -0
- package/dist/webauthn.js.map +1 -0
- package/package.json +48 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
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.
|
|
18
|
+
|
|
19
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
20
|
+
exercising permissions granted by this License.
|
|
21
|
+
|
|
22
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
23
|
+
including but not limited to software source code, documentation
|
|
24
|
+
source, and configuration files.
|
|
25
|
+
|
|
26
|
+
"Object" form shall mean any form resulting from mechanical
|
|
27
|
+
transformation or translation of a Source form, including but
|
|
28
|
+
not limited to compiled object code, generated documentation,
|
|
29
|
+
and conversions to other media types.
|
|
30
|
+
|
|
31
|
+
"Work" shall mean the work of authorship made available under
|
|
32
|
+
the License, as indicated by a copyright notice that is included in
|
|
33
|
+
or attached to the work.
|
|
34
|
+
|
|
35
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
36
|
+
form, that is based on (or derived from) the Work and for which the
|
|
37
|
+
editorial revisions, annotations, elaborations, or other transformations
|
|
38
|
+
represent, as a whole, an original work of authorship.
|
|
39
|
+
|
|
40
|
+
"Contribution" shall mean any work of authorship, including
|
|
41
|
+
the original version of the Work and any modifications or additions
|
|
42
|
+
to that Work or Derivative Works of the Work, that is intentionally
|
|
43
|
+
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
44
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
45
|
+
the copyright owner.
|
|
46
|
+
|
|
47
|
+
"Contributor" shall mean Licensor and any Legal Entity
|
|
48
|
+
on behalf of whom a Contribution has been received by the Licensor and
|
|
49
|
+
subsequently incorporated within the Work.
|
|
50
|
+
|
|
51
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
52
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
53
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
54
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
55
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
56
|
+
Work and such Derivative Works in Source or Object form.
|
|
57
|
+
|
|
58
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
59
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
60
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
61
|
+
(except as stated in this section) patent license to make, have made,
|
|
62
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
63
|
+
where such license applies only to those patent claims licensable
|
|
64
|
+
by such Contributor that are necessarily infringed by their
|
|
65
|
+
Contribution(s) alone or by the combined work of their Contribution(s)
|
|
66
|
+
with the Work to which such Contribution(s) was submitted.
|
|
67
|
+
|
|
68
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
69
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
70
|
+
modifications, and in Source or Object form, provided that You
|
|
71
|
+
meet the following conditions:
|
|
72
|
+
|
|
73
|
+
(a) You must give any other recipients of the Work or Derivative Works
|
|
74
|
+
a copy of this License; and
|
|
75
|
+
|
|
76
|
+
(b) You must cause any modified files to carry prominent notices
|
|
77
|
+
stating that You changed the files; and
|
|
78
|
+
|
|
79
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
80
|
+
that You distribute, all copyright, patent, trademark, and
|
|
81
|
+
attribution notices from the Source form of the Work; and
|
|
82
|
+
|
|
83
|
+
(d) If the Work includes a "NOTICE" text file, you must include a
|
|
84
|
+
readable copy of the attribution notices contained within such NOTICE
|
|
85
|
+
file, in at least one of the following places: within a NOTICE text
|
|
86
|
+
file distributed as part of the Derivative Works; or, within the
|
|
87
|
+
Source form or documentation, if provided along with the Derivative
|
|
88
|
+
Works; or, on a display generated by the Derivative Works.
|
|
89
|
+
|
|
90
|
+
The "NOTICE" file referenced above refers to a text file that may
|
|
91
|
+
accompany the source form of the Work.
|
|
92
|
+
|
|
93
|
+
You may add Your own attribution notices within Derivative Works
|
|
94
|
+
that You distribute, alongside or as an addendum to the NOTICE text
|
|
95
|
+
from the Work, provided that such additional attribution notices
|
|
96
|
+
cannot be construed as modifying the License.
|
|
97
|
+
|
|
98
|
+
You may add Your own license statement for Your modifications and
|
|
99
|
+
may provide additional grant of rights to use, reproduce, or
|
|
100
|
+
distribute Derivative Works, subject to the terms and conditions
|
|
101
|
+
for the Work itself.
|
|
102
|
+
|
|
103
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
104
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
105
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
106
|
+
this License, without any additional terms or conditions.
|
|
107
|
+
|
|
108
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
109
|
+
names, trademarks, service marks, or product names of the Licensor.
|
|
110
|
+
|
|
111
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
112
|
+
agreed to in writing, Licensor provides the Work (and each Contributor
|
|
113
|
+
provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES
|
|
114
|
+
OR CONDITIONS OF ANY KIND, either express or implied, including,
|
|
115
|
+
without limitation, any warranties or conditions of TITLE,
|
|
116
|
+
NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE.
|
|
117
|
+
|
|
118
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
119
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
120
|
+
unless required by applicable law (such as deliberate and grossly
|
|
121
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
122
|
+
liable to You for damages, including any direct, indirect, special,
|
|
123
|
+
incidental, or exemplary damages of any character arising as a
|
|
124
|
+
result of this License or out of the use or inability to use the
|
|
125
|
+
Work.
|
|
126
|
+
|
|
127
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
128
|
+
the Work or Derivative Works thereof, You may choose to offer, and
|
|
129
|
+
charge a fee for, acceptance of support, warranty, indemnity,
|
|
130
|
+
or other liability obligations and/or rights consistent with this License.
|
|
131
|
+
|
|
132
|
+
END OF TERMS AND CONDITIONS
|
package/README.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# @dbsc-toolkit/client
|
|
2
|
+
|
|
3
|
+
Browser SDK for the DBSC Toolkit's fallback paths. You only need this if you want to support browsers that do not implement DBSC natively (anything other than Chrome 147+ on a hardware-key-capable platform).
|
|
4
|
+
|
|
5
|
+
If your users are all on DBSC-capable Chrome, you do not need this package — the browser drives the protocol on its own.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
pnpm add @dbsc-toolkit/client
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { dbscClient } from "@dbsc-toolkit/client";
|
|
17
|
+
|
|
18
|
+
await dbscClient.init({
|
|
19
|
+
registerEndpoint: "/dbsc/fallback/webauthn/register",
|
|
20
|
+
signalEndpoint: "/dbsc/fallback/hmac/signals",
|
|
21
|
+
});
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
`init()` detects DBSC support via feature detection. If absent, it tries WebAuthn. If WebAuthn is also absent, it posts the HMAC signal bundle.
|
|
25
|
+
|
|
26
|
+
The protection tier reached is decided server-side and reported via the existing session API on your backend.
|
|
27
|
+
|
|
28
|
+
## License
|
|
29
|
+
|
|
30
|
+
Apache-2.0
|
package/dist/detect.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect.d.ts","sourceRoot":"","sources":["../src/detect.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,UAAU,GAAG,MAAM,GAAG,MAAM,CAAC;AAE/D,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,UAAU,CAAC,CAoB5D"}
|
package/dist/detect.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export async function detectClientTier() {
|
|
2
|
+
// DBSC is browser-native; Chrome 146+ handles it automatically via HTTP headers.
|
|
3
|
+
// No JS detection is needed for the DBSC path — the browser drives it.
|
|
4
|
+
// This SDK only handles the fallback paths.
|
|
5
|
+
if (typeof window === "undefined")
|
|
6
|
+
return "none";
|
|
7
|
+
if (window.PublicKeyCredential &&
|
|
8
|
+
typeof PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable === "function") {
|
|
9
|
+
try {
|
|
10
|
+
const available = await PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable();
|
|
11
|
+
if (available)
|
|
12
|
+
return "webauthn";
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
// platform check failed, fall through to hmac
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return "hmac";
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=detect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect.js","sourceRoot":"","sources":["../src/detect.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,KAAK,UAAU,gBAAgB;IACpC,iFAAiF;IACjF,uEAAuE;IACvE,4CAA4C;IAE5C,IAAI,OAAO,MAAM,KAAK,WAAW;QAAE,OAAO,MAAM,CAAC;IAEjD,IACE,MAAM,CAAC,mBAAmB;QAC1B,OAAO,mBAAmB,CAAC,6CAA6C,KAAK,UAAU,EACvF,CAAC;QACD,IAAI,CAAC;YACH,MAAM,SAAS,GAAG,MAAM,mBAAmB,CAAC,6CAA6C,EAAE,CAAC;YAC5F,IAAI,SAAS;gBAAE,OAAO,UAAU,CAAC;QACnC,CAAC;QAAC,MAAM,CAAC;YACP,8CAA8C;QAChD,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAmB,MAAM,aAAa,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAsB,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signals.d.ts","sourceRoot":"","sources":["../src/signals.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,OAAO,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,oBAAoB,IAAI,aAAa,CAQpD"}
|
package/dist/signals.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Signal collection for the HMAC fallback tier.
|
|
2
|
+
// This is NOT hardware binding. It is best-effort context binding.
|
|
3
|
+
// Operators using this tier must review GDPR obligations for signal collection.
|
|
4
|
+
export function collectClientSignals() {
|
|
5
|
+
return {
|
|
6
|
+
userAgent: navigator.userAgent,
|
|
7
|
+
acceptLanguage: navigator.language,
|
|
8
|
+
secureContext: window.isSecureContext,
|
|
9
|
+
screenDepth: screen.colorDepth,
|
|
10
|
+
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=signals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signals.js","sourceRoot":"","sources":["../src/signals.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,mEAAmE;AACnE,gFAAgF;AAUhF,MAAM,UAAU,oBAAoB;IAClC,OAAO;QACL,SAAS,EAAE,SAAS,CAAC,SAAS;QAC9B,cAAc,EAAE,SAAS,CAAC,QAAQ;QAClC,aAAa,EAAE,MAAM,CAAC,eAAe;QACrC,WAAW,EAAE,MAAM,CAAC,UAAU;QAC9B,QAAQ,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,eAAe,EAAE,CAAC,QAAQ;KAC3D,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webauthn.d.ts","sourceRoot":"","sources":["../src/webauthn.ts"],"names":[],"mappings":"AAEA,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAEzE;AAED,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAE7E"}
|
package/dist/webauthn.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { startRegistration, startAuthentication } from "@simplewebauthn/browser";
|
|
2
|
+
export async function registerWebAuthn(options) {
|
|
3
|
+
return startRegistration(options);
|
|
4
|
+
}
|
|
5
|
+
export async function authenticateWebAuthn(options) {
|
|
6
|
+
return startAuthentication(options);
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=webauthn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webauthn.js","sourceRoot":"","sources":["../src/webauthn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAEjF,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,OAAgB;IACrD,OAAO,iBAAiB,CAAC,OAAkD,CAAC,CAAC;AAC/E,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,OAAgB;IACzD,OAAO,mBAAmB,CAAC,OAAoD,CAAC,CAAC;AACnF,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dbsc-toolkit/client",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Browser SDK for DBSC Toolkit fallback paths (WebAuthn + HMAC)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"@simplewebauthn/browser": "^10.0.0",
|
|
16
|
+
"typescript": "^5.4.0",
|
|
17
|
+
"vitest": "^1.6.0"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"README.md"
|
|
22
|
+
],
|
|
23
|
+
"license": "Apache-2.0",
|
|
24
|
+
"homepage": "https://github.com/SulimanAbdulrazzaq/dbsc-toolkit#readme",
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/SulimanAbdulrazzaq/dbsc-toolkit/issues"
|
|
27
|
+
},
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "https://github.com/SulimanAbdulrazzaq/dbsc-toolkit.git",
|
|
31
|
+
"directory": "packages/client"
|
|
32
|
+
},
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public"
|
|
35
|
+
},
|
|
36
|
+
"keywords": [
|
|
37
|
+
"dbsc",
|
|
38
|
+
"browser",
|
|
39
|
+
"webauthn",
|
|
40
|
+
"session",
|
|
41
|
+
"security"
|
|
42
|
+
],
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "tsc -p tsconfig.json",
|
|
45
|
+
"test": "vitest run --passWithNoTests",
|
|
46
|
+
"clean": "rm -rf dist"
|
|
47
|
+
}
|
|
48
|
+
}
|