@zerodev/wallet-core 0.0.1-alpha.12 → 0.0.1-alpha.13
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 +28 -1
- package/dist/_cjs/actions/auth/index.js.map +1 -1
- package/dist/_cjs/actions/auth/registerWithOTP.js +6 -1
- package/dist/_cjs/actions/auth/registerWithOTP.js.map +1 -1
- package/dist/_cjs/core/createZeroDevWallet.js +5 -1
- package/dist/_cjs/core/createZeroDevWallet.js.map +1 -1
- package/dist/_esm/actions/auth/index.js.map +1 -1
- package/dist/_esm/actions/auth/registerWithOTP.js +6 -1
- package/dist/_esm/actions/auth/registerWithOTP.js.map +1 -1
- package/dist/_esm/core/createZeroDevWallet.js +5 -1
- package/dist/_esm/core/createZeroDevWallet.js.map +1 -1
- package/dist/_types/actions/auth/index.d.ts +1 -1
- package/dist/_types/actions/auth/index.d.ts.map +1 -1
- package/dist/_types/actions/auth/registerWithOTP.d.ts +8 -0
- package/dist/_types/actions/auth/registerWithOTP.d.ts.map +1 -1
- package/dist/_types/core/createZeroDevWallet.d.ts +3 -1
- package/dist/_types/core/createZeroDevWallet.d.ts.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/actions/auth/index.ts +1 -0
- package/src/actions/auth/registerWithOTP.ts +24 -1
- package/src/core/createZeroDevWallet.ts +12 -2
package/package.json
CHANGED
|
@@ -8,6 +8,13 @@ export type OtpContact = {
|
|
|
8
8
|
contact: string
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
export type OtpCodeCustomization = {
|
|
12
|
+
/** The length of the OTP code (must be between 6 and 9 inclusive) */
|
|
13
|
+
length: 6 | 7 | 8 | 9
|
|
14
|
+
/** Whether the OTP code should be alphanumeric */
|
|
15
|
+
alphanumeric: boolean
|
|
16
|
+
}
|
|
17
|
+
|
|
11
18
|
export type RegisterWithOTPParameters = {
|
|
12
19
|
/** The email address to register */
|
|
13
20
|
email: string
|
|
@@ -17,6 +24,8 @@ export type RegisterWithOTPParameters = {
|
|
|
17
24
|
projectId: string
|
|
18
25
|
/** Optional email customization settings */
|
|
19
26
|
emailCustomization?: EmailCustomization
|
|
27
|
+
/** Optional OTP code customization settings */
|
|
28
|
+
otpCodeCustomization?: OtpCodeCustomization
|
|
20
29
|
}
|
|
21
30
|
|
|
22
31
|
export type RegisterWithOTPReturnType = {
|
|
@@ -50,7 +59,20 @@ export async function registerWithOTP(
|
|
|
50
59
|
client: Client,
|
|
51
60
|
params: RegisterWithOTPParameters,
|
|
52
61
|
): Promise<RegisterWithOTPReturnType> {
|
|
53
|
-
const {
|
|
62
|
+
const {
|
|
63
|
+
email,
|
|
64
|
+
contact,
|
|
65
|
+
projectId,
|
|
66
|
+
emailCustomization,
|
|
67
|
+
otpCodeCustomization,
|
|
68
|
+
} = params
|
|
69
|
+
|
|
70
|
+
if (
|
|
71
|
+
otpCodeCustomization &&
|
|
72
|
+
(otpCodeCustomization.length < 6 || otpCodeCustomization.length > 9)
|
|
73
|
+
) {
|
|
74
|
+
throw new Error('OTP code length must be between 6 and 9')
|
|
75
|
+
}
|
|
54
76
|
|
|
55
77
|
return await client.request({
|
|
56
78
|
path: `${projectId}/auth/init/otp`,
|
|
@@ -59,6 +81,7 @@ export async function registerWithOTP(
|
|
|
59
81
|
email,
|
|
60
82
|
contact,
|
|
61
83
|
emailCustomization,
|
|
84
|
+
otpCodeCustomization,
|
|
62
85
|
},
|
|
63
86
|
})
|
|
64
87
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { getWebAuthnAttestation } from '@turnkey/http'
|
|
2
2
|
import type { LocalAccount } from 'viem/accounts'
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
EmailCustomization,
|
|
5
|
+
OtpCodeCustomization,
|
|
6
|
+
} from '../actions/auth/index.js'
|
|
4
7
|
import { toViemAccount } from '../adapters/viem.js'
|
|
5
8
|
import {
|
|
6
9
|
createAuthProxyClient,
|
|
@@ -61,6 +64,7 @@ export type AuthParams =
|
|
|
61
64
|
contact: string
|
|
62
65
|
}
|
|
63
66
|
emailCustomization?: EmailCustomization
|
|
67
|
+
otpCodeCustomization?: OtpCodeCustomization
|
|
64
68
|
}
|
|
65
69
|
| {
|
|
66
70
|
type: 'otp'
|
|
@@ -73,6 +77,7 @@ export type AuthParams =
|
|
|
73
77
|
mode: 'send'
|
|
74
78
|
email: string
|
|
75
79
|
redirectURL: string
|
|
80
|
+
otpCodeCustomization?: OtpCodeCustomization
|
|
76
81
|
}
|
|
77
82
|
| {
|
|
78
83
|
type: 'magicLink'
|
|
@@ -364,6 +369,9 @@ export async function createZeroDevWallet(
|
|
|
364
369
|
emailCustomization: {
|
|
365
370
|
magicLinkTemplate: `${params.redirectURL}${params.redirectURL.includes('?') ? '&' : '?'}code=%s`,
|
|
366
371
|
},
|
|
372
|
+
...(params.otpCodeCustomization && {
|
|
373
|
+
otpCodeCustomization: params.otpCodeCustomization,
|
|
374
|
+
}),
|
|
367
375
|
}
|
|
368
376
|
} else {
|
|
369
377
|
otpParams = {
|
|
@@ -378,13 +386,15 @@ export async function createZeroDevWallet(
|
|
|
378
386
|
}
|
|
379
387
|
|
|
380
388
|
if (otpParams.mode === 'sendOtp') {
|
|
381
|
-
const { email, contact, emailCustomization } =
|
|
389
|
+
const { email, contact, emailCustomization, otpCodeCustomization } =
|
|
390
|
+
otpParams
|
|
382
391
|
|
|
383
392
|
const data = await client.registerWithOTP({
|
|
384
393
|
email,
|
|
385
394
|
contact,
|
|
386
395
|
projectId,
|
|
387
396
|
...(emailCustomization && { emailCustomization }),
|
|
397
|
+
...(otpCodeCustomization && { otpCodeCustomization }),
|
|
388
398
|
})
|
|
389
399
|
|
|
390
400
|
return data
|