@moon-x/core 0.3.0 → 0.4.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.
@@ -81,6 +81,35 @@ var createWebAuthnPasskey = () => ({
81
81
  authenticatorAttachment: result.authenticatorAttachment
82
82
  };
83
83
  return sanitized;
84
+ },
85
+ assertForInternalPresence: async ({ optionsJSON }) => {
86
+ const result = await startAuthentication({
87
+ optionsJSON: {
88
+ ...optionsJSON,
89
+ allowCredentials: []
90
+ }
91
+ });
92
+ if (!result.response.userHandle) {
93
+ throw new Error("user_handle_missing");
94
+ }
95
+ const sanitized = {
96
+ id: result.id,
97
+ rawId: result.rawId,
98
+ type: result.type,
99
+ response: {
100
+ clientDataJSON: result.response.clientDataJSON,
101
+ authenticatorData: result.response.authenticatorData,
102
+ signature: result.response.signature,
103
+ userHandle: void 0
104
+ },
105
+ clientExtensionResults: result.clientExtensionResults,
106
+ authenticatorAttachment: result.authenticatorAttachment
107
+ };
108
+ return {
109
+ response: sanitized,
110
+ userHandleB64url: result.response.userHandle,
111
+ credentialIdB64url: result.rawId
112
+ };
84
113
  }
85
114
  });
86
115
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moon-x/core",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "license": "UNLICENSED",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,47 +0,0 @@
1
- interface CachedAssertion {
2
- userHandleB64url: string;
3
- credentialIdB64url: string;
4
- }
5
- declare const setAssertCacheTtlMs: (ms: number) => void;
6
- declare const getAssertCacheTtlMs: () => number;
7
- declare const clearParentAssertCache: () => void;
8
- declare const readParentAssertCache: () => CachedAssertion | null;
9
- declare const writeParentAssertCache: (entry: CachedAssertion) => void;
10
- /**
11
- * Run `fn` inside a try/catch that clears the parent-side assertion
12
- * cache on failure. Used by every wallet-interaction SDK method
13
- * (sign / send / etc.) so that if the operation fails for any reason
14
- * — backend rejection, network error, MPC ceremony failure — the
15
- * next user attempt re-prompts biometric instead of silently reusing
16
- * a possibly-bad cached assertion.
17
- *
18
- * The cache is set inside the platform-specific `assertPasskeyInParent`
19
- * only on a successful ceremony, so cancellations / activation
20
- * failures don't pollute it. This wrapper specifically handles the
21
- * "assertion succeeded but downstream work failed" case where the
22
- * cache is set but the user is stuck — without the clear, the user
23
- * would have to refresh to escape.
24
- */
25
- declare const withClearOnFailure: <T>(fn: () => Promise<T>) => Promise<T>;
26
- /**
27
- * Generate fresh user.id bytes for a new WebAuthn credential. The
28
- * caller overrides `options.user.id` with these bytes before
29
- * navigator.credentials.create so the authenticator persists them as
30
- * the credential's user.id; on every subsequent assertion they come
31
- * back as response.userHandle and serve as the AES-GCM key for that
32
- * credential's DEK wrap.
33
- *
34
- * Returns the bytes both as base64url (what the WebAuthn options
35
- * accept and what we ship over postMessage) and as raw bytes (for
36
- * any caller that prefers direct binary).
37
- *
38
- * Requires a working `crypto.getRandomValues`. On RN this is provided
39
- * by the `react-native-get-random-values` polyfill that the SDK's
40
- * docs ask consumers to import at app entry.
41
- */
42
- declare const generatePasskeyUserId: () => {
43
- userIdB64url: string;
44
- userIdBytes: Uint8Array;
45
- };
46
-
47
- export { type CachedAssertion as C, getAssertCacheTtlMs as a, writeParentAssertCache as b, clearParentAssertCache as c, generatePasskeyUserId as g, readParentAssertCache as r, setAssertCacheTtlMs as s, withClearOnFailure as w };
@@ -1,47 +0,0 @@
1
- interface CachedAssertion {
2
- userHandleB64url: string;
3
- credentialIdB64url: string;
4
- }
5
- declare const setAssertCacheTtlMs: (ms: number) => void;
6
- declare const getAssertCacheTtlMs: () => number;
7
- declare const clearParentAssertCache: () => void;
8
- declare const readParentAssertCache: () => CachedAssertion | null;
9
- declare const writeParentAssertCache: (entry: CachedAssertion) => void;
10
- /**
11
- * Run `fn` inside a try/catch that clears the parent-side assertion
12
- * cache on failure. Used by every wallet-interaction SDK method
13
- * (sign / send / etc.) so that if the operation fails for any reason
14
- * — backend rejection, network error, MPC ceremony failure — the
15
- * next user attempt re-prompts biometric instead of silently reusing
16
- * a possibly-bad cached assertion.
17
- *
18
- * The cache is set inside the platform-specific `assertPasskeyInParent`
19
- * only on a successful ceremony, so cancellations / activation
20
- * failures don't pollute it. This wrapper specifically handles the
21
- * "assertion succeeded but downstream work failed" case where the
22
- * cache is set but the user is stuck — without the clear, the user
23
- * would have to refresh to escape.
24
- */
25
- declare const withClearOnFailure: <T>(fn: () => Promise<T>) => Promise<T>;
26
- /**
27
- * Generate fresh user.id bytes for a new WebAuthn credential. The
28
- * caller overrides `options.user.id` with these bytes before
29
- * navigator.credentials.create so the authenticator persists them as
30
- * the credential's user.id; on every subsequent assertion they come
31
- * back as response.userHandle and serve as the AES-GCM key for that
32
- * credential's DEK wrap.
33
- *
34
- * Returns the bytes both as base64url (what the WebAuthn options
35
- * accept and what we ship over postMessage) and as raw bytes (for
36
- * any caller that prefers direct binary).
37
- *
38
- * Requires a working `crypto.getRandomValues`. On RN this is provided
39
- * by the `react-native-get-random-values` polyfill that the SDK's
40
- * docs ask consumers to import at app entry.
41
- */
42
- declare const generatePasskeyUserId: () => {
43
- userIdB64url: string;
44
- userIdBytes: Uint8Array;
45
- };
46
-
47
- export { type CachedAssertion as C, getAssertCacheTtlMs as a, writeParentAssertCache as b, clearParentAssertCache as c, generatePasskeyUserId as g, readParentAssertCache as r, setAssertCacheTtlMs as s, withClearOnFailure as w };