@privy-io/expo 0.1.1 → 0.1.2-beta-20231024142926
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/dist/index.d.ts +29 -21
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +68 -67
- package/dist/index.mjs +72 -67
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -66,6 +66,12 @@ type EmbeddedWalletNeedsCreationState = {
|
|
|
66
66
|
*/
|
|
67
67
|
create: (password?: string) => void;
|
|
68
68
|
};
|
|
69
|
+
/**
|
|
70
|
+
* The embedded wallet is being created
|
|
71
|
+
*/
|
|
72
|
+
type EmbeddedWalletCreatingState = {
|
|
73
|
+
status: 'creating';
|
|
74
|
+
};
|
|
69
75
|
/**
|
|
70
76
|
* There was an error trying to either connect, create, or recover the embedded wallet
|
|
71
77
|
*/
|
|
@@ -76,7 +82,7 @@ type EmbeddedWalletErrorState = {
|
|
|
76
82
|
/**
|
|
77
83
|
* Represents the states in which a Privy embedded wallet connection can exist.
|
|
78
84
|
*/
|
|
79
|
-
export type EmbeddedWalletState = EmbeddedWalletConnectedState | EmbeddedWalletConnectingState | EmbeddedWalletInitialState | EmbeddedWalletNeedsRecoveryState | EmbeddedWalletNeedsCreationState | EmbeddedWalletErrorState;
|
|
85
|
+
export type EmbeddedWalletState = EmbeddedWalletConnectedState | EmbeddedWalletConnectingState | EmbeddedWalletInitialState | EmbeddedWalletNeedsRecoveryState | EmbeddedWalletCreatingState | EmbeddedWalletNeedsCreationState | EmbeddedWalletErrorState;
|
|
80
86
|
export type EmbeddedWalletStatus = EmbeddedWalletState['status'];
|
|
81
87
|
export type User = PrivyAuthenticatedUser['user'];
|
|
82
88
|
/**
|
|
@@ -92,13 +98,29 @@ export type User = PrivyAuthenticatedUser['user'];
|
|
|
92
98
|
* console.log(account.address)
|
|
93
99
|
*/
|
|
94
100
|
export const getUserEmbeddedWallet: (user: User | null) => EmbeddedWallet | null;
|
|
101
|
+
type OtpFlowState = {
|
|
102
|
+
status: 'initial';
|
|
103
|
+
} | {
|
|
104
|
+
status: 'error';
|
|
105
|
+
error: Error | null;
|
|
106
|
+
} | {
|
|
107
|
+
status: 'sending-code';
|
|
108
|
+
} | {
|
|
109
|
+
status: 'awaiting-code-input';
|
|
110
|
+
} | {
|
|
111
|
+
status: 'submitting-code';
|
|
112
|
+
} | {
|
|
113
|
+
status: 'done';
|
|
114
|
+
};
|
|
95
115
|
export const SecureStorageAdapter: Storage;
|
|
96
116
|
export type PrivyContext = {
|
|
97
117
|
client: Privy;
|
|
98
118
|
user: PrivyUser | null;
|
|
99
119
|
isReady: boolean;
|
|
100
120
|
wallet: EmbeddedWalletState;
|
|
101
|
-
|
|
121
|
+
oAuthState: OAuthFlowState;
|
|
122
|
+
otpState: OtpFlowState;
|
|
123
|
+
setOtpState: React.Dispatch<React.SetStateAction<OtpFlowState>>;
|
|
102
124
|
};
|
|
103
125
|
export const PrivyContext: React.Context<PrivyContext>;
|
|
104
126
|
export type PrivyProviderProps = {
|
|
@@ -113,21 +135,6 @@ export type PrivyProviderProps = {
|
|
|
113
135
|
storage?: Storage;
|
|
114
136
|
};
|
|
115
137
|
export const PrivyProvider: (props: PrivyProviderProps) => React.JSX.Element;
|
|
116
|
-
type OtpFlowState = {
|
|
117
|
-
status: 'initial';
|
|
118
|
-
} | {
|
|
119
|
-
status: 'error';
|
|
120
|
-
error: Error | null;
|
|
121
|
-
} | {
|
|
122
|
-
status: 'sending-code';
|
|
123
|
-
} | {
|
|
124
|
-
status: 'awaiting-code-input';
|
|
125
|
-
} | {
|
|
126
|
-
status: 'submitting-code';
|
|
127
|
-
} | {
|
|
128
|
-
status: 'done';
|
|
129
|
-
};
|
|
130
|
-
export const usePrivyClient: () => import("@privy-io/js-sdk-core").default;
|
|
131
138
|
export const useLoginWithEmail: () => {
|
|
132
139
|
sendCode: ({ email }: {
|
|
133
140
|
email: string;
|
|
@@ -136,7 +143,7 @@ export const useLoginWithEmail: () => {
|
|
|
136
143
|
code: string;
|
|
137
144
|
email?: string | undefined;
|
|
138
145
|
}) => Promise<import("@privy-io/public-api").PrivyAuthenticatedUser | undefined>;
|
|
139
|
-
state: OtpFlowState;
|
|
146
|
+
state: import("src/hooks/hooks.types").OtpFlowState;
|
|
140
147
|
};
|
|
141
148
|
export const useLinkEmail: () => {
|
|
142
149
|
sendCode: ({ email }: {
|
|
@@ -146,7 +153,7 @@ export const useLinkEmail: () => {
|
|
|
146
153
|
code: string;
|
|
147
154
|
email?: string | undefined;
|
|
148
155
|
}) => Promise<import("@privy-io/public-api").PrivyUser | undefined>;
|
|
149
|
-
state: OtpFlowState;
|
|
156
|
+
state: import("src/hooks/hooks.types").OtpFlowState;
|
|
150
157
|
};
|
|
151
158
|
export const useLoginWithSMS: () => {
|
|
152
159
|
sendCode: ({ phone }: {
|
|
@@ -156,7 +163,7 @@ export const useLoginWithSMS: () => {
|
|
|
156
163
|
code: string;
|
|
157
164
|
phone?: string | undefined;
|
|
158
165
|
}) => Promise<import("@privy-io/public-api").PrivyAuthenticatedUser | undefined>;
|
|
159
|
-
state: OtpFlowState;
|
|
166
|
+
state: import("src/hooks/hooks.types").OtpFlowState;
|
|
160
167
|
};
|
|
161
168
|
export const useLinkSMS: () => {
|
|
162
169
|
sendCode: ({ phone }: {
|
|
@@ -166,9 +173,10 @@ export const useLinkSMS: () => {
|
|
|
166
173
|
code: string;
|
|
167
174
|
phone?: string | undefined;
|
|
168
175
|
}) => Promise<import("@privy-io/public-api").PrivyUser | undefined>;
|
|
169
|
-
state: OtpFlowState;
|
|
176
|
+
state: import("src/hooks/hooks.types").OtpFlowState;
|
|
170
177
|
};
|
|
171
178
|
export const useEmbeddedWallet: () => EmbeddedWalletState;
|
|
179
|
+
export const usePrivyClient: () => import("@privy-io/js-sdk-core").default;
|
|
172
180
|
export const usePrivy: () => {
|
|
173
181
|
user: import("@privy-io/public-api").PrivyUser | null;
|
|
174
182
|
isReady: boolean;
|
package/dist/index.d.ts.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,SAAS,CAAC;IAE1B;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CAMnB,CAAC;AAEF,OAAO,MAAM,uBAAwB,kBAAkB,sBAuDtD,CAAC;ACrGF,OAAO,MAAM;;eAKe,MAAM;;;cAcD,MAAM;;;;CAuBtC,CAAC;AC1CF,OAAO,MAAM;;eAKe,MAAM;;;cAcD,MAAM;;;;CAuBtC,CAAC;AC1CF,OAAO,MAAM;;eAKe,MAAM;;;cAcD,MAAM;;;;CAuBtC,CAAC;AC1CF,OAAO,MAAM;;eAKe,MAAM;;;cAcD,MAAM;;;;CAuBtC,CAAC;AC1CF,OAAO,MAAM,yBAAwB,mBAIpC,CAAC;ACLF,OAAO,MAAM,6DAIZ,CAAC;ACJF,OAAO,MAAM;;;;CAMZ,CAAC;AEVF,cAAc,uBAAuB,CAAC","sources":["packages-js-public/expo/src/src/context/EmbeddedWalletWebView.tsx","packages-js-public/expo/src/src/expo.ts","packages-js-public/expo/src/src/utils/toStableSetter.ts","packages-js-public/expo/src/src/types.ts","packages-js-public/expo/src/src/utils/getUserEmbeddedWallet.ts","packages-js-public/expo/src/src/utils/toErrorState.ts","packages-js-public/expo/src/src/utils/index.ts","packages-js-public/expo/src/src/context/useCompleteOAuthFlow.ts","packages-js-public/expo/src/src/context/useConnectEmbeddedWallet.ts","packages-js-public/expo/src/src/context/useInitializeUser.ts","packages-js-public/expo/src/src/hooks/hooks.types.ts","packages-js-public/expo/src/src/hooks/useFetchUserOnAppResume.ts","packages-js-public/expo/src/src/storage/SecureStore.ts","packages-js-public/expo/src/src/PrivyProvider.tsx","packages-js-public/expo/src/src/hooks/useLoginWithEmail.ts","packages-js-public/expo/src/src/hooks/useLinkEmail.ts","packages-js-public/expo/src/src/hooks/useLoginWithSMS.ts","packages-js-public/expo/src/src/hooks/useLinkSMS.ts","packages-js-public/expo/src/src/hooks/useEmbeddedWallet.ts","packages-js-public/expo/src/src/hooks/usePrivyClient.ts","packages-js-public/expo/src/src/hooks/usePrivy.ts","packages-js-public/expo/src/src/hooks/index.ts","packages-js-public/expo/src/src/index.ts","packages-js-public/expo/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"export * from '@privy-io/js-sdk-core';\nexport * from './PrivyProvider';\nexport * from './types';\nexport * from './hooks';\nexport * from './expo';\nexport {SecureStorageAdapter} from './storage/SecureStore';\nexport {getUserEmbeddedWallet} from './utils';\n"],"names":[],"version":3,"file":"index.d.ts.map"}
|
package/dist/index.js
CHANGED
|
@@ -42,6 +42,10 @@ $parcel$export($a86988141172f0df$exports, "PrivyProvider", () => $a86988141172f0
|
|
|
42
42
|
|
|
43
43
|
|
|
44
44
|
|
|
45
|
+
var $c6c939beab98cc54$exports = {};
|
|
46
|
+
$c6c939beab98cc54$exports = JSON.parse('{"name":"@privy-io/expo","version":"0.1.2-beta-20231024142926","description":"Expo client for the Privy Auth API","keywords":["authentication","authorization","identity","privacy","privy","user data","react-native","expo","web3"],"license":"Apache-2.0","source":"./src/index.ts","main":"./dist/index.js","module":"./dist/index.mjs","types":"./dist/index.d.ts","exports":{".":{"require":"./dist/index.js","import":"./dist/index.mjs","types":"./dist/index.d.ts"}},"targets":{"main":{"isLibrary":true,"sourceMap":false},"module":{"isLibrary":true,"sourceMap":false}},"files":["dist/**/*","LICENSE","README.md"],"scripts":{"build":"npx parcel build --no-cache","clean":"rm -rf dist .turbo","prepublishOnly":"npm run clean && npm run build","dev":"npx parcel watch -p 4234","test":"jest --testMatch \\"**/test/unit/**/*.test.ts\\"","test:ci":"npm run test","test-integration":"jest --testMatch \\"**/test/integration/**/*.test.ts\\"","lint":"eslint \\"src/**/*.{ts,tsx,js,jsx}\\" && npx tsc --noEmit","format":"eslint \\"src/**/*.{ts,tsx,js,jsx}\\" --fix"},"peerDependencies":{"expo-linking":"*","react":"*","react-native":"*","react-native-webview":"*","expo-secure-store":"*"},"dependencies":{"@privy-io/js-sdk-core":"0.6.1-beta-20231024142926","react-fast-compare":"^3.2.2"},"devDependencies":{"@privy-io/eslint-config-custom":"*","@privy-io/tsconfig":"*","@tsconfig/node16-strictest-esm":"^1.0.3","parcel":"2.10.0","tsup":"^6.2.3","typescript":"^4.9.5"},"author":"privy.io","publishConfig":{"access":"public"}}');
|
|
47
|
+
|
|
48
|
+
|
|
45
49
|
|
|
46
50
|
|
|
47
51
|
const $686f2598373ca7a0$export$4e939057215c533 = ({ client: client, isWebViewReady: isWebViewReady, setIsWebViewReady: setIsWebViewReady })=>{
|
|
@@ -130,12 +134,12 @@ const $4cd0d7946b71f944$export$8483e4c9b261aeda = (user)=>{
|
|
|
130
134
|
|
|
131
135
|
|
|
132
136
|
|
|
133
|
-
const $d3556a85e1df5179$export$84a1ab94d79df399 = ({ client: client, user: user, isUserInitialized: isUserInitialized,
|
|
137
|
+
const $d3556a85e1df5179$export$84a1ab94d79df399 = ({ client: client, user: user, isUserInitialized: isUserInitialized, setOAuthState: setOAuthState })=>{
|
|
134
138
|
const url = $g1Z2s$expolinking.useURL();
|
|
135
139
|
return (0, $g1Z2s$react.useEffect)(()=>{
|
|
136
140
|
const complete = async ()=>{
|
|
137
141
|
if (!url) {
|
|
138
|
-
|
|
142
|
+
setOAuthState({
|
|
139
143
|
status: "done"
|
|
140
144
|
});
|
|
141
145
|
return;
|
|
@@ -143,22 +147,22 @@ const $d3556a85e1df5179$export$84a1ab94d79df399 = ({ client: client, user: user,
|
|
|
143
147
|
const { queryParams: queryParams } = $g1Z2s$expolinking.parse(url);
|
|
144
148
|
const { privy_oauth_state: privy_oauth_state, privy_oauth_code: privy_oauth_code } = queryParams;
|
|
145
149
|
if (!privy_oauth_code || !privy_oauth_state) {
|
|
146
|
-
|
|
150
|
+
setOAuthState({
|
|
147
151
|
status: "done"
|
|
148
152
|
});
|
|
149
153
|
return;
|
|
150
154
|
}
|
|
151
|
-
|
|
155
|
+
setOAuthState({
|
|
152
156
|
status: "loading"
|
|
153
157
|
});
|
|
154
158
|
try {
|
|
155
159
|
if (user) await client.auth.oauth.linkWithCode(privy_oauth_code, privy_oauth_state);
|
|
156
160
|
else await client.auth.oauth.loginWithCode(privy_oauth_code, privy_oauth_state);
|
|
157
|
-
|
|
161
|
+
setOAuthState({
|
|
158
162
|
status: "done"
|
|
159
163
|
});
|
|
160
164
|
} catch (error) {
|
|
161
|
-
|
|
165
|
+
setOAuthState((0, $bb2bf684522c01ab$export$5a99dcfc36d582cc)(error));
|
|
162
166
|
}
|
|
163
167
|
// Since stripping query params off the url in place is not possible
|
|
164
168
|
// navigating to the currentUrl less the query params should accomplish the same
|
|
@@ -177,6 +181,9 @@ const $d3556a85e1df5179$export$84a1ab94d79df399 = ({ client: client, user: user,
|
|
|
177
181
|
|
|
178
182
|
const $dcec8b6b3d4da6e3$export$a5ddad04f22150fe = ({ client: client, user: user, setWallet: setWallet, isWebViewReady: isWebViewReady })=>{
|
|
179
183
|
const create = (0, $g1Z2s$react.useCallback)(async (password)=>{
|
|
184
|
+
setWallet({
|
|
185
|
+
status: "creating"
|
|
186
|
+
});
|
|
180
187
|
try {
|
|
181
188
|
const provider = await client.embeddedWallet.create(password);
|
|
182
189
|
setWallet({
|
|
@@ -254,15 +261,14 @@ const $dcec8b6b3d4da6e3$export$a5ddad04f22150fe = ({ client: client, user: user,
|
|
|
254
261
|
if (isWebViewReady) load();
|
|
255
262
|
}, [
|
|
256
263
|
isWebViewReady,
|
|
257
|
-
user
|
|
258
|
-
create,
|
|
259
|
-
recover
|
|
264
|
+
user
|
|
260
265
|
]);
|
|
261
266
|
};
|
|
262
267
|
|
|
263
268
|
|
|
264
269
|
|
|
265
|
-
const $87d06e0dd3fdf2f8$export$616ad0264ddb756f = ({ client: client, isUserInitialized: isUserInitialized, setIsUserInitialized: setIsUserInitialized })=>
|
|
270
|
+
const $87d06e0dd3fdf2f8$export$616ad0264ddb756f = ({ client: client, isUserInitialized: isUserInitialized, setIsUserInitialized: setIsUserInitialized })=>{
|
|
271
|
+
(0, $g1Z2s$react.useEffect)(()=>{
|
|
266
272
|
const initialize = async ()=>{
|
|
267
273
|
try {
|
|
268
274
|
await client.user.get();
|
|
@@ -276,6 +282,7 @@ const $87d06e0dd3fdf2f8$export$616ad0264ddb756f = ({ client: client, isUserIniti
|
|
|
276
282
|
}, [
|
|
277
283
|
isUserInitialized
|
|
278
284
|
]);
|
|
285
|
+
};
|
|
279
286
|
|
|
280
287
|
|
|
281
288
|
var $a1ac5291d4c9c760$exports = {};
|
|
@@ -287,7 +294,7 @@ $parcel$export($a1ac5291d4c9c760$exports, "useOAuthFlow", () => $a1ac5291d4c9c76
|
|
|
287
294
|
|
|
288
295
|
const $a1ac5291d4c9c760$export$6fd8cd66c0c1502f = (state)=>state.status === "done" || state.status === "error";
|
|
289
296
|
const $a1ac5291d4c9c760$export$fc3dfe2dd4ef958b = ()=>{
|
|
290
|
-
const {
|
|
297
|
+
const { oAuthState: oAuthState, client: client } = (0, $g1Z2s$react.useContext)((0, $a86988141172f0df$export$d9ac34284a76b7d1));
|
|
291
298
|
const start = (0, $g1Z2s$react.useCallback)(async function start({ provider: provider, redirectUri: redirectUri }) {
|
|
292
299
|
const { url: oauthUrl } = await client.auth.oauth.generateURL(provider, $g1Z2s$expolinking.createURL(redirectUri || "/"));
|
|
293
300
|
return $g1Z2s$expolinking.openURL(oauthUrl);
|
|
@@ -296,7 +303,7 @@ const $a1ac5291d4c9c760$export$fc3dfe2dd4ef958b = ()=>{
|
|
|
296
303
|
]);
|
|
297
304
|
return {
|
|
298
305
|
start: start,
|
|
299
|
-
state:
|
|
306
|
+
state: oAuthState
|
|
300
307
|
};
|
|
301
308
|
};
|
|
302
309
|
|
|
@@ -339,18 +346,22 @@ const $a86988141172f0df$export$269acd2f821af04e = (props)=>{
|
|
|
339
346
|
const [isUserInitialized, setIsUserInitialized] = (0, $g1Z2s$react.useState)(false);
|
|
340
347
|
const [isWebViewReady, setIsWebViewReady] = (0, $g1Z2s$react.useState)(false);
|
|
341
348
|
const [user, setUser] = (0, $g1Z2s$react.useState)(null);
|
|
342
|
-
const [
|
|
349
|
+
const [oAuthState, setOAuthState] = (0, $g1Z2s$react.useState)({
|
|
343
350
|
status: "initial"
|
|
344
351
|
});
|
|
345
352
|
const [wallet, setWallet] = (0, $g1Z2s$react.useState)({
|
|
346
353
|
status: "initial"
|
|
347
354
|
});
|
|
355
|
+
const [otpState, setOtpState] = (0, $g1Z2s$react.useState)({
|
|
356
|
+
status: "initial"
|
|
357
|
+
});
|
|
348
358
|
const client = (0, $g1Z2s$react.useMemo)(()=>{
|
|
349
359
|
return new (0, ($parcel$interopDefault($g1Z2s$privyiojssdkcore)))({
|
|
350
360
|
storage: props.storage || (0, $20e20f192fa12fb8$export$d40cbc459c78d4fa),
|
|
351
361
|
appId: props.appId,
|
|
352
362
|
// @ts-expect-error internal config for development
|
|
353
363
|
baseUrl: props.baseUrl,
|
|
364
|
+
sdkVersion: `expo:${(0, (/*@__PURE__*/$parcel$interopDefault($c6c939beab98cc54$exports))).version}`,
|
|
354
365
|
callbacks: {
|
|
355
366
|
setUser: (0, $08d51d63a68f1cd0$export$c570510ed8d5fa)(setUser)
|
|
356
367
|
}
|
|
@@ -379,15 +390,17 @@ const $a86988141172f0df$export$269acd2f821af04e = (props)=>{
|
|
|
379
390
|
client: client,
|
|
380
391
|
isUserInitialized: isUserInitialized,
|
|
381
392
|
user: user,
|
|
382
|
-
|
|
393
|
+
setOAuthState: setOAuthState
|
|
383
394
|
});
|
|
384
395
|
return /*#__PURE__*/ (0, ($parcel$interopDefault($g1Z2s$react))).createElement((0, ($parcel$interopDefault($g1Z2s$react))).Fragment, null, /*#__PURE__*/ (0, ($parcel$interopDefault($g1Z2s$react))).createElement($a86988141172f0df$export$d9ac34284a76b7d1.Provider, {
|
|
385
396
|
value: {
|
|
386
397
|
client: client,
|
|
387
398
|
user: user,
|
|
388
|
-
isReady: isWebViewReady && isUserInitialized && (0, $a1ac5291d4c9c760$export$6fd8cd66c0c1502f)(
|
|
399
|
+
isReady: isWebViewReady && isUserInitialized && (0, $a1ac5291d4c9c760$export$6fd8cd66c0c1502f)(oAuthState),
|
|
389
400
|
wallet: wallet,
|
|
390
|
-
|
|
401
|
+
oAuthState: oAuthState,
|
|
402
|
+
otpState: otpState,
|
|
403
|
+
setOtpState: setOtpState
|
|
391
404
|
}
|
|
392
405
|
}, props.children), /*#__PURE__*/ (0, ($parcel$interopDefault($g1Z2s$react))).createElement((0, $g1Z2s$reactnative.View), {
|
|
393
406
|
style: {
|
|
@@ -418,31 +431,21 @@ $parcel$export($8ee466aa5d26834e$exports, "usePrivy", () => $d69c97c483a6be45$ex
|
|
|
418
431
|
|
|
419
432
|
|
|
420
433
|
|
|
421
|
-
|
|
422
|
-
const $b27197b05fcc1019$export$9f1f355652e8b9cb = ()=>{
|
|
423
|
-
const { client: client } = (0, $g1Z2s$react.useContext)((0, $a86988141172f0df$export$d9ac34284a76b7d1));
|
|
424
|
-
return client;
|
|
425
|
-
};
|
|
426
|
-
|
|
427
|
-
|
|
428
434
|
const $d618b248836e7fe8$export$35882cb036127e21 = ()=>{
|
|
429
|
-
const client = (0, $b27197b05fcc1019$export$9f1f355652e8b9cb)();
|
|
430
435
|
const [_email, setEmail] = (0, $g1Z2s$react.useState)("");
|
|
431
|
-
const
|
|
432
|
-
status: "initial"
|
|
433
|
-
});
|
|
436
|
+
const { client: client, otpState: otpState, setOtpState: setOtpState } = (0, $g1Z2s$react.useContext)((0, $a86988141172f0df$export$d9ac34284a76b7d1));
|
|
434
437
|
const sendCode = (0, $g1Z2s$react.useCallback)(async ({ email: email })=>{
|
|
435
438
|
setEmail(email);
|
|
436
439
|
try {
|
|
437
|
-
|
|
440
|
+
setOtpState({
|
|
438
441
|
status: "sending-code"
|
|
439
442
|
});
|
|
440
443
|
await client.auth.email.sendCode(email);
|
|
441
|
-
|
|
444
|
+
setOtpState({
|
|
442
445
|
status: "awaiting-code-input"
|
|
443
446
|
});
|
|
444
447
|
} catch (error) {
|
|
445
|
-
|
|
448
|
+
setOtpState((0, $bb2bf684522c01ab$export$5a99dcfc36d582cc)(error));
|
|
446
449
|
}
|
|
447
450
|
}, [
|
|
448
451
|
client
|
|
@@ -451,16 +454,16 @@ const $d618b248836e7fe8$export$35882cb036127e21 = ()=>{
|
|
|
451
454
|
const dest = email || _email;
|
|
452
455
|
if (!dest) throw new Error("Must `sendCode` with a valid email before calling `loginWithCode`");
|
|
453
456
|
try {
|
|
454
|
-
|
|
457
|
+
setOtpState({
|
|
455
458
|
status: "submitting-code"
|
|
456
459
|
});
|
|
457
460
|
const res = await client.auth.email.loginWithCode(dest, code);
|
|
458
|
-
|
|
461
|
+
setOtpState({
|
|
459
462
|
status: "done"
|
|
460
463
|
});
|
|
461
464
|
return res;
|
|
462
465
|
} catch (error) {
|
|
463
|
-
|
|
466
|
+
setOtpState((0, $bb2bf684522c01ab$export$5a99dcfc36d582cc)(error));
|
|
464
467
|
}
|
|
465
468
|
}, [
|
|
466
469
|
client,
|
|
@@ -469,7 +472,7 @@ const $d618b248836e7fe8$export$35882cb036127e21 = ()=>{
|
|
|
469
472
|
return {
|
|
470
473
|
sendCode: sendCode,
|
|
471
474
|
loginWithCode: loginWithCode,
|
|
472
|
-
state:
|
|
475
|
+
state: otpState
|
|
473
476
|
};
|
|
474
477
|
};
|
|
475
478
|
|
|
@@ -478,23 +481,20 @@ const $d618b248836e7fe8$export$35882cb036127e21 = ()=>{
|
|
|
478
481
|
|
|
479
482
|
|
|
480
483
|
const $52f811ed8fd80894$export$adf3c939ee6f7493 = ()=>{
|
|
481
|
-
const client = (0, $b27197b05fcc1019$export$9f1f355652e8b9cb)();
|
|
482
484
|
const [_email, setEmail] = (0, $g1Z2s$react.useState)("");
|
|
483
|
-
const
|
|
484
|
-
status: "initial"
|
|
485
|
-
});
|
|
485
|
+
const { client: client, otpState: otpState, setOtpState: setOtpState } = (0, $g1Z2s$react.useContext)((0, $a86988141172f0df$export$d9ac34284a76b7d1));
|
|
486
486
|
const sendCode = (0, $g1Z2s$react.useCallback)(async ({ email: email })=>{
|
|
487
487
|
setEmail(email);
|
|
488
488
|
try {
|
|
489
|
-
|
|
489
|
+
setOtpState({
|
|
490
490
|
status: "sending-code"
|
|
491
491
|
});
|
|
492
492
|
await client.auth.email.sendCode(email);
|
|
493
|
-
|
|
493
|
+
setOtpState({
|
|
494
494
|
status: "awaiting-code-input"
|
|
495
495
|
});
|
|
496
496
|
} catch (error) {
|
|
497
|
-
|
|
497
|
+
setOtpState((0, $bb2bf684522c01ab$export$5a99dcfc36d582cc)(error));
|
|
498
498
|
}
|
|
499
499
|
}, [
|
|
500
500
|
client
|
|
@@ -503,16 +503,16 @@ const $52f811ed8fd80894$export$adf3c939ee6f7493 = ()=>{
|
|
|
503
503
|
const dest = email || _email;
|
|
504
504
|
if (!dest) throw new Error("Must `sendCode` with a valid email before calling `linkWithCode`");
|
|
505
505
|
try {
|
|
506
|
-
|
|
506
|
+
setOtpState({
|
|
507
507
|
status: "submitting-code"
|
|
508
508
|
});
|
|
509
509
|
const res = await client.auth.email.linkWithCode(dest, code);
|
|
510
|
-
|
|
510
|
+
setOtpState({
|
|
511
511
|
status: "done"
|
|
512
512
|
});
|
|
513
513
|
return res;
|
|
514
514
|
} catch (error) {
|
|
515
|
-
|
|
515
|
+
setOtpState((0, $bb2bf684522c01ab$export$5a99dcfc36d582cc)(error));
|
|
516
516
|
}
|
|
517
517
|
}, [
|
|
518
518
|
client,
|
|
@@ -521,7 +521,7 @@ const $52f811ed8fd80894$export$adf3c939ee6f7493 = ()=>{
|
|
|
521
521
|
return {
|
|
522
522
|
sendCode: sendCode,
|
|
523
523
|
linkWithCode: linkWithCode,
|
|
524
|
-
state:
|
|
524
|
+
state: otpState
|
|
525
525
|
};
|
|
526
526
|
};
|
|
527
527
|
|
|
@@ -530,23 +530,20 @@ const $52f811ed8fd80894$export$adf3c939ee6f7493 = ()=>{
|
|
|
530
530
|
|
|
531
531
|
|
|
532
532
|
const $128a75b395eab63a$export$bee5fe3d09aee7c2 = ()=>{
|
|
533
|
-
const client = (0, $b27197b05fcc1019$export$9f1f355652e8b9cb)();
|
|
534
533
|
const [_phone, setPhone] = (0, $g1Z2s$react.useState)("");
|
|
535
|
-
const
|
|
536
|
-
status: "initial"
|
|
537
|
-
});
|
|
534
|
+
const { client: client, otpState: otpState, setOtpState: setOtpState } = (0, $g1Z2s$react.useContext)((0, $a86988141172f0df$export$d9ac34284a76b7d1));
|
|
538
535
|
const sendCode = (0, $g1Z2s$react.useCallback)(async ({ phone: phone })=>{
|
|
539
536
|
setPhone(phone);
|
|
540
537
|
try {
|
|
541
|
-
|
|
538
|
+
setOtpState({
|
|
542
539
|
status: "sending-code"
|
|
543
540
|
});
|
|
544
541
|
await client.auth.phone.sendCode(phone);
|
|
545
|
-
|
|
542
|
+
setOtpState({
|
|
546
543
|
status: "awaiting-code-input"
|
|
547
544
|
});
|
|
548
545
|
} catch (error) {
|
|
549
|
-
|
|
546
|
+
setOtpState((0, $bb2bf684522c01ab$export$5a99dcfc36d582cc)(error));
|
|
550
547
|
}
|
|
551
548
|
}, [
|
|
552
549
|
client
|
|
@@ -555,16 +552,16 @@ const $128a75b395eab63a$export$bee5fe3d09aee7c2 = ()=>{
|
|
|
555
552
|
const dest = phone || _phone;
|
|
556
553
|
if (!dest) throw new Error("Must `sendCode` with a valid phone number before calling `loginWithCode`");
|
|
557
554
|
try {
|
|
558
|
-
|
|
555
|
+
setOtpState({
|
|
559
556
|
status: "submitting-code"
|
|
560
557
|
});
|
|
561
558
|
const res = await client.auth.phone.loginWithCode(phone || _phone, code);
|
|
562
|
-
|
|
559
|
+
setOtpState({
|
|
563
560
|
status: "done"
|
|
564
561
|
});
|
|
565
562
|
return res;
|
|
566
563
|
} catch (error) {
|
|
567
|
-
|
|
564
|
+
setOtpState((0, $bb2bf684522c01ab$export$5a99dcfc36d582cc)(error));
|
|
568
565
|
}
|
|
569
566
|
}, [
|
|
570
567
|
client,
|
|
@@ -573,7 +570,7 @@ const $128a75b395eab63a$export$bee5fe3d09aee7c2 = ()=>{
|
|
|
573
570
|
return {
|
|
574
571
|
sendCode: sendCode,
|
|
575
572
|
loginWithCode: loginWithCode,
|
|
576
|
-
state:
|
|
573
|
+
state: otpState
|
|
577
574
|
};
|
|
578
575
|
};
|
|
579
576
|
|
|
@@ -582,23 +579,20 @@ const $128a75b395eab63a$export$bee5fe3d09aee7c2 = ()=>{
|
|
|
582
579
|
|
|
583
580
|
|
|
584
581
|
const $d0f69aef5a750107$export$2b5393df0050a256 = ()=>{
|
|
585
|
-
const client = (0, $b27197b05fcc1019$export$9f1f355652e8b9cb)();
|
|
586
582
|
const [_phone, setPhone] = (0, $g1Z2s$react.useState)("");
|
|
587
|
-
const
|
|
588
|
-
status: "initial"
|
|
589
|
-
});
|
|
583
|
+
const { client: client, otpState: otpState, setOtpState: setOtpState } = (0, $g1Z2s$react.useContext)((0, $a86988141172f0df$export$d9ac34284a76b7d1));
|
|
590
584
|
const sendCode = (0, $g1Z2s$react.useCallback)(async ({ phone: phone })=>{
|
|
591
585
|
setPhone(phone);
|
|
592
586
|
try {
|
|
593
|
-
|
|
587
|
+
setOtpState({
|
|
594
588
|
status: "sending-code"
|
|
595
589
|
});
|
|
596
590
|
await client.auth.phone.sendCode(phone);
|
|
597
|
-
|
|
591
|
+
setOtpState({
|
|
598
592
|
status: "awaiting-code-input"
|
|
599
593
|
});
|
|
600
594
|
} catch (error) {
|
|
601
|
-
|
|
595
|
+
setOtpState((0, $bb2bf684522c01ab$export$5a99dcfc36d582cc)(error));
|
|
602
596
|
}
|
|
603
597
|
}, [
|
|
604
598
|
client
|
|
@@ -607,16 +601,16 @@ const $d0f69aef5a750107$export$2b5393df0050a256 = ()=>{
|
|
|
607
601
|
const dest = phone || _phone;
|
|
608
602
|
if (!dest) throw new Error("Must `sendCode` with a valid phone number before calling `linkWithCode`");
|
|
609
603
|
try {
|
|
610
|
-
|
|
604
|
+
setOtpState({
|
|
611
605
|
status: "submitting-code"
|
|
612
606
|
});
|
|
613
607
|
const res = await client.auth.phone.linkWithCode(phone || _phone, code);
|
|
614
|
-
|
|
608
|
+
setOtpState({
|
|
615
609
|
status: "done"
|
|
616
610
|
});
|
|
617
611
|
return res;
|
|
618
612
|
} catch (error) {
|
|
619
|
-
|
|
613
|
+
setOtpState((0, $bb2bf684522c01ab$export$5a99dcfc36d582cc)(error));
|
|
620
614
|
}
|
|
621
615
|
}, [
|
|
622
616
|
client,
|
|
@@ -625,7 +619,7 @@ const $d0f69aef5a750107$export$2b5393df0050a256 = ()=>{
|
|
|
625
619
|
return {
|
|
626
620
|
sendCode: sendCode,
|
|
627
621
|
linkWithCode: linkWithCode,
|
|
628
|
-
state:
|
|
622
|
+
state: otpState
|
|
629
623
|
};
|
|
630
624
|
};
|
|
631
625
|
|
|
@@ -640,6 +634,13 @@ const $86a0ae4dcb27af6e$export$7cb4baffef0102f = ()=>{
|
|
|
640
634
|
|
|
641
635
|
|
|
642
636
|
|
|
637
|
+
const $b27197b05fcc1019$export$9f1f355652e8b9cb = ()=>{
|
|
638
|
+
const { client: client } = (0, $g1Z2s$react.useContext)((0, $a86988141172f0df$export$d9ac34284a76b7d1));
|
|
639
|
+
return client;
|
|
640
|
+
};
|
|
641
|
+
|
|
642
|
+
|
|
643
|
+
|
|
643
644
|
|
|
644
645
|
const $d69c97c483a6be45$export$9c33552016a926e5 = ()=>{
|
|
645
646
|
const { user: user, isReady: isReady, client: client } = (0, $g1Z2s$react.useContext)((0, $a86988141172f0df$export$d9ac34284a76b7d1));
|
package/dist/index.mjs
CHANGED
|
@@ -7,6 +7,10 @@ import $gsnqM$reactfastcompare from "react-fast-compare";
|
|
|
7
7
|
import {getItemAsync as $gsnqM$getItemAsync, setItemAsync as $gsnqM$setItemAsync, deleteItemAsync as $gsnqM$deleteItemAsync} from "expo-secure-store";
|
|
8
8
|
|
|
9
9
|
|
|
10
|
+
function $parcel$interopDefault(a) {
|
|
11
|
+
return a && a.__esModule ? a.default : a;
|
|
12
|
+
}
|
|
13
|
+
|
|
10
14
|
function $parcel$export(e, n, v, s) {
|
|
11
15
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
12
16
|
}
|
|
@@ -18,6 +22,10 @@ $parcel$export($b50fc71d7f94fd16$exports, "PrivyProvider", () => $b50fc71d7f94fd
|
|
|
18
22
|
|
|
19
23
|
|
|
20
24
|
|
|
25
|
+
var $de087c354fa2001e$exports = {};
|
|
26
|
+
$de087c354fa2001e$exports = JSON.parse('{"name":"@privy-io/expo","version":"0.1.2-beta-20231024142926","description":"Expo client for the Privy Auth API","keywords":["authentication","authorization","identity","privacy","privy","user data","react-native","expo","web3"],"license":"Apache-2.0","source":"./src/index.ts","main":"./dist/index.js","module":"./dist/index.mjs","types":"./dist/index.d.ts","exports":{".":{"require":"./dist/index.js","import":"./dist/index.mjs","types":"./dist/index.d.ts"}},"targets":{"main":{"isLibrary":true,"sourceMap":false},"module":{"isLibrary":true,"sourceMap":false}},"files":["dist/**/*","LICENSE","README.md"],"scripts":{"build":"npx parcel build --no-cache","clean":"rm -rf dist .turbo","prepublishOnly":"npm run clean && npm run build","dev":"npx parcel watch -p 4234","test":"jest --testMatch \\"**/test/unit/**/*.test.ts\\"","test:ci":"npm run test","test-integration":"jest --testMatch \\"**/test/integration/**/*.test.ts\\"","lint":"eslint \\"src/**/*.{ts,tsx,js,jsx}\\" && npx tsc --noEmit","format":"eslint \\"src/**/*.{ts,tsx,js,jsx}\\" --fix"},"peerDependencies":{"expo-linking":"*","react":"*","react-native":"*","react-native-webview":"*","expo-secure-store":"*"},"dependencies":{"@privy-io/js-sdk-core":"0.6.1-beta-20231024142926","react-fast-compare":"^3.2.2"},"devDependencies":{"@privy-io/eslint-config-custom":"*","@privy-io/tsconfig":"*","@tsconfig/node16-strictest-esm":"^1.0.3","parcel":"2.10.0","tsup":"^6.2.3","typescript":"^4.9.5"},"author":"privy.io","publishConfig":{"access":"public"}}');
|
|
27
|
+
|
|
28
|
+
|
|
21
29
|
|
|
22
30
|
|
|
23
31
|
const $a7a4cc2f44eb469d$export$4e939057215c533 = ({ client: client, isWebViewReady: isWebViewReady, setIsWebViewReady: setIsWebViewReady })=>{
|
|
@@ -106,12 +114,12 @@ const $c78f5641ca0c8cbc$export$8483e4c9b261aeda = (user)=>{
|
|
|
106
114
|
|
|
107
115
|
|
|
108
116
|
|
|
109
|
-
const $05cdfc0c94e9a5ec$export$84a1ab94d79df399 = ({ client: client, user: user, isUserInitialized: isUserInitialized,
|
|
117
|
+
const $05cdfc0c94e9a5ec$export$84a1ab94d79df399 = ({ client: client, user: user, isUserInitialized: isUserInitialized, setOAuthState: setOAuthState })=>{
|
|
110
118
|
const url = $gsnqM$useURL();
|
|
111
119
|
return (0, $gsnqM$useEffect)(()=>{
|
|
112
120
|
const complete = async ()=>{
|
|
113
121
|
if (!url) {
|
|
114
|
-
|
|
122
|
+
setOAuthState({
|
|
115
123
|
status: "done"
|
|
116
124
|
});
|
|
117
125
|
return;
|
|
@@ -119,22 +127,22 @@ const $05cdfc0c94e9a5ec$export$84a1ab94d79df399 = ({ client: client, user: user,
|
|
|
119
127
|
const { queryParams: queryParams } = $gsnqM$parse(url);
|
|
120
128
|
const { privy_oauth_state: privy_oauth_state, privy_oauth_code: privy_oauth_code } = queryParams;
|
|
121
129
|
if (!privy_oauth_code || !privy_oauth_state) {
|
|
122
|
-
|
|
130
|
+
setOAuthState({
|
|
123
131
|
status: "done"
|
|
124
132
|
});
|
|
125
133
|
return;
|
|
126
134
|
}
|
|
127
|
-
|
|
135
|
+
setOAuthState({
|
|
128
136
|
status: "loading"
|
|
129
137
|
});
|
|
130
138
|
try {
|
|
131
139
|
if (user) await client.auth.oauth.linkWithCode(privy_oauth_code, privy_oauth_state);
|
|
132
140
|
else await client.auth.oauth.loginWithCode(privy_oauth_code, privy_oauth_state);
|
|
133
|
-
|
|
141
|
+
setOAuthState({
|
|
134
142
|
status: "done"
|
|
135
143
|
});
|
|
136
144
|
} catch (error) {
|
|
137
|
-
|
|
145
|
+
setOAuthState((0, $124a96fd11dcd394$export$5a99dcfc36d582cc)(error));
|
|
138
146
|
}
|
|
139
147
|
// Since stripping query params off the url in place is not possible
|
|
140
148
|
// navigating to the currentUrl less the query params should accomplish the same
|
|
@@ -153,6 +161,9 @@ const $05cdfc0c94e9a5ec$export$84a1ab94d79df399 = ({ client: client, user: user,
|
|
|
153
161
|
|
|
154
162
|
const $5c6f43f35a6299b7$export$a5ddad04f22150fe = ({ client: client, user: user, setWallet: setWallet, isWebViewReady: isWebViewReady })=>{
|
|
155
163
|
const create = (0, $gsnqM$useCallback)(async (password)=>{
|
|
164
|
+
setWallet({
|
|
165
|
+
status: "creating"
|
|
166
|
+
});
|
|
156
167
|
try {
|
|
157
168
|
const provider = await client.embeddedWallet.create(password);
|
|
158
169
|
setWallet({
|
|
@@ -230,15 +241,14 @@ const $5c6f43f35a6299b7$export$a5ddad04f22150fe = ({ client: client, user: user,
|
|
|
230
241
|
if (isWebViewReady) load();
|
|
231
242
|
}, [
|
|
232
243
|
isWebViewReady,
|
|
233
|
-
user
|
|
234
|
-
create,
|
|
235
|
-
recover
|
|
244
|
+
user
|
|
236
245
|
]);
|
|
237
246
|
};
|
|
238
247
|
|
|
239
248
|
|
|
240
249
|
|
|
241
|
-
const $863e5e1a455daa34$export$616ad0264ddb756f = ({ client: client, isUserInitialized: isUserInitialized, setIsUserInitialized: setIsUserInitialized })=>
|
|
250
|
+
const $863e5e1a455daa34$export$616ad0264ddb756f = ({ client: client, isUserInitialized: isUserInitialized, setIsUserInitialized: setIsUserInitialized })=>{
|
|
251
|
+
(0, $gsnqM$useEffect)(()=>{
|
|
242
252
|
const initialize = async ()=>{
|
|
243
253
|
try {
|
|
244
254
|
await client.user.get();
|
|
@@ -252,6 +262,7 @@ const $863e5e1a455daa34$export$616ad0264ddb756f = ({ client: client, isUserIniti
|
|
|
252
262
|
}, [
|
|
253
263
|
isUserInitialized
|
|
254
264
|
]);
|
|
265
|
+
};
|
|
255
266
|
|
|
256
267
|
|
|
257
268
|
var $708febbf476a0970$exports = {};
|
|
@@ -263,7 +274,7 @@ $parcel$export($708febbf476a0970$exports, "useOAuthFlow", () => $708febbf476a097
|
|
|
263
274
|
|
|
264
275
|
const $708febbf476a0970$export$6fd8cd66c0c1502f = (state)=>state.status === "done" || state.status === "error";
|
|
265
276
|
const $708febbf476a0970$export$fc3dfe2dd4ef958b = ()=>{
|
|
266
|
-
const {
|
|
277
|
+
const { oAuthState: oAuthState, client: client } = (0, $gsnqM$useContext)((0, $b50fc71d7f94fd16$export$d9ac34284a76b7d1));
|
|
267
278
|
const start = (0, $gsnqM$useCallback)(async function start({ provider: provider, redirectUri: redirectUri }) {
|
|
268
279
|
const { url: oauthUrl } = await client.auth.oauth.generateURL(provider, $gsnqM$createURL(redirectUri || "/"));
|
|
269
280
|
return $gsnqM$openURL(oauthUrl);
|
|
@@ -272,7 +283,7 @@ const $708febbf476a0970$export$fc3dfe2dd4ef958b = ()=>{
|
|
|
272
283
|
]);
|
|
273
284
|
return {
|
|
274
285
|
start: start,
|
|
275
|
-
state:
|
|
286
|
+
state: oAuthState
|
|
276
287
|
};
|
|
277
288
|
};
|
|
278
289
|
|
|
@@ -315,18 +326,22 @@ const $b50fc71d7f94fd16$export$269acd2f821af04e = (props)=>{
|
|
|
315
326
|
const [isUserInitialized, setIsUserInitialized] = (0, $gsnqM$useState)(false);
|
|
316
327
|
const [isWebViewReady, setIsWebViewReady] = (0, $gsnqM$useState)(false);
|
|
317
328
|
const [user, setUser] = (0, $gsnqM$useState)(null);
|
|
318
|
-
const [
|
|
329
|
+
const [oAuthState, setOAuthState] = (0, $gsnqM$useState)({
|
|
319
330
|
status: "initial"
|
|
320
331
|
});
|
|
321
332
|
const [wallet, setWallet] = (0, $gsnqM$useState)({
|
|
322
333
|
status: "initial"
|
|
323
334
|
});
|
|
335
|
+
const [otpState, setOtpState] = (0, $gsnqM$useState)({
|
|
336
|
+
status: "initial"
|
|
337
|
+
});
|
|
324
338
|
const client = (0, $gsnqM$useMemo)(()=>{
|
|
325
339
|
return new (0, $gsnqM$privyiojssdkcore1)({
|
|
326
340
|
storage: props.storage || (0, $e2136775fd5786e2$export$d40cbc459c78d4fa),
|
|
327
341
|
appId: props.appId,
|
|
328
342
|
// @ts-expect-error internal config for development
|
|
329
343
|
baseUrl: props.baseUrl,
|
|
344
|
+
sdkVersion: `expo:${(0, (/*@__PURE__*/$parcel$interopDefault($de087c354fa2001e$exports))).version}`,
|
|
330
345
|
callbacks: {
|
|
331
346
|
setUser: (0, $046068485f201c48$export$c570510ed8d5fa)(setUser)
|
|
332
347
|
}
|
|
@@ -355,15 +370,17 @@ const $b50fc71d7f94fd16$export$269acd2f821af04e = (props)=>{
|
|
|
355
370
|
client: client,
|
|
356
371
|
isUserInitialized: isUserInitialized,
|
|
357
372
|
user: user,
|
|
358
|
-
|
|
373
|
+
setOAuthState: setOAuthState
|
|
359
374
|
});
|
|
360
375
|
return /*#__PURE__*/ (0, $gsnqM$react).createElement((0, $gsnqM$react).Fragment, null, /*#__PURE__*/ (0, $gsnqM$react).createElement($b50fc71d7f94fd16$export$d9ac34284a76b7d1.Provider, {
|
|
361
376
|
value: {
|
|
362
377
|
client: client,
|
|
363
378
|
user: user,
|
|
364
|
-
isReady: isWebViewReady && isUserInitialized && (0, $708febbf476a0970$export$6fd8cd66c0c1502f)(
|
|
379
|
+
isReady: isWebViewReady && isUserInitialized && (0, $708febbf476a0970$export$6fd8cd66c0c1502f)(oAuthState),
|
|
365
380
|
wallet: wallet,
|
|
366
|
-
|
|
381
|
+
oAuthState: oAuthState,
|
|
382
|
+
otpState: otpState,
|
|
383
|
+
setOtpState: setOtpState
|
|
367
384
|
}
|
|
368
385
|
}, props.children), /*#__PURE__*/ (0, $gsnqM$react).createElement((0, $gsnqM$View), {
|
|
369
386
|
style: {
|
|
@@ -394,31 +411,21 @@ $parcel$export($44b98c070e3ec565$exports, "usePrivy", () => $ed23cea2d2e0a913$ex
|
|
|
394
411
|
|
|
395
412
|
|
|
396
413
|
|
|
397
|
-
|
|
398
|
-
const $f5b7b0e486222817$export$9f1f355652e8b9cb = ()=>{
|
|
399
|
-
const { client: client } = (0, $gsnqM$useContext)((0, $b50fc71d7f94fd16$export$d9ac34284a76b7d1));
|
|
400
|
-
return client;
|
|
401
|
-
};
|
|
402
|
-
|
|
403
|
-
|
|
404
414
|
const $c3e76d3da9513431$export$35882cb036127e21 = ()=>{
|
|
405
|
-
const client = (0, $f5b7b0e486222817$export$9f1f355652e8b9cb)();
|
|
406
415
|
const [_email, setEmail] = (0, $gsnqM$useState)("");
|
|
407
|
-
const
|
|
408
|
-
status: "initial"
|
|
409
|
-
});
|
|
416
|
+
const { client: client, otpState: otpState, setOtpState: setOtpState } = (0, $gsnqM$useContext)((0, $b50fc71d7f94fd16$export$d9ac34284a76b7d1));
|
|
410
417
|
const sendCode = (0, $gsnqM$useCallback)(async ({ email: email })=>{
|
|
411
418
|
setEmail(email);
|
|
412
419
|
try {
|
|
413
|
-
|
|
420
|
+
setOtpState({
|
|
414
421
|
status: "sending-code"
|
|
415
422
|
});
|
|
416
423
|
await client.auth.email.sendCode(email);
|
|
417
|
-
|
|
424
|
+
setOtpState({
|
|
418
425
|
status: "awaiting-code-input"
|
|
419
426
|
});
|
|
420
427
|
} catch (error) {
|
|
421
|
-
|
|
428
|
+
setOtpState((0, $124a96fd11dcd394$export$5a99dcfc36d582cc)(error));
|
|
422
429
|
}
|
|
423
430
|
}, [
|
|
424
431
|
client
|
|
@@ -427,16 +434,16 @@ const $c3e76d3da9513431$export$35882cb036127e21 = ()=>{
|
|
|
427
434
|
const dest = email || _email;
|
|
428
435
|
if (!dest) throw new Error("Must `sendCode` with a valid email before calling `loginWithCode`");
|
|
429
436
|
try {
|
|
430
|
-
|
|
437
|
+
setOtpState({
|
|
431
438
|
status: "submitting-code"
|
|
432
439
|
});
|
|
433
440
|
const res = await client.auth.email.loginWithCode(dest, code);
|
|
434
|
-
|
|
441
|
+
setOtpState({
|
|
435
442
|
status: "done"
|
|
436
443
|
});
|
|
437
444
|
return res;
|
|
438
445
|
} catch (error) {
|
|
439
|
-
|
|
446
|
+
setOtpState((0, $124a96fd11dcd394$export$5a99dcfc36d582cc)(error));
|
|
440
447
|
}
|
|
441
448
|
}, [
|
|
442
449
|
client,
|
|
@@ -445,7 +452,7 @@ const $c3e76d3da9513431$export$35882cb036127e21 = ()=>{
|
|
|
445
452
|
return {
|
|
446
453
|
sendCode: sendCode,
|
|
447
454
|
loginWithCode: loginWithCode,
|
|
448
|
-
state:
|
|
455
|
+
state: otpState
|
|
449
456
|
};
|
|
450
457
|
};
|
|
451
458
|
|
|
@@ -454,23 +461,20 @@ const $c3e76d3da9513431$export$35882cb036127e21 = ()=>{
|
|
|
454
461
|
|
|
455
462
|
|
|
456
463
|
const $c9c034ed42105250$export$adf3c939ee6f7493 = ()=>{
|
|
457
|
-
const client = (0, $f5b7b0e486222817$export$9f1f355652e8b9cb)();
|
|
458
464
|
const [_email, setEmail] = (0, $gsnqM$useState)("");
|
|
459
|
-
const
|
|
460
|
-
status: "initial"
|
|
461
|
-
});
|
|
465
|
+
const { client: client, otpState: otpState, setOtpState: setOtpState } = (0, $gsnqM$useContext)((0, $b50fc71d7f94fd16$export$d9ac34284a76b7d1));
|
|
462
466
|
const sendCode = (0, $gsnqM$useCallback)(async ({ email: email })=>{
|
|
463
467
|
setEmail(email);
|
|
464
468
|
try {
|
|
465
|
-
|
|
469
|
+
setOtpState({
|
|
466
470
|
status: "sending-code"
|
|
467
471
|
});
|
|
468
472
|
await client.auth.email.sendCode(email);
|
|
469
|
-
|
|
473
|
+
setOtpState({
|
|
470
474
|
status: "awaiting-code-input"
|
|
471
475
|
});
|
|
472
476
|
} catch (error) {
|
|
473
|
-
|
|
477
|
+
setOtpState((0, $124a96fd11dcd394$export$5a99dcfc36d582cc)(error));
|
|
474
478
|
}
|
|
475
479
|
}, [
|
|
476
480
|
client
|
|
@@ -479,16 +483,16 @@ const $c9c034ed42105250$export$adf3c939ee6f7493 = ()=>{
|
|
|
479
483
|
const dest = email || _email;
|
|
480
484
|
if (!dest) throw new Error("Must `sendCode` with a valid email before calling `linkWithCode`");
|
|
481
485
|
try {
|
|
482
|
-
|
|
486
|
+
setOtpState({
|
|
483
487
|
status: "submitting-code"
|
|
484
488
|
});
|
|
485
489
|
const res = await client.auth.email.linkWithCode(dest, code);
|
|
486
|
-
|
|
490
|
+
setOtpState({
|
|
487
491
|
status: "done"
|
|
488
492
|
});
|
|
489
493
|
return res;
|
|
490
494
|
} catch (error) {
|
|
491
|
-
|
|
495
|
+
setOtpState((0, $124a96fd11dcd394$export$5a99dcfc36d582cc)(error));
|
|
492
496
|
}
|
|
493
497
|
}, [
|
|
494
498
|
client,
|
|
@@ -497,7 +501,7 @@ const $c9c034ed42105250$export$adf3c939ee6f7493 = ()=>{
|
|
|
497
501
|
return {
|
|
498
502
|
sendCode: sendCode,
|
|
499
503
|
linkWithCode: linkWithCode,
|
|
500
|
-
state:
|
|
504
|
+
state: otpState
|
|
501
505
|
};
|
|
502
506
|
};
|
|
503
507
|
|
|
@@ -506,23 +510,20 @@ const $c9c034ed42105250$export$adf3c939ee6f7493 = ()=>{
|
|
|
506
510
|
|
|
507
511
|
|
|
508
512
|
const $9d97888350f64cf1$export$bee5fe3d09aee7c2 = ()=>{
|
|
509
|
-
const client = (0, $f5b7b0e486222817$export$9f1f355652e8b9cb)();
|
|
510
513
|
const [_phone, setPhone] = (0, $gsnqM$useState)("");
|
|
511
|
-
const
|
|
512
|
-
status: "initial"
|
|
513
|
-
});
|
|
514
|
+
const { client: client, otpState: otpState, setOtpState: setOtpState } = (0, $gsnqM$useContext)((0, $b50fc71d7f94fd16$export$d9ac34284a76b7d1));
|
|
514
515
|
const sendCode = (0, $gsnqM$useCallback)(async ({ phone: phone })=>{
|
|
515
516
|
setPhone(phone);
|
|
516
517
|
try {
|
|
517
|
-
|
|
518
|
+
setOtpState({
|
|
518
519
|
status: "sending-code"
|
|
519
520
|
});
|
|
520
521
|
await client.auth.phone.sendCode(phone);
|
|
521
|
-
|
|
522
|
+
setOtpState({
|
|
522
523
|
status: "awaiting-code-input"
|
|
523
524
|
});
|
|
524
525
|
} catch (error) {
|
|
525
|
-
|
|
526
|
+
setOtpState((0, $124a96fd11dcd394$export$5a99dcfc36d582cc)(error));
|
|
526
527
|
}
|
|
527
528
|
}, [
|
|
528
529
|
client
|
|
@@ -531,16 +532,16 @@ const $9d97888350f64cf1$export$bee5fe3d09aee7c2 = ()=>{
|
|
|
531
532
|
const dest = phone || _phone;
|
|
532
533
|
if (!dest) throw new Error("Must `sendCode` with a valid phone number before calling `loginWithCode`");
|
|
533
534
|
try {
|
|
534
|
-
|
|
535
|
+
setOtpState({
|
|
535
536
|
status: "submitting-code"
|
|
536
537
|
});
|
|
537
538
|
const res = await client.auth.phone.loginWithCode(phone || _phone, code);
|
|
538
|
-
|
|
539
|
+
setOtpState({
|
|
539
540
|
status: "done"
|
|
540
541
|
});
|
|
541
542
|
return res;
|
|
542
543
|
} catch (error) {
|
|
543
|
-
|
|
544
|
+
setOtpState((0, $124a96fd11dcd394$export$5a99dcfc36d582cc)(error));
|
|
544
545
|
}
|
|
545
546
|
}, [
|
|
546
547
|
client,
|
|
@@ -549,7 +550,7 @@ const $9d97888350f64cf1$export$bee5fe3d09aee7c2 = ()=>{
|
|
|
549
550
|
return {
|
|
550
551
|
sendCode: sendCode,
|
|
551
552
|
loginWithCode: loginWithCode,
|
|
552
|
-
state:
|
|
553
|
+
state: otpState
|
|
553
554
|
};
|
|
554
555
|
};
|
|
555
556
|
|
|
@@ -558,23 +559,20 @@ const $9d97888350f64cf1$export$bee5fe3d09aee7c2 = ()=>{
|
|
|
558
559
|
|
|
559
560
|
|
|
560
561
|
const $4bbe53962e284753$export$2b5393df0050a256 = ()=>{
|
|
561
|
-
const client = (0, $f5b7b0e486222817$export$9f1f355652e8b9cb)();
|
|
562
562
|
const [_phone, setPhone] = (0, $gsnqM$useState)("");
|
|
563
|
-
const
|
|
564
|
-
status: "initial"
|
|
565
|
-
});
|
|
563
|
+
const { client: client, otpState: otpState, setOtpState: setOtpState } = (0, $gsnqM$useContext)((0, $b50fc71d7f94fd16$export$d9ac34284a76b7d1));
|
|
566
564
|
const sendCode = (0, $gsnqM$useCallback)(async ({ phone: phone })=>{
|
|
567
565
|
setPhone(phone);
|
|
568
566
|
try {
|
|
569
|
-
|
|
567
|
+
setOtpState({
|
|
570
568
|
status: "sending-code"
|
|
571
569
|
});
|
|
572
570
|
await client.auth.phone.sendCode(phone);
|
|
573
|
-
|
|
571
|
+
setOtpState({
|
|
574
572
|
status: "awaiting-code-input"
|
|
575
573
|
});
|
|
576
574
|
} catch (error) {
|
|
577
|
-
|
|
575
|
+
setOtpState((0, $124a96fd11dcd394$export$5a99dcfc36d582cc)(error));
|
|
578
576
|
}
|
|
579
577
|
}, [
|
|
580
578
|
client
|
|
@@ -583,16 +581,16 @@ const $4bbe53962e284753$export$2b5393df0050a256 = ()=>{
|
|
|
583
581
|
const dest = phone || _phone;
|
|
584
582
|
if (!dest) throw new Error("Must `sendCode` with a valid phone number before calling `linkWithCode`");
|
|
585
583
|
try {
|
|
586
|
-
|
|
584
|
+
setOtpState({
|
|
587
585
|
status: "submitting-code"
|
|
588
586
|
});
|
|
589
587
|
const res = await client.auth.phone.linkWithCode(phone || _phone, code);
|
|
590
|
-
|
|
588
|
+
setOtpState({
|
|
591
589
|
status: "done"
|
|
592
590
|
});
|
|
593
591
|
return res;
|
|
594
592
|
} catch (error) {
|
|
595
|
-
|
|
593
|
+
setOtpState((0, $124a96fd11dcd394$export$5a99dcfc36d582cc)(error));
|
|
596
594
|
}
|
|
597
595
|
}, [
|
|
598
596
|
client,
|
|
@@ -601,7 +599,7 @@ const $4bbe53962e284753$export$2b5393df0050a256 = ()=>{
|
|
|
601
599
|
return {
|
|
602
600
|
sendCode: sendCode,
|
|
603
601
|
linkWithCode: linkWithCode,
|
|
604
|
-
state:
|
|
602
|
+
state: otpState
|
|
605
603
|
};
|
|
606
604
|
};
|
|
607
605
|
|
|
@@ -616,6 +614,13 @@ const $49439d8bd8a2399b$export$7cb4baffef0102f = ()=>{
|
|
|
616
614
|
|
|
617
615
|
|
|
618
616
|
|
|
617
|
+
const $f5b7b0e486222817$export$9f1f355652e8b9cb = ()=>{
|
|
618
|
+
const { client: client } = (0, $gsnqM$useContext)((0, $b50fc71d7f94fd16$export$d9ac34284a76b7d1));
|
|
619
|
+
return client;
|
|
620
|
+
};
|
|
621
|
+
|
|
622
|
+
|
|
623
|
+
|
|
619
624
|
|
|
620
625
|
const $ed23cea2d2e0a913$export$9c33552016a926e5 = ()=>{
|
|
621
626
|
const { user: user, isReady: isReady, client: client } = (0, $gsnqM$useContext)((0, $b50fc71d7f94fd16$export$d9ac34284a76b7d1));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@privy-io/expo",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2-beta-20231024142926",
|
|
4
4
|
"description": "Expo client for the Privy Auth API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"authentication",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"build": "npx parcel build --no-cache",
|
|
45
45
|
"clean": "rm -rf dist .turbo",
|
|
46
46
|
"prepublishOnly": "npm run clean && npm run build",
|
|
47
|
-
"dev": "npx parcel watch",
|
|
47
|
+
"dev": "npx parcel watch -p 4234",
|
|
48
48
|
"test": "jest --testMatch \"**/test/unit/**/*.test.ts\"",
|
|
49
49
|
"test:ci": "npm run test",
|
|
50
50
|
"test-integration": "jest --testMatch \"**/test/integration/**/*.test.ts\"",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"expo-secure-store": "*"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@privy-io/js-sdk-core": "
|
|
62
|
+
"@privy-io/js-sdk-core": "0.6.1-beta-20231024142926",
|
|
63
63
|
"react-fast-compare": "^3.2.2"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|