@mysten/enoki 0.9.1 → 0.11.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.
Files changed (49) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/cjs/EnokiClient/type.d.ts +1 -1
  3. package/dist/cjs/EnokiClient/type.js.map +1 -1
  4. package/dist/cjs/index.d.ts +1 -1
  5. package/dist/cjs/index.js +1 -0
  6. package/dist/cjs/index.js.map +2 -2
  7. package/dist/cjs/wallet/features.d.ts +50 -0
  8. package/dist/cjs/wallet/{feature.js → features.js} +7 -5
  9. package/dist/cjs/wallet/features.js.map +7 -0
  10. package/dist/cjs/wallet/providers.js +5 -0
  11. package/dist/cjs/wallet/providers.js.map +2 -2
  12. package/dist/cjs/wallet/state.d.ts +3 -3
  13. package/dist/cjs/wallet/state.js +30 -32
  14. package/dist/cjs/wallet/state.js.map +2 -2
  15. package/dist/cjs/wallet/types.d.ts +24 -21
  16. package/dist/cjs/wallet/types.js.map +1 -1
  17. package/dist/cjs/wallet/utils.d.ts +3 -1
  18. package/dist/cjs/wallet/utils.js +24 -6
  19. package/dist/cjs/wallet/utils.js.map +3 -3
  20. package/dist/cjs/wallet/wallet.d.ts +2 -2
  21. package/dist/cjs/wallet/wallet.js +46 -58
  22. package/dist/cjs/wallet/wallet.js.map +2 -2
  23. package/dist/esm/EnokiClient/type.d.ts +1 -1
  24. package/dist/esm/index.d.ts +1 -1
  25. package/dist/esm/index.js +3 -1
  26. package/dist/esm/index.js.map +2 -2
  27. package/dist/esm/wallet/features.d.ts +50 -0
  28. package/dist/esm/wallet/features.js +7 -0
  29. package/dist/esm/wallet/features.js.map +7 -0
  30. package/dist/esm/wallet/providers.js +5 -0
  31. package/dist/esm/wallet/providers.js.map +2 -2
  32. package/dist/esm/wallet/state.d.ts +3 -3
  33. package/dist/esm/wallet/state.js +32 -34
  34. package/dist/esm/wallet/state.js.map +2 -2
  35. package/dist/esm/wallet/types.d.ts +24 -21
  36. package/dist/esm/wallet/utils.d.ts +3 -1
  37. package/dist/esm/wallet/utils.js +19 -1
  38. package/dist/esm/wallet/utils.js.map +3 -3
  39. package/dist/esm/wallet/wallet.d.ts +2 -2
  40. package/dist/esm/wallet/wallet.js +45 -57
  41. package/dist/esm/wallet/wallet.js.map +2 -2
  42. package/dist/tsconfig.esm.tsbuildinfo +1 -1
  43. package/dist/tsconfig.tsbuildinfo +1 -1
  44. package/package.json +1 -1
  45. package/dist/cjs/wallet/feature.d.ts +0 -31
  46. package/dist/cjs/wallet/feature.js.map +0 -7
  47. package/dist/esm/wallet/feature.d.ts +0 -31
  48. package/dist/esm/wallet/feature.js +0 -5
  49. package/dist/esm/wallet/feature.js.map +0 -7
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @mysten/enoki
2
2
 
3
+ ## 0.11.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 5d0269c: Split the `enoki:getMetadata` feature into `enoki:getMetadata` and `enoki:getSession`.
8
+
9
+ `getWalletMetadata` now only returns the authentication provider, while `getSession` returns the
10
+ zkLogin session data.
11
+
12
+ ## 0.10.0
13
+
14
+ ### Minor Changes
15
+
16
+ - 7a25d35: Use IndexedDB for persisting zkLogin state and session data
17
+
18
+ ### Patch Changes
19
+
20
+ - f8f9afc: adds ONE Championship auth provider
21
+
3
22
  ## 0.9.1
4
23
 
5
24
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  import type { PublicKey } from '@mysten/sui/cryptography';
2
2
  import type { ZkLoginSignatureInputs } from '@mysten/sui/zklogin';
3
- export type AuthProvider = 'google' | 'facebook' | 'twitch';
3
+ export type AuthProvider = 'google' | 'facebook' | 'twitch' | 'onefc';
4
4
  export type EnokiNetwork = 'mainnet' | 'testnet' | 'devnet';
5
5
  export type EnokiDomainNetwork = 'mainnet' | 'testnet';
6
6
  export type EnokiSubanameStatus = 'PENDING' | 'ACTIVE';
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/EnokiClient/type.ts"],
4
- "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { PublicKey } from '@mysten/sui/cryptography';\nimport type { ZkLoginSignatureInputs } from '@mysten/sui/zklogin';\n\nexport type AuthProvider = 'google' | 'facebook' | 'twitch';\nexport type EnokiNetwork = 'mainnet' | 'testnet' | 'devnet';\nexport type EnokiDomainNetwork = 'mainnet' | 'testnet';\nexport type EnokiSubanameStatus = 'PENDING' | 'ACTIVE';\n\nexport interface GetAppApiInput {}\nexport interface GetAppApiResponse {\n\tallowedOrigins: string[];\n\tauthenticationProviders: {\n\t\tproviderType: AuthProvider;\n\t\tclientId: string;\n\t}[];\n\tdomains: {\n\t\tnftId: string;\n\t\tname: string;\n\t\tnetwork: EnokiDomainNetwork;\n\t}[];\n}\n\nexport interface GetZkLoginApiInput {\n\tjwt: string;\n}\nexport interface GetZkLoginApiResponse {\n\taddress: string;\n\tpublicKey: string;\n\tsalt: string;\n}\n\nexport interface GetZkLoginAddressesApiInput {\n\tjwt: string;\n}\nexport interface GetZkLoginAddressesApiResponse {\n\taddresses: {\n\t\tclientId: string;\n\t\tsalt: string;\n\t\taddress: string;\n\t\tpublicKey: string;\n\t\tlegacy?: boolean;\n\t}[];\n}\n\nexport interface CreateZkLoginNonceApiInput {\n\tnetwork?: EnokiNetwork;\n\tephemeralPublicKey: PublicKey;\n\tadditionalEpochs?: number;\n}\nexport interface CreateZkLoginNonceApiResponse {\n\tnonce: string;\n\trandomness: string;\n\tepoch: number;\n\tmaxEpoch: number;\n\testimatedExpiration: number;\n}\n\nexport interface CreateZkLoginZkpApiInput {\n\tnetwork?: EnokiNetwork;\n\tjwt: string;\n\tephemeralPublicKey: PublicKey;\n\trandomness: string;\n\tmaxEpoch: number;\n}\nexport interface CreateZkLoginZkpApiResponse extends ZkLoginSignatureInputs {}\n\nexport type CreateSponsoredTransactionApiInput = {\n\tnetwork?: EnokiNetwork;\n\ttransactionKindBytes: string;\n} & (\n\t| {\n\t\t\tjwt: string;\n\t\t\tsender?: never;\n\t\t\tallowedAddresses?: never;\n\t\t\tallowedMoveCallTargets?: never;\n\t }\n\t| {\n\t\t\tsender: string;\n\t\t\tallowedAddresses?: string[];\n\t\t\tallowedMoveCallTargets?: string[];\n\t\t\tjwt?: never;\n\t }\n);\n\nexport interface CreateSponsoredTransactionApiResponse {\n\tbytes: string;\n\tdigest: string;\n}\n\nexport interface ExecuteSponsoredTransactionApiInput {\n\tdigest: string;\n\tsignature: string;\n}\n\nexport interface ExecuteSponsoredTransactionApiResponse {\n\tdigest: string;\n}\n\nexport interface GetSubnamesApiInput {\n\taddress?: string;\n\tnetwork?: EnokiDomainNetwork;\n\tdomain?: string;\n}\nexport interface GetSubnamesApiResponse {\n\tsubnames: {\n\t\tname: string;\n\t\tstatus: EnokiSubanameStatus;\n\t}[];\n}\n\nexport type CreateSubnameApiInput = {\n\tdomain: string;\n\tnetwork?: EnokiDomainNetwork;\n\tsubname: string;\n} & (\n\t| {\n\t\t\tjwt: string;\n\t\t\ttargetAddress?: never;\n\t }\n\t| {\n\t\t\ttargetAddress: string;\n\t\t\tjwt?: never;\n\t }\n);\nexport interface CreateSubnameApiResponse {\n\tname: string;\n}\n\nexport interface DeleteSubnameApiInput {\n\tdomain: string;\n\tnetwork?: EnokiDomainNetwork;\n\tsubname: string;\n}\nexport interface DeleteSubnameApiResponse {\n\tname: string;\n}\n"],
4
+ "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { PublicKey } from '@mysten/sui/cryptography';\nimport type { ZkLoginSignatureInputs } from '@mysten/sui/zklogin';\n\nexport type AuthProvider = 'google' | 'facebook' | 'twitch' | 'onefc';\nexport type EnokiNetwork = 'mainnet' | 'testnet' | 'devnet';\nexport type EnokiDomainNetwork = 'mainnet' | 'testnet';\nexport type EnokiSubanameStatus = 'PENDING' | 'ACTIVE';\n\nexport interface GetAppApiInput {}\nexport interface GetAppApiResponse {\n\tallowedOrigins: string[];\n\tauthenticationProviders: {\n\t\tproviderType: AuthProvider;\n\t\tclientId: string;\n\t}[];\n\tdomains: {\n\t\tnftId: string;\n\t\tname: string;\n\t\tnetwork: EnokiDomainNetwork;\n\t}[];\n}\n\nexport interface GetZkLoginApiInput {\n\tjwt: string;\n}\nexport interface GetZkLoginApiResponse {\n\taddress: string;\n\tpublicKey: string;\n\tsalt: string;\n}\n\nexport interface GetZkLoginAddressesApiInput {\n\tjwt: string;\n}\nexport interface GetZkLoginAddressesApiResponse {\n\taddresses: {\n\t\tclientId: string;\n\t\tsalt: string;\n\t\taddress: string;\n\t\tpublicKey: string;\n\t\tlegacy?: boolean;\n\t}[];\n}\n\nexport interface CreateZkLoginNonceApiInput {\n\tnetwork?: EnokiNetwork;\n\tephemeralPublicKey: PublicKey;\n\tadditionalEpochs?: number;\n}\nexport interface CreateZkLoginNonceApiResponse {\n\tnonce: string;\n\trandomness: string;\n\tepoch: number;\n\tmaxEpoch: number;\n\testimatedExpiration: number;\n}\n\nexport interface CreateZkLoginZkpApiInput {\n\tnetwork?: EnokiNetwork;\n\tjwt: string;\n\tephemeralPublicKey: PublicKey;\n\trandomness: string;\n\tmaxEpoch: number;\n}\nexport interface CreateZkLoginZkpApiResponse extends ZkLoginSignatureInputs {}\n\nexport type CreateSponsoredTransactionApiInput = {\n\tnetwork?: EnokiNetwork;\n\ttransactionKindBytes: string;\n} & (\n\t| {\n\t\t\tjwt: string;\n\t\t\tsender?: never;\n\t\t\tallowedAddresses?: never;\n\t\t\tallowedMoveCallTargets?: never;\n\t }\n\t| {\n\t\t\tsender: string;\n\t\t\tallowedAddresses?: string[];\n\t\t\tallowedMoveCallTargets?: string[];\n\t\t\tjwt?: never;\n\t }\n);\n\nexport interface CreateSponsoredTransactionApiResponse {\n\tbytes: string;\n\tdigest: string;\n}\n\nexport interface ExecuteSponsoredTransactionApiInput {\n\tdigest: string;\n\tsignature: string;\n}\n\nexport interface ExecuteSponsoredTransactionApiResponse {\n\tdigest: string;\n}\n\nexport interface GetSubnamesApiInput {\n\taddress?: string;\n\tnetwork?: EnokiDomainNetwork;\n\tdomain?: string;\n}\nexport interface GetSubnamesApiResponse {\n\tsubnames: {\n\t\tname: string;\n\t\tstatus: EnokiSubanameStatus;\n\t}[];\n}\n\nexport type CreateSubnameApiInput = {\n\tdomain: string;\n\tnetwork?: EnokiDomainNetwork;\n\tsubname: string;\n} & (\n\t| {\n\t\t\tjwt: string;\n\t\t\ttargetAddress?: never;\n\t }\n\t| {\n\t\t\ttargetAddress: string;\n\t\t\tjwt?: never;\n\t }\n);\nexport interface CreateSubnameApiResponse {\n\tname: string;\n}\n\nexport interface DeleteSubnameApiInput {\n\tdomain: string;\n\tnetwork?: EnokiDomainNetwork;\n\tsubname: string;\n}\nexport interface DeleteSubnameApiResponse {\n\tname: string;\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
6
6
  "names": []
7
7
  }
@@ -7,6 +7,6 @@ export { EnokiKeypair, EnokiPublicKey } from './EnokiKeypair.js';
7
7
  export type { EnokiWallet } from './wallet/wallet.js';
8
8
  export { registerEnokiWallets } from './wallet/register.js';
9
9
  export { enokiWalletsInitializer } from './wallet/initializer.js';
10
- export { isEnokiWallet, isGoogleWallet, isTwitchWallet, isFacebookWallet, getWalletMetadata, } from './wallet/utils.js';
10
+ export { isEnokiWallet, isGoogleWallet, isTwitchWallet, isFacebookWallet, getWalletMetadata, getSession, } from './wallet/utils.js';
11
11
  export { type RegisterEnokiWalletsOptions } from './wallet/types.js';
12
12
  export { isEnokiNetwork } from './utils.js';
package/dist/cjs/index.js CHANGED
@@ -28,6 +28,7 @@ __export(index_exports, {
28
28
  createLocalStorage: () => import_stores.createLocalStorage,
29
29
  createSessionStorage: () => import_stores.createSessionStorage,
30
30
  enokiWalletsInitializer: () => import_initializer.enokiWalletsInitializer,
31
+ getSession: () => import_utils.getSession,
31
32
  getWalletMetadata: () => import_utils.getWalletMetadata,
32
33
  isEnokiNetwork: () => import_utils2.isEnokiNetwork,
33
34
  isEnokiWallet: () => import_utils.isEnokiWallet,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts"],
4
- "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nexport { EnokiClient, type EnokiClientConfig, EnokiClientError } from './EnokiClient/index.js';\nexport type { EnokiNetwork, AuthProvider } from './EnokiClient/type.js';\nexport { EnokiFlow, type EnokiFlowConfig } from './EnokiFlow.js';\nexport {\n\tcreateLocalStorage,\n\tcreateSessionStorage,\n\tcreateInMemoryStorage,\n\ttype SyncStore,\n} from './stores.js';\nexport { createDefaultEncryption, type Encryption } from './encryption.js';\nexport { EnokiKeypair, EnokiPublicKey } from './EnokiKeypair.js';\n\nexport type { EnokiWallet } from './wallet/wallet.js';\nexport { registerEnokiWallets } from './wallet/register.js';\nexport { enokiWalletsInitializer } from './wallet/initializer.js';\n\nexport {\n\tisEnokiWallet,\n\tisGoogleWallet,\n\tisTwitchWallet,\n\tisFacebookWallet,\n\tgetWalletMetadata,\n} from './wallet/utils.js';\nexport { type RegisterEnokiWalletsOptions } from './wallet/types.js';\n\nexport { isEnokiNetwork } from './utils.js';\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,yBAAsE;AAEtE,uBAAgD;AAChD,oBAKO;AACP,wBAAyD;AACzD,0BAA6C;AAG7C,sBAAqC;AACrC,yBAAwC;AAExC,mBAMO;AAGP,IAAAA,gBAA+B;",
4
+ "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nexport { EnokiClient, type EnokiClientConfig, EnokiClientError } from './EnokiClient/index.js';\nexport type { EnokiNetwork, AuthProvider } from './EnokiClient/type.js';\nexport { EnokiFlow, type EnokiFlowConfig } from './EnokiFlow.js';\nexport {\n\tcreateLocalStorage,\n\tcreateSessionStorage,\n\tcreateInMemoryStorage,\n\ttype SyncStore,\n} from './stores.js';\nexport { createDefaultEncryption, type Encryption } from './encryption.js';\nexport { EnokiKeypair, EnokiPublicKey } from './EnokiKeypair.js';\n\nexport type { EnokiWallet } from './wallet/wallet.js';\nexport { registerEnokiWallets } from './wallet/register.js';\nexport { enokiWalletsInitializer } from './wallet/initializer.js';\n\nexport {\n\tisEnokiWallet,\n\tisGoogleWallet,\n\tisTwitchWallet,\n\tisFacebookWallet,\n\tgetWalletMetadata,\n\tgetSession,\n} from './wallet/utils.js';\nexport { type RegisterEnokiWalletsOptions } from './wallet/types.js';\n\nexport { isEnokiNetwork } from './utils.js';\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,yBAAsE;AAEtE,uBAAgD;AAChD,oBAKO;AACP,wBAAyD;AACzD,0BAA6C;AAG7C,sBAAqC;AACrC,yBAAwC;AAExC,mBAOO;AAGP,IAAAA,gBAA+B;",
6
6
  "names": ["import_utils"]
7
7
  }
@@ -0,0 +1,50 @@
1
+ import type { AuthProvider, EnokiNetwork } from '../EnokiClient/type.js';
2
+ import type { ZkLoginSession } from './types.js';
3
+ /** Name of the feature for retrieving basic wallet metadata. */
4
+ export declare const EnokiGetMetadata = "enoki:getMetadata";
5
+ /** The latest API version of the getMetadata API. */
6
+ export type EnokiGetMetadataVersion = '1.0.0';
7
+ /**
8
+ * A Wallet Standard feature for retreiving Enoki-specific metadata about the wallet.
9
+ */
10
+ export type EnokiGetMetadataFeature = {
11
+ /** Namespace for the feature. */
12
+ [EnokiGetMetadata]: {
13
+ /** Version of the feature API. */
14
+ version: EnokiGetMetadataVersion;
15
+ getMetadata: EnokiGetMetadataMethod;
16
+ };
17
+ };
18
+ export type EnokiGetMetadataMethod = (input?: EnokiGetMetadataInput) => EnokiGetMetadataOutput;
19
+ /** Input for retrieving metadata about the wallet. */
20
+ export type EnokiGetMetadataInput = void;
21
+ /** Output of retrieving metadata about the wallet. */
22
+ export type EnokiGetMetadataOutput = {
23
+ /** The social provider for the wallet. */
24
+ provider: AuthProvider;
25
+ };
26
+ /** Name of the feature for retrieving the Enoki session. */
27
+ export declare const EnokiGetSession = "enoki:getSession";
28
+ /** The latest API version of the getSession API. */
29
+ export type EnokiGetSessionVersion = '1.0.0';
30
+ /**
31
+ * A Wallet Standard feature for retreiving the zkLogin session from the wallet.
32
+ */
33
+ export type EnokiGetSessionFeature = {
34
+ /** Namespace for the feature. */
35
+ [EnokiGetSession]: {
36
+ /** Version of the feature API. */
37
+ version: EnokiGetSessionVersion;
38
+ getSession: EnokiGetSessionMethod;
39
+ };
40
+ };
41
+ export type EnokiGetSessionMethod = (input?: EnokiGetSessionInput) => Promise<EnokiGetSessionOutput>;
42
+ /** Input for retrieving the session from the wallet. */
43
+ export type EnokiGetSessionInput = {
44
+ /**
45
+ * The network to retrieve session data for. Defaults to the active network.
46
+ **/
47
+ network?: EnokiNetwork;
48
+ };
49
+ /** Output of retrieving the Enoki session. */
50
+ export type EnokiGetSessionOutput = ZkLoginSession | null;
@@ -16,10 +16,12 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var feature_exports = {};
20
- __export(feature_exports, {
21
- EnokiGetMetadata: () => EnokiGetMetadata
19
+ var features_exports = {};
20
+ __export(features_exports, {
21
+ EnokiGetMetadata: () => EnokiGetMetadata,
22
+ EnokiGetSession: () => EnokiGetSession
22
23
  });
23
- module.exports = __toCommonJS(feature_exports);
24
+ module.exports = __toCommonJS(features_exports);
24
25
  const EnokiGetMetadata = "enoki:getMetadata";
25
- //# sourceMappingURL=feature.js.map
26
+ const EnokiGetSession = "enoki:getSession";
27
+ //# sourceMappingURL=features.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/wallet/features.ts"],
4
+ "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { AuthProvider, EnokiNetwork } from '../EnokiClient/type.js';\nimport type { ZkLoginSession } from './types.js';\n\n/** Name of the feature for retrieving basic wallet metadata. */\nexport const EnokiGetMetadata = 'enoki:getMetadata';\n\n/** The latest API version of the getMetadata API. */\nexport type EnokiGetMetadataVersion = '1.0.0';\n\n/**\n * A Wallet Standard feature for retreiving Enoki-specific metadata about the wallet.\n */\nexport type EnokiGetMetadataFeature = {\n\t/** Namespace for the feature. */\n\t[EnokiGetMetadata]: {\n\t\t/** Version of the feature API. */\n\t\tversion: EnokiGetMetadataVersion;\n\t\tgetMetadata: EnokiGetMetadataMethod;\n\t};\n};\n\nexport type EnokiGetMetadataMethod = (input?: EnokiGetMetadataInput) => EnokiGetMetadataOutput;\n\n/** Input for retrieving metadata about the wallet. */\nexport type EnokiGetMetadataInput = void;\n\n/** Output of retrieving metadata about the wallet. */\nexport type EnokiGetMetadataOutput = {\n\t/** The social provider for the wallet. */\n\tprovider: AuthProvider;\n};\n\n/** Name of the feature for retrieving the Enoki session. */\nexport const EnokiGetSession = 'enoki:getSession';\n\n/** The latest API version of the getSession API. */\nexport type EnokiGetSessionVersion = '1.0.0';\n\n/**\n * A Wallet Standard feature for retreiving the zkLogin session from the wallet.\n */\nexport type EnokiGetSessionFeature = {\n\t/** Namespace for the feature. */\n\t[EnokiGetSession]: {\n\t\t/** Version of the feature API. */\n\t\tversion: EnokiGetSessionVersion;\n\t\tgetSession: EnokiGetSessionMethod;\n\t};\n};\n\nexport type EnokiGetSessionMethod = (\n\tinput?: EnokiGetSessionInput,\n) => Promise<EnokiGetSessionOutput>;\n\n/** Input for retrieving the session from the wallet. */\nexport type EnokiGetSessionInput = {\n\t/**\n\t * The network to retrieve session data for. Defaults to the active network.\n\t **/\n\tnetwork?: EnokiNetwork;\n};\n\n/** Output of retrieving the Enoki session. */\nexport type EnokiGetSessionOutput = ZkLoginSession | null;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAOO,MAAM,mBAAmB;AA6BzB,MAAM,kBAAkB;",
6
+ "names": []
7
+ }
@@ -36,6 +36,11 @@ const ENOKI_PROVIDER_WALLETS_INFO = [
36
36
  provider: "twitch",
37
37
  name: "Sign in with Twitch",
38
38
  icon: "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPCEtLSBHZW5lcmF0b3I6IEFkb2JlIElsbHVzdHJhdG9yIDIzLjAuNiwgU1ZHIEV4cG9ydCBQbHVnLUluIC4gU1ZHIFZlcnNpb246IDYuMDAgQnVpbGQgMCkgIC0tPgo8c3ZnIHZlcnNpb249IjEuMSIgaWQ9IkxheWVyXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiCgl2aWV3Qm94PSItNDAwIC00MDAgMjgwMCAzMjAwIiB4bWw6c3BhY2U9InByZXNlcnZlIj4KCTxzdHlsZSB0eXBlPSJ0ZXh0L2NzcyI+CgkJLnN0MCB7CgkJCWZpbGw6ICNGRkZGRkY7CgkJfQoKCQkuc3QxIHsKCQkJZmlsbDogIzkxNDZGRjsKCQl9Cgk8L3N0eWxlPgoJPHRpdGxlPkFzc2V0IDI8L3RpdGxlPgoJPGc+CgkJPHBvbHlnb24gY2xhc3M9InN0MCIgcG9pbnRzPSIyMjAwLDEzMDAgMTgwMCwxNzAwIDE0MDAsMTcwMCAxMDUwLDIwNTAgMTA1MCwxN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WBgKhWy1cDQqLy+fmpqyyc0eeHRdNwwDCx1NYozt2bMHAHA0dITdzPAkjnE8f/48etR2oX2N2r948aK4uBgA8vLy+vv78d+vX7+WlZWh+3GEvHfvns2PVVVVkiSdPn0ahyg7MvhrG4BsyxgbGhpCDsVfxxpgjImiaFebKIqaptXX14dCoeLiYhxZkRC9Xm88Huc47vXr1w0NDdgaRVF8/vx5b2+vqqrv379///49jrhYS62trTt27JAk6cOHD/39/YSQ2dnZvr6+T58++Xy+WCyGzGFZlqqqyHKojCAIPT098XgcAKLRKC7+IZf+EvMfRH6+VhQlNzd3enraMIympiYAUFUVc3oeXk/1oOM4WIsOcBTE879sput6LBbr7e2VJOnWrVuSJGGlulwuDHVK8lM2gDrA6XlseeynzwfILd3d3TMzM48ePbJHX57n8ViTknwnOFrsJMspmrbqjDE8juLt06dPL126ZBiGYRhoQzKZ/Af5TpjvTDy/ovMDdaWUqqoqy7KmaZqmqaqq6zqlVBCEVJ3ttO+CGYAaW5aFt9heMBqUUjyL2WQiiqL95F8iZQNSBcdxeLy0XYuJhOcsQogoijiMAADa4yTnt+tOBizkp0VK6f/yKdYrx3GEEEEQkEb/4ftPGmmkkUYaaaSRRhpppJHGr/gPrRmLNs+cA/AAAAAASUVORK5CYII="
39
44
  }
40
45
  ];
41
46
  //# sourceMappingURL=providers.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/wallet/providers.ts"],
4
- "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { Wallet } from '@mysten/wallet-standard';\n\nimport type { AuthProvider } from '../EnokiClient/type.js';\n\nexport const ENOKI_PROVIDER_WALLETS_INFO: {\n\tname: string;\n\ticon: Wallet['icon'];\n\tprovider: AuthProvider;\n}[] = [\n\t{\n\t\tprovider: 'google',\n\t\tname: 'Sign in with Google',\n\t\ticon: 'data:image/svg+xml;base64,PHN2ZyBmaWxsPSJub25lIiBoZW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n\t},\n];\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOO,MAAM,8BAIP;AAAA,EACL;AAAA,IACC,UAAU;AAAA,IACV,MAAM;AAAA,IACN,MAAM;AAAA,EACP;AAAA,EACA;AAAA,IACC,UAAU;AAAA,IACV,MAAM;AAAA,IACN,MAAM;AAAA,EACP;AAAA,EACA;AAAA,IACC,UAAU;AAAA,IACV,MAAM;AAAA,IACN,MAAM;AAAA,EACP;AACD;",
4
+ "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { Wallet } from '@mysten/wallet-standard';\n\nimport type { AuthProvider } from '../EnokiClient/type.js';\n\nexport const ENOKI_PROVIDER_WALLETS_INFO: {\n\tname: string;\n\ticon: Wallet['icon'];\n\tprovider: AuthProvider;\n}[] = [\n\t{\n\t\tprovider: 'google',\n\t\tname: 'Sign in with Google',\n\t\ticon: 'data:image/svg+xml;base64,PHN2ZyBmaWxsPSJub25lIiBoZWlnaHQ9IjMyIiB2aWV3Qm94PSIwIDAgMzIgMzIiIHdpZHRoPSIzMiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJtMzIgMGgtMzJ2MzJoMzJ6IiBmaWxsPSIjZmZmIi8+PGcgY2xpcC1ydWxlPSJldmVub2RkIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxwYXRoIGQ9Im0yMy44Mjk5IDE2LjE4MThjMC0uNTY3Mi0uMDUwOS0xLjExMjctLjE0NTQtMS42MzYzaC03LjUzNDZ2My4wOTQ1aDQuMzA1NWMtLjE4NTUgMS0uNzQ5MSAxLjg0NzMtMS41OTY0IDIuNDE0NnYyLjAwNzNoMi41ODU1YzEuNTEyNy0xLjM5MjggMi4zODU0LTMuNDQzNyAyLjM4NTQtNS44ODAxeiIgZmlsbD0iIzQyODVmNCIvPjxwYXRoIGQ9Im0xNi4xND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
6
6
  "names": []
7
7
  }
@@ -9,10 +9,10 @@ export type EnokiWalletStateConfig = EnokiClientConfig & {
9
9
  export declare class EnokiWalletState {
10
10
  #private;
11
11
  constructor(config: EnokiWalletStateConfig);
12
- get zkLoginState(): WritableAtom<ZkLoginState>;
12
+ get zkLoginState(): WritableAtom<ZkLoginState | null>;
13
13
  get sessionContextByNetwork(): Map<Experimental_SuiClientTypes.Network, EnokiSessionContext>;
14
14
  getSessionContext(network: Experimental_SuiClientTypes.Network): EnokiSessionContext;
15
15
  logout(): Promise<void>;
16
- setSession(state: EnokiSessionContext, newValue: ZkLoginSession | null): Promise<void>;
17
- getSession({ $zkLoginSession, storageKey }: EnokiSessionContext): Promise<ZkLoginSession | null>;
16
+ setSession(context: EnokiSessionContext, newValue: ZkLoginSession | null): Promise<void>;
17
+ getSession({ $zkLoginSession, idbStore }: EnokiSessionContext): Promise<ZkLoginSession | null>;
18
18
  }
@@ -32,30 +32,27 @@ module.exports = __toCommonJS(state_exports);
32
32
  var import_idb_keyval = require("idb-keyval");
33
33
  var import_nanostores = require("nanostores");
34
34
  var import_encryption = require("../encryption.js");
35
- var import_stores = require("../stores.js");
36
- var _encryption, _encryptionKey, _sessionStore, _stateStorageKey, _sessionContextByNetwork, _zkLoginState, _EnokiWalletState_instances, createZkLoginState_fn;
35
+ var _encryption, _encryptionKey, _stateStore, _sessionContextByNetwork, _zkLoginState, _EnokiWalletState_instances, createZkLoginState_fn;
36
+ const sessionKey = "zklogin-session";
37
+ const stateKey = "zklogin-state";
37
38
  class EnokiWalletState {
38
39
  constructor(config) {
39
40
  __privateAdd(this, _EnokiWalletState_instances);
40
41
  __privateAdd(this, _encryption);
41
42
  __privateAdd(this, _encryptionKey);
42
- __privateAdd(this, _sessionStore);
43
- __privateAdd(this, _stateStorageKey);
43
+ __privateAdd(this, _stateStore);
44
44
  __privateAdd(this, _sessionContextByNetwork);
45
45
  __privateAdd(this, _zkLoginState);
46
46
  __privateSet(this, _encryptionKey, config.apiKey);
47
47
  __privateSet(this, _encryption, (0, import_encryption.createDefaultEncryption)());
48
- __privateSet(this, _sessionStore, (0, import_stores.createSessionStorage)());
49
- __privateSet(this, _stateStorageKey, `@enoki/flow/state/${config.apiKey}/${config.clientId}`);
48
+ __privateSet(this, _stateStore, (0, import_idb_keyval.createStore)(`${config.apiKey}_${config.clientId}`, "enoki"));
50
49
  __privateSet(this, _zkLoginState, __privateMethod(this, _EnokiWalletState_instances, createZkLoginState_fn).call(this));
51
50
  __privateSet(this, _sessionContextByNetwork, config.clients.reduce((accumulator, client) => {
52
51
  const network = client.network;
53
- const storageKey = `@enoki/flow/session/${config.apiKey}/${network}/${config.clientId}`;
54
52
  const idbStore = (0, import_idb_keyval.createStore)(`${config.apiKey}_${network}_${config.clientId}`, "enoki");
55
53
  const sessionContext = {
56
54
  $zkLoginSession: (0, import_nanostores.atom)({ initialized: false, value: null }),
57
55
  client,
58
- storageKey,
59
56
  idbStore
60
57
  };
61
58
  (0, import_nanostores.onMount)(sessionContext.$zkLoginSession, () => {
@@ -78,31 +75,31 @@ class EnokiWalletState {
78
75
  return context;
79
76
  }
80
77
  async logout() {
81
- __privateGet(this, _zkLoginState).set({});
82
- __privateGet(this, _sessionStore).delete(__privateGet(this, _stateStorageKey));
83
- for (const state of __privateGet(this, _sessionContextByNetwork).values()) {
84
- await (0, import_idb_keyval.clear)(state.idbStore);
85
- await this.setSession(state, null);
78
+ __privateGet(this, _zkLoginState).set(null);
79
+ await (0, import_idb_keyval.clear)(__privateGet(this, _stateStore));
80
+ for (const context of __privateGet(this, _sessionContextByNetwork).values()) {
81
+ await this.setSession(context, null);
82
+ await (0, import_idb_keyval.clear)(context.idbStore);
86
83
  }
87
84
  }
88
- async setSession(state, newValue) {
85
+ async setSession(context, newValue) {
89
86
  if (newValue) {
90
87
  const storedValue = await __privateGet(this, _encryption).encrypt(
91
88
  __privateGet(this, _encryptionKey),
92
89
  JSON.stringify(newValue)
93
90
  );
94
- __privateGet(this, _sessionStore).set(state.storageKey, storedValue);
91
+ await (0, import_idb_keyval.set)(sessionKey, storedValue, context.idbStore);
95
92
  } else {
96
- __privateGet(this, _sessionStore).delete(state.storageKey);
93
+ await (0, import_idb_keyval.del)(sessionKey, context.idbStore);
97
94
  }
98
- state.$zkLoginSession.set({ initialized: true, value: newValue });
95
+ context.$zkLoginSession.set({ initialized: true, value: newValue });
99
96
  }
100
- async getSession({ $zkLoginSession, storageKey }) {
97
+ async getSession({ $zkLoginSession, idbStore }) {
101
98
  if ($zkLoginSession.get().initialized) {
102
99
  return $zkLoginSession.get().value;
103
100
  }
104
101
  try {
105
- const storedValue = __privateGet(this, _sessionStore).get(storageKey);
102
+ const storedValue = await (0, import_idb_keyval.get)(sessionKey, idbStore);
106
103
  if (!storedValue) return null;
107
104
  const state = JSON.parse(
108
105
  await __privateGet(this, _encryption).decrypt(__privateGet(this, _encryptionKey), storedValue)
@@ -120,24 +117,25 @@ class EnokiWalletState {
120
117
  }
121
118
  _encryption = new WeakMap();
122
119
  _encryptionKey = new WeakMap();
123
- _sessionStore = new WeakMap();
124
- _stateStorageKey = new WeakMap();
120
+ _stateStore = new WeakMap();
125
121
  _sessionContextByNetwork = new WeakMap();
126
122
  _zkLoginState = new WeakMap();
127
123
  _EnokiWalletState_instances = new WeakSet();
128
124
  createZkLoginState_fn = function() {
129
- const storage = (0, import_stores.createLocalStorage)();
130
- let storedState = null;
131
- try {
132
- const rawStoredValue = storage.get(__privateGet(this, _stateStorageKey));
133
- if (rawStoredValue) {
134
- storedState = JSON.parse(rawStoredValue);
135
- }
136
- } catch {
137
- }
138
- const $zkLoginState = (0, import_nanostores.atom)(storedState || {});
125
+ const $zkLoginState = (0, import_nanostores.atom)(null);
126
+ (0, import_nanostores.onMount)($zkLoginState, () => {
127
+ (0, import_nanostores.task)(async () => {
128
+ try {
129
+ const rawStoredValue = await (0, import_idb_keyval.get)(stateKey, __privateGet(this, _stateStore));
130
+ if (rawStoredValue) {
131
+ $zkLoginState.set(JSON.parse(rawStoredValue));
132
+ }
133
+ } catch {
134
+ }
135
+ });
136
+ });
139
137
  (0, import_nanostores.onSet)($zkLoginState, ({ newValue }) => {
140
- storage.set(__privateGet(this, _stateStorageKey), JSON.stringify(newValue));
138
+ (0, import_idb_keyval.set)(stateKey, JSON.stringify(newValue), __privateGet(this, _stateStore));
141
139
  });
142
140
  return $zkLoginState;
143
141
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/wallet/state.ts"],
4
- "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { clear, createStore } from 'idb-keyval';\nimport type { WritableAtom } from 'nanostores';\nimport { atom, onMount, onSet } from 'nanostores';\n\nimport type { Encryption } from '../encryption.js';\nimport { createDefaultEncryption } from '../encryption.js';\nimport type { EnokiClientConfig } from '../EnokiClient/index.js';\nimport type { ClientWithCoreApi, Experimental_SuiClientTypes } from '@mysten/sui/experimental';\nimport type { SyncStore } from '../stores.js';\nimport { createLocalStorage, createSessionStorage } from '../stores.js';\n\nimport type { EnokiSessionContext, ZkLoginSession, ZkLoginState } from './types.js';\n\nexport type EnokiWalletStateConfig = EnokiClientConfig & {\n\tclients: ClientWithCoreApi[];\n\tclientId: string;\n};\n\nexport class EnokiWalletState {\n\t#encryption: Encryption;\n\t#encryptionKey: string;\n\t#sessionStore: SyncStore;\n\t#stateStorageKey: string;\n\t#sessionContextByNetwork: Map<Experimental_SuiClientTypes.Network, EnokiSessionContext>;\n\t#zkLoginState: WritableAtom<ZkLoginState>;\n\n\tconstructor(config: EnokiWalletStateConfig) {\n\t\tthis.#encryptionKey = config.apiKey;\n\t\tthis.#encryption = createDefaultEncryption();\n\t\tthis.#sessionStore = createSessionStorage();\n\t\tthis.#stateStorageKey = `@enoki/flow/state/${config.apiKey}/${config.clientId}`;\n\t\tthis.#zkLoginState = this.#createZkLoginState();\n\n\t\tthis.#sessionContextByNetwork = config.clients.reduce((accumulator, client) => {\n\t\t\tconst network = client.network;\n\t\t\tconst storageKey = `@enoki/flow/session/${config.apiKey}/${network}/${config.clientId}`;\n\t\t\tconst idbStore = createStore(`${config.apiKey}_${network}_${config.clientId}`, 'enoki');\n\n\t\t\tconst sessionContext: EnokiSessionContext = {\n\t\t\t\t$zkLoginSession: atom({ initialized: false, value: null }),\n\t\t\t\tclient,\n\t\t\t\tstorageKey,\n\t\t\t\tidbStore,\n\t\t\t};\n\n\t\t\tonMount(sessionContext.$zkLoginSession, () => {\n\t\t\t\tthis.getSession(sessionContext);\n\t\t\t});\n\n\t\t\treturn accumulator.set(network, sessionContext);\n\t\t}, new Map());\n\t}\n\n\tget zkLoginState() {\n\t\treturn this.#zkLoginState;\n\t}\n\n\tget sessionContextByNetwork() {\n\t\treturn this.#sessionContextByNetwork;\n\t}\n\n\tgetSessionContext(network: Experimental_SuiClientTypes.Network) {\n\t\tconst context = this.#sessionContextByNetwork.get(network);\n\t\tif (!context) {\n\t\t\tthrow new Error(`The network ${network} isn't supported.`);\n\t\t}\n\n\t\treturn context;\n\t}\n\n\tasync logout() {\n\t\tthis.#zkLoginState.set({});\n\t\tthis.#sessionStore.delete(this.#stateStorageKey);\n\n\t\tfor (const state of this.#sessionContextByNetwork.values()) {\n\t\t\tawait clear(state.idbStore);\n\t\t\tawait this.setSession(state, null);\n\t\t}\n\t}\n\n\tasync setSession(state: EnokiSessionContext, newValue: ZkLoginSession | null) {\n\t\tif (newValue) {\n\t\t\tconst storedValue = await this.#encryption.encrypt(\n\t\t\t\tthis.#encryptionKey,\n\t\t\t\tJSON.stringify(newValue),\n\t\t\t);\n\n\t\t\tthis.#sessionStore.set(state.storageKey, storedValue);\n\t\t} else {\n\t\t\tthis.#sessionStore.delete(state.storageKey);\n\t\t}\n\n\t\tstate.$zkLoginSession.set({ initialized: true, value: newValue });\n\t}\n\n\tasync getSession({ $zkLoginSession, storageKey }: EnokiSessionContext) {\n\t\tif ($zkLoginSession.get().initialized) {\n\t\t\treturn $zkLoginSession.get().value;\n\t\t}\n\n\t\ttry {\n\t\t\tconst storedValue = this.#sessionStore.get(storageKey);\n\t\t\tif (!storedValue) return null;\n\n\t\t\tconst state: ZkLoginSession = JSON.parse(\n\t\t\t\tawait this.#encryption.decrypt(this.#encryptionKey, storedValue),\n\t\t\t);\n\n\t\t\tif (state?.expiresAt && Date.now() > state.expiresAt) {\n\t\t\t\tawait this.logout();\n\t\t\t} else {\n\t\t\t\t$zkLoginSession.set({ initialized: true, value: state });\n\t\t\t}\n\t\t} catch {\n\t\t\t$zkLoginSession.set({ initialized: true, value: null });\n\t\t}\n\n\t\treturn $zkLoginSession.get().value;\n\t}\n\n\t#createZkLoginState() {\n\t\tconst storage = createLocalStorage();\n\t\tlet storedState: ZkLoginState | null = null;\n\n\t\ttry {\n\t\t\tconst rawStoredValue = storage.get(this.#stateStorageKey);\n\t\t\tif (rawStoredValue) {\n\t\t\t\tstoredState = JSON.parse(rawStoredValue);\n\t\t\t}\n\t\t} catch {\n\t\t\t// Ignore errors\n\t\t}\n\n\t\tconst $zkLoginState = atom<ZkLoginState>(storedState || {});\n\n\t\tonSet($zkLoginState, ({ newValue }) => {\n\t\t\tstorage.set(this.#stateStorageKey, JSON.stringify(newValue));\n\t\t});\n\n\t\treturn $zkLoginState;\n\t}\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAAmC;AAEnC,wBAAqC;AAGrC,wBAAwC;AAIxC,oBAAyD;AAZzD;AAqBO,MAAM,iBAAiB;AAAA,EAQ7B,YAAY,QAAgC;AARtC;AACN;AACA;AACA;AACA;AACA;AACA;AAGC,uBAAK,gBAAiB,OAAO;AAC7B,uBAAK,iBAAc,2CAAwB;AAC3C,uBAAK,mBAAgB,oCAAqB;AAC1C,uBAAK,kBAAmB,qBAAqB,OAAO,MAAM,IAAI,OAAO,QAAQ;AAC7E,uBAAK,eAAgB,sBAAK,oDAAL;AAErB,uBAAK,0BAA2B,O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esContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { UseStore } from 'idb-keyval';\nimport { clear, createStore, del, get, set } from 'idb-keyval';\nimport type { WritableAtom } from 'nanostores';\nimport { atom, onMount, onSet, task } from 'nanostores';\n\nimport type { Encryption } from '../encryption.js';\nimport { createDefaultEncryption } from '../encryption.js';\nimport type { EnokiClientConfig } from '../EnokiClient/index.js';\nimport type { ClientWithCoreApi, Experimental_SuiClientTypes } from '@mysten/sui/experimental';\n\nimport type { EnokiSessionContext, ZkLoginSession, ZkLoginState } from './types.js';\n\nexport type EnokiWalletStateConfig = EnokiClientConfig & {\n\tclients: ClientWithCoreApi[];\n\tclientId: string;\n};\n\nconst sessionKey = 'zklogin-session';\n\nconst stateKey = 'zklogin-state';\n\nexport class EnokiWalletState {\n\t#encryption: Encryption;\n\t#encryptionKey: string;\n\n\t#stateStore: UseStore;\n\t#sessionContextByNetwork: Map<Experimental_SuiClientTypes.Network, EnokiSessionContext>;\n\t#zkLoginState: WritableAtom<ZkLoginState | null>;\n\n\tconstructor(config: EnokiWalletStateConfig) {\n\t\tthis.#encryptionKey = config.apiKey;\n\t\tthis.#encryption = createDefaultEncryption();\n\n\t\tthis.#stateStore = createStore(`${config.apiKey}_${config.clientId}`, 'enoki');\n\t\tthis.#zkLoginState = this.#createZkLoginState();\n\n\t\tthis.#sessionContextByNetwork = config.clients.reduce((accumulator, client) => {\n\t\t\tconst network = client.network;\n\t\t\tconst idbStore = createStore(`${config.apiKey}_${network}_${config.clientId}`, 'enoki');\n\n\t\t\tconst sessionContext: EnokiSessionContext = {\n\t\t\t\t$zkLoginSession: atom({ initialized: false, value: null }),\n\t\t\t\tclient,\n\t\t\t\tidbStore,\n\t\t\t};\n\n\t\t\tonMount(sessionContext.$zkLoginSession, () => {\n\t\t\t\tthis.getSession(sessionContext);\n\t\t\t});\n\n\t\t\treturn accumulator.set(network, sessionContext);\n\t\t}, new Map());\n\t}\n\n\tget zkLoginState() {\n\t\treturn this.#zkLoginState;\n\t}\n\n\tget sessionContextByNetwork() {\n\t\treturn this.#sessionContextByNetwork;\n\t}\n\n\tgetSessionContext(network: Experimental_SuiClientTypes.Network) {\n\t\tconst context = this.#sessionContextByNetwork.get(network);\n\t\tif (!context) {\n\t\t\tthrow new Error(`The network ${network} isn't supported.`);\n\t\t}\n\n\t\treturn context;\n\t}\n\n\tasync logout() {\n\t\tthis.#zkLoginState.set(null);\n\t\tawait clear(this.#stateStore);\n\n\t\tfor (const context of this.#sessionContextByNetwork.values()) {\n\t\t\tawait this.setSession(context, null);\n\t\t\tawait clear(context.idbStore);\n\t\t}\n\t}\n\n\tasync setSession(context: EnokiSessionContext, newValue: ZkLoginSession | null) {\n\t\tif (newValue) {\n\t\t\tconst storedValue = await this.#encryption.encrypt(\n\t\t\t\tthis.#encryptionKey,\n\t\t\t\tJSON.stringify(newValue),\n\t\t\t);\n\n\t\t\tawait set(sessionKey, storedValue, context.idbStore);\n\t\t} else {\n\t\t\tawait del(sessionKey, context.idbStore);\n\t\t}\n\n\t\tcontext.$zkLoginSession.set({ initialized: true, value: newValue });\n\t}\n\n\tasync getSession({ $zkLoginSession, idbStore }: EnokiSessionContext) {\n\t\tif ($zkLoginSession.get().initialized) {\n\t\t\treturn $zkLoginSession.get().value;\n\t\t}\n\n\t\ttry {\n\t\t\tconst storedValue = await get(sessionKey, idbStore);\n\t\t\tif (!storedValue) return null;\n\n\t\t\tconst state: ZkLoginSession = JSON.parse(\n\t\t\t\tawait this.#encryption.decrypt(this.#encryptionKey, storedValue),\n\t\t\t);\n\n\t\t\tif (state?.expiresAt && Date.now() > state.expiresAt) {\n\t\t\t\tawait this.logout();\n\t\t\t} else {\n\t\t\t\t$zkLoginSession.set({ initialized: true, value: state });\n\t\t\t}\n\t\t} catch {\n\t\t\t$zkLoginSession.set({ initialized: true, value: null });\n\t\t}\n\n\t\treturn $zkLoginSession.get().value;\n\t}\n\n\t#createZkLoginState() {\n\t\tconst $zkLoginState = atom<ZkLoginState | null>(null);\n\n\t\tonMount($zkLoginState, () => {\n\t\t\ttask(async () => {\n\t\t\t\ttry {\n\t\t\t\t\tconst rawStoredValue = await get<string>(stateKey, this.#stateStore);\n\t\t\t\t\tif (rawStoredValue) {\n\t\t\t\t\t\t$zkLoginState.set(JSON.parse(rawStoredValue));\n\t\t\t\t\t}\n\t\t\t\t} catch {\n\t\t\t\t\t// Ignore errors\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\n\t\tonSet($zkLoginState, ({ newValue }) => {\n\t\t\tset(stateKey, JSON.stringify(newValue), this.#stateStore);\n\t\t});\n\n\t\treturn $zkLoginState;\n\t}\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,wBAAkD;AAElD,wBAA2C;AAG3C,wBAAwC;AATxC;AAoBA,MAAM,aAAa;AAEnB,MAAM,WAAW;AAEV,MAAM,iBAAiB;AAAA,EAQ7B,YAAY,QAAgC;AARtC;AACN;AACA;AAEA;AACA;AACA;AAGC,uBAAK,gBAAiB,OAAO;AAC7B,uBAAK,iBAAc,2CAAwB;AAE3C,uBAAK,iBAAc,+BAAY,GAAG,OAAO,MAAM,IAAI,OAAO,QAAQ,IAAI,OAAO;AAC7E,uBAAK,eAAgB,sBAAK,oDAAL;AAErB,uBAAK,0BAA2B,OAAO,QAAQ,OAAO,CAAC,aAAa,WAAW;AAC9E,YAAM,UAAU,OAAO;AACvB,YAAM,eAAW,+BAAY,GAAG,OAAO,MAAM,IAAI,OAAO,IAAI,OAAO,QAAQ,IAAI,OAAO;AAEtF,YAAM,iBAAsC;AAAA,QAC3C,qBAAiB,wBAAK,EAAE,aAAa,OAAO,OAAO,KAAK,CAAC;AAAA,QACzD;AAAA,QACA;AAAA,MACD;AAEA,qCAAQ,eAAe,iBAAiB,MAAM;AAC7C,aAAK,WAAW,cAAc;AAAA,MAC/B,CAAC;AAED,aAAO,YAAY,IAAI,SAAS,cAA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AA,MAChE;AAEA,UAAI,OAAO,aAAa,KAAK,IAAI,IAAI,MAAM,WAAW;AACrD,cAAM,KAAK,OAAO;AAAA,MACnB,OAAO;AACN,wBAAgB,IAAI,EAAE,aAAa,MAAM,OAAO,MAAM,CAAC;AAAA,MACxD;AAAA,IACD,QAAQ;AACP,sBAAgB,IAAI,EAAE,aAAa,MAAM,OAAO,KAAK,CAAC;AAAA,IACvD;AAEA,WAAO,gBAAgB,IAAI,EAAE;AAAA,EAC9B;AAwBD;AAzHC;AACA;AAEA;AACA;AACA;AANM;AAoGN,wBAAmB,WAAG;AACrB,QAAM,oBAAgB,wBAA0B,IAAI;AAEpD,iCAAQ,eAAe,MAAM;AAC5B,gCAAK,YAAY;AAChB,UAAI;AACH,cAAM,iBAAiB,UAAM,uBAAY,UAAU,mBAAK,YAAW;AACnE,YAAI,gBAAgB;AACnB,wBAAc,IAAI,KAAK,MAAM,cAAc,CAAC;AAAA,QAC7C;AAAA,MACD,QAAQ;AAAA,MAER;AAAA,IACD,CAAC;AAAA,EACF,CAAC;AAED,+BAAM,eAAe,CAAC,EAAE,SAAS,MAAM;AACtC,+BAAI,UAAU,KAAK,UAAU,QAAQ,GAAG,mBAAK,YAAW;AAAA,EACzD,CAAC;AAED,SAAO;AACR;",
6
6
  "names": []
7
7
  }
@@ -10,8 +10,8 @@ export type WalletEventsMap = {
10
10
  [E in keyof StandardEventsListeners]: Parameters<StandardEventsListeners[E]>[0];
11
11
  };
12
12
  export type ZkLoginState = {
13
- address?: string;
14
- publicKey?: string;
13
+ address: string;
14
+ publicKey: string;
15
15
  };
16
16
  export type ZkLoginSession = {
17
17
  maxEpoch: number;
@@ -23,18 +23,32 @@ export type ZkLoginSession = {
23
23
  export type EnokiSessionContext = {
24
24
  idbStore: UseStore;
25
25
  client: ClientWithCoreApi;
26
- storageKey: string;
27
26
  $zkLoginSession: WritableAtom<{
28
27
  initialized: boolean;
29
28
  value: ZkLoginSession | null;
30
29
  }>;
31
30
  };
32
- export type EnokiWalletOptions = {
33
- provider: AuthProvider;
34
- windowFeatures?: string | (() => string);
31
+ type ClientConfig = {
32
+ /**
33
+ * A list of client instances to use when building and executing transactions.
34
+ */
35
35
  clients: ClientWithCoreApi[];
36
+ /**
37
+ * A function that returns the current network that the application is acting on.
38
+ */
36
39
  getCurrentNetwork: () => Experimental_SuiClientTypes.Network;
37
- } & AuthProviderOptions & EnokiClientConfig & Pick<Wallet, 'name' | 'icon'>;
40
+ };
41
+ export type EnokiWalletOptions = {
42
+ /**
43
+ * The window features to use when opening the authorization popup.
44
+ * https://developer.mozilla.org/en-US/docs/Web/API/Window/open#windowfeatures
45
+ */
46
+ windowFeatures?: string | (() => string);
47
+ /**
48
+ * The authentication provider to register the wallet for.
49
+ */
50
+ provider: AuthProvider;
51
+ } & AuthProviderOptions & EnokiClientConfig & ClientConfig & Pick<Wallet, 'name' | 'icon'>;
38
52
  export type AuthProviderOptions = {
39
53
  /**
40
54
  * The OAuth client ID.
@@ -49,24 +63,12 @@ export type AuthProviderOptions = {
49
63
  */
50
64
  extraParams?: Record<string, string> | (() => Record<string, string>);
51
65
  };
52
- export type RegisterEnokiWalletsOptions = EnokiClientConfig & {
66
+ export type RegisterEnokiWalletsOptions = {
53
67
  /**
54
68
  * Configuration for each OAuth provider.
55
69
  */
56
70
  providers: Partial<Record<AuthProvider, AuthProviderOptions>>;
57
- /**
58
- * The window features to use when opening the authorization popup.
59
- * https://developer.mozilla.org/en-US/docs/Web/API/Window/open#windowfeatures
60
- */
61
- windowFeatures?: string | (() => string);
62
- } & ({
63
- /**
64
- * A list of client instances to use when building and executing transactions.
65
- */
66
- clients: ClientWithCoreApi[];
67
- /** A function that returns the current network that the application is acting on. */
68
- getCurrentNetwork: () => Experimental_SuiClientTypes.Network;
69
- } | {
71
+ } & Pick<EnokiWalletOptions, 'apiKey' | 'apiUrl' | 'windowFeatures'> & (ClientConfig | {
70
72
  /**
71
73
  * The SuiClient instance to use when building and executing transactions.
72
74
  */
@@ -77,3 +79,4 @@ export type RegisterEnokiWalletsOptions = EnokiClientConfig & {
77
79
  */
78
80
  network?: EnokiNetwork;
79
81
  });
82
+ export {};
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/wallet/types.ts"],
4
- "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { SuiClient } from '@mysten/sui/client';\nimport type { StandardEventsListeners, Wallet } from '@mysten/wallet-standard';\n\nimport type { EnokiClientConfig } from '../EnokiClient/index.js';\nimport type { AuthProvider, EnokiNetwork } from '../EnokiClient/type.js';\nimport type { ClientWithCoreApi, Experimental_SuiClientTypes } from '@mysten/sui/experimental';\nimport type { ZkLoginSignatureInputs } from '@mysten/sui/zklogin';\nimport type { UseStore } from 'idb-keyval';\nimport type { WritableAtom } from 'nanostores';\n\nexport type WalletEventsMap = {\n\t[E in keyof StandardEventsListeners]: Parameters<StandardEventsListeners[E]>[0];\n};\n\nexport type ZkLoginState = {\n\taddress?: string;\n\tpublicKey?: string;\n};\n\nexport type ZkLoginSession = {\n\tmaxEpoch: number;\n\trandomness: string;\n\texpiresAt: number;\n\tjwt?: string;\n\tproof?: ZkLoginSignatureInputs;\n};\n\nexport type EnokiSessionContext = {\n\tidbStore: UseStore;\n\tclient: ClientWithCoreApi;\n\tstorageKey: string;\n\t$zkLoginSession: WritableAtom<{ initialized: boolean; value: ZkLoginSession | null }>;\n};\n\nexport type EnokiWalletOptions = {\n\tprovider: AuthProvider;\n\twindowFeatures?: string | (() => string);\n\tclients: ClientWithCoreApi[];\n\tgetCurrentNetwork: () => Experimental_SuiClientTypes.Network;\n} & AuthProviderOptions &\n\tEnokiClientConfig &\n\tPick<Wallet, 'name' | 'icon'>;\n\nexport type AuthProviderOptions = {\n\t/**\n\t * The OAuth client ID.\n\t */\n\tclientId: string;\n\n\t/**\n\t * The URL to redirect to after authorization.\n\t */\n\tredirectUrl?: string;\n\n\t/**\n\t * Extra parameters to include in the authorization URL.\n\t */\n\textraParams?: Record<string, string> | (() => Record<string, string>);\n};\n\nexport type RegisterEnokiWalletsOptions = EnokiClientConfig & {\n\t/**\n\t * Configuration for each OAuth provider.\n\t */\n\tproviders: Partial<Record<AuthProvider, AuthProviderOptions>>;\n\n\t/**\n\t * The window features to use when opening the authorization popup.\n\t * https://developer.mozilla.org/en-US/docs/Web/API/Window/open#windowfeatures\n\t */\n\twindowFeatures?: string | (() => string);\n} & (\n\t\t| {\n\t\t\t\t/**\n\t\t\t\t * A list of client instances to use when building and executing transactions.\n\t\t\t\t */\n\t\t\t\tclients: ClientWithCoreApi[];\n\n\t\t\t\t/** A function that returns the current network that the application is acting on. */\n\t\t\t\tgetCurrentNetwork: () => Experimental_SuiClientTypes.Network;\n\t\t }\n\t\t| {\n\t\t\t\t/**\n\t\t\t\t * The SuiClient instance to use when building and executing transactions.\n\t\t\t\t */\n\t\t\t\tclient: SuiClient;\n\n\t\t\t\t/**\n\t\t\t\t * The network to use when building and executing transactions.\n\t\t\t\t * @default 'mainnet'\n\t\t\t\t */\n\t\t\t\tnetwork?: EnokiNetwork;\n\t\t }\n\t);\n"],
4
+ "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { SuiClient } from '@mysten/sui/client';\nimport type { StandardEventsListeners, Wallet } from '@mysten/wallet-standard';\n\nimport type { EnokiClientConfig } from '../EnokiClient/index.js';\nimport type { AuthProvider, EnokiNetwork } from '../EnokiClient/type.js';\nimport type { ClientWithCoreApi, Experimental_SuiClientTypes } from '@mysten/sui/experimental';\nimport type { ZkLoginSignatureInputs } from '@mysten/sui/zklogin';\nimport type { UseStore } from 'idb-keyval';\nimport type { WritableAtom } from 'nanostores';\n\nexport type WalletEventsMap = {\n\t[E in keyof StandardEventsListeners]: Parameters<StandardEventsListeners[E]>[0];\n};\n\nexport type ZkLoginState = {\n\taddress: string;\n\tpublicKey: string;\n};\n\nexport type ZkLoginSession = {\n\tmaxEpoch: number;\n\trandomness: string;\n\texpiresAt: number;\n\tjwt?: string;\n\tproof?: ZkLoginSignatureInputs;\n};\n\nexport type EnokiSessionContext = {\n\tidbStore: UseStore;\n\tclient: ClientWithCoreApi;\n\t$zkLoginSession: WritableAtom<{ initialized: boolean; value: ZkLoginSession | null }>;\n};\n\ntype ClientConfig = {\n\t/**\n\t * A list of client instances to use when building and executing transactions.\n\t */\n\tclients: ClientWithCoreApi[];\n\n\t/**\n\t * A function that returns the current network that the application is acting on.\n\t */\n\tgetCurrentNetwork: () => Experimental_SuiClientTypes.Network;\n};\n\nexport type EnokiWalletOptions = {\n\t/**\n\t * The window features to use when opening the authorization popup.\n\t * https://developer.mozilla.org/en-US/docs/Web/API/Window/open#windowfeatures\n\t */\n\twindowFeatures?: string | (() => string);\n\n\t/**\n\t * The authentication provider to register the wallet for.\n\t */\n\tprovider: AuthProvider;\n} & AuthProviderOptions &\n\tEnokiClientConfig &\n\tClientConfig &\n\tPick<Wallet, 'name' | 'icon'>;\n\nexport type AuthProviderOptions = {\n\t/**\n\t * The OAuth client ID.\n\t */\n\tclientId: string;\n\n\t/**\n\t * The URL to redirect to after authorization.\n\t */\n\tredirectUrl?: string;\n\n\t/**\n\t * Extra parameters to include in the authorization URL.\n\t */\n\textraParams?: Record<string, string> | (() => Record<string, string>);\n};\n\nexport type RegisterEnokiWalletsOptions = {\n\t/**\n\t * Configuration for each OAuth provider.\n\t */\n\tproviders: Partial<Record<AuthProvider, AuthProviderOptions>>;\n} & Pick<EnokiWalletOptions, 'apiKey' | 'apiUrl' | 'windowFeatures'> &\n\t(\n\t\t| ClientConfig\n\t\t| {\n\t\t\t\t/**\n\t\t\t\t * The SuiClient instance to use when building and executing transactions.\n\t\t\t\t */\n\t\t\t\tclient: SuiClient;\n\n\t\t\t\t/**\n\t\t\t\t * The network to use when building and executing transactions.\n\t\t\t\t * @default 'mainnet'\n\t\t\t\t */\n\t\t\t\tnetwork?: EnokiNetwork;\n\t\t }\n\t);\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
6
6
  "names": []
7
7
  }
@@ -1,9 +1,11 @@
1
1
  import type { Wallet } from '@mysten/wallet-standard';
2
2
  import type { UiWallet } from '@wallet-standard/ui';
3
3
  import type { EnokiWallet } from './wallet.js';
4
+ import type { EnokiGetSessionInput } from './features.js';
4
5
  export declare function isEnokiWallet(wallet: UiWallet): boolean;
5
6
  export declare function isEnokiWallet(wallet: Wallet): wallet is EnokiWallet;
6
- export declare function getWalletMetadata(wallet: Wallet | UiWallet): import("./feature.js").EnokiGetMetadataOutput | null;
7
+ export declare function getWalletMetadata(wallet: Wallet | UiWallet): import("./features.js").EnokiGetMetadataOutput | null;
8
+ export declare function getSession(wallet: Wallet | UiWallet, input?: EnokiGetSessionInput): Promise<import("./features.js").EnokiGetSessionOutput>;
7
9
  export declare function isGoogleWallet(wallet: Wallet | UiWallet): boolean;
8
10
  export declare function isTwitchWallet(wallet: Wallet | UiWallet): boolean;
9
11
  export declare function isFacebookWallet(wallet: Wallet | UiWallet): boolean;
@@ -18,6 +18,7 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var utils_exports = {};
20
20
  __export(utils_exports, {
21
+ getSession: () => getSession,
21
22
  getWalletMetadata: () => getWalletMetadata,
22
23
  isEnokiWallet: () => isEnokiWallet,
23
24
  isFacebookWallet: () => isFacebookWallet,
@@ -26,27 +27,44 @@ __export(utils_exports, {
26
27
  });
27
28
  module.exports = __toCommonJS(utils_exports);
28
29
  var import_ui = require("@wallet-standard/ui");
29
- var import_feature = require("./feature.js");
30
+ var import_features = require("./features.js");
30
31
  function isEnokiWallet(wallet) {
31
32
  if (isWalletHandle(wallet)) {
32
- return wallet.features.includes(import_feature.EnokiGetMetadata);
33
+ return wallet.features.includes(import_features.EnokiGetMetadata);
33
34
  }
34
- return import_feature.EnokiGetMetadata in wallet.features;
35
+ return import_features.EnokiGetMetadata in wallet.features;
35
36
  }
36
37
  function getWalletMetadata(wallet) {
37
38
  if (isWalletHandle(wallet)) {
38
39
  try {
39
40
  const { getMetadata } = (0, import_ui.getWalletFeature)(
40
41
  wallet,
41
- import_feature.EnokiGetMetadata
42
+ import_features.EnokiGetMetadata
42
43
  );
43
44
  return getMetadata();
44
45
  } catch (error) {
45
46
  return null;
46
47
  }
47
- } else if (import_feature.EnokiGetMetadata in wallet.features) {
48
+ } else if (import_features.EnokiGetMetadata in wallet.features) {
48
49
  const walletWithFeature = wallet;
49
- return walletWithFeature.features[import_feature.EnokiGetMetadata].getMetadata();
50
+ return walletWithFeature.features[import_features.EnokiGetMetadata].getMetadata();
51
+ }
52
+ return null;
53
+ }
54
+ async function getSession(wallet, input) {
55
+ if (isWalletHandle(wallet)) {
56
+ try {
57
+ const { getSession: getSession2 } = (0, import_ui.getWalletFeature)(
58
+ wallet,
59
+ import_features.EnokiGetSession
60
+ );
61
+ return await getSession2(input);
62
+ } catch (error) {
63
+ return null;
64
+ }
65
+ } else if (import_features.EnokiGetSession in wallet.features) {
66
+ const walletWithFeature = wallet;
67
+ return await walletWithFeature.features[import_features.EnokiGetSession].getSession(input);
50
68
  }
51
69
  return null;
52
70
  }