@moon-x/core 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/{chunk-SOKLPX7V.mjs → chunk-VVL65GIB.mjs} +10 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +10 -0
- package/dist/index.mjs +1 -1
- package/dist/{interfaces-9k0eKCc4.d.ts → interfaces-Bm7fGOAI.d.ts} +73 -24
- package/dist/{interfaces-fNhwnCeY.d.mts → interfaces-CYtJHALV.d.mts} +73 -24
- package/dist/{post-message-C_99BCBh.d.ts → post-message-CmgAfkOS.d.mts} +2 -0
- package/dist/{post-message-C_99BCBh.d.mts → post-message-CmgAfkOS.d.ts} +2 -0
- package/dist/react/index.d.mts +1 -0
- package/dist/react/index.d.ts +1 -0
- package/dist/react/index.js +2 -1
- package/dist/react/index.mjs +2 -1
- package/dist/sdk/index.d.mts +26 -12
- package/dist/sdk/index.d.ts +26 -12
- package/dist/sdk/index.js +57 -8
- package/dist/sdk/index.mjs +46 -8
- package/dist/types/index.d.mts +19 -3
- package/dist/types/index.d.ts +19 -3
- package/dist/utils/index.d.mts +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +10 -0
- package/dist/utils/index.mjs +1 -1
- package/dist/web/index.d.mts +2 -2
- package/dist/web/index.d.ts +2 -2
- package/dist/web/index.js +23 -116
- package/dist/web/index.mjs +24 -60
- package/package.json +6 -2
package/dist/web/index.mjs
CHANGED
|
@@ -5,12 +5,7 @@ import {
|
|
|
5
5
|
import {
|
|
6
6
|
PostMessageClient,
|
|
7
7
|
PostMessageServer
|
|
8
|
-
} from "../chunk-
|
|
9
|
-
import {
|
|
10
|
-
fromB64url,
|
|
11
|
-
toB64url
|
|
12
|
-
} from "../chunk-CDT4MC7S.mjs";
|
|
13
|
-
import "../chunk-GQKIA37O.mjs";
|
|
8
|
+
} from "../chunk-VVL65GIB.mjs";
|
|
14
9
|
|
|
15
10
|
// src/web/iframe-transport.ts
|
|
16
11
|
var clientCache = /* @__PURE__ */ new WeakMap();
|
|
@@ -49,74 +44,43 @@ var createIframeTransport = ({
|
|
|
49
44
|
});
|
|
50
45
|
|
|
51
46
|
// src/web/webauthn-passkey.ts
|
|
47
|
+
import { startAuthentication } from "@simplewebauthn/browser";
|
|
52
48
|
var createWebAuthnPasskey = () => ({
|
|
53
49
|
assert: async ({ rpId, challenge }) => {
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
challenge: challengeBytes,
|
|
50
|
+
const result = await startAuthentication({
|
|
51
|
+
optionsJSON: {
|
|
52
|
+
challenge,
|
|
58
53
|
rpId,
|
|
59
54
|
userVerification: "preferred",
|
|
60
|
-
// Empty allowCredentials → discoverable login → userHandle is
|
|
61
|
-
// REQUIRED on the response. See `parent-passkey-assert.ts`
|
|
62
|
-
// for the full rationale.
|
|
63
55
|
allowCredentials: []
|
|
64
56
|
}
|
|
65
57
|
});
|
|
66
|
-
if (!
|
|
67
|
-
const assertion = credential.response;
|
|
68
|
-
if (!assertion.userHandle) {
|
|
58
|
+
if (!result.response.userHandle) {
|
|
69
59
|
throw new Error("user_handle_missing");
|
|
70
60
|
}
|
|
71
61
|
return {
|
|
72
|
-
rawIdB64url:
|
|
73
|
-
userHandleB64url:
|
|
62
|
+
rawIdB64url: result.rawId,
|
|
63
|
+
userHandleB64url: result.response.userHandle
|
|
74
64
|
};
|
|
75
65
|
},
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
userId,
|
|
80
|
-
userName,
|
|
81
|
-
userDisplayName,
|
|
82
|
-
challenge,
|
|
83
|
-
excludeCredentials
|
|
84
|
-
}) => {
|
|
85
|
-
const challengeBytes = fromB64url(challenge);
|
|
86
|
-
const credential = await navigator.credentials.create({
|
|
87
|
-
publicKey: {
|
|
88
|
-
rp: { id: rpId, name: rpName },
|
|
89
|
-
user: {
|
|
90
|
-
id: userId,
|
|
91
|
-
name: userName,
|
|
92
|
-
displayName: userDisplayName
|
|
93
|
-
},
|
|
94
|
-
challenge: challengeBytes,
|
|
95
|
-
pubKeyCredParams: [
|
|
96
|
-
{ type: "public-key", alg: -7 },
|
|
97
|
-
// ES256
|
|
98
|
-
{ type: "public-key", alg: -257 }
|
|
99
|
-
// RS256
|
|
100
|
-
],
|
|
101
|
-
authenticatorSelection: {
|
|
102
|
-
residentKey: "required",
|
|
103
|
-
userVerification: "preferred"
|
|
104
|
-
},
|
|
105
|
-
excludeCredentials: (excludeCredentials ?? []).map((id) => ({
|
|
106
|
-
id: fromB64url(id),
|
|
107
|
-
type: "public-key"
|
|
108
|
-
}))
|
|
109
|
-
}
|
|
66
|
+
assertForServer: async ({ optionsJSON }) => {
|
|
67
|
+
const result = await startAuthentication({
|
|
68
|
+
optionsJSON
|
|
110
69
|
});
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
70
|
+
const sanitized = {
|
|
71
|
+
id: result.id,
|
|
72
|
+
rawId: result.rawId,
|
|
73
|
+
type: result.type,
|
|
74
|
+
response: {
|
|
75
|
+
clientDataJSON: result.response.clientDataJSON,
|
|
76
|
+
authenticatorData: result.response.authenticatorData,
|
|
77
|
+
signature: result.response.signature,
|
|
78
|
+
userHandle: void 0
|
|
79
|
+
},
|
|
80
|
+
clientExtensionResults: result.clientExtensionResults,
|
|
81
|
+
authenticatorAttachment: result.authenticatorAttachment
|
|
119
82
|
};
|
|
83
|
+
return sanitized;
|
|
120
84
|
}
|
|
121
85
|
});
|
|
122
86
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moon-x/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"license": "UNLICENSED",
|
|
4
5
|
"main": "dist/index.js",
|
|
5
6
|
"types": "dist/index.d.ts",
|
|
6
7
|
"exports": {
|
|
@@ -56,12 +57,15 @@
|
|
|
56
57
|
"publishConfig": {
|
|
57
58
|
"access": "public"
|
|
58
59
|
},
|
|
60
|
+
"dependencies": {
|
|
61
|
+
"@simplewebauthn/browser": "^13.2.2"
|
|
62
|
+
},
|
|
59
63
|
"devDependencies": {
|
|
60
64
|
"@testing-library/react": "16.3.2",
|
|
61
65
|
"@types/react": "19.2.14",
|
|
62
66
|
"@types/react-dom": "19.2.3",
|
|
63
67
|
"@vitest/ui": "1.6.1",
|
|
64
|
-
"happy-dom": "
|
|
68
|
+
"happy-dom": "20.8.9",
|
|
65
69
|
"react": "18.3.1",
|
|
66
70
|
"react-dom": "18.3.1",
|
|
67
71
|
"tsup": "8.5.1",
|