@mysten/enoki 0.12.15 → 1.0.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/CHANGELOG.md +41 -2
- package/README.md +76 -0
- package/dist/EnokiClient/index.d.mts +41 -0
- package/dist/EnokiClient/index.d.mts.map +1 -0
- package/dist/EnokiClient/index.mjs +136 -0
- package/dist/EnokiClient/index.mjs.map +1 -0
- package/dist/EnokiClient/type.d.mts +119 -0
- package/dist/EnokiClient/type.d.mts.map +1 -0
- package/dist/EnokiFlow.d.mts +103 -0
- package/dist/EnokiFlow.d.mts.map +1 -0
- package/dist/EnokiFlow.mjs +205 -0
- package/dist/EnokiFlow.mjs.map +1 -0
- package/dist/EnokiKeypair.d.mts +23 -0
- package/dist/EnokiKeypair.d.mts.map +1 -0
- package/dist/EnokiKeypair.mjs +53 -0
- package/dist/EnokiKeypair.mjs.map +1 -0
- package/dist/encryption.d.mts +15 -0
- package/dist/encryption.d.mts.map +1 -0
- package/dist/encryption.mjs +53 -0
- package/dist/encryption.mjs.map +1 -0
- package/dist/index.d.mts +13 -0
- package/dist/index.mjs +11 -0
- package/dist/react.d.mts +28 -0
- package/dist/react.d.mts.map +1 -0
- package/dist/react.mjs +61 -0
- package/dist/react.mjs.map +1 -0
- package/dist/stores.d.mts +25 -0
- package/dist/stores.d.mts.map +1 -0
- package/dist/stores.mjs +56 -0
- package/dist/stores.mjs.map +1 -0
- package/dist/utils.d.mts +7 -0
- package/dist/utils.d.mts.map +1 -0
- package/dist/utils.mjs +8 -0
- package/dist/utils.mjs.map +1 -0
- package/dist/wallet/features.d.mts +55 -0
- package/dist/wallet/features.d.mts.map +1 -0
- package/dist/wallet/features.mjs +9 -0
- package/dist/wallet/features.mjs.map +1 -0
- package/dist/wallet/initializer.d.mts +19 -0
- package/dist/wallet/initializer.d.mts.map +1 -0
- package/dist/wallet/initializer.mjs +20 -0
- package/dist/wallet/initializer.mjs.map +1 -0
- package/dist/wallet/providers.mjs +32 -0
- package/dist/wallet/providers.mjs.map +1 -0
- package/dist/wallet/register.d.mts +16 -0
- package/dist/wallet/register.d.mts.map +1 -0
- package/dist/wallet/register.mjs +43 -0
- package/dist/wallet/register.mjs.map +1 -0
- package/dist/wallet/state.mjs +101 -0
- package/dist/wallet/state.mjs.map +1 -0
- package/dist/wallet/types.d.mts +72 -0
- package/dist/wallet/types.d.mts.map +1 -0
- package/dist/wallet/utils.d.mts +16 -0
- package/dist/wallet/utils.d.mts.map +1 -0
- package/dist/wallet/utils.mjs +44 -0
- package/dist/wallet/utils.mjs.map +1 -0
- package/dist/wallet/wallet.d.mts +33 -0
- package/dist/wallet/wallet.d.mts.map +1 -0
- package/dist/wallet/wallet.mjs +345 -0
- package/dist/wallet/wallet.mjs.map +1 -0
- package/package.json +27 -29
- package/dist/cjs/EnokiClient/index.d.ts +0 -34
- package/dist/cjs/EnokiClient/index.js +0 -193
- package/dist/cjs/EnokiClient/index.js.map +0 -7
- package/dist/cjs/EnokiClient/type.d.ts +0 -119
- package/dist/cjs/EnokiClient/type.js +0 -17
- package/dist/cjs/EnokiClient/type.js.map +0 -7
- package/dist/cjs/EnokiFlow.d.ts +0 -74
- package/dist/cjs/EnokiFlow.js +0 -278
- package/dist/cjs/EnokiFlow.js.map +0 -7
- package/dist/cjs/EnokiKeypair.d.ts +0 -20
- package/dist/cjs/EnokiKeypair.js +0 -87
- package/dist/cjs/EnokiKeypair.js.map +0 -7
- package/dist/cjs/encryption.d.ts +0 -15
- package/dist/cjs/encryption.js +0 -96
- package/dist/cjs/encryption.js.map +0 -7
- package/dist/cjs/index.d.ts +0 -12
- package/dist/cjs/index.js +0 -50
- package/dist/cjs/index.js.map +0 -7
- package/dist/cjs/package.json +0 -4
- package/dist/cjs/react.d.ts +0 -20
- package/dist/cjs/react.js +0 -76
- package/dist/cjs/react.js.map +0 -7
- package/dist/cjs/stores.d.ts +0 -21
- package/dist/cjs/stores.js +0 -67
- package/dist/cjs/stores.js.map +0 -7
- package/dist/cjs/utils.d.ts +0 -2
- package/dist/cjs/utils.js +0 -27
- package/dist/cjs/utils.js.map +0 -7
- package/dist/cjs/wallet/features.d.ts +0 -50
- package/dist/cjs/wallet/features.js +0 -27
- package/dist/cjs/wallet/features.js.map +0 -7
- package/dist/cjs/wallet/initializer.d.ts +0 -11
- package/dist/cjs/wallet/initializer.js +0 -41
- package/dist/cjs/wallet/initializer.js.map +0 -7
- package/dist/cjs/wallet/providers.d.ts +0 -7
- package/dist/cjs/wallet/providers.js +0 -51
- package/dist/cjs/wallet/providers.js.map +0 -7
- package/dist/cjs/wallet/register.d.ts +0 -7
- package/dist/cjs/wallet/register.js +0 -67
- package/dist/cjs/wallet/register.js.map +0 -7
- package/dist/cjs/wallet/state.d.ts +0 -18
- package/dist/cjs/wallet/state.js +0 -142
- package/dist/cjs/wallet/state.js.map +0 -7
- package/dist/cjs/wallet/types.d.ts +0 -82
- package/dist/cjs/wallet/types.js +0 -17
- package/dist/cjs/wallet/types.js.map +0 -7
- package/dist/cjs/wallet/utils.d.ts +0 -11
- package/dist/cjs/wallet/utils.js +0 -83
- package/dist/cjs/wallet/utils.js.map +0 -7
- package/dist/cjs/wallet/wallet.d.ts +0 -16
- package/dist/cjs/wallet/wallet.js +0 -465
- package/dist/cjs/wallet/wallet.js.map +0 -7
- package/dist/esm/EnokiClient/index.d.ts +0 -34
- package/dist/esm/EnokiClient/index.js +0 -173
- package/dist/esm/EnokiClient/index.js.map +0 -7
- package/dist/esm/EnokiClient/type.d.ts +0 -119
- package/dist/esm/EnokiClient/type.js +0 -1
- package/dist/esm/EnokiClient/type.js.map +0 -7
- package/dist/esm/EnokiFlow.d.ts +0 -74
- package/dist/esm/EnokiFlow.js +0 -258
- package/dist/esm/EnokiFlow.js.map +0 -7
- package/dist/esm/EnokiKeypair.d.ts +0 -20
- package/dist/esm/EnokiKeypair.js +0 -67
- package/dist/esm/EnokiKeypair.js.map +0 -7
- package/dist/esm/encryption.d.ts +0 -15
- package/dist/esm/encryption.js +0 -76
- package/dist/esm/encryption.js.map +0 -7
- package/dist/esm/index.d.ts +0 -12
- package/dist/esm/index.js +0 -41
- package/dist/esm/index.js.map +0 -7
- package/dist/esm/package.json +0 -4
- package/dist/esm/react.d.ts +0 -20
- package/dist/esm/react.js +0 -56
- package/dist/esm/react.js.map +0 -7
- package/dist/esm/stores.d.ts +0 -21
- package/dist/esm/stores.js +0 -47
- package/dist/esm/stores.js.map +0 -7
- package/dist/esm/utils.d.ts +0 -2
- package/dist/esm/utils.js +0 -7
- package/dist/esm/utils.js.map +0 -7
- package/dist/esm/wallet/features.d.ts +0 -50
- package/dist/esm/wallet/features.js +0 -7
- package/dist/esm/wallet/features.js.map +0 -7
- package/dist/esm/wallet/initializer.d.ts +0 -11
- package/dist/esm/wallet/initializer.js +0 -21
- package/dist/esm/wallet/initializer.js.map +0 -7
- package/dist/esm/wallet/providers.d.ts +0 -7
- package/dist/esm/wallet/providers.js +0 -31
- package/dist/esm/wallet/providers.js.map +0 -7
- package/dist/esm/wallet/register.d.ts +0 -7
- package/dist/esm/wallet/register.js +0 -47
- package/dist/esm/wallet/register.js.map +0 -7
- package/dist/esm/wallet/state.d.ts +0 -18
- package/dist/esm/wallet/state.js +0 -122
- package/dist/esm/wallet/state.js.map +0 -7
- package/dist/esm/wallet/types.d.ts +0 -82
- package/dist/esm/wallet/types.js +0 -1
- package/dist/esm/wallet/types.js.map +0 -7
- package/dist/esm/wallet/utils.d.ts +0 -11
- package/dist/esm/wallet/utils.js +0 -63
- package/dist/esm/wallet/utils.js.map +0 -7
- package/dist/esm/wallet/wallet.d.ts +0 -16
- package/dist/esm/wallet/wallet.js +0 -443
- package/dist/esm/wallet/wallet.js.map +0 -7
- package/dist/tsconfig.esm.tsbuildinfo +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/react/package.json +0 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,44 @@
|
|
|
1
1
|
# @mysten/enoki
|
|
2
2
|
|
|
3
|
+
## 1.0.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- e00788c: Update to use SuiJsonRpcClient instead of SuiClient
|
|
8
|
+
|
|
9
|
+
Updated all type signatures, internal usages, examples, and documentation to use
|
|
10
|
+
`SuiJsonRpcClient` from `@mysten/sui/jsonRpc` instead of the deprecated `SuiClient` from
|
|
11
|
+
`@mysten/sui/client`.
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [e00788c]
|
|
16
|
+
- Updated dependencies [e00788c]
|
|
17
|
+
- Updated dependencies [e00788c]
|
|
18
|
+
- Updated dependencies [e00788c]
|
|
19
|
+
- Updated dependencies [e00788c]
|
|
20
|
+
- Updated dependencies [e00788c]
|
|
21
|
+
- Updated dependencies [e00788c]
|
|
22
|
+
- Updated dependencies [e00788c]
|
|
23
|
+
- Updated dependencies [e00788c]
|
|
24
|
+
- Updated dependencies [e00788c]
|
|
25
|
+
- Updated dependencies [e00788c]
|
|
26
|
+
- Updated dependencies [e00788c]
|
|
27
|
+
- Updated dependencies [e00788c]
|
|
28
|
+
- Updated dependencies [e00788c]
|
|
29
|
+
- Updated dependencies [e00788c]
|
|
30
|
+
- Updated dependencies [e00788c]
|
|
31
|
+
- Updated dependencies [e00788c]
|
|
32
|
+
- @mysten/signers@1.0.0
|
|
33
|
+
- @mysten/sui@2.0.0
|
|
34
|
+
- @mysten/wallet-standard@0.20.0
|
|
35
|
+
|
|
36
|
+
## 0.13.0
|
|
37
|
+
|
|
38
|
+
### Minor Changes
|
|
39
|
+
|
|
40
|
+
- 95c02d8: Add `additionalEpochs` as part of the configuration to generate zkLogin nonce
|
|
41
|
+
|
|
3
42
|
## 0.12.15
|
|
4
43
|
|
|
5
44
|
### Patch Changes
|
|
@@ -913,8 +952,8 @@
|
|
|
913
952
|
|
|
914
953
|
- a92b03de42: The Typescript SDK has been renamed to `@mysten/sui` and includes many new features
|
|
915
954
|
and breaking changes. See the
|
|
916
|
-
[full migration guide](https://sdk.mystenlabs.com/
|
|
917
|
-
|
|
955
|
+
[full migration guide](https://sdk.mystenlabs.com/sui/migrations/sui-1.0) for details on how to
|
|
956
|
+
upgrade.
|
|
918
957
|
|
|
919
958
|
### Patch Changes
|
|
920
959
|
|
package/README.md
CHANGED
|
@@ -1 +1,77 @@
|
|
|
1
1
|
# `@mysten/enoki`
|
|
2
|
+
|
|
3
|
+
zkLogin authentication and sponsored transactions. Enable users to sign in with Google, Twitch,
|
|
4
|
+
Facebook, and other OAuth providers, and execute transactions without gas fees.
|
|
5
|
+
|
|
6
|
+
## Features
|
|
7
|
+
|
|
8
|
+
- **zkLogin**: Authenticate users with OAuth providers (Google, Twitch, Facebook)
|
|
9
|
+
- **Sponsored Transactions**: Execute transactions without requiring users to hold gas
|
|
10
|
+
- **Wallet Integration**: Register Enoki wallets with dApp Kit
|
|
11
|
+
- **Subname Management**: Create and manage SuiNS subnames
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
npm install @mysten/enoki
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Quick Start
|
|
20
|
+
|
|
21
|
+
### Register Enoki wallets
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
import { registerEnokiWallets } from '@mysten/enoki';
|
|
25
|
+
|
|
26
|
+
registerEnokiWallets({
|
|
27
|
+
apiKey: 'your-enoki-api-key',
|
|
28
|
+
providers: ['google', 'twitch', 'facebook'],
|
|
29
|
+
});
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Use with React and dApp Kit
|
|
33
|
+
|
|
34
|
+
```tsx
|
|
35
|
+
import { registerEnokiWallets } from '@mysten/enoki';
|
|
36
|
+
import { useEnokiFlow } from '@mysten/enoki/react';
|
|
37
|
+
|
|
38
|
+
// In your app setup
|
|
39
|
+
registerEnokiWallets({
|
|
40
|
+
apiKey: 'your-enoki-api-key',
|
|
41
|
+
providers: ['google'],
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// In your component
|
|
45
|
+
function LoginButton() {
|
|
46
|
+
const { login } = useEnokiFlow();
|
|
47
|
+
|
|
48
|
+
return <button onClick={() => login('google')}>Sign in with Google</button>;
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Low-level client usage
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
import { EnokiClient } from '@mysten/enoki';
|
|
56
|
+
|
|
57
|
+
const client = new EnokiClient({
|
|
58
|
+
apiKey: 'your-enoki-api-key',
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// Create a sponsored transaction
|
|
62
|
+
const sponsored = await client.createSponsoredTransaction({
|
|
63
|
+
network: 'mainnet',
|
|
64
|
+
sender: '0x...',
|
|
65
|
+
transactionKindBytes: '...',
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// Execute it
|
|
69
|
+
await client.executeSponsoredTransaction({
|
|
70
|
+
digest: sponsored.digest,
|
|
71
|
+
signature: '...',
|
|
72
|
+
});
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Documentation
|
|
76
|
+
|
|
77
|
+
See the [Enoki documentation](https://docs.enoki.mystenlabs.com) for detailed setup and usage.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { CreateSponsoredTransactionApiInput, CreateSponsoredTransactionApiResponse, CreateSubnameApiInput, CreateSubnameApiResponse, CreateZkLoginNonceApiInput, CreateZkLoginNonceApiResponse, CreateZkLoginZkpApiInput, CreateZkLoginZkpApiResponse, DeleteSubnameApiInput, ExecuteSponsoredTransactionApiInput, ExecuteSponsoredTransactionApiResponse, GetAppApiInput, GetAppApiResponse, GetSubnamesApiInput, GetSubnamesApiResponse, GetZkLoginAddressesApiInput, GetZkLoginAddressesApiResponse, GetZkLoginApiInput, GetZkLoginApiResponse } from "./type.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/EnokiClient/index.d.ts
|
|
4
|
+
interface EnokiClientConfig {
|
|
5
|
+
/** The API key for the Enoki app, available in the Enoki Portal. */
|
|
6
|
+
apiKey: string;
|
|
7
|
+
/** The API URL for Enoki. In most cases, this should not be set. */
|
|
8
|
+
apiUrl?: string;
|
|
9
|
+
/** The amount of epochs that you would like to have the nonce be valid for. Range: `0 <= value <= 30` */
|
|
10
|
+
additionalEpochs?: number;
|
|
11
|
+
}
|
|
12
|
+
declare class EnokiClientError extends Error {
|
|
13
|
+
errors: {
|
|
14
|
+
code: string;
|
|
15
|
+
message: string;
|
|
16
|
+
data: unknown;
|
|
17
|
+
}[];
|
|
18
|
+
status: number;
|
|
19
|
+
code: string;
|
|
20
|
+
constructor(status: number, response: string);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A low-level client for interacting with the Enoki API.
|
|
24
|
+
*/
|
|
25
|
+
declare class EnokiClient {
|
|
26
|
+
#private;
|
|
27
|
+
constructor(config: EnokiClientConfig);
|
|
28
|
+
getApp(_input?: GetAppApiInput): Promise<GetAppApiResponse>;
|
|
29
|
+
getZkLogin(input: GetZkLoginApiInput): Promise<GetZkLoginApiResponse>;
|
|
30
|
+
getZkLoginAddresses(input: GetZkLoginAddressesApiInput): Promise<GetZkLoginAddressesApiResponse>;
|
|
31
|
+
createZkLoginNonce(input: CreateZkLoginNonceApiInput): Promise<CreateZkLoginNonceApiResponse>;
|
|
32
|
+
createZkLoginZkp(input: CreateZkLoginZkpApiInput): Promise<CreateZkLoginZkpApiResponse>;
|
|
33
|
+
createSponsoredTransaction(input: CreateSponsoredTransactionApiInput): Promise<CreateSponsoredTransactionApiResponse>;
|
|
34
|
+
executeSponsoredTransaction(input: ExecuteSponsoredTransactionApiInput): Promise<ExecuteSponsoredTransactionApiResponse>;
|
|
35
|
+
getSubnames(input: GetSubnamesApiInput): Promise<GetSubnamesApiResponse>;
|
|
36
|
+
createSubname(input: CreateSubnameApiInput): Promise<CreateSubnameApiResponse>;
|
|
37
|
+
deleteSubname(input: DeleteSubnameApiInput): void;
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
export { EnokiClient, EnokiClientConfig, EnokiClientError };
|
|
41
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/EnokiClient/index.ts"],"sourcesContent":[],"mappings":";;;UA6BiB,iBAAA;;EAAA,MAAA,EAAA,MAAA;EAWJ;EA6BA,MAAA,CAAA,EAAA,MAAW;EAMH;EAOJ,gBAAA,CAAA,EAAA,MAAA;;AAAc,cA1ClB,gBAAA,SAAyB,KAAA,CA0CP;EAMZ,MAAA,EAAA;IAAkB,IAAA,EAAA,MAAA;IAAA,OAAA,EAAA,MAAA;IAST,IAAA,EAAA,OAAA;EAA2B,CAAA,EAAA;EAAA,MAAA,EAAA,MAAA;EAS5B,IAAA,EAAA,MAAA;EAA0B,WAAA,CAAA,MAAA,EAAA,MAAA,EAAA,QAAA,EAAA,MAAA;;;;;AA0BlB,cA/DtB,WAAA,CA+DsB;EAAkC,CAAA,OAAA;EAAA,WAAA,CAAA,MAAA,EAzDhD,iBAyDgD;EAkBjC,MAAA,CAAA,MAAA,CAAA,EApEnB,cAoEmB,CAAA,EApEL,OAoEK,CApEL,iBAoEK,CAAA;EAAmC,UAAA,CAAA,KAAA,EA9DpD,kBA8DoD,CAAA,EA9DlC,OA8DkC,CA9DlC,qBA8DkC,CAAA;EAAA,mBAAA,CAAA,KAAA,EArD3C,2BAqD2C,CAAA,EArDhB,OAqDgB,CArDhB,8BAqDgB,CAAA;EAYnD,kBAAA,CAAA,KAAA,EAxDO,0BAwDP,CAAA,EAxDiC,OAwDjC,CAxDiC,6BAwDjC,CAAA;EAAmB,gBAAA,CAAA,KAAA,EA7Cd,wBA6Cc,CAAA,EA7CU,OA6CV,CA7CU,2BA6CV,CAAA;EAAA,0BAAA,CAAA,KAAA,EA9BJ,kCA8BI,CAAA,EA9B8B,OA8B9B,CA9B8B,qCA8B9B,CAAA;EAmBjB,2BAAA,CAAA,KAAA,EA/Bc,mCA+Bd,CAAA,EA/BiD,OA+BjD,CA/BiD,sCA+BjD,CAAA;EAAqB,WAAA,CAAA,KAAA,EAnBvB,mBAmBuB,CAAA,EAnBJ,OAmBI,CAnBJ,sBAmBI,CAAA;EAAA,aAAA,CAAA,KAAA,EAArB,qBAAqB,CAAA,EAAA,OAAA,CAAA,wBAAA,CAAA;EAiBrB,aAAA,CAAA,KAAA,EAAA,qBAAA,CAAA,EAAA,IAAA"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
//#region src/EnokiClient/index.ts
|
|
2
|
+
const DEFAULT_API_URL = "https://api.enoki.mystenlabs.com";
|
|
3
|
+
const ZKLOGIN_HEADER = "zklogin-jwt";
|
|
4
|
+
var EnokiClientError = class extends Error {
|
|
5
|
+
constructor(status, response) {
|
|
6
|
+
let errors;
|
|
7
|
+
try {
|
|
8
|
+
errors = JSON.parse(response).errors;
|
|
9
|
+
} catch {}
|
|
10
|
+
const cause = errors?.[0] ? new Error(errors[0].message) : void 0;
|
|
11
|
+
super(`Request to Enoki API failed (status: ${status})`, { cause });
|
|
12
|
+
this.errors = [];
|
|
13
|
+
this.errors = errors ?? [];
|
|
14
|
+
this.name = "EnokiClientError";
|
|
15
|
+
this.status = status;
|
|
16
|
+
this.code = errors?.[0]?.code ?? "unknown_error";
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* A low-level client for interacting with the Enoki API.
|
|
21
|
+
*/
|
|
22
|
+
var EnokiClient = class {
|
|
23
|
+
#version;
|
|
24
|
+
#apiUrl;
|
|
25
|
+
#apiKey;
|
|
26
|
+
#additionalEpochs;
|
|
27
|
+
constructor(config) {
|
|
28
|
+
this.#version = "v1";
|
|
29
|
+
this.#apiUrl = config.apiUrl ?? DEFAULT_API_URL;
|
|
30
|
+
this.#apiKey = config.apiKey;
|
|
31
|
+
this.#additionalEpochs = config.additionalEpochs;
|
|
32
|
+
}
|
|
33
|
+
getApp(_input) {
|
|
34
|
+
return this.#fetch("app", { method: "GET" });
|
|
35
|
+
}
|
|
36
|
+
getZkLogin(input) {
|
|
37
|
+
return this.#fetch("zklogin", {
|
|
38
|
+
method: "GET",
|
|
39
|
+
headers: { [ZKLOGIN_HEADER]: input.jwt }
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
getZkLoginAddresses(input) {
|
|
43
|
+
return this.#fetch("zklogin/addresses", {
|
|
44
|
+
method: "GET",
|
|
45
|
+
headers: { [ZKLOGIN_HEADER]: input.jwt }
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
createZkLoginNonce(input) {
|
|
49
|
+
return this.#fetch("zklogin/nonce", {
|
|
50
|
+
method: "POST",
|
|
51
|
+
body: JSON.stringify({
|
|
52
|
+
network: input.network,
|
|
53
|
+
ephemeralPublicKey: input.ephemeralPublicKey.toSuiPublicKey(),
|
|
54
|
+
additionalEpochs: input.additionalEpochs ?? this.#additionalEpochs
|
|
55
|
+
})
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
createZkLoginZkp(input) {
|
|
59
|
+
return this.#fetch("zklogin/zkp", {
|
|
60
|
+
method: "POST",
|
|
61
|
+
headers: { [ZKLOGIN_HEADER]: input.jwt },
|
|
62
|
+
body: JSON.stringify({
|
|
63
|
+
network: input.network,
|
|
64
|
+
ephemeralPublicKey: input.ephemeralPublicKey.toSuiPublicKey(),
|
|
65
|
+
maxEpoch: input.maxEpoch,
|
|
66
|
+
randomness: input.randomness
|
|
67
|
+
})
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
createSponsoredTransaction(input) {
|
|
71
|
+
return this.#fetch("transaction-blocks/sponsor", {
|
|
72
|
+
method: "POST",
|
|
73
|
+
headers: input.jwt ? { [ZKLOGIN_HEADER]: input.jwt } : {},
|
|
74
|
+
body: JSON.stringify({
|
|
75
|
+
sender: input.sender,
|
|
76
|
+
network: input.network,
|
|
77
|
+
transactionBlockKindBytes: input.transactionKindBytes,
|
|
78
|
+
allowedAddresses: input.allowedAddresses,
|
|
79
|
+
allowedMoveCallTargets: input.allowedMoveCallTargets
|
|
80
|
+
})
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
executeSponsoredTransaction(input) {
|
|
84
|
+
return this.#fetch(`transaction-blocks/sponsor/${input.digest}`, {
|
|
85
|
+
method: "POST",
|
|
86
|
+
body: JSON.stringify({ signature: input.signature })
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
getSubnames(input) {
|
|
90
|
+
const query = new URLSearchParams();
|
|
91
|
+
if (input.address) query.set("address", input.address);
|
|
92
|
+
if (input.network) query.set("network", input.network);
|
|
93
|
+
if (input.domain) query.set("domain", input.domain);
|
|
94
|
+
return this.#fetch("subnames" + (query.size > 0 ? `?${query.toString()}` : ""), { method: "GET" });
|
|
95
|
+
}
|
|
96
|
+
createSubname(input) {
|
|
97
|
+
return this.#fetch("subnames", {
|
|
98
|
+
method: "POST",
|
|
99
|
+
headers: input.jwt ? { [ZKLOGIN_HEADER]: input.jwt } : {},
|
|
100
|
+
body: JSON.stringify({
|
|
101
|
+
network: input.network,
|
|
102
|
+
domain: input.domain,
|
|
103
|
+
subname: input.subname,
|
|
104
|
+
targetAddress: input.targetAddress
|
|
105
|
+
})
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
deleteSubname(input) {
|
|
109
|
+
this.#fetch("subnames", {
|
|
110
|
+
method: "DELETE",
|
|
111
|
+
body: JSON.stringify({
|
|
112
|
+
network: input.network,
|
|
113
|
+
domain: input.domain,
|
|
114
|
+
subname: input.subname
|
|
115
|
+
})
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
async #fetch(path, init) {
|
|
119
|
+
const res = await fetch(`${this.#apiUrl}/${this.#version}/${path}`, {
|
|
120
|
+
...init,
|
|
121
|
+
headers: {
|
|
122
|
+
...init.headers,
|
|
123
|
+
Authorization: `Bearer ${this.#apiKey}`,
|
|
124
|
+
"Content-Type": "application/json",
|
|
125
|
+
"Request-Id": crypto.randomUUID()
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
if (!res.ok) throw new EnokiClientError(res.status, await res.text());
|
|
129
|
+
const { data } = await res.json();
|
|
130
|
+
return data;
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
//#endregion
|
|
135
|
+
export { EnokiClient, EnokiClientError };
|
|
136
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["#version","#apiUrl","#apiKey","#additionalEpochs","#fetch"],"sources":["../../src/EnokiClient/index.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type {\n\tCreateSponsoredTransactionApiInput,\n\tCreateSponsoredTransactionApiResponse,\n\tCreateSubnameApiInput,\n\tCreateSubnameApiResponse,\n\tCreateZkLoginNonceApiInput,\n\tCreateZkLoginNonceApiResponse,\n\tCreateZkLoginZkpApiInput,\n\tCreateZkLoginZkpApiResponse,\n\tDeleteSubnameApiInput,\n\tDeleteSubnameApiResponse,\n\tExecuteSponsoredTransactionApiInput,\n\tExecuteSponsoredTransactionApiResponse,\n\tGetAppApiInput,\n\tGetAppApiResponse,\n\tGetSubnamesApiInput,\n\tGetSubnamesApiResponse,\n\tGetZkLoginAddressesApiInput,\n\tGetZkLoginAddressesApiResponse,\n\tGetZkLoginApiInput,\n\tGetZkLoginApiResponse,\n} from './type.js';\n\nconst DEFAULT_API_URL = 'https://api.enoki.mystenlabs.com';\nconst ZKLOGIN_HEADER = 'zklogin-jwt';\n\nexport interface EnokiClientConfig {\n\t/** The API key for the Enoki app, available in the Enoki Portal. */\n\tapiKey: string;\n\n\t/** The API URL for Enoki. In most cases, this should not be set. */\n\tapiUrl?: string;\n\n\t/** The amount of epochs that you would like to have the nonce be valid for. Range: `0 <= value <= 30` */\n\tadditionalEpochs?: number;\n}\n\nexport class EnokiClientError extends Error {\n\terrors: { code: string; message: string; data: unknown }[] = [];\n\tstatus: number;\n\tcode: string;\n\n\tconstructor(status: number, response: string) {\n\t\tlet errors;\n\t\ttry {\n\t\t\tconst parsedResponse = JSON.parse(response) as {\n\t\t\t\terrors: { code: string; message: string; data: unknown }[];\n\t\t\t};\n\t\t\terrors = parsedResponse.errors;\n\t\t} catch {\n\t\t\t// Ignore\n\t\t}\n\t\tconst cause = errors?.[0] ? new Error(errors[0].message) : undefined;\n\t\tsuper(`Request to Enoki API failed (status: ${status})`, {\n\t\t\tcause,\n\t\t});\n\t\tthis.errors = errors ?? [];\n\t\tthis.name = 'EnokiClientError';\n\t\tthis.status = status;\n\t\tthis.code = errors?.[0]?.code ?? 'unknown_error';\n\t}\n}\n\n/**\n * A low-level client for interacting with the Enoki API.\n */\nexport class EnokiClient {\n\t#version: string;\n\t#apiUrl: string;\n\t#apiKey: string;\n\t#additionalEpochs: number | undefined;\n\n\tconstructor(config: EnokiClientConfig) {\n\t\tthis.#version = 'v1';\n\t\tthis.#apiUrl = config.apiUrl ?? DEFAULT_API_URL;\n\t\tthis.#apiKey = config.apiKey;\n\t\tthis.#additionalEpochs = config.additionalEpochs;\n\t}\n\n\tgetApp(_input?: GetAppApiInput) {\n\t\treturn this.#fetch<GetAppApiResponse>('app', {\n\t\t\tmethod: 'GET',\n\t\t});\n\t}\n\n\tgetZkLogin(input: GetZkLoginApiInput) {\n\t\treturn this.#fetch<GetZkLoginApiResponse>('zklogin', {\n\t\t\tmethod: 'GET',\n\t\t\theaders: {\n\t\t\t\t[ZKLOGIN_HEADER]: input.jwt,\n\t\t\t},\n\t\t});\n\t}\n\n\tgetZkLoginAddresses(input: GetZkLoginAddressesApiInput) {\n\t\treturn this.#fetch<GetZkLoginAddressesApiResponse>('zklogin/addresses', {\n\t\t\tmethod: 'GET',\n\t\t\theaders: {\n\t\t\t\t[ZKLOGIN_HEADER]: input.jwt,\n\t\t\t},\n\t\t});\n\t}\n\n\tcreateZkLoginNonce(input: CreateZkLoginNonceApiInput) {\n\t\treturn this.#fetch<CreateZkLoginNonceApiResponse>('zklogin/nonce', {\n\t\t\tmethod: 'POST',\n\t\t\tbody: JSON.stringify({\n\t\t\t\tnetwork: input.network,\n\t\t\t\tephemeralPublicKey: input.ephemeralPublicKey.toSuiPublicKey(),\n\t\t\t\tadditionalEpochs: input.additionalEpochs ?? this.#additionalEpochs,\n\t\t\t}),\n\t\t});\n\t}\n\n\tcreateZkLoginZkp(input: CreateZkLoginZkpApiInput) {\n\t\treturn this.#fetch<CreateZkLoginZkpApiResponse>('zklogin/zkp', {\n\t\t\tmethod: 'POST',\n\t\t\theaders: {\n\t\t\t\t[ZKLOGIN_HEADER]: input.jwt,\n\t\t\t},\n\t\t\tbody: JSON.stringify({\n\t\t\t\tnetwork: input.network,\n\t\t\t\tephemeralPublicKey: input.ephemeralPublicKey.toSuiPublicKey(),\n\t\t\t\tmaxEpoch: input.maxEpoch,\n\t\t\t\trandomness: input.randomness,\n\t\t\t}),\n\t\t});\n\t}\n\n\tcreateSponsoredTransaction(input: CreateSponsoredTransactionApiInput) {\n\t\treturn this.#fetch<CreateSponsoredTransactionApiResponse>('transaction-blocks/sponsor', {\n\t\t\tmethod: 'POST',\n\t\t\theaders: input.jwt\n\t\t\t\t? {\n\t\t\t\t\t\t[ZKLOGIN_HEADER]: input.jwt,\n\t\t\t\t\t}\n\t\t\t\t: {},\n\t\t\tbody: JSON.stringify({\n\t\t\t\tsender: input.sender,\n\t\t\t\tnetwork: input.network,\n\t\t\t\ttransactionBlockKindBytes: input.transactionKindBytes,\n\t\t\t\tallowedAddresses: input.allowedAddresses,\n\t\t\t\tallowedMoveCallTargets: input.allowedMoveCallTargets,\n\t\t\t}),\n\t\t});\n\t}\n\n\texecuteSponsoredTransaction(input: ExecuteSponsoredTransactionApiInput) {\n\t\treturn this.#fetch<ExecuteSponsoredTransactionApiResponse>(\n\t\t\t`transaction-blocks/sponsor/${input.digest}`,\n\t\t\t{\n\t\t\t\tmethod: 'POST',\n\t\t\t\tbody: JSON.stringify({\n\t\t\t\t\tsignature: input.signature,\n\t\t\t\t}),\n\t\t\t},\n\t\t);\n\t}\n\n\tgetSubnames(input: GetSubnamesApiInput) {\n\t\tconst query = new URLSearchParams();\n\t\tif (input.address) {\n\t\t\tquery.set('address', input.address);\n\t\t}\n\t\tif (input.network) {\n\t\t\tquery.set('network', input.network);\n\t\t}\n\t\tif (input.domain) {\n\t\t\tquery.set('domain', input.domain);\n\t\t}\n\t\treturn this.#fetch<GetSubnamesApiResponse>(\n\t\t\t'subnames' + (query.size > 0 ? `?${query.toString()}` : ''),\n\t\t\t{\n\t\t\t\tmethod: 'GET',\n\t\t\t},\n\t\t);\n\t}\n\n\tcreateSubname(input: CreateSubnameApiInput) {\n\t\treturn this.#fetch<CreateSubnameApiResponse>('subnames', {\n\t\t\tmethod: 'POST',\n\t\t\theaders: input.jwt\n\t\t\t\t? {\n\t\t\t\t\t\t[ZKLOGIN_HEADER]: input.jwt,\n\t\t\t\t\t}\n\t\t\t\t: {},\n\t\t\tbody: JSON.stringify({\n\t\t\t\tnetwork: input.network,\n\t\t\t\tdomain: input.domain,\n\t\t\t\tsubname: input.subname,\n\t\t\t\ttargetAddress: input.targetAddress,\n\t\t\t}),\n\t\t});\n\t}\n\n\tdeleteSubname(input: DeleteSubnameApiInput) {\n\t\tthis.#fetch<DeleteSubnameApiResponse>('subnames', {\n\t\t\tmethod: 'DELETE',\n\t\t\tbody: JSON.stringify({\n\t\t\t\tnetwork: input.network,\n\t\t\t\tdomain: input.domain,\n\t\t\t\tsubname: input.subname,\n\t\t\t}),\n\t\t});\n\t}\n\n\tasync #fetch<T = unknown>(path: string, init: RequestInit): Promise<T> {\n\t\tconst res = await fetch(`${this.#apiUrl}/${this.#version}/${path}`, {\n\t\t\t...init,\n\t\t\theaders: {\n\t\t\t\t...init.headers,\n\t\t\t\tAuthorization: `Bearer ${this.#apiKey}`,\n\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\t'Request-Id': crypto.randomUUID(),\n\t\t\t},\n\t\t});\n\n\t\tif (!res.ok) {\n\t\t\tthrow new EnokiClientError(res.status, await res.text());\n\t\t}\n\n\t\tconst { data } = await res.json();\n\n\t\treturn data as T;\n\t}\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { PublicKey } from "@mysten/sui/cryptography";
|
|
2
|
+
import { ZkLoginSignatureInputs } from "@mysten/sui/zklogin";
|
|
3
|
+
|
|
4
|
+
//#region src/EnokiClient/type.d.ts
|
|
5
|
+
type AuthProvider = 'google' | 'facebook' | 'twitch' | 'onefc' | 'playtron';
|
|
6
|
+
type EnokiNetwork = 'mainnet' | 'testnet' | 'devnet';
|
|
7
|
+
type EnokiDomainNetwork = 'mainnet' | 'testnet';
|
|
8
|
+
type EnokiSubanameStatus = 'PENDING' | 'ACTIVE';
|
|
9
|
+
interface GetAppApiInput {}
|
|
10
|
+
interface GetAppApiResponse {
|
|
11
|
+
allowedOrigins: string[];
|
|
12
|
+
authenticationProviders: {
|
|
13
|
+
providerType: AuthProvider;
|
|
14
|
+
clientId: string;
|
|
15
|
+
}[];
|
|
16
|
+
domains: {
|
|
17
|
+
nftId: string;
|
|
18
|
+
name: string;
|
|
19
|
+
network: EnokiDomainNetwork;
|
|
20
|
+
}[];
|
|
21
|
+
}
|
|
22
|
+
interface GetZkLoginApiInput {
|
|
23
|
+
jwt: string;
|
|
24
|
+
}
|
|
25
|
+
interface GetZkLoginApiResponse {
|
|
26
|
+
address: string;
|
|
27
|
+
publicKey: string;
|
|
28
|
+
salt: string;
|
|
29
|
+
}
|
|
30
|
+
interface GetZkLoginAddressesApiInput {
|
|
31
|
+
jwt: string;
|
|
32
|
+
}
|
|
33
|
+
interface GetZkLoginAddressesApiResponse {
|
|
34
|
+
addresses: {
|
|
35
|
+
clientId: string;
|
|
36
|
+
salt: string;
|
|
37
|
+
address: string;
|
|
38
|
+
publicKey: string;
|
|
39
|
+
legacy?: boolean;
|
|
40
|
+
}[];
|
|
41
|
+
}
|
|
42
|
+
interface CreateZkLoginNonceApiInput {
|
|
43
|
+
network?: EnokiNetwork;
|
|
44
|
+
ephemeralPublicKey: PublicKey;
|
|
45
|
+
additionalEpochs?: number;
|
|
46
|
+
}
|
|
47
|
+
interface CreateZkLoginNonceApiResponse {
|
|
48
|
+
nonce: string;
|
|
49
|
+
randomness: string;
|
|
50
|
+
epoch: number;
|
|
51
|
+
maxEpoch: number;
|
|
52
|
+
estimatedExpiration: number;
|
|
53
|
+
}
|
|
54
|
+
interface CreateZkLoginZkpApiInput {
|
|
55
|
+
network?: EnokiNetwork;
|
|
56
|
+
jwt: string;
|
|
57
|
+
ephemeralPublicKey: PublicKey;
|
|
58
|
+
randomness: string;
|
|
59
|
+
maxEpoch: number;
|
|
60
|
+
}
|
|
61
|
+
interface CreateZkLoginZkpApiResponse extends ZkLoginSignatureInputs {}
|
|
62
|
+
type CreateSponsoredTransactionApiInput = {
|
|
63
|
+
network?: EnokiNetwork;
|
|
64
|
+
transactionKindBytes: string;
|
|
65
|
+
} & ({
|
|
66
|
+
jwt: string;
|
|
67
|
+
sender?: never;
|
|
68
|
+
allowedAddresses?: never;
|
|
69
|
+
allowedMoveCallTargets?: never;
|
|
70
|
+
} | {
|
|
71
|
+
sender: string;
|
|
72
|
+
allowedAddresses?: string[];
|
|
73
|
+
allowedMoveCallTargets?: string[];
|
|
74
|
+
jwt?: never;
|
|
75
|
+
});
|
|
76
|
+
interface CreateSponsoredTransactionApiResponse {
|
|
77
|
+
bytes: string;
|
|
78
|
+
digest: string;
|
|
79
|
+
}
|
|
80
|
+
interface ExecuteSponsoredTransactionApiInput {
|
|
81
|
+
digest: string;
|
|
82
|
+
signature: string;
|
|
83
|
+
}
|
|
84
|
+
interface ExecuteSponsoredTransactionApiResponse {
|
|
85
|
+
digest: string;
|
|
86
|
+
}
|
|
87
|
+
interface GetSubnamesApiInput {
|
|
88
|
+
address?: string;
|
|
89
|
+
network?: EnokiDomainNetwork;
|
|
90
|
+
domain?: string;
|
|
91
|
+
}
|
|
92
|
+
interface GetSubnamesApiResponse {
|
|
93
|
+
subnames: {
|
|
94
|
+
name: string;
|
|
95
|
+
status: EnokiSubanameStatus;
|
|
96
|
+
}[];
|
|
97
|
+
}
|
|
98
|
+
type CreateSubnameApiInput = {
|
|
99
|
+
domain: string;
|
|
100
|
+
network?: EnokiDomainNetwork;
|
|
101
|
+
subname: string;
|
|
102
|
+
} & ({
|
|
103
|
+
jwt: string;
|
|
104
|
+
targetAddress?: never;
|
|
105
|
+
} | {
|
|
106
|
+
targetAddress: string;
|
|
107
|
+
jwt?: never;
|
|
108
|
+
});
|
|
109
|
+
interface CreateSubnameApiResponse {
|
|
110
|
+
name: string;
|
|
111
|
+
}
|
|
112
|
+
interface DeleteSubnameApiInput {
|
|
113
|
+
domain: string;
|
|
114
|
+
network?: EnokiDomainNetwork;
|
|
115
|
+
subname: string;
|
|
116
|
+
}
|
|
117
|
+
//#endregion
|
|
118
|
+
export { AuthProvider, CreateSponsoredTransactionApiInput, CreateSponsoredTransactionApiResponse, CreateSubnameApiInput, CreateSubnameApiResponse, CreateZkLoginNonceApiInput, CreateZkLoginNonceApiResponse, CreateZkLoginZkpApiInput, CreateZkLoginZkpApiResponse, DeleteSubnameApiInput, EnokiNetwork, ExecuteSponsoredTransactionApiInput, ExecuteSponsoredTransactionApiResponse, GetAppApiInput, GetAppApiResponse, GetSubnamesApiInput, GetSubnamesApiResponse, GetZkLoginAddressesApiInput, GetZkLoginAddressesApiResponse, GetZkLoginApiInput, GetZkLoginApiResponse };
|
|
119
|
+
//# sourceMappingURL=type.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.mts","names":[],"sources":["../../src/EnokiClient/type.ts"],"sourcesContent":[],"mappings":";;;;KAMY,YAAA;KACA,YAAA;AADA,KAEA,kBAAA,GAFY,SAAA,GAAA,SAAA;AACZ,KAEA,mBAAA,GAFY,SAAA,GAAA,QAAA;AACZ,UAGK,cAAA,CAHa,CAC9B;AAEiB,UACA,iBAAA,CADc;EACd,cAAA,EAAA,MAAiB,EAAA;EAajB,uBAAkB,EAAA;IAGlB,YAAA,EAbD,YAasB;IAMrB,QAAA,EAAA,MAAA;EAGA,CAAA,EAAA;EAUA,OAAA,EAAA;IAKA,KAAA,EAAA,MAAA;IAQA,IAAA,EAAA,MAAA;IAOA,OAAA,EA9CN,kBA8CkC;EAEjC,CAAA,EAAA;AAkBZ;AAKiB,UAnEA,kBAAA,CAmEA;EAKA,GAAA,EAAA,MAAA;AAIjB;AAKiB,UA9EA,qBAAA,CA8EsB;EAO3B,OAAA,EAAA,MAAA;EAcK,SAAA,EAAA,MAAA;EAIA,IAAA,EAAA,MAAA;;UAjGA,2BAAA;;;UAGA,8BAAA;;;;;;;;;UAUA,0BAAA;YACN;sBACU;;;UAGJ,6BAAA;;;;;;;UAQA,wBAAA;YACN;;sBAEU;;;;UAIJ,2BAAA,SAAoC;KAEzC,kCAAA;YACD;;;;;;;;;;;;;UAiBM,qCAAA;;;;UAKA,mCAAA;;;;UAKA,sCAAA;;;UAIA,mBAAA;;YAEN;;;UAGM,sBAAA;;;YAGP;;;KAIE,qBAAA;;YAED;;;;;;;;;UAYM,wBAAA;;;UAIA,qBAAA;;YAEN"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { AuthProvider, EnokiNetwork } from "./EnokiClient/type.mjs";
|
|
2
|
+
import { EnokiClient, EnokiClientConfig } from "./EnokiClient/index.mjs";
|
|
3
|
+
import { Encryption } from "./encryption.mjs";
|
|
4
|
+
import { EnokiKeypair } from "./EnokiKeypair.mjs";
|
|
5
|
+
import { SyncStore } from "./stores.mjs";
|
|
6
|
+
import { ZkLoginSignatureInputs } from "@mysten/sui/zklogin";
|
|
7
|
+
import { WritableAtom } from "nanostores";
|
|
8
|
+
|
|
9
|
+
//#region src/EnokiFlow.d.ts
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated Use `RegisterEnokiWalletsOptions` instead
|
|
13
|
+
*/
|
|
14
|
+
type EnokiFlowConfig = EnokiClientConfig & ({
|
|
15
|
+
experimental_nativeCryptoSigner?: unknown;
|
|
16
|
+
/**
|
|
17
|
+
* The storage interface to persist Enoki data locally.
|
|
18
|
+
* If not provided, it will use a sessionStorage-backed store.
|
|
19
|
+
*/
|
|
20
|
+
store?: SyncStore;
|
|
21
|
+
/**
|
|
22
|
+
* The encryption interface that will be used to encrypt data before storing it locally.
|
|
23
|
+
* If not provided, it will use a default encryption interface.
|
|
24
|
+
*/
|
|
25
|
+
encryption?: Encryption;
|
|
26
|
+
} | {
|
|
27
|
+
store?: never;
|
|
28
|
+
encryption?: never;
|
|
29
|
+
/**
|
|
30
|
+
* Enables the new native crypto signer for the EnokiFlow, which is more secure.
|
|
31
|
+
*/
|
|
32
|
+
experimental_nativeCryptoSigner: true;
|
|
33
|
+
});
|
|
34
|
+
interface ZkLoginState {
|
|
35
|
+
provider?: AuthProvider;
|
|
36
|
+
address?: string;
|
|
37
|
+
salt?: string;
|
|
38
|
+
publicKey?: string;
|
|
39
|
+
}
|
|
40
|
+
interface ZkLoginSession {
|
|
41
|
+
ephemeralKeyPair: string;
|
|
42
|
+
maxEpoch: number;
|
|
43
|
+
randomness: string;
|
|
44
|
+
expiresAt: number;
|
|
45
|
+
jwt?: string;
|
|
46
|
+
proof?: ZkLoginSignatureInputs;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* @deprecated Use `registerEnokiWallets` instead
|
|
50
|
+
*/
|
|
51
|
+
declare class EnokiFlow {
|
|
52
|
+
#private;
|
|
53
|
+
$zkLoginSession: WritableAtom<{
|
|
54
|
+
initialized: boolean;
|
|
55
|
+
value: ZkLoginSession | null;
|
|
56
|
+
}>;
|
|
57
|
+
$zkLoginState: WritableAtom<ZkLoginState>;
|
|
58
|
+
constructor(config: EnokiFlowConfig);
|
|
59
|
+
get enokiClient(): EnokiClient;
|
|
60
|
+
createAuthorizationURL(input: {
|
|
61
|
+
provider: AuthProvider;
|
|
62
|
+
clientId: string;
|
|
63
|
+
redirectUrl: string;
|
|
64
|
+
network?: 'mainnet' | 'testnet' | 'devnet';
|
|
65
|
+
extraParams?: Record<string, unknown>;
|
|
66
|
+
}): Promise<string>;
|
|
67
|
+
handleAuthCallback(hash?: string): Promise<string | null>;
|
|
68
|
+
getSession(): Promise<ZkLoginSession | null>;
|
|
69
|
+
logout(): Promise<void>;
|
|
70
|
+
getProof({
|
|
71
|
+
network
|
|
72
|
+
}?: {
|
|
73
|
+
network?: EnokiNetwork;
|
|
74
|
+
}): Promise<{
|
|
75
|
+
proofPoints: {
|
|
76
|
+
a: Iterable<string> & {
|
|
77
|
+
length: number;
|
|
78
|
+
};
|
|
79
|
+
b: Iterable<Iterable<string> & {
|
|
80
|
+
length: number;
|
|
81
|
+
}> & {
|
|
82
|
+
length: number;
|
|
83
|
+
};
|
|
84
|
+
c: Iterable<string> & {
|
|
85
|
+
length: number;
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
issBase64Details: {
|
|
89
|
+
value: string;
|
|
90
|
+
indexMod4: number;
|
|
91
|
+
};
|
|
92
|
+
headerBase64: string;
|
|
93
|
+
addressSeed: string;
|
|
94
|
+
}>;
|
|
95
|
+
getKeypair({
|
|
96
|
+
network
|
|
97
|
+
}?: {
|
|
98
|
+
network?: EnokiNetwork;
|
|
99
|
+
}): Promise<EnokiKeypair>;
|
|
100
|
+
}
|
|
101
|
+
//#endregion
|
|
102
|
+
export { EnokiFlow, EnokiFlowConfig, ZkLoginSession, ZkLoginState };
|
|
103
|
+
//# sourceMappingURL=EnokiFlow.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EnokiFlow.d.mts","names":[],"sources":["../src/EnokiFlow.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;AA2BA;;AAQY,KARA,eAAA,GAAkB,iBAQlB,GAAA,CAAA;EAKK,+BAAA,CAAA,EAAA,OAAA;EAAU;AAa3B;AAQA;AAkBA;EAS8D,KAAA,CAAA,EArDlD,SAqDkD;EAA5C;;;;EA6CF,UAAA,CAAA,EA7FC,UA6FD;CAKJ,GAAA;EAII,KAAA,CAAA,EAAA,KAAA;EACd,UAAA,CAAA,EAAA,KAAA;EAuE2D;;;EA6EhD,+BAAA,EAAA,IAAA;CAWK,CAAA;AAAuB,UAzPxB,YAAA,CAyPwB;aAxP7B;;;;;AAqSQ,UA9RH,cAAA,CA8RG;EAAuB,gBAAA,EAAA,MAAA;EAAmB,QAAA,EAAA,MAAA;EAAA,UAAA,EAAA,MAAA;EAAA,SAAA,EAAA,MAAA;;UAvRrD;;;;;cAWI,SAAA;;mBASK;;WAA4C;;iBAC9C,aAAa;sBAER;qBA0CL;;cAKJ;;;;kBAII;MACd;qCAuE2D;gBAkD5C,QAAA;YA2BJ;;;;cAW4B;MAAmB;;;;;;;;;;;;;;;;;;;;;;;;cA6CjB;MAAmB,QAAA"}
|