@zerodev/wallet-core 0.0.1-alpha.19 → 0.0.1-alpha.20
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/_cjs/actions/auth/authenticateWithOAuth.js +2 -2
- package/dist/_cjs/actions/auth/authenticateWithOAuth.js.map +1 -1
- package/dist/_cjs/client/index.js.map +1 -1
- package/dist/_cjs/client/transports/createTransport.js +1 -0
- package/dist/_cjs/client/transports/createTransport.js.map +1 -1
- package/dist/_cjs/client/transports/rest.js +2 -2
- package/dist/_cjs/client/transports/rest.js.map +1 -1
- package/dist/_cjs/core/createZeroDevWallet.js +3 -0
- package/dist/_cjs/core/createZeroDevWallet.js.map +1 -1
- package/dist/_cjs/index.js.map +1 -1
- package/dist/_cjs/stampers/indexedDbStamper.js +3 -0
- package/dist/_cjs/stampers/indexedDbStamper.js.map +1 -1
- package/dist/_esm/actions/auth/authenticateWithOAuth.js +3 -2
- package/dist/_esm/actions/auth/authenticateWithOAuth.js.map +1 -1
- package/dist/_esm/client/index.js +1 -1
- package/dist/_esm/client/index.js.map +1 -1
- package/dist/_esm/client/transports/createTransport.js +1 -0
- package/dist/_esm/client/transports/createTransport.js.map +1 -1
- package/dist/_esm/client/transports/rest.js +2 -2
- package/dist/_esm/client/transports/rest.js.map +1 -1
- package/dist/_esm/core/createZeroDevWallet.js +3 -0
- package/dist/_esm/core/createZeroDevWallet.js.map +1 -1
- package/dist/_esm/index.js.map +1 -1
- package/dist/_esm/stampers/indexedDbStamper.js +3 -0
- package/dist/_esm/stampers/indexedDbStamper.js.map +1 -1
- package/dist/_types/actions/auth/authenticateWithOAuth.d.ts +3 -0
- package/dist/_types/actions/auth/authenticateWithOAuth.d.ts.map +1 -1
- package/dist/_types/client/index.d.ts +1 -1
- package/dist/_types/client/index.d.ts.map +1 -1
- package/dist/_types/client/transports/createTransport.d.ts +2 -0
- package/dist/_types/client/transports/createTransport.d.ts.map +1 -1
- package/dist/_types/core/createZeroDevWallet.d.ts +2 -1
- package/dist/_types/core/createZeroDevWallet.d.ts.map +1 -1
- package/dist/_types/index.d.ts +1 -1
- package/dist/_types/index.d.ts.map +1 -1
- package/dist/_types/stampers/indexedDbStamper.d.ts.map +1 -1
- package/dist/_types/stampers/types.d.ts +5 -0
- package/dist/_types/stampers/types.d.ts.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/actions/auth/authenticateWithOAuth.ts +5 -2
- package/src/client/index.ts +4 -1
- package/src/client/transports/createTransport.ts +3 -0
- package/src/client/transports/rest.ts +2 -2
- package/src/core/createZeroDevWallet.ts +5 -0
- package/src/index.ts +6 -1
- package/src/stampers/indexedDbStamper.ts +3 -0
- package/src/stampers/types.ts +5 -0
package/package.json
CHANGED
|
@@ -7,6 +7,8 @@ export type AuthenticateWithOAuthParameters = {
|
|
|
7
7
|
projectId: string
|
|
8
8
|
/** The session ID from the OAuth callback URL */
|
|
9
9
|
sessionId: string
|
|
10
|
+
/** Proof-of-possession signature for `sessionId`. */
|
|
11
|
+
popSignature: string
|
|
10
12
|
}
|
|
11
13
|
|
|
12
14
|
export type AuthenticateWithOAuthReturnType = {
|
|
@@ -37,6 +39,7 @@ export type AuthenticateWithOAuthReturnType = {
|
|
|
37
39
|
* provider: 'google',
|
|
38
40
|
* projectId: 'proj_456',
|
|
39
41
|
* sessionId: 'abc123',
|
|
42
|
+
* popSignature: '3045022100...',
|
|
40
43
|
* });
|
|
41
44
|
* ```
|
|
42
45
|
*/
|
|
@@ -44,11 +47,11 @@ export async function authenticateWithOAuth(
|
|
|
44
47
|
client: Client,
|
|
45
48
|
params: AuthenticateWithOAuthParameters,
|
|
46
49
|
): Promise<AuthenticateWithOAuthReturnType> {
|
|
47
|
-
const { projectId, sessionId } = params
|
|
50
|
+
const { projectId, sessionId, popSignature } = params
|
|
48
51
|
|
|
49
52
|
return await client.request({
|
|
50
53
|
path: `${projectId}/auth/oauth`,
|
|
51
54
|
method: 'POST',
|
|
52
|
-
body: { sessionId },
|
|
55
|
+
body: { sessionId, popSignature },
|
|
53
56
|
})
|
|
54
57
|
}
|
package/src/client/index.ts
CHANGED
|
@@ -10,7 +10,10 @@ export {
|
|
|
10
10
|
createClient,
|
|
11
11
|
type ZeroDevWalletClient,
|
|
12
12
|
} from './createClient.js'
|
|
13
|
-
export {
|
|
13
|
+
export {
|
|
14
|
+
type CreateTransportOptions,
|
|
15
|
+
zeroDevWalletTransport,
|
|
16
|
+
} from './transports/createTransport.js'
|
|
14
17
|
export type {
|
|
15
18
|
Client,
|
|
16
19
|
ClientConfig,
|
|
@@ -10,6 +10,8 @@ export type CreateTransportOptions = {
|
|
|
10
10
|
key?: string
|
|
11
11
|
/** Transport name */
|
|
12
12
|
name?: string
|
|
13
|
+
/** Extra options merged into every fetch() call */
|
|
14
|
+
fetchOptions?: Omit<RequestInit, 'body' | 'method' | 'signal'>
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
/**
|
|
@@ -34,6 +36,7 @@ export function zeroDevWalletTransport(
|
|
|
34
36
|
name,
|
|
35
37
|
apiKeyStamper,
|
|
36
38
|
passkeyStamper,
|
|
39
|
+
...(options.fetchOptions && { fetchOptions: options.fetchOptions }),
|
|
37
40
|
})
|
|
38
41
|
|
|
39
42
|
return {
|
|
@@ -50,9 +50,9 @@ export function rest(url: string, cfg: RestTransportConfig): RestTransport {
|
|
|
50
50
|
try {
|
|
51
51
|
let requestBody = args.body
|
|
52
52
|
let requestHeaders = {
|
|
53
|
-
'content-type': 'application/json',
|
|
54
|
-
...(args.headers ?? {}),
|
|
55
53
|
...(cfg.fetchOptions?.headers ?? {}),
|
|
54
|
+
...(args.headers ?? {}),
|
|
55
|
+
'content-type': 'application/json',
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
// Handle stamping if requested
|
|
@@ -5,6 +5,7 @@ import type {
|
|
|
5
5
|
} from '../actions/auth/index.js'
|
|
6
6
|
import { toViemAccount } from '../adapters/viem.js'
|
|
7
7
|
import {
|
|
8
|
+
type CreateTransportOptions,
|
|
8
9
|
createAuthProxyClient,
|
|
9
10
|
createClient,
|
|
10
11
|
type ZeroDevWalletClient,
|
|
@@ -35,6 +36,7 @@ export interface ZeroDevWalletConfig {
|
|
|
35
36
|
rpId?: string
|
|
36
37
|
apiKeyStamper?: ApiKeyStamper
|
|
37
38
|
passkeyStamper?: PasskeyStamper
|
|
39
|
+
fetchOptions?: CreateTransportOptions['fetchOptions']
|
|
38
40
|
}
|
|
39
41
|
|
|
40
42
|
// Re-export EmailCustomization for convenience
|
|
@@ -140,6 +142,7 @@ export async function createZeroDevWallet(
|
|
|
140
142
|
passkeyStamper,
|
|
141
143
|
transport: zeroDevWalletTransport({
|
|
142
144
|
baseUrl: config.proxyBaseUrl || `${KMS_SERVER_URL}/api/v1`,
|
|
145
|
+
...(config.fetchOptions && { fetchOptions: config.fetchOptions }),
|
|
143
146
|
}),
|
|
144
147
|
})
|
|
145
148
|
|
|
@@ -220,10 +223,12 @@ export async function createZeroDevWallet(
|
|
|
220
223
|
async auth(params: AuthParams) {
|
|
221
224
|
switch (params.type) {
|
|
222
225
|
case 'oauth': {
|
|
226
|
+
const popSignature = await client.apiKeyStamper.sign(params.sessionId)
|
|
223
227
|
const data = await client.authenticateWithOAuth({
|
|
224
228
|
provider: params.provider,
|
|
225
229
|
projectId,
|
|
226
230
|
sessionId: params.sessionId,
|
|
231
|
+
popSignature,
|
|
227
232
|
})
|
|
228
233
|
|
|
229
234
|
if (data.session) {
|
package/src/index.ts
CHANGED
|
@@ -56,7 +56,12 @@ export { toViemAccount } from './adapters/viem.js'
|
|
|
56
56
|
export type { ZeroDevWalletActions } from './client/decorators/client.js'
|
|
57
57
|
// Client decorators
|
|
58
58
|
export { zeroDevWalletActions } from './client/decorators/client.js'
|
|
59
|
-
export type {
|
|
59
|
+
export type {
|
|
60
|
+
Client,
|
|
61
|
+
ClientConfig,
|
|
62
|
+
CreateTransportOptions,
|
|
63
|
+
Transport,
|
|
64
|
+
} from './client/index.js'
|
|
60
65
|
// Client
|
|
61
66
|
export {
|
|
62
67
|
createBaseClient,
|
|
@@ -15,6 +15,9 @@ export async function createIndexedDbStamper(): Promise<ApiKeyStamper> {
|
|
|
15
15
|
async stamp(payload: string) {
|
|
16
16
|
return await inner.stamp(payload)
|
|
17
17
|
},
|
|
18
|
+
async sign(payload: string) {
|
|
19
|
+
return await inner.sign(payload)
|
|
20
|
+
},
|
|
18
21
|
async clear() {
|
|
19
22
|
await inner.clear()
|
|
20
23
|
},
|
package/src/stampers/types.ts
CHANGED
|
@@ -39,6 +39,11 @@ export type ApiKeyStamper = Stamper & {
|
|
|
39
39
|
prepareKeyRotation: () => Promise<string>
|
|
40
40
|
/** Promote the pending key to active. Call after the server accepts the new key. */
|
|
41
41
|
commitKeyRotation: () => Promise<void>
|
|
42
|
+
/**
|
|
43
|
+
* Sign `payload` with the currently active key. Returns a hex-encoded
|
|
44
|
+
* ECDSA-P256 / SHA-256 signature in ASN.1 DER form.
|
|
45
|
+
*/
|
|
46
|
+
sign: (payload: string) => Promise<string>
|
|
42
47
|
}
|
|
43
48
|
export type Attestation = {
|
|
44
49
|
attestationObject: string
|